diff options
| author | aura <nw@moneybot.cc> | 2026-03-04 00:51:18 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-04 00:51:18 +0100 |
| commit | 890bea19359649695df1b618a41ce580cf3dfbda (patch) | |
| tree | 8bc10ae4e613b0ad57fae9a68cec38c7d59cf067 /src/gui/button.cpp | |
| parent | 61aea7311c2e1af78fd9da544499f2198f2da1dd (diff) | |
| parent | be91342733fd56d1e7bafe72e82a8ac4dc67b79d (diff) | |
Merge branch 'ui-rework'
Diffstat (limited to 'src/gui/button.cpp')
| -rw-r--r-- | src/gui/button.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 2b57772..e66130b 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -5,15 +5,31 @@ void gui_button_draw_fn( void* ptr ) { I32 x = gui_relx( btn ); I32 y = gui_rely( btn ); + I32 mx, my; + gui_cursor_pos( &mx, &my ); + U8 inbounds = mx >= x && mx <= x + btn->w && my >= y && my <= y + btn->h; + U8 active = btn->held && inbounds && gui_mbutton_down( GUI_MBTNLEFT ); + U8 hover = inbounds && !active; + + CLR border = gui_is_fg_window( btn )? ui_clr.border : ui_clr.border_inactive; + + CLR fill = ui_clr.bg_sec; + CLR txt = ui_clr.txt; + if( active ) { + fill = CLR::blend( ui_clr.bg_sec, ui_clr.border, 0.22f ); + } + if( hover ) { + fill = ui_clr.border; + txt = CLR::BLACK(); + } - CLR col = gui_is_fg_window( btn )? ui_clr.border : ui_clr.border_inactive; - gui_draw_frect( x, y, btn->w, btn->h, col ); - gui_draw_frect( x+1, y+1, btn->w-2, btn->h-2, ui_clr.bg_sec ); + gui_draw_frect( x, y, btn->w, btn->h, border ); + gui_draw_frect( x+1, y+1, btn->w-2, btn->h-2, fill ); I32 middle = x + btn->w/2; I32 middle_y = y + btn->h/2 - 7; - gui_draw_str( middle, middle_y, ALIGN_C, FNT_JPN12, ui_clr.txt, btn->name ); + gui_draw_str( middle, middle_y, ALIGN_C, FNT_JPN12, txt, btn->name ); } void gui_button_input_fn( void* ptr ) { |
