fix(zephr/ui): color picker and small mouse event fixes

- reset pressed state at the end of the frame
- correctly place the color picker regardless of window size
- make color picker popup border radius consistent regardless of window
  size
- don't draw the color picker popup if it's parent is not visible
This commit is contained in:
2024-01-09 03:27:54 +02:00
parent 12626a513e
commit 1c9d084113
3 changed files with 19 additions and 9 deletions
+2 -4
View File
@@ -853,6 +853,7 @@ bool zephr_should_quit(void) {
zephr_ctx->cursor = ZEPHR_CURSOR_ARROW;
zephr_ctx->mouse.released = false;
zephr_ctx->mouse.pressed = false;
audio_update();
@@ -866,6 +867,7 @@ void zephr_swap_buffers(void) {
if (zephr_ctx->ui.popup_open) {
draw_color_picker_popup(&zephr_ctx->ui.popup_parent_constraints);
}
zephr_ctx->ui.popup_open = false;
glXSwapBuffers(x11_display, x11_window);
XDefineCursor(x11_display, x11_window, zephr_ctx->cursors[zephr_ctx->cursor]);
@@ -1064,10 +1066,6 @@ bool zephr_iter_events(ZephrEvent *event_out) {
switch (xev.xbutton.button) {
case Button1:
event_out->mouse.button = ZEPHR_MOUSE_BUTTON_LEFT;
/* if (!inside_rect(&zephr_ctx->ui.popup_rect, &event_out->mouse.position)) { */
/* zephr_ctx->ui.popup_open = false; */
/* zephr_ctx->ui.active_element = 0; */
/* } */
break;
case Button2:
event_out->mouse.button = ZEPHR_MOUSE_BUTTON_MIDDLE;