From f269d7c56e3b1621322bcee47f0b2bb60920824c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 12 Jan 2013 04:07:29 +0000 Subject: [PATCH] various tweaks to get 80% Of the way to proper use of TimeAxisView::name_label and TimeAxisView::name_entry. Not done yet, since the entry sometimes loses focus and cannot be hidden. git-svn-id: svn://localhost/ardour2/branches/3.0@13836 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_time_axis.cc | 10 +++-- gtk2_ardour/route_time_axis.cc | 10 +---- gtk2_ardour/time_axis_view.cc | 61 ++++++++++++++++++++--------- gtk2_ardour/time_axis_view.h | 1 - gtk2_ardour/visual_time_axis.cc | 18 ++++----- 5 files changed, 59 insertions(+), 41 deletions(-) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 498832da02..618344fcbc 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -154,8 +154,9 @@ AutomationTimeAxisView::AutomationTimeAxisView ( } /* for automation tracks, the label does not swap with an entry box. remove all that stuff */ - if ( name_label.get_parent() ) - name_hbox.remove(name_label); + if (name_label.get_parent()) { + hide_name_label (); + } name_label.set_text (_name); name_label.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); @@ -421,14 +422,15 @@ AutomationTimeAxisView::set_height (uint32_t h) first_call_to_set_height = false; if (h >= preset_height (HeightNormal)) { - name_label.show(); + show_name_label (); + hide_name_entry (); auto_button.show(); hide_button.show_all(); } else if (h >= preset_height (HeightSmall)) { controls_table.hide_all (); hide_name_entry (); - name_label.hide(); + hide_name_label (); auto_button.hide(); } } diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index b501214d6b..5d091375b4 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1286,6 +1286,8 @@ RouteTimeAxisView::playlist () const void RouteTimeAxisView::name_entry_changed () { + TimeAxisView::name_entry_changed (); + string x = name_entry.get_text (); if (x == _route->name()) { @@ -2168,14 +2170,6 @@ void RouteTimeAxisView::update_rec_display () { RouteUI::update_rec_display (); - - if (_route->record_enabled()) { - hide_name_entry (); - show_name_label (); - } else { - hide_name_label (); - show_name_entry (); - } } void diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 93435af953..06ff659fab 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -70,10 +70,22 @@ PBD::Signal1 TimeAxisView::CatchDeletion; TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/) : AxisView (sess) , controls_table (2, 8) + , height (0) + , last_name_entry_key_press_event (0) + , display_menu (0) + , parent (rent) + , selection_group (0) + , _hidden (false) + , in_destructor (false) + , name_packing (NamePackingBits (0)) , _size_menu (0) + , _canvas_display (0) , _y_position (0) , _editor (ed) + , control_parent (0) , _order (0) + , _effective_height (0) + , _resize_drag_start (-1) , _preresize_cursor (0) , _have_preresize_cursor (false) , _ghost_group (0) @@ -94,17 +106,6 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie _ghost_group->lower_to_bottom(); _ghost_group->show(); - control_parent = 0; - display_menu = 0; - _hidden = false; - in_destructor = false; - height = 0; - _effective_height = 0; - parent = rent; - last_name_entry_key_press_event = 0; - name_packing = NamePackingBits (0); - _resize_drag_start = -1; - /* Create the standard LHS Controls We create the top-level container and name add the name label here, @@ -357,6 +358,28 @@ TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev) bool TimeAxisView::controls_ebox_button_press (GdkEventButton* event) { + if (event->button == 1) { + if (event->type == GDK_2BUTTON_PRESS) { + /* see if it is inside the name label */ + if (name_label.is_ancestor (controls_ebox)) { + int nlx; + int nly; + controls_ebox.translate_coordinates (name_label, event->x, event->y, nlx, nly); + Gtk::Allocation a = name_label.get_allocation (); + if (nlx > 0 && nlx < a.get_width() && + nly > 0 && nly < a.get_height()) { + hide_name_label (); + show_name_entry (); + if (can_edit_name()) { + name_entry.grab_focus (); + name_entry.start_editing ((GdkEvent*) event); + } + return true; + } + } + } + } + if (maybe_set_cursor (event->y) > 0) { _resize_drag_start = event->y_root; } @@ -532,6 +555,8 @@ TimeAxisView::set_height (uint32_t h) /* resize the selection rect */ show_selection (_editor.get_selection().time); } + + show_name_label (); } bool @@ -650,6 +675,8 @@ TimeAxisView::name_entry_focus_in (GdkEventFocus*) bool TimeAxisView::name_entry_focus_out (GdkEventFocus*) { + cerr << "NEFO\n"; + /* clean up */ last_name_entry_key_press_event = 0; @@ -680,6 +707,9 @@ TimeAxisView::name_entry_activated () void TimeAxisView::name_entry_changed () { + cerr << "swithcing back to name labnel\n"; + hide_name_entry (); + show_name_label (); } bool @@ -696,12 +726,7 @@ TimeAxisView::name_entry_button_press (GdkEventButton *ev) } if (ev->button == 1) { - if (ev->type == GDK_2BUTTON_PRESS) { - if (can_edit_name()) { - name_entry.grab_focus (); - name_entry.start_editing ((GdkEvent*) ev); - } - } else { + if (ev->type != GDK_2BUTTON_PRESS) { conditionally_add_to_selection (); } } @@ -1135,7 +1160,7 @@ TimeAxisView::compute_heights () void TimeAxisView::show_name_label () { - if (!(name_packing & NameLabelPacked)) { + if (!(name_packing & NameLabelPacked) && name_label.get_parent() == 0) { name_hbox.pack_start (name_label, true, true); name_packing = NamePackingBits (name_packing | NameLabelPacked); name_hbox.show (); diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index 26da869ee5..958b0b55dd 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -281,7 +281,6 @@ class TimeAxisView : public virtual AxisView virtual void selection_click (GdkEventButton*); bool _hidden; - bool _has_state; bool in_destructor; NamePackingBits name_packing; diff --git a/gtk2_ardour/visual_time_axis.cc b/gtk2_ardour/visual_time_axis.cc index bad9ce30e9..07d2ae62aa 100644 --- a/gtk2_ardour/visual_time_axis.cc +++ b/gtk2_ardour/visual_time_axis.cc @@ -148,17 +148,13 @@ VisualTimeAxis::set_height(uint32_t h) { TimeAxisView::set_height(h); + show_name_label (); + if (h >= hNormal) { - hide_name_label (); - show_name_entry (); other_button_hbox.show_all() ; } else if (h >= hSmaller) { - hide_name_label (); - show_name_entry (); other_button_hbox.hide_all() ; } else if (h >= hSmall) { - hide_name_entry (); - show_name_label (); other_button_hbox.hide_all() ; } } @@ -339,9 +335,9 @@ VisualTimeAxis::start_time_axis_rename() void VisualTimeAxis::label_view() { - name_label.set_text(time_axis_name) ; - name_entry.set_text(time_axis_name) ; - ARDOUR_UI::instance()->set_tip(name_entry, time_axis_name) ; + name_label.set_text (time_axis_name); + name_entry.set_text (time_axis_name); + ARDOUR_UI::instance()->set_tip (name_entry, Glib::Markup::escape_text (time_axis_name)); } @@ -351,6 +347,8 @@ VisualTimeAxis::label_view() void VisualTimeAxis::name_entry_changed() { + TimeAxisView::name_entry_changed (); + string x = name_entry.get_text (); if (x == time_axis_name) { @@ -365,7 +363,7 @@ VisualTimeAxis::name_entry_changed() } if (!editor.get_named_time_axis(x)) { - set_time_axis_name(x, this); + set_time_axis_name (x, this); } else { ARDOUR_UI::instance()->popup_error (_("A track already exists with that name")); name_entry.set_text(time_axis_name);