diff options
author | David Robillard <d@drobilla.net> | 2015-02-08 16:03:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-02-08 16:03:54 +0000 |
commit | 9e108b92c62ad48d5690e5c207e224b7da49bd49 (patch) | |
tree | 4f99ff2f1b7e0b1640e2b481d8b23d30d8e80756 /src | |
parent | f32b5d18e947ab276e7c0f345599b2f5f8c634c2 (diff) | |
download | patchage-9e108b92c62ad48d5690e5c207e224b7da49bd49.tar.gz patchage-9e108b92c62ad48d5690e5c207e224b7da49bd49.tar.bz2 patchage-9e108b92c62ad48d5690e5c207e224b7da49bd49.zip |
Style messages pane to match canvas.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5545 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/Configuration.cpp | 8 | ||||
-rw-r--r-- | src/Configuration.hpp | 8 | ||||
-rw-r--r-- | src/Patchage.cpp | 40 | ||||
-rw-r--r-- | src/Patchage.hpp | 2 | ||||
-rw-r--r-- | src/patchage.ui | 34 |
5 files changed, 73 insertions, 19 deletions
diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 5d84e86..0fbafe2 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -41,6 +41,8 @@ Configuration::Configuration() , _zoom(1.0) , _font_size(12.0) , _show_toolbar(true) + , _show_messages(false) + , _messages_height(0) { _port_colors[JACK_AUDIO] = _default_port_colors[JACK_AUDIO] = 0x3E5E00FF; _port_colors[JACK_MIDI] = _default_port_colors[JACK_MIDI] = 0x650300FF; @@ -188,6 +190,10 @@ Configuration::load() file >> _show_toolbar; } else if (key == "sprung_layout") { file >> _sprung_layout; + } else if (key == "show_messages") { + file >> _show_messages; + } else if (key == "messages_height") { + file >> _messages_height; } else if (key == "port_color") { std::string type_name; uint32_t rgba; @@ -286,6 +292,8 @@ Configuration::save() file << "font_size " << _font_size << std::endl; file << "show_toolbar " << _show_toolbar << std::endl; file << "sprung_layout " << _sprung_layout << std::endl; + file << "show_messages " << _show_messages << std::endl; + file << "messages_height " << _messages_height << std::endl; file << std::hex << std::uppercase; for (int i = 0; i < N_PORT_TYPES; ++i) { diff --git a/src/Configuration.hpp b/src/Configuration.hpp index a80c581..3907510 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -62,6 +62,12 @@ public: float get_sprung_layout() const { return _sprung_layout; } void set_sprung_layout(float sprung_layout) { _sprung_layout = sprung_layout; } + bool get_show_messages() const { return _show_messages; } + void set_show_messages(bool show_messages) { _show_messages = show_messages; } + + int get_messages_height() const { return _messages_height; } + void set_messages_height(int height) { _messages_height = height; } + uint32_t get_port_color(PortType type) const { return _port_colors[type]; } void set_port_color(PortType type, uint32_t rgba) { _port_colors[type] = rgba; @@ -92,6 +98,8 @@ private: float _font_size; bool _show_toolbar; bool _sprung_layout; + bool _show_messages; + int _messages_height; }; #endif // PATCHAGE_CONFIGURATION_HPP diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 67e390f..5ce8f5f 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -137,6 +137,7 @@ Patchage::Patchage(int argc, char** argv) , INIT_WIDGET(_log_scrolledwindow) , INIT_WIDGET(_status_text) , _legend(NULL) + , _pane_initialized(false) , _attach(true) , _driver_detached(false) , _refresh(false) @@ -194,6 +195,9 @@ Patchage::Patchage(int argc, char** argv) _clear_load_but->signal_clicked().connect( sigc::mem_fun(this, &Patchage::clear_load)); + _status_text->signal_size_allocate().connect( + sigc::mem_fun(this, &Patchage::on_messages_resized)); + #ifdef PATCHAGE_JACK_SESSION _menu_open_session->signal_activate().connect( sigc::mem_fun(this, &Patchage::show_open_session_dialog)); @@ -257,12 +261,17 @@ Patchage::Patchage(int argc, char** argv) _menu_view_sprung_layout->set_sensitive(false); } + for (int s = Gtk::STATE_NORMAL; s <= Gtk::STATE_INSENSITIVE; ++s) { + _status_text->modify_base((Gtk::StateType)s, Gdk::Color("#000000")); + _status_text->modify_text((Gtk::StateType)s, Gdk::Color("#FFFFFF")); + } + _error_tag = Gtk::TextTag::create(); _error_tag->property_foreground() = "#CC0000"; _status_text->get_buffer()->get_tag_table()->add(_error_tag); _warning_tag = Gtk::TextTag::create(); - _warning_tag->property_foreground() = "#E6B200"; + _warning_tag->property_foreground() = "#C4A000"; _status_text->get_buffer()->get_tag_table()->add(_warning_tag); _canvas->widget().show(); @@ -307,7 +316,10 @@ Patchage::Patchage(int argc, char** argv) update_state(); _menu_view_toolbar->set_active(_conf->get_show_toolbar()); _menu_view_sprung_layout->set_active(_conf->get_sprung_layout()); - _main_paned->set_position(42); + _status_text->set_pixels_inside_wrap(2); + _status_text->set_left_margin(4); + _status_text->set_right_margin(4); + _status_text->set_pixels_below_lines(2); g_signal_connect(_main_win->gobj(), "configure-event", G_CALLBACK(configure_cb), this); @@ -377,6 +389,7 @@ Patchage::idle_callback() // Initial run, attach if (_attach) { attach(); + _menu_view_messages->set_active(_conf->get_show_messages()); _attach = false; } @@ -874,6 +887,13 @@ Patchage::on_legend_color_change(int id, const std::string& label, uint32_t rgba } void +Patchage::on_messages_resized(Gtk::Allocation& alloc) +{ + const int max_pos = _main_paned->get_allocation().get_height(); + _conf->set_messages_height(max_pos - _main_paned->get_position()); +} + +void Patchage::save() { _conf->set_zoom(_canvas->get_zoom()); // Can be changed by ganv @@ -940,9 +960,25 @@ void Patchage::on_view_messages() { if (_menu_view_messages->get_active()) { + Glib::RefPtr<Gtk::TextBuffer> buffer = _status_text->get_buffer(); + if (!_pane_initialized) { + int y, line_height; + _status_text->get_line_yrange(buffer->begin(), y, line_height); + const int pad = _status_text->get_pixels_inside_wrap(); + const int max_pos = _main_paned->get_allocation().get_height(); + const int min_height = (line_height + 2 * pad); + const int conf_height = _conf->get_messages_height(); + _main_paned->set_position(max_pos - std::max(conf_height, min_height)); + _pane_initialized = true; + } + _log_scrolledwindow->show(); + _status_text->scroll_to_mark( + _status_text->get_buffer()->get_insert(), 0); + _conf->set_show_messages(true); } else { _log_scrolledwindow->hide(); + _conf->set_show_messages(false); } } diff --git a/src/Patchage.hpp b/src/Patchage.hpp index b234b0d..9183b7e 100644 --- a/src/Patchage.hpp +++ b/src/Patchage.hpp @@ -112,6 +112,7 @@ protected: void on_decrease_font_size(); void on_normal_font_size(); void on_legend_color_change(int id, const std::string& label, uint32_t rgba); + void on_messages_resized(Gtk::Allocation& alloc); bool on_scroll(GdkEventScroll* ev); @@ -183,6 +184,7 @@ protected: Glib::RefPtr<Gtk::TextTag> _error_tag; Glib::RefPtr<Gtk::TextTag> _warning_tag; + bool _pane_initialized; bool _attach; bool _driver_detached; bool _refresh; diff --git a/src/patchage.ui b/src/patchage.ui index 686ad41..4411193 100644 --- a/src/patchage.ui +++ b/src/patchage.ui @@ -1214,6 +1214,23 @@ The bar represents the percentage of available time used for audio processing (i <property name="can_focus">True</property> <property name="position">3200</property> <child> + <object class="GtkScrolledWindow" id="main_scrolledwin"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> + <property name="receives_default">True</property> + <property name="shadow_type">in</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">False</property> + </packing> + </child> + <child> <object class="GtkScrolledWindow" id="log_scrolledwindow"> <property name="can_focus">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> @@ -1237,23 +1254,6 @@ The bar represents the percentage of available time used for audio processing (i <property name="shrink">True</property> </packing> </child> - <child> - <object class="GtkScrolledWindow" id="main_scrolledwin"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="receives_default">True</property> - <property name="shadow_type">in</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="resize">True</property> - <property name="shrink">False</property> - </packing> - </child> </object> <packing> <property name="expand">True</property> |