Layout logic moved from core into widgets.
This commit is contained in:
parent
7cd7388607
commit
93b912d932
9 changed files with 28 additions and 31 deletions
|
|
@ -136,7 +136,6 @@ typedef enum {
|
||||||
// Flags encode static properties checked by the framework.
|
// Flags encode static properties checked by the framework.
|
||||||
// Widgets set these in their WidgetClassT definition.
|
// Widgets set these in their WidgetClassT definition.
|
||||||
#define WCLASS_FOCUSABLE 0x00000001
|
#define WCLASS_FOCUSABLE 0x00000001
|
||||||
#define WCLASS_BOX_CONTAINER 0x00000002
|
|
||||||
#define WCLASS_HORIZ_CONTAINER 0x00000004
|
#define WCLASS_HORIZ_CONTAINER 0x00000004
|
||||||
#define WCLASS_PAINTS_CHILDREN 0x00000008
|
#define WCLASS_PAINTS_CHILDREN 0x00000008
|
||||||
#define WCLASS_NO_HIT_RECURSE 0x00000010
|
#define WCLASS_NO_HIT_RECURSE 0x00000010
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ WidgetT *widgetFindByAccel(WidgetT *root, char key);
|
||||||
int32_t widgetCountVisibleChildren(const WidgetT *w);
|
int32_t widgetCountVisibleChildren(const WidgetT *w);
|
||||||
int32_t widgetFrameBorderWidth(const WidgetT *w);
|
int32_t widgetFrameBorderWidth(const WidgetT *w);
|
||||||
bool widgetIsFocusable(int32_t type);
|
bool widgetIsFocusable(int32_t type);
|
||||||
bool widgetIsBoxContainer(int32_t type);
|
|
||||||
bool widgetIsHorizContainer(int32_t type);
|
bool widgetIsHorizContainer(int32_t type);
|
||||||
int32_t multiClickDetect(int32_t vx, int32_t vy);
|
int32_t multiClickDetect(int32_t vx, int32_t vy);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
// widgetIsHorizContainer
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,7 @@ void widgetCalcMinSizeBox(WidgetT *w, const BitmapFontT *font) {
|
||||||
// size calculation. Hints only increase the minimum, never shrink it.
|
// size calculation. Hints only increase the minimum, never shrink it.
|
||||||
|
|
||||||
void widgetCalcMinSizeTree(WidgetT *w, const BitmapFontT *font) {
|
void widgetCalcMinSizeTree(WidgetT *w, const BitmapFontT *font) {
|
||||||
if (widgetIsBoxContainer(w->type)) {
|
if (wclsHas(w, WGT_METHOD_CALC_MIN_SIZE)) {
|
||||||
widgetCalcMinSizeBox(w, font);
|
|
||||||
} else if (wclsHas(w, WGT_METHOD_CALC_MIN_SIZE)) {
|
|
||||||
wclsCalcMinSize(w, font);
|
wclsCalcMinSize(w, font);
|
||||||
} else {
|
} else {
|
||||||
w->calcMinW = 0;
|
w->calcMinW = 0;
|
||||||
|
|
@ -357,9 +355,7 @@ void widgetLayoutBox(WidgetT *w, const BitmapFontT *font) {
|
||||||
// do nothing (they have no children to lay out).
|
// do nothing (they have no children to lay out).
|
||||||
|
|
||||||
void widgetLayoutChildren(WidgetT *w, const BitmapFontT *font) {
|
void widgetLayoutChildren(WidgetT *w, const BitmapFontT *font) {
|
||||||
if (widgetIsBoxContainer(w->type)) {
|
if (wclsHas(w, WGT_METHOD_LAYOUT)) {
|
||||||
widgetLayoutBox(w, font);
|
|
||||||
} else if (wclsHas(w, WGT_METHOD_LAYOUT)) {
|
|
||||||
wclsLayout(w, font);
|
wclsLayout(w, font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,21 +141,31 @@ void widgetFrameDestroy(WidgetT *w) {
|
||||||
|
|
||||||
static const WidgetClassT sClassVBox = {
|
static const WidgetClassT sClassVBox = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.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 = {
|
static const WidgetClassT sClassHBox = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.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 = {
|
static const WidgetClassT sClassFrame = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.version = WGT_CLASS_VERSION,
|
||||||
.flags = WCLASS_BOX_CONTAINER | WCLASS_FOCUS_FORWARD,
|
.flags = WCLASS_FOCUS_FORWARD,
|
||||||
.handlers = {
|
.handlers = {
|
||||||
[WGT_METHOD_PAINT] = (void *)widgetFramePaint,
|
[WGT_METHOD_PAINT] = (void *)widgetFramePaint,
|
||||||
[WGT_METHOD_DESTROY] = (void *)widgetFrameDestroy,
|
[WGT_METHOD_DESTROY] = (void *)widgetFrameDestroy,
|
||||||
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetFrameGetLayoutMetrics,
|
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetFrameGetLayoutMetrics,
|
||||||
|
[WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox,
|
||||||
|
[WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,9 +310,11 @@ void widgetRadioSetText(WidgetT *w, const char *text) {
|
||||||
|
|
||||||
static const WidgetClassT sClassRadioGroup = {
|
static const WidgetClassT sClassRadioGroup = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.version = WGT_CLASS_VERSION,
|
||||||
.flags = WCLASS_BOX_CONTAINER,
|
.flags = 0,
|
||||||
.handlers = {
|
.handlers = {
|
||||||
[WGT_METHOD_DESTROY] = (void *)widgetRadioGroupDestroy,
|
[WGT_METHOD_DESTROY] = (void *)widgetRadioGroupDestroy,
|
||||||
|
[WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox,
|
||||||
|
[WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,12 @@ void widgetStatusBarGetLayoutMetrics(const WidgetT *w, const BitmapFontT *font,
|
||||||
|
|
||||||
static const WidgetClassT sClassStatusBar = {
|
static const WidgetClassT sClassStatusBar = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.version = WGT_CLASS_VERSION,
|
||||||
.flags = WCLASS_BOX_CONTAINER | WCLASS_HORIZ_CONTAINER,
|
.flags = WCLASS_HORIZ_CONTAINER,
|
||||||
.handlers = {
|
.handlers = {
|
||||||
[WGT_METHOD_PAINT] = (void *)widgetStatusBarPaint,
|
[WGT_METHOD_PAINT] = (void *)widgetStatusBarPaint,
|
||||||
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetStatusBarGetLayoutMetrics,
|
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetStatusBarGetLayoutMetrics,
|
||||||
|
[WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox,
|
||||||
|
[WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -596,10 +596,12 @@ static const WidgetClassT sClassTabControl = {
|
||||||
|
|
||||||
static const WidgetClassT sClassTabPage = {
|
static const WidgetClassT sClassTabPage = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.version = WGT_CLASS_VERSION,
|
||||||
.flags = WCLASS_BOX_CONTAINER | WCLASS_ACCEL_WHEN_HIDDEN,
|
.flags = WCLASS_ACCEL_WHEN_HIDDEN,
|
||||||
.handlers = {
|
.handlers = {
|
||||||
[WGT_METHOD_ON_ACCEL_ACTIVATE] = (void *)widgetTabPageAccelActivate,
|
[WGT_METHOD_ON_ACCEL_ACTIVATE] = (void *)widgetTabPageAccelActivate,
|
||||||
[WGT_METHOD_DESTROY] = (void *)widgetTabPageDestroy,
|
[WGT_METHOD_DESTROY] = (void *)widgetTabPageDestroy,
|
||||||
|
[WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox,
|
||||||
|
[WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,12 @@ void widgetToolbarGetLayoutMetrics(const WidgetT *w, const BitmapFontT *font, in
|
||||||
|
|
||||||
static const WidgetClassT sClassToolbar = {
|
static const WidgetClassT sClassToolbar = {
|
||||||
.version = WGT_CLASS_VERSION,
|
.version = WGT_CLASS_VERSION,
|
||||||
.flags = WCLASS_BOX_CONTAINER | WCLASS_HORIZ_CONTAINER,
|
.flags = WCLASS_HORIZ_CONTAINER,
|
||||||
.handlers = {
|
.handlers = {
|
||||||
[WGT_METHOD_PAINT] = (void *)widgetToolbarPaint,
|
[WGT_METHOD_PAINT] = (void *)widgetToolbarPaint,
|
||||||
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetToolbarGetLayoutMetrics,
|
[WGT_METHOD_GET_LAYOUT_METRICS] = (void *)widgetToolbarGetLayoutMetrics,
|
||||||
|
[WGT_METHOD_CALC_MIN_SIZE] = (void *)widgetCalcMinSizeBox,
|
||||||
|
[WGT_METHOD_LAYOUT] = (void *)widgetLayoutBox,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue