From 596daa2b8baf420a82254e2dce14a47ecf916fc0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 26 Apr 2007 23:21:53 +0000 Subject: fix mixer-strip-width-not-restored, hopefully forever git-svn-id: svn://localhost/ardour2/trunk@1753 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 8 +++++++- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_mixer.cc | 16 ++++++++++++++-- gtk2_ardour/enums.cc | 6 ++++++ gtk2_ardour/mixer_strip.cc | 37 +++++++++++++++++-------------------- gtk2_ardour/mixer_strip.h | 6 ++++-- gtk2_ardour/mixer_ui.cc | 9 ++++++--- 7 files changed, 55 insertions(+), 28 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index a9a9a39511..d79bd5b2c7 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -2041,6 +2041,10 @@ Editor::set_state (const XMLNode& node) edit_cursor->set_position (0); } + if ((prop = node.property ("mixer-width"))) { + editor_mixer_strip_width = Width (string_2_enum (prop->value(), editor_mixer_strip_width)); + } + if ((prop = node.property ("zoom-focus"))) { set_zoom_focus ((ZoomFocus) atoi (prop->value())); } @@ -2181,6 +2185,8 @@ Editor::get_state () node->add_child_nocopy (*geometry); } + maybe_add_mixer_strip_width (*node); + snprintf (buf, sizeof(buf), "%d", (int) zoom_focus); node->add_property ("zoom-focus", buf); snprintf (buf, sizeof(buf), "%f", frames_per_unit); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ae7201dbbd..bbdc107652 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -264,6 +264,7 @@ class Editor : public PublicEditor TrackViewList* get_valid_views (TimeAxisView*, ARDOUR::RouteGroup* grp = 0); Width editor_mixer_strip_width; + void maybe_add_mixer_strip_width (XMLNode&); void show_editor_mixer (bool yn); void set_selected_mixer_strip (TimeAxisView&); void hide_track_in_display (TimeAxisView& tv); diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc index e37c7c7fe3..95f59d46d5 100644 --- a/gtk2_ardour/editor_mixer.cc +++ b/gtk2_ardour/editor_mixer.cc @@ -20,6 +20,9 @@ #include #include #include + +#include + #include #include "editor.h" @@ -32,6 +35,7 @@ #include "i18n.h" using namespace Gtkmm2ext; +using namespace PBD; void Editor::editor_mixer_button_toggled () @@ -107,8 +111,8 @@ Editor::show_editor_mixer (bool yn) current_mixer_strip->set_embedded (true); current_mixer_strip->Hiding.connect (mem_fun(*this, &Editor::current_mixer_strip_hidden)); current_mixer_strip->GoingAway.connect (mem_fun(*this, &Editor::current_mixer_strip_removed)); - current_mixer_strip->set_width (editor_mixer_strip_width); - + current_mixer_strip->set_width (editor_mixer_strip_width, (void*) this); + global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK ); global_hpacker.reorder_child (*current_mixer_strip, 0); @@ -355,3 +359,11 @@ Editor::session_going_away () session = 0; } + +void +Editor::maybe_add_mixer_strip_width (XMLNode& node) +{ + if (current_mixer_strip) { + node.add_property ("mixer-width", enum_2_string (current_mixer_strip->get_width())); + } +} diff --git a/gtk2_ardour/enums.cc b/gtk2_ardour/enums.cc index 9943d52258..e6c81598fb 100644 --- a/gtk2_ardour/enums.cc +++ b/gtk2_ardour/enums.cc @@ -20,6 +20,7 @@ #include #include "audio_clock.h" +#include "enums.h" using namespace std; using namespace PBD; @@ -33,6 +34,7 @@ setup_gtk_ardour_enums () vector s; AudioClock::Mode clock_mode; + Width width; #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear() @@ -45,4 +47,8 @@ setup_gtk_ardour_enums () REGISTER_CLASS_ENUM (AudioClock, Frames); REGISTER_CLASS_ENUM (AudioClock, Off); REGISTER (clock_mode); + + REGISTER_ENUM (Wide); + REGISTER_ENUM (Narrow); + REGISTER (width); } diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 8ac941e4e5..6be59ed044 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -112,6 +113,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr rt ignore_speed_adjustment = false; comment_window = 0; comment_area = 0; + _width_owner = 0; width_button.add (*(manage (new Gtk::Image (::get_icon("strip_width"))))); hide_button.add (*(manage (new Gtk::Image (::get_icon("hide"))))); @@ -370,19 +372,10 @@ MixerStrip::set_stuff_from_route () ensure_xml_node (); + /* if width is not set, it will be set by the MixerUI or editor */ + if ((prop = xml_node->property ("strip_width")) != 0) { - if (prop->value() == "wide") { - set_width (Wide); - } else if (prop->value() == "narrow") { - set_width (Narrow); - } - else { - error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg; - set_width (Wide); - } - } - else { - set_width (Wide); + set_width (Width (string_2_enum (prop->value(), _width)), this); } if ((prop = xml_node->property ("shown_mixer")) != 0) { @@ -398,14 +391,17 @@ MixerStrip::set_stuff_from_route () } void -MixerStrip::set_width (Width w) +MixerStrip::set_width (Width w, void* owner) { /* always set the gpm width again, things may be hidden */ + gpm.set_width (w); panners.set_width (w); pre_redirect_box.set_width (w); post_redirect_box.set_width (w); - + + _width_owner = owner; + if (_width == w) { return; } @@ -413,11 +409,14 @@ MixerStrip::set_width (Width w) ensure_xml_node (); _width = w; - + + if (_width_owner == this) { + xml_node->add_property ("strip_width", enum_2_string (_width)); + } + switch (w) { case Wide: set_size_request (-1, -1); - xml_node->add_property ("strip_width", "wide"); if (rec_enable_button) { ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("record")); @@ -441,8 +440,6 @@ MixerStrip::set_width (Width w) break; case Narrow: - xml_node->add_property ("strip_width", "narrow"); - if (rec_enable_button) { ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec")); } @@ -1095,10 +1092,10 @@ MixerStrip::width_clicked () { switch (_width) { case Wide: - set_width (Narrow); + set_width (Narrow, this); break; case Narrow: - set_width (Wide); + set_width (Wide, this); break; } } diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index ea2569b644..7e92f83579 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -85,12 +85,13 @@ class MixerStrip : public RouteUI, public Gtk::EventBox MixerStrip (Mixer_UI&, ARDOUR::Session&, boost::shared_ptr, bool in_mixer = true); ~MixerStrip (); - void set_width (Width); + void set_width (Width, void* owner); Width get_width() const { return _width; } + void* width_owner() const { return _width_owner; } void fast_update (); void set_embedded (bool); - + ARDOUR::RouteGroup* mix_group() const; protected: @@ -107,6 +108,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox bool _embedded; bool _packed; Width _width; + void* _width_owner; Gtk::Button hide_button; Gtk::Button width_button; diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index cbd9cfe083..766db2938f 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -244,7 +244,7 @@ Mixer_UI::show_window () for (ri = rows.begin(); ri != rows.end(); ++ri) { ms = (*ri)[track_columns.strip]; - ms->set_width (ms->get_width()); + ms->set_width (ms->get_width(), ms->width_owner()); } _visible = true; } @@ -274,7 +274,10 @@ Mixer_UI::add_strip (Session::RouteList& routes) strip = new MixerStrip (*this, *session, route); strips.push_back (strip); - strip->set_width (_strip_width); + if (strip->width_owner() != strip) { + strip->set_width (_strip_width, this); + } + show_strip (strip); no_track_list_redisplay = true; @@ -1040,7 +1043,7 @@ Mixer_UI::set_strip_width (Width w) _strip_width = w; for (list::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_width (w); + (*i)->set_width (w, this); } } -- cgit v1.2.3