mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Split MakeNWidget to improve readability. (#12785)
Split MakeNWidget() into two stages, widget-creation and attribute-applying, to reduce function size and make it clearer.pull/12788/head
parent
22d70f9334
commit
b991a399ef
237
src/widget.cpp
237
src/widget.cpp
|
@ -2957,192 +2957,189 @@ bool NWidgetLeaf::ButtonHit(const Point &pt)
|
||||||
/* == Conversion code from NWidgetPart array to NWidgetBase* tree == */
|
/* == Conversion code from NWidgetPart array to NWidgetBase* tree == */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a single nested widget in \a *dest from its parts.
|
* Test if (an NWidgetPart) WidgetType is an attribute widget part type.
|
||||||
*
|
* @param tp WidgetType to test.
|
||||||
* Construct a NWidgetBase object from a #NWidget function, and apply all
|
* @return True iff WidgetType is an attribute widget.
|
||||||
* settings that follow it, until encountering a #EndContainer, another
|
|
||||||
* #NWidget, or the end of the parts array.
|
|
||||||
*
|
|
||||||
* @param nwid_begin Iterator to beginning of nested widget parts.
|
|
||||||
* @param nwid_end Iterator to ending of nested widget parts.
|
|
||||||
* @param dest Address of pointer to use for returning the composed widget.
|
|
||||||
* @param fill_dest Fill the composed widget with child widgets.
|
|
||||||
* @return Iterator to remaining nested widget parts.
|
|
||||||
*/
|
*/
|
||||||
static std::span<const NWidgetPart>::iterator MakeNWidget(std::span<const NWidgetPart>::iterator nwid_begin, std::span<const NWidgetPart>::iterator nwid_end, std::unique_ptr<NWidgetBase> &dest, bool *fill_dest)
|
static bool IsAttributeWidgetPartType(WidgetType tp)
|
||||||
{
|
{
|
||||||
dest = nullptr;
|
return tp > WPT_ATTRIBUTE_BEGIN && tp < WPT_ATTRIBUTE_END;
|
||||||
*fill_dest = false;
|
}
|
||||||
|
|
||||||
while (nwid_begin < nwid_end) {
|
|
||||||
switch (nwid_begin->type) {
|
|
||||||
case NWID_SPACER:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetSpacer>(0, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_HORIZONTAL:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetHorizontal>(nwid_begin->u.cont_flags);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_HORIZONTAL_LTR:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetHorizontalLTR>(nwid_begin->u.cont_flags);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WWT_PANEL:
|
|
||||||
case WWT_INSET:
|
|
||||||
case WWT_FRAME:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetBackground>(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_VERTICAL:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetVertical>(nwid_begin->u.cont_flags);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_MATRIX: {
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetMatrix>(nwid_begin->u.widget.colour, nwid_begin->u.widget.index);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WPT_FUNCTION: {
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = nwid_begin->u.func_ptr();
|
|
||||||
*fill_dest = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply an attribute NWidgetPart to an NWidget.
|
||||||
|
* @param nwid Attribute NWidgetPart
|
||||||
|
* @param dest NWidget to apply attribute to.
|
||||||
|
* @pre NWidgetPart must be an attribute NWidgetPart.
|
||||||
|
*/
|
||||||
|
static void ApplyNWidgetPartAttribute(const NWidgetPart &nwid, NWidgetBase *dest)
|
||||||
|
{
|
||||||
|
switch (nwid.type) {
|
||||||
case WPT_RESIZE: {
|
case WPT_RESIZE: {
|
||||||
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest.get());
|
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest);
|
||||||
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_RESIZE requires NWidgetResizeBase");
|
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_RESIZE requires NWidgetResizeBase");
|
||||||
assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0);
|
assert(nwid.u.xy.x >= 0 && nwid.u.xy.y >= 0);
|
||||||
nwrb->SetResize(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
|
nwrb->SetResize(nwid.u.xy.x, nwid.u.xy.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_MINSIZE: {
|
case WPT_MINSIZE: {
|
||||||
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest.get());
|
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest);
|
||||||
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_MINSIZE requires NWidgetResizeBase");
|
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_MINSIZE requires NWidgetResizeBase");
|
||||||
assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0);
|
assert(nwid.u.xy.x >= 0 && nwid.u.xy.y >= 0);
|
||||||
nwrb->SetMinimalSize(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
|
nwrb->SetMinimalSize(nwid.u.xy.x, nwid.u.xy.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_MINTEXTLINES: {
|
case WPT_MINTEXTLINES: {
|
||||||
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest.get());
|
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest);
|
||||||
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_MINTEXTLINES requires NWidgetResizeBase");
|
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_MINTEXTLINES requires NWidgetResizeBase");
|
||||||
assert(nwid_begin->u.text_lines.size >= FS_BEGIN && nwid_begin->u.text_lines.size < FS_END);
|
assert(nwid.u.text_lines.size >= FS_BEGIN && nwid.u.text_lines.size < FS_END);
|
||||||
nwrb->SetMinimalTextLines(nwid_begin->u.text_lines.lines, nwid_begin->u.text_lines.spacing, nwid_begin->u.text_lines.size);
|
nwrb->SetMinimalTextLines(nwid.u.text_lines.lines, nwid.u.text_lines.spacing, nwid.u.text_lines.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_TEXTSTYLE: {
|
case WPT_TEXTSTYLE: {
|
||||||
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest.get());
|
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest);
|
||||||
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_TEXTSTYLE requires NWidgetCore");
|
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_TEXTSTYLE requires NWidgetCore");
|
||||||
nwc->SetTextStyle(nwid_begin->u.text_style.colour, nwid_begin->u.text_style.size);
|
nwc->SetTextStyle(nwid.u.text_style.colour, nwid.u.text_style.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_ALIGNMENT: {
|
case WPT_ALIGNMENT: {
|
||||||
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest.get());
|
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest);
|
||||||
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_ALIGNMENT requires NWidgetCore");
|
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_ALIGNMENT requires NWidgetCore");
|
||||||
nwc->SetAlignment(nwid_begin->u.align.align);
|
nwc->SetAlignment(nwid.u.align.align);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_FILL: {
|
case WPT_FILL: {
|
||||||
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest.get());
|
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(dest);
|
||||||
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_FILL requires NWidgetResizeBase");
|
if (nwrb == nullptr) [[unlikely]] throw std::runtime_error("WPT_FILL requires NWidgetResizeBase");
|
||||||
nwrb->SetFill(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
|
nwrb->SetFill(nwid.u.xy.x, nwid.u.xy.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_DATATIP: {
|
case WPT_DATATIP: {
|
||||||
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest.get());
|
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest);
|
||||||
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_DATATIP requires NWidgetCore");
|
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_DATATIP requires NWidgetCore");
|
||||||
nwc->widget_data = nwid_begin->u.data_tip.data;
|
nwc->widget_data = nwid.u.data_tip.data;
|
||||||
nwc->tool_tip = nwid_begin->u.data_tip.tooltip;
|
nwc->tool_tip = nwid.u.data_tip.tooltip;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_PADDING:
|
case WPT_PADDING:
|
||||||
if (dest == nullptr) [[unlikely]] throw std::runtime_error("WPT_PADDING requires NWidgetBase");
|
if (dest == nullptr) [[unlikely]] throw std::runtime_error("WPT_PADDING requires NWidgetBase");
|
||||||
dest->SetPadding(nwid_begin->u.padding);
|
dest->SetPadding(nwid.u.padding);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WPT_PIPSPACE: {
|
case WPT_PIPSPACE: {
|
||||||
NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(dest.get());
|
NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(dest);
|
||||||
if (nwc != nullptr) nwc->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
|
if (nwc != nullptr) nwc->SetPIP(nwid.u.pip.pre, nwid.u.pip.inter, nwid.u.pip.post);
|
||||||
|
|
||||||
NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(dest.get());
|
NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(dest);
|
||||||
if (nwb != nullptr) nwb->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
|
if (nwb != nullptr) nwb->SetPIP(nwid.u.pip.pre, nwid.u.pip.inter, nwid.u.pip.post);
|
||||||
|
|
||||||
if (nwc == nullptr && nwb == nullptr) [[unlikely]] throw std::runtime_error("WPT_PIPSPACE requires NWidgetPIPContainer or NWidgetBackground");
|
if (nwc == nullptr && nwb == nullptr) [[unlikely]] throw std::runtime_error("WPT_PIPSPACE requires NWidgetPIPContainer or NWidgetBackground");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_PIPRATIO: {
|
case WPT_PIPRATIO: {
|
||||||
NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(dest.get());
|
NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(dest);
|
||||||
if (nwc != nullptr) nwc->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
|
if (nwc != nullptr) nwc->SetPIPRatio(nwid.u.pip.pre, nwid.u.pip.inter, nwid.u.pip.post);
|
||||||
|
|
||||||
NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(dest.get());
|
NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(dest);
|
||||||
if (nwb != nullptr) nwb->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
|
if (nwb != nullptr) nwb->SetPIPRatio(nwid.u.pip.pre, nwid.u.pip.inter, nwid.u.pip.post);
|
||||||
|
|
||||||
if (nwc == nullptr && nwb == nullptr) [[unlikely]] throw std::runtime_error("WPT_PIPRATIO requires NWidgetPIPContainer or NWidgetBackground");
|
if (nwc == nullptr && nwb == nullptr) [[unlikely]] throw std::runtime_error("WPT_PIPRATIO requires NWidgetPIPContainer or NWidgetBackground");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_SCROLLBAR: {
|
case WPT_SCROLLBAR: {
|
||||||
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest.get());
|
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(dest);
|
||||||
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_SCROLLBAR requires NWidgetCore");
|
if (nwc == nullptr) [[unlikely]] throw std::runtime_error("WPT_SCROLLBAR requires NWidgetCore");
|
||||||
nwc->scrollbar_index = nwid_begin->u.widget.index;
|
nwc->scrollbar_index = nwid.u.widget.index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WPT_ASPECT: {
|
case WPT_ASPECT: {
|
||||||
if (dest == nullptr) [[unlikely]] throw std::runtime_error("WPT_ASPECT requires NWidgetBase");
|
if (dest == nullptr) [[unlikely]] throw std::runtime_error("WPT_ASPECT requires NWidgetBase");
|
||||||
dest->aspect_ratio = nwid_begin->u.aspect.ratio;
|
dest->aspect_ratio = nwid.u.aspect.ratio;
|
||||||
dest->aspect_flags = nwid_begin->u.aspect.flags;
|
dest->aspect_flags = nwid.u.aspect.flags;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WPT_ENDCONTAINER:
|
|
||||||
return nwid_begin;
|
|
||||||
|
|
||||||
case NWID_VIEWPORT:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetViewport>(nwid_begin->u.widget.index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_HSCROLLBAR:
|
|
||||||
case NWID_VSCROLLBAR:
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetScrollbar>(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NWID_SELECTION: {
|
|
||||||
if (dest != nullptr) return nwid_begin;
|
|
||||||
dest = std::make_unique<NWidgetStacked>(nwid_begin->u.widget.index);
|
|
||||||
*fill_dest = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (dest != nullptr) return nwid_begin;
|
NOT_REACHED();
|
||||||
assert((nwid_begin->type & WWT_MASK) < WWT_LAST || (nwid_begin->type & WWT_MASK) == NWID_BUTTON_DROPDOWN);
|
|
||||||
dest = std::make_unique<NWidgetLeaf>(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
nwid_begin++;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make NWidget from an NWidgetPart.
|
||||||
|
* @param nwid NWidgetPart.
|
||||||
|
* @pre NWidgetPart must not be an attribute NWidgetPart nor WPT_ENDCONTAINER.
|
||||||
|
* @return Pointer to created NWidget.
|
||||||
|
*/
|
||||||
|
static std::unique_ptr<NWidgetBase> MakeNWidget(const NWidgetPart &nwid)
|
||||||
|
{
|
||||||
|
assert(!IsAttributeWidgetPartType(nwid.type));
|
||||||
|
assert(nwid.type != WPT_ENDCONTAINER);
|
||||||
|
|
||||||
|
switch (nwid.type) {
|
||||||
|
case NWID_SPACER: return std::make_unique<NWidgetSpacer>(0, 0);
|
||||||
|
|
||||||
|
case WWT_PANEL: [[fallthrough]];
|
||||||
|
case WWT_INSET: [[fallthrough]];
|
||||||
|
case WWT_FRAME: return std::make_unique<NWidgetBackground>(nwid.type, nwid.u.widget.colour, nwid.u.widget.index);
|
||||||
|
|
||||||
|
case NWID_HORIZONTAL: return std::make_unique<NWidgetHorizontal>(nwid.u.cont_flags);
|
||||||
|
case NWID_HORIZONTAL_LTR: return std::make_unique<NWidgetHorizontalLTR>(nwid.u.cont_flags);
|
||||||
|
case NWID_VERTICAL: return std::make_unique<NWidgetVertical>(nwid.u.cont_flags);
|
||||||
|
case NWID_SELECTION: return std::make_unique<NWidgetStacked>(nwid.u.widget.index);
|
||||||
|
case NWID_MATRIX: return std::make_unique<NWidgetMatrix>(nwid.u.widget.colour, nwid.u.widget.index);
|
||||||
|
case NWID_VIEWPORT: return std::make_unique<NWidgetViewport>(nwid.u.widget.index);
|
||||||
|
|
||||||
|
case NWID_HSCROLLBAR: [[fallthrough]];
|
||||||
|
case NWID_VSCROLLBAR: return std::make_unique<NWidgetScrollbar>(nwid.type, nwid.u.widget.colour, nwid.u.widget.index);
|
||||||
|
|
||||||
|
case WPT_FUNCTION: return nwid.u.func_ptr();
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert((nwid.type & WWT_MASK) < WWT_LAST || (nwid.type & WWT_MASK) == NWID_BUTTON_DROPDOWN);
|
||||||
|
return std::make_unique<NWidgetLeaf>(nwid.type, nwid.u.widget.colour, nwid.u.widget.index, 0x0, STR_NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a single nested widget in \a *dest from its parts.
|
||||||
|
*
|
||||||
|
* Construct a NWidgetBase object from a #NWidget function, and apply all
|
||||||
|
* attributes that follow it, until encountering a #EndContainer, another
|
||||||
|
* #NWidget, or the end of the parts array.
|
||||||
|
*
|
||||||
|
* @param nwid_begin Iterator to beginning of nested widget parts.
|
||||||
|
* @param nwid_end Iterator to ending of nested widget parts.
|
||||||
|
* @param[out] dest Address of pointer to use for returning the composed widget.
|
||||||
|
* @param[out] fill_dest Fill the composed widget with child widgets.
|
||||||
|
* @return Iterator to remaining nested widget parts.
|
||||||
|
*/
|
||||||
|
static std::span<const NWidgetPart>::iterator MakeNWidget(std::span<const NWidgetPart>::iterator nwid_begin, std::span<const NWidgetPart>::iterator nwid_end, std::unique_ptr<NWidgetBase> &dest, bool &fill_dest)
|
||||||
|
{
|
||||||
|
dest = nullptr;
|
||||||
|
|
||||||
|
if (IsAttributeWidgetPartType(nwid_begin->type)) [[unlikely]] throw std::runtime_error("Expected non-attribute NWidgetPart type");
|
||||||
|
if (nwid_begin->type == WPT_ENDCONTAINER) return nwid_begin;
|
||||||
|
|
||||||
|
fill_dest = IsContainerWidgetType(nwid_begin->type);
|
||||||
|
dest = MakeNWidget(*nwid_begin);
|
||||||
|
if (dest == nullptr) return nwid_begin;
|
||||||
|
|
||||||
|
++nwid_begin;
|
||||||
|
|
||||||
|
/* Once a widget is created, we're now looking for attributes. */
|
||||||
|
while (nwid_begin != nwid_end && IsAttributeWidgetPartType(nwid_begin->type)) {
|
||||||
|
ApplyNWidgetPartAttribute(*nwid_begin, dest.get());
|
||||||
|
++nwid_begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nwid_begin;
|
return nwid_begin;
|
||||||
|
@ -3174,10 +3171,10 @@ static std::span<const NWidgetPart>::iterator MakeWidgetTree(std::span<const NWi
|
||||||
NWidgetBackground *nwid_parent = dynamic_cast<NWidgetBackground *>(parent.get());
|
NWidgetBackground *nwid_parent = dynamic_cast<NWidgetBackground *>(parent.get());
|
||||||
assert(parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr));
|
assert(parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr));
|
||||||
|
|
||||||
for (;;) {
|
while (nwid_begin != nwid_end) {
|
||||||
std::unique_ptr<NWidgetBase> sub_widget = nullptr;
|
std::unique_ptr<NWidgetBase> sub_widget = nullptr;
|
||||||
bool fill_sub = false;
|
bool fill_sub = false;
|
||||||
nwid_begin = MakeNWidget(nwid_begin, nwid_end, sub_widget, &fill_sub);
|
nwid_begin = MakeNWidget(nwid_begin, nwid_end, sub_widget, fill_sub);
|
||||||
|
|
||||||
/* Break out of loop when end reached */
|
/* Break out of loop when end reached */
|
||||||
if (sub_widget == nullptr) break;
|
if (sub_widget == nullptr) break;
|
||||||
|
|
|
@ -87,6 +87,7 @@ enum WidgetType {
|
||||||
NWID_CUSTOM, ///< General Custom widget.
|
NWID_CUSTOM, ///< General Custom widget.
|
||||||
|
|
||||||
/* Nested widget part types. */
|
/* Nested widget part types. */
|
||||||
|
WPT_ATTRIBUTE_BEGIN, ///< Begin marker for attribute NWidgetPart types.
|
||||||
WPT_RESIZE, ///< Widget part for specifying resizing.
|
WPT_RESIZE, ///< Widget part for specifying resizing.
|
||||||
WPT_MINSIZE, ///< Widget part for specifying minimal size.
|
WPT_MINSIZE, ///< Widget part for specifying minimal size.
|
||||||
WPT_MINTEXTLINES, ///< Widget part for specifying minimal number of lines of text.
|
WPT_MINTEXTLINES, ///< Widget part for specifying minimal number of lines of text.
|
||||||
|
@ -97,10 +98,12 @@ enum WidgetType {
|
||||||
WPT_PIPRATIO, ///< Widget part for specifying pre/inter/post ratio for containers.
|
WPT_PIPRATIO, ///< Widget part for specifying pre/inter/post ratio for containers.
|
||||||
WPT_TEXTSTYLE, ///< Widget part for specifying text colour.
|
WPT_TEXTSTYLE, ///< Widget part for specifying text colour.
|
||||||
WPT_ALIGNMENT, ///< Widget part for specifying text/image alignment.
|
WPT_ALIGNMENT, ///< Widget part for specifying text/image alignment.
|
||||||
WPT_ENDCONTAINER, ///< Widget part to denote end of a container.
|
|
||||||
WPT_FUNCTION, ///< Widget part for calling a user function.
|
|
||||||
WPT_SCROLLBAR, ///< Widget part for attaching a scrollbar.
|
WPT_SCROLLBAR, ///< Widget part for attaching a scrollbar.
|
||||||
WPT_ASPECT, ///< Widget part for sepcifying aspect ratio.
|
WPT_ASPECT, ///< Widget part for sepcifying aspect ratio.
|
||||||
|
WPT_ATTRIBUTE_END, ///< End marker for attribute NWidgetPart types.
|
||||||
|
|
||||||
|
WPT_FUNCTION, ///< Widget part for calling a user function.
|
||||||
|
WPT_ENDCONTAINER, ///< Widget part to denote end of a container.
|
||||||
|
|
||||||
/* Pushable window widget types. */
|
/* Pushable window widget types. */
|
||||||
WWT_MASK = 0x7F,
|
WWT_MASK = 0x7F,
|
||||||
|
|
Loading…
Reference in New Issue