Mixer: Fix automatic row layout logic.

pull/3/head
Jonathan Moore Liles 2010-02-04 07:45:56 -06:00
parent 2f74b4dd02
commit 6015dc164a
3 changed files with 26 additions and 14 deletions

View File

@ -370,26 +370,37 @@ Mixer::contains ( Mixer_Strip *ms )
return ms->parent() == mixer_strips; return ms->parent() == mixer_strips;
} }
/* set the ideal number of rows... All may not actually fit. */
void void
Mixer::rows ( int n ) Mixer::rows ( int ideal_rows )
{ {
int sh; int sh;
if ( n > 1 ) int actual_rows = 1;
if ( ideal_rows > 1 )
{ {
sh = (scroll->h() / n) - (mixer_strips->vspacing() * (n - 1)); sh = (scroll->h() / ideal_rows ) - (mixer_strips->vspacing() * (ideal_rows - 1));
mixer_strips->flow( true ); mixer_strips->flow( true );
}
else
{
sh = (scroll->h() - 18) / n;
mixer_strips->flow( false );
}
if ( sh < Mixer_Strip::min_h() ) if ( sh < Mixer_Strip::min_h() )
{ {
rows( ( scroll->h() - 18 ) / Mixer_Strip::min_h() ); int can_fit = ( scroll->h() - 18 ) / Mixer_Strip::min_h();
return;
actual_rows = can_fit > 0 ? can_fit : 1;
}
else
actual_rows = ideal_rows;
}
else
actual_rows = 1;
if ( 1 == actual_rows )
{
sh = (scroll->h() - 18);
mixer_strips->flow( false );
actual_rows = 1;
} }
int tw = 0; int tw = 0;
@ -403,12 +414,12 @@ Mixer::rows ( int n )
tw += t->w() + mixer_strips->hspacing(); tw += t->w() + mixer_strips->hspacing();
} }
if ( n > 1 ) if ( actual_rows > 1 )
mixer_strips->size( scroll->w() - 18, mixer_strips->h() ); mixer_strips->size( scroll->w() - 18, mixer_strips->h() );
else else
mixer_strips->size( tw, mixer_strips->h() ); mixer_strips->size( tw, mixer_strips->h() );
_rows = n; _rows = ideal_rows;
scroll->redraw(); scroll->redraw();
} }

View File

@ -64,6 +64,7 @@ protected:
public: public:
int min_h ( void ) const { return Mixer_Strip::min_h() + (18 * 2); }
void rows ( int n ); void rows ( int n );
virtual void resize ( int X, int Y, int W, int H ); virtual void resize ( int X, int Y, int W, int H );

View File

@ -54,7 +54,7 @@ class Mixer_Strip : public Fl_Group, public Loggable {
public: public:
static int min_h ( void ) { return 250; } static int min_h ( void ) { return 336; }
Mixer_Strip( const char *strip_name ); Mixer_Strip( const char *strip_name );
Mixer_Strip(); /* for log create */ Mixer_Strip(); /* for log create */