Fix track height menu.
authorCarl Hetherington <carl@carlh.net>
Tue, 11 May 2010 00:09:41 +0000 (00:09 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 11 May 2010 00:09:41 +0000 (00:09 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7093 d708f5d6-7413-0410-9779-e7cbd77b26cf

12 files changed:
gtk2_ardour/ardour.menus.in
gtk2_ardour/automation_line.cc
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/crossfade_view.cc
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_actions.cc
gtk2_ardour/editor_ops.cc
gtk2_ardour/enums.h
gtk2_ardour/route_time_axis.cc
gtk2_ardour/time_axis_view.cc
gtk2_ardour/time_axis_view.h

index c0eb33f7e229eb7b274e1c4394619656a4dba56e..e6ae76a74eaa6b621100578f5b4310d4282749c9 100644 (file)
                <menu action='TrackHeightMenu'>
                     <menuitem action='fit-tracks'/>
                     <menuitem action='track-height-largest'/>
-                    <menuitem action='track-height-large'/>
                     <menuitem action='track-height-larger'/>
+                    <menuitem action='track-height-large'/>
                     <menuitem action='track-height-normal'/>
                     <menuitem action='track-height-smaller'/>
                     <menuitem action='track-height-small'/>
index 844063a22726ac7b6a3d04b75c1a6885482b063c..29163c6aaaa802eaa38e548a4a53d4003e94c49f 100644 (file)
@@ -153,9 +153,9 @@ AutomationLine::control_point_box_size ()
                                4.0);
        }
 
-       if (_height > TimeAxisView::hLarger) {
+       if (_height > TimeAxisView::preset_height (HeightLarger)) {
                return 8.0;
-       } else if (_height > (guint32) TimeAxisView::hNormal) {
+       } else if (_height > (guint32) TimeAxisView::preset_height (HeightNormal)) {
                return 6.0;
        }
        return 4.0;
index d40f5e3405c7ca90ea92ee6891b709c8b7fdb8e2..d2b43d33f925aa1fc8c2e87727ffc367a66e95d6 100644 (file)
@@ -381,10 +381,9 @@ AutomationTimeAxisView::clear_clicked ()
 void
 AutomationTimeAxisView::set_height (uint32_t h)
 {
-       bool changed = (height != (uint32_t) h) || first_call_to_set_height;
-       bool changed_between_small_and_normal = (
-                  (height < hNormal && h >= hNormal)
-               || (height >= hNormal || h < hNormal) );
+       bool const changed = (height != (uint32_t) h) || first_call_to_set_height;
+       uint32_t const normal = preset_height (HeightNormal);
+       bool const changed_between_small_and_normal = ( (height < normal && h >= normal) || (height >= normal || h < normal) );
 
        TimeAxisView* state_parent = get_parent_with_state ();
        assert(state_parent);
@@ -411,7 +410,7 @@ AutomationTimeAxisView::set_height (uint32_t h)
 
                first_call_to_set_height = false;
 
-               if (h >= hNormal) {
+               if (h >= preset_height (HeightNormal)) {
                        controls_table.remove (name_hbox);
 
                        if (plugname) {
@@ -432,7 +431,7 @@ AutomationTimeAxisView::set_height (uint32_t h)
                        auto_button.show();
                        hide_button.show_all();
 
-               } else if (h >= hSmall) {
+               } else if (h >= preset_height (HeightSmall)) {
                        controls_table.remove (name_hbox);
                        if (plugname) {
                                if (plugname_packed) {
@@ -449,7 +448,7 @@ AutomationTimeAxisView::set_height (uint32_t h)
                        auto_button.hide();
                        hide_button.hide();
                }
-       } else if (h >= hNormal){
+       } else if (h >= preset_height (HeightNormal)) {
                cerr << "track grown, but neither changed_between_small_and_normal nor first_call_to_set_height set!" << endl;
        }
 
index 2854de9a782e865e8bb9995fe26769a0e4f1e8be..823934ef4ed81f821f2d3624a8d5e4225c54d6ea 100644 (file)
@@ -108,7 +108,7 @@ CrossfadeView::reset_width_dependent_items (double pixel_width)
 void
 CrossfadeView::set_height (double h)
 {
-       if (h <= TimeAxisView::hSmall) {
+       if (h <= TimeAxisView::preset_height (HeightSmall)) {
                h -= 3.0;
        } else {
                h -= NAME_HIGHLIGHT_SIZE + 3.0;
index d6d1f7bef4ac0098c15b545127b261c878a6d660..085767e50b1776a0a0f7c8ab6f3f970c1d7de1c6 100644 (file)
@@ -4698,8 +4698,8 @@ Editor::add_to_idle_resize (TimeAxisView* view, int32_t h)
        }
 
        /* clamp */
-       if (uint32_t (min_resulting) < TimeAxisView::hSmall) {
-               _pending_resize_amount += TimeAxisView::hSmall - min_resulting;
+       if (uint32_t (min_resulting) < TimeAxisView::preset_height (HeightSmall)) {
+               _pending_resize_amount += TimeAxisView::preset_height (HeightSmall) - min_resulting;
        }
 }
 
index fe2dea81f612c0a716fa199b3a6fc5ff041bc66b..e60ae99c9aab537c28098ceecbcbc4a3f7d79d4a 100644 (file)
@@ -1973,7 +1973,7 @@ public:
 
        void fit_tracks (TrackViewList &);
        void fit_selected_tracks ();
-       void set_track_height (uint32_t h);
+       void set_track_height (Height);
 
        void remove_tracks ();
        void toggle_tracks_active ();
index 79df54b25fdecbb568ce4551a6b04fb87e9b60ef..c13a637ee6e7ee54dbf3145d3246fa06a6636d8e 100644 (file)
@@ -579,28 +579,28 @@ Editor::register_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
         ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-largest", _("Largest"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hLargest));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightLargest));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-larger", _("Larger"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hLarger));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightLarger));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-large", _("Large"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hLarge));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightLarge));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-normal", _("Normal"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hNormal));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightNormal));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-small", _("Small"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hSmall));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightSmall));
        ActionManager::track_selection_sensitive_actions.push_back (act);
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = ActionManager::register_action (editor_actions, "track-height-smaller", _("Smaller"), sigc::bind (
-                               sigc::mem_fun(*this, &Editor::set_track_height), TimeAxisView::hSmaller));
+                               sigc::mem_fun(*this, &Editor::set_track_height), HeightSmaller));
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::track_selection_sensitive_actions.push_back (act);
 
index 669a6096eba4d23ff72b99456e19efcc01e22b36..54ee1288c2ad2120a3fb1e0e2ec1ba4f1081ff98 100644 (file)
@@ -6016,7 +6016,7 @@ Editor::playhead_backward_to_grid ()
 }
 
 void
-Editor::set_track_height (uint32_t h)
+Editor::set_track_height (Height h)
 {
        TrackSelection& ts (selection->tracks);
 
@@ -6325,7 +6325,7 @@ Editor::fit_tracks (TrackViewList & tracks)
        uint32_t h = (uint32_t) floor ((_canvas_height - child_heights - canvas_timebars_vsize) / tracks.size());
        double first_y_pos = DBL_MAX;
 
-       if (h < TimeAxisView::hSmall) {
+       if (h < TimeAxisView::preset_height (HeightSmall)) {
                MessageDialog msg (*this, _("There are too many tracks to fit in the current window"));
                /* too small to be displayed */
                return;
index 62fe7eeacec211d8e4336372f9fcd0bf5a8b82fc..0b0e95f82874979419fe1aaefbdf0b541ce2e7d0 100644 (file)
@@ -45,6 +45,15 @@ struct SelectionRect {
     uint32_t id;
 };
 
+enum Height {
+       HeightLargest,
+       HeightLarger,
+       HeightLarge,
+       HeightNormal,
+       HeightSmall,
+       HeightSmaller
+};
+
 extern void setup_gtk_ardour_enums ();
 
 #endif /* __ardour_gtk_enums_h__ */
index 27c99985742a2eb12050212e51aea7d5ec82024b..e77063c893a3619a4b53db9f2e8be5cd5c69d95c 100644 (file)
@@ -756,7 +756,7 @@ RouteTimeAxisView::set_height (uint32_t h)
        snprintf (buf, sizeof (buf), "%u", height);
        xml_node->add_property ("height", buf);
 
-       if (height >= hNormal) {
+       if (height >= preset_height (HeightNormal)) {
                reset_meter();
                show_name_entry ();
                hide_name_label ();
@@ -778,7 +778,7 @@ RouteTimeAxisView::set_height (uint32_t h)
                        playlist_button.show();
                }
 
-       } else if (height >= hSmaller) {
+       } else if (height >= preset_height (HeightSmaller)) {
 
                reset_meter();
                show_name_entry ();
index 4efb48a19f8ccacd40cc214d107160a2a115796f..e5d4092789fcadf23187367311f7df8c1c5a89fa 100644 (file)
@@ -66,14 +66,8 @@ using namespace ArdourCanvas;
 using Gtkmm2ext::Keyboard;
 
 const double trim_handle_size = 6.0; /* pixels */
-
-uint32_t TimeAxisView::hLargest = 0;
-uint32_t TimeAxisView::hLarge = 0;
-uint32_t TimeAxisView::hLarger = 0;
-uint32_t TimeAxisView::hNormal = 0;
-uint32_t TimeAxisView::hSmaller = 0;
-uint32_t TimeAxisView::hSmall = 0;
-bool TimeAxisView::need_size_info = true;
+uint32_t TimeAxisView::extra_height;
+uint32_t TimeAxisView::smaller_height;
 int const TimeAxisView::_max_order = 512;
 PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
 
@@ -84,10 +78,10 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
          _editor (ed),
          _order (0)
 {
-       if (need_size_info) {
-               compute_controls_size_info ();
-               need_size_info = false;
+       if (extra_height == 0) {
+               compute_heights ();
        }
+       
        _canvas_background = new Group (*ed.get_background_group (), 0.0, 0.0);
        _canvas_display = new Group (*ed.get_trackview_group (), 0.0, 0.0);
        _canvas_display->hide(); // reveal as needed 
@@ -395,9 +389,9 @@ TimeAxisView::step_height (bool bigger)
                set_height (height + step);
        } else {
                if (height > step) {
-                       set_height (std::max (height - step, hSmall));
-               } else if (height != hSmall) {
-                       set_height (hSmall);
+                       set_height (std::max (height - step, preset_height (HeightSmall)));
+               } else if (height != preset_height (HeightSmall)) {
+                       set_height (HeightSmall);
                }
        }
 }
@@ -412,6 +406,12 @@ TimeAxisView::set_heights (uint32_t h)
        }
 }
 
+void
+TimeAxisView::set_height (Height h)
+{
+       set_height (preset_height (h));
+}
+
 void
 TimeAxisView::set_height(uint32_t h)
 {
@@ -474,8 +474,8 @@ TimeAxisView::name_entry_key_release (GdkEventKey* ev)
                
                /* resize to show editable name display */
                
-               if ((*i)->current_height() <= hSmaller) {
-                       (*i)->set_height (hSmaller);
+               if ((*i)->current_height() <= preset_height (HeightSmaller)) {
+                       (*i)->set_height (HeightSmaller);
                }
                
                (*i)->name_entry.grab_focus();
@@ -990,20 +990,20 @@ TimeAxisView::set_state (const XMLNode& node, int /*version*/)
        if ((prop = node.property ("track-height")) != 0) {
 
                if (prop->value() == "largest") {
-                       set_height (hLargest);
+                       set_height (HeightLargest);
                } else if (prop->value() == "large") {
-                       set_height (hLarge);
+                       set_height (HeightLarge);
                } else if (prop->value() == "larger") {
-                       set_height (hLarger);
+                       set_height (HeightLarger);
                } else if (prop->value() == "normal") {
-                       set_height (hNormal);
+                       set_height (HeightNormal);
                } else if (prop->value() == "smaller") {
-                       set_height (hSmaller);
+                       set_height (HeightSmaller);
                } else if (prop->value() == "small") {
-                       set_height (hSmall);
+                       set_height (HeightSmall);
                } else {
                        error << string_compose(_("unknown track height name \"%1\" in XML GUI information"), prop->value()) << endmsg;
-                       set_height (Normal);
+                       set_height (HeightNormal);
                }
 
        } else if ((prop = node.property ("height")) != 0) {
@@ -1012,7 +1012,7 @@ TimeAxisView::set_state (const XMLNode& node, int /*version*/)
 
        } else {
 
-               set_height (hNormal);
+               set_height (HeightNormal);
        }
 
        return 0;
@@ -1029,14 +1029,14 @@ TimeAxisView::reset_height()
 }
 
 void
-TimeAxisView::compute_controls_size_info ()
+TimeAxisView::compute_heights ()
 {
        Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
        Gtk::Table two_row_table (2, 8);
        Gtk::Table one_row_table (1, 8);
        Button* buttons[5];
        const int border_width = 2;
-       const int extra_height = (2 * border_width)
+       extra_height = (2 * border_width)
                //+ 2   // 2 pixels for the hseparator between TimeAxisView control areas
                + 10; // resizer button (3 x 2 pixel elements + 2 x 2 pixel gaps)
 
@@ -1062,36 +1062,9 @@ TimeAxisView::compute_controls_size_info ()
        one_row_table.show_all ();
        Gtk::Requisition req(one_row_table.size_request ());
 
-
        // height required to show 1 row of buttons
 
-       hSmaller = req.height + extra_height;
-
-       window.remove ();
-       window.add (two_row_table);
-
-       two_row_table.attach (*buttons[1], 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-       two_row_table.attach (*buttons[2], 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-       two_row_table.attach (*buttons[3], 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-       two_row_table.attach (*buttons[4], 8, 9, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
-
-       two_row_table.show_all ();
-       req = two_row_table.size_request ();
-
-       // height required to show all normal buttons
-
-       hNormal = /*req.height*/ 48 + extra_height;
-
-       // these heights are all just larger than normal. no more
-       // elements are visible (yet).
-
-       hLarger = hNormal + 50;
-       hLarge = hNormal + 150;
-       hLargest = hNormal + 250;
-
-       // height required to show track name
-
-       hSmall = 27;
+       smaller_height = req.height + extra_height;
 }
 
 void
@@ -1338,3 +1311,25 @@ TimeAxisView::set_visibility (bool yn)
        
        return false;
 }
+
+uint32_t
+TimeAxisView::preset_height (Height h)
+{
+       switch (h) {
+       case HeightLargest:
+               return extra_height + 48 + 250;
+       case HeightLarger:
+               return extra_height + 48 + 150;
+       case HeightLarge:
+               return extra_height + 48 + 50;
+       case HeightNormal:
+               return extra_height + 48;
+       case HeightSmall:
+               return 27;
+       case HeightSmaller:
+               return smaller_height;
+       }
+
+       /* NOTREACHED */
+       return 0;
+}
index d002cc02cf6f23b08f97d035fb3dc990251fd448..4e91b15336a590b55bdff477598623207b657092 100644 (file)
@@ -83,12 +83,6 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
        };
 
   public:
-       static uint32_t hLargest;
-       static uint32_t hLarge;
-       static uint32_t hLarger;
-       static uint32_t hNormal;
-       static uint32_t hSmaller;
-       static uint32_t hSmall;
 
        TimeAxisView(ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* parent, ArdourCanvas::Canvas& canvas);
        virtual ~TimeAxisView ();
@@ -155,6 +149,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
        virtual void exited () {}
 
        virtual void set_height (uint32_t h);
+       void set_height (Height);
        void reset_height();
 
        std::pair<TimeAxisView*, ARDOUR::layer_t> covers_y_position (double);
@@ -222,6 +217,8 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
        typedef std::vector<boost::shared_ptr<TimeAxisView> > Children;
 
        SelectionRect* get_selection_rect(uint32_t id);
+
+       static uint32_t preset_height (Height);
        
   protected:
        /* The Standard LHS Controls */
@@ -310,9 +307,6 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful
        bool in_destructor;
        NamePackingBits name_packing;
 
-       static void compute_controls_size_info ();
-       static bool need_size_info;
-
        void set_heights (uint32_t h);
        void color_handler ();
 
@@ -335,6 +329,10 @@ private:
        double _resize_drag_start;
        ArdourCanvas::Group* _ghost_group;
 
+       void compute_heights ();
+       static uint32_t extra_height;
+       static uint32_t smaller_height;
+
        static int const _max_order;
 
 }; /* class TimeAxisView */