diff options
author | quou <quou@disroot.org> | 2024-06-02 21:46:07 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-06-02 21:47:26 +1000 |
commit | 62b4a3ededd237f4b4850d91c052585e2f687499 (patch) | |
tree | 25bf590a634c6c71f399cf9b1d620500f06b8b9f /ui.c | |
parent | 2e761bdb8badecdbda2925a056a6d5aa3e3cac83 (diff) |
Switched to luigi, parsing out FLAC metadata.
Diffstat (limited to 'ui.c')
-rw-r--r-- | ui.c | 152 |
1 files changed, 0 insertions, 152 deletions
@@ -1,152 +0,0 @@ -#include "config.h" -#include "render.h" -#include "plat.h" -#include "rcache.h" -#include "ui.h" - -Rectangle rectcut_left(Rectangle* l, int a) { - Rectangle r; - r.x = l->x; - r.y = l->y; - r.w = a; - r.h = l->h; - l->x += a; - l->w -= a; - return r; -} - -Rectangle rectcut_right(Rectangle* l, int a) { - Rectangle r; - r.x = l->x + l->w - a; - r.y = l->y; - r.w = a; - r.h = l->h; - l->w -= a; - return r; -} - -Rectangle rectcut_top(Rectangle* l, int a) { - Rectangle r; - r.x = l->x; - r.y = l->y; - r.w = l->w; - r.h = a; - l->y += a; - l->h -= a; - return r; -} - -Rectangle rectcut_bottom(Rectangle* l, int a) { - Rectangle r; - r.x = l->x; - r.y = l->y + l->h - a; - r.w = l->w; - r.h = a; - l->h -= a; - return r; -} - -Rectangle shrink_rect(const Rectangle* l, int a) { - Rectangle r; - int a2 = a * 2; - r.x = l->x + a; - r.y = l->y + a; - r.w = l->w - a2; - r.h = l->h - a2; - return r; -} - -Rectangle centre_rect( - const Rectangle* l, - const Rectangle* t -) { - Rectangle r; - r.x = l->x + l->w / 2 - t->w / 2; - r.y = l->y + l->h / 2 - t->h / 2; - r.w = t->w; - r.h = t->h; - return r; -} - -void init_ui(UI* u, Font* f) { - u->font = f; -} - -void ui_begin(UI* u, Rectangle* l) { - (void)u; - l->x = 0; - l->y = 0; - l->w = get_render_w(); - l->h = get_render_h(); -} - -void ui_end(UI* u) { - (void)u; -} - -void ui_label( - UI* u, - const Rectangle* l, - const char* text -) { - rc_add_cmd_rfont_text_col( - u->font, - l->x, - l->y, - text, - theme_text_colour - ); -} - -int ui_button( - UI* u, - const Rectangle* r, - const char* label -) { - Rectangle o, t; - Colour c; - int h; - o = shrink_rect(r, theme_outline_width); - h = point_rect_overlap( - &o, - get_mouse_x(), - get_mouse_y() - ); - if (h) { - if (mbtn_pressed(mbtn_left)) - c = theme_active_colour; - else - c = theme_hovered_colour; - } else - c = theme_background_colour; - rc_add_cmd_rect(r, theme_outline_colour); - rc_add_cmd_rect(&o, c); - t = text_rect(u->font, label); - o = centre_rect(&o, &t); - rc_add_cmd_rfont_text_col( - u->font, - o.x, - o.y, - label, - theme_text_colour - ); - return h && mbtn_just_released(mbtn_left); -} - -void ui_container( - UI* u, - const Rectangle* l, - Rectangle* r, - const Rectangle* c -) { - Rectangle o, cl; - (void)u; - rc_add_cmd_rect(l, theme_outline_colour); - o = shrink_rect(l, theme_outline_width); - rc_add_cmd_rect(&o, theme_background_colour); - cl = o; - cl.w += cl.x; - cl.h += cl.y; - rc_add_cmd_clip(&cl); - *r = shrink_rect(&o, theme_padding); -} |