aboutsummaryrefslogtreecommitdiff
path: root/src/sdl/theme.c
blob: 680b6eed2f71a36355186bdf2cc42481ad34ee8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "util.h"
#include "theme.h"

static const theme_t
DEFAULT_THEME = {
  .text_styles = {{
    .align  = TEXT_ALIGN_TOP_CENTER,
    .pad    = { 0, 10 },
    .colors = {
      { 0xff, 0xff, 0xff, 0xff },
      { 0x00, 0x00, 0x00, 0xff },
    },
  }, {
    .align  = TEXT_ALIGN_BOTTOM_LEFT,
    .pad    = { 10, 10 },
    .colors = {
      { 0xff, 0xff, 0xff, 0xff },
      { 0x00, 0x00, 0x00, 0xff },
    },
  }, {
    .align  = TEXT_ALIGN_BOTTOM_RIGHT,
    .pad    = { 10, 10 },
    .colors = {
      { 0xff, 0xff, 0xff, 0xff },
      { 0x00, 0x00, 0x00, 0xff },
    },
  }, {
    .align  = TEXT_ALIGN_CENTER_CENTER,
    .pad    = { 0, 0 },
    .colors = {
      { 0xff, 0xff, 0xff, 0xff },
      { 0x00, 0x00, 0x00, 0xff },
    },
  }, {
    .align  = TEXT_ALIGN_TOP_RIGHT,
    .pad    = { 10, 10 },
    .colors = {
      { 0xff, 0xff, 0xff, 0xff },
      { 0x00, 0x00, 0x00, 0xff },
    },
  }},

  .bg_styles = {{
    // normal style
    .r = { .base = 0x00 },
    .g = { .base = 0x00 },
    .b = { .base = 0x00 },
    .a = { .base = 0xFF },
  }, {
    // won style
    .r = { .base = 0x66, .scale = 0x33, .phase = 1000, .period = 2000 },
    .g = { .base = 0x66, .scale = 0x33, .phase = 3000, .period = 5000 },
    .b = { .base = 0x66, .scale = 0x33, .phase = 5000, .period = 7000 },
    .a = { .base = 0xFF },
  }},
};

const theme_t *
theme_get_default(void) {
  return &DEFAULT_THEME;
}

const text_style_t *
theme_get_text_style(
  const theme_t * const theme,
  const text_style_id_t id
) {
  if (id >= TEXT_STYLE_LAST) {
    die("invalid text style ID");
  }
  return theme->text_styles + id;
}

const bg_style_t *
theme_get_bg_style(
  const theme_t * const theme,
  const bg_style_id_t id
) {
  if (id >= BG_STYLE_LAST) {
    die("invalid BG style ID");
  }

  return theme->bg_styles + id;
}