diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Patchage.cpp | 76 | ||||
-rw-r--r-- | src/Patchage.h | 11 | ||||
-rw-r--r-- | src/patchage.glade | 74 |
3 files changed, 125 insertions, 36 deletions
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 <raul/SharedPtr.h> 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<int>(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 @@ </child> <child> - <widget class="GtkHBox" id="hbox1"> + <widget class="GtkVPaned" id="main_paned"> <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> + <property name="can_focus">True</property> + <property name="position">0</property> <child> - <widget class="GtkVPaned" id="main_paned"> - <property name="height_request">407</property> + <widget class="GtkScrolledWindow" id="canvas_scrolledwindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="position">1000</property> + <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> <child> - <widget class="GtkScrolledWindow" id="canvas_scrolledwindow"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="shrink">False</property> - <property name="resize">True</property> - </packing> + <placeholder/> </child> + </widget> + <packing> + <property name="shrink">False</property> + <property name="resize">True</property> + </packing> + </child> + + <child> + <widget class="GtkExpander" id="messages_expander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="expanded">False</property> + <property name="spacing">0</property> <child> <widget class="GtkScrolledWindow" id="scrolledwindow1"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> <property name="shadow_type">GTK_SHADOW_IN</property> <property name="window_placement">GTK_CORNER_TOP_LEFT</property> @@ -634,16 +634,34 @@ </widget> </child> </widget> + </child> + + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">Messages</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> <packing> - <property name="shrink">True</property> - <property name="resize">True</property> + <property name="type">label_item</property> </packing> </child> </widget> <packing> - <property name="padding">2</property> - <property name="expand">True</property> - <property name="fill">True</property> + <property name="shrink">True</property> + <property name="resize">True</property> </packing> </child> </widget> |