diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index fbe0e16ab7..9a73a6272f 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2265,6 +2265,10 @@ Editor::set_state (const XMLNode& node, int /*version*/) reset_zoom (samples_per_pixel); } + if ((prop = node.property ("visible-track-count"))) { + set_visible_track_count (PBD::atoi (prop->value())); + } + if ((prop = node.property ("snap-to"))) { set_snap_to ((SnapType) string_2_enum (prop->value(), _snap_type)); } @@ -2496,6 +2500,8 @@ Editor::get_state () node->add_property ("pre-internal-snap-to", enum_2_string (pre_internal_snap_type)); node->add_property ("pre-internal-snap-mode", enum_2_string (pre_internal_snap_mode)); node->add_property ("edit-point", enum_2_string (_edit_point)); + snprintf (buf, sizeof(buf), "%d", _visible_track_count); + node->add_property ("visible-track-count", buf); snprintf (buf, sizeof (buf), "%" PRIi64, playhead_cursor->current_frame ()); node->add_property ("playhead", buf); @@ -3482,18 +3488,24 @@ Editor::build_track_count_menu () visible_tracks_selector.AddMenuElem (MenuElem (X_("24"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 24))); visible_tracks_selector.AddMenuElem (MenuElem (X_("32"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 32))); visible_tracks_selector.AddMenuElem (MenuElem (X_("64"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 64))); - visible_tracks_selector.AddMenuElem (MenuElem (_("all"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), -1))); + visible_tracks_selector.AddMenuElem (MenuElem (_("all"), sigc::bind (sigc::mem_fun(*this, &Editor::set_visible_track_count), 0))); } void Editor::set_visible_track_count (int32_t n) { - if (n == _visible_track_count && !visible_tracks_selector.get_text().empty()) { + _visible_track_count = n; + + /* if the canvas hasn't really been allocated any size yet, just + record the desired number of visible tracks and return. when canvas + allocation happens, we will get called again and then we can do the + real work. + */ + + if (_visible_canvas_height <= 1) { return; } - _visible_track_count = n; - int h; string str; @@ -3502,11 +3514,17 @@ Editor::set_visible_track_count (int32_t n) std::ostringstream s; s << _visible_track_count; str = s.str(); - } else { + } else if (_visible_track_count == 0) { h = _visible_canvas_height / track_views.size(); str = _("all"); + } else { + /* negative value means that the visible track count has + been overridden by explicit track height changes. + */ + visible_tracks_selector.set_text (X_("*")); + return; } - + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { (*i)->set_height (h); } @@ -3516,6 +3534,12 @@ Editor::set_visible_track_count (int32_t n) } } +void +Editor::override_visible_track_count () +{ + _visible_track_count = -_visible_track_count; +} + bool Editor::edit_controls_button_release (GdkEventButton* ev) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index a33bf39693..ea7908c64e 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -128,7 +128,7 @@ class VerboseCursor; class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr { - public: + public: Editor (); ~Editor (); @@ -450,6 +450,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD ArdourCanvas::GtkCanvasViewport* get_time_bars_canvas () const; ArdourCanvas::GtkCanvasViewport* get_track_canvas () const; + void override_visible_track_count (); protected: void map_transport_state (); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 4c0ca25eb5..b88c7e3ef7 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -283,6 +283,8 @@ Editor::track_canvas_viewport_size_allocated () */ vertical_adjustment.set_value (_full_canvas_height - _visible_canvas_height); } + + set_visible_track_count (_visible_track_count); } update_fixed_rulers(); diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 66f8ca9aa0..9a1af4b577 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -270,6 +270,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi virtual void ensure_time_axis_view_is_visible (const TimeAxisView& tav, bool at_top = false) { _ensure_time_axis_view_is_visible (tav, at_top); } + virtual void override_visible_track_count () = 0; virtual void scroll_tracks_down_line () = 0; virtual void scroll_tracks_up_line () = 0; virtual bool scroll_down_one_track () = 0; diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index cbd2b995fe..f67ca6a3ce 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -524,6 +524,8 @@ TimeAxisView::set_height (uint32_t h) /* resize the selection rect */ show_selection (_editor.get_selection().time); } + + _editor.override_visible_track_count (); } bool