|
ObjectivelyMVC
Object oriented MVC framework for SDL3 and GNU C
|
#include <Theme.h>
Public Member Functions | |
| Class * | _Theme (void) |
| The Theme archetype. | |
| AtlasImage * | addIcon (Theme *self, const char *name, Image *image) |
Registers image as the icon name, so that :name: in any Text drawn under this Theme renders it inline, and Theme::icon resolves it. | |
| void | addStylesheet (Theme *self, Stylesheet *stylesheet) |
| Adds the specified Stylesheet to this Theme. | |
| void | apply (const Theme *self, const View *view) |
| Applies this Theme to the given View. | |
| Style * | computeStyle (const Theme *self, View *view) |
| Font * | font (Theme *self, const FontAttributes *attributes, float pixelDensity) |
| Resolves the Font with the given attributes at the given pixel density. | |
| AtlasImage * | icon (Theme *self, const char *name) |
| ImageAtlas * | icons (Theme *self) |
| Returns the ImageAtlas holding this Theme's icons, and any other app art added to it, creating it on first access. | |
| Image * | image (Theme *self, const char *name, float pixelDensity) |
| Resolves the Image for the given Resource name at the given pixel density. | |
| Theme * | init (Theme *self) |
| Initializes this Theme. | |
| void | removeStylesheet (Theme *self, Stylesheet *stylesheet) |
| Removes the given Stylesheet from this Theme. | |
| void | renderDeviceDidReset (Theme *self) |
| Notifies this Theme that the render device has been reset. | |
| void | renderDeviceWillReset (Theme *self) |
| Releases the GPU resources of every cached Font's bitmap, and of Theme::icons if it has been created, ahead of a render device reset. | |
| Theme * | theme (SDL_Window *window) |
Data Fields | |
| Object | object |
| The superclass. | |
| Array * | stylesheets |
| The Stylesheets, in order of priority. | |
Protected Attributes | |
| ThemeInterface * | interface [0] |
| The interface type. | |
| Class * _Theme | ( | void | ) |
The Theme archetype.
Definition at line 334 of file Theme.c.
| AtlasImage * addIcon | ( | Theme * | self, |
| const char * | name, | ||
| Image * | image | ||
| ) |
Registers image as the icon name, so that :name: in any Text drawn under this Theme renders it inline, and Theme::icon resolves it.
The icon is added to Theme::icons and the atlas is compiled, which repacks it, so register icons at startup rather than while drawing. AtlasImages already handed out stay valid: compiling updates their rects in place. Icons SHOULD be square; Text draws them as a square of the line height.
Definition at line 158 of file Theme.c.
| void addStylesheet | ( | Theme * | self, |
| Stylesheet * | stylesheet | ||
| ) |
Adds the specified Stylesheet to this Theme.
| self | The Theme. |
| stylesheet | The Stylesheet. |
| Font * font | ( | Theme * | self, |
| const FontAttributes * | attributes, | ||
| float | pixelDensity | ||
| ) |
Resolves the Font with the given attributes at the given pixel density.
Instances are cached by this Theme, keyed by attributes and pixel density, so repeated requests – including from multiple windows sharing this Theme – return the same Font.
| self | The Theme. |
| attributes | The FontAttributes. |
| pixelDensity | The pixel density. |
Definition at line 108 of file Theme.c.
| AtlasImage * icon | ( | Theme * | self, |
| const char * | name | ||
| ) |
| self | The Theme. |
| name | The name. |
name via Theme::addIcon, or NULL. Definition at line 175 of file Theme.c.
| ImageAtlas * icons | ( | Theme * | self | ) |
Returns the ImageAtlas holding this Theme's icons, and any other app art added to it, creating it on first access.
Theme::addIcon is the usual way in. Apps MAY also add unnamed art directly (ImageAtlas::addImage, then ImageAtlas::compile) exactly as with any other ImageAtlas; Theme owns the instance and forwards render device resets to it, so such art gets correct GPU resource lifecycle for free.
| self | The Theme. |
Definition at line 144 of file Theme.c.
Resolves the Image for the given Resource name at the given pixel density.
| self | The Theme. |
| name | The Resource name, which may carry an @ decoration (see Image). |
| pixelDensity | Pixels per point, e.g. the window's pixel density. |
Definition at line 82 of file Theme.c.
Initializes this Theme.
| self | The Theme. |
NULL on error. Definition at line 237 of file Theme.c.
| void removeStylesheet | ( | Theme * | self, |
| Stylesheet * | stylesheet | ||
| ) |
Removes the given Stylesheet from this Theme.
| self | The Theme. |
| stylesheet | The Stylesheet. |
| void renderDeviceDidReset | ( | Theme * | self | ) |
| void renderDeviceWillReset | ( | Theme * | self | ) |
Releases the GPU resources of every cached Font's bitmap, and of Theme::icons if it has been created, ahead of a render device reset.
Fonts are cached here, not owned by the Views drawing them, so this Theme is the one place that reliably reaches every bitmap Texture, including one no live View references.
| self | The Theme. |
Definition at line 276 of file Theme.c.
| Theme * theme | ( | SDL_Window * | window | ) |
| window | The window. |
Definition at line 295 of file Theme.c.
|
protected |
| Array* Theme::stylesheets |