fix for crash when loading a session after running another, caused by not checking for _view != 0 in route_time_axis.cc; make fit_to_pixels() more useful and use it to truncate redirect and redirect parameters names in track control area

git-svn-id: svn://localhost/ardour2/trunk@1212 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-12-14 16:21:43 +00:00
parent b7f645cbe6
commit 0d6c5f78e9
8 changed files with 67 additions and 31 deletions

View 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"

View 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 ()

View 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;
}

View 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__ */

View 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);
}

View File

@ -241,6 +241,8 @@ protected:
vector<RedirectAutomationLine*> redirect_automation_curves;
sigc::connection modified_connection;
void post_construct ();
};
#endif /* __ardour_route_time_axis_h__ */

View 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

View 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);