summaryrefslogtreecommitdiff
path: root/gtk2_ardour/time_axis_view_item.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-12 20:39:53 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-12 20:39:53 +0000
commitff9ddf510065305e13d169d35f9b4e6b88ce76d7 (patch)
tree0e41589d7332ce31499c9f02ca59f9b799487b03 /gtk2_ardour/time_axis_view_item.cc
parentab565167ff36eb473340e950d93d46c3dfaa9616 (diff)
tidy up (a bit) locations editing widget ; use pixbuf/string code from 2.0;remove edit point clock
git-svn-id: svn://localhost/ardour2/branches/3.0@6074 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/time_axis_view_item.cc')
-rw-r--r--gtk2_ardour/time_axis_view_item.cc81
1 files changed, 43 insertions, 38 deletions
diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc
index cb114f4f3d..1d8fc2aca7 100644
--- a/gtk2_ardour/time_axis_view_item.cc
+++ b/gtk2_ardour/time_axis_view_item.cc
@@ -56,6 +56,7 @@ bool TimeAxisViewItem::have_name_font = false;
const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6 ;
+int TimeAxisViewItem::NAME_HEIGHT;
double TimeAxisViewItem::NAME_Y_OFFSET;
double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
@@ -96,6 +97,7 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
layout->set_font_description (*NAME_FONT);
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
+ NAME_HEIGHT = height;
NAME_Y_OFFSET = height + 3;
NAME_HIGHLIGHT_SIZE = height + 2;
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
@@ -145,6 +147,8 @@ TimeAxisViewItem::init (const string& it_name, double spu, Gdk::Color const & ba
show_vestigial = true;
visibility = vis;
_sensitive = true;
+ name_pixbuf_width = 0;
+ last_item_width = 0;
if (duration == 0) {
warning << "Time Axis Item Duration == 0" << endl ;
@@ -525,48 +529,16 @@ TimeAxisViewItem::get_time_axis_view()
void
TimeAxisViewItem::set_name_text(const ustring& new_name)
{
- uint32_t pb_width, it_width;
- double font_size;
-
- font_size = NAME_FONT->get_size() / Pango::SCALE;
- it_width = trackview.editor().frame_to_pixel(item_duration);
- pb_width = new_name.length() * font_size;
-
- if (pb_width > it_width - NAME_X_OFFSET) {
- pb_width = it_width - NAME_X_OFFSET;
- }
-
- if (pb_width <= 0 || it_width < NAME_X_OFFSET) {
- if (name_pixbuf) {
- name_pixbuf->hide();
- }
+ if (!name_pixbuf) {
return;
- } else {
- name_pixbuf->show();
}
- Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, pb_width, NAME_HIGHLIGHT_SIZE);
-
- cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, pb_width, NAME_HIGHLIGHT_SIZE );
- cairo_t *cr = cairo_create (surface);
- cairo_text_extents_t te;
- cairo_set_source_rgba (cr, 0.2, 0.2, 0.2, 1.0);
- cairo_select_font_face (cr, NAME_FONT->get_family().c_str(),
- CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size (cr, 10);
- cairo_text_extents (cr, new_name.c_str(), &te);
-
- cairo_move_to (cr, 0.5,
- 0.5 - te.height / 2 - te.y_bearing + NAME_HIGHLIGHT_SIZE / 2);
- cairo_show_text (cr, new_name.c_str());
-
- unsigned char* src = cairo_image_surface_get_data (surface);
- convert_bgra_to_rgba(src, buf->get_pixels(), pb_width, NAME_HIGHLIGHT_SIZE);
-
- cairo_destroy(cr);
- name_pixbuf->property_pixbuf() = buf;
+ 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);
}
+
/**
* Set the height of this item
*
@@ -897,7 +869,40 @@ TimeAxisViewItem::reset_width_dependent_items (double pixel_width)
void
TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
{
- set_name_text (item_name);
+ uint32_t it_width;
+ int pb_width;
+ bool pixbuf_holds_full_name;
+
+ if (!name_pixbuf) {
+ return;
+ }
+
+ it_width = trackview.editor().frame_to_pixel(item_duration);
+ pb_width = name_pixbuf_width;
+
+ pixbuf_holds_full_name = last_item_width > pb_width + NAME_X_OFFSET;
+ last_item_width = it_width;
+
+ if (pixbuf_holds_full_name && (it_width >= pb_width + NAME_X_OFFSET)) {
+ /*
+ we've previously had the full name length showing
+ and its still showing.
+ */
+ return;
+ }
+
+ if (pb_width > it_width - NAME_X_OFFSET) {
+ pb_width = it_width - NAME_X_OFFSET;
+ }
+
+ if (pb_width <= 0 || it_width <= NAME_X_OFFSET) {
+ name_pixbuf->hide();
+ return;
+ } else {
+ name_pixbuf->show();
+ }
+
+ name_pixbuf->property_pixbuf() = pixbuf_from_ustring(item_name, NAME_FONT, pb_width, NAME_HEIGHT);
}