[gnome-control-center] RANDR - ensure that the output labels fit inside the monitor rectangles
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-control-center] RANDR - ensure that the output labels fit inside the monitor rectangles
- Date: Thu, 6 Aug 2009 20:34:16 +0000 (UTC)
commit 5d9f7b5e2a312e3dc5a1a385858992a8380949fd
Author: Federico Mena Quintero <federico novell com>
Date: Thu Aug 6 11:56:27 2009 -0500
RANDR - ensure that the output labels fit inside the monitor rectangles
The labels would get clipped if the monitor rectangles were too small,
thus making the labels unreadable. Now we ensure that the ink_rect of
the text fits, and we center the text based on its logical_rect.
Signed-off-by: Federico Mena Quintero <federico novell com>
capplets/display/xrandr-capplet.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 9113152..3f4add2 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -1500,11 +1500,13 @@ paint_output (App *app, cairo_t *cr, int i)
GList *connected_outputs = list_connected_outputs (app, &total_w, &total_h);
GnomeOutputInfo *output = g_list_nth (connected_outputs, i)->data;
PangoLayout *layout = get_display_name (app, output);
- PangoRectangle extent;
+ PangoRectangle ink_extent, log_extent;
GdkRectangle viewport;
double angle;
GdkColor output_color;
double r, g, b;
+ double available_w;
+ double factor;
cairo_save (cr);
@@ -1611,13 +1613,19 @@ paint_output (App *app, cairo_t *cr, int i)
cairo_set_line_width (cr, 2);
layout_set_font (layout, "Sans Bold 12");
+ pango_layout_get_pixel_extents (layout, &ink_extent, &log_extent);
- pango_layout_get_pixel_extents (layout, NULL, &extent);
+ available_w = w * scale + 0.5 - 6; /* Same as the inner rectangle's width, minus 1 pixel of padding on each side */
+ if (available_w < ink_extent.width)
+ factor = available_w / ink_extent.width;
+ else
+ factor = 1.0;
- extent.x = x + ((w * scale + 0.5) - extent.width) / 2;
- extent.y = y + ((h * scale + 0.5) - extent.height) / 2;
+ cairo_move_to (cr,
+ x + ((w * scale + 0.5) - factor * log_extent.width) / 2,
+ y + ((h * scale + 0.5) - factor * log_extent.height) / 2);
- cairo_move_to (cr, extent.x, extent.y);
+ cairo_scale (cr, factor, factor);
if (output->on)
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]