mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 11:20:12 +00:00
cellrendertoggle: Draw background + frame for mark
Also compute padding and borders properly for the marks.
This commit is contained in:
parent
46f46ed36e
commit
1ee3df5161
@ -335,12 +335,21 @@ gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
|
||||
gint calc_width;
|
||||
gint calc_height;
|
||||
gint xpad, ypad;
|
||||
GtkStyleContext *context;
|
||||
GtkBorder border, padding;
|
||||
|
||||
priv = GTK_CELL_RENDERER_TOGGLE (cell)->priv;
|
||||
|
||||
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
|
||||
calc_width = xpad * 2 + priv->indicator_size;
|
||||
calc_height = ypad * 2 + priv->indicator_size;
|
||||
|
||||
context = gtk_cell_renderer_toggle_save_context (cell, widget);
|
||||
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
|
||||
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
|
||||
|
||||
calc_width = xpad * 2 + priv->indicator_size + padding.left + padding.right + border.left + border.right;
|
||||
calc_height = ypad * 2 + priv->indicator_size + padding.top + padding.bottom + border.top + border.bottom;
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
if (width)
|
||||
*width = calc_width;
|
||||
@ -388,6 +397,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
||||
gint x_offset, y_offset;
|
||||
gint xpad, ypad;
|
||||
GtkStateFlags state;
|
||||
GtkBorder padding, border;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
|
||||
@ -421,19 +431,33 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
|
||||
context = gtk_cell_renderer_toggle_save_context (cell, widget);
|
||||
gtk_style_context_set_state (context, state);
|
||||
|
||||
if (priv->radio)
|
||||
{
|
||||
gtk_render_option (context, cr,
|
||||
gtk_render_background (context, cr,
|
||||
cell_area->x + x_offset + xpad,
|
||||
cell_area->y + y_offset + ypad,
|
||||
width, height);
|
||||
gtk_render_frame (context, cr,
|
||||
cell_area->x + x_offset + xpad,
|
||||
cell_area->y + y_offset + ypad,
|
||||
width, height);
|
||||
|
||||
gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
|
||||
gtk_style_context_get_border (context, gtk_style_context_get_state (context), &border);
|
||||
|
||||
if (priv->radio)
|
||||
{
|
||||
gtk_render_option (context, cr,
|
||||
cell_area->x + x_offset + xpad + padding.left + border.left,
|
||||
cell_area->y + y_offset + ypad + padding.top + border.top,
|
||||
width - padding.left - padding.right - border.left - border.right,
|
||||
height - padding.top - padding.bottom - border.top - border.bottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_render_check (context, cr,
|
||||
cell_area->x + x_offset + xpad,
|
||||
cell_area->y + y_offset + ypad,
|
||||
width, height);
|
||||
cell_area->x + x_offset + xpad + padding.left + border.left,
|
||||
cell_area->y + y_offset + ypad + padding.top + border.top,
|
||||
width - padding.left - padding.right - border.left - border.right,
|
||||
height - padding.top - padding.bottom - border.top - border.bottom);
|
||||
}
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
Loading…
Reference in New Issue
Block a user