92 lines
1.9 KiB
C
92 lines
1.9 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
struct rgn;
|
|
#define THEME_BUILDER_DESIRED_REGION_SIZE (16*1024)
|
|
|
|
enum ax_color_cat {
|
|
AX_COLOR_BACKGROUND = 0,
|
|
AX_COLOR_SURFACE,
|
|
AX_COLOR_PRIMARY,
|
|
AX_COLOR_PRIMARY_ALT,
|
|
AX_COLOR_SECONDARY,
|
|
AX_COLOR_SECONDARY_ALT,
|
|
AX_COLOR_ON_BACKGROUND,
|
|
AX_COLOR_ON_SURFACE,
|
|
AX_COLOR_ON_PRIMARY,
|
|
AX_COLOR_ON_SECONDARY,
|
|
AX_COLOR__COUNT,
|
|
};
|
|
|
|
enum ax_font_cat {
|
|
AX_FONT_H1 = 0,
|
|
AX_FONT_H2,
|
|
AX_FONT_H3,
|
|
AX_FONT_H4,
|
|
AX_FONT_BODY,
|
|
AX_FONT_BUTTON,
|
|
AX_FONT__COUNT,
|
|
AX_FONT__DEFAULT,
|
|
};
|
|
|
|
struct ax_theme {
|
|
const char* fatal_err;
|
|
int64_t colors[AX_COLOR__COUNT];
|
|
const char* font_path[AX_FONT__COUNT];
|
|
size_t font_size[AX_FONT__COUNT];
|
|
};
|
|
|
|
struct ax_theme_builder {
|
|
struct rgn* rgn;
|
|
const char* dflt_font_path;
|
|
struct ax_theme thm;
|
|
};
|
|
|
|
int ax__string_to_color_cat(const char* str, enum ax_color_cat* out_cat);
|
|
int ax__string_to_font_cat(const char* str, enum ax_font_cat* out_cat);
|
|
|
|
void ax__theme_builder_init(
|
|
struct ax_theme_builder* thmb, struct rgn* rgn);
|
|
|
|
char* ax__theme_make_error_buf(
|
|
struct ax_theme_builder* thmb,
|
|
size_t len);
|
|
|
|
void ax__theme_set_color(
|
|
struct ax_theme_builder* thmb,
|
|
enum ax_color_cat cat,
|
|
int64_t val);
|
|
|
|
void ax__theme_set_font(
|
|
struct ax_theme_builder* thmb,
|
|
enum ax_font_cat cat,
|
|
const char* path, size_t size);
|
|
|
|
void ax__theme_builder_finish(
|
|
struct ax_theme_builder* thmb,
|
|
struct rgn* dst_rgn,
|
|
struct ax_theme** out_thm);
|
|
|
|
static inline int64_t ax__theme_color(
|
|
struct ax_theme* thm,
|
|
enum ax_color_cat i)
|
|
{
|
|
return thm->colors[i];
|
|
}
|
|
|
|
static inline const char* ax__theme_font(
|
|
struct ax_theme* thm,
|
|
enum ax_font_cat i,
|
|
size_t* out_size)
|
|
{
|
|
if (out_size != NULL) {
|
|
*out_size = thm->font_size[i];
|
|
}
|
|
return thm->font_path[i];
|
|
}
|
|
|
|
|
|
void ax__debug_theme(struct ax_theme* thm);
|