mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
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
This commit is contained in:
parent
edfc81352e
commit
4b35fc4c68
15 changed files with 116 additions and 28 deletions
|
|
@ -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
|
void
|
||||||
AutomationLine::show_selection ()
|
AutomationLine::show_selection ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulThingWithGoin
|
||||||
|
|
||||||
XMLNode& get_state (void);
|
XMLNode& get_state (void);
|
||||||
int set_state (const XMLNode&);
|
int set_state (const XMLNode&);
|
||||||
|
void set_colors();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Ro
|
||||||
/* make sure labels etc. are correct */
|
/* make sure labels etc. are correct */
|
||||||
|
|
||||||
automation_state_changed ();
|
automation_state_changed ();
|
||||||
|
ColorChanged.connect (mem_fun (*this, &AutomationTimeAxisView::color_handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
AutomationTimeAxisView::~AutomationTimeAxisView ()
|
AutomationTimeAxisView::~AutomationTimeAxisView ()
|
||||||
|
|
@ -787,6 +788,42 @@ AutomationTimeAxisView::exited ()
|
||||||
hide_all_but_selected_control_points ();
|
hide_all_but_selected_control_points ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
void
|
||||||
AutomationTimeAxisView::set_state (const XMLNode& node)
|
AutomationTimeAxisView::set_state (const XMLNode& node)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,9 @@ class AutomationTimeAxisView : public TimeAxisView {
|
||||||
void entered ();
|
void entered ();
|
||||||
void exited ();
|
void exited ();
|
||||||
|
|
||||||
|
void set_colors ();
|
||||||
|
void color_handler (ColorID, uint32_t);
|
||||||
|
|
||||||
static Pango::FontDescription name_font;
|
static Pango::FontDescription name_font;
|
||||||
static bool have_name_font;
|
static bool have_name_font;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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->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 ();
|
edit_groups_changed ();
|
||||||
|
|
||||||
|
|
@ -3665,7 +3665,7 @@ Editor::idle_visual_changer ()
|
||||||
/* the signal handler will do the rest */
|
/* the signal handler will do the rest */
|
||||||
} else {
|
} else {
|
||||||
update_fixed_rulers();
|
update_fixed_rulers();
|
||||||
tempo_map_changed (Change (0), true);
|
redisplay_tempo (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1275,8 +1275,8 @@ class Editor : public PublicEditor
|
||||||
void remove_metric_marks ();
|
void remove_metric_marks ();
|
||||||
void draw_metric_marks (const ARDOUR::Metrics& metrics);
|
void draw_metric_marks (const ARDOUR::Metrics& metrics);
|
||||||
|
|
||||||
void tempo_map_changed (ARDOUR::Change, bool immediate_redraw);
|
void tempo_map_changed (ARDOUR::Change);
|
||||||
void redisplay_tempo ();
|
void redisplay_tempo (bool immediate_redraw);
|
||||||
|
|
||||||
void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false);
|
void snap_to (nframes_t& first, int32_t direction = 0, bool for_mark = false);
|
||||||
uint32_t bbt_beat_subdivision;
|
uint32_t bbt_beat_subdivision;
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ Editor::track_canvas_size_allocated ()
|
||||||
}
|
}
|
||||||
|
|
||||||
update_fixed_rulers();
|
update_fixed_rulers();
|
||||||
tempo_map_changed (Change (0), true);
|
redisplay_tempo (true);
|
||||||
|
|
||||||
Resized (); /* EMIT_SIGNAL */
|
Resized (); /* EMIT_SIGNAL */
|
||||||
|
|
||||||
|
|
@ -723,6 +723,6 @@ Editor::canvas_horizontally_scrolled ()
|
||||||
|
|
||||||
update_fixed_rulers ();
|
update_fixed_rulers ();
|
||||||
|
|
||||||
tempo_map_changed (Change (0), !_dragging_hscrollbar);
|
redisplay_tempo (!_dragging_hscrollbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -709,7 +709,7 @@ Editor::update_ruler_visibility ()
|
||||||
|
|
||||||
update_fixed_rulers();
|
update_fixed_rulers();
|
||||||
//update_tempo_based_rulers();
|
//update_tempo_based_rulers();
|
||||||
tempo_map_changed(Change (0), false);
|
redisplay_tempo (false);
|
||||||
|
|
||||||
time_canvas_event_box.show_all();
|
time_canvas_event_box.show_all();
|
||||||
time_button_frame.show_all();
|
time_button_frame.show_all();
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,28 @@ Editor::draw_metric_marks (const Metrics& metrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::tempo_map_changed (Change ignored, bool immediate_redraw)
|
Editor::tempo_map_changed (Change ignored)
|
||||||
{
|
{
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return;
|
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
|
BBT_Time previous_beat, next_beat; // the beats previous to the leftmost frame and after the rightmost frame
|
||||||
|
|
||||||
|
|
@ -152,11 +167,6 @@ Editor::tempo_map_changed (Change ignored, bool immediate_redraw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Editor::redisplay_tempo ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Editor::hide_measures ()
|
Editor::hide_measures ()
|
||||||
{
|
{
|
||||||
|
|
@ -307,8 +317,6 @@ Editor::mouse_add_new_tempo_event (nframes_t frame)
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
map.dump (cerr);
|
map.dump (cerr);
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -349,8 +357,6 @@ Editor::mouse_add_new_meter_event (nframes_t frame)
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
map.dump (cerr);
|
map.dump (cerr);
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -401,8 +407,6 @@ Editor::edit_meter_section (MeterSection* section)
|
||||||
XMLNode &after = session->tempo_map().get_state();
|
XMLNode &after = session->tempo_map().get_state();
|
||||||
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -433,8 +437,6 @@ Editor::edit_tempo_section (TempoSection* section)
|
||||||
XMLNode &after = session->tempo_map().get_state();
|
XMLNode &after = session->tempo_map().get_state();
|
||||||
session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
session->add_command (new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -485,8 +487,6 @@ Editor::real_remove_tempo_marker (TempoSection *section)
|
||||||
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,7 +521,5 @@ Editor::real_remove_meter_marker (MeterSection *section)
|
||||||
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
session->add_command(new MementoCommand<TempoMap>(session->tempo_map(), &before, &after));
|
||||||
commit_reversible_command ();
|
commit_reversible_command ();
|
||||||
|
|
||||||
session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ struct GhostRegion : public sigc::trackable
|
||||||
void set_samples_per_unit (double spu);
|
void set_samples_per_unit (double spu);
|
||||||
void set_duration (double units);
|
void set_duration (double units);
|
||||||
void set_height ();
|
void set_height ();
|
||||||
|
void set_colors ();
|
||||||
|
|
||||||
sigc::signal<void,GhostRegion*> GoingAway;
|
sigc::signal<void,GhostRegion*> GoingAway;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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)
|
TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_color, nframes_t start, nframes_t duration, Visibility vis)
|
||||||
{
|
{
|
||||||
item_name = it_name ;
|
item_name = it_name ;
|
||||||
|
name_text_width = ::pixel_width (it_name, NAME_FONT);
|
||||||
|
last_name_text_width = 0;
|
||||||
samples_per_unit = spu ;
|
samples_per_unit = spu ;
|
||||||
should_show_selection = true;
|
should_show_selection = true;
|
||||||
frame_position = start ;
|
frame_position = start ;
|
||||||
|
|
@ -488,6 +490,7 @@ TimeAxisViewItem::set_item_name(std::string new_name, void* src)
|
||||||
if (new_name != item_name) {
|
if (new_name != item_name) {
|
||||||
std::string temp_name = item_name ;
|
std::string temp_name = item_name ;
|
||||||
item_name = new_name ;
|
item_name = new_name ;
|
||||||
|
name_text_width = ::pixel_width (new_name, NAME_FONT);
|
||||||
NameChanged (item_name, temp_name, src) ; /* EMIT_SIGNAL */
|
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
|
* @param new_name the new name text to display
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TimeAxisViewItem::set_name_text(std::string new_name)
|
TimeAxisViewItem::set_name_text(const ustring& new_name)
|
||||||
{
|
{
|
||||||
if (name_text) {
|
if (name_text) {
|
||||||
name_text->property_text() = new_name.c_str();
|
name_text->property_text() = new_name.c_str();
|
||||||
|
name_text_width = pixel_width (new_name, NAME_FONT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -914,6 +918,13 @@ TimeAxisViewItem::reset_name_width (double pixel_width)
|
||||||
return;
|
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;
|
int width;
|
||||||
|
|
||||||
ustring ustr = fit_to_pixels (item_name, (int) floor (pixel_width - NAME_X_OFFSET), NAME_FONT, width);
|
ustring ustr = fit_to_pixels (item_name, (int) floor (pixel_width - NAME_X_OFFSET), NAME_FONT, width);
|
||||||
|
|
@ -941,6 +952,8 @@ TimeAxisViewItem::reset_name_width (double pixel_width)
|
||||||
name_text->property_text() = ustr;
|
name_text->property_text() = ustr;
|
||||||
name_text->show();
|
name_text->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_name_text_width = pixel_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ class TimeAxisViewItem : public Selectable
|
||||||
*
|
*
|
||||||
* @param new_name the new name text to display
|
* @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
|
* Set the height of this item
|
||||||
|
|
@ -461,6 +461,9 @@ class TimeAxisViewItem : public Selectable
|
||||||
ArdourCanvas::SimpleRect* frame_handle_start;
|
ArdourCanvas::SimpleRect* frame_handle_start;
|
||||||
ArdourCanvas::SimpleRect* frame_handle_end;
|
ArdourCanvas::SimpleRect* frame_handle_end;
|
||||||
|
|
||||||
|
int name_text_width;
|
||||||
|
double last_name_text_width;
|
||||||
|
|
||||||
Visibility visibility;
|
Visibility visibility;
|
||||||
|
|
||||||
}; /* class TimeAxisViewItem */
|
}; /* class TimeAxisViewItem */
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,20 @@ using namespace sigc;
|
||||||
using namespace Glib;
|
using namespace Glib;
|
||||||
using namespace PBD;
|
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
|
ustring
|
||||||
fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
|
fit_to_pixels (const ustring& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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);
|
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*);
|
gint just_hide_it (GdkEventAny*, Gtk::Window*);
|
||||||
void allow_keyboard_focus (bool);
|
void allow_keyboard_focus (bool);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue