diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-06-06 01:24:56 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-06-06 16:01:48 +0300 |
commit | 977eea5508c3d976b0c3d591585978b092a54b53 (patch) | |
tree | e5400c774dcdcb981a0811c087edd473c2ef2f3e | |
parent | 1abf31270f2d9c04c4946a7e5e0dc3f961395ba9 (diff) | |
download | metacity-977eea5508c3d976b0c3d591585978b092a54b53.tar.gz |
libmetacity: apply scale in meta_theme_create_font_desc
-rw-r--r-- | libmetacity/meta-frame-style.c | 10 | ||||
-rw-r--r-- | libmetacity/meta-frame-style.h | 3 | ||||
-rw-r--r-- | libmetacity/meta-theme.c | 28 | ||||
-rw-r--r-- | libmetacity/meta-theme.h | 4 | ||||
-rw-r--r-- | src/ui/frames.c | 4 | ||||
-rw-r--r-- | src/ui/ui.c | 2 | ||||
-rw-r--r-- | theme-viewer/theme-viewer-window.c | 12 |
7 files changed, 34 insertions, 29 deletions
diff --git a/libmetacity/meta-frame-style.c b/libmetacity/meta-frame-style.c index 32ee34aa..6be57807 100644 --- a/libmetacity/meta-frame-style.c +++ b/libmetacity/meta-frame-style.c @@ -298,16 +298,6 @@ meta_frame_style_unref (MetaFrameStyle *style) } } -void -meta_frame_style_apply_scale (const MetaFrameStyle *style, - PangoFontDescription *font_desc) -{ - int size = pango_font_description_get_size (font_desc); - double scale = style->layout->title_scale / get_window_scaling_factor (); - - pango_font_description_set_size (font_desc, MAX (size * scale, 1)); -} - gboolean meta_frame_style_validate (MetaFrameStyle *style, guint current_theme_version, diff --git a/libmetacity/meta-frame-style.h b/libmetacity/meta-frame-style.h index 511c25ac..dc6426f9 100644 --- a/libmetacity/meta-frame-style.h +++ b/libmetacity/meta-frame-style.h @@ -96,9 +96,6 @@ void meta_frame_style_ref (MetaFrameStyle *style) void meta_frame_style_unref (MetaFrameStyle *style); -void meta_frame_style_apply_scale (const MetaFrameStyle *style, - PangoFontDescription *font_desc); - gboolean meta_frame_style_validate (MetaFrameStyle *style, guint current_theme_version, GError **error); diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c index f19ac4ca..4dc7891c 100644 --- a/libmetacity/meta-theme.c +++ b/libmetacity/meta-theme.c @@ -56,6 +56,26 @@ static GParamSpec *properties[LAST_PROP] = { NULL }; G_DEFINE_TYPE (MetaTheme, meta_theme, G_TYPE_OBJECT) +static void +font_desc_apply_scale (PangoFontDescription *font_desc, + MetaTheme *theme, + MetaFrameType type, + MetaFrameFlags flags) +{ + gint old_size; + MetaFrameStyle *style; + gdouble scale; + gint new_size; + + old_size = pango_font_description_get_size (font_desc); + style = meta_theme_get_frame_style (theme, type, flags); + scale = get_window_scaling_factor (); + + new_size = MAX (old_size * (style->layout->title_scale / scale), 1); + + pango_font_description_set_size (font_desc, new_size); +} + static MetaStyleInfo * meta_theme_get_style_info (MetaTheme *theme, const gchar *variant) @@ -358,8 +378,10 @@ meta_theme_get_frame_style (MetaTheme *theme, } PangoFontDescription* -meta_theme_create_font_desc (MetaTheme *theme, - const gchar *variant) +meta_theme_create_font_desc (MetaTheme *theme, + const gchar *variant, + MetaFrameType type, + MetaFrameFlags flags) { MetaStyleInfo *style_info; GtkStyleContext *context; @@ -379,6 +401,8 @@ meta_theme_create_font_desc (MetaTheme *theme, if (theme->titlebar_font) pango_font_description_merge (font_desc, theme->titlebar_font, TRUE); + font_desc_apply_scale (font_desc, theme, type, flags); + return font_desc; } diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h index 11e1011a..64b6fc7b 100644 --- a/libmetacity/meta-theme.h +++ b/libmetacity/meta-theme.h @@ -166,7 +166,9 @@ MetaFrameStyle *meta_theme_get_frame_style (MetaTheme MetaFrameFlags flags); PangoFontDescription *meta_theme_create_font_desc (MetaTheme *theme, - const gchar *variant); + const gchar *variant, + MetaFrameType type, + MetaFrameFlags flags); gint meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc, PangoContext *context); diff --git a/src/ui/frames.c b/src/ui/frames.c index b78a615a..a5bbbcfa 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -454,8 +454,8 @@ meta_frames_ensure_layout (MetaFrames *frames, current = meta_ui_get_theme (); - font_desc = meta_theme_create_font_desc (current, frame->theme_variant); - meta_frame_style_apply_scale (style, font_desc); + font_desc = meta_theme_create_font_desc (current, frame->theme_variant, + type, flags); size = pango_font_description_get_size (font_desc); diff --git a/src/ui/ui.c b/src/ui/ui.c index 4670507d..f917c1d7 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -689,7 +689,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui, theme = meta_ui_get_theme (); theme_variant = NULL; - font_desc = meta_theme_create_font_desc (theme, theme_variant); + font_desc = meta_theme_create_font_desc (theme, theme_variant, type, flags); context = gtk_widget_get_pango_context (GTK_WIDGET (ui->frames)); text_height = meta_pango_font_desc_get_text_height (font_desc, context); diff --git a/theme-viewer/theme-viewer-window.c b/theme-viewer/theme-viewer-window.c index 6d72f91f..7dcd0415 100644 --- a/theme-viewer/theme-viewer-window.c +++ b/theme-viewer/theme-viewer-window.c @@ -239,22 +239,14 @@ update_title_layout (ThemeViewerWindow *window) GtkWidget *widget; PangoLayout *layout; PangoFontDescription *font_desc; - MetaFrameType type; - MetaFrameFlags flags; - MetaFrameStyle *style; PangoContext *context; gint height; widget = GTK_WIDGET (window); layout = gtk_widget_create_pango_layout (widget, "Metacity Theme Viewer"); - font_desc = meta_theme_create_font_desc (window->theme, window->theme_variant); - - type = window->frame_type; - flags = window->frame_flags; - - style = meta_theme_get_frame_style (window->theme, type, flags); - meta_frame_style_apply_scale (style, font_desc); + font_desc = meta_theme_create_font_desc (window->theme, window->theme_variant, + window->frame_type, window->frame_flags); context = gtk_widget_get_pango_context (widget); height = meta_pango_font_desc_get_text_height (font_desc, context); |