mirror of https://github.com/OpenTTD/OpenTTD
(svn r15861) -Codechange: Add NWID_HORIZONTAL_LTR that forces the ordering from left-to-right.
parent
44351cdc57
commit
d17083e429
|
@ -960,6 +960,21 @@ void NWidgetHorizontal::StoreWidgets(Widget *widgets, int length, bool left_movi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NWidgetHorizontalLTR::NWidgetHorizontalLTR() : NWidgetHorizontal()
|
||||||
|
{
|
||||||
|
this->type = NWID_HORIZONTAL_LTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NWidgetHorizontalLTR::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
|
||||||
|
{
|
||||||
|
NWidgetHorizontal::AssignMinimalPosition(x, y, given_width, given_height, allow_resize_x, allow_resize_y, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NWidgetHorizontalLTR::StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl)
|
||||||
|
{
|
||||||
|
NWidgetHorizontal::StoreWidgets(widgets, length, left_moving, top_moving, false);
|
||||||
|
}
|
||||||
|
|
||||||
NWidgetVertical::NWidgetVertical() : NWidgetContainer(NWID_VERTICAL)
|
NWidgetVertical::NWidgetVertical() : NWidgetContainer(NWID_VERTICAL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1346,6 +1361,11 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest)
|
||||||
*dest = new NWidgetHorizontal();
|
*dest = new NWidgetHorizontal();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NWID_HORIZONTAL_LTR:
|
||||||
|
if (*dest != NULL) return num_used;
|
||||||
|
*dest = new NWidgetHorizontalLTR();
|
||||||
|
break;
|
||||||
|
|
||||||
case WWT_PANEL:
|
case WWT_PANEL:
|
||||||
case WWT_INSET:
|
case WWT_INSET:
|
||||||
case WWT_FRAME:
|
case WWT_FRAME:
|
||||||
|
@ -1464,7 +1484,7 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *pare
|
||||||
|
|
||||||
/* If sub-widget is a container, recursively fill that container. */
|
/* If sub-widget is a container, recursively fill that container. */
|
||||||
WidgetType tp = sub_widget->type;
|
WidgetType tp = sub_widget->type;
|
||||||
if (tp == NWID_HORIZONTAL || tp == NWID_VERTICAL || tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET) {
|
if (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL || tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET) {
|
||||||
int num_used = MakeWidgetTree(parts, count - total_used, sub_widget);
|
int num_used = MakeWidgetTree(parts, count - total_used, sub_widget);
|
||||||
parts += num_used;
|
parts += num_used;
|
||||||
total_used += num_used;
|
total_used += num_used;
|
||||||
|
|
|
@ -96,9 +96,10 @@ enum WidgetType {
|
||||||
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
|
WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!!
|
||||||
|
|
||||||
/* Nested widget types. */
|
/* Nested widget types. */
|
||||||
NWID_HORIZONTAL, ///< Horizontal container.
|
NWID_HORIZONTAL, ///< Horizontal container.
|
||||||
NWID_VERTICAL, ///< Vertical container.
|
NWID_HORIZONTAL_LTR, ///< Horizontal container that doesn't change the order of the widgets for RTL languages.
|
||||||
NWID_SPACER, ///< Invisible widget that takes some space.
|
NWID_VERTICAL, ///< Vertical container.
|
||||||
|
NWID_SPACER, ///< Invisible widget that takes some space.
|
||||||
|
|
||||||
/* Nested widget part types. */
|
/* Nested widget part types. */
|
||||||
WPT_RESIZE, ///< Widget part for specifying resizing.
|
WPT_RESIZE, ///< Widget part for specifying resizing.
|
||||||
|
@ -217,6 +218,16 @@ public:
|
||||||
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
|
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Horizontal container that doesn't change the direction of the widgets for RTL languages. */
|
||||||
|
class NWidgetHorizontalLTR : public NWidgetHorizontal {
|
||||||
|
public:
|
||||||
|
NWidgetHorizontalLTR();
|
||||||
|
|
||||||
|
void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
|
||||||
|
|
||||||
|
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
|
||||||
|
};
|
||||||
|
|
||||||
/** Vertical container */
|
/** Vertical container */
|
||||||
class NWidgetVertical : public NWidgetContainer {
|
class NWidgetVertical : public NWidgetContainer {
|
||||||
public:
|
public:
|
||||||
|
@ -428,7 +439,7 @@ static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget part function for starting a new horizontal container, vertical container, or spacer widget.
|
* Widget part function for starting a new horizontal container, vertical container, or spacer widget.
|
||||||
* @param tp Type of the new nested widget, #NWID_HORIZONTAL, #NWID_VERTICAL, or #NWID_SPACER
|
* @param tp Type of the new nested widget, #NWID_HORIZONTAL(_LTR), #NWID_VERTICAL, or #NWID_SPACER
|
||||||
*/
|
*/
|
||||||
static inline NWidgetPart NWidget(WidgetType tp)
|
static inline NWidgetPart NWidget(WidgetType tp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue