GUI: Code cleanup

This commit is contained in:
aryanrawlani28 2020-05-21 02:29:59 +05:30 committed by Eugene Sandulenko
parent ab4ac760fb
commit 7e27af8148
5 changed files with 13 additions and 18 deletions

View file

@ -344,7 +344,6 @@ EditGameDialog::EditGameDialog(const String &domain)
// Activate the first tab
tab->setActiveTab(0);
_tabWidget = tab;
// Add OK & Cancel buttons

View file

@ -527,7 +527,7 @@ void DropdownButtonWidget::clearEntries() {
}
void DropdownButtonWidget::drawWidget() {
if (_entries.empty()) {
if (_entries.empty()) {
// Degrade to a regular button
g_gui.theme()->drawButton(Common::Rect(_x, _y, _x + _w, _y + _h), _label, _state);
} else {
@ -613,7 +613,7 @@ void PicButtonWidget::drawWidget() {
const int x = _x + (_w - gfx->w) / 2;
const int y = _y + (_h - gfx->h) / 2;
g_gui.theme()->drawSurface(Common::Point(x, y), *gfx, _transparency);
}
}
@ -791,8 +791,7 @@ void SliderWidget::drawWidget() {
if (g_gui.useRTL() && _useRTL) {
// GUI TODO: This currently draws the numbers okay (Rightmost is 0, left goes high value), but renders incorrectly (colors should be inverted).
g_gui.theme()->drawSlider(r1, valueToBarWidth(getMaxValue() - _value), _state);
}
else {
} else {
g_gui.theme()->drawSlider(r1, valueToBarWidth(_value), _state);
}
}
@ -867,7 +866,7 @@ void GraphicsWidget::drawWidget() {
const int x = _x + (_w - _gfx.w) / 2;
const int y = _y + (_h - _gfx.h) / 2;
g_gui.theme()->drawSurface(Common::Point(x, y), _gfx, _transparency);
}
}

View file

@ -396,7 +396,7 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) {
Common::Rect r1(x, y, x + w, y + _lineHeight);
Common::Rect r2(x + 1, y + 2, x + w, y + 2 + _lineHeight);
Graphics::TextAlign alignment = Graphics::TextAlign::kTextAlignLeft;
Graphics::TextAlign alignment = Graphics::kTextAlignLeft;
if (g_gui.useRTL()) {
r2.translate(-g_gui.getOverlayOffset(), 0);

View file

@ -141,13 +141,6 @@ void ScrollContainerWidget::reflowLayout() {
}
void ScrollContainerWidget::drawWidget() {
// GUI TODO: Recheck what the below line does.
if (g_gui.useRTL()) {
if (this->_name.contains("GameOptions") || this->_name.contains("GlobalOptions")) {
_x = g_system->getOverlayWidth() - _x - _w + g_gui.getOverlayOffset();
}
}
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight()), _backgroundType);
}

View file

@ -70,14 +70,17 @@ void TabWidget::init() {
int x = _w - _butRP - _butW * 2 - 2;
int y = _butTP - _tabHeight;
String leftArrow = "<";
String rightArrow = ">";
if (g_gui.useRTL()) { // GUI TODO: Incomplete and possibly incorrect too. Unusable atm.
_navLeft = new ButtonWidget(this, x, y, _butW, _butH, ">", nullptr, kCmdLeft);
_navRight = new ButtonWidget(this, x + _butW + 2, y, _butW, _butH, "<", nullptr, kCmdRight);
_navLeft = new ButtonWidget(this, x, y, _butW, _butH, rightArrow, nullptr, kCmdLeft);
_navRight = new ButtonWidget(this, x + _butW + 2, y, _butW, _butH, leftArrow, nullptr, kCmdRight);
_navLeft->setEnabled(true);
_navRight->setEnabled(false);
} else {
_navLeft = new ButtonWidget(this, x, y, _butW, _butH, "<", nullptr, kCmdLeft);
_navRight = new ButtonWidget(this, x + _butW + 2, y, _butW, _butH, ">", nullptr, kCmdRight);
_navLeft = new ButtonWidget(this, x, y, _butW, _butH, leftArrow, nullptr, kCmdLeft);
_navRight = new ButtonWidget(this, x + _butW + 2, y, _butW, _butH, rightArrow, nullptr, kCmdRight);
_navLeft->setEnabled(false);
_navRight->setEnabled(true);
}
@ -129,6 +132,7 @@ int TabWidget::addTab(const String &title, const String &dialogName) {
newTab._tabWidth = newWidth;
_tabs.push_back(newTab);
int numTabs = _tabs.size();
// Activate the new tab