ui: add ui_picker_button

This commit is contained in:
luboslenco
2026-03-27 09:04:01 +01:00
parent 874356967c
commit c9765e43f4
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -388,6 +388,7 @@ extern char ui_text_to_paste[1024];
extern char ui_text_to_copy[1024];
extern void (*ui_on_border_hover)(ui_handle_t *, int);
extern void (*ui_on_tab_drop)(ui_handle_t *, int, ui_handle_t *, int);
extern bool (*ui_picker_button)(void);
extern const char *ui_theme_keys[];
extern int ui_theme_keys_count;
+9 -1
View File
@@ -19,6 +19,7 @@ static int text_area_selection_start_col = 0;
bool ui_text_area_line_numbers = false;
bool ui_text_area_scroll_past_end = false;
ui_text_coloring_t *ui_text_area_coloring = NULL;
bool (*ui_picker_button)(void) = NULL;
float ui_dist(float x1, float y1, float x2, float y2) {
float vx = x1 - x2;
@@ -158,6 +159,10 @@ uint32_t ui_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
return (a << 24) | (r << 16) | (g << 8) | b;
}
bool _ui_picker_button() {
return ui_button("P", UI_ALIGN_CENTER, "");
}
int ui_color_wheel(ui_handle_t *handle, bool alpha, float w, float h, bool color_preview, void (*picker)(void *), void *data) {
ui_t *current = ui_get_current();
if (w < 0) {
@@ -186,7 +191,10 @@ int ui_color_wheel(ui_handle_t *handle, bool alpha, float w, float h, bool color
float _y = current->_y;
float _w = current->_w;
current->_w = (int)(28.0 * UI_SCALE());
if (picker != NULL && ui_button("P", UI_ALIGN_CENTER, "")) {
if (ui_picker_button == NULL) {
ui_picker_button = &_ui_picker_button;
}
if (picker != NULL && ui_picker_button()) {
(*picker)(data);
current->changed = false;
handle->changed = false;