diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/labelwidget.c | 10 | ||||
-rw-r--r-- | src/ui/labelwidget.h | 1 | ||||
-rw-r--r-- | src/ui/mobile.c | 3 | ||||
-rw-r--r-- | src/ui/util.c | 15 | ||||
-rw-r--r-- | src/ui/util.h | 1 | ||||
-rw-r--r-- | src/ui/widget.c | 22 | ||||
-rw-r--r-- | src/ui/widget.h | 2 |
7 files changed, 42 insertions, 12 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 9713e1f2..e4fe9d5f 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -51,6 +51,7 @@ struct Impl_LabelWidget { | |||
51 | uint8_t wrap : 1; | 51 | uint8_t wrap : 1; |
52 | uint8_t allCaps : 1; | 52 | uint8_t allCaps : 1; |
53 | uint8_t removeTrailingColon : 1; | 53 | uint8_t removeTrailingColon : 1; |
54 | uint8_t chevron : 1; | ||
54 | } flags; | 55 | } flags; |
55 | }; | 56 | }; |
56 | 57 | ||
@@ -307,7 +308,7 @@ static iRect contentBounds_LabelWidget_(const iLabelWidget *d) { | |||
307 | 308 | ||
308 | static void draw_LabelWidget_(const iLabelWidget *d) { | 309 | static void draw_LabelWidget_(const iLabelWidget *d) { |
309 | const iWidget *w = constAs_Widget(d); | 310 | const iWidget *w = constAs_Widget(d); |
310 | draw_Widget(w); | 311 | drawBackground_Widget(w); |
311 | const iBool isButton = d->click.button != 0; | 312 | const iBool isButton = d->click.button != 0; |
312 | const int64_t flags = flags_Widget(w); | 313 | const int64_t flags = flags_Widget(w); |
313 | const iRect bounds = bounds_Widget(w); | 314 | const iRect bounds = bounds_Widget(w); |
@@ -423,7 +424,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
423 | "%s", | 424 | "%s", |
424 | cstr_String(&d->label)); | 425 | cstr_String(&d->label)); |
425 | } | 426 | } |
426 | if (flags & chevron_WidgetFlag) { | 427 | if (d->flags.chevron) { |
427 | const iRect chRect = rect; | 428 | const iRect chRect = rect; |
428 | const int chSize = lineHeight_Text(d->font); | 429 | const int chSize = lineHeight_Text(d->font); |
429 | drawCentered_Text(d->font, | 430 | drawCentered_Text(d->font, |
@@ -432,6 +433,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
432 | iTrue, iconColor, rightAngle_Icon); | 433 | iTrue, iconColor, rightAngle_Icon); |
433 | } | 434 | } |
434 | unsetClip_Paint(&p); | 435 | unsetClip_Paint(&p); |
436 | drawChildren_Widget(w); | ||
435 | } | 437 | } |
436 | 438 | ||
437 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { | 439 | static void sizeChanged_LabelWidget_(iLabelWidget *d) { |
@@ -569,6 +571,10 @@ void setNoTopFrame_LabelWidget(iLabelWidget *d, iBool noTopFrame) { | |||
569 | d->flags.noTopFrame = noTopFrame; | 571 | d->flags.noTopFrame = noTopFrame; |
570 | } | 572 | } |
571 | 573 | ||
574 | void setChevron_LabelWidget(iLabelWidget *d, iBool chevron) { | ||
575 | d->flags.chevron = chevron; | ||
576 | } | ||
577 | |||
572 | void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) { | 578 | void setWrap_LabelWidget(iLabelWidget *d, iBool wrap) { |
573 | d->flags.wrap = wrap; | 579 | d->flags.wrap = wrap; |
574 | } | 580 | } |
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index 6275d2c8..6542ae12 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h | |||
@@ -32,6 +32,7 @@ iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *comma | |||
32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); | 32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); |
33 | void setNoAutoMinHeight_LabelWidget (iLabelWidget *, iBool noAutoMinHeight); | 33 | void setNoAutoMinHeight_LabelWidget (iLabelWidget *, iBool noAutoMinHeight); |
34 | void setNoTopFrame_LabelWidget (iLabelWidget *, iBool noTopFrame); | 34 | void setNoTopFrame_LabelWidget (iLabelWidget *, iBool noTopFrame); |
35 | void setChevron_LabelWidget (iLabelWidget *, iBool chevron); | ||
35 | void setWrap_LabelWidget (iLabelWidget *, iBool wrap); | 36 | void setWrap_LabelWidget (iLabelWidget *, iBool wrap); |
36 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); | 37 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); |
37 | void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps); | 38 | void setAllCaps_LabelWidget (iLabelWidget *, iBool allCaps); |
diff --git a/src/ui/mobile.c b/src/ui/mobile.c index f11769f5..af17b78c 100644 --- a/src/ui/mobile.c +++ b/src/ui/mobile.c | |||
@@ -734,7 +734,8 @@ void initPanels_Mobile(iWidget *panels, iWidget *parentWidget, | |||
734 | iLabelWidget * button = | 734 | iLabelWidget * button = |
735 | addChildFlags_Widget(topPanel, | 735 | addChildFlags_Widget(topPanel, |
736 | iClob(makePanelButton_(cstr_String(label), "panel.open")), | 736 | iClob(makePanelButton_(cstr_String(label), "panel.open")), |
737 | chevron_WidgetFlag | borderTop_WidgetFlag); | 737 | borderTop_WidgetFlag); |
738 | setChevron_LabelWidget(button, iTrue); | ||
738 | const iChar icon = toInt_String(string_Command(item->label, "icon")); | 739 | const iChar icon = toInt_String(string_Command(item->label, "icon")); |
739 | if (icon) { | 740 | if (icon) { |
740 | setIcon_LabelWidget(button, icon); | 741 | setIcon_LabelWidget(button, icon); |
diff --git a/src/ui/util.c b/src/ui/util.c index e3759f09..5f6d0331 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1436,7 +1436,7 @@ void resizeToLargestPage_Widget(iWidget *tabs) { | |||
1436 | // puts("... DONE WITH RESIZE TO LARGEST PAGE"); | 1436 | // puts("... DONE WITH RESIZE TO LARGEST PAGE"); |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) { | 1439 | static iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) { |
1440 | iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); | 1440 | iWidget *buttons = findChild_Widget(tabs, "tabs.buttons"); |
1441 | iForEach(ObjectList, i, buttons->children) { | 1441 | iForEach(ObjectList, i, buttons->children) { |
1442 | iAssert(isInstance_Object(i.object, &Class_LabelWidget)); | 1442 | iAssert(isInstance_Object(i.object, &Class_LabelWidget)); |
@@ -1448,6 +1448,19 @@ iLabelWidget *tabButtonForPage_Widget_(iWidget *tabs, const iWidget *page) { | |||
1448 | return NULL; | 1448 | return NULL; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | void addTabCloseButton_Widget(iWidget *tabs, const iWidget *page, const char *command) { | ||
1452 | iLabelWidget *tabButton = tabButtonForPage_Widget_(tabs, page); | ||
1453 | // setPadding1_Widget(as_Widget(tabButton), gap_UI / 8); | ||
1454 | iLabelWidget *close = addChildFlags_Widget( | ||
1455 | as_Widget(tabButton), | ||
1456 | iClob(new_LabelWidget(close_Icon, | ||
1457 | format_CStr("%s id:%s", command, cstr_String(id_Widget(page))))), | ||
1458 | moveToParentRightEdge_WidgetFlag | tight_WidgetFlag | frameless_WidgetFlag | | ||
1459 | hidden_WidgetFlag | visibleOnParentHover_WidgetFlag); | ||
1460 | updateSize_LabelWidget(close); | ||
1461 | printTree_Widget(tabs); | ||
1462 | } | ||
1463 | |||
1451 | void showTabPage_Widget(iWidget *tabs, const iWidget *page) { | 1464 | void showTabPage_Widget(iWidget *tabs, const iWidget *page) { |
1452 | if (!page) { | 1465 | if (!page) { |
1453 | return; | 1466 | return; |
diff --git a/src/ui/util.h b/src/ui/util.h index 94e5d8bd..cf96dfe4 100644 --- a/src/ui/util.h +++ b/src/ui/util.h | |||
@@ -272,6 +272,7 @@ void prependTabPage_Widget (iWidget *tabs, iWidget *page, const cha | |||
272 | iWidget * removeTabPage_Widget (iWidget *tabs, size_t index); /* returns the page */ | 272 | iWidget * removeTabPage_Widget (iWidget *tabs, size_t index); /* returns the page */ |
273 | void resizeToLargestPage_Widget (iWidget *tabs); | 273 | void resizeToLargestPage_Widget (iWidget *tabs); |
274 | void showTabPage_Widget (iWidget *tabs, const iWidget *page); | 274 | void showTabPage_Widget (iWidget *tabs, const iWidget *page); |
275 | void addTabCloseButton_Widget(iWidget *tabs, const iWidget *page, const char *command); | ||
275 | void setTabPageLabel_Widget (iWidget *tabs, const iAnyObject *page, const iString *label); | 276 | void setTabPageLabel_Widget (iWidget *tabs, const iAnyObject *page, const iString *label); |
276 | iWidget * tabPage_Widget (iWidget *tabs, size_t index); | 277 | iWidget * tabPage_Widget (iWidget *tabs, size_t index); |
277 | iLabelWidget * tabPageButton_Widget (iWidget *tabs, const iAnyObject *page); | 278 | iLabelWidget * tabPageButton_Widget (iWidget *tabs, const iAnyObject *page); |
diff --git a/src/ui/widget.c b/src/ui/widget.c index 4b8b1dc5..2cd1bf2b 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 == id_Window(window_Widget(d)) && | 1045 | ev->motion.windowID == id_Window(window_Widget(d)) && |
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)); |
@@ -1712,7 +1720,7 @@ size_t childIndex_Widget(const iWidget *d, const iAnyObject *child) { | |||
1712 | } | 1720 | } |
1713 | 1721 | ||
1714 | iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { | 1722 | iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { |
1715 | if (d->flags & hidden_WidgetFlag) { | 1723 | if (isHidden_Widget_(d)) { |
1716 | return NULL; | 1724 | return NULL; |
1717 | } | 1725 | } |
1718 | /* Check for on-top widgets first. */ | 1726 | /* Check for on-top widgets first. */ |
diff --git a/src/ui/widget.h b/src/ui/widget.h index 9243c00a..b119610a 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -109,7 +109,7 @@ enum iWidgetFlag { | |||
109 | #define extraPadding_WidgetFlag iBit64(49) | 109 | #define extraPadding_WidgetFlag iBit64(49) |
110 | #define borderBottom_WidgetFlag iBit64(50) | 110 | #define borderBottom_WidgetFlag iBit64(50) |
111 | #define horizontalOffset_WidgetFlag iBit64(51) /* default is vertical offset */ | 111 | #define horizontalOffset_WidgetFlag iBit64(51) /* default is vertical offset */ |
112 | #define chevron_WidgetFlag iBit64(52) | 112 | #define visibleOnParentHover_WidgetFlag iBit64(52) |
113 | #define drawBackgroundToBottom_WidgetFlag iBit64(53) | 113 | #define drawBackgroundToBottom_WidgetFlag iBit64(53) |
114 | #define dragged_WidgetFlag iBit64(54) | 114 | #define dragged_WidgetFlag iBit64(54) |
115 | #define hittable_WidgetFlag iBit64(55) | 115 | #define hittable_WidgetFlag iBit64(55) |