1 /*
2  * Copyright (C) 2001 Havoc Pennington
3  * Copyright (C) 2016 Alberts Muktupāvels
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef META_FRAME_STYLE_PRIVATE_H
20 #define META_FRAME_STYLE_PRIVATE_H
21 
22 #include "meta-button.h"
23 #include "meta-button-private.h"
24 #include "meta-color-spec-private.h"
25 #include "meta-draw-op-private.h"
26 #include "meta-frame-enums.h"
27 #include "meta-frame-layout-private.h"
28 
29 G_BEGIN_DECLS
30 
31 typedef struct _MetaFrameStyle MetaFrameStyle;
32 typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
33 
34 /**
35  * How to draw a frame in a particular state (say, a focussed, non-maximised,
36  * resizable frame). This corresponds closely to the <frame_style> tag
37  * in a theme file.
38  */
39 struct _MetaFrameStyle
40 {
41   /** Reference count. */
42   int refcount;
43   /**
44    * Parent style.
45    * Settings which are unspecified here will be taken from there.
46    */
47   MetaFrameStyle *parent;
48   /** Operations for drawing each kind of button in each state. */
49   MetaDrawOpList *buttons[META_BUTTON_FUNCTION_LAST][META_BUTTON_STATE_LAST];
50   /** Operations for drawing each piece of the frame. */
51   MetaDrawOpList *pieces[META_FRAME_PIECE_LAST];
52   /**
53    * Details such as the height and width of each edge, the corner rounding,
54    * and the aspect ratio of the buttons.
55    */
56   MetaFrameLayout *layout;
57   /**
58    * Background colour of the window. Only present in theme formats
59    * 2 and above. Can be NULL to use the standard GTK theme engine.
60    */
61   MetaColorSpec *window_background_color;
62   /**
63    * Transparency of the window background. 0=transparent; 255=opaque.
64    */
65   guint8 window_background_alpha;
66 };
67 
68 /**
69  * How to draw frames at different times: when it's maximised or not, shaded
70  * or not, when it's focussed or not, and (for non-maximised windows), when
71  * it can be horizontally or vertically resized, both, or neither.
72  * Not all window types actually get a frame.
73  *
74  * A theme contains one of these objects for each type of window (each
75  * MetaFrameType), that is, normal, dialogue (modal and non-modal), etc.
76  *
77  * This corresponds closely to the <frame_style_set> tag in a theme file.
78  */
79 struct _MetaFrameStyleSet
80 {
81   int refcount;
82   MetaFrameStyleSet *parent;
83   MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
84   MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST];
85   MetaFrameStyle *tiled_left_styles[META_FRAME_FOCUS_LAST];
86   MetaFrameStyle *tiled_right_styles[META_FRAME_FOCUS_LAST];
87   MetaFrameStyle *shaded_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
88   MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST];
89   MetaFrameStyle *tiled_left_and_shaded_styles[META_FRAME_FOCUS_LAST];
90   MetaFrameStyle *tiled_right_and_shaded_styles[META_FRAME_FOCUS_LAST];
91 };
92 
93 G_GNUC_INTERNAL
94 MetaFrameStyle    *meta_frame_style_new           (MetaFrameStyle     *parent);
95 
96 G_GNUC_INTERNAL
97 void               meta_frame_style_ref           (MetaFrameStyle     *style);
98 
99 G_GNUC_INTERNAL
100 void               meta_frame_style_unref         (MetaFrameStyle     *style);
101 
102 G_GNUC_INTERNAL
103 gboolean           meta_frame_style_validate      (MetaFrameStyle     *style,
104                                                    guint               current_theme_version,
105                                                    GError            **error);
106 
107 G_GNUC_INTERNAL
108 MetaDrawOpList    *meta_frame_style_get_button    (MetaFrameStyle     *style,
109                                                    MetaButtonFunction  function,
110                                                    MetaButtonState     state);
111 
112 G_GNUC_INTERNAL
113 MetaFrameStyleSet *meta_frame_style_set_new       (MetaFrameStyleSet  *parent);
114 
115 G_GNUC_INTERNAL
116 void               meta_frame_style_set_ref       (MetaFrameStyleSet  *style_set);
117 
118 G_GNUC_INTERNAL
119 void               meta_frame_style_set_unref     (MetaFrameStyleSet  *style_set);
120 
121 G_GNUC_INTERNAL
122 gboolean           meta_frame_style_set_validate  (MetaFrameStyleSet  *style_set,
123                                                    GError            **error);
124 
125 G_GNUC_INTERNAL
126 MetaFrameStyle    *meta_frame_style_set_get_style (MetaFrameStyleSet  *style_set,
127                                                    MetaFrameState      state,
128                                                    MetaFrameResize     resize,
129                                                    MetaFrameFocus      focus);
130 
131 G_END_DECLS
132 
133 #endif
134