diff --git a/core/dvxWidget.h b/core/dvxWidget.h index 73c2a93..bd8b7d1 100644 --- a/core/dvxWidget.h +++ b/core/dvxWidget.h @@ -136,7 +136,6 @@ typedef enum { // Flags encode static properties checked by the framework. // Widgets set these in their WidgetClassT definition. #define WCLASS_FOCUSABLE 0x00000001 -#define WCLASS_BOX_CONTAINER 0x00000002 #define WCLASS_HORIZ_CONTAINER 0x00000004 #define WCLASS_PAINTS_CHILDREN 0x00000008 #define WCLASS_NO_HIT_RECURSE 0x00000010 diff --git a/core/dvxWidgetPlugin.h b/core/dvxWidgetPlugin.h index 4e434a3..16c9e46 100644 --- a/core/dvxWidgetPlugin.h +++ b/core/dvxWidgetPlugin.h @@ -128,7 +128,6 @@ WidgetT *widgetFindByAccel(WidgetT *root, char key); int32_t widgetCountVisibleChildren(const WidgetT *w); int32_t widgetFrameBorderWidth(const WidgetT *w); bool widgetIsFocusable(int32_t type); -bool widgetIsBoxContainer(int32_t type); bool widgetIsHorizContainer(int32_t type); int32_t multiClickDetect(int32_t vx, int32_t vy); diff --git a/core/widgetCore.c b/core/widgetCore.c index 9e675de..b9dae6c 100644 --- a/core/widgetCore.c +++ b/core/widgetCore.c @@ -527,21 +527,6 @@ bool widgetIsFocusable(int32_t type) { } -// ============================================================ -// widgetIsBoxContainer -// ============================================================ -// -// Returns true for widget types that use the generic box layout. - -bool widgetIsBoxContainer(int32_t type) { - if (type < 0 || type >= arrlen(widgetClassTable) || !widgetClassTable[type]) { - return false; - } - - return (widgetClassTable[type]->flags & WCLASS_BOX_CONTAINER) != 0; -} - - // ============================================================ // widgetIsHorizContainer // ============================================================ diff --git a/core/widgetLayout.c b/core/widgetLayout.c index 070b32b..b0470d3 100644 --- a/core/widgetLayout.c +++ b/core/widgetLayout.c @@ -128,9 +128,7 @@ void widgetCalcMinSizeBox(WidgetT *w, const BitmapFontT *font) { // size calculation. Hints only increase the minimum, never shrink it. void widgetCalcMinSizeTree(WidgetT *w, const BitmapFontT *font) { - if (widgetIsBoxContainer(w->type)) { - widgetCalcMinSizeBox(w, font); - } else if (wclsHas(w, WGT_METHOD_CALC_MIN_SIZE)) { + if (wclsHas(w, WGT_METHOD_CALC_MIN_SIZE)) { wclsCalcMinSize(w, font); } else { w->calcMinW = 0; @@ -357,9 +355,7 @@ void widgetLayoutBox(WidgetT *w, const BitmapFontT *font) { // do nothing (they have no children to lay out). void widgetLayoutChildren(WidgetT *w, const BitmapFontT *font) { - if (widgetIsBoxContainer(w->type)) { - widgetLayoutBox(w, font); - } else if (wclsHas(w, WGT_METHOD_LAYOUT)) { + if (wclsHas(w, WGT_METHOD_LAYOUT)) { wclsLayout(w, font); } } diff --git a/widgets/box/widgetBox.c b/widgets/box/widgetBox.c index bef74f0..5e5a384 100644 --- a/widgets/box/widgetBox.c +++ b/widgets/box/widgetBox.c @@ -141,21 +141,31 @@ void widgetFrameDestroy(WidgetT *w) { static const WidgetClassT sClassVBox = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER, + .flags = 0, + .handlers = { + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, + } }; static const WidgetClassT sClassHBox = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER | WCLASS_HORIZ_CONTAINER, + .flags = WCLASS_HORIZ_CONTAINER, + .handlers = { + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, + } }; static const WidgetClassT sClassFrame = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER | WCLASS_FOCUS_FORWARD, + .flags = WCLASS_FOCUS_FORWARD, .handlers = { [WGT_METHOD_PAINT] = (void *)widgetFramePaint, [WGT_METHOD_DESTROY] = (void *)widgetFrameDestroy, [WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetFrameGetLayoutMetrics, + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, } }; diff --git a/widgets/radio/widgetRadio.c b/widgets/radio/widgetRadio.c index fe1a7ba..c095a98 100644 --- a/widgets/radio/widgetRadio.c +++ b/widgets/radio/widgetRadio.c @@ -310,9 +310,11 @@ void widgetRadioSetText(WidgetT *w, const char *text) { static const WidgetClassT sClassRadioGroup = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER, + .flags = 0, .handlers = { - [WGT_METHOD_DESTROY] = (void *)widgetRadioGroupDestroy, + [WGT_METHOD_DESTROY] = (void *)widgetRadioGroupDestroy, + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, } }; diff --git a/widgets/statusBar/widgetStatusBar.c b/widgets/statusBar/widgetStatusBar.c index c17847d..a15b5d2 100644 --- a/widgets/statusBar/widgetStatusBar.c +++ b/widgets/statusBar/widgetStatusBar.c @@ -72,10 +72,12 @@ void widgetStatusBarGetLayoutMetrics(const WidgetT *w, const BitmapFontT *font, static const WidgetClassT sClassStatusBar = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER | WCLASS_HORIZ_CONTAINER, + .flags = WCLASS_HORIZ_CONTAINER, .handlers = { [WGT_METHOD_PAINT] = (void *)widgetStatusBarPaint, [WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetStatusBarGetLayoutMetrics, + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, } }; diff --git a/widgets/tabControl/widgetTabControl.c b/widgets/tabControl/widgetTabControl.c index e913505..d71023f 100644 --- a/widgets/tabControl/widgetTabControl.c +++ b/widgets/tabControl/widgetTabControl.c @@ -596,10 +596,12 @@ static const WidgetClassT sClassTabControl = { static const WidgetClassT sClassTabPage = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER | WCLASS_ACCEL_WHEN_HIDDEN, + .flags = WCLASS_ACCEL_WHEN_HIDDEN, .handlers = { [WGT_METHOD_ON_ACCEL_ACTIVATE] = (void *)widgetTabPageAccelActivate, [WGT_METHOD_DESTROY] = (void *)widgetTabPageDestroy, + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, } }; diff --git a/widgets/toolbar/widgetToolbar.c b/widgets/toolbar/widgetToolbar.c index 9612243..9b82fab 100644 --- a/widgets/toolbar/widgetToolbar.c +++ b/widgets/toolbar/widgetToolbar.c @@ -64,10 +64,12 @@ void widgetToolbarGetLayoutMetrics(const WidgetT *w, const BitmapFontT *font, in static const WidgetClassT sClassToolbar = { .version = WGT_CLASS_VERSION, - .flags = WCLASS_BOX_CONTAINER | WCLASS_HORIZ_CONTAINER, + .flags = WCLASS_HORIZ_CONTAINER, .handlers = { [WGT_METHOD_PAINT] = (void *)widgetToolbarPaint, [WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetToolbarGetLayoutMetrics, + [WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox, + [WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox, } };