mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
GRAPHICS: move start + end to Graphics::TextAlign
This commit is contained in:
parent
4fc9c11bbe
commit
51d95f8978
@ -274,7 +274,7 @@ void RemapWidget::refreshKeymap() {
|
|||||||
ActionRow &row = _actions[i];
|
ActionRow &row = _actions[i];
|
||||||
|
|
||||||
if (!row.actionText) {
|
if (!row.actionText) {
|
||||||
row.actionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, "", GUI::ThemeEngine::kTextAlignHStart, nullptr, GUI::ThemeEngine::kFontStyleNormal);
|
row.actionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, "", Graphics::kTextAlignStart, nullptr, GUI::ThemeEngine::kFontStyleNormal);
|
||||||
row.actionText->setLabel(row.action->description);
|
row.actionText->setLabel(row.action->description);
|
||||||
|
|
||||||
row.keyButton = new GUI::DropdownButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kRemapCmd + i);
|
row.keyButton = new GUI::DropdownButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kRemapCmd + i);
|
||||||
@ -303,7 +303,7 @@ void RemapWidget::refreshKeymap() {
|
|||||||
|
|
||||||
KeymapTitleRow &keymapTitle = _keymapSeparators[row.keymap];
|
KeymapTitleRow &keymapTitle = _keymapSeparators[row.keymap];
|
||||||
if (!keymapTitle.descriptionText) {
|
if (!keymapTitle.descriptionText) {
|
||||||
keymapTitle.descriptionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, row.keymap->getDescription(), GUI::ThemeEngine::kTextAlignHStart);
|
keymapTitle.descriptionText = new GUI::StaticTextWidget(widgetsBoss(), 0, 0, 0, 0, row.keymap->getDescription(), Graphics::kTextAlignStart);
|
||||||
keymapTitle.resetButton = new GUI::ButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kResetKeymapCmd + i);
|
keymapTitle.resetButton = new GUI::ButtonWidget(widgetsBoss(), 0, 0, 0, 0, "", nullptr, kResetKeymapCmd + i);
|
||||||
|
|
||||||
// I18N: Button to reset keymap mappings to defaults
|
// I18N: Button to reset keymap mappings to defaults
|
||||||
|
@ -466,4 +466,15 @@ Common::String Font::handleEllipsis(const Common::String &input, int w) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextAlign convertTextAlignH(TextAlign alignH, bool rtl) {
|
||||||
|
switch (alignH) {
|
||||||
|
case kTextAlignStart:
|
||||||
|
return rtl ? kTextAlignRight : kTextAlignLeft;
|
||||||
|
case kTextAlignEnd:
|
||||||
|
return rtl ? kTextAlignLeft : kTextAlignRight;
|
||||||
|
default:
|
||||||
|
return alignH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // End of namespace Graphics
|
} // End of namespace Graphics
|
||||||
|
@ -39,11 +39,20 @@ class ManagedSurface;
|
|||||||
/** Text alignment modes */
|
/** Text alignment modes */
|
||||||
enum TextAlign {
|
enum TextAlign {
|
||||||
kTextAlignInvalid,
|
kTextAlignInvalid,
|
||||||
|
kTextAlignStart, ///< Text should be aligned to start of line (virtual)
|
||||||
kTextAlignLeft, ///< Text should be aligned to the left
|
kTextAlignLeft, ///< Text should be aligned to the left
|
||||||
kTextAlignCenter, ///< Text should be centered
|
kTextAlignCenter, ///< Text should be centered
|
||||||
|
kTextAlignEnd, ///< Text should be aligned to end of line (virtual)
|
||||||
kTextAlignRight ///< Text should be aligned to the right
|
kTextAlignRight ///< Text should be aligned to the right
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts virtual text alignments (start + end)
|
||||||
|
* to actual text alignment (left + right + center) for drawing,
|
||||||
|
* if given actual text alignments it is returned as-is
|
||||||
|
*/
|
||||||
|
TextAlign convertTextAlignH(TextAlign alignH, bool rtl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances of this class represent a distinct font, with a built-in renderer.
|
* Instances of this class represent a distinct font, with a built-in renderer.
|
||||||
* @todo Maybe move the high-level methods (drawString etc.) to a separate
|
* @todo Maybe move the high-level methods (drawString etc.) to a separate
|
||||||
|
@ -76,7 +76,7 @@ struct WidgetDrawData {
|
|||||||
|
|
||||||
TextData _textDataId;
|
TextData _textDataId;
|
||||||
TextColor _textColorId;
|
TextColor _textColorId;
|
||||||
GUI::ThemeEngine::TextAlignH _textAlignH;
|
Graphics::TextAlign _textAlignH;
|
||||||
GUI::ThemeEngine::TextAlignVertical _textAlignV;
|
GUI::ThemeEngine::TextAlignVertical _textAlignV;
|
||||||
|
|
||||||
/** Extra space that the widget occupies when it's drawn.
|
/** Extra space that the widget occupies when it's drawn.
|
||||||
@ -504,7 +504,7 @@ void ThemeEngine::addDrawStep(const Common::String &drawDataId, const Graphics::
|
|||||||
_widgets[id]->_steps.push_back(step);
|
_widgets[id]->_steps.push_back(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThemeEngine::addTextData(const Common::String &drawDataId, TextData textId, TextColor colorId, TextAlignH alignH, TextAlignVertical alignV) {
|
bool ThemeEngine::addTextData(const Common::String &drawDataId, TextData textId, TextColor colorId, Graphics::TextAlign alignH, TextAlignVertical alignV) {
|
||||||
DrawData id = parseDrawDataId(drawDataId);
|
DrawData id = parseDrawDataId(drawDataId);
|
||||||
|
|
||||||
if (id == -1 || textId == -1 || colorId == kTextColorMAX || !_widgets[id])
|
if (id == -1 || textId == -1 || colorId == kTextColorMAX || !_widgets[id])
|
||||||
@ -1065,7 +1065,7 @@ void ThemeEngine::drawRadiobutton(const Common::Rect &r, const Common::String &s
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, convertTextAlignH(_widgets[dd]->_textAlignH, rtl),
|
drawDDText(getTextData(dd), getTextColor(dd), r2, str, true, false, convertTextAlignH(_widgets[dd]->_textAlignH, rtl),
|
||||||
_widgets[dd]->_textAlignV);
|
_widgets[dd]->_textAlignV);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state, bool rtl) {
|
void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo state, bool rtl) {
|
||||||
@ -1996,23 +1996,6 @@ void ThemeEngine::drawToScreen() {
|
|||||||
_vectorRenderer->setSurface(&_screen);
|
_vectorRenderer->setSurface(&_screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics::TextAlign convertTextAlignH(GUI::ThemeEngine::TextAlignH alignH, bool rtl) {
|
|
||||||
switch (alignH) {
|
|
||||||
case GUI::ThemeEngine::kTextAlignHStart:
|
|
||||||
return rtl ? Graphics::kTextAlignRight : Graphics::kTextAlignLeft;
|
|
||||||
case GUI::ThemeEngine::kTextAlignHEnd:
|
|
||||||
return rtl ? Graphics::kTextAlignLeft : Graphics::kTextAlignRight;
|
|
||||||
case GUI::ThemeEngine::kTextAlignHLeft:
|
|
||||||
return Graphics::kTextAlignLeft;
|
|
||||||
case GUI::ThemeEngine::kTextAlignHCenter:
|
|
||||||
return Graphics::kTextAlignCenter;
|
|
||||||
case GUI::ThemeEngine::kTextAlignHRight:
|
|
||||||
return Graphics::kTextAlignRight;
|
|
||||||
default:
|
|
||||||
return Graphics::kTextAlignInvalid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::Rect ThemeEngine::swapClipRect(const Common::Rect &newRect) {
|
Common::Rect ThemeEngine::swapClipRect(const Common::Rect &newRect) {
|
||||||
Common::Rect oldRect = _clip;
|
Common::Rect oldRect = _clip;
|
||||||
_clip = newRect;
|
_clip = newRect;
|
||||||
|
@ -186,15 +186,6 @@ public:
|
|||||||
kTextAlignVTop
|
kTextAlignVTop
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TextAlignH {
|
|
||||||
kTextAlignHInvalid,
|
|
||||||
kTextAlignHStart, ///< Text should be aligned to start of line
|
|
||||||
kTextAlignHLeft, ///< Text should be aligned to the left
|
|
||||||
kTextAlignHCenter, ///< Text should be centered
|
|
||||||
kTextAlignHEnd, ///< Text should be aligned to end of line
|
|
||||||
kTextAlignHRight ///< Text should be aligned to the right
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Widget background type
|
/// Widget background type
|
||||||
enum WidgetBackground {
|
enum WidgetBackground {
|
||||||
kWidgetBackgroundNo, ///< No background at all
|
kWidgetBackgroundNo, ///< No background at all
|
||||||
@ -555,7 +546,7 @@ public:
|
|||||||
* Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the
|
* Adds a new TextStep from the ThemeParser. This will be deprecated/removed once the
|
||||||
* new Font API is in place. FIXME: Is that so ???
|
* new Font API is in place. FIXME: Is that so ???
|
||||||
*/
|
*/
|
||||||
bool addTextData(const Common::String &drawDataId, TextData textId, TextColor id, TextAlignH alignH, TextAlignVertical alignV);
|
bool addTextData(const Common::String &drawDataId, TextData textId, TextColor id, Graphics::TextAlign alignH, TextAlignVertical alignV);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@ -776,8 +767,6 @@ protected:
|
|||||||
Common::Rect _clip;
|
Common::Rect _clip;
|
||||||
};
|
};
|
||||||
|
|
||||||
Graphics::TextAlign convertTextAlignH(GUI::ThemeEngine::TextAlignH alignH, bool rtl);
|
|
||||||
|
|
||||||
} // End of namespace GUI.
|
} // End of namespace GUI.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,7 @@ bool ThemeEval::getWidgetData(const Common::String &widget, int16 &x, int16 &y,
|
|||||||
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h, useRTL);
|
return _layouts[dialogName]->getWidgetData(widgetName, x, y, w, h, useRTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH ThemeEval::getWidgetTextHAlign(const Common::String &widget) {
|
Graphics::TextAlign ThemeEval::getWidgetTextHAlign(const Common::String &widget) {
|
||||||
Common::StringTokenizer tokenizer(widget, ".");
|
Common::StringTokenizer tokenizer(widget, ".");
|
||||||
|
|
||||||
if (widget.hasPrefix("Dialog."))
|
if (widget.hasPrefix("Dialog."))
|
||||||
@ -81,20 +81,20 @@ GUI::ThemeEngine::TextAlignH ThemeEval::getWidgetTextHAlign(const Common::String
|
|||||||
Common::String widgetName = tokenizer.nextToken();
|
Common::String widgetName = tokenizer.nextToken();
|
||||||
|
|
||||||
if (!_layouts.contains(dialogName))
|
if (!_layouts.contains(dialogName))
|
||||||
return GUI::ThemeEngine::kTextAlignHInvalid;
|
return Graphics::kTextAlignInvalid;
|
||||||
|
|
||||||
return _layouts[dialogName]->getWidgetTextHAlign(widgetName);
|
return _layouts[dialogName]->getWidgetTextHAlign(widgetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String &type, int w, int h, GUI::ThemeEngine::TextAlignH align, bool useRTL) {
|
ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String &type, int w, int h, Graphics::TextAlign align, bool useRTL) {
|
||||||
int typeW = -1;
|
int typeW = -1;
|
||||||
int typeH = -1;
|
int typeH = -1;
|
||||||
GUI::ThemeEngine::TextAlignH typeAlign = GUI::ThemeEngine::kTextAlignHInvalid;
|
Graphics::TextAlign typeAlign = Graphics::kTextAlignInvalid;
|
||||||
|
|
||||||
if (!type.empty()) {
|
if (!type.empty()) {
|
||||||
typeW = getVar("Globals." + type + ".Width", -1);
|
typeW = getVar("Globals." + type + ".Width", -1);
|
||||||
typeH = getVar("Globals." + type + ".Height", -1);
|
typeH = getVar("Globals." + type + ".Height", -1);
|
||||||
typeAlign = (GUI::ThemeEngine::TextAlignH)getVar("Globals." + type + ".Align", GUI::ThemeEngine::kTextAlignHInvalid);
|
typeAlign = (Graphics::TextAlign)getVar("Globals." + type + ".Align", Graphics::kTextAlignInvalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeLayoutWidget *widget;
|
ThemeLayoutWidget *widget;
|
||||||
@ -102,13 +102,13 @@ ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String
|
|||||||
widget = new ThemeLayoutTabWidget(_curLayout.top(), name,
|
widget = new ThemeLayoutTabWidget(_curLayout.top(), name,
|
||||||
typeW == -1 ? w : typeW,
|
typeW == -1 ? w : typeW,
|
||||||
typeH == -1 ? h : typeH,
|
typeH == -1 ? h : typeH,
|
||||||
typeAlign == GUI::ThemeEngine::kTextAlignHInvalid ? align : typeAlign,
|
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign,
|
||||||
getVar("Globals.TabWidget.Tab.Height", 0));
|
getVar("Globals.TabWidget.Tab.Height", 0));
|
||||||
else
|
else
|
||||||
widget = new ThemeLayoutWidget(_curLayout.top(), name,
|
widget = new ThemeLayoutWidget(_curLayout.top(), name,
|
||||||
typeW == -1 ? w : typeW,
|
typeW == -1 ? w : typeW,
|
||||||
typeH == -1 ? h : typeH,
|
typeH == -1 ? h : typeH,
|
||||||
typeAlign == GUI::ThemeEngine::kTextAlignHInvalid ? align : typeAlign,
|
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign,
|
||||||
useRTL);
|
useRTL);
|
||||||
|
|
||||||
_curLayout.top()->addChild(widget);
|
_curLayout.top()->addChild(widget);
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "graphics/font.h"
|
#include "graphics/font.h"
|
||||||
|
|
||||||
#include "gui/ThemeLayout.h"
|
#include "gui/ThemeLayout.h"
|
||||||
#include "gui/ThemeEngine.h"
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
@ -77,7 +76,7 @@ public:
|
|||||||
|
|
||||||
ThemeEval &addDialog(const Common::String &name, const Common::String &overlays, int16 maxWidth = -1, int16 maxHeight = -1, int inset = 0);
|
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 &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, GUI::ThemeEngine::TextAlignH align = GUI::ThemeEngine::kTextAlignHStart, bool useRTL = false);
|
ThemeEval &addWidget(const Common::String &name, const Common::String &type, int w = -1, int h = -1, Graphics::TextAlign align = Graphics::kTextAlignStart, bool useRTL = false);
|
||||||
ThemeEval &addImportedLayout(const Common::String &name);
|
ThemeEval &addImportedLayout(const Common::String &name);
|
||||||
ThemeEval &addSpace(int size = -1);
|
ThemeEval &addSpace(int size = -1);
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ public:
|
|||||||
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 getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
bool getWidgetData(const Common::String &widget, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH getWidgetTextHAlign(const Common::String &widget);
|
Graphics::TextAlign getWidgetTextHAlign(const Common::String &widget);
|
||||||
|
|
||||||
#ifdef LAYOUT_DEBUG_DIALOG
|
#ifdef LAYOUT_DEBUG_DIALOG
|
||||||
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
|
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
|
||||||
|
@ -89,20 +89,20 @@ bool ThemeLayout::getWidgetData(const Common::String &name, int16 &x, int16 &y,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH ThemeLayout::getWidgetTextHAlign(const Common::String &name) {
|
Graphics::TextAlign ThemeLayout::getWidgetTextHAlign(const Common::String &name) {
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
assert(getLayoutType() == kLayoutMain);
|
assert(getLayoutType() == kLayoutMain);
|
||||||
return _textHAlign;
|
return _textHAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH res;
|
Graphics::TextAlign res;
|
||||||
|
|
||||||
for (uint i = 0; i < _children.size(); ++i) {
|
for (uint i = 0; i < _children.size(); ++i) {
|
||||||
if ((res = _children[i]->getWidgetTextHAlign(name)) != GUI::ThemeEngine::kTextAlignHInvalid)
|
if ((res = _children[i]->getWidgetTextHAlign(name)) != Graphics::kTextAlignInvalid)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GUI::ThemeEngine::kTextAlignHInvalid;
|
return Graphics::kTextAlignInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 ThemeLayoutStacked::getParentWidth() {
|
int16 ThemeLayoutStacked::getParentWidth() {
|
||||||
@ -172,12 +172,12 @@ bool ThemeLayoutWidget::getWidgetData(const Common::String &name, int16 &x, int1
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH ThemeLayoutWidget::getWidgetTextHAlign(const Common::String &name) {
|
Graphics::TextAlign ThemeLayoutWidget::getWidgetTextHAlign(const Common::String &name) {
|
||||||
if (name == _name) {
|
if (name == _name) {
|
||||||
return _textHAlign;
|
return _textHAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GUI::ThemeEngine::kTextAlignHInvalid;
|
return Graphics::kTextAlignInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeLayoutWidget::reflowLayout(Widget *widgetChain) {
|
void ThemeLayoutWidget::reflowLayout(Widget *widgetChain) {
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "graphics/font.h"
|
#include "graphics/font.h"
|
||||||
#include "gui/ThemeEngine.h"
|
|
||||||
|
|
||||||
#ifdef LAYOUT_DEBUG_DIALOG
|
#ifdef LAYOUT_DEBUG_DIALOG
|
||||||
namespace Graphics {
|
namespace Graphics {
|
||||||
@ -64,7 +63,7 @@ public:
|
|||||||
ThemeLayout(ThemeLayout *p) :
|
ThemeLayout(ThemeLayout *p) :
|
||||||
_parent(p), _x(0), _y(0), _w(-1), _h(-1),
|
_parent(p), _x(0), _y(0), _w(-1), _h(-1),
|
||||||
_defaultW(-1), _defaultH(-1),
|
_defaultW(-1), _defaultH(-1),
|
||||||
_textHAlign(GUI::ThemeEngine::kTextAlignHInvalid) {}
|
_textHAlign(Graphics::kTextAlignInvalid) {}
|
||||||
|
|
||||||
virtual ~ThemeLayout() {
|
virtual ~ThemeLayout() {
|
||||||
for (uint i = 0; i < _children.size(); ++i)
|
for (uint i = 0; i < _children.size(); ++i)
|
||||||
@ -101,7 +100,7 @@ protected:
|
|||||||
|
|
||||||
void setWidth(int16 width) { _w = width; }
|
void setWidth(int16 width) { _w = width; }
|
||||||
void setHeight(int16 height) { _h = height; }
|
void setHeight(int16 height) { _h = height; }
|
||||||
void setTextHAlign(GUI::ThemeEngine::TextAlignH align) { _textHAlign = align; }
|
void setTextHAlign(Graphics::TextAlign align) { _textHAlign = align; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the layout element is attached to a GUI widget
|
* Checks if the layout element is attached to a GUI widget
|
||||||
@ -117,11 +116,11 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
virtual bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL);
|
||||||
|
|
||||||
virtual GUI::ThemeEngine::TextAlignH getWidgetTextHAlign(const Common::String &name);
|
virtual Graphics::TextAlign getWidgetTextHAlign(const Common::String &name);
|
||||||
|
|
||||||
void importLayout(ThemeLayout *layout);
|
void importLayout(ThemeLayout *layout);
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH getTextHAlign() { return _textHAlign; }
|
Graphics::TextAlign getTextHAlign() { return _textHAlign; }
|
||||||
|
|
||||||
#ifdef LAYOUT_DEBUG_DIALOG
|
#ifdef LAYOUT_DEBUG_DIALOG
|
||||||
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font);
|
void debugDraw(Graphics::Surface *screen, const Graphics::Font *font);
|
||||||
@ -136,7 +135,7 @@ protected:
|
|||||||
Common::Rect _padding;
|
Common::Rect _padding;
|
||||||
Common::Array<ThemeLayout *> _children;
|
Common::Array<ThemeLayout *> _children;
|
||||||
int16 _defaultW, _defaultH;
|
int16 _defaultW, _defaultH;
|
||||||
GUI::ThemeEngine::TextAlignH _textHAlign;
|
Graphics::TextAlign _textHAlign;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThemeLayoutMain : public ThemeLayout {
|
class ThemeLayoutMain : public ThemeLayout {
|
||||||
@ -221,7 +220,7 @@ protected:
|
|||||||
|
|
||||||
class ThemeLayoutWidget : public ThemeLayout {
|
class ThemeLayoutWidget : public ThemeLayout {
|
||||||
public:
|
public:
|
||||||
ThemeLayoutWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, GUI::ThemeEngine::TextAlignH align, bool &useRTL) : 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;
|
_w = _defaultW = w;
|
||||||
_h = _defaultH = h;
|
_h = _defaultH = h;
|
||||||
_useRTL = useRTL;
|
_useRTL = useRTL;
|
||||||
@ -230,7 +229,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override;
|
bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override;
|
||||||
GUI::ThemeEngine::TextAlignH getWidgetTextHAlign(const Common::String &name) override;
|
Graphics::TextAlign getWidgetTextHAlign(const Common::String &name) override;
|
||||||
|
|
||||||
void reflowLayout(Widget *widgetChain) override;
|
void reflowLayout(Widget *widgetChain) override;
|
||||||
|
|
||||||
@ -255,7 +254,7 @@ class ThemeLayoutTabWidget : public ThemeLayoutWidget {
|
|||||||
int _tabHeight;
|
int _tabHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThemeLayoutTabWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, GUI::ThemeEngine::TextAlignH align, int tabHeight):
|
ThemeLayoutTabWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, Graphics::TextAlign align, int tabHeight):
|
||||||
ThemeLayoutWidget(p, name, w, h, align, _useRTL) {
|
ThemeLayoutWidget(p, name, w, h, align, _useRTL) {
|
||||||
_tabHeight = tabHeight;
|
_tabHeight = tabHeight;
|
||||||
}
|
}
|
||||||
|
@ -80,19 +80,19 @@ static TextColor parseTextColorId(const Common::String &name) {
|
|||||||
return kTextColorMAX;
|
return kTextColorMAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH parseTextHAlign(const Common::String &val) {
|
Graphics::TextAlign parseTextHAlign(const Common::String &val) {
|
||||||
if (val == "start")
|
if (val == "start")
|
||||||
return GUI::ThemeEngine::kTextAlignHStart;
|
return Graphics::kTextAlignStart;
|
||||||
else if (val == "end")
|
else if (val == "end")
|
||||||
return GUI::ThemeEngine::kTextAlignHEnd;
|
return Graphics::kTextAlignEnd;
|
||||||
else if (val == "left")
|
else if (val == "left")
|
||||||
return GUI::ThemeEngine::kTextAlignHLeft;
|
return Graphics::kTextAlignLeft;
|
||||||
else if (val == "right")
|
else if (val == "right")
|
||||||
return GUI::ThemeEngine::kTextAlignHRight;
|
return Graphics::kTextAlignRight;
|
||||||
else if (val == "center")
|
else if (val == "center")
|
||||||
return GUI::ThemeEngine::kTextAlignHCenter;
|
return Graphics::kTextAlignCenter;
|
||||||
else
|
else
|
||||||
return GUI::ThemeEngine::kTextAlignHInvalid;
|
return Graphics::kTextAlignInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GUI::ThemeEngine::TextAlignVertical parseTextVAlign(const Common::String &val) {
|
static GUI::ThemeEngine::TextAlignVertical parseTextVAlign(const Common::String &val) {
|
||||||
@ -257,10 +257,10 @@ bool ThemeParser::parserCallback_alphabitmap(ParserNode *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ThemeParser::parserCallback_text(ParserNode *node) {
|
bool ThemeParser::parserCallback_text(ParserNode *node) {
|
||||||
GUI::ThemeEngine::TextAlignH alignH;
|
Graphics::TextAlign alignH;
|
||||||
GUI::ThemeEngine::TextAlignVertical alignV;
|
GUI::ThemeEngine::TextAlignVertical alignV;
|
||||||
|
|
||||||
if ((alignH = parseTextHAlign(node->values["horizontal_align"])) == GUI::ThemeEngine::kTextAlignHInvalid)
|
if ((alignH = parseTextHAlign(node->values["horizontal_align"])) == Graphics::kTextAlignInvalid)
|
||||||
return parserError("Invalid value for text alignment.");
|
return parserError("Invalid value for text alignment.");
|
||||||
|
|
||||||
if ((alignV = parseTextVAlign(node->values["vertical_align"])) == GUI::ThemeEngine::kTextAlignVInvalid)
|
if ((alignV = parseTextVAlign(node->values["vertical_align"])) == GUI::ThemeEngine::kTextAlignVInvalid)
|
||||||
@ -706,10 +706,10 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
|
|||||||
return parserError("Corrupted height value in key for " + var);
|
return parserError("Corrupted height value in key for " + var);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ThemeEngine::TextAlignH alignH = GUI::ThemeEngine::kTextAlignHStart;
|
Graphics::TextAlign alignH = Graphics::kTextAlignStart;
|
||||||
|
|
||||||
if (node->values.contains("textalign")) {
|
if (node->values.contains("textalign")) {
|
||||||
if ((alignH = parseTextHAlign(node->values["textalign"])) == GUI::ThemeEngine::kTextAlignHInvalid)
|
if ((alignH = parseTextHAlign(node->values["textalign"])) == Graphics::kTextAlignInvalid)
|
||||||
return parserError("Invalid value for text alignment.");
|
return parserError("Invalid value for text alignment.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,9 +965,9 @@ bool ThemeParser::parseCommonLayoutProps(ParserNode *node, const Common::String
|
|||||||
|
|
||||||
|
|
||||||
if (node->values.contains("textalign")) {
|
if (node->values.contains("textalign")) {
|
||||||
GUI::ThemeEngine::TextAlignH alignH = GUI::ThemeEngine::kTextAlignHStart;
|
Graphics::TextAlign alignH = Graphics::kTextAlignStart;
|
||||||
|
|
||||||
if ((alignH = parseTextHAlign(node->values["textalign"])) == GUI::ThemeEngine::kTextAlignHInvalid)
|
if ((alignH = parseTextHAlign(node->values["textalign"])) == Graphics::kTextAlignInvalid)
|
||||||
return parserError("Invalid value for text alignment.");
|
return parserError("Invalid value for text alignment.");
|
||||||
|
|
||||||
_theme->getEvaluator()->setVar(var + "Align", alignH);
|
_theme->getEvaluator()->setVar(var + "Align", alignH);
|
||||||
|
@ -1161,7 +1161,7 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin
|
|||||||
yPos += yStep;
|
yPos += yStep;
|
||||||
|
|
||||||
if (info.descriptions[idx].comment && strlen(info.descriptions[idx].comment) > 0) {
|
if (info.descriptions[idx].comment && strlen(info.descriptions[idx].comment) > 0) {
|
||||||
new StaticTextWidget(scrollContainer, lineHeight + descrDelta, yPos, width - descrDelta, yStep, info.descriptions[idx].comment, GUI::ThemeEngine::kTextAlignHStart, "", ThemeEngine::kFontStyleNormal);
|
new StaticTextWidget(scrollContainer, lineHeight + descrDelta, yPos, width - descrDelta, yStep, info.descriptions[idx].comment, Graphics::kTextAlignStart, "", ThemeEngine::kFontStyleNormal);
|
||||||
yPos += yStep;
|
yPos += yStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,12 +1171,12 @@ void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::Strin
|
|||||||
|
|
||||||
if (nHidden) {
|
if (nHidden) {
|
||||||
Common::String hiddenStr = Common::String::format(_("%d hidden achievements remaining"), nHidden);
|
Common::String hiddenStr = Common::String::format(_("%d hidden achievements remaining"), nHidden);
|
||||||
new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, hiddenStr.c_str(), GUI::ThemeEngine::kTextAlignHStart);
|
new StaticTextWidget(scrollContainer, lineHeight, yPos, width, yStep, hiddenStr.c_str(), Graphics::kTextAlignStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nMax) {
|
if (nMax) {
|
||||||
Common::String totalStr = Common::String::format(_("Achievements unlocked: %d/%d"), nAchieved, nMax);
|
Common::String totalStr = Common::String::format(_("Achievements unlocked: %d/%d"), nAchieved, nMax);
|
||||||
new StaticTextWidget(scrollContainer, lineHeight, lineHeight, width, yStep, totalStr.c_str(), GUI::ThemeEngine::kTextAlignHStart);
|
new StaticTextWidget(scrollContainer, lineHeight, lineHeight, width, yStep, totalStr.c_str(), Graphics::kTextAlignStart);
|
||||||
|
|
||||||
SliderWidget *progressBar;
|
SliderWidget *progressBar;
|
||||||
progressBar = new SliderWidget(scrollContainer, lineHeight, lineHeight*2, progressBarWidth, lineHeight);
|
progressBar = new SliderWidget(scrollContainer, lineHeight, lineHeight*2, progressBarWidth, lineHeight);
|
||||||
|
@ -773,7 +773,7 @@ SaveLoadChooserGrid::SaveLoadChooserGrid(const Common::String &title, bool saveM
|
|||||||
|
|
||||||
// Page display
|
// Page display
|
||||||
_pageDisplay = new StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String());
|
_pageDisplay = new StaticTextWidget(this, "SaveLoadChooser.PageDisplay", Common::String());
|
||||||
_pageDisplay->setAlign(GUI::ThemeEngine::kTextAlignHEnd);
|
_pageDisplay->setAlign(Graphics::kTextAlignEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveLoadChooserGrid::~SaveLoadChooserGrid() {
|
SaveLoadChooserGrid::~SaveLoadChooserGrid() {
|
||||||
@ -997,7 +997,7 @@ void SaveLoadChooserGrid::reflowLayout() {
|
|||||||
PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, nullptr, buttonCmd);
|
PicButtonWidget *button = new PicButtonWidget(container, dstX, dstY, buttonWidth, buttonHeight, nullptr, buttonCmd);
|
||||||
dstY += buttonHeight;
|
dstY += buttonHeight;
|
||||||
|
|
||||||
StaticTextWidget *description = new StaticTextWidget(container, dstX, dstY, buttonWidth, kLineHeight, Common::String(), GUI::ThemeEngine::kTextAlignHStart);
|
StaticTextWidget *description = new StaticTextWidget(container, dstX, dstY, buttonWidth, kLineHeight, Common::String(), Graphics::kTextAlignStart);
|
||||||
|
|
||||||
_buttons.push_back(SlotButton(container, button, description));
|
_buttons.push_back(SlotButton(container, button, description));
|
||||||
}
|
}
|
||||||
|
@ -292,20 +292,12 @@ void Widget::read(Common::String str) {
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip, ThemeEngine::FontStyle font)
|
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip, ThemeEngine::FontStyle font)
|
||||||
: Widget(boss, x, y, w, h, tooltip), _align(align) {
|
|
||||||
setFlags(WIDGET_ENABLED);
|
|
||||||
_type = kStaticTextWidget;
|
|
||||||
_label = text;
|
|
||||||
_font = font;
|
|
||||||
}
|
|
||||||
|
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, GUI::ThemeEngine::TextAlignH align, const char *tooltip, ThemeEngine::FontStyle font)
|
|
||||||
: Widget(boss, x, y, w, h, tooltip) {
|
: Widget(boss, x, y, w, h, tooltip) {
|
||||||
setFlags(WIDGET_ENABLED);
|
setFlags(WIDGET_ENABLED);
|
||||||
_type = kStaticTextWidget;
|
_type = kStaticTextWidget;
|
||||||
_label = text;
|
_label = text;
|
||||||
_font = font;
|
_font = font;
|
||||||
_align = GUI::convertTextAlignH(align, g_gui.useRTL() && _useRTL);
|
_align = Graphics::convertTextAlignH(align, g_gui.useRTL() && _useRTL);
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip, ThemeEngine::FontStyle font)
|
StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip, ThemeEngine::FontStyle font)
|
||||||
@ -314,7 +306,7 @@ StaticTextWidget::StaticTextWidget(GuiObject *boss, const Common::String &name,
|
|||||||
_type = kStaticTextWidget;
|
_type = kStaticTextWidget;
|
||||||
_label = text;
|
_label = text;
|
||||||
|
|
||||||
_align = GUI::convertTextAlignH(g_gui.xmlEval()->getWidgetTextHAlign(name), g_gui.useRTL() && _useRTL);
|
_align = Graphics::convertTextAlignH(g_gui.xmlEval()->getWidgetTextHAlign(name), g_gui.useRTL() && _useRTL);
|
||||||
|
|
||||||
_font = font;
|
_font = font;
|
||||||
}
|
}
|
||||||
@ -332,6 +324,7 @@ void StaticTextWidget::setLabel(const Common::String &label) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StaticTextWidget::setAlign(Graphics::TextAlign align) {
|
void StaticTextWidget::setAlign(Graphics::TextAlign align) {
|
||||||
|
align = Graphics::convertTextAlignH(align, g_gui.useRTL() && _useRTL);
|
||||||
if (_align != align){
|
if (_align != align){
|
||||||
_align = align;
|
_align = align;
|
||||||
|
|
||||||
@ -339,9 +332,6 @@ void StaticTextWidget::setAlign(Graphics::TextAlign align) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticTextWidget::setAlign(GUI::ThemeEngine::TextAlignH align) {
|
|
||||||
setAlign(GUI::convertTextAlignH(align, g_gui.useRTL() && _useRTL));
|
|
||||||
}
|
|
||||||
|
|
||||||
void StaticTextWidget::drawWidget() {
|
void StaticTextWidget::drawWidget() {
|
||||||
g_gui.theme()->drawText(
|
g_gui.theme()->drawText(
|
||||||
|
@ -201,15 +201,12 @@ protected:
|
|||||||
ThemeEngine::FontStyle _font;
|
ThemeEngine::FontStyle _font;
|
||||||
public:
|
public:
|
||||||
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip = nullptr, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold);
|
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, Graphics::TextAlign align, const char *tooltip = nullptr, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold);
|
||||||
StaticTextWidget(GuiObject *boss, int x, int y, int w, int h, const Common::String &text, GUI::ThemeEngine::TextAlignH align, const char *tooltip = nullptr, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold);
|
|
||||||
StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip = nullptr, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold);
|
StaticTextWidget(GuiObject *boss, const Common::String &name, const Common::String &text, const char *tooltip = nullptr, ThemeEngine::FontStyle font = ThemeEngine::kFontStyleBold);
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
void setLabel(const Common::String &label);
|
void setLabel(const Common::String &label);
|
||||||
void handleMouseEntered(int button) override { readLabel(); }
|
void handleMouseEntered(int button) override { readLabel(); }
|
||||||
const Common::String &getLabel() const { return _label; }
|
const Common::String &getLabel() const { return _label; }
|
||||||
void setAlign(Graphics::TextAlign align);
|
void setAlign(Graphics::TextAlign align);
|
||||||
void setAlign(GUI::ThemeEngine::TextAlignH align);
|
|
||||||
|
|
||||||
Graphics::TextAlign getAlign() const { return _align; }
|
Graphics::TextAlign getAlign() const { return _align; }
|
||||||
void readLabel() { read(_label); }
|
void readLabel() { read(_label); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user