simplify time-axis packing: consistent table layout
authorRobin Gareus <robin@gareus.org>
Sun, 31 Aug 2014 05:11:24 +0000 (07:11 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 31 Aug 2014 05:11:24 +0000 (07:11 +0200)
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/route_time_axis.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h

index 538bdc1029d221e22c5da5c457bda94e76f5b243..f474acd007b6ea335aef342c0b53ae87c1ea5e89 100644 (file)
@@ -157,8 +157,8 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        }
        
        name_label.set_text (_name);
-       name_label.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
-        name_label.set_name (X_("TrackParameterName"));
+       name_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       name_label.set_name (X_("TrackParameterName"));
        name_label.set_ellipsize (Pango::ELLIPSIZE_END);
 
        string tipname = nomparent;
@@ -169,16 +169,19 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        ARDOUR_UI::instance()->set_tip(controls_ebox, tipname);
 
        /* add the buttons */
-       controls_table.attach (hide_button, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-       controls_table.attach (name_label, 0, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-       controls_table.attach (auto_button, 6, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+       controls_table.remove (name_hbox);
+       controls_table.attach (hide_button, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       controls_table.attach (name_label,  1, 3, 1, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 2, 0);
+       controls_table.attach (auto_button, 3, 4, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+       controls_table.set_border_width (0);
 
        name_label.show ();
+       hide_button.show ();
 
        if (_controller) {
                _controller.get()->set_size_request(-1, 24);
                /* add bar controller */
-               controls_table.attach (*_controller.get(), 1, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               controls_table.attach (*_controller.get(), 1, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
                /* note that this handler connects *before* the default handler */
                _controller->event_widget().signal_scroll_event().connect (mem_fun (*this, &AutomationTimeAxisView::controls_ebox_scroll), false);
        }
@@ -424,11 +427,13 @@ AutomationTimeAxisView::set_height (uint32_t h)
 
                if (h >= preset_height (HeightNormal)) {
                        auto_button.show();
-                       hide_button.show_all();
+                       name_label.show();
+                       hide_button.show();
 
                } else if (h >= preset_height (HeightSmall)) {
                        controls_table.hide_all ();
                        auto_button.hide();
+                       name_label.hide();
                }
        }
 
index 2362ea8e67f3d31a36400fabd73b2ee1a94e3888..bc86a79c14c3df0781f2bad2afb7472b5145cfb6 100644 (file)
@@ -181,7 +181,8 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
                        break;
                }
 
-               controls_table.attach (*rec_enable_button, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
+               controls_table.attach (*rec_enable_button, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_button_size_group->add_widget(*rec_enable_button);
 
                 if (is_midi_track()) {
                         ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record (Right-click for Step Edit)"));
@@ -199,6 +200,10 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
 
        } else {
                gm.set_fader_name ("AudioBusFader");
+               Gtk::Fixed *blank = manage(new Gtk::Fixed());
+               controls_button_size_group->add_widget(*blank);
+               controls_table.attach (*blank, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               blank->show();
        }
 
        top_hbox.pack_end(gm.get_level_meter(), false, false, 4);
@@ -208,15 +213,23 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        _route->output()->changed.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
        _route->track_number_changed.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::label_view, this), gui_context());
 
-       controls_table.attach (*mute_button, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
+       controls_table.attach (*mute_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       controls_button_size_group->add_widget(*mute_button);
 
-        if (!_route->is_master()) {
-                controls_table.attach (*solo_button, 2, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-        }
+       if (!_route->is_master()) {
+               controls_table.attach (*solo_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_button_size_group->add_widget(*solo_button);
+       } else {
+               Gtk::Fixed *blank = manage(new Gtk::Fixed());
+               controls_button_size_group->add_widget(*blank);
+               controls_table.attach (*blank, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               blank->show();
+       }
 
        if (!ARDOUR::Profile->get_trx()) {
-               controls_table.attach (route_group_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-               name_table.attach (gm.get_gain_slider(), 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 2);
+               controls_table.attach (route_group_button, 2, 3, 3, 4, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_button_size_group->add_widget(route_group_button);
+               controls_table.attach (gm.get_gain_slider(), 3, 6, 2, 4, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
        }
        
        ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
@@ -233,11 +246,13 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        label_view ();
 
        if (!ARDOUR::Profile->get_trx()) {
-               controls_table.attach (automation_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               controls_table.attach (automation_button, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
+               controls_button_size_group->add_widget(automation_button);
        }
 
        if (!ARDOUR::Profile->get_trx() && is_track() && track()->mode() == ARDOUR::Normal) {
-               controls_table.attach (playlist_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               controls_table.attach (playlist_button, 0, 1, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
+               controls_button_size_group->add_widget(playlist_button);
        }
 
        _y_position = -1;
@@ -366,17 +381,14 @@ RouteTimeAxisView::update_track_number_visibility ()
        }
 
        if (number_label.get_parent()) {
-               name_hbox.remove (number_label);
+               controls_table.remove (number_label); // XXX
        }
        if (show_label) {
-//             controls_table.resize ( 2, 4 );
-               name_hbox.pack_start(number_label, false, false, 2);
-//             controls_table.attach (number_label, 3, 4, 0, 1,  Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+               controls_table.attach (number_label, 3, 4, 0, 1,  Gtk::SHRINK, Gtk::SHRINK, 0, 0);
                const int tnw = std::max(2u, _session->track_number_decimals()) * 8; // TODO 8 = max_width_of_digit_0_to_9()
                number_label.set_size_request(3 + tnw, -1);
                number_label.show ();
        } else {
-//             controls_table.resize ( 2, 3 );
                number_label.hide ();
        }
 }
index 7fcd700fac6fa6421ac36266161690a9ad53a665..aaa5ecebd532ae82fd13e49a1d99bfb8b9a7e9d5 100644 (file)
@@ -72,8 +72,8 @@ PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
 
 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
        : AxisView (sess)
-       , controls_table (2, 3)
-       , name_table (2, 1)
+       , controls_table (4, 4)
+       , controls_button_size_group (Gtk::SizeGroup::create (Gtk::SIZE_GROUP_BOTH))
        , _name_editing (false)
        , height (0)
        , display_menu (0)
@@ -126,36 +126,24 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        delete an_entry;
 
        name_hbox.pack_end (name_label, true, true);
+       name_hbox.set_size_request(100, 0); // XXX min header width (if fader is not visible)
        name_hbox.show ();
        name_label.show ();
 
        controls_table.set_row_spacings (2);
        controls_table.set_col_spacings (2);
        controls_table.set_border_width (2);
-       controls_table.set_homogeneous (true);
 
+       controls_table.attach (name_hbox, 4, 5, 0, 2,  Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
        controls_table.show_all ();
        controls_table.set_no_show_all ();
 
-       name_table.attach (name_hbox, 0, 5, 0, 1,  Gtk::FILL|Gtk::EXPAND,  Gtk::FILL|Gtk::EXPAND, 3, 0);
-       name_table.show_all ();
-       name_table.set_no_show_all ();
-
        HSeparator* separator = manage (new HSeparator());
        separator->set_name("TrackSeparator");
        separator->set_size_request(-1, 1);
        separator->show();
 
-       name_vbox.pack_start (name_table, false, false);
-       name_vbox.show ();
-
-       controls_hbox.pack_start (controls_table, false, false);
-       controls_hbox.show ();
-
-       controls_hbox.pack_start (name_vbox, true, true);
-       controls_hbox.show ();
-
-       controls_vbox.pack_start (controls_hbox, false, false);
+       controls_vbox.pack_start (controls_table, false, false);
        controls_vbox.show ();
 
        top_hbox.pack_start (controls_vbox, true, true);
@@ -179,11 +167,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        controls_ebox.signal_leave_notify_event().connect (sigc::mem_fun (*this, &TimeAxisView::controls_ebox_leave));
        controls_ebox.show ();
 
-       time_axis_vbox.pack_start (controls_ebox, true, true, 0);
-//     time_axis_vbox.pack_end (*separator, false, false);
-       time_axis_vbox.show();
-
-       time_axis_frame.add(time_axis_vbox);
+       time_axis_frame.add(controls_ebox);
        time_axis_frame.show();
 
        ColorsChanged.connect (sigc::mem_fun (*this, &TimeAxisView::color_handler));
@@ -607,7 +591,7 @@ TimeAxisView::begin_name_edit ()
 
                name_entry = manage (new Gtkmm2ext::FocusEntry);
                
-               name_entry->set_width_chars(15);
+               name_entry->set_width_chars(8); // min width, entry expands
 
                name_entry->set_name ("EditorTrackNameDisplay");
                name_entry->signal_key_press_event().connect (sigc::mem_fun (*this, &TimeAxisView::name_entry_key_press), false);
@@ -620,7 +604,7 @@ TimeAxisView::begin_name_edit ()
                        name_hbox.remove (name_label);
                }
                
-               name_hbox.pack_end (*name_entry, false, false);
+               name_hbox.pack_end (*name_entry, true, true);
                name_entry->show ();
 
                name_entry->select_region (0, -1);
@@ -776,7 +760,6 @@ TimeAxisView::set_selected (bool yn)
 
                //time_axis_frame.set_name (controls_base_selected_name);
                controls_ebox.set_name (controls_base_selected_name);
-               time_axis_vbox.set_name (controls_base_selected_name);
                controls_vbox.set_name (controls_base_selected_name);
        } else {
                time_axis_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
@@ -784,7 +767,6 @@ TimeAxisView::set_selected (bool yn)
 
                //time_axis_frame.set_name (controls_base_unselected_name);
                controls_ebox.set_name (controls_base_unselected_name);
-               time_axis_vbox.set_name (controls_base_unselected_name);
                controls_vbox.set_name (controls_base_unselected_name);
 
                hide_selection ();
index 5bb2055127cf2769646324b50df56a8dfabb8bdf..c422e140bfb097ac7ec196582ef1d6ca767334e4 100644 (file)
@@ -30,6 +30,7 @@
 #include <gtkmm/table.h>
 #include <gtkmm/entry.h>
 #include <gtkmm/label.h>
+#include <gtkmm/sizegroup.h>
 
 #include <gtkmm2ext/focus_entry.h>
 
@@ -200,13 +201,10 @@ class TimeAxisView : public virtual AxisView
 
        protected:
        /* The Standard LHS Controls */
-       Gtk::HBox              controls_hbox;
        Gtk::Table             controls_table;
-       Gtk::Table             name_table;
+       Glib::RefPtr<Gtk::SizeGroup> controls_button_size_group;
        Gtk::EventBox          controls_ebox;
        Gtk::VBox              controls_vbox;
-       Gtk::VBox              name_vbox;
-       Gtk::VBox              time_axis_vbox;
        Gtk::Frame             time_axis_frame;
        Gtk::HBox              name_hbox;
        Gtk::HBox              top_hbox;