forked from AuroraMiddleware/gtk
switch: remove slider padding from available allocation when drawing
This also simplifies the code a bit, and makes previous workarounds useless.
This commit is contained in:
parent
6abbd68674
commit
ea7661cb3f
@ -571,12 +571,15 @@ gtk_switch_draw (GtkWidget *widget,
|
|||||||
gtk_render_background (context, cr, x, y, width, height);
|
gtk_render_background (context, cr, x, y, width, height);
|
||||||
gtk_render_frame (context, cr, x, y, width, height);
|
gtk_render_frame (context, cr, x, y, width, height);
|
||||||
|
|
||||||
/* XXX the +1/-1 it's pixel wriggling after checking with the default
|
width -= padding.left + padding.right;
|
||||||
* theme and xmag
|
height -= padding.top + padding.bottom;
|
||||||
*/
|
|
||||||
handle.y = y + padding.top + 1;
|
x += padding.left;
|
||||||
handle.width = (width - padding.left - padding.right) / 2;
|
y += padding.top;
|
||||||
handle.height = (height - padding.top - padding.bottom) - 1;
|
|
||||||
|
handle.y = y;
|
||||||
|
handle.width = width / 2;
|
||||||
|
handle.height = height;
|
||||||
|
|
||||||
/* Translators: if the "on" state label requires more than three
|
/* Translators: if the "on" state label requires more than three
|
||||||
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
|
* glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for
|
||||||
@ -586,10 +589,8 @@ gtk_switch_draw (GtkWidget *widget,
|
|||||||
pango_layout_get_extents (layout, NULL, &rect);
|
pango_layout_get_extents (layout, NULL, &rect);
|
||||||
pango_extents_to_pixels (&rect, NULL);
|
pango_extents_to_pixels (&rect, NULL);
|
||||||
|
|
||||||
label_x = x + padding.left
|
label_x = x + ((width / 2) - rect.width) / 2;
|
||||||
+ ((width / 2) - rect.width - padding.left - padding.right) / 2;
|
label_y = y + (height - rect.height) / 2;
|
||||||
label_y = y + padding.top
|
|
||||||
+ (height - rect.height - padding.top - padding.bottom) / 2;
|
|
||||||
|
|
||||||
gtk_render_layout (context, cr, label_x, label_y, layout);
|
gtk_render_layout (context, cr, label_x, label_y, layout);
|
||||||
|
|
||||||
@ -602,11 +603,8 @@ gtk_switch_draw (GtkWidget *widget,
|
|||||||
pango_layout_get_extents (layout, NULL, &rect);
|
pango_layout_get_extents (layout, NULL, &rect);
|
||||||
pango_extents_to_pixels (&rect, NULL);
|
pango_extents_to_pixels (&rect, NULL);
|
||||||
|
|
||||||
label_x = x + padding.left
|
label_x = x + (width / 2) + ((width / 2) - rect.width) / 2;
|
||||||
+ (width / 2)
|
label_y = y + (height - rect.height) / 2;
|
||||||
+ ((width / 2) - rect.width - padding.left - padding.right) / 2;
|
|
||||||
label_y = y + padding.top
|
|
||||||
+ (height - rect.height - padding.top - padding.bottom) / 2;
|
|
||||||
|
|
||||||
gtk_render_layout (context, cr, label_x, label_y, layout);
|
gtk_render_layout (context, cr, label_x, label_y, layout);
|
||||||
|
|
||||||
@ -615,9 +613,9 @@ gtk_switch_draw (GtkWidget *widget,
|
|||||||
if (priv->is_dragging)
|
if (priv->is_dragging)
|
||||||
handle.x = x + priv->handle_x;
|
handle.x = x + priv->handle_x;
|
||||||
else if (priv->is_active)
|
else if (priv->is_active)
|
||||||
handle.x = x + width - handle.width - padding.right;
|
handle.x = x + width - handle.width;
|
||||||
else
|
else
|
||||||
handle.x = x + padding.left;
|
handle.x = x;
|
||||||
|
|
||||||
gtk_style_context_restore (context);
|
gtk_style_context_restore (context);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user