More theme tweaking
This commit is contained in:
parent
215439621c
commit
b1253e8462
4 changed files with 97 additions and 33 deletions
28
src/theme.h
28
src/theme.h
|
|
@ -32,7 +32,9 @@ typedef struct GuideTheme {
|
||||||
SDL_Color row_active_mid;
|
SDL_Color row_active_mid;
|
||||||
SDL_Color row_active_bottom;
|
SDL_Color row_active_bottom;
|
||||||
SDL_Color row_text;
|
SDL_Color row_text;
|
||||||
|
SDL_Color row_subtext;
|
||||||
SDL_Color row_active_text;
|
SDL_Color row_active_text;
|
||||||
|
SDL_Color row_active_subtext;
|
||||||
SDL_Color block_top;
|
SDL_Color block_top;
|
||||||
SDL_Color block_mid;
|
SDL_Color block_mid;
|
||||||
SDL_Color block_bottom;
|
SDL_Color block_bottom;
|
||||||
|
|
@ -142,7 +144,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0x1e,0x3a,0x5f,0xff},
|
.row_active_mid = {0x1e,0x3a,0x5f,0xff},
|
||||||
.row_active_bottom = {0x17,0x2c,0x49,0xff},
|
.row_active_bottom = {0x17,0x2c,0x49,0xff},
|
||||||
.row_text = {0xff,0xff,0xff,0xff},
|
.row_text = {0xff,0xff,0xff,0xff},
|
||||||
|
.row_subtext = {0xe8,0xee,0xf5,0xff},
|
||||||
.row_active_text = {0xff,0xd7,0x00,0xff},
|
.row_active_text = {0xff,0xd7,0x00,0xff},
|
||||||
|
.row_active_subtext = {0xff,0xf2,0xb8,0xff},
|
||||||
.block_top = {0x5a,0x67,0x80,0xff},
|
.block_top = {0x5a,0x67,0x80,0xff},
|
||||||
.block_mid = {0x4a,0x55,0x68,0xff},
|
.block_mid = {0x4a,0x55,0x68,0xff},
|
||||||
.block_bottom = {0x3f,0x49,0x59,0xff},
|
.block_bottom = {0x3f,0x49,0x59,0xff},
|
||||||
|
|
@ -188,8 +192,10 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_top = {0x16,0x2a,0x4d,0xff},
|
.row_active_top = {0x16,0x2a,0x4d,0xff},
|
||||||
.row_active_mid = {0x0f,0x34,0x60,0xff},
|
.row_active_mid = {0x0f,0x34,0x60,0xff},
|
||||||
.row_active_bottom = {0x0a,0x1d,0x35,0xff},
|
.row_active_bottom = {0x0a,0x1d,0x35,0xff},
|
||||||
.row_text = {0xa0,0xa0,0xa0,0xff},
|
.row_text = {0xd0,0xd0,0xd0,0xff},
|
||||||
|
.row_subtext = {0xb8,0xb8,0xb8,0xff},
|
||||||
.row_active_text = {0xea,0xea,0xea,0xff},
|
.row_active_text = {0xea,0xea,0xea,0xff},
|
||||||
|
.row_active_subtext = {0xd2,0xd2,0xd2,0xff},
|
||||||
.block_top = {0x20,0x28,0x4b,0xff},
|
.block_top = {0x20,0x28,0x4b,0xff},
|
||||||
.block_mid = {0x1a,0x21,0x3e,0xff},
|
.block_mid = {0x1a,0x21,0x3e,0xff},
|
||||||
.block_bottom = {0x12,0x17,0x2e,0xff},
|
.block_bottom = {0x12,0x17,0x2e,0xff},
|
||||||
|
|
@ -236,7 +242,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0xb9,0x1c,0x1c,0xff},
|
.row_active_mid = {0xb9,0x1c,0x1c,0xff},
|
||||||
.row_active_bottom = {0x7f,0x1d,0x1d,0xff},
|
.row_active_bottom = {0x7f,0x1d,0x1d,0xff},
|
||||||
.row_text = {0xff,0xff,0xff,0xff},
|
.row_text = {0xff,0xff,0xff,0xff},
|
||||||
|
.row_subtext = {0xe6,0xee,0xff,0xff},
|
||||||
.row_active_text = {0xff,0xcc,0x00,0xff},
|
.row_active_text = {0xff,0xcc,0x00,0xff},
|
||||||
|
.row_active_subtext = {0xff,0xea,0x99,0xff},
|
||||||
.block_top = {0x39,0x7a,0xf0,0xff},
|
.block_top = {0x39,0x7a,0xf0,0xff},
|
||||||
.block_mid = {0x25,0x63,0xeb,0xff},
|
.block_mid = {0x25,0x63,0xeb,0xff},
|
||||||
.block_bottom = {0x1e,0x40,0xaf,0xff},
|
.block_bottom = {0x1e,0x40,0xaf,0xff},
|
||||||
|
|
@ -283,7 +291,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0x4a,0x14,0x8c,0xff},
|
.row_active_mid = {0x4a,0x14,0x8c,0xff},
|
||||||
.row_active_bottom = {0x2d,0x0e,0x52,0xff},
|
.row_active_bottom = {0x2d,0x0e,0x52,0xff},
|
||||||
.row_text = {0xe0,0xf7,0xfa,0xff},
|
.row_text = {0xe0,0xf7,0xfa,0xff},
|
||||||
|
.row_subtext = {0xc8,0xee,0xf1,0xff},
|
||||||
.row_active_text = {0x00,0xff,0xf9,0xff},
|
.row_active_text = {0x00,0xff,0xf9,0xff},
|
||||||
|
.row_active_subtext = {0x9c,0xff,0xfb,0xff},
|
||||||
.block_top = {0x8a,0x2b,0xbe,0xff},
|
.block_top = {0x8a,0x2b,0xbe,0xff},
|
||||||
.block_mid = {0x6a,0x1b,0x9a,0xff},
|
.block_mid = {0x6a,0x1b,0x9a,0xff},
|
||||||
.block_bottom = {0x48,0x15,0x72,0xff},
|
.block_bottom = {0x48,0x15,0x72,0xff},
|
||||||
|
|
@ -329,8 +339,10 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_top = {0x12,0x3c,0x12,0xff},
|
.row_active_top = {0x12,0x3c,0x12,0xff},
|
||||||
.row_active_mid = {0x0f,0x38,0x0f,0xff},
|
.row_active_mid = {0x0f,0x38,0x0f,0xff},
|
||||||
.row_active_bottom = {0x08,0x1a,0x08,0xff},
|
.row_active_bottom = {0x08,0x1a,0x08,0xff},
|
||||||
.row_text = {0x33,0xff,0x00,0xff},
|
.row_text = {0x66,0xff,0x4a,0xff},
|
||||||
.row_active_text = {0x33,0xff,0x00,0xff},
|
.row_subtext = {0x52,0xd8,0x3e,0xff},
|
||||||
|
.row_active_text = {0x9d,0xff,0x84,0xff},
|
||||||
|
.row_active_subtext = {0x7a,0xed,0x66,0xff},
|
||||||
.block_top = {0x2a,0x66,0x2a,0xff},
|
.block_top = {0x2a,0x66,0x2a,0xff},
|
||||||
.block_mid = {0x1b,0x4d,0x1b,0xff},
|
.block_mid = {0x1b,0x4d,0x1b,0xff},
|
||||||
.block_bottom = {0x0f,0x2f,0x0f,0xff},
|
.block_bottom = {0x0f,0x2f,0x0f,0xff},
|
||||||
|
|
@ -377,7 +389,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0xff,0x8c,0x42,0xff},
|
.row_active_mid = {0xff,0x8c,0x42,0xff},
|
||||||
.row_active_bottom = {0xd8,0x5f,0x10,0xff},
|
.row_active_bottom = {0xd8,0x5f,0x10,0xff},
|
||||||
.row_text = {0xff,0xff,0xff,0xff},
|
.row_text = {0xff,0xff,0xff,0xff},
|
||||||
|
.row_subtext = {0xff,0xf2,0xd6,0xff},
|
||||||
.row_active_text = {0xff,0xff,0x00,0xff},
|
.row_active_text = {0xff,0xff,0x00,0xff},
|
||||||
|
.row_active_subtext = {0xff,0xf4,0xa8,0xff},
|
||||||
.block_top = {0x7b,0xe0,0xd9,0xff},
|
.block_top = {0x7b,0xe0,0xd9,0xff},
|
||||||
.block_mid = {0x4e,0xcd,0xc4,0xff},
|
.block_mid = {0x4e,0xcd,0xc4,0xff},
|
||||||
.block_bottom = {0x23,0x92,0x93,0xff},
|
.block_bottom = {0x23,0x92,0x93,0xff},
|
||||||
|
|
@ -424,7 +438,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0x8b,0x00,0x00,0xff},
|
.row_active_mid = {0x8b,0x00,0x00,0xff},
|
||||||
.row_active_bottom = {0x4a,0x04,0x04,0xff},
|
.row_active_bottom = {0x4a,0x04,0x04,0xff},
|
||||||
.row_text = {0xff,0xf8,0xdc,0xff},
|
.row_text = {0xff,0xf8,0xdc,0xff},
|
||||||
|
.row_subtext = {0xf0,0xe5,0xc6,0xff},
|
||||||
.row_active_text = {0xff,0xd7,0x00,0xff},
|
.row_active_text = {0xff,0xd7,0x00,0xff},
|
||||||
|
.row_active_subtext = {0xff,0xe9,0x8f,0xff},
|
||||||
.block_top = {0x62,0x13,0x13,0xff},
|
.block_top = {0x62,0x13,0x13,0xff},
|
||||||
.block_mid = {0x4a,0x04,0x04,0xff},
|
.block_mid = {0x4a,0x04,0x04,0xff},
|
||||||
.block_bottom = {0x2d,0x02,0x02,0xff},
|
.block_bottom = {0x2d,0x02,0x02,0xff},
|
||||||
|
|
@ -471,7 +487,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0x03,0x69,0xa1,0xff},
|
.row_active_mid = {0x03,0x69,0xa1,0xff},
|
||||||
.row_active_bottom = {0x04,0x4d,0x7a,0xff},
|
.row_active_bottom = {0x04,0x4d,0x7a,0xff},
|
||||||
.row_text = {0x0c,0x4a,0x6e,0xff},
|
.row_text = {0x0c,0x4a,0x6e,0xff},
|
||||||
|
.row_subtext = {0x2c,0x6a,0x8b,0xff},
|
||||||
.row_active_text = {0xf0,0xf9,0xff,0xff},
|
.row_active_text = {0xf0,0xf9,0xff,0xff},
|
||||||
|
.row_active_subtext = {0xd8,0xf0,0xff,0xff},
|
||||||
.block_top = {0xec,0xf8,0xff,0xff},
|
.block_top = {0xec,0xf8,0xff,0xff},
|
||||||
.block_mid = {0xe0,0xf2,0xfe,0xff},
|
.block_mid = {0xe0,0xf2,0xfe,0xff},
|
||||||
.block_bottom = {0xb8,0xe5,0xfb,0xff},
|
.block_bottom = {0xb8,0xe5,0xfb,0xff},
|
||||||
|
|
@ -518,7 +536,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0x4a,0x37,0x28,0xff},
|
.row_active_mid = {0x4a,0x37,0x28,0xff},
|
||||||
.row_active_bottom = {0x2d,0x20,0x17,0xff},
|
.row_active_bottom = {0x2d,0x20,0x17,0xff},
|
||||||
.row_text = {0xff,0xf8,0xdc,0xff},
|
.row_text = {0xff,0xf8,0xdc,0xff},
|
||||||
|
.row_subtext = {0xf0,0xe3,0xc0,0xff},
|
||||||
.row_active_text = {0xda,0x8e,0x00,0xff},
|
.row_active_text = {0xda,0x8e,0x00,0xff},
|
||||||
|
.row_active_subtext = {0xf1,0xc8,0x79,0xff},
|
||||||
.block_top = {0x90,0x61,0x34,0xff},
|
.block_top = {0x90,0x61,0x34,0xff},
|
||||||
.block_mid = {0x6b,0x44,0x23,0xff},
|
.block_mid = {0x6b,0x44,0x23,0xff},
|
||||||
.block_bottom = {0x4f,0x32,0x18,0xff},
|
.block_bottom = {0x4f,0x32,0x18,0xff},
|
||||||
|
|
@ -565,7 +585,9 @@ static const GuideTheme GUIDE_THEMES[GUIDE_THEME_COUNT] = {
|
||||||
.row_active_mid = {0xff,0x38,0x64,0xff},
|
.row_active_mid = {0xff,0x38,0x64,0xff},
|
||||||
.row_active_bottom = {0xa0,0x11,0x3b,0xff},
|
.row_active_bottom = {0xa0,0x11,0x3b,0xff},
|
||||||
.row_text = {0xff,0xff,0xff,0xff},
|
.row_text = {0xff,0xff,0xff,0xff},
|
||||||
|
.row_subtext = {0xd8,0xf6,0xff,0xff},
|
||||||
.row_active_text = {0xff,0xf0,0x1f,0xff},
|
.row_active_text = {0xff,0xf0,0x1f,0xff},
|
||||||
|
.row_active_subtext = {0xff,0xf8,0x9d,0xff},
|
||||||
.block_top = {0x5b,0x20,0xce,0xff},
|
.block_top = {0x5b,0x20,0xce,0xff},
|
||||||
.block_mid = {0x3a,0x0c,0xa3,0xff},
|
.block_mid = {0x3a,0x0c,0xa3,0xff},
|
||||||
.block_bottom = {0x1f,0x06,0x5b,0xff},
|
.block_bottom = {0x1f,0x06,0x5b,0xff},
|
||||||
|
|
|
||||||
101
src/ui.c
101
src/ui.c
|
|
@ -67,10 +67,15 @@ static SDL_Color readable_text_color(SDL_Color background) {
|
||||||
return color_luma(background) < 120 ? COLOR_TEXT_LIGHT : COLOR_TEXT_DARK;
|
return color_luma(background) < 120 ? COLOR_TEXT_LIGHT : COLOR_TEXT_DARK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Color secondary_text_color(SDL_Color primary, SDL_Color background) {
|
static SDL_Color ensure_contrast(SDL_Color preferred, SDL_Color background) {
|
||||||
SDL_Color secondary = blend_color(primary, background, 110);
|
int diff = color_luma(preferred) - color_luma(background);
|
||||||
secondary.a = 255;
|
if (diff < 0) {
|
||||||
return secondary;
|
diff = -diff;
|
||||||
|
}
|
||||||
|
if (diff < 75) {
|
||||||
|
return readable_text_color(background);
|
||||||
|
}
|
||||||
|
return preferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Texture *text_to_texture(SDL_Renderer *renderer, TTF_Font *font, const char *text, SDL_Color color, int *width, int *height) {
|
static SDL_Texture *text_to_texture(SDL_Renderer *renderer, TTF_Font *font, const char *text, SDL_Color color, int *width, int *height) {
|
||||||
|
|
@ -279,6 +284,18 @@ static void draw_text_clipped(SDL_Renderer *renderer,
|
||||||
SDL_RenderSetClipRect(renderer, had_clip ? &previous_clip : NULL);
|
SDL_RenderSetClipRect(renderer, had_clip ? &previous_clip : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void draw_text_shadowed(SDL_Renderer *renderer,
|
||||||
|
TTF_Font *font,
|
||||||
|
const char *text,
|
||||||
|
const SDL_Rect *clip_rect,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
SDL_Color color,
|
||||||
|
SDL_Color shadow) {
|
||||||
|
draw_text_clipped(renderer, font, text, clip_rect, x + 1, y + 1, shadow);
|
||||||
|
draw_text_clipped(renderer, font, text, clip_rect, x, y, color);
|
||||||
|
}
|
||||||
|
|
||||||
static void fit_text_with_ellipsis(TTF_Font *font, const char *text, int max_width, char *out, size_t out_size) {
|
static void fit_text_with_ellipsis(TTF_Font *font, const char *text, int max_width, char *out, size_t out_size) {
|
||||||
int width = 0;
|
int width = 0;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
@ -363,6 +380,8 @@ static void format_clock_label(char *buffer, size_t buffer_size, time_t now, int
|
||||||
|
|
||||||
static void draw_timeline_header_cached(SDL_Renderer *renderer, const UiCache *cache, const GuideTheme *theme, SDL_Rect rect) {
|
static void draw_timeline_header_cached(SDL_Renderer *renderer, const UiCache *cache, const GuideTheme *theme, SDL_Rect rect) {
|
||||||
int segments = 4;
|
int segments = 4;
|
||||||
|
SDL_Color ribbon_text = ensure_contrast(theme->ribbon_text, theme->ribbon_mid);
|
||||||
|
SDL_Color ribbon_shadow = color_luma(theme->ribbon_mid) < 120 ? color_with_alpha(COLOR_BLACK, 255) : color_with_alpha(COLOR_TEXT_LIGHT, 255);
|
||||||
|
|
||||||
draw_beveled_bar(renderer,
|
draw_beveled_bar(renderer,
|
||||||
&rect,
|
&rect,
|
||||||
|
|
@ -375,7 +394,12 @@ static void draw_timeline_header_cached(SDL_Renderer *renderer, const UiCache *c
|
||||||
for (int i = 0; i < segments; ++i) {
|
for (int i = 0; i < segments; ++i) {
|
||||||
int x = rect.x + (rect.w * i) / segments;
|
int x = rect.x + (rect.w * i) / segments;
|
||||||
int centered_x = x - cache->timeline_labels[i].width / 2;
|
int centered_x = x - cache->timeline_labels[i].width / 2;
|
||||||
draw_cached_text(renderer, &cache->timeline_labels[i], centered_x, rect.y + 10);
|
SDL_Rect shadow_dst = {centered_x + 1, rect.y + 11, cache->timeline_labels[i].width, cache->timeline_labels[i].height};
|
||||||
|
SDL_Rect text_dst = {centered_x, rect.y + 10, cache->timeline_labels[i].width, cache->timeline_labels[i].height};
|
||||||
|
SDL_SetTextureColorMod(cache->timeline_labels[i].texture, ribbon_shadow.r, ribbon_shadow.g, ribbon_shadow.b);
|
||||||
|
SDL_RenderCopy(renderer, cache->timeline_labels[i].texture, NULL, &shadow_dst);
|
||||||
|
SDL_SetTextureColorMod(cache->timeline_labels[i].texture, ribbon_text.r, ribbon_text.g, ribbon_text.b);
|
||||||
|
SDL_RenderCopy(renderer, cache->timeline_labels[i].texture, NULL, &text_dst);
|
||||||
set_draw_color(renderer, theme->grid_line);
|
set_draw_color(renderer, theme->grid_line);
|
||||||
SDL_RenderDrawLine(renderer, x, rect.y + rect.h - 2, x, rect.y + rect.h + 5 * 76);
|
SDL_RenderDrawLine(renderer, x, rect.y + rect.h - 2, x, rect.y + rect.h + 5 * 76);
|
||||||
}
|
}
|
||||||
|
|
@ -432,11 +456,14 @@ static void draw_info_panel(SDL_Renderer *renderer,
|
||||||
time_t end_time;
|
time_t end_time;
|
||||||
double program_seek;
|
double program_seek;
|
||||||
const ProgramEntry *program;
|
const ProgramEntry *program;
|
||||||
|
SDL_Color panel_text;
|
||||||
|
|
||||||
if (!rect || !selected_channel) {
|
if (!rect || !selected_channel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panel_text = ensure_contrast(theme->panel_text, theme->panel_fill);
|
||||||
|
|
||||||
draw_panel_shadow(renderer, rect);
|
draw_panel_shadow(renderer, rect);
|
||||||
draw_rounded_top_panel(renderer, rect, theme->panel_fill, theme->panel_border, theme->rounded_radius > 0 ? theme->rounded_radius : 8);
|
draw_rounded_top_panel(renderer, rect, theme->panel_fill, theme->panel_border, theme->rounded_radius > 0 ? theme->rounded_radius : 8);
|
||||||
accent = (SDL_Rect){rect->x + 1, rect->y + 1, rect->w - 2, 38};
|
accent = (SDL_Rect){rect->x + 1, rect->y + 1, rect->w - 2, 38};
|
||||||
|
|
@ -460,10 +487,10 @@ static void draw_info_panel(SDL_Renderer *renderer,
|
||||||
selected_channel->description[0] != '\0' ? selected_channel->description : "Local programming lineup.");
|
selected_channel->description[0] != '\0' ? selected_channel->description : "Local programming lineup.");
|
||||||
|
|
||||||
clip_rect = (SDL_Rect){rect->x + 16, rect->y + 12, rect->w - 32, rect->h - 24};
|
clip_rect = (SDL_Rect){rect->x + 16, rect->y + 12, rect->w - 32, rect->h - 24};
|
||||||
draw_text_clipped(renderer, fonts->large, selected_channel->name, &clip_rect, rect->x + 18, rect->y + 44, theme->panel_text);
|
draw_text_clipped(renderer, fonts->large, selected_channel->name, &clip_rect, rect->x + 18, rect->y + 44, panel_text);
|
||||||
draw_text_clipped(renderer, fonts->medium, program->program_title, &clip_rect, rect->x + 18, rect->y + 88, theme->panel_text);
|
draw_text_clipped(renderer, fonts->medium, program->program_title, &clip_rect, rect->x + 18, rect->y + 88, panel_text);
|
||||||
draw_text_clipped(renderer, fonts->small, time_range, &clip_rect, rect->x + 18, rect->y + 124, theme->panel_text);
|
draw_text_clipped(renderer, fonts->small, time_range, &clip_rect, rect->x + 18, rect->y + 124, panel_text);
|
||||||
draw_text_clipped(renderer, fonts->small, description, &clip_rect, rect->x + 18, rect->y + 148, theme->panel_text);
|
draw_text_clipped(renderer, fonts->small, description, &clip_rect, rect->x + 18, rect->y + 148, panel_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_grid_background(SDL_Renderer *renderer, const GuideTheme *theme, const SDL_Rect *grid_rect, int row_height, double pixels_per_minute) {
|
static void draw_grid_background(SDL_Renderer *renderer, const GuideTheme *theme, const SDL_Rect *grid_rect, int row_height, double pixels_per_minute) {
|
||||||
|
|
@ -475,8 +502,10 @@ static void draw_grid_background(SDL_Renderer *renderer, const GuideTheme *theme
|
||||||
|
|
||||||
for (int minute = 0; minute <= 90; minute += 30) {
|
for (int minute = 0; minute <= 90; minute += 30) {
|
||||||
int x = GUIDE_X_START + (int) (minute * pixels_per_minute);
|
int x = GUIDE_X_START + (int) (minute * pixels_per_minute);
|
||||||
set_draw_color(renderer, theme->grid_line);
|
SDL_Color strong_line = ensure_contrast(theme->grid_line, theme->background_mid);
|
||||||
|
set_draw_color(renderer, strong_line);
|
||||||
SDL_RenderDrawLine(renderer, x, grid_rect->y, x, grid_rect->y + grid_rect->h);
|
SDL_RenderDrawLine(renderer, x, grid_rect->y, x, grid_rect->y + grid_rect->h);
|
||||||
|
SDL_RenderDrawLine(renderer, x + 1, grid_rect->y, x + 1, grid_rect->y + grid_rect->h);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int row = 0; row <= GUIDE_VISIBLE_ROWS; ++row) {
|
for (int row = 0; row <= GUIDE_VISIBLE_ROWS; ++row) {
|
||||||
|
|
@ -593,14 +622,15 @@ void ui_render_guide(SDL_Renderer *renderer,
|
||||||
draw_video(renderer, video_texture, texture_width, texture_height, preview);
|
draw_video(renderer, video_texture, texture_width, texture_height, preview);
|
||||||
draw_status_bar(renderer, fonts->medium, theme, selected_channel, &status_bar, now_wall);
|
draw_status_bar(renderer, fonts->medium, theme, selected_channel, &status_bar, now_wall);
|
||||||
|
|
||||||
if (cache->timeline_label_slot != now_wall / 60) {
|
if (cache->timeline_label_slot != now_wall / 60 || cache->timeline_theme != theme) {
|
||||||
char label[32];
|
char label[32];
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
format_clock_label(label, sizeof(label), now_wall, (int) ((TIMELINE_VISIBLE_SECONDS / 60.0 / 4) * i));
|
format_clock_label(label, sizeof(label), now_wall, (int) ((TIMELINE_VISIBLE_SECONDS / 60.0 / 4) * i));
|
||||||
text_texture_destroy(&cache->timeline_labels[i]);
|
text_texture_destroy(&cache->timeline_labels[i]);
|
||||||
text_texture_init(&cache->timeline_labels[i], renderer, fonts->small, label, theme->ribbon_text);
|
text_texture_init(&cache->timeline_labels[i], renderer, fonts->small, label, COLOR_TEXT_LIGHT);
|
||||||
}
|
}
|
||||||
cache->timeline_label_slot = now_wall / 60;
|
cache->timeline_label_slot = now_wall / 60;
|
||||||
|
cache->timeline_theme = theme;
|
||||||
}
|
}
|
||||||
draw_timeline_header_cached(renderer, cache, theme, header_row);
|
draw_timeline_header_cached(renderer, cache, theme, header_row);
|
||||||
draw_grid_background(renderer, theme, &grid, row_height, pixels_per_minute);
|
draw_grid_background(renderer, theme, &grid, row_height, pixels_per_minute);
|
||||||
|
|
@ -653,6 +683,15 @@ void ui_render_guide(SDL_Renderer *renderer,
|
||||||
SDL_Rect block = {guide_x_start, timeline_rect.y + 4, 48, timeline_rect.h - 8};
|
SDL_Rect block = {guide_x_start, timeline_rect.y + 4, 48, timeline_rect.h - 8};
|
||||||
SDL_Rect title_rect = {block.x + 8, block.y + 8, block.w - 16, block.h - 16};
|
SDL_Rect title_rect = {block.x + 8, block.y + 8, block.w - 16, block.h - 16};
|
||||||
char title[128];
|
char title[128];
|
||||||
|
SDL_Color row_primary = ensure_contrast(is_selected ? theme->row_active_text : theme->row_text,
|
||||||
|
is_selected ? theme->row_active_mid : theme->row_mid);
|
||||||
|
SDL_Color row_secondary = ensure_contrast(is_selected ? theme->row_active_subtext : theme->row_subtext,
|
||||||
|
is_selected ? theme->row_active_mid : theme->row_mid);
|
||||||
|
SDL_Color block_text = ensure_contrast(is_selected ? theme->block_active_text : theme->block_text,
|
||||||
|
is_selected ? theme->block_active_mid : theme->block_mid);
|
||||||
|
SDL_Color block_shadow = color_luma(is_selected ? theme->block_active_mid : theme->block_mid) < 120
|
||||||
|
? color_with_alpha(COLOR_BLACK, 255)
|
||||||
|
: color_with_alpha(COLOR_TEXT_LIGHT, 255);
|
||||||
|
|
||||||
if (!program) {
|
if (!program) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -665,27 +704,28 @@ void ui_render_guide(SDL_Renderer *renderer,
|
||||||
title_rect = (SDL_Rect){block.x + 8, block.y + 8, block.w - 16, block.h - 16};
|
title_rect = (SDL_Rect){block.x + 8, block.y + 8, block.w - 16, block.h - 16};
|
||||||
|
|
||||||
if (is_selected) {
|
if (is_selected) {
|
||||||
draw_text_clipped(renderer, fonts->medium, channel->name, &sidebar, 20, row_rect.y + 12, theme->row_active_text);
|
draw_text_shadowed(renderer, fonts->medium, channel->name, &sidebar, 20, row_rect.y + 12, row_primary, color_with_alpha(COLOR_BLACK, 255));
|
||||||
{
|
{
|
||||||
char number[16];
|
char number[16];
|
||||||
snprintf(number, sizeof(number), "%d", channel->number);
|
snprintf(number, sizeof(number), "%d", channel->number);
|
||||||
draw_text_clipped(renderer, fonts->medium, number, &sidebar, 176, row_rect.y + 12, theme->row_active_text);
|
draw_text_shadowed(renderer, fonts->medium, number, &sidebar, 176, row_rect.y + 12, row_primary, color_with_alpha(COLOR_BLACK, 255));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
draw_text_clipped(renderer, fonts->medium, channel->name, &sidebar, 20, row_rect.y + 12, theme->row_text);
|
draw_text_shadowed(renderer, fonts->medium, channel->name, &sidebar, 20, row_rect.y + 12, row_primary, color_with_alpha(COLOR_BLACK, 255));
|
||||||
{
|
{
|
||||||
char number[16];
|
char number[16];
|
||||||
snprintf(number, sizeof(number), "%d", channel->number);
|
snprintf(number, sizeof(number), "%d", channel->number);
|
||||||
draw_text_clipped(renderer, fonts->medium, number, &sidebar, 176, row_rect.y + 12, theme->row_text);
|
draw_text_shadowed(renderer, fonts->medium, number, &sidebar, 176, row_rect.y + 12, row_primary, color_with_alpha(COLOR_BLACK, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_text_clipped(renderer,
|
draw_text_shadowed(renderer,
|
||||||
fonts->small,
|
fonts->small,
|
||||||
program->file_name,
|
program->file_name,
|
||||||
&sidebar,
|
&sidebar,
|
||||||
20,
|
20,
|
||||||
row_rect.y + 38,
|
row_rect.y + 38,
|
||||||
secondary_text_color(theme->row_text, is_selected ? theme->row_active_mid : theme->row_mid));
|
row_secondary,
|
||||||
|
color_with_alpha(COLOR_BLACK, 255));
|
||||||
|
|
||||||
SDL_RenderSetClipRect(renderer, &clip);
|
SDL_RenderSetClipRect(renderer, &clip);
|
||||||
draw_beveled_bar(renderer,
|
draw_beveled_bar(renderer,
|
||||||
|
|
@ -700,13 +740,14 @@ void ui_render_guide(SDL_Renderer *renderer,
|
||||||
title_rect.w,
|
title_rect.w,
|
||||||
title,
|
title,
|
||||||
sizeof(title));
|
sizeof(title));
|
||||||
draw_text_clipped(renderer,
|
draw_text_shadowed(renderer,
|
||||||
is_selected ? fonts->medium : fonts->small,
|
is_selected ? fonts->medium : fonts->small,
|
||||||
title,
|
title,
|
||||||
&title_rect,
|
&title_rect,
|
||||||
title_rect.x,
|
title_rect.x,
|
||||||
title_rect.y,
|
title_rect.y,
|
||||||
is_selected ? theme->block_active_text : theme->block_text);
|
block_text,
|
||||||
|
block_shadow);
|
||||||
SDL_RenderSetClipRect(renderer, NULL);
|
SDL_RenderSetClipRect(renderer, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
src/ui.h
1
src/ui.h
|
|
@ -42,6 +42,7 @@ typedef struct UiCache {
|
||||||
UiTextTexture footer_title;
|
UiTextTexture footer_title;
|
||||||
UiTextTexture *timeline_labels;
|
UiTextTexture *timeline_labels;
|
||||||
time_t timeline_label_slot;
|
time_t timeline_label_slot;
|
||||||
|
const GuideTheme *timeline_theme;
|
||||||
UiChannelCache *channels;
|
UiChannelCache *channels;
|
||||||
int channel_count;
|
int channel_count;
|
||||||
} UiCache;
|
} UiCache;
|
||||||
|
|
|
||||||
BIN
src/ui.o
BIN
src/ui.o
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue