mirror of
https://github.com/brl/mutter.git
synced 2025-02-02 14:53:03 +00:00
theme: Consider minimum sizes
GTK+ improved its CSS support, and the default theme started to make use of it, so we must update our theming code accordingly. Start by supporting min-width/min-height where it makes sense.
This commit is contained in:
parent
ac8fe2d9b2
commit
d5b69bcd54
@ -59,7 +59,7 @@ CANBERRA_GTK_VERSION=0.26
|
||||
CLUTTER_PACKAGE=clutter-1.0
|
||||
|
||||
MUTTER_PC_MODULES="
|
||||
gtk+-3.0 >= 3.19.1
|
||||
gtk+-3.0 >= 3.19.7
|
||||
gio-unix-2.0 >= 2.35.1
|
||||
pango >= 1.2.0
|
||||
cairo >= 1.10.0
|
||||
|
@ -60,6 +60,11 @@ struct _MetaFrameLayout
|
||||
/** Border/padding of titlebar buttons */
|
||||
GtkBorder button_border;
|
||||
|
||||
/** Min size of titlebar region */
|
||||
GtkRequisition titlebar_min_size;
|
||||
/** Min size of titlebar buttons */
|
||||
GtkRequisition button_min_size;
|
||||
|
||||
/** Size of images in buttons */
|
||||
guint icon_size;
|
||||
|
||||
|
@ -80,9 +80,10 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
|
||||
if (!layout->has_title)
|
||||
text_height = 0;
|
||||
|
||||
buttons_height = layout->icon_size +
|
||||
buttons_height = MAX ((int)layout->icon_size, layout->button_min_size.height) +
|
||||
layout->button_border.top + layout->button_border.bottom;
|
||||
content_height = MAX (buttons_height, text_height) +
|
||||
content_height = MAX (buttons_height, text_height);
|
||||
content_height = MAX (content_height, layout->titlebar_min_size.height) +
|
||||
layout->titlebar_border.top + layout->titlebar_border.bottom;
|
||||
|
||||
borders->visible.top = layout->frame_border.top + content_height;
|
||||
@ -234,6 +235,16 @@ get_padding_and_border (GtkStyleContext *style,
|
||||
border->bottom += tmp.bottom;
|
||||
}
|
||||
|
||||
static void
|
||||
get_min_size (GtkStyleContext *style,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
"min-width", &requisition->width,
|
||||
"min-height", &requisition->height,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
scale_border (GtkBorder *border,
|
||||
double factor)
|
||||
@ -251,6 +262,7 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
|
||||
{
|
||||
GtkStyleContext *style;
|
||||
GtkBorder border;
|
||||
GtkRequisition requisition;
|
||||
int border_radius, max_radius;
|
||||
|
||||
meta_style_info_set_flags (style_info, flags);
|
||||
@ -281,14 +293,17 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
|
||||
max_radius = MIN (layout->frame_border.bottom, layout->frame_border.right);
|
||||
layout->bottom_right_corner_rounded_radius = MAX (border_radius, max_radius);
|
||||
|
||||
get_min_size (style, &layout->titlebar_min_size);
|
||||
get_padding_and_border (style, &layout->titlebar_border);
|
||||
scale_border (&layout->titlebar_border, layout->title_scale);
|
||||
|
||||
style = style_info->styles[META_STYLE_ELEMENT_BUTTON];
|
||||
get_min_size (style, &layout->button_min_size);
|
||||
get_padding_and_border (style, &layout->button_border);
|
||||
scale_border (&layout->button_border, layout->title_scale);
|
||||
|
||||
style = style_info->styles[META_STYLE_ELEMENT_IMAGE];
|
||||
get_min_size (style, &requisition);
|
||||
get_padding_and_border (style, &border);
|
||||
scale_border (&border, layout->title_scale);
|
||||
|
||||
@ -296,6 +311,11 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
|
||||
layout->button_border.right += border.right;
|
||||
layout->button_border.top += border.top;
|
||||
layout->button_border.bottom += border.bottom;
|
||||
|
||||
layout->button_min_size.width = MAX(layout->button_min_size.width,
|
||||
requisition.width);
|
||||
layout->button_min_size.height = MAX(layout->button_min_size.height,
|
||||
requisition.height);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -359,9 +379,9 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
|
||||
(fgeom->content_border.right + borders.invisible.right);
|
||||
content_height = borders.visible.top - fgeom->content_border.top - fgeom->content_border.bottom;
|
||||
|
||||
button_width = layout->icon_size +
|
||||
button_width = MAX ((int)layout->icon_size, layout->button_min_size.width) +
|
||||
layout->button_border.left + layout->button_border.right;
|
||||
button_height = layout->icon_size +
|
||||
button_height = MAX ((int)layout->icon_size, layout->button_min_size.height) +
|
||||
layout->button_border.top + layout->button_border.bottom;
|
||||
button_width *= scale;
|
||||
button_height *= scale;
|
||||
|
Loading…
x
Reference in New Issue
Block a user