Foenix A2650 OS/f Library
 
Loading...
Searching...
No Matches
theme.h
Go to the documentation of this file.
1
2
3/*
4 * theme.h
5 *
6* Created on: Mar 26, 2022
7 * Author: micahbly
8 */
9
10#ifndef LIB_THEME_H_
11#define LIB_THEME_H_
12
13
14/* about this class: Theme
15 *
16 * This provides functionality for working with visual themes for windows
17 *
18 *** things this library needs to be able to do
19 * Provide system default theme control templates for close, minimize, normal size, and maximize buttons
20 * Provide system default font objects for app font and system font
21 * Read a theme from disk, and make it the global theme
22 * Provide information about the current global theme
23 * Provide the control templates, colors, desktop patterns, etc., from the theme object
24 * Allow a calling method to update the control templates, colors, etc, of the current theme object??? TBD
25 *
26 * STRETCH GOALS
27 *
28 *
29 * SUPER STRETCH GOALS
30 *
31 *
32 */
33
34
35/*****************************************************************************/
36/* Includes */
37/*****************************************************************************/
38
39// project includes
40#include "window.h"
41
42// C includes
43#include <stdbool.h>
44
45// A2560 includes
46#include <mcp/syscalls.h>
47#include "a2560k.h"
48
49
50/*****************************************************************************/
51/* Macro Definitions */
52/*****************************************************************************/
53
54#define WIN_DEFAULT_OUTLINE_COLOR SYS_DEF_COLOR_WINFRAME
55#define WIN_DEFAULT_OUTLINE_SIZE 1
56#define WIN_DEFAULT_FLOW_FROM_BOTTOM false
57#define WIN_DEFAULT_TITLEBAR_HEIGHT 18
58#define WIN_DEFAULT_TITLEBAR_COLOR SYS_DEF_COLOR_WINTITLE_BACK
59#define WIN_DEFAULT_TITLEBAR_FONT_COLOR SYS_COLOR_WHITE
60#define WIN_DEFAULT_TITLEBAR_ACTIVE_ACCENT SYS_COLOR_PURPLEBLUEHL
61#define WIN_DEFAULT_TITLEBAR_INACTIVE_ACCENT SYS_COLOR_PURPLEBLUEINACT
62#define WIN_DEFAULT_TITLEBAR_HAS_OUTLINE false
63#define WIN_DEFAULT_ICONBAR_HEIGHT 16
64#define WIN_DEFAULT_ICONBAR_COLOR SYS_DEF_COLOR_ICONBAR_BACK
65#define WIN_DEFAULT_ICONBAR_HAS_OUTLINE false
66#define WIN_DEFAULT_STANDARD_BACK_COLOR SYS_DEF_COLOR_CONTENT_BACK
67#define WIN_DEFAULT_STANDARD_FORE_COLOR SYS_COLOR_GRAY10
68#define WIN_DEFAULT_INACTIVE_BACK_COLOR SYS_COLOR_WHITE
69#define WIN_DEFAULT_INACTIVE_FORE_COLOR SYS_COLOR_GRAY4
70#define WIN_DEFAULT_HIGHLIGHT_BACK_COLOR SYS_COLOR_TETRA_3
71#define WIN_DEFAULT_HIGHLIGHT_FORE_COLOR SYS_COLOR_WHITE
72#define WIN_DEFAULT_MENU_FORE_COLOR SYS_COLOR_BLACK
73#define WIN_DEFAULT_MENU_BACK_COLOR SYS_COLOR_GRAY1
74#define WIN_DEFAULT_DESKTOP_COLOR SYS_DEF_COLOR_DESKTOP
75#define WIN_DEFAULT_DESKTOP_WIDTH 16
76#define WIN_DEFAULT_DESKTOP_HEIGHT 16
77#define WIN_DEFAULT_BACKGROUND_BGRA 0xCCCCCC00;
78#define WIN_DEFAULT_BORDER_BGRA 0x33333300;
79
80#define THEME_PARAM_MINIMAL_RESOURCES true // parameter for Theme_CreateXXXXtheme()
81#define THEME_PARAM_FULL_RESOURCES false // parameter for Theme_CreateXXXXtheme()
82
83/*****************************************************************************/
84/* Enumerations */
85/*****************************************************************************/
86
87
88
89/*****************************************************************************/
90/* Structs */
91/*****************************************************************************/
92
93
95{
96 Bitmap* image_left_[2][2];
99 int16_t left_width_;
100 int16_t mid_width_;
101 int16_t right_width_;
102 int16_t height_;
103};
104
105struct Theme
106{
107 Font* icon_font_;
108 Font* control_font_;
109 uint8_t* clut_;
110 uint8_t outline_size_;
116 uint8_t title_color_;
117 h_align_type title_h_align_;
135 uint32_t border_color_;
137 ControlTemplate* control_t_minimize_;
138 ControlTemplate* control_t_norm_size_;
139 ControlTemplate* control_t_maximize_;
140 ControlBackdrop flex_width_backdrops_[2];
141
142};
143
144/*****************************************************************************/
145/* Global Variables */
146/*****************************************************************************/
147
148
149/*****************************************************************************/
150/* Public Function Prototypes */
151/*****************************************************************************/
152
153
154// **** CONSTRUCTOR AND DESTRUCTOR *****
155
156// constructor
158Theme* Theme_New(void);
159
160// destructor
161// frees all allocated memory associated with the passed object, and the object itself
162bool Theme_Destroy(Theme** the_theme);
163
164
165
171Theme* Theme_CreateDefaultTheme(bool minimal_resources);
172
173
174
175
176
177
178// **** xxx functions *****
179
182bool Theme_Activate(Theme* the_theme);
183
184
185// **** Set xxx functions *****
186
187
188
189
190
191// **** Get xxx functions *****
192
193ControlTemplate* Theme_GetCloseControlTemplate(Theme* the_theme);
194ControlTemplate* Theme_GetMinimizeControlTemplate(Theme* the_theme);
195ControlTemplate* Theme_GetNormSizeControlTemplate(Theme* the_theme);
196ControlTemplate* Theme_GetMaximizeControlTemplate(Theme* the_theme);
197
199ControlTemplate* Theme_CreateControlTemplateFlexWidth(Theme* the_theme, control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type h_align, v_align_type v_align, char* caption);
200
202ControlTemplate* Theme_CreateControlTemplateFixedWidth(Theme* the_theme, control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type h_align, v_align_type v_align, char* caption);
203
204Bitmap* Theme_GetDesktopPattern(Theme* the_theme);
205
206ColorIdx Theme_GetTitlebarColor(Theme* the_theme);
207ColorIdx Theme_GetTitleColor(Theme* the_theme);
208ColorIdx Theme_GetIconbarColor(Theme* the_theme);
209ColorIdx Theme_GetOutlineColor(Theme* the_theme);
210ColorIdx Theme_GetContentAreaColor(Theme* the_theme);
211ColorIdx Theme_GetDesktopColor(Theme* the_theme);
212ColorIdx Theme_GetInactiveBackColor(Theme* the_theme);
213ColorIdx Theme_GetInactiveForeColor(Theme* the_theme);
214ColorIdx Theme_GetMenuBackColor(Theme* the_theme);
215ColorIdx Theme_GetMenuForeColor(Theme* the_theme);
216ColorIdx Theme_GetHighlightBackColor(Theme* the_theme);
217ColorIdx Theme_GetHighlightForeColor(Theme* the_theme);
218
219
220
221// **** xxx functions *****
222
223
224
225
226// **** xxx functions *****
227
228
229
230
231// TEMP UNTIL DISK AVAIL
235
236
237
238
239// **** Debug functions *****
240
241void Theme_Print(Theme* the_theme);
242
243
244
245#endif /* LIB_THEME_H_ */
246
247
control_type
Definition: control.h:83
Definition: bitmap.h:97
Definition: theme.h:95
Bitmap * image_mid_[2][2]
left side of 4 image state bitmaps: [active yes/no][pushed down yes/no]
Definition: theme.h:97
int16_t mid_width_
width of the left image
Definition: theme.h:100
Bitmap * image_right_[2][2]
4 image state bitmaps: [active yes/no][pushed down yes/no]
Definition: theme.h:98
int16_t height_
width of the right image
Definition: theme.h:102
int16_t left_width_
4 image state bitmaps: [active yes/no][pushed down yes/no]
Definition: theme.h:99
int16_t right_width_
width of the mid image
Definition: theme.h:101
A structure that can be used to instantiate a ControlTemplate object instance in a window The Control...
Definition: control_template.h:69
This Font object is essentially the Mac "fontRecord" struct, with added pointers for the data tables.
Definition: font.h:71
Definition: theme.h:106
uint8_t standard_fore_color_
Index to the color LUT.
Definition: theme.h:123
bool titlebar_outline_
Background color of the title bar when window is active - Index to the color LUT
Definition: theme.h:115
bool iconbar_outline_
Index to the color LUT.
Definition: theme.h:121
Bitmap * desktop_pattern_
Required LUT index for the desktop color; Used when no pattern bitmap.
Definition: theme.h:131
uint8_t inactive_back_color_
Index to the color LUT
Definition: theme.h:124
uint32_t background_color_
Height of the desktop pattern.
Definition: theme.h:134
uint8_t highlight_back_color_
Index to the color LUT
Definition: theme.h:126
uint8_t pattern_height_
Width of the desktop pattern.
Definition: theme.h:133
uint8_t inactive_fore_color_
Index to the color LUT.
Definition: theme.h:125
uint8_t titlebar_color_
Height of titlebar. Cannot be smaller than height of control font.
Definition: theme.h:114
uint8_t desktop_color_
Index to the color LUT
Definition: theme.h:130
uint8_t outline_color_
Thickness of border around window, in pixels. 0 is acceptable. Border is drawn from window rect inwar...
Definition: theme.h:111
uint8_t menu_back_color_
Index to the color LUT
Definition: theme.h:128
uint8_t titlebar_height_
Controls the vertical flow of elements: if true, order from top will be content area->iconbar->titleb...
Definition: theme.h:113
uint8_t standard_back_color_
Draw an outline using the outline_color_, around the iconbar?
Definition: theme.h:122
uint8_t iconbar_color_
Height of iconbar (when displayed).
Definition: theme.h:120
bool flow_from_bottom_
Index to the color LUT.
Definition: theme.h:112
uint8_t iconbar_height_
horizontal coordinate relative to the window's left or right edge. If title_h_align_ is H_ALIGN_CENTE...
Definition: theme.h:119
uint8_t highlight_fore_color_
Index to the color LUT.
Definition: theme.h:127
int16_t title_x_offset_
whether the title text should be positioned relative to the left side, right side,...
Definition: theme.h:118
uint8_t pattern_width_
Optional bitmap to be tiled into a desktop pattern.
Definition: theme.h:132
uint8_t * clut_
Font for controls (incuding titlebar)
Definition: theme.h:109
ControlTemplate * control_t_close_
32bit BGRA (A is non-functional). Used for the border color in the VICKY.
Definition: theme.h:136
uint32_t border_color_
32bit BGRA (A is non-functional). Used for the base background layer in the VICKY.
Definition: theme.h:135
uint8_t title_color_
Draw an outline using the outline_color_, around the titlebar?
Definition: theme.h:116
h_align_type title_h_align_
Foreground color of the title bar when window is active - Index to the color LUT
Definition: theme.h:117
uint8_t menu_fore_color_
Index to the color LUT.
Definition: theme.h:129
ControlTemplate * Theme_CreateControlTemplateFlexWidth(Theme *the_theme, control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type h_align, v_align_type v_align, char *caption)
Create a control template for a flexible-width control.
Definition: theme.c:3081
ControlTemplate * Theme_CreateControlTemplateFixedWidth(Theme *the_theme, control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type h_align, v_align_type v_align, char *caption)
Create a control template for a fixed-width control with no background.
Definition: theme.c:3152
bool Theme_Activate(Theme *the_theme)
Make the passed theme into the active Theme Note: this will change the VICKY's CLUT,...
Definition: theme.c:3850
Theme * Theme_CreateDefaultTheme(bool minimal_resources)
create default Theme.
Definition: theme.c:3407
Theme * Theme_New(void)
Allocate a Theme object.
Definition: theme.c:3328
Theme * Theme_CreateGreenTheme(void)
create default Theme.
Definition: theme.c:3907