make marker labels and regionview name text (now drawn with pixbufs) be color-adjustable just like all other canvas items

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@7212 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-06-02 15:54:51 +00:00
parent 519eaabe8b
commit f9a47cff2b
9 changed files with 45 additions and 9 deletions

View File

@ -75,6 +75,7 @@
<Option name="tempo bar" value="72727fff"/>
<Option name="TempoMarker" value="f2425bff"/>
<Option name="TimeAxisFrame" value="000000cb"/>
<Option name="time axis item name" value="000000ff"/>
<Option name="time-stretch-fill" value="e2b5b596"/>
<Option name="time-stretch-outline" value="63636396"/>
<Option name="TransportDragRect" value="969696c6"/>

View File

@ -72,6 +72,7 @@ CANVAS_VARIABLE(canvasvar_Selection, "Selection")
CANVAS_VARIABLE(canvasvar_TempoBar, "tempo bar")
CANVAS_VARIABLE(canvasvar_TempoMarker, "TempoMarker")
CANVAS_VARIABLE(canvasvar_TimeAxisFrame, "TimeAxisFrame")
CANVAS_VARIABLE(canvasvar_TimeAxisViewItemName, "time axis item name")
CANVAS_VARIABLE(canvasvar_TimeStretchFill, "time-stretch-fill")
CANVAS_VARIABLE(canvasvar_TimeStretchOutline, "time-stretch-outline")
CANVAS_VARIABLE(canvasvar_TransportDragRect, "TransportDragRect")

View File

@ -255,9 +255,10 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con
name_pixbuf->property_x() = label_offset;
name_pixbuf->property_y() = (13 / 2) - (name_height / 2);
set_name (annotation.c_str());
set_name (annotation);
editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition));
ColorsChanged.connect (mem_fun (*this, &Marker::color_handler));
mark->set_data ("marker", this);
@ -342,12 +343,21 @@ Marker::the_item() const
return *mark;
}
void
Marker::color_handler ()
{
set_name (_annotation);
}
void
Marker::set_name (const string& new_name)
{
int name_width = pixel_width (new_name, *name_font) + 2;
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, name_font, name_width, name_height);
_annotation = new_name;
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, name_font,
ARDOUR_UI::config()->canvasvar_MarkerLabel.get(),
name_width, name_height);
if (_type == End || _type == LoopEnd || _type == PunchOut) {
name_pixbuf->property_x() = - (name_width);

View File

@ -96,8 +96,10 @@ class Marker : public PBD::Destructible
unsigned char shift; /* should be double, but its always small and integral */
Type _type;
int name_height;
std::string _annotation;
void reposition ();
void color_handler ();
};
class TempoMarker : public Marker

View File

@ -164,8 +164,6 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie
controls_frame.set_name ("TimeAxisViewControlsBaseUnselected");
controls_vbox.set_name ("TimeAxisViewControlsBaseUnselected");
controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler));
}
TimeAxisView::~TimeAxisView()

View File

@ -239,6 +239,8 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color& base_colo
set_duration (item_duration, this) ;
set_position (start, this) ;
ColorsChanged.connect (mem_fun (*this, &TimeAxisViewItem::color_handler));
}
/**
@ -552,9 +554,19 @@ TimeAxisViewItem::set_name_text(const ustring& new_name)
return;
}
_name = new_name;
last_item_width = trackview.editor.frame_to_pixel(item_duration);
name_pixbuf_width = pixel_width (new_name, *NAME_FONT) + 2;
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, NAME_FONT, name_pixbuf_width, NAME_HEIGHT);
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, NAME_FONT,
ARDOUR_UI::config()->canvasvar_TimeAxisViewItemName.get(),
name_pixbuf_width, NAME_HEIGHT);
}
void
TimeAxisViewItem::color_handler ()
{
set_name_text (_name);
}
/**
@ -919,7 +931,9 @@ TimeAxisViewItem::reset_name_width (double pix_width)
name_pixbuf->show();
}
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(item_name, NAME_FONT, pb_width, NAME_HEIGHT);
name_pixbuf->property_pixbuf() = pixbuf_from_ustring(item_name, NAME_FONT,
ARDOUR_UI::config()->canvasvar_TimeAxisViewItemName.get(),
pb_width, NAME_HEIGHT);
}

View File

@ -373,6 +373,8 @@ class TimeAxisViewItem : public Selectable
virtual void reset_width_dependent_items (double pixel_width);
void reset_name_width (double pixel_width);
void color_handler ();
/**
* Callback used to remove this item during the gtk idle loop
* This is used to avoid deleting the obejct while inside the remove_this_group
@ -465,7 +467,7 @@ class TimeAxisViewItem : public Selectable
double _height;
Visibility visibility;
bool _recregion;
std::string _name;
}; /* class TimeAxisViewItem */

View File

@ -887,14 +887,21 @@ convert_bgra_to_rgba (guint8 const* src,
}
Glib::RefPtr<Gdk::Pixbuf>
pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, int clip_width, int clip_height)
pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, uint32_t rgba, int clip_width, int clip_height)
{
Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, clip_width, clip_height);
cairo_t* cr = cairo_create (surface);
cairo_text_extents_t te;
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
float fr, fg, fb, fa;
fr = ((rgba & 0xff000000) >> 24) / 255.0f;
fg = ((rgba & 0xff0000) >> 16) / 255.0f;
fb = ((rgba & 0xff00) >> 8) / 255.0f;
fa = (rgba & 0xff) / 255.0f;
cairo_set_source_rgba (cr, fr, fg, fb, fa);
cairo_select_font_face (cr, font->get_family().c_str(),
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, font->get_size() / Pango::SCALE);

View File

@ -96,6 +96,7 @@ void convert_bgra_to_rgba (guint8 const* src,
int height);
Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_ustring (const Glib::ustring& name,
Pango::FontDescription* font,
uint32_t rgba,
int clip_width,
int clip_height);