various tweaks to get 80% Of the way to proper use of TimeAxisView::name_label and...
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 12 Jan 2013 04:07:29 +0000 (04:07 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 12 Jan 2013 04:07:29 +0000 (04:07 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13836 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/automation_time_axis.cc
gtk2_ardour/route_time_axis.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h
gtk2_ardour/visual_time_axis.cc

index 498832da0233cb900ca64cbbc88590666577dfc1..618344fcbc69afada5dc079fa421e90fbe84f03e 100644 (file)
@@ -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();
                }
        }
index b501214d6b68a694a867ccb08f92729ff57f1eb3..5d091375b4e2195a3c78ce7a6ab2d755d12a2334 100644 (file)
@@ -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
index 93435af9531d2e86e42fe87431f65bf6c5786d6a..06ff659fabd5e5e2f75a94b236749e2a2cd4dd50 100644 (file)
@@ -70,10 +70,22 @@ PBD::Signal1<void,TimeAxisView*> 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 ();
index 26da869ee523714d439233abf88cdc595cd31951..958b0b55dd8279d08bc6e17f94d968008d3448fa 100644 (file)
@@ -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;
 
index bad9ce30e935bc029dec957e1e7404ed38dcd2cf..07d2ae62aa9b7ca047d53e2e245c217dfcb93053 100644 (file)
@@ -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);