Only highlight the widgets on mouse down when they are also hovered #106

Merged
MartinFouilleul merged 3 commits from ilidemi/orca:fix-hovered-active into main 2023-09-16 14:41:21 +00:00
2 changed files with 22 additions and 17 deletions
Showing only changes of commit 300d5aeab4 - Show all commits

View File

@ -867,6 +867,10 @@ bool oc_ui_style_selector_match(oc_ui_box* box, oc_ui_style_rule* rule, oc_ui_se
{
res = res && oc_ui_box_hovering(box, oc_ui_mouse_position());
}
if(selector->status & OC_UI_HOT)
{
res = res && box->hot;
}
if(selector->status & OC_UI_ACTIVE)
{
res = res && box->active;
@ -2780,14 +2784,14 @@ oc_ui_radio_group_info oc_ui_radio_group(const char* name, oc_ui_radio_group_inf
| OC_UI_STYLE_BORDER_SIZE;
oc_ui_style_box_before(radio, defaultPattern, &defaultStyle, defaultMask);
oc_ui_pattern hoverPattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &hoverPattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = defaultTag });
oc_ui_pattern_push(&ui->frameArena, &hoverPattern, (oc_ui_selector){ .op = OC_UI_SEL_AND, .kind = OC_UI_SEL_STATUS, .status = OC_UI_HOVER });
oc_ui_style hoverStyle = { .bgColor = theme->fill0,
.borderColor = theme->primary };
oc_ui_style_mask hoverMask = OC_UI_STYLE_BG_COLOR
| OC_UI_STYLE_BORDER_COLOR;
oc_ui_style_box_after(radio, hoverPattern, &hoverStyle, hoverMask);
oc_ui_pattern hotPattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &hotPattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = defaultTag });
oc_ui_pattern_push(&ui->frameArena, &hotPattern, (oc_ui_selector){ .op = OC_UI_SEL_AND, .kind = OC_UI_SEL_STATUS, .status = OC_UI_HOT });
oc_ui_style hotStyle = { .bgColor = theme->fill0,
.borderColor = theme->primary };
oc_ui_style_mask hotMask = OC_UI_STYLE_BG_COLOR
| OC_UI_STYLE_BORDER_COLOR;
oc_ui_style_box_after(radio, hotPattern, &hotStyle, hotMask);
oc_ui_pattern activePattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &activePattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = defaultTag });
@ -2807,11 +2811,11 @@ oc_ui_radio_group_info oc_ui_radio_group(const char* name, oc_ui_radio_group_inf
| OC_UI_STYLE_BG_COLOR;
oc_ui_style_box_before(radio, selectedPattern, &selectedStyle, selectedMask);
oc_ui_pattern selectedHoverPattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &selectedHoverPattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = selectedTag });
oc_ui_pattern_push(&ui->frameArena, &selectedHoverPattern, (oc_ui_selector){ .op = OC_UI_SEL_AND, .kind = OC_UI_SEL_STATUS, .status = OC_UI_HOVER });
oc_ui_style selectedHoverStyle = { .bgColor = theme->primaryHover };
oc_ui_style_box_after(radio, selectedHoverPattern, &selectedHoverStyle, OC_UI_STYLE_BG_COLOR);
oc_ui_pattern selectedHotPattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &selectedHotPattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = selectedTag });
oc_ui_pattern_push(&ui->frameArena, &selectedHotPattern, (oc_ui_selector){ .op = OC_UI_SEL_AND, .kind = OC_UI_SEL_STATUS, .status = OC_UI_HOT });
oc_ui_style selectedHotStyle = { .bgColor = theme->primaryHover };
oc_ui_style_box_after(radio, selectedHotPattern, &selectedHotStyle, OC_UI_STYLE_BG_COLOR);
oc_ui_pattern selectedActivePattern = { 0 };
oc_ui_pattern_push(&ui->frameArena, &selectedActivePattern, (oc_ui_selector){ .kind = OC_UI_SEL_TAG, .tag = selectedTag });

View File

@ -388,12 +388,13 @@ typedef enum
typedef u8 oc_ui_status;
enum
enum oc_ui_status_enum
{
OC_UI_NONE = 0,
OC_UI_HOVER = 1 << 1,
OC_UI_ACTIVE = 1 << 2,
OC_UI_DRAGGING = 1 << 3,
OC_UI_HOT = 1 << 2,
OC_UI_ACTIVE = 1 << 3,
OC_UI_DRAGGING = 1 << 4,
};
typedef enum
@ -623,7 +624,7 @@ typedef struct oc_ui_context
oc_ui_edit_move editSelectionMode;
i32 editWordSelectionInitialCursor;
i32 editWordSelectionInitialMark;
bool clipboardRegistered;
oc_ui_theme* theme;