From 2f45acc0c280673281e486a7c635351281e890d9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 29 Oct 2011 20:33:17 +0000 Subject: tweak text layout on wide buttons git-svn-id: svn://localhost/ardour2/branches/3.0@10344 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_button.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'gtk2_ardour/ardour_button.cc') diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc index f925ecf6bc..ef537d1999 100644 --- a/gtk2_ardour/ardour_button.cc +++ b/gtk2_ardour/ardour_button.cc @@ -133,14 +133,23 @@ ArdourButton::render (cairo_t* cr) /* text, if any */ + float text_margin; + + if (_width < 75) { + text_margin = 3; + } else { + text_margin = 10; + } + if ((_elements & Text) && !_text.empty()) { + cairo_set_source_rgba (cr, text_r, text_g, text_b, text_a); if (_elements & Indicator) { if (_led_left) { - cairo_move_to (cr, _diameter + 3 + 4, _height/2.0 - _text_height/2.0); + cairo_move_to (cr, _width - text_margin - 4, _height/2.0 - _text_height/2.0); } else { - cairo_move_to (cr, 3, _height/2.0 - _text_height/2.0); + cairo_move_to (cr, text_margin, _height/2.0 - _text_height/2.0); } } else { /* center text */ @@ -148,7 +157,7 @@ ArdourButton::render (cairo_t* cr) } pango_cairo_show_layout (cr, _layout->gobj()); - } + } if (_elements & Indicator) { @@ -158,7 +167,7 @@ ArdourButton::render (cairo_t* cr) if (_elements & Text) { if (_led_left) { - cairo_translate (cr, 3 + (_diameter/2.0), _height/2.0); + cairo_translate (cr, text_margin + (_diameter/2.0), _height/2.0); } else { cairo_translate (cr, _width - ((_diameter/2.0) + 4.0), _height/2.0); } @@ -235,7 +244,11 @@ ArdourButton::on_size_request (Gtk::Requisition* req) if ((_elements & Text) && !_text.empty()) { _layout->get_pixel_size (_text_width, _text_height); - xpad += 6; + if (_text_width + _diameter < 75) { + xpad = 7; + } else { + xpad = 20; + } } else { _text_width = 0; _text_height = 0; -- cgit v1.2.3