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.

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