diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-25 03:03:25 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-25 03:03:25 +0000 |
commit | d707fa06b79b9ed46323ebe9010c15b198e4058f (patch) | |
tree | b2d13de70d1daeabc96031a79d8cec1f16c92da8 /gtk2_ardour | |
parent | 275e710e671409421b6a1155bfeeff0d4580a87a (diff) |
dramatically simplify maximi[sz]ation code, ripping out all the old pane sizing stuff that seems to be a left over from gtk1 (!)
git-svn-id: svn://localhost/ardour2/branches/3.0@11344 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour_ui2.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/editor.cc | 125 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 14 |
3 files changed, 43 insertions, 113 deletions
diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 17f3625f4c..69228c4161 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -592,26 +592,17 @@ ARDOUR_UI::editor_realized () void ARDOUR_UI::maximise_editing_space () { - if (!editor) { - return; - } - - transport_tearoff->set_visible (false); - editor->maximise_editing_space (); - if (Config->get_keep_tearoffs()) { - transport_tearoff->set_visible (true); + if (editor) { + editor->maximise_editing_space (); } } void ARDOUR_UI::restore_editing_space () { - if (!editor) { - return; + if (editor) { + editor->restore_editing_space (); } - - transport_tearoff->set_visible (true); - editor->restore_editing_space (); } bool diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 9a24be433a..f94269c564 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -43,6 +43,7 @@ #include "pbd/enumwriter.h" #include "pbd/memento_command.h" #include "pbd/unknown_type.h" +#include "pbd/stacktrace.h" #include <glibmm/miscutils.h> #include <gtkmm/image.h> @@ -330,6 +331,7 @@ Editor::Editor () current_interthread_info = 0; _show_measures = true; + _maximised = false; show_gain_after_trim = false; have_pending_keyboard_selection = false; @@ -554,10 +556,6 @@ Editor::Editor () _the_notebook.set_tab_pos (Gtk::POS_RIGHT); _the_notebook.show_all (); - post_maximal_editor_width = 0; - post_maximal_horizontal_pane_position = 0; - post_maximal_editor_height = 0; - post_maximal_vertical_pane_position = 0; _notebook_shrunk = false; editor_summary_pane.pack1(edit_packer); @@ -2367,6 +2365,13 @@ Editor::set_state (const XMLNode& node, int /*version*/) _regions->set_state (**i); } + if ((prop = node.property ("maximised"))) { + bool yn = string_is_affirmative (prop->value()); + if (yn) { + ActionManager::do_action ("Common", "ToggleMaximalEditor"); + } + } + return 0; } @@ -2399,8 +2404,6 @@ Editor::get_state () snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&edit_pane)->gobj())); geometry->add_property("edit-horizontal-pane-pos", string(buf)); geometry->add_property("notebook-shrunk", _notebook_shrunk ? "1" : "0"); - snprintf(buf,sizeof(buf), "%d",pre_maximal_horizontal_pane_position); - geometry->add_property("pre-maximal-horizontal-pane-position", string(buf)); snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&editor_summary_pane)->gobj())); geometry->add_property("edit-vertical-pane-pos", string(buf)); @@ -2428,6 +2431,7 @@ Editor::get_state () node->add_property ("y-origin", buf); node->add_property ("show-measures", _show_measures ? "yes" : "no"); + node->add_property ("maximised", _maximised ? "yes" : "no"); node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no"); node->add_property ("stationary-playhead", _stationary_playhead ? "yes" : "no"); node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no"); @@ -3509,10 +3513,6 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which) _notebook_shrunk = string_is_affirmative (prop->value ()); } - if (geometry && (prop = geometry->property ("pre-maximal-horizontal-pane-position"))) { - pre_maximal_horizontal_pane_position = atoi (prop->value ()); - } - if (!geometry || (prop = geometry->property ("edit-horizontal-pane-pos")) == 0) { /* initial allocation is 90% to canvas, 10% to notebook */ pos = (int) floor (alloc.get_width() * 0.90f); @@ -3523,9 +3523,6 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which) if (GTK_WIDGET(edit_pane.gobj())->allocation.width > pos) { edit_pane.set_position (pos); - if (pre_maximal_horizontal_pane_position == 0) { - pre_maximal_horizontal_pane_position = pos; - } } done = (Pane) (done | Horizontal); @@ -3541,12 +3538,12 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which) pos = (int) floor (alloc.get_height() * 0.90f); snprintf (buf, sizeof(buf), "%d", pos); } else { + pos = atoi (prop->value()); } if (GTK_WIDGET(editor_summary_pane.gobj())->allocation.height > pos) { editor_summary_pane.set_position (pos); - pre_maximal_vertical_pane_position = pos; } done = (Pane) (done | Vertical); @@ -3897,98 +3894,40 @@ Editor::session_state_saved (string) void Editor::maximise_editing_space () { - /* these calls will leave each tearoff visible *if* it is torn off - */ - - _mouse_mode_tearoff->set_visible (false); - _tools_tearoff->set_visible (false); - _zoom_tearoff->set_visible (false); - - pre_maximal_horizontal_pane_position = edit_pane.get_position (); - pre_maximal_vertical_pane_position = editor_summary_pane.get_position (); - pre_maximal_editor_width = this->get_width (); - pre_maximal_editor_height = this->get_height (); - - if (post_maximal_horizontal_pane_position == 0) { - post_maximal_horizontal_pane_position = edit_pane.get_width(); - } - - if (post_maximal_vertical_pane_position == 0) { - post_maximal_vertical_pane_position = editor_summary_pane.get_height(); + if (_maximised) { + return; } fullscreen (); - if (post_maximal_editor_width) { - edit_pane.set_position (post_maximal_horizontal_pane_position - - abs(post_maximal_editor_width - pre_maximal_editor_width)); - } else { - edit_pane.set_position (post_maximal_horizontal_pane_position); - } - - /* Hack: we must do this in an idle handler for it to work; see comment in - restore_editing_space() - */ - - Glib::signal_idle().connect ( - sigc::bind ( - sigc::mem_fun (*this, &Editor::idle_reset_vertical_pane_position), - post_maximal_vertical_pane_position - ) - ); - - if (Config->get_keep_tearoffs()) { - _mouse_mode_tearoff->set_visible (true); - _tools_tearoff->set_visible (true); - if (Config->get_show_zoom_tools ()) { - _zoom_tearoff->set_visible (true); - } + if (!Config->get_keep_tearoffs()) { + /* these calls will leave each tearoff visible *if* it is torn off, + but invisible otherwise. + */ + _mouse_mode_tearoff->set_visible (false); + _tools_tearoff->set_visible (false); + _zoom_tearoff->set_visible (false); } -} - -bool -Editor::idle_reset_vertical_pane_position (int p) -{ - editor_summary_pane.set_position (p); - return false; + _maximised = true; } void Editor::restore_editing_space () { - // user changed width/height of panes during fullscreen - - if (post_maximal_horizontal_pane_position != edit_pane.get_position()) { - post_maximal_horizontal_pane_position = edit_pane.get_position(); - } - - if (post_maximal_vertical_pane_position != editor_summary_pane.get_position()) { - post_maximal_vertical_pane_position = editor_summary_pane.get_position(); + if (!_maximised) { + return; } unfullscreen(); - _mouse_mode_tearoff->set_visible (true); - _tools_tearoff->set_visible (true); - if (Config->get_show_zoom_tools ()) { + if (!Config->get_keep_tearoffs()) { + _mouse_mode_tearoff->set_visible (true); + _tools_tearoff->set_visible (true); _zoom_tearoff->set_visible (true); } - post_maximal_editor_width = this->get_width(); - post_maximal_editor_height = this->get_height(); - - edit_pane.set_position (pre_maximal_horizontal_pane_position + abs(this->get_width() - pre_maximal_editor_width)); - /* This is a bit of a hack, but it seems that if you set the vertical pane position - here it gets reset to some wrong value after this method has finished. Doing - the setup in an idle callback seems to work. - */ - Glib::signal_idle().connect ( - sigc::bind ( - sigc::mem_fun (*this, &Editor::idle_reset_vertical_pane_position), - pre_maximal_vertical_pane_position - ) - ); + _maximised = false; } /** @@ -5445,10 +5384,16 @@ Editor::notebook_tab_clicked (GdkEventButton* ev, Gtk::Widget* page) /* double-click on a notebook tab shrinks or expands the notebook */ if (_notebook_shrunk) { - edit_pane.set_position (pre_maximal_horizontal_pane_position); + if (pre_notebook_shrink_pane_width) { + edit_pane.set_position (*pre_notebook_shrink_pane_width); + } _notebook_shrunk = false; } else { - pre_maximal_horizontal_pane_position = edit_pane.get_position (); + pre_notebook_shrink_pane_width = edit_pane.get_position(); + + /* this expands the LHS of the edit pane to cover the notebook + PAGE but leaves the tabs visible. + */ edit_pane.set_position (edit_pane.get_position() + page->get_width()); _notebook_shrunk = true; } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 553f4c7e7e..e12e20f610 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -525,14 +525,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD void update_join_object_range_location (double, double); - int post_maximal_editor_width; - int post_maximal_editor_height; - int post_maximal_horizontal_pane_position; - int post_maximal_vertical_pane_position; - int pre_maximal_horizontal_pane_position; - int pre_maximal_vertical_pane_position; - int pre_maximal_editor_width; - int pre_maximal_editor_height; + boost::optional<int> pre_notebook_shrink_pane_width; + void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*); Gtk::Notebook _the_notebook; @@ -543,8 +537,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Gtk::HPaned edit_pane; Gtk::VPaned editor_summary_pane; - bool idle_reset_vertical_pane_position (int); - Gtk::EventBox meter_base; Gtk::HBox meter_box; Gtk::EventBox marker_base; @@ -1451,6 +1443,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD bool _follow_playhead; /// true if we scroll the tracks rather than the playhead bool _stationary_playhead; + /// true if we are in fullscreen mode + bool _maximised; ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_begin; ARDOUR::TempoMap::BBTPointList::const_iterator current_bbt_points_end; |