}
+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 ()
{
XMLNode& get_state (void);
int set_state (const XMLNode&);
+ void set_colors();
protected:
/* make sure labels etc. are correct */
automation_state_changed ();
+ ColorChanged.connect (mem_fun (*this, &AutomationTimeAxisView::color_handler));
}
AutomationTimeAxisView::~AutomationTimeAxisView ()
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
AutomationTimeAxisView::set_state (const XMLNode& node)
{
void entered ();
void exited ();
+ void set_colors ();
+ void color_handler (ColorID, uint32_t);
+
static Pango::FontDescription name_font;
static bool have_name_font;
};
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 ();
/* the signal handler will do the rest */
} else {
update_fixed_rulers();
- tempo_map_changed (Change (0), true);
+ redisplay_tempo (true);
}
}
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;
}
update_fixed_rulers();
- tempo_map_changed (Change (0), true);
+ redisplay_tempo (true);
Resized (); /* EMIT_SIGNAL */
update_fixed_rulers ();
- tempo_map_changed (Change (0), !_dragging_hscrollbar);
+ redisplay_tempo (!_dragging_hscrollbar);
}
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();
}
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
}
}
-void
-Editor::redisplay_tempo ()
-{
-}
-
void
Editor::hide_measures ()
{
commit_reversible_command ();
map.dump (cerr);
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
commit_reversible_command ();
map.dump (cerr);
-
- session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
}
void
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
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
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;
}
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;
}
}
}
+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];
+ }
+}
void set_samples_per_unit (double spu);
void set_duration (double units);
void set_height ();
+ void set_colors ();
sigc::signal<void,GhostRegion*> GoingAway;
};
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 ;
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 */
}
}
* @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);
}
}
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;
name_text->property_text() = ustr;
name_text->show();
}
+
+ last_name_text_width = pixel_width;
}
*
* @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
ArdourCanvas::SimpleRect* frame_handle_start;
ArdourCanvas::SimpleRect* frame_handle_end;
+ int name_text_width;
+ double last_name_text_width;
+
Visibility visibility;
}; /* class TimeAxisViewItem */
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)
{
}
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);