22 #ifndef THEME_LAYOUT_H 23 #define THEME_LAYOUT_H 25 #include "common/array.h" 26 #include "common/rect.h" 27 #include "graphics/font.h" 31 #ifdef LAYOUT_DEBUG_DIALOG 53 kLayoutScrollContainerWidget,
66 _parent(p), _x(0), _y(0), _w(-1), _h(-1),
67 _defaultW(-1), _defaultH(-1),
71 for (uint i = 0; i < _children.size(); ++i)
75 virtual void reflowLayout(
Widget *widgetChain) = 0;
76 virtual void resetLayout();
78 void addChild(
ThemeLayout *child) { _children.push_back(child); }
80 void setPadding(int16 left, int16 right, int16 top, int16 bottom) {
82 _padding.right = right;
84 _padding.bottom = bottom;
88 int16 getWidth() {
return _w; }
89 int16 getHeight() {
return _h; }
91 void offsetX(
int newX) {
93 for (uint i = 0; i < _children.size(); ++i)
94 _children[i]->offsetX(newX);
97 void offsetY(
int newY) {
99 for (uint i = 0; i < _children.size(); ++i)
100 _children[i]->offsetY(newY);
103 void setWidth(int16 width) { _w = width; }
104 void setHeight(int16 height) { _h = height; }
114 virtual LayoutType getLayoutType()
const = 0;
119 virtual bool getWidgetData(
const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h,
bool &useRTL);
120 bool getUseRTL() {
return _useRTL; }
128 #ifdef LAYOUT_DEBUG_DIALOG 131 virtual const char *getName()
const {
return "<override-me>"; }
135 int16 _x, _y, _w, _h;
139 int16 _defaultW, _defaultH;
150 _w = _defaultW = width;
151 _h = _defaultH = height;
155 void reflowLayout(
Widget *widgetChain)
override;
157 void resetLayout()
override {
158 ThemeLayout::resetLayout();
163 virtual const char *getName()
const override {
return _name.c_str(); }
166 LayoutType getLayoutType()
const override {
return kLayoutMain; }
167 ThemeLayout *makeClone(
ThemeLayout *newParent)
override { assert(!
"Do not copy Main Layouts!");
return nullptr; }
180 ThemeLayout(p), _type(type), _itemAlign(itemAlign) {
181 assert((type == kLayoutVertical) || (type == kLayoutHorizontal));
185 void reflowLayout(
Widget *widgetChain)
override {
186 if (_type == kLayoutVertical)
187 reflowLayoutVertical(widgetChain);
189 reflowLayoutHorizontal(widgetChain);
192 void reflowLayoutHorizontal(
Widget *widgetChain);
193 void reflowLayoutVertical(
Widget *widgetChain);
195 #ifdef LAYOUT_DEBUG_DIALOG 196 const char *getName()
const override {
197 return (_type == kLayoutVertical)
198 ?
"Vertical Layout" :
"Horizontal Layout";
203 int16 getParentWidth();
204 int16 getParentHeight();
206 LayoutType getLayoutType()
const override {
return _type; }
210 n->_parent = newParent;
212 for (uint i = 0; i < n->_children.size(); ++i)
213 n->_children[i] = n->_children[i]->makeClone(n);
218 const LayoutType _type;
230 setTextHAlign(align);
233 bool getWidgetData(
const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h,
bool &useRTL)
override;
236 void reflowLayout(
Widget *widgetChain)
override;
238 virtual const char *getName()
const override {
return _name.c_str(); }
241 LayoutType getLayoutType()
const override {
return kLayoutWidget; }
243 bool isBound(
Widget *widgetChain)
const override;
248 n->_parent = newParent;
261 _tabHeight = tabHeight;
264 void reflowLayout(
Widget *widgetChain)
override {
265 for (uint i = 0; i < _children.size(); ++i) {
266 _children[i]->reflowLayout(widgetChain);
270 bool getWidgetData(
const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h,
bool &useRTL)
override {
271 if (ThemeLayoutWidget::getWidgetData(name, x, y, w, h, useRTL)) {
280 LayoutType getLayoutType()
const override {
return kLayoutTabWidget; }
284 n->_parent = newParent;
295 _scrollWidth = scrollWidth;
298 void reflowLayout(
Widget *widgetChain)
override {
299 for (uint i = 0; i < _children.size(); ++i) {
300 _children[i]->reflowLayout(widgetChain);
304 bool getWidgetData(
const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h,
bool &useRTL)
override {
305 if (ThemeLayoutWidget::getWidgetData(name, x, y, w, h, useRTL)) {
314 LayoutType getLayoutType()
const override {
return kLayoutScrollContainerWidget; }
318 n->_parent = newParent;
326 if (p->getLayoutType() == kLayoutHorizontal) {
327 _w = _defaultW = size;
329 }
else if (p->getLayoutType() == kLayoutVertical) {
331 _h = _defaultH = size;
335 bool getWidgetData(
const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h,
bool &useRTL)
override {
return false; }
336 void reflowLayout(
Widget *widgetChain)
override {}
337 #ifdef LAYOUT_DEBUG_DIALOG 338 const char *getName()
const override {
return "SPACE"; }
342 LayoutType getLayoutType()
const override {
return kLayoutSpace; }
346 n->_parent = newParent;
Definition: ThemeLayout.h:323
Definition: managed_surface.h:51
TextAlign
Definition: font.h:48
Items are centered in the container.
Definition: ThemeLayout.h:60
Indicates invalid alignment.
Definition: font.h:49
Items are aligned to the left for vertical layouts or to the top for horizontal layouts.
Definition: ThemeLayout.h:59
Definition: ThemeLayout.h:143
Definition: formatinfo.h:28
Definition: ThemeLayout.h:177
virtual bool isBound(Widget *widgetChain) const
Definition: ThemeLayout.h:112
Items are aligned to the right for vertical layouts or to the bottom for horizontal layouts...
Definition: ThemeLayout.h:61
Definition: ThemeLayout.h:41
ItemAlign
Cross-direction alignment of layout children.
Definition: ThemeLayout.h:58