From c44ae9cd6a176c18655816ab6a1692a2fca65816 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 16 Oct 2006 04:55:16 +0000 Subject: Magic flashy PaneExpander(TM) 2.0. git-svn-id: http://svn.drobilla.net/lad/patchage@178 a436a847-0d15-0410-975c-d299462d15a1 --- src/Patchage.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------ src/Patchage.h | 11 ++++++++ src/patchage.glade | 74 ++++++++++++++++++++++++++++++++-------------------- 3 files changed, 125 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 09c115b..4c9d843 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -33,7 +33,9 @@ #include Patchage::Patchage(int argc, char** argv) -: +: m_pane_closed(false), + m_update_pane_position(true), + m_user_pane_position(0), #ifdef HAVE_LASH m_lash_driver(NULL), #endif @@ -112,6 +114,7 @@ Patchage::Patchage(int argc, char** argv) xml->get_widget("zoom_scale", m_zoom_slider); xml->get_widget("status_text", m_status_text); xml->get_widget("main_paned", m_main_paned); + xml->get_widget("messages_expander", m_messages_expander); xml->get_widget("zoom_full_but", m_zoom_full_button); xml->get_widget("zoom_normal_but", m_zoom_normal_button); @@ -157,8 +160,22 @@ Patchage::Patchage(int argc, char** argv) m_canvas->show(); - m_main_paned->set_position(INT_MAX); + m_main_window->present(); + + m_update_pane_position = false; + m_main_paned->set_position(max_pane_position()); + + m_main_paned->property_position().signal_changed().connect( + sigc::mem_fun(*this, &Patchage::on_pane_position_changed)); + + m_messages_expander->property_expanded().signal_changed().connect( + sigc::mem_fun(*this, &Patchage::on_messages_expander_changed)); + m_main_paned->set_position(max_pane_position()); + m_user_pane_position = max_pane_position() - m_main_window->get_height()/8; + m_update_pane_position = true; + m_pane_closed = true; + // Idle callback, check if we need to refresh Glib::signal_timeout().connect(sigc::mem_fun(this, &Patchage::idle_callback), 100); } @@ -386,14 +403,57 @@ Patchage::menu_file_quit() void -Patchage::show_messages_toggled() +Patchage::on_pane_position_changed() { - const bool show = m_menu_view_messages->get_active(); + // avoid infinite recursion... + if (!m_update_pane_position) + return; + + m_update_pane_position = false; + + int new_position = m_main_paned->get_position(); + + if (m_pane_closed && new_position < max_pane_position()) { + m_user_pane_position = new_position; + m_messages_expander->set_expanded(true); + m_pane_closed = false; + m_menu_view_messages->set_active(true); + } else if (new_position >= max_pane_position()) { + m_pane_closed = true; + m_messages_expander->set_expanded(false); + if (new_position > max_pane_position()) + m_main_paned->set_position(max_pane_position()); // ... here + m_menu_view_messages->set_active(false); + } + + m_update_pane_position = true; +} - if (show) - m_main_paned->set_position(static_cast(m_main_paned->get_height() * 3/4)); - else - m_main_paned->set_position(INT_MAX); + +void +Patchage::on_messages_expander_changed() +{ + if (!m_pane_closed) { + // Store pane position for restoring + m_user_pane_position = m_main_paned->get_position(); + if (m_update_pane_position) { + m_update_pane_position = false; + m_main_paned->set_position(max_pane_position()); + m_update_pane_position = true; + } + m_pane_closed = true; + } else { + m_main_paned->set_position(m_user_pane_position); + m_pane_closed = false; + } +} + + +void +Patchage::show_messages_toggled() +{ + if (m_update_pane_position) + m_messages_expander->set_expanded(m_menu_view_messages->get_active()); } diff --git a/src/Patchage.h b/src/Patchage.h index c317b97..d730b4b 100644 --- a/src/Patchage.h +++ b/src/Patchage.h @@ -59,6 +59,9 @@ public: void status_message(const string& msg); inline void queue_refresh() { m_refresh = true; } + int max_pane_position() + { return m_main_paned->property_max_position() - m_messages_expander->get_label_widget()->get_height() - 8; } + protected: void attach_menu_items(); @@ -71,6 +74,13 @@ protected: void zoom_changed(); bool idle_callback(); + void on_pane_position_changed(); + void on_messages_expander_changed(); + + bool m_pane_closed; + bool m_update_pane_position; + int m_user_pane_position; + #ifdef HAVE_LASH LashDriver* m_lash_driver; Gtk::MenuItem* m_menu_lash_launch; @@ -115,6 +125,7 @@ protected: Gtk::HScale* m_zoom_slider; Gtk::TextView* m_status_text; Gtk::Paned* m_main_paned; + Gtk::Expander* m_messages_expander; Gtk::Button* m_zoom_normal_button; Gtk::Button* m_zoom_full_button; }; diff --git a/src/patchage.glade b/src/patchage.glade index f0bb790..7c2f846 100644 --- a/src/patchage.glade +++ b/src/patchage.glade @@ -573,43 +573,43 @@ - + True - False - 0 + True + 0 - - 407 + True True - 1000 + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - - True - True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - - - - False - True - + + + + False + True + + + + + + True + True + False + 0 True True GTK_POLICY_NEVER - GTK_POLICY_ALWAYS + GTK_POLICY_AUTOMATIC GTK_SHADOW_IN GTK_CORNER_TOP_LEFT @@ -634,16 +634,34 @@ + + + + + True + Messages + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + - True - True + label_item - 2 - True - True + True + True -- cgit v1.2.1