tweak time axis view item text positioning; allow ArdourCanvas::Text to have its width clamped, and use this as TAVI's get narrow so that text doesn't overflow
This commit is contained in:
parent
7e19053b88
commit
393ba98422
@ -80,7 +80,7 @@ TimeAxisViewItem::set_constant_heights ()
|
|||||||
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
|
Gtkmm2ext::get_ink_pixel_size (layout, width, height);
|
||||||
|
|
||||||
NAME_HEIGHT = height;
|
NAME_HEIGHT = height;
|
||||||
NAME_Y_OFFSET = height + 4;
|
NAME_Y_OFFSET = height + 5; // XXX this offset is magic
|
||||||
NAME_HIGHLIGHT_SIZE = height + 2;
|
NAME_HIGHLIGHT_SIZE = height + 2;
|
||||||
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
|
NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3;
|
||||||
}
|
}
|
||||||
@ -523,7 +523,7 @@ TimeAxisViewItem::set_name_text(const string& new_name)
|
|||||||
last_item_width = trackview.editor().sample_to_pixel(item_duration);
|
last_item_width = trackview.editor().sample_to_pixel(item_duration);
|
||||||
name_text_width = pixel_width (new_name, NAME_FONT) + 2;
|
name_text_width = pixel_width (new_name, NAME_FONT) + 2;
|
||||||
name_text->set (new_name);
|
name_text->set (new_name);
|
||||||
// CAIROCANVAS need to limit text to name_text_width or something
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -886,7 +886,7 @@ TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
|
|||||||
{
|
{
|
||||||
uint32_t it_width;
|
uint32_t it_width;
|
||||||
int pb_width;
|
int pb_width;
|
||||||
bool pixbuf_holds_full_name;
|
bool showing_full_name;
|
||||||
|
|
||||||
if (!name_text) {
|
if (!name_text) {
|
||||||
return;
|
return;
|
||||||
@ -895,10 +895,10 @@ TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
|
|||||||
it_width = trackview.editor().sample_to_pixel(item_duration);
|
it_width = trackview.editor().sample_to_pixel(item_duration);
|
||||||
pb_width = name_text_width;
|
pb_width = name_text_width;
|
||||||
|
|
||||||
pixbuf_holds_full_name = last_item_width > pb_width + NAME_X_OFFSET;
|
showing_full_name = last_item_width > pb_width + NAME_X_OFFSET;
|
||||||
last_item_width = it_width;
|
last_item_width = it_width;
|
||||||
|
|
||||||
if (pixbuf_holds_full_name && (it_width >= pb_width + NAME_X_OFFSET)) {
|
if (showing_full_name && (it_width >= pb_width + NAME_X_OFFSET)) {
|
||||||
/*
|
/*
|
||||||
we've previously had the full name length showing
|
we've previously had the full name length showing
|
||||||
and its still showing.
|
and its still showing.
|
||||||
@ -923,8 +923,7 @@ TimeAxisViewItem::reset_name_width (double /*pixel_width*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
name_text->set (item_name);
|
name_text->set (item_name);
|
||||||
// CAIROCANVAS need to limit text length to pb_width
|
name_text->clamp_width (pb_width);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
void set_font_description (Pango::FontDescription);
|
void set_font_description (Pango::FontDescription);
|
||||||
void set_alignment (Pango::Alignment);
|
void set_alignment (Pango::Alignment);
|
||||||
|
|
||||||
|
void clamp_width (double);
|
||||||
|
|
||||||
void set_size_chars (int nchars);
|
void set_size_chars (int nchars);
|
||||||
void dump (std::ostream&) const;
|
void dump (std::ostream&) const;
|
||||||
|
|
||||||
@ -34,9 +36,10 @@ private:
|
|||||||
Pango::Alignment _alignment;
|
Pango::Alignment _alignment;
|
||||||
mutable Cairo::RefPtr<Cairo::ImageSurface> _image;
|
mutable Cairo::RefPtr<Cairo::ImageSurface> _image;
|
||||||
mutable Duple _origin;
|
mutable Duple _origin;
|
||||||
mutable int _width;
|
mutable double _width;
|
||||||
mutable int _height;
|
mutable double _height;
|
||||||
mutable bool _need_redraw;
|
mutable bool _need_redraw;
|
||||||
|
double _clamped_width;
|
||||||
|
|
||||||
void redraw (Cairo::RefPtr<Cairo::Context>) const;
|
void redraw (Cairo::RefPtr<Cairo::Context>) const;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@ Text::Text (Group* parent)
|
|||||||
, _width (0)
|
, _width (0)
|
||||||
, _height (0)
|
, _height (0)
|
||||||
, _need_redraw (false)
|
, _need_redraw (false)
|
||||||
|
, _clamped_width (COORD_MAX)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -80,6 +81,12 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const
|
|||||||
_need_redraw = false;
|
_need_redraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Text::clamp_width (double w)
|
||||||
|
{
|
||||||
|
_clamped_width = w;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Text::compute_bounding_box () const
|
Text::compute_bounding_box () const
|
||||||
{
|
{
|
||||||
@ -120,7 +127,7 @@ Text::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
context->set_source (_image, 0, 0);
|
context->set_source (_image, 0, 0);
|
||||||
context->rectangle (0, 0, _width, _height);
|
context->rectangle (0, 0, min (_clamped_width, _width), _height);
|
||||||
context->fill ();
|
context->fill ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user