|
@@ -216,13 +216,14 @@ FORCEINLINE void NWidgetBase::StoreSizeP
|
|
|
}
|
|
|
this->current_x = given_width;
|
|
|
this->current_y = given_height;
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Base class for a resizable nested widget.
|
|
|
/**
|
|
|
* Base class for a resizable nested widget.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetResizeBase : public NWidgetBase {
|
|
|
public:
|
|
|
NWidgetResizeBase(WidgetType tp, uint fill_x, uint fill_y);
|
|
|
|
|
|
void SetMinimalSize(uint min_x, uint min_y);
|
|
@@ -254,13 +255,14 @@ enum NWidgetDisplay {
|
|
|
ND_SHADE_GREY = 1 << NDB_SHADE_GREY, ///< Bit value of the 'shade to grey' flag.
|
|
|
ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED, ///< Bit value of the 'dimmed colours' flag.
|
|
|
ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE, ///< Bit value of the 'dropdown active' flag.
|
|
|
};
|
|
|
DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay)
|
|
|
|
|
|
/** Base class for a 'real' widget.
|
|
|
/**
|
|
|
* Base class for a 'real' widget.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetCore : public NWidgetResizeBase {
|
|
|
public:
|
|
|
NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint16 widget_data, StringID tool_tip);
|
|
|
|
|
|
void SetIndex(int index);
|
|
@@ -311,13 +313,14 @@ inline void NWidgetCore::SetDisabled(boo
|
|
|
inline bool NWidgetCore::IsDisabled() const
|
|
|
{
|
|
|
return HasBit(this->disp_flags, NDB_DISABLED);
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Baseclass for container widgets.
|
|
|
/**
|
|
|
* Baseclass for container widgets.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetContainer : public NWidgetBase {
|
|
|
public:
|
|
|
NWidgetContainer(WidgetType tp);
|
|
|
~NWidgetContainer();
|
|
|
|
|
@@ -340,13 +343,14 @@ enum StackedZeroSizePlanes {
|
|
|
SZSP_HORIZONTAL, ///< Display plane with zero size vertically, and filling and resizing horizontally.
|
|
|
SZSP_NONE, ///< Display plane with zero size in both directions (none filling and resizing).
|
|
|
|
|
|
SZSP_BEGIN = SZSP_VERTICAL, ///< First zero-size plane.
|
|
|
};
|
|
|
|
|
|
/** Stacked widgets, widgets all occupying the same space in the window.
|
|
|
/**
|
|
|
* Stacked widgets, widgets all occupying the same space in the window.
|
|
|
* #NWID_SELECTION allows for selecting one of several panels (planes) to tbe displayed. All planes must have the same size.
|
|
|
* Since all planes are also initialized, switching between different planes can be done while the window is displayed.
|
|
|
*
|
|
|
* There are also a number of special planes (defined in #StackedZeroSizePlanes) that have zero size in one direction (and are stretchable in
|
|
|
* the other direction) or have zero size in both directions. They are used to make all child planes of the widget disappear.
|
|
|
* Unlike switching between the regular display planes (that all have the same size), switching from or to one of the zero-sized planes means that
|
|
@@ -394,43 +398,47 @@ protected:
|
|
|
NWidContainerFlags flags; ///< Flags of the container.
|
|
|
uint8 pip_pre; ///< Amount of space before first widget.
|
|
|
uint8 pip_inter; ///< Amount of space between widgets.
|
|
|
uint8 pip_post; ///< Amount of space after last widget.
|
|
|
};
|
|
|
|
|
|
/** Horizontal container.
|
|
|
/**
|
|
|
* Horizontal container.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetHorizontal : public NWidgetPIPContainer {
|
|
|
public:
|
|
|
NWidgetHorizontal(NWidContainerFlags flags = NC_NONE);
|
|
|
|
|
|
void SetupSmallestSize(Window *w, bool init_array);
|
|
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
|
|
|
};
|
|
|
|
|
|
/** Horizontal container that doesn't change the direction of the widgets for RTL languages.
|
|
|
/**
|
|
|
* Horizontal container that doesn't change the direction of the widgets for RTL languages.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetHorizontalLTR : public NWidgetHorizontal {
|
|
|
public:
|
|
|
NWidgetHorizontalLTR(NWidContainerFlags flags = NC_NONE);
|
|
|
|
|
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
|
|
|
};
|
|
|
|
|
|
/** Vertical container.
|
|
|
/**
|
|
|
* Vertical container.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetVertical : public NWidgetPIPContainer {
|
|
|
public:
|
|
|
NWidgetVertical(NWidContainerFlags flags = NC_NONE);
|
|
|
|
|
|
void SetupSmallestSize(Window *w, bool init_array);
|
|
|
void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl);
|
|
|
};
|
|
|
|
|
|
|
|
|
/** Spacer widget.
|
|
|
/**
|
|
|
* Spacer widget.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetSpacer : public NWidgetResizeBase {
|
|
|
public:
|
|
|
NWidgetSpacer(int length, int height);
|
|
|
|
|
|
void SetupSmallestSize(Window *w, bool init_array);
|
|
@@ -438,13 +446,14 @@ public:
|
|
|
|
|
|
/* virtual */ void Draw(const Window *w);
|
|
|
/* virtual */ void SetDirty(const Window *w) const;
|
|
|
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
|
|
|
};
|
|
|
|
|
|
/** Nested widget with a child.
|
|
|
/**
|
|
|
* Nested widget with a child.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetBackground : public NWidgetCore {
|
|
|
public:
|
|
|
NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = NULL);
|
|
|
~NWidgetBackground();
|
|
|
|
|
@@ -482,13 +491,14 @@ public:
|
|
|
/* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const;
|
|
|
|
|
|
void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom);
|
|
|
void UpdateViewportCoordinates(Window *w);
|
|
|
};
|
|
|
|
|
|
/** Leaf widget.
|
|
|
/**
|
|
|
* Leaf widget.
|
|
|
* @ingroup NestedWidgets */
|
|
|
class NWidgetLeaf : public NWidgetCore {
|
|
|
public:
|
|
|
NWidgetLeaf(WidgetType tp, Colours colour, int index, uint16 data, StringID tip);
|
|
|
|
|
|
/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
|
|
@@ -566,54 +576,61 @@ static FORCEINLINE uint ComputeMaxSize(u
|
|
|
* .
|
|
|
* In both cases, the background widget \b MUST end with a #EndContainer widget part.
|
|
|
*
|
|
|
* @see NestedWidgets
|
|
|
*/
|
|
|
|
|
|
/** Widget part for storing data and tooltip information.
|
|
|
/**
|
|
|
* Widget part for storing data and tooltip information.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPartDataTip {
|
|
|
uint16 data; ///< Data value of the widget.
|
|
|
StringID tooltip; ///< Tooltip of the widget.
|
|
|
};
|
|
|
|
|
|
/** Widget part for storing basic widget information.
|
|
|
/**
|
|
|
* Widget part for storing basic widget information.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPartWidget {
|
|
|
Colours colour; ///< Widget colour.
|
|
|
int16 index; ///< Widget index in the widget array.
|
|
|
};
|
|
|
|
|
|
/** Widget part for storing padding.
|
|
|
/**
|
|
|
* Widget part for storing padding.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPartPaddings {
|
|
|
uint8 top, right, bottom, left; ///< Paddings for all directions.
|
|
|
};
|
|
|
|
|
|
/** Widget part for storing pre/inter/post spaces.
|
|
|
/**
|
|
|
* Widget part for storing pre/inter/post spaces.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPartPIP {
|
|
|
uint8 pre, inter, post; ///< Amount of space before/between/after child widgets.
|
|
|
};
|
|
|
|
|
|
/** Widget part for storing minimal text line data.
|
|
|
/**
|
|
|
* Widget part for storing minimal text line data.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPartTextLines {
|
|
|
uint8 lines; ///< Number of text lines.
|
|
|
uint8 spacing; ///< Extra spacing around lines.
|
|
|
FontSize size; ///< Font size of text lines.
|
|
|
};
|
|
|
|
|
|
/** Pointer to function returning a nested widget.
|
|
|
/**
|
|
|
* Pointer to function returning a nested widget.
|
|
|
* @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget.
|
|
|
* @return Nested widget (tree).
|
|
|
* @post \c *biggest_index must contain the value of the biggest index in the returned tree.
|
|
|
*/
|
|
|
typedef NWidgetBase *NWidgetFunctionType(int *biggest_index);
|
|
|
|
|
|
/** Partial widget specification to allow NWidgets to be written nested.
|
|
|
/**
|
|
|
* Partial widget specification to allow NWidgets to be written nested.
|
|
|
* @ingroup NestedWidgetParts */
|
|
|
struct NWidgetPart {
|
|
|
WidgetType type; ///< Type of the part. @see NWidgetPartType.
|
|
|
union {
|
|
|
Point xy; ///< Part with an x/y size.
|
|
|
NWidgetPartDataTip data_tip; ///< Part with a data/tooltip.
|
|
@@ -707,13 +724,14 @@ static inline NWidgetPart EndContainer()
|
|
|
|
|
|
part.type = WPT_ENDCONTAINER;
|
|
|
|
|
|
return part;
|
|
|
}
|
|
|
|
|
|
/** Widget part function for setting the data and tooltip.
|
|
|
/**
|
|
|
* Widget part function for setting the data and tooltip.
|
|
|
* @param data Data of the widget.
|
|
|
* @param tip Tooltip of the widget.
|
|
|
* @ingroup NestedWidgetParts
|
|
|
*/
|
|
|
static inline NWidgetPart SetDataTip(uint16 data, StringID tip)
|
|
|
{
|