- holt_widget: left aligned resource labels if too large

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1088 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
paolo 2006-09-10 21:29:22 +00:00
parent ca905257a6
commit 4ff377733a
1 changed files with 6 additions and 2 deletions

View File

@ -120,15 +120,19 @@ void HoltResource::draw(cairo_t *cr)
cairo_save(cr); cairo_save(cr);
// clip text outside region // clip text outside region
cairo_rectangle(cr, _pos.real() - _radius, _pos.imag() - _radius, cairo_rectangle(cr, _pos.real() - _radius, _pos.imag() - _radius,
2 * _radius * x_percent, 2 * _radius * y_percent); 2 * _radius * x_percent, 2 * _radius * y_percent);
cairo_clip(cr); cairo_clip(cr);
// draw text // draw text
cairo_text_extents_t extents; cairo_text_extents_t extents;
cairo_text_extents(cr, _resource->get_name().c_str(), &extents); cairo_text_extents(cr, _resource->get_name().c_str(), &extents);
double xpos = _pos.real() - extents.width * (1 - x_percent + x_percent / 2);
// left aligned if too large
if(xpos<_pos.real() - _radius)
xpos = _pos.real() - _radius;
cairo_move_to(cr, cairo_move_to(cr,
_pos.real() - extents.width * (1 - x_percent + x_percent / 2), xpos,
_pos.imag() + extents.height * ((1 - y_percent) / 2 + 0.5) ); _pos.imag() + extents.height * ((1 - y_percent) / 2 + 0.5) );
cairo_show_text(cr, _resource->get_name().c_str()); cairo_show_text(cr, _resource->get_name().c_str());