Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.3KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2009 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #pragma once
  19. #include <FL/Fl_Group.H>
  20. class Fl_Flowpack : public Fl_Group
  21. {
  22. int _hspacing;
  23. int _vspacing;
  24. int _max_width;
  25. public:
  26. Fl_Flowpack ( int X, int Y, int W, int H, const char *L = 0 )
  27. : Fl_Group( X, Y, W, H, L )
  28. {
  29. resizable( 0 );
  30. _max_width = _hspacing = _vspacing = 0;
  31. }
  32. int max_width ( void ) const { return _max_width; }
  33. void vspacing ( int v ) { _vspacing = v; }
  34. int vspacing ( void ) const { return _vspacing; };
  35. void hspacing ( int h ) { _hspacing = h; }
  36. int hspacing ( void ) const { return _hspacing; };
  37. void
  38. add ( Fl_Widget *w )
  39. {
  40. Fl_Group::add( w );
  41. dolayout();
  42. }
  43. void
  44. remove ( Fl_Widget *w )
  45. {
  46. Fl_Group::remove( w );
  47. dolayout();
  48. }
  49. void
  50. resize ( int X, int Y, int W, int )
  51. {
  52. Fl_Group::resize( X, Y, W, layout( W ) );
  53. }
  54. void
  55. draw ( void )
  56. {
  57. dolayout();
  58. Fl_Group::draw();
  59. }
  60. void dolayout ( void )
  61. {
  62. size( w(), layout( w() ) );
  63. }
  64. int
  65. layout ( int W )
  66. {
  67. resizable( 0 );
  68. int X = 0;
  69. int Y = 0;
  70. int H = 0;
  71. _max_width = 0;
  72. for ( int i = 0; i < children(); ++i )
  73. {
  74. Fl_Widget *o = child( i );
  75. if ( ! o->visible() )
  76. continue;
  77. H = o->h() > H ? o->h() : H;
  78. if ( X + o->w() >= W )
  79. {
  80. Y += H + _vspacing;
  81. H = o->h();
  82. X = 0;
  83. }
  84. o->position( x() + X, y() + Y );
  85. X += o->w() + _hspacing;
  86. if ( X > _max_width )
  87. _max_width = X;
  88. }
  89. return Y + H;
  90. }
  91. };