1 /*************************************************************************
2  * Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr>    *
3  * Copyright (C) 2019 Jan Grulich <jgrulich@redhat.com>                  *
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, write to the                         *
17  * Free Software Foundation, Inc.,                                       *
18  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
19  *************************************************************************/
20 
21 #ifndef Header_Adwaita
22 #define Header_Adwaita
23 
24 #include <QColor>
25 #include <QFlags>
26 #include <QPointer>
27 #include <QScopedPointer>
28 #include <QWeakPointer>
29 
30 #ifndef M_PI
31 #define M_PI 3.14159265358979323846
32 #endif
33 
34 namespace Adwaita
35 {
36     //*@name convenience typedef
37     //@{
38 
39 #if QT_VERSION >= 0x050000
40     //* scoped pointer convenience typedef
41     template <typename T> using WeakPointer = QPointer<T>;
42 #else
43     //* scoped pointer convenience typedef
44     template <typename T> using WeakPointer = QWeakPointer<T>;
45 #endif
46 
47     //* scoped pointer convenience typedef
48     template <typename T> using ScopedPointer = QScopedPointer<T, QScopedPointerPodDeleter>;
49 
50     //* disable QStringLiteral for older Qt version
51 #if QT_VERSION < 0x050000
52     using QStringLiteral = QString;
53 #endif
54 
55     //@}
56 
57     //* Settings
58     namespace Settings
59     {
60         const bool SingleClick { true };
61         const bool ShowIconsOnPushButtons { true };
62         const int ToolButtonStyle { Qt::ToolButtonTextBesideIcon };
63         const bool ShowIconsInMenuItems { true };
64     }
65 
66     enum EnumMnemonicsMode {
67         MN_NEVER,
68         MN_AUTO,
69         MN_ALWAYS
70     };
71 
72     enum EnumWindowDragMode {
73         WD_NONE,
74         WD_MINIMAL,
75         WD_FULL
76     };
77 
78     //* Config
79     namespace Config
80     {
81         // Common
82         const int ShadowStrength { 0 };
83         const int ShadowSize { 0 };
84         const QColor ShadowColor { Qt::transparent };
85         const bool OutlineCloseButton { false };
86 
87         // Style
88         const bool AnimationsEnabled { true };
89         const int AnimationSteps { 100 };
90         const int AnimationsDuration { 180 };
91         const bool StackedWidgetTransitionsEnabled { false };
92         const bool ProgressBarAnimated { true };
93         const int ProgressBarBusyStepDuration { 600 };
94         const int ScrollBarAddLineButtons { 0 };
95         const int ScrollBarSubLineButtons { 0 };
96         const bool ScrollBarShowOnMouseOver { true };
97         const int MnemonicsMode { MN_AUTO };
98         const bool ToolBarDrawItemSeparator { 0 };
99         const bool ViewDrawFocusIndicator { true };
100         const bool SliderDrawTickMarks { true };
101         const bool ViewDrawTreeBranchLines { true };
102         const bool ViewInvertSortIndicator { true };
103         const bool TabBarDrawCenteredTabs { false };
104         const bool TitleWidgetDrawFrame { true };
105         const bool DockWidgetDrawFrame { false };
106         const bool SidePanelDrawFrame { false };
107         const bool MenuItemDrawStrongFocus { true };
108         const int WindowDragMode { 0 };
109         const QStringList WindowDragWhiteList;
110         const QStringList WindowDragBlackList;
111         const bool UseWMMoveResize { true };
112         const bool SplitterProxyEnabled { true };
113         const int SplitterProxyWidth { 3 };
114         const bool WidgetExplorerEnabled { false };
115         const bool DrawWidgetRects { false };
116     }
117 
118     namespace PropertyNames
119     {
120         const char noAnimations[] = "_kde_no_animations";
121         const char noWindowGrab[] = "_kde_no_window_grab";
122         const char netWMForceShadow[] = "_KDE_NET_WM_FORCE_SHADOW";
123         const char netWMSkipShadow[] = "_KDE_NET_WM_SKIP_SHADOW";
124         const char sidePanelView[] = "_kde_side_panel_view";
125         const char toolButtonAlignment[] = "_kde_toolButton_alignment";
126         const char menuTitle[] = "_adwaita_toolButton_menutitle";
127         const char alteredBackground[] = "_adwaita_altered_background";
128     }
129 
130     //* metrics
131     enum Metrics {
132         // frames
133         Frame_FrameWidth = 4,
134         Frame_FrameRadius = 5,
135 
136         // layout
137         Layout_TopLevelMarginWidth = 10,
138         Layout_ChildMarginWidth = 6,
139         Layout_DefaultSpacing = 6,
140 
141         // line editors
142         LineEdit_FrameWidth = 3,
143         LineEdit_MarginHeight = 2,
144         LineEdit_MarginWidth = 8,
145         LineEdit_MinHeight = 36,
146         LineEdit_MinWidth = 80,
147 
148         // menu items
149         Menu_FrameWidth = 0,
150         MenuItem_MarginWidth = 4,
151         MenuItem_ItemSpacing = 6,
152         MenuItem_AcceleratorSpace = 16,
153         MenuButton_IndicatorWidth = 20,
154 
155         // combobox
156         ComboBox_FrameWidth = 4,
157         ComboBox_MarginHeight = 4,
158         ComboBox_MarginWidth = 8,
159         ComboBox_MinHeight = 36,
160         ComboBox_MinWidth = 80,
161 
162         // spinbox
163         SpinBox_FrameWidth = LineEdit_FrameWidth,
164         SpinBox_ArrowButtonWidth = 20,
165         SpinBox_MinHeight = 36,
166         SpinBox_MinWidth = 80,
167         SpinBox_MarginHeight = 4,
168         SpinBox_MarginWidth = 8,
169 
170         // groupbox title margin
171         GroupBox_TitleMarginWidth = 4,
172 
173         // buttons
174         Button_MinHeight = 36,
175         Button_MinWidth = 80,
176         Button_MarginHeight = 4,
177         Button_MarginWidth = 8,
178         Button_ItemSpacing = 4,
179 
180         // tool buttons
181         ToolButton_MarginWidth = 6,
182         ToolButton_ItemSpacing = 4,
183         ToolButton_InlineIndicatorWidth = 12,
184 
185         // checkboxes and radio buttons
186         CheckBox_Size = 22,
187         CheckBox_FocusMarginWidth = 3,
188         CheckBox_ItemSpacing = 8,
189 
190         // menubar items
191         MenuBarItem_MarginWidth = 8,
192         MenuBarItem_MarginHeight = 5,
193 
194         // scrollbars
195         ScrollBar_Extend = 14,
196         ScrollBar_SliderWidth = 8,
197         ScrollBar_MinSliderHeight = 24,
198         ScrollBar_NoButtonHeight = (ScrollBar_Extend - ScrollBar_SliderWidth) / 2,
199         ScrollBar_SingleButtonHeight = 0,
200         ScrollBar_DoubleButtonHeight = 0,
201 
202         // toolbars
203         ToolBar_FrameWidth = 2,
204         ToolBar_HandleExtent = 10,
205         ToolBar_HandleWidth = 6,
206         ToolBar_SeparatorWidth = 8,
207         ToolBar_ExtensionWidth = 20,
208         ToolBar_ItemSpacing = 0,
209 
210         // progressbars
211         ProgressBar_BusyIndicatorSize = 24,
212         ProgressBar_Thickness = 3,
213         ProgressBar_ItemSpacing = 3,
214 
215         // mdi title bar
216         TitleBar_MarginWidth = 4,
217 
218         // sliders
219         Slider_TickLength = 4,
220         Slider_TickMarginWidth = 6,
221         Slider_GrooveThickness = 3,
222         Slider_ControlThickness = 24,
223 
224         // tabbar
225         TabBar_TabMarginHeight = 9,
226         TabBar_TabMarginWidth = 8,
227         TabBar_TabMinWidth = 80,
228         TabBar_TabMinHeight = 36,
229         TabBar_TabItemSpacing = 8,
230         TabBar_TabOverlap = 1,
231         TabBar_BaseOverlap = 0,
232 
233         // tab widget
234         TabWidget_MarginWidth = 4,
235 
236         // toolbox
237         ToolBox_TabMinWidth = 80,
238         ToolBox_TabItemSpacing = 4,
239         ToolBox_TabMarginWidth = 8,
240 
241         // tooltips
242         ToolTip_FrameWidth = 3,
243 
244         // scroll areas
245         ScrollArea_FrameWidth = 2,
246 
247         // list headers
248         Header_MarginWidth = 3,
249         Header_ItemSpacing = 2,
250         Header_ArrowSize = 10,
251 
252         // tree view
253         ItemView_ArrowSize = 10,
254         ItemView_ItemMarginWidth = 3,
255         SidePanel_ItemMarginWidth = 4,
256 
257         // splitter
258         Splitter_SplitterWidth = 1,
259 
260         // shadow dimensions
261         Shadow_Overlap = 0
262 
263     };
264 
265     //* animation mode
266     enum AnimationMode {
267         AnimationNone = 0,
268         AnimationHover = 0x1,
269         AnimationFocus = 0x2,
270         AnimationEnable = 0x4,
271         AnimationPressed = 0x8
272     };
273     Q_DECLARE_FLAGS(AnimationModes, AnimationMode)
274 
275     //* corners
276     enum Corner {
277         CornerTopLeft = 0x1,
278         CornerTopRight = 0x2,
279         CornerBottomLeft = 0x4,
280         CornerBottomRight = 0x8,
281         CornersTop = CornerTopLeft | CornerTopRight,
282         CornersBottom = CornerBottomLeft | CornerBottomRight,
283         CornersLeft = CornerTopLeft | CornerBottomLeft,
284         CornersRight = CornerTopRight | CornerBottomRight,
285         AllCorners = CornerTopLeft | CornerTopRight | CornerBottomLeft | CornerBottomRight
286     };
287     Q_DECLARE_FLAGS(Corners, Corner)
288 
289     //* sides
290     enum Side {
291         SideNone = 0x0,
292         SideLeft = 0x1,
293         SideTop = 0x2,
294         SideRight = 0x4,
295         SideBottom = 0x8,
296         AllSides = SideLeft | SideTop | SideRight | SideBottom
297     };
298     Q_DECLARE_FLAGS(Sides, Side)
299 
300     //* checkbox state
301     enum CheckBoxState {
302         CheckOff,
303         CheckPartial,
304         CheckOn,
305         CheckAnimated
306     };
307 
308     //* radio button state
309     enum RadioButtonState {
310         RadioOff,
311         RadioOn,
312         RadioAnimated
313     };
314 
315     //* arrow orientation
316     enum ArrowOrientation {
317         ArrowNone,
318         ArrowUp,
319         ArrowDown,
320         ArrowLeft,
321         ArrowRight
322     };
323 
324     //* button type
325     enum ButtonType {
326         ButtonClose,
327         ButtonMaximize,
328         ButtonMinimize,
329         ButtonRestore
330     };
331 
332 } // namespace Adwaita
333 
334 Q_DECLARE_OPERATORS_FOR_FLAGS(Adwaita::AnimationModes)
335 Q_DECLARE_OPERATORS_FOR_FLAGS(Adwaita::Corners)
336 Q_DECLARE_OPERATORS_FOR_FLAGS(Adwaita::Sides)
337 
338 #endif // ADWAITA_H
339 
340