Gama C Library
Gama C API Documentation
widgets.h
Go to the documentation of this file.
1/**
2 * @file widgets.h
3 * @brief Master header for Gama UI widgets and theme management.
4 *
5 * This file includes all individual widget headers and defines a mechanism
6 * for caching and restoring widget themes, allowing for easy styling changes
7 * and scoped theme modifications.
8 */
9#pragma once
10
11#include "widgets/button.h"
12#include "widgets/frame.h"
13#include "widgets/joystick.h"
14#include "widgets/scale.h"
15#include "widgets/switch.h"
16
17/**
18 * @def GAMA_MAX_THEME_CACHE_SIZE
19 * @brief Defines the maximum number of widget theme states that can be cached.
20 */
21#ifndef GAMA_MAX_THEME_CACHE_SIZE
22#define GAMA_MAX_THEME_CACHE_SIZE 10
23#endif
24
25/**
26 * @brief Structure containing all widget themes for caching purposes.
27 */
28typedef struct {
29 gmwButtonTheme button; /**< Theme for button widgets. */
30 gmwSwitchTheme switch_; /**< Theme for switch widgets. */
31 gmwScaleTheme scale; /**< Theme for scale widgets. */
32 gmwJoystickTheme joystick; /**< Theme for joystick widgets. */
33 gmwFrameTheme frame; /**< Theme for frame widgets. */
35
36/**
37 * @internal
38 * @brief Internal cache array for widget themes.
39 */
41
42/**
43 * @internal
44 * @brief Current index in the theme cache array.
45 */
47
48/**
49 * @brief Saves the current widget themes to the theme cache.
50 *
51 * This function pushes the current state of all widget themes onto a stack.
52 * This is useful for temporarily changing themes and then restoring them later.
53 *
54 * @return A pointer to the saved theme cache entry, or NULL if the cache is full.
55 */
67
68/**
69 * @brief Restores the previous widget themes from the theme cache.
70 *
71 * This function pops the last saved theme state from the stack and applies
72 * it to the global widget themes.
73 */
Defines the theme and functionality for a button widget.
gmwButtonTheme gmwButton
Global button theme instance with default values.
Definition button.h:51
Defines the theme and functionality for a frame widget.
gmwFrameTheme gmwFrame
Global frame theme instance with default values.
Definition frame.h:42
Defines the theme and functionality for a virtual joystick widget.
gmwJoystickTheme gmwJoystick
Global joystick theme instance with default values.
Definition joystick.h:43
Defines the theme and functionality for a scale (slider) widget.
gmwScaleTheme gmwScale
Global scale theme instance with default values.
Definition scale.h:46
Structure defining the visual theme for a button widget.
Definition button.h:16
Structure defining the visual theme for a frame widget.
Definition frame.h:17
Structure defining the visual theme for a joystick widget.
Definition joystick.h:17
Structure defining the visual theme for a scale (slider) widget.
Definition scale.h:18
Structure defining the visual theme for a switch widget.
Definition switch.h:18
Structure containing all widget themes for caching purposes.
Definition widgets.h:28
gmwScaleTheme scale
Definition widgets.h:31
gmwSwitchTheme switch_
Definition widgets.h:30
gmwButtonTheme button
Definition widgets.h:29
gmwJoystickTheme joystick
Definition widgets.h:32
gmwFrameTheme frame
Definition widgets.h:33
Defines the theme and functionality for a toggle switch widget.
gmwSwitchTheme gmwSwitch
Global switch theme instance with default values.
Definition switch.h:53
gmwThemeCache * gmw_save()
Saves the current widget themes to the theme cache.
Definition widgets.h:56
#define GAMA_MAX_THEME_CACHE_SIZE
Defines the maximum number of widget theme states that can be cached.
Definition widgets.h:22
short gm_theme_cache_index
Definition widgets.h:46
gmwThemeCache _theme_cache[GAMA_MAX_THEME_CACHE_SIZE]
Definition widgets.h:40
void gmw_restore()
Restores the previous widget themes from the theme cache.
Definition widgets.h:74