fix for crash when loading a session after running another, caused by not checking...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 14 Dec 2006 16:21:43 +0000 (16:21 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 14 Dec 2006 16:21:43 +0000 (16:21 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1212 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour2_ui.rc
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/automation_time_axis.h
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_time_axis.h
gtk2_ardour/utils.cc
gtk2_ardour/utils.h

index d28b6622e748867151c8bee246fd74ef81f4dcd4..81abce1830d8a4f4cfe05134d04799e4cf8decce 100644 (file)
@@ -58,6 +58,11 @@ style "plugin_maker_text"
        fg[NORMAL] = { 0.80, 0.80, 0.80 }
 }
 
+style "automation_track_name"
+{
+       font_name = "sans italic 8"
+}
+
 style "first_action_message" 
 {
        font_name = "sans medium 34"
@@ -1157,6 +1162,7 @@ widget "*EditorMainCanvas" style "main_canvas_area"
 widget "*AudioTrackControlsBaseInactiveUnselected" style "track_controls_inactive"
 widget "*BusControlsBaseInactiveUnselected" style "track_controls_inactive"
 widget "*AutomationTrackControlsBaseInactiveUnselected" style "track_controls_inactive"
+widget "*AutomationTrackName" style "automation_track_name"
 widget "*AudioTrackControlsBaseInactiveSelected" style "track_controls_inactive"
 widget "*BusControlsBaseInactiveSelected" style "track_controls_inactive"
 widget "*AutomationTrackControlsBaseInactiveSelected" style "track_controls_inactive"
index 4ab0428a5100ff6f5ce20d1d89b9ca4b59674e2d..45c8700a6a78a95dee7087829e2734dbe59b789a 100644 (file)
@@ -124,6 +124,8 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
                controls_base_selected_name = "AudioBusControlsBaseSelected";
                controls_base_unselected_name = "AudioBusControlsBaseUnselected";
        }
+
+       post_construct ();
 }
 
 AudioTimeAxisView::~AudioTimeAxisView ()
index e99d755615d90c5de60e8d070ea6be568de5f756..776dff37f21c8e49b815342e96b8ff2708ac2fa3 100644 (file)
@@ -21,6 +21,9 @@ using namespace PBD;
 using namespace Gtk;
 using namespace Editing;
 
+Pango::FontDescription AutomationTimeAxisView::name_font;
+bool AutomationTimeAxisView::have_name_font = false;
+
 AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, PublicEditor& e, TimeAxisView& rent, 
                                                ArdourCanvas::Canvas& canvas, const string & nom, 
                                                const string & state_name, const string & nomparent)
@@ -34,6 +37,11 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
          clear_button (_("clear")),
          auto_button (X_("")) /* force addition of a label */
 {
+       if (!have_name_font) {
+               name_font = get_font_for_style (X_("AutomationTrackName"));
+               have_name_font = true;
+       }
+
        automation_menu = 0;
        in_destructor = false;
        auto_off_item = 0;
@@ -84,14 +92,14 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
 
        string shortpname = _name;
        bool shortened = false;
-       
-       if (_name.length()) {
-               if (shortpname.length() > 18) {
-                       shortpname = shortpname.substr (0, 16);
-                       shortpname += "...";
-                       shortened = true;
-               }
+
+       int ignore_width;
+       shortpname = fit_to_pixels (_name, 60, name_font, ignore_width, true);
+
+       if (shortpname != _name ){
+               shortened = true;
        }
+
        name_label.set_text (shortpname);
        name_label.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
 
@@ -99,11 +107,8 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
 
                /* limit the plug name string */
 
-               string pname = nomparent;
-
-               if (pname.length() > 14) {
-                       pname = pname.substr (0, 11);
-                       pname += "...";
+               string pname = fit_to_pixels (nomparent, 60, name_font, ignore_width, true);
+               if (pname != nomparent) {
                        shortened = true;
                }
 
index 30fa71bea973608bff90dfc4f10b2c29508ce0f5..0eb525f6c1805c2d083e8b100b19687b016779aa 100644 (file)
@@ -121,6 +121,9 @@ class AutomationTimeAxisView : public TimeAxisView {
 
        void entered ();
        void exited ();
+
+       static Pango::FontDescription name_font;
+       static bool have_name_font;
 };
 
 #endif /* __ardour_gtk_automation_time_axis_h__ */
index bacd9e23f44ede23a2a3628be13b04cd8d26ad07..b3a95711f1caeca0b17649a46821460f7a790936 100644 (file)
@@ -186,11 +186,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
        hide_button.unset_flags (Gtk::CAN_FOCUS);
        visual_button.unset_flags (Gtk::CAN_FOCUS);
 
-       /* map current state of the route */
-
-       update_diskstream_display ();
-       redirects_changed (0);
-       reset_redirect_automation_curves ();
        y_position = -1;
 
        _route->redirects_changed.connect (mem_fun(*this, &RouteTimeAxisView::redirects_changed));
@@ -203,11 +198,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
                track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
                get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
 
-               /* ask for notifications of any new RegionViews */
-               // FIXME: _view is NULL, but it would be nice to attach this here :/
-               //_view->RegionViewAdded.connect (mem_fun(*this, &RouteTimeAxisView::region_view_added));
-               //_view->attach ();
-
                /* pick up the correct freeze state */
                map_frozen ();
 
@@ -215,7 +205,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh
 
        editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
        ColorChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
-
 }
 
 RouteTimeAxisView::~RouteTimeAxisView ()
@@ -244,6 +233,17 @@ RouteTimeAxisView::~RouteTimeAxisView ()
        }
 }
 
+void
+RouteTimeAxisView::post_construct ()
+{
+       /* map current state of the route */
+
+       update_diskstream_display ();
+       _route->foreach_redirect (this, &RouteTimeAxisView::add_redirect_to_subplugin_menu);
+       _route->foreach_redirect (this, &RouteTimeAxisView::add_existing_redirect_automation_curves);
+       reset_redirect_automation_curves ();
+}
+
 void
 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
 {
@@ -663,7 +663,9 @@ RouteTimeAxisView::set_height (TrackHeight h)
 
        ensure_xml_node ();
 
-       _view->set_height ((double) height);
+       if (_view) {
+               _view->set_height ((double) height);
+       }
 
        switch (height_style) {
        case Largest:
@@ -1032,7 +1034,9 @@ RouteTimeAxisView::set_selected_points (PointSelection& points)
 void
 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
 {
-       _view->set_selected_regionviews (regions);
+       if (_view) {
+               _view->set_selected_regionviews (regions);
+       }
 }
 
 void
@@ -1549,7 +1553,9 @@ RouteTimeAxisView::add_redirect_automation_curve (boost::shared_ptr<Redirect> re
 
        add_child (ran->view);
 
-       _view->foreach_regionview (bind (mem_fun(*this, &RouteTimeAxisView::add_ghost_to_redirect), ran->view));
+       if (_view) {
+               _view->foreach_regionview (bind (mem_fun(*this, &RouteTimeAxisView::add_ghost_to_redirect), ran->view));
+       }
 
        redirect->mark_automation_visible (what, true);
 }
index 1e28a790a63bf7c305336d9fa16229841bb74184..c597f2893ca3a0fa774c3c87db666d398394bd4d 100644 (file)
@@ -241,6 +241,8 @@ protected:
        vector<RedirectAutomationLine*> redirect_automation_curves;
 
        sigc::connection modified_connection;
+
+       void post_construct ();
 };
 
 #endif /* __ardour_route_time_axis_h__ */
index 389d43d2f234061642630ed7fde3c425765d0e06..887494829eab97dbc8c4fd3102cd1bc029e6233d 100644 (file)
@@ -46,11 +46,13 @@ using namespace Glib;
 using namespace PBD;
 
 ustring
-fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width)
+fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
 {
        Label foo;
        Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
-       
+       ustring::size_type shorter_by = 0;
+       ustring txt;
+
        layout->set_font_description (font);
 
        actual_width = 0;
@@ -59,9 +61,11 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font
        ustring::iterator last = ustr.end();
        --last; /* now points at final entry */
 
+       txt = ustr;
+
        while (!ustr.empty()) {
 
-               layout->set_text (ustr);
+               layout->set_text (txt);
 
                int width, height;
                Gtkmm2ext::get_ink_pixel_size (layout, width, height);
@@ -72,9 +76,17 @@ fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font
                }
                
                ustr.erase (last--);
+               shorter_by++;
+
+               if (with_ellipses && shorter_by > 3) {
+                       txt = ustr;
+                       txt += "...";
+               } else {
+                       txt = ustr;
+               }
        }
 
-       return ustr;
+       return txt;
 }
 
 gint
index 244e45d260d91eeed1f66494b61421d01bd5e9c1..6d5ff0702d8b7443577a6cb30ac58ea6db0894a1 100644 (file)
@@ -53,7 +53,7 @@ slider_position_to_gain (double pos)
        return pow (2.0,(sqrt(sqrt(sqrt(pos)))*198.0-192.0)/6.0);
 }
 
-Glib::ustring fit_to_pixels (const Glib::ustring&, int pixel_width, Pango::FontDescription& font, int& actual_width);
+Glib::ustring fit_to_pixels (const Glib::ustring&, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses = false);
 
 gint   just_hide_it (GdkEventAny*, Gtk::Window*);
 void   allow_keyboard_focus (bool);