GUI: RTL: Get internal widget RTL flag from theme
This commit is contained in:
parent
58704be218
commit
07ab77d065
12 changed files with 41 additions and 37 deletions
|
@ -309,7 +309,7 @@ void HelpDialog::reflowLayout() {
|
|||
|
||||
assert(lineHeight);
|
||||
|
||||
g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h);
|
||||
g_gui.xmlEval()->getWidgetData("ScummHelp.HelpText", x, y, w, h, _useRTL);
|
||||
|
||||
// Make sure than we don't have more lines than what we can fit
|
||||
// on the space that the layout reserves for text
|
||||
|
|
|
@ -50,7 +50,7 @@ void ThemeEval::reset() {
|
|||
_layouts.clear();
|
||||
}
|
||||
|
||||
bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h) {
|
||||
bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) {
|
||||
Common::StringTokenizer tokenizer(widget, ".");
|
||||
|
||||
if (widget.hasPrefix("Dialog."))
|
||||
|
@ -62,7 +62,7 @@ bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y,
|
|||
if (!_layouts.contains(dialogName))
|
||||
return false;
|
||||
|
||||
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h);
|
||||
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h, useRTL);
|
||||
}
|
||||
|
||||
Graphics::TextAlign ThemeEval::getWidgetTextHAlign(const Common::String &widget) {
|
||||
|
@ -80,7 +80,7 @@ Graphics::TextAlign ThemeEval::getWidgetTextHAlign(const Common::String &widget)
|
|||
return _layouts[dialogName]->getWidgetTextHAlign(widgetName);
|
||||
}
|
||||
|
||||
ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String &type, int w, int h, Graphics::TextAlign align) {
|
||||
ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String &type, int w, int h, Graphics::TextAlign align, bool useRTL) {
|
||||
int typeW = -1;
|
||||
int typeH = -1;
|
||||
Graphics::TextAlign typeAlign = Graphics::kTextAlignInvalid;
|
||||
|
@ -102,7 +102,8 @@ ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String
|
|||
widget = new ThemeLayoutWidget(_curLayout.top(), name,
|
||||
typeW == -1 ? w : typeW,
|
||||
typeH == -1 ? h : typeH,
|
||||
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign);
|
||||
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign,
|
||||
useRTL);
|
||||
|
||||
_curLayout.top()->addChild(widget);
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
|
||||
ThemeEval &addDialog(const Common::String &name, const Common::String &overlays, int16 maxWidth = -1, int16 maxHeight = -1, int inset = 0);
|
||||
ThemeEval &addLayout(ThemeLayout::LayoutType type, int spacing = -1, ThemeLayout::ItemAlign itemAlign = ThemeLayout::kItemAlignStart);
|
||||
ThemeEval &addWidget(const Common::String &name, const Common::String &type, int w = -1, int h = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft);
|
||||
ThemeEval &addWidget(const Common::String &name, const Common::String &type, int w = -1, int h = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool useRTL = false);
|
||||
ThemeEval &addImportedLayout(const Common::String &name);
|
||||
ThemeEval &addSpace(int size = -1);
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
bool hasDialog(const Common::String &name);
|
||||
|
||||
void reflowDialogLayout(const Common::String &name, Widget *widgetChain);
|
||||
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h);
|
||||
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
||||
|
||||
Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget);
|
||||
|
||||
|
|
|
@ -71,16 +71,18 @@ void ThemeLayout::resetLayout() {
|
|||
_children[i]->resetLayout();
|
||||
}
|
||||
|
||||
bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) {
|
||||
bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) {
|
||||
if (name.empty()) {
|
||||
assert(getLayoutType() == kLayoutMain);
|
||||
x = _x; y = _y;
|
||||
w = _w; h = _h;
|
||||
useRTL = _useRTL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint i = 0; i < _children.size(); ++i) {
|
||||
if (_children[i]->getWidgetData(name, x, y, w, h))
|
||||
if (_children[i]->getWidgetData(name, x, y, w, h, useRTL))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -158,10 +160,12 @@ void ThemeLayout::debugDraw(Graphics::Surface *screen, const Graphics::Font *fon
|
|||
#endif
|
||||
|
||||
|
||||
bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) {
|
||||
bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) {
|
||||
if (name == _name) {
|
||||
x = _x; y = _y;
|
||||
w = _w; h = _h;
|
||||
useRTL = _useRTL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -229,7 +233,7 @@ void ThemeLayoutMain::reflowLayout(Widget *widgetChain) {
|
|||
_w = _defaultW > 0 ? MIN(_defaultW, g_system->getOverlayWidth()) : -1;
|
||||
_h = _defaultH > 0 ? MIN(_defaultH, g_system->getOverlayHeight()) : -1;
|
||||
} else {
|
||||
if (!g_gui.xmlEval()->getWidgetData(_overlays, _x, _y, _w, _h)) {
|
||||
if (!g_gui.xmlEval()->getWidgetData(_overlays, _x, _y, _w, _h, _useRTL)) {
|
||||
warning("Unable to retrieve overlayed dialog position %s", _overlays.c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ protected:
|
|||
virtual ThemeLayout *makeClone(ThemeLayout *newParent) = 0;
|
||||
|
||||
public:
|
||||
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h);
|
||||
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
||||
|
||||
virtual Graphics::TextAlign getWidgetTextHAlign(const Common::String &name);
|
||||
|
||||
|
@ -131,6 +131,7 @@ public:
|
|||
protected:
|
||||
ThemeLayout *_parent;
|
||||
int16 _x, _y, _w, _h;
|
||||
bool _useRTL;
|
||||
Common::Rect _padding;
|
||||
Common::Array<ThemeLayout *> _children;
|
||||
int16 _defaultW, _defaultH;
|
||||
|
@ -219,14 +220,15 @@ protected:
|
|||
|
||||
class ThemeLayoutWidget : public ThemeLayout {
|
||||
public:
|
||||
ThemeLayoutWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, Graphics::TextAlign align) : ThemeLayout(p), _name(name) {
|
||||
ThemeLayoutWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, Graphics::TextAlign align, bool &useRTL) : ThemeLayout(p), _name(name) {
|
||||
_w = _defaultW = w;
|
||||
_h = _defaultH = h;
|
||||
_useRTL = useRTL;
|
||||
|
||||
setTextHAlign(align);
|
||||
}
|
||||
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) override;
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override;
|
||||
Graphics::TextAlign getWidgetTextHAlign(const Common::String &name) override;
|
||||
|
||||
void reflowLayout(Widget *widgetChain) override;
|
||||
|
@ -253,7 +255,7 @@ class ThemeLayoutTabWidget : public ThemeLayoutWidget {
|
|||
|
||||
public:
|
||||
ThemeLayoutTabWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, Graphics::TextAlign align, int tabHeight):
|
||||
ThemeLayoutWidget(p, name, w, h, align) {
|
||||
ThemeLayoutWidget(p, name, w, h, align, _useRTL) {
|
||||
_tabHeight = tabHeight;
|
||||
}
|
||||
|
||||
|
@ -263,8 +265,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) override {
|
||||
if (ThemeLayoutWidget::getWidgetData(name, x, y, w, h)) {
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override {
|
||||
if (ThemeLayoutWidget::getWidgetData(name, x, y, w, h, _useRTL)) {
|
||||
h -= _tabHeight;
|
||||
return true;
|
||||
}
|
||||
|
@ -294,7 +296,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h) override { return false; }
|
||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override { return false; }
|
||||
void reflowLayout(Widget *widgetChain) override {}
|
||||
#ifdef LAYOUT_DEBUG_DIALOG
|
||||
const char *getName() const { return "SPACE"; }
|
||||
|
|
|
@ -713,7 +713,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
|
|||
useRTL = false;
|
||||
}
|
||||
|
||||
_theme->getEvaluator()->addWidget(var, node->values["type"], width, height, alignH);
|
||||
_theme->getEvaluator()->addWidget(var, node->values["type"], width, height, alignH, useRTL);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -41,12 +41,13 @@ GuiObject::~GuiObject() {
|
|||
void GuiObject::reflowLayout() {
|
||||
if (!_name.empty()) {
|
||||
int16 w, h;
|
||||
|
||||
if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, w, h) || w == -1 || h == -1) {
|
||||
bool useRTL = true;
|
||||
if (!g_gui.xmlEval()->getWidgetData(_name, _x, _y, w, h, useRTL) || w == -1 || h == -1) {
|
||||
error("Unable to load widget position for '%s'. Please check your theme files", _name.c_str());
|
||||
}
|
||||
_w = w;
|
||||
_h = h;
|
||||
_useRTL = useRTL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
|||
|
||||
int16 _x, _y;
|
||||
uint16 _w, _h;
|
||||
bool _useRTL;
|
||||
const Common::String _name;
|
||||
|
||||
Widget *_firstWidget;
|
||||
|
|
|
@ -2785,10 +2785,10 @@ void GlobalOptionsDialog::setupCloudTab() {
|
|||
int16 shiftUp = 0;
|
||||
if (!showingCurrentStorage || enabled) {
|
||||
// "storage is disabled" hint is not shown, shift everything up
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined");
|
||||
shiftUp = y;
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageUsernameDesc", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageUsernameDesc", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined");
|
||||
shiftUp = y - shiftUp;
|
||||
}
|
||||
|
@ -2838,10 +2838,10 @@ void GlobalOptionsDialog::setupCloudTab() {
|
|||
|
||||
int16 disconnectWidgetsAdditionalShift = 0;
|
||||
if (!showDownloadButton) {
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDownloadHint", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDownloadHint", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.StorageDownloadHint's position is undefined");
|
||||
disconnectWidgetsAdditionalShift = y;
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisconnectHint", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisconnectHint", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.DownloadButton's position is undefined");
|
||||
disconnectWidgetsAdditionalShift = y - disconnectWidgetsAdditionalShift;
|
||||
}
|
||||
|
@ -2888,10 +2888,10 @@ void GlobalOptionsDialog::setupCloudTab() {
|
|||
}
|
||||
|
||||
if (!shownConnectedInfo) {
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageDisabledHint", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.StorageUsernameDesc's position is undefined");
|
||||
shiftUp = y;
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint", x, y, w, h, _useRTL))
|
||||
warning("GlobalOptions_Cloud_Container.StorageWizardNotConnectedHint's position is undefined");
|
||||
shiftUp = y - shiftUp;
|
||||
|
||||
|
@ -2911,7 +2911,7 @@ void GlobalOptionsDialog::shiftWidget(Widget *widget, const char *widgetName, in
|
|||
|
||||
int16 x, y;
|
||||
int16 w, h;
|
||||
if (!g_gui.xmlEval()->getWidgetData(widgetName, x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData(widgetName, x, y, w, h, _useRTL))
|
||||
warning("%s's position is undefined", widgetName);
|
||||
|
||||
// GUI TODO: I'm not sure what's this being used for. Will this be useful when using navbars?
|
||||
|
|
|
@ -493,7 +493,7 @@ void SaveLoadChooserSimple::reflowLayout() {
|
|||
int16 x, y;
|
||||
int16 w, h;
|
||||
|
||||
if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h))
|
||||
if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.Thumbnail", x, y, w, h, _useRTL))
|
||||
error("Error when loading position data for Save/Load Thumbnails");
|
||||
|
||||
// Even if there is no thumbnail support, getWidgetData() will provide default thumbnail values
|
||||
|
@ -934,7 +934,7 @@ void SaveLoadChooserGrid::reflowLayout() {
|
|||
|
||||
int16 x, y;
|
||||
int16 w;
|
||||
if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.List", x, y, w, availableHeight))
|
||||
if (!g_gui.xmlEval()->getWidgetData("SaveLoadChooser.List", x, y, w, availableHeight, _useRTL))
|
||||
error("Could not load widget position for 'SaveLoadChooser.List'");
|
||||
|
||||
const int16 buttonWidth = kThumbnailWidth + 6;
|
||||
|
|
|
@ -39,13 +39,13 @@ namespace GUI {
|
|||
|
||||
Widget::Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip)
|
||||
: GuiObject(x, y, w, h), _type(0), _boss(boss), _tooltip(tooltip),
|
||||
_flags(0), _hasFocus(false), _useRTL(false), _state(ThemeEngine::kStateEnabled) {
|
||||
_flags(0), _hasFocus(false), _state(ThemeEngine::kStateEnabled) {
|
||||
init();
|
||||
}
|
||||
|
||||
Widget::Widget(GuiObject *boss, const Common::String &name, const char *tooltip)
|
||||
: GuiObject(name), _type(0), _boss(boss), _tooltip(tooltip),
|
||||
_flags(0), _hasFocus(false), _useRTL(false), _state(ThemeEngine::kStateDisabled) {
|
||||
_flags(0), _hasFocus(false), _state(ThemeEngine::kStateDisabled) {
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,6 @@ void Widget::init() {
|
|||
_next = _boss->_firstWidget;
|
||||
_boss->_firstWidget = this;
|
||||
_needsRedraw = true;
|
||||
|
||||
if (TransMan.getCurrentLanguage() == "C" && false) { // GUI TODO: Change this and GuiManager::GuiManager() to use RTL.
|
||||
_useRTL = true; // GUI TODO: Widgets will get _useRTL true or not from the XML parser.
|
||||
}
|
||||
}
|
||||
|
||||
Widget::~Widget() {
|
||||
|
|
|
@ -102,7 +102,6 @@ protected:
|
|||
GuiObject *_boss;
|
||||
Widget *_next;
|
||||
bool _hasFocus;
|
||||
bool _useRTL;
|
||||
ThemeEngine::WidgetStateInfo _state;
|
||||
Common::String _tooltip;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue