From 734bd9095a198d3b22faf4921637e4700a22de39 Mon Sep 17 00:00:00 2001 From: Greg Zharun Date: Wed, 3 Sep 2014 17:16:54 +0300 Subject: [PATCH 1/7] [Summary] Applied a workaround for Pango issue about text name widths --- gtk2_ardour/time_axis_view_item.cc | 4 +++- gtk2_ardour/time_axis_view_item.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index 12b5cca30e..c2a6a01d9c 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -62,8 +62,10 @@ using namespace Gtkmm2ext; // GZ: Should be moved to config #ifdef _WIN32 Pango::FontDescription TimeAxisViewItem::NAME_FONT("Arial 8"); + const double TimeAxisViewItem::NAME_WIDTH_CORRECTION = 0; #else Pango::FontDescription TimeAxisViewItem::NAME_FONT("Helvetica 8"); + const double TimeAxisViewItem::NAME_WIDTH_CORRECTION = 7; #endif const double TimeAxisViewItem::NAME_HIGHLIGHT_Y_INDENT = 1.0; @@ -569,7 +571,7 @@ TimeAxisViewItem::set_name_text(const string& new_name) } // This is a workaround. // Pango returns incorrect width values 1.5*NAME_HIGHLIGHT_X_INDENT - name_text_width = pixel_width (new_name, NAME_FONT) + 1.5*NAME_HIGHLIGHT_X_INDENT; + name_text_width = pixel_width (new_name, NAME_FONT) + NAME_WIDTH_CORRECTION; name_text->set (new_name); } diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index 0b5e00c799..56cc3be994 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -100,6 +100,7 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList bool name_active() const { return name_connected; } // Default sizes, font and spacing + static const double NAME_WIDTH_CORRECTION; static Pango::FontDescription NAME_FONT; static void set_constant_heights (); static const double NAME_HIGHLIGHT_Y_INDENT; From e59ebf02bbabd7a2d5fdec7c951fd37c610e2cb5 Mon Sep 17 00:00:00 2001 From: GZharun Date: Wed, 3 Sep 2014 17:55:15 +0300 Subject: [PATCH 2/7] [Summary] Changed name highlight opacity according to PRD --- gtk2_ardour/time_axis_view_item.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index c2a6a01d9c..08d8f8008f 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -683,7 +683,7 @@ TimeAxisViewItem::compute_colors (Gdk::Color const & base_color) fill_color = RGBA_TO_UINT(r,g,b,160); // place to config - uint32_t opacity = 255*0.5; //50% + uint32_t opacity = 255*0.8; //80% name_highlight_color = RGBA_TO_UINT(0, 0, 0, opacity); } From 96003844c00ce11f868b401539e69aae1c2dd9e5 Mon Sep 17 00:00:00 2001 From: Valeriy Kamyshniy Date: Wed, 3 Sep 2014 18:14:34 +0300 Subject: [PATCH 3/7] [Summary] Progressing dropdown --- gtk2_ardour/waves_dropdown.cc | 22 ++++++---------------- gtk2_ardour/waves_dropdown.h | 2 +- gtk2_ardour/waves_ui.cc | 1 - 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/waves_dropdown.cc b/gtk2_ardour/waves_dropdown.cc index d9c3f4983f..24f9e0f99e 100644 --- a/gtk2_ardour/waves_dropdown.cc +++ b/gtk2_ardour/waves_dropdown.cc @@ -41,14 +41,18 @@ WavesDropdown::add_menu_item (const std::string& item, void* cookie) { Gtk::Menu_Helpers::MenuList& items = _menu.items (); - items.push_back (Gtk::Menu_Helpers::MenuElem (item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), cookie))); + items.push_back (Gtk::Menu_Helpers::MenuElem (item, sigc::bind (sigc::mem_fun(*this, &WavesDropdown::_on_menu_item), items.size (), cookie))); return _menu.items ().back (); } void -WavesDropdown::_on_menu_item (void* cookie) +WavesDropdown::_on_menu_item (size_t item_number, void* cookie) { + Gtk::Menu_Helpers::MenuList& items = _menu.items (); + Gtk::Menu_Helpers::MenuList::iterator i = items.begin(); + std::advance (i, item_number); + set_text ((*i).get_label()); signal_menu_item_clicked (this, cookie); } @@ -71,18 +75,4 @@ WavesDropdown::_on_popup_menu_position (int& x, int& y, bool& push_in) x += xo; y += yo; } - - /* - if (get_window ()) { - Gtk::Allocation a = get_allocation (); - - int xo; - int yo; - - get_window ()->get_origin (xo, yo); - - x = xo; - y = yo + a.get_height (); - } - */ } diff --git a/gtk2_ardour/waves_dropdown.h b/gtk2_ardour/waves_dropdown.h index db9d362d94..1a48f7b3bd 100644 --- a/gtk2_ardour/waves_dropdown.h +++ b/gtk2_ardour/waves_dropdown.h @@ -40,7 +40,7 @@ class WavesDropdown : public WavesIconButton private: Gtk::Menu _menu; - void _on_menu_item (void* cookie); + void _on_menu_item (size_t item_number, void* cookie); void _on_popup_menu_position (int& x, int& y, bool& push_in); }; diff --git a/gtk2_ardour/waves_ui.cc b/gtk2_ardour/waves_ui.cc index 5cfcb06346..be4bbf233c 100644 --- a/gtk2_ardour/waves_ui.cc +++ b/gtk2_ardour/waves_ui.cc @@ -463,7 +463,6 @@ WavesUI::create_ui (const XMLNodeList& definition, const XMLNodeMap& styles, Gtk WavesDropdown* dropdown = dynamic_cast (&root); if (dropdown) { - dbg_msg ("launching dropdown->create_menu ()"); add_dropdown_items (*dropdown, definition, styles); } else { for (XMLNodeList::const_iterator i = definition.begin (); i != definition.end (); ++i) { From f397b87712376cdc6c80cbce67aad4e7fcc87dad Mon Sep 17 00:00:00 2001 From: nikolay Date: Wed, 3 Sep 2014 18:36:46 +0300 Subject: [PATCH 4/7] [Summary] Do not show color palette for master [Reviewed] GZharun --- gtk2_ardour/mixer_strip.cc | 8 ++++++-- gtk2_ardour/ui/editor_mixer.xml | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 3b330a42c4..b1af8ab205 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -343,13 +343,17 @@ MixerStrip::set_route (boost::shared_ptr rt) if (route()->is_master()) { master_mute_button.show (); - get_container ("track_buttons_home").hide (); + //get_container ("track_buttons_home").hide (); + color_buttons_home.set_visible (false); + color_palette_button.set_visible (false); + color_palette_button.set_active (false); //mute_button.hide (); //solo_button.hide (); //rec_enable_button.hide (); } else { master_mute_button.hide (); - get_container ("track_buttons_home").show (); + color_palette_button.set_visible (true); + color_palette_home.set_visible (true); //mute_button.show (); //solo_button.show (); //rec_enable_button.show (); diff --git a/gtk2_ardour/ui/editor_mixer.xml b/gtk2_ardour/ui/editor_mixer.xml index 039e97256d..ebe8f1fc6d 100644 --- a/gtk2_ardour/ui/editor_mixer.xml +++ b/gtk2_ardour/ui/editor_mixer.xml @@ -7,6 +7,8 @@ Date: Wed, 3 Sep 2014 18:39:01 +0300 Subject: [PATCH 5/7] [Summary] Added possibility to change track names in Mixer Bridge, Meter Bridge and Inspector. Changed hovered tracks's name colors in Mixer Bridge and Meter Bridge. [Reviewed] GZharun --- gtk2_ardour/mixer_strip.cc | 178 ++++++++++++++++++++++++++++++-- gtk2_ardour/mixer_strip.h | 23 ++++- gtk2_ardour/ui/editor_mixer.xml | 37 +++++-- gtk2_ardour/ui/meter_strip.xml | 33 ++++-- gtk2_ardour/ui/mixer_strip.xml | 33 ++++-- 5 files changed, 272 insertions(+), 32 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index b1af8ab205..b01a0684c3 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -26,6 +26,7 @@ #include "pbd/enumwriter.h" #include "pbd/replace_all.h" #include "pbd/stacktrace.h" +#include "pbd/whitespace.h" #include #include @@ -100,10 +101,14 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, const std::string& layout_s , panners (sess) , _visibility (X_("mixer-strip-visibility")) + ,_editor (ARDOUR_UI::instance()->the_editor()) + , gain_meter_home (get_box ("gain_meter_home")) , _comment_button (get_waves_button ("comment_button")) , midi_input_enable_button (get_waves_button ("midi_input_enable_button")) - , name_button (get_waves_button ("name_button")) + , _name_button_home (get_event_box("name_label_home")) + , name_button (get_waves_button ("name_button")) + , _name_entry (get_entry("name_entry")) , color_palette_button (get_waves_button ("color_palette_button")) , color_palette_home (get_container ("color_palette_home")) , color_buttons_home (get_container ("color_buttons_home")) @@ -178,10 +183,15 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr rt , gpm (sess, xml_property(*xml_tree()->root(), "gainmeterscript", "default_gain_meter.xml")) , panners (sess) , _visibility (X_("mixer-strip-visibility")) + + , _editor (ARDOUR_UI::instance()->the_editor()) + , gain_meter_home (get_box ("gain_meter_home")) , _comment_button (get_waves_button ("comment_button")) , midi_input_enable_button (get_waves_button ("midi_input_enable_button")) - , name_button (get_waves_button ("name_button")) + , _name_button_home (get_event_box("name_label_home")) + , name_button (get_waves_button ("name_button")) + , _name_entry (get_entry ("name_entry")) , color_palette_button (get_waves_button ("color_palette_button")) , color_palette_home (get_container ("color_palette_home")) , color_buttons_home (get_container ("color_buttons_home")) @@ -291,6 +301,24 @@ MixerStrip::init () gpm.LevelMeterButtonPress.connect_same_thread (_level_meter_connection, boost::bind (&MixerStrip::level_meter_button_press, this, _1)); + _name_entry.signal_key_press_event().connect (sigc::mem_fun (*this, &MixerStrip::name_entry_key_press), false); + _name_entry.signal_key_release_event().connect (sigc::mem_fun (*this, &MixerStrip::name_entry_key_release), false); + _name_entry.signal_focus_out_event().connect (sigc::mem_fun (*this, &MixerStrip::name_entry_focus_out)); + + if( _route ) + _name_entry.set_text ( _route->name() ); + + _name_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &MixerStrip::end_name_edit), RESPONSE_OK)); + + _name_button_home.add_events (Gdk::BUTTON_PRESS_MASK| + Gdk::BUTTON_RELEASE_MASK| + Gdk::POINTER_MOTION_MASK); + _name_button_home.set_flags (CAN_FOCUS); + + /* note that this handler connects *before* the default handler */ + _name_button_home.signal_button_press_event().connect (sigc::mem_fun (*this, &MixerStrip::controls_ebox_button_press)); + _name_button_home.signal_button_release_event().connect (sigc::mem_fun (*this, &MixerStrip::controls_ebox_button_release)); + Session* session = ARDOUR_UI::instance()->the_session(); if( session ) session->session_routes_reconnected.connect(_input_output_channels_update, invalidator (*this), boost::bind (&MixerStrip::update_inspector_info_panel, this), gui_context()); @@ -305,11 +333,149 @@ MixerStrip::~MixerStrip () delete comment_window; } -Gdk::Color -MixerStrip::palette_random_color() +bool +MixerStrip::controls_ebox_button_press (GdkEventButton* event) { - int number_of_colors_in_palette = sizeof(MixerStrip::XMLColor)/sizeof(*MixerStrip::XMLColor); - return (Gdk::Color)(MixerStrip::XMLColor[random() % number_of_colors_in_palette]); + if ((event->button == 1 && event->type == GDK_2BUTTON_PRESS) || Keyboard::is_edit_event (event)) { + /* see if it is inside the name label */ + if (name_button.is_ancestor (_name_button_home)) { + int nlx; + int nly; + _name_button_home.translate_coordinates (name_button, event->x, event->y, nlx, nly); + Gtk::Allocation a = name_button.get_allocation (); + if (nlx > 0 && nlx < a.get_width() && nly > 0 && nly < a.get_height()) { + begin_name_edit (); + return true; + } + } + + } + + return true; +} + +bool +MixerStrip::controls_ebox_button_release (GdkEventButton* ev) +{ + return false; +} + +void +MixerStrip::selection_click (GdkEventButton* ev) +{ + Selection::Operation op = ArdourKeyboard::selection_type (ev->state); +} + +bool +MixerStrip::name_entry_key_press (GdkEventKey* ev) +{ + /* steal escape, tabs from GTK */ + + switch (ev->keyval) { + case GDK_Escape: + case GDK_ISO_Left_Tab: + case GDK_Tab: + return true; + } + return false; +} + +bool +MixerStrip::name_entry_key_release (GdkEventKey* ev) +{ + TrackViewList::iterator i; + + switch (ev->keyval) { + case GDK_Escape: + end_name_edit (RESPONSE_CANCEL); + return true; + + /* Shift+Tab Keys Pressed. Note that for Shift+Tab, GDK actually + * generates a different ev->keyval, rather than setting + * ev->state. + */ + case GDK_ISO_Left_Tab: + end_name_edit (RESPONSE_APPLY); + return true; + + case GDK_Tab: + end_name_edit (RESPONSE_ACCEPT); + return true; + default: + break; + } + + return false; +} + + +bool +MixerStrip::name_entry_focus_out (GdkEventFocus*) +{ + end_name_edit (RESPONSE_OK); + return false; +} + +void +MixerStrip::begin_name_edit () +{ + if( _route->is_master () ) + return; + + _name_entry.set_text ( _route->name() ); + name_button.hide(); + _name_entry.show (); + + _name_entry.select_region (0, -1); + _name_entry.set_state (STATE_SELECTED); + _name_entry.grab_focus (); + _name_entry.start_editing (0); +} + +void +MixerStrip::end_name_edit (int response) +{ + switch (response) { + case RESPONSE_CANCEL: + break; + case RESPONSE_OK: + name_entry_changed (); + break; + case RESPONSE_ACCEPT: + name_entry_changed (); + case RESPONSE_APPLY: + name_entry_changed (); + } + + name_button.show (); + _name_entry.hide (); +} + +void +MixerStrip::name_entry_changed () +{ + string x = _name_entry.get_text (); + + if (x == _route->name()) { + return; + } + + strip_whitespace_edges (x); + + if (x.length() == 0) { + _name_entry.set_text ( cut_string(_route->name(), _max_name_size) ); + return; + } + + if (_session->route_name_internal (x)) { + ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"), + PROGRAM_NAME)); + _name_entry.grab_focus (); + } else if (RouteUI::verify_new_route_name (x)) { + _route->set_name (x); + } else { + _name_entry.grab_focus (); + } } void diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index 81780bcc44..e91e5dc889 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -125,7 +125,6 @@ class MixerStrip : public RouteUI void toggle_processors (); void ab_plugins (); - static Gdk::Color palette_random_color(); static const char* XMLColor[15]; protected: @@ -135,7 +134,9 @@ class MixerStrip : public RouteUI void set_selected(bool yn); void set_stuff_from_route (); - + + PublicEditor& _editor; + private: Mixer_UI& _mixer; @@ -164,8 +165,22 @@ class MixerStrip : public RouteUI gint mark_update_safe (); guint32 mode_switch_in_progress; - WavesButton& name_button; - + Gtk::Container& _name_button_home; + bool controls_ebox_button_press (GdkEventButton*); + bool controls_ebox_button_release (GdkEventButton* ev); + void selection_click (GdkEventButton* ev); + + WavesButton& name_button; + + Gtk::Entry& _name_entry; + void begin_name_edit (); + void end_name_edit (int); + + bool name_entry_key_release (GdkEventKey *ev); + bool name_entry_key_press (GdkEventKey *ev); + bool name_entry_focus_out (GdkEventFocus *ev); + void name_entry_changed (); + WavesButton& color_palette_button; Gtk::Container& color_palette_home; Gtk::Container& color_buttons_home; diff --git a/gtk2_ardour/ui/editor_mixer.xml b/gtk2_ardour/ui/editor_mixer.xml index ebe8f1fc6d..7f8bdd633e 100644 --- a/gtk2_ardour/ui/editor_mixer.xml +++ b/gtk2_ardour/ui/editor_mixer.xml @@ -244,14 +244,35 @@ prelighticon="inspector_master_mute_prelight" visible="false" noshowall="true"/> -