diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-22 07:22:15 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-10-22 07:22:15 +0300 |
commit | d14f9aebe27cd48a8d21c0eb691c8e7bf94722a8 (patch) | |
tree | da58c38b49dba1c45483eec89ea9408432655aea /src/ui/widget.c | |
parent | 525c0e24dca01a08ae389b271aee7400ebd8c16b (diff) |
Working on tab close buttons
An [x] button appears on tab buttons when hovering on them. Still needs a bit of layout tweaks and the first tab doesn't have a button yet.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index ec92ac5a..75c07c5a 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -973,6 +973,18 @@ iLocalDef iBool isMouseEvent_(const SDL_Event *ev) { | |||
973 | ev->type == SDL_MOUSEBUTTONUP || ev->type == SDL_MOUSEBUTTONDOWN); | 973 | ev->type == SDL_MOUSEBUTTONUP || ev->type == SDL_MOUSEBUTTONDOWN); |
974 | } | 974 | } |
975 | 975 | ||
976 | iLocalDef iBool isHidden_Widget_(const iWidget *d) { | ||
977 | if (d->flags & visibleOnParentHover_WidgetFlag && | ||
978 | (isHover_Widget(d) || isHover_Widget(d->parent))) { | ||
979 | return iFalse; | ||
980 | } | ||
981 | return (d->flags & hidden_WidgetFlag) != 0; | ||
982 | } | ||
983 | |||
984 | iLocalDef iBool isDrawn_Widget_(const iWidget *d) { | ||
985 | return !isHidden_Widget_(d) || d->flags & visualOffset_WidgetFlag; | ||
986 | } | ||
987 | |||
976 | static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) { | 988 | static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) { |
977 | if (d->flags & destroyPending_WidgetFlag) { | 989 | if (d->flags & destroyPending_WidgetFlag) { |
978 | return iFalse; /* no more events handled */ | 990 | return iFalse; /* no more events handled */ |
@@ -983,7 +995,7 @@ static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) { | |||
983 | d->flags & disabledWhenHidden_WidgetFlag)) { | 995 | d->flags & disabledWhenHidden_WidgetFlag)) { |
984 | if (isKey || isMouse) return iFalse; | 996 | if (isKey || isMouse) return iFalse; |
985 | } | 997 | } |
986 | if (d->flags & hidden_WidgetFlag) { | 998 | if (isHidden_Widget_(d)) { |
987 | if (isMouse) return iFalse; | 999 | if (isMouse) return iFalse; |
988 | } | 1000 | } |
989 | return iTrue; | 1001 | return iTrue; |
@@ -1032,7 +1044,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
1032 | else if (ev->type == SDL_MOUSEMOTION && | 1044 | else if (ev->type == SDL_MOUSEMOTION && |
1033 | ev->motion.windowID == SDL_GetWindowID(window_Widget(d)->win) && | 1045 | ev->motion.windowID == SDL_GetWindowID(window_Widget(d)->win) && |
1034 | (!window_Widget(d)->hover || hasParent_Widget(d, window_Widget(d)->hover)) && | 1046 | (!window_Widget(d)->hover || hasParent_Widget(d, window_Widget(d)->hover)) && |
1035 | flags_Widget(d) & hover_WidgetFlag && ~flags_Widget(d) & hidden_WidgetFlag && | 1047 | flags_Widget(d) & hover_WidgetFlag && !isHidden_Widget_(d) && |
1036 | ~flags_Widget(d) & disabled_WidgetFlag) { | 1048 | ~flags_Widget(d) & disabled_WidgetFlag) { |
1037 | if (contains_Widget(d, init_I2(ev->motion.x, ev->motion.y))) { | 1049 | if (contains_Widget(d, init_I2(ev->motion.x, ev->motion.y))) { |
1038 | setHover_Widget(d); | 1050 | setHover_Widget(d); |
@@ -1282,10 +1294,6 @@ int backgroundFadeColor_Widget(void) { | |||
1282 | } | 1294 | } |
1283 | } | 1295 | } |
1284 | 1296 | ||
1285 | iLocalDef iBool isDrawn_Widget_(const iWidget *d) { | ||
1286 | return ~d->flags & hidden_WidgetFlag || d->flags & visualOffset_WidgetFlag; | ||
1287 | } | ||
1288 | |||
1289 | void drawLayerEffects_Widget(const iWidget *d) { | 1297 | void drawLayerEffects_Widget(const iWidget *d) { |
1290 | /* Layered effects are not buffered, so they are drawn here separately. */ | 1298 | /* Layered effects are not buffered, so they are drawn here separately. */ |
1291 | iAssert(isDrawn_Widget_(d)); | 1299 | iAssert(isDrawn_Widget_(d)); |
@@ -1711,7 +1719,7 @@ size_t childIndex_Widget(const iWidget *d, const iAnyObject *child) { | |||
1711 | } | 1719 | } |
1712 | 1720 | ||
1713 | iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { | 1721 | iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { |
1714 | if (d->flags & hidden_WidgetFlag) { | 1722 | if (isHidden_Widget_(d)) { |
1715 | return NULL; | 1723 | return NULL; |
1716 | } | 1724 | } |
1717 | /* Check for on-top widgets first. */ | 1725 | /* Check for on-top widgets first. */ |