summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-03 02:05:34 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-03 02:05:34 +0000
commit4b35fc4c68fbd4845f7f8f3d2307e97412d7a4d8 (patch)
tree04aab666f44cb9787220fa76d79a3fba379655fd /gtk2_ardour
parentedfc81352e66a412c6bc180c15f788512eccbe42 (diff)
audun's tempo redraw fix; sort-of cache time axis view item name widths and avoid pango-width-computation when unnecessary
git-svn-id: svn://localhost/ardour2/trunk@1657 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/automation_line.cc7
-rw-r--r--gtk2_ardour/automation_line.h1
-rw-r--r--gtk2_ardour/automation_time_axis.cc37
-rw-r--r--gtk2_ardour/automation_time_axis.h3
-rw-r--r--gtk2_ardour/editor.cc4
-rw-r--r--gtk2_ardour/editor.h4
-rw-r--r--gtk2_ardour/editor_canvas.cc4
-rw-r--r--gtk2_ardour/editor_rulers.cc2
-rw-r--r--gtk2_ardour/editor_tempodisplay.cc36
-rw-r--r--gtk2_ardour/ghostregion.cc10
-rw-r--r--gtk2_ardour/ghostregion.h1
-rw-r--r--gtk2_ardour/time_axis_view_item.cc15
-rw-r--r--gtk2_ardour/time_axis_view_item.h5
-rw-r--r--gtk2_ardour/utils.cc14
-rw-r--r--gtk2_ardour/utils.h1
15 files changed, 116 insertions, 28 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index 4978a1ef68..67f91e1ed4 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -1136,6 +1136,13 @@ AutomationLine::set_selected_points (PointSelection& points)
}
+void AutomationLine::set_colors() {
+ set_line_color( color_map[cAutomationLine] );
+ for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+ (*i)->show_color (false, !points_visible);
+ }
+}
+
void
AutomationLine::show_selection ()
{
diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h
index 4942643b65..76afff5097 100644
--- a/gtk2_ardour/automation_line.h
+++ b/gtk2_ardour/automation_line.h
@@ -159,6 +159,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulThingWithGoin
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ void set_colors();
protected:
diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc
index 69653c9c99..0da3a38fdc 100644
--- a/gtk2_ardour/automation_time_axis.cc
+++ b/gtk2_ardour/automation_time_axis.cc
@@ -163,6 +163,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
/* make sure labels etc. are correct */
automation_state_changed ();
+ ColorChanged.connect (mem_fun (*this, &AutomationTimeAxisView::color_handler));
}
AutomationTimeAxisView::~AutomationTimeAxisView ()
@@ -788,6 +789,42 @@ AutomationTimeAxisView::exited ()
}
void
+AutomationTimeAxisView::set_colors () {
+
+ for( list<GhostRegion *>::iterator i=ghosts.begin(); i != ghosts.end(); i++ ) {
+ (*i)->set_colors();
+ }
+
+ for( vector<AutomationLine *>::iterator i=lines.begin(); i != lines.end(); i++ ) {
+ (*i)->set_colors();
+ }
+
+}
+
+void
+AutomationTimeAxisView::color_handler (ColorID id, uint32_t val) {
+
+ switch (id) {
+ case cGhostTrackWave:
+ case cGhostTrackWaveClip:
+ case cGhostTrackZeroLine:
+
+ case cControlPoint:
+ case cControlPointFill:
+ case cControlPointOutline:
+ case cAutomationLine:
+ set_colors ();
+
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+
+void
AutomationTimeAxisView::set_state (const XMLNode& node)
{
TimeAxisView::set_state (node);
diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h
index 0eb525f6c1..f7c61942df 100644
--- a/gtk2_ardour/automation_time_axis.h
+++ b/gtk2_ardour/automation_time_axis.h
@@ -122,6 +122,9 @@ class AutomationTimeAxisView : public TimeAxisView {
void entered ();
void exited ();
+ void set_colors ();
+ void color_handler (ColorID, uint32_t);
+
static Pango::FontDescription name_font;
static bool have_name_font;
};
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index a62e193a62..885b3027c4 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -1075,7 +1075,7 @@ Editor::connect_to_session (Session *t)
session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
- session_connections.push_back (session->tempo_map().StateChanged.connect (bind (mem_fun(*this, &Editor::tempo_map_changed), false)));
+ session_connections.push_back (session->tempo_map().StateChanged.connect (mem_fun(*this, &Editor::tempo_map_changed)));
edit_groups_changed ();
@@ -3665,7 +3665,7 @@ Editor::idle_visual_changer ()
/* the signal handler will do the rest */
} else {
update_fixed_rulers();
- tempo_map_changed (Change (0), true);
+ redisplay_tempo (true);
}
}
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 20e6429aae..fd3ecee508 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1275,8 +1275,8 @@ class Editor : public PublicEditor
void remove_metric_marks ();
void draw_metric_marks (const ARDOUR::Metrics& metrics);
- void tempo_map_changed (ARDOUR::Change, bool immediate_redraw);
- void redisplay_tempo ();
+ void tempo_map_changed (ARDOUR::Change);
+ void redisplay_tempo (bool immediate_redraw);
void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false);
uint32_t bbt_beat_subdivision;
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index d9fe6f529f..049f6f48b2 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -368,7 +368,7 @@ Editor::track_canvas_size_allocated ()
}
update_fixed_rulers();
- tempo_map_changed (Change (0), true);
+ redisplay_tempo (true);
Resized (); /* EMIT_SIGNAL */
@@ -723,6 +723,6 @@ Editor::canvas_horizontally_scrolled ()
update_fixed_rulers ();
- tempo_map_changed (Change (0), !_dragging_hscrollbar);
+ redisplay_tempo (!_dragging_hscrollbar);
}
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index 9dac8bc4c0..1a928002a8 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -709,7 +709,7 @@ Editor::update_ruler_visibility ()
update_fixed_rulers();
//update_tempo_based_rulers();
- tempo_map_changed(Change (0), false);
+ redisplay_tempo (false);
time_canvas_event_box.show_all();
time_button_frame.show_all();
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc
index fc5117fcf5..339c335fa3 100644
--- a/gtk2_ardour/editor_tempodisplay.cc
+++ b/gtk2_ardour/editor_tempodisplay.cc
@@ -93,13 +93,28 @@ Editor::draw_metric_marks (const Metrics& metrics)
}
void
-Editor::tempo_map_changed (Change ignored, bool immediate_redraw)
+Editor::tempo_map_changed (Change ignored)
{
if (!session) {
return;
}
- ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::tempo_map_changed), ignored, immediate_redraw));
+ ENSURE_GUI_THREAD(bind (mem_fun (*this, &Editor::tempo_map_changed), ignored));
+
+ redisplay_tempo (false); // redraw rulers and measures
+ session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks); // redraw metric markers
+}
+
+/**
+ * This code was originally in tempo_map_changed, but this is called every time the canvas scrolls horizontally.
+ * That's why this is moved in here. The new tempo_map_changed is called when the ARDOUR::TempoMap actually changed.
+ */
+void
+Editor::redisplay_tempo (bool immediate_redraw)
+{
+ if (!session) {
+ return;
+ }
BBT_Time previous_beat, next_beat; // the beats previous to the leftmost frame and after the rightmost frame
@@ -153,11 +168,6 @@ Editor::tempo_map_changed (Change ignored, bool immediate_redraw)
}
void
-Editor::redisplay_tempo ()
-{
-}
-
-void
Editor::hide_measures ()
{
for (TimeLineList::iterator i = used_measure_lines.begin(); i != used_measure_lines.end(); ++i) {
@@ -307,8 +317,6 @@ Editor::mouse_add_new_tempo_event (nframes_t frame)
commit_reversible_command ();
map.dump (cerr);
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
@@ -349,8 +357,6 @@ Editor::mouse_add_new_meter_event (nframes_t frame)
commit_reversible_command ();
map.dump (cerr);
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
@@ -401,8 +407,6 @@ Editor::edit_meter_section (MeterSection* section)
XMLNode &after = session->tempo_map().get_state();
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
@@ -433,8 +437,6 @@ Editor::edit_tempo_section (TempoSection* section)
XMLNode &after = session->tempo_map().get_state();
session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
@@ -485,8 +487,6 @@ Editor::real_remove_tempo_marker (TempoSection *section)
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
-
return FALSE;
}
@@ -521,7 +521,5 @@ Editor::real_remove_meter_marker (MeterSection *section)
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
commit_reversible_command ();
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
-
return FALSE;
}
diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc
index 2cd2601406..7f7d11c0be 100644
--- a/gtk2_ardour/ghostregion.cc
+++ b/gtk2_ardour/ghostregion.cc
@@ -69,3 +69,13 @@ GhostRegion::set_height ()
}
}
+void
+GhostRegion::set_colors ()
+{
+ for (uint32_t n=0; n < waves.size(); ++n) {
+ waves[n]->property_wave_color() = color_map[cGhostTrackWave];
+
+ waves[n]->property_clip_color() = color_map[cGhostTrackWaveClip];
+ waves[n]->property_zero_color() = color_map[cGhostTrackZeroLine];
+ }
+}
diff --git a/gtk2_ardour/ghostregion.h b/gtk2_ardour/ghostregion.h
index 77b22f942c..1e32add794 100644
--- a/gtk2_ardour/ghostregion.h
+++ b/gtk2_ardour/ghostregion.h
@@ -41,6 +41,7 @@ struct GhostRegion : public sigc::trackable
void set_samples_per_unit (double spu);
void set_duration (double units);
void set_height ();
+ void set_colors ();
sigc::signal<void,GhostRegion*> GoingAway;
};
diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc
index 09d959358d..cf29fae9bd 100644
--- a/gtk2_ardour/time_axis_view_item.cc
+++ b/gtk2_ardour/time_axis_view_item.cc
@@ -125,6 +125,8 @@ void
TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_color, nframes_t start, nframes_t duration, Visibility vis)
{
item_name = it_name ;
+ name_text_width = ::pixel_width (it_name, NAME_FONT);
+ last_name_text_width = 0;
samples_per_unit = spu ;
should_show_selection = true;
frame_position = start ;
@@ -488,6 +490,7 @@ TimeAxisViewItem::set_item_name(std::string new_name, void* src)
if (new_name != item_name) {
std::string temp_name = item_name ;
item_name = new_name ;
+ name_text_width = ::pixel_width (new_name, NAME_FONT);
NameChanged (item_name, temp_name, src) ; /* EMIT_SIGNAL */
}
}
@@ -553,10 +556,11 @@ TimeAxisViewItem::get_time_axis_view()
* @param new_name the new name text to display
*/
void
-TimeAxisViewItem::set_name_text(std::string new_name)
+TimeAxisViewItem::set_name_text(const ustring& new_name)
{
if (name_text) {
name_text->property_text() = new_name.c_str();
+ name_text_width = pixel_width (new_name, NAME_FONT);
}
}
@@ -913,6 +917,13 @@ TimeAxisViewItem::reset_name_width (double pixel_width)
if (name_text == 0) {
return;
}
+
+ if ((last_name_text_width && // we did this once
+ (name_text_width <= pixel_width - NAME_X_OFFSET) && // fits the new size
+ (name_text_width <= last_name_text_width - NAME_X_OFFSET))) { // fit into the old size too
+ last_name_text_width = pixel_width;
+ return;
+ }
int width;
@@ -941,6 +952,8 @@ TimeAxisViewItem::reset_name_width (double pixel_width)
name_text->property_text() = ustr;
name_text->show();
}
+
+ last_name_text_width = pixel_width;
}
diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h
index e0331a2de2..960d940268 100644
--- a/gtk2_ardour/time_axis_view_item.h
+++ b/gtk2_ardour/time_axis_view_item.h
@@ -199,7 +199,7 @@ class TimeAxisViewItem : public Selectable
*
* @param new_name the new name text to display
*/
- void set_name_text(std::string new_name) ;
+ void set_name_text(const Glib::ustring& new_name) ;
/**
* Set the height of this item
@@ -461,6 +461,9 @@ class TimeAxisViewItem : public Selectable
ArdourCanvas::SimpleRect* frame_handle_start;
ArdourCanvas::SimpleRect* frame_handle_end;
+ int name_text_width;
+ double last_name_text_width;
+
Visibility visibility;
}; /* class TimeAxisViewItem */
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index fbebf0d51a..9c1ef22a88 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -44,6 +44,20 @@ using namespace sigc;
using namespace Glib;
using namespace PBD;
+int
+pixel_width (const ustring& str, Pango::FontDescription& font)
+{
+ Label foo;
+ Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
+
+ layout->set_font_description (font);
+ layout->set_text (str);
+
+ int width, height;
+ Gtkmm2ext::get_ink_pixel_size (layout, width, height);
+ return width;
+}
+
ustring
fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
{
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index 2d2f879073..b95f09d243 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -53,6 +53,7 @@ slider_position_to_gain (double pos)
}
Glib::ustring fit_to_pixels (const Glib::ustring&, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses = false);
+int pixel_width (const Glib::ustring& str, Pango::FontDescription& font);
gint just_hide_it (GdkEventAny*, Gtk::Window*);
void allow_keyboard_focus (bool);