add API to select TAV height mode.

preparation for further Summary and Number of visible
track count fixes.

* “Only Self”: don’t resize child-views (old default)
* “Total Height”: distribute height equally among 
   all visible child [automation] lanes
* “Height per Lane”: given height should be applied
   to all sub-views.
This commit is contained in:
Robin Gareus 2015-03-19 21:47:34 +01:00
parent 6874bca886
commit f1ce87a699
8 changed files with 31 additions and 11 deletions

View file

@ -454,13 +454,13 @@ AutomationTimeAxisView::clear_clicked ()
} }
void void
AutomationTimeAxisView::set_height (uint32_t h) AutomationTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
{ {
bool const changed = (height != (uint32_t) h) || first_call_to_set_height; bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
uint32_t const normal = preset_height (HeightNormal); uint32_t const normal = preset_height (HeightNormal);
bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) ); bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
TimeAxisView::set_height (h); TimeAxisView::set_height (h, m);
_base_rect->set_y1 (h); _base_rect->set_y1 (h);

View file

@ -69,7 +69,7 @@ class AutomationTimeAxisView : public TimeAxisView {
~AutomationTimeAxisView(); ~AutomationTimeAxisView();
virtual void set_height (uint32_t); virtual void set_height (uint32_t, TrackHeightMode m = OnlySelf);
void set_samples_per_pixel (double); void set_samples_per_pixel (double);
std::string name() const { return _name; } std::string name() const { return _name; }

View file

@ -467,7 +467,7 @@ MidiTimeAxisView::midi_view()
} }
void void
MidiTimeAxisView::set_height (uint32_t h) MidiTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
{ {
if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) { if (h >= MIDI_CONTROLS_BOX_MIN_HEIGHT) {
_midi_controls_box.show (); _midi_controls_box.show ();
@ -496,7 +496,7 @@ MidiTimeAxisView::set_height (uint32_t h)
which needs to know if we have just shown or hidden a scroomer / which needs to know if we have just shown or hidden a scroomer /
piano roll. piano roll.
*/ */
RouteTimeAxisView::set_height (h); RouteTimeAxisView::set_height (h, m);
} }
void void

View file

@ -78,7 +78,7 @@ public:
MidiStreamView* midi_view(); MidiStreamView* midi_view();
void set_height (uint32_t); void set_height (uint32_t, TrackHeightMode m = OnlySelf);
boost::shared_ptr<ARDOUR::MidiRegion> add_region (ARDOUR::framepos_t, ARDOUR::framecnt_t, bool); boost::shared_ptr<ARDOUR::MidiRegion> add_region (ARDOUR::framepos_t, ARDOUR::framecnt_t, bool);

View file

@ -961,7 +961,7 @@ RouteTimeAxisView::show_selection (TimeSelection& ts)
} }
void void
RouteTimeAxisView::set_height (uint32_t h) RouteTimeAxisView::set_height (uint32_t h, TrackHeightMode m)
{ {
int gmlen = h - 9; int gmlen = h - 9;
bool height_changed = (height == 0) || (h != height); bool height_changed = (height == 0) || (h != height);
@ -972,7 +972,7 @@ RouteTimeAxisView::set_height (uint32_t h)
} }
gm.get_level_meter().setup_meters (gmlen, meter_width); gm.get_level_meter().setup_meters (gmlen, meter_width);
TimeAxisView::set_height (h); TimeAxisView::set_height (h, m);
if (_view) { if (_view) {
_view->set_height ((double) current_height()); _view->set_height ((double) current_height());

View file

@ -84,7 +84,7 @@ public:
void set_button_names (); void set_button_names ();
void set_samples_per_pixel (double); void set_samples_per_pixel (double);
void set_height (uint32_t h); void set_height (uint32_t h, TrackHeightMode m = OnlySelf);
void show_timestretch (framepos_t start, framepos_t end, int layers, int layer); void show_timestretch (framepos_t start, framepos_t end, int layers, int layer);
void hide_timestretch (); void hide_timestretch ();
void selection_click (GdkEventButton*); void selection_click (GdkEventButton*);

View file

@ -568,8 +568,16 @@ TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
} }
void void
TimeAxisView::set_height (uint32_t h) TimeAxisView::set_height (uint32_t h, TrackHeightMode m)
{ {
uint32_t lanes = 0;
if (m == TotalHeight) {
for (Children::iterator i = children.begin(); i != children.end(); ++i) {
if ( !(*i)->hidden()) ++lanes;
}
}
h /= (lanes + 1);
if (h < preset_height (HeightSmall)) { if (h < preset_height (HeightSmall)) {
h = preset_height (HeightSmall); h = preset_height (HeightSmall);
} }
@ -590,6 +598,12 @@ TimeAxisView::set_height (uint32_t h)
show_selection (_editor.get_selection().time); show_selection (_editor.get_selection().time);
} }
if (m != OnlySelf) {
for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->set_height(h, OnlySelf);
}
}
_editor.override_visible_track_count (); _editor.override_visible_track_count ();
} }

View file

@ -142,7 +142,13 @@ class TimeAxisView : public virtual AxisView
virtual void entered () {} virtual void entered () {}
virtual void exited () {} virtual void exited () {}
virtual void set_height (uint32_t h); enum TrackHeightMode {
OnlySelf,
TotalHeight,
HeightPerLane
};
virtual void set_height (uint32_t h, TrackHeightMode m = OnlySelf);
void set_height_enum (Height, bool apply_to_selection = false); void set_height_enum (Height, bool apply_to_selection = false);
void reset_height(); void reset_height();