~elementary-os/ubuntu-package-imports/mutter-bionic

« back to all changes in this revision

Viewing changes to src/ui/theme-private.h

  • Committer: RabbitBot
  • Date: 2018-04-11 14:49:36 UTC
  • Revision ID: rabbitbot@elementary.io-20180411144936-hgymqa9d8d1xfpbh
Initial import, version 3.28.0-2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 
2
 
 
3
/* Metacity Theme Rendering */
 
4
 
 
5
/*
 
6
 * Copyright (C) 2001 Havoc Pennington
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU General Public License as
 
10
 * published by the Free Software Foundation; either version 2 of the
 
11
 * License, or (at your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef META_THEME_PRIVATE_H
 
23
#define META_THEME_PRIVATE_H
 
24
 
 
25
#include <meta/boxes.h>
 
26
#include <meta/theme.h>
 
27
#include <meta/common.h>
 
28
#include <gtk/gtk.h>
 
29
 
 
30
/**
 
31
 * MetaStyleInfo: (skip)
 
32
 *
 
33
 */
 
34
typedef struct _MetaStyleInfo MetaStyleInfo;
 
35
/**
 
36
 * MetaFrameLayout: (skip)
 
37
 *
 
38
 */
 
39
typedef struct _MetaFrameLayout MetaFrameLayout;
 
40
/**
 
41
 * MetaButtonSpace: (skip)
 
42
 *
 
43
 */
 
44
typedef struct _MetaButtonSpace MetaButtonSpace;
 
45
/**
 
46
 * MetaFrameGeometry: (skip)
 
47
 *
 
48
 */
 
49
typedef struct _MetaFrameGeometry MetaFrameGeometry;
 
50
 
 
51
/**
 
52
 * Various parameters used to calculate the geometry of a frame.
 
53
 **/
 
54
struct _MetaFrameLayout
 
55
{
 
56
  /** Invisible border required by the theme */
 
57
  GtkBorder invisible_border;
 
58
  /** Border/padding of the entire frame */
 
59
  GtkBorder frame_border;
 
60
  /** Border/padding of the titlebar region */
 
61
  GtkBorder titlebar_border;
 
62
  /** Border/padding of titlebar buttons */
 
63
  GtkBorder button_border;
 
64
 
 
65
  /** Margin of title */
 
66
  GtkBorder title_margin;
 
67
  /** Margin of titlebar buttons */
 
68
  GtkBorder button_margin;
 
69
 
 
70
  /** Min size of titlebar region */
 
71
  GtkRequisition titlebar_min_size;
 
72
  /** Min size of titlebar buttons */
 
73
  GtkRequisition button_min_size;
 
74
 
 
75
  /** Size of images in buttons */
 
76
  guint icon_size;
 
77
 
 
78
  /** Space between titlebar elements */
 
79
  guint titlebar_spacing;
 
80
 
 
81
  /** scale factor for title text */
 
82
  double title_scale;
 
83
 
 
84
  /** Whether title text will be displayed */
 
85
  guint has_title : 1;
 
86
 
 
87
  /** Whether we should hide the buttons */
 
88
  guint hide_buttons : 1;
 
89
 
 
90
  /** Radius of the top left-hand corner; 0 if not rounded */
 
91
  guint top_left_corner_rounded_radius;
 
92
  /** Radius of the top right-hand corner; 0 if not rounded */
 
93
  guint top_right_corner_rounded_radius;
 
94
  /** Radius of the bottom left-hand corner; 0 if not rounded */
 
95
  guint bottom_left_corner_rounded_radius;
 
96
  /** Radius of the bottom right-hand corner; 0 if not rounded */
 
97
  guint bottom_right_corner_rounded_radius;
 
98
};
 
99
 
 
100
/**
 
101
 * The computed size of a button (really just a way of tying its
 
102
 * visible and clickable areas together).
 
103
 * The reason for two different rectangles here is Fitts' law & maximized
 
104
 * windows; see bug #97703 for more details.
 
105
 */
 
106
struct _MetaButtonSpace
 
107
{
 
108
  /** The screen area where the button's image is drawn */
 
109
  GdkRectangle visible;
 
110
  /** The screen area where the button can be activated by clicking */
 
111
  GdkRectangle clickable;
 
112
};
 
113
 
 
114
/**
 
115
 * Calculated actual geometry of the frame
 
116
 */
 
117
struct _MetaFrameGeometry
 
118
{
 
119
  MetaFrameBorders borders;
 
120
 
 
121
  int width;
 
122
  int height;
 
123
 
 
124
  GdkRectangle title_rect;
 
125
 
 
126
  GtkBorder content_border;
 
127
 
 
128
  /* used for a memset hack */
 
129
#define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
 
130
#define LENGTH_OF_BUTTON_RECTS (G_STRUCT_OFFSET (MetaFrameGeometry, appmenu_rect) + sizeof (MetaButtonSpace) - G_STRUCT_OFFSET (MetaFrameGeometry, close_rect))
 
131
 
 
132
  /* The button rects (if changed adjust memset hack) */
 
133
  MetaButtonSpace close_rect;
 
134
  MetaButtonSpace max_rect;
 
135
  MetaButtonSpace min_rect;
 
136
  MetaButtonSpace menu_rect;
 
137
  MetaButtonSpace appmenu_rect;
 
138
  /* End of button rects (if changed adjust memset hack) */
 
139
 
 
140
  /* Saved button layout */
 
141
  MetaButtonLayout button_layout;
 
142
  int n_left_buttons;
 
143
  int n_right_buttons;
 
144
 
 
145
  /* Round corners */
 
146
  guint top_left_corner_rounded_radius;
 
147
  guint top_right_corner_rounded_radius;
 
148
  guint bottom_left_corner_rounded_radius;
 
149
  guint bottom_right_corner_rounded_radius;
 
150
};
 
151
 
 
152
typedef enum
 
153
{
 
154
  META_BUTTON_STATE_NORMAL,
 
155
  META_BUTTON_STATE_PRESSED,
 
156
  META_BUTTON_STATE_PRELIGHT,
 
157
  META_BUTTON_STATE_LAST
 
158
} MetaButtonState;
 
159
 
 
160
typedef enum
 
161
{
 
162
  META_BUTTON_TYPE_CLOSE,
 
163
  META_BUTTON_TYPE_MAXIMIZE,
 
164
  META_BUTTON_TYPE_MINIMIZE,
 
165
  META_BUTTON_TYPE_MENU,
 
166
  META_BUTTON_TYPE_APPMENU,
 
167
  META_BUTTON_TYPE_LAST
 
168
} MetaButtonType;
 
169
 
 
170
typedef enum
 
171
{
 
172
  META_STYLE_ELEMENT_WINDOW,
 
173
  META_STYLE_ELEMENT_FRAME,
 
174
  META_STYLE_ELEMENT_TITLEBAR,
 
175
  META_STYLE_ELEMENT_TITLE,
 
176
  META_STYLE_ELEMENT_BUTTON,
 
177
  META_STYLE_ELEMENT_IMAGE,
 
178
  META_STYLE_ELEMENT_LAST
 
179
} MetaStyleElement;
 
180
 
 
181
struct _MetaStyleInfo
 
182
{
 
183
  int refcount;
 
184
 
 
185
  GtkStyleContext *styles[META_STYLE_ELEMENT_LAST];
 
186
};
 
187
 
 
188
/* Kinds of frame...
 
189
 *
 
190
 *  normal ->   focused / unfocused
 
191
 *  max    ->   focused / unfocused
 
192
 *  shaded ->   focused / unfocused
 
193
 *  max/shaded -> focused / unfocused
 
194
 *
 
195
 *  so 4 states with 2 sub-states each, meaning 8 total
 
196
 *
 
197
 * 8 window states times 7 or 8 window types. Except some
 
198
 * window types never get a frame so that narrows it down a bit.
 
199
 *
 
200
 */
 
201
typedef enum
 
202
{
 
203
  META_FRAME_STATE_NORMAL,
 
204
  META_FRAME_STATE_MAXIMIZED,
 
205
  META_FRAME_STATE_TILED_LEFT,
 
206
  META_FRAME_STATE_TILED_RIGHT,
 
207
  META_FRAME_STATE_SHADED,
 
208
  META_FRAME_STATE_MAXIMIZED_AND_SHADED,
 
209
  META_FRAME_STATE_TILED_LEFT_AND_SHADED,
 
210
  META_FRAME_STATE_TILED_RIGHT_AND_SHADED,
 
211
  META_FRAME_STATE_LAST
 
212
} MetaFrameState;
 
213
 
 
214
typedef enum
 
215
{
 
216
  META_FRAME_FOCUS_NO,
 
217
  META_FRAME_FOCUS_YES,
 
218
  META_FRAME_FOCUS_LAST
 
219
} MetaFrameFocus;
 
220
 
 
221
/**
 
222
 * A theme. This is a singleton class which groups all settings from a theme
 
223
 * together.
 
224
 */
 
225
struct _MetaTheme
 
226
{
 
227
  MetaFrameLayout *layouts[META_FRAME_TYPE_LAST];
 
228
};
 
229
 
 
230
void               meta_frame_layout_apply_scale (const MetaFrameLayout *layout,
 
231
                                                  PangoFontDescription  *font_desc);
 
232
 
 
233
MetaFrameLayout* meta_theme_get_frame_layout (MetaTheme     *theme,
 
234
                                              MetaFrameType  type);
 
235
 
 
236
MetaStyleInfo * meta_theme_create_style_info (GdkScreen   *screen,
 
237
                                              const gchar *variant);
 
238
MetaStyleInfo * meta_style_info_ref          (MetaStyleInfo *style);
 
239
void            meta_style_info_unref        (MetaStyleInfo  *style_info);
 
240
 
 
241
void            meta_style_info_set_flags    (MetaStyleInfo  *style_info,
 
242
                                              MetaFrameFlags  flags);
 
243
 
 
244
PangoFontDescription * meta_style_info_create_font_desc (MetaStyleInfo *style_info);
 
245
 
 
246
void meta_theme_draw_frame (MetaTheme              *theme,
 
247
                            MetaStyleInfo          *style_info,
 
248
                            cairo_t                *cr,
 
249
                            MetaFrameType           type,
 
250
                            MetaFrameFlags          flags,
 
251
                            int                     client_width,
 
252
                            int                     client_height,
 
253
                            PangoLayout            *title_layout,
 
254
                            int                     text_height,
 
255
                            const MetaButtonLayout *button_layout,
 
256
                            MetaButtonState         button_states[META_BUTTON_TYPE_LAST],
 
257
                            cairo_surface_t        *mini_icon);
 
258
 
 
259
void meta_theme_get_frame_borders (MetaTheme         *theme,
 
260
                                   MetaStyleInfo     *style_info,
 
261
                                   MetaFrameType      type,
 
262
                                   int                text_height,
 
263
                                   MetaFrameFlags     flags,
 
264
                                   MetaFrameBorders  *borders);
 
265
 
 
266
void meta_theme_calc_geometry (MetaTheme              *theme,
 
267
                               MetaStyleInfo          *style_info,
 
268
                               MetaFrameType           type,
 
269
                               int                     text_height,
 
270
                               MetaFrameFlags          flags,
 
271
                               int                     client_width,
 
272
                               int                     client_height,
 
273
                               const MetaButtonLayout *button_layout,
 
274
                               MetaFrameGeometry      *fgeom);
 
275
 
 
276
/* random stuff */
 
277
 
 
278
int                   meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
 
279
                                                            PangoContext         *context);
 
280
int                   meta_theme_get_window_scaling_factor (void);
 
281
 
 
282
#endif /* META_THEME_PRIVATE_H */