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.

127 lines
3.4KB

  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. bool _flow;
  26. public:
  27. Fl_Flowpack ( int X, int Y, int W, int H, const char *L = 0 )
  28. : Fl_Group( X, Y, W, H, L )
  29. {
  30. resizable( 0 );
  31. _max_width = _hspacing = _vspacing = 0;
  32. _flow = true;
  33. }
  34. virtual ~Fl_Flowpack ( )
  35. {
  36. }
  37. int max_width ( void ) const { return _max_width; }
  38. void vspacing ( int v ) { _vspacing = v; }
  39. int vspacing ( void ) const { return _vspacing; };
  40. void hspacing ( int h ) { _hspacing = h; }
  41. int hspacing ( void ) const { return _hspacing; };
  42. bool flow ( void ) const { return _flow; }
  43. void flow ( bool v ) { _flow = v; }
  44. void
  45. add ( Fl_Widget *w )
  46. {
  47. Fl_Group::add( w );
  48. dolayout();
  49. }
  50. void
  51. remove ( Fl_Widget *w )
  52. {
  53. Fl_Group::remove( w );
  54. dolayout();
  55. }
  56. void
  57. resize ( int X, int Y, int W, int )
  58. {
  59. Fl_Group::resize( X, Y, W, layout( W ) );
  60. }
  61. void
  62. draw ( void )
  63. {
  64. dolayout();
  65. Fl_Group::draw();
  66. }
  67. void dolayout ( void )
  68. {
  69. size( w(), layout( w() ) );
  70. }
  71. int
  72. layout ( int W )
  73. {
  74. resizable( 0 );
  75. int X = 0;
  76. int Y = 0;
  77. int H = 0;
  78. _max_width = 0;
  79. for ( int i = 0; i < children(); ++i )
  80. {
  81. Fl_Widget *o = child( i );
  82. if ( ! o->visible() )
  83. continue;
  84. H = o->h() > H ? o->h() : H;
  85. if ( _flow && X + o->w() >= W )
  86. {
  87. Y += H + _vspacing;
  88. H = o->h();
  89. X = 0;
  90. }
  91. o->position( x() + X, y() + Y );
  92. X += o->w() + _hspacing;
  93. if ( X > _max_width )
  94. _max_width = X;
  95. }
  96. return Y + H;
  97. }
  98. };