From 6015dc164a6c1190d3d014526f01c0ddf61ddf52 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Thu, 4 Feb 2010 07:45:56 -0600 Subject: [PATCH] Mixer: Fix automatic row layout logic. --- mixer/src/Mixer.C | 35 +++++++++++++++++++++++------------ mixer/src/Mixer.H | 3 ++- mixer/src/Mixer_Strip.H | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/mixer/src/Mixer.C b/mixer/src/Mixer.C index ce0b13f..b7f71bc 100644 --- a/mixer/src/Mixer.C +++ b/mixer/src/Mixer.C @@ -370,26 +370,37 @@ Mixer::contains ( Mixer_Strip *ms ) return ms->parent() == mixer_strips; } +/* set the ideal number of rows... All may not actually fit. */ void -Mixer::rows ( int n ) +Mixer::rows ( int ideal_rows ) { 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 ); + + if ( sh < Mixer_Strip::min_h() ) + { + int can_fit = ( scroll->h() - 18 ) / Mixer_Strip::min_h(); + + actual_rows = can_fit > 0 ? can_fit : 1; + } + else + actual_rows = ideal_rows; } else - { - sh = (scroll->h() - 18) / n; - mixer_strips->flow( false ); - } + actual_rows = 1; - if ( sh < Mixer_Strip::min_h() ) + if ( 1 == actual_rows ) { - rows( ( scroll->h() - 18 ) / Mixer_Strip::min_h() ); - return; + sh = (scroll->h() - 18); + mixer_strips->flow( false ); + + actual_rows = 1; } int tw = 0; @@ -403,12 +414,12 @@ Mixer::rows ( int n ) tw += t->w() + mixer_strips->hspacing(); } - if ( n > 1 ) + if ( actual_rows > 1 ) mixer_strips->size( scroll->w() - 18, mixer_strips->h() ); else mixer_strips->size( tw, mixer_strips->h() ); - _rows = n; + _rows = ideal_rows; scroll->redraw(); } diff --git a/mixer/src/Mixer.H b/mixer/src/Mixer.H index a76e3ac..54aab53 100644 --- a/mixer/src/Mixer.H +++ b/mixer/src/Mixer.H @@ -63,7 +63,8 @@ protected: int handle ( int m ); public: - + + int min_h ( void ) const { return Mixer_Strip::min_h() + (18 * 2); } void rows ( int n ); virtual void resize ( int X, int Y, int W, int H ); diff --git a/mixer/src/Mixer_Strip.H b/mixer/src/Mixer_Strip.H index 08727f3..32ce755 100644 --- a/mixer/src/Mixer_Strip.H +++ b/mixer/src/Mixer_Strip.H @@ -54,7 +54,7 @@ class Mixer_Strip : public Fl_Group, public Loggable { public: - static int min_h ( void ) { return 250; } + static int min_h ( void ) { return 336; } Mixer_Strip( const char *strip_name ); Mixer_Strip(); /* for log create */