summaryrefslogtreecommitdiff
path: root/libmetacity/meta-frame-style.h
blob: c7428c6cb7ca3b1e42328d9730af93e556cb0d2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright (C) 2001 Havoc Pennington
 * Copyright (C) 2016 Alberts Muktupāvels
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef META_FRAME_STYLE_H
#define META_FRAME_STYLE_H

#include <libmetacity/meta-button-enums.h>
#include <libmetacity/meta-frame-enums.h>
#include <libmetacity/meta-frame-layout.h>

G_BEGIN_DECLS

typedef struct _MetaColorSpec MetaColorSpec;
typedef struct _MetaFrameStyle MetaFrameStyle;
typedef struct _MetaFrameStyleSet MetaFrameStyleSet;
typedef struct _MetaDrawOpList MetaDrawOpList;

/**
 * How to draw a frame in a particular state (say, a focussed, non-maximised,
 * resizable frame). This corresponds closely to the <frame_style> tag
 * in a theme file.
 */
struct _MetaFrameStyle
{
  /** Reference count. */
  int refcount;
  /**
   * Parent style.
   * Settings which are unspecified here will be taken from there.
   */
  MetaFrameStyle *parent;
  /** Operations for drawing each kind of button in each state. */
  MetaDrawOpList *buttons[META_BUTTON_TYPE_LAST][META_BUTTON_STATE_LAST];
  /** Operations for drawing each piece of the frame. */
  MetaDrawOpList *pieces[META_FRAME_PIECE_LAST];
  /**
   * Details such as the height and width of each edge, the corner rounding,
   * and the aspect ratio of the buttons.
   */
  MetaFrameLayout *layout;
  /**
   * Background colour of the window. Only present in theme formats
   * 2 and above. Can be NULL to use the standard GTK theme engine.
   */
  MetaColorSpec *window_background_color;
  /**
   * Transparency of the window background. 0=transparent; 255=opaque.
   */
  guint8 window_background_alpha;
};

/**
 * How to draw frames at different times: when it's maximised or not, shaded
 * or not, when it's focussed or not, and (for non-maximised windows), when
 * it can be horizontally or vertically resized, both, or neither.
 * Not all window types actually get a frame.
 *
 * A theme contains one of these objects for each type of window (each
 * MetaFrameType), that is, normal, dialogue (modal and non-modal), etc.
 *
 * This corresponds closely to the <frame_style_set> tag in a theme file.
 */
struct _MetaFrameStyleSet
{
  int refcount;
  MetaFrameStyleSet *parent;
  MetaFrameStyle *normal_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
  MetaFrameStyle *maximized_styles[META_FRAME_FOCUS_LAST];
  MetaFrameStyle *tiled_left_styles[META_FRAME_FOCUS_LAST];
  MetaFrameStyle *tiled_right_styles[META_FRAME_FOCUS_LAST];
  MetaFrameStyle *shaded_styles[META_FRAME_RESIZE_LAST][META_FRAME_FOCUS_LAST];
  MetaFrameStyle *maximized_and_shaded_styles[META_FRAME_FOCUS_LAST];
  MetaFrameStyle *tiled_left_and_shaded_styles[META_FRAME_FOCUS_LAST];
  MetaFrameStyle *tiled_right_and_shaded_styles[META_FRAME_FOCUS_LAST];
};

MetaFrameStyle    *meta_frame_style_new           (MetaFrameStyle        *parent);

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);

MetaDrawOpList    *meta_frame_style_get_button    (MetaFrameStyle        *style,
                                                   MetaButtonType         type,
                                                   MetaButtonState        state);

MetaFrameStyleSet *meta_frame_style_set_new       (MetaFrameStyleSet     *parent);

void               meta_frame_style_set_ref       (MetaFrameStyleSet     *style_set);

void               meta_frame_style_set_unref     (MetaFrameStyleSet     *style_set);

gboolean           meta_frame_style_set_validate  (MetaFrameStyleSet     *style_set,
                                                   GError               **error);

MetaFrameStyle    *meta_frame_style_set_get_style (MetaFrameStyleSet     *style_set,
                                                   MetaFrameState         state,
                                                   MetaFrameResize        resize,
                                                   MetaFrameFocus         focus);

G_END_DECLS

#endif