Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Minor fixes (scrollbars, tooltips, tabs, EditText) #1785

Merged
merged 4 commits into from Aug 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/ThemeEngine.cpp
Expand Up @@ -1030,7 +1030,7 @@ void ThemeEngine::drawScrollbar(const Common::Rect &r, int sliderY, int sliderHe
drawDD(kDDScrollbarBase, r);

Common::Rect r2 = r;
const int buttonExtra = (r.width() * 120) / 100;
const int buttonExtra = r.width() + 1; // scrollbar.cpp's UP_DOWN_BOX_HEIGHT

r2.bottom = r2.top + buttonExtra;
drawDD(scrollState == kScrollbarStateUp ? kDDScrollbarButtonHover : kDDScrollbarButtonIdle, r2,
Expand Down
8 changes: 5 additions & 3 deletions gui/Tooltip.cpp
Expand Up @@ -49,8 +49,8 @@ void Tooltip::setup(Dialog *parent, Widget *widget, int x, int y) {
const Graphics::Font *tooltipFont = g_gui.theme()->getFont(ThemeEngine::kFontStyleTooltip);

_wrappedLines.clear();
_w = tooltipFont->wordWrapText(widget->getTooltip(), _maxWidth - 4, _wrappedLines);
_h = (tooltipFont->getFontHeight() + 2) * _wrappedLines.size();
_w = tooltipFont->wordWrapText(widget->getTooltip(), _maxWidth - 4, _wrappedLines) + 4;
_h = (tooltipFont->getFontHeight() + 2) * _wrappedLines.size() + 4;

_x = MIN<int16>(parent->_x + x + _xdelta, g_gui.getWidth() - _w - 3);
_y = MIN<int16>(parent->_y + y + _ydelta, g_gui.getHeight() - _h - 3);
Expand All @@ -62,9 +62,11 @@ void Tooltip::drawDialog(DrawLayer layerToDraw) {

Dialog::drawDialog(layerToDraw);

int16 textX = _x + 3; // including 2px padding and 1px original code shift
int16 textY = _y + 3;
for (Common::StringArray::const_iterator i = _wrappedLines.begin(); i != _wrappedLines.end(); ++i, ++num) {
g_gui.theme()->drawText(
Common::Rect(_x + 1, _y + 1 + num * h, _x + 1 + _w, _y + 1 + (num + 1) * h),
Common::Rect(textX, textY + num * h, textX + _w, textY + (num + 1) * h),
*i,
ThemeEngine::kStateEnabled,
Graphics::kTextAlignLeft,
Expand Down
2 changes: 1 addition & 1 deletion gui/widgets/edittext.cpp
Expand Up @@ -100,7 +100,7 @@ void EditTextWidget::drawWidget() {
setTextDrawableArea(r);

g_gui.theme()->drawText(
Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
Common::Rect(_x + 2 + _leftPadding, _y + 1, _x + _leftPadding + getEditRect().width() + 2, _y + _h),
_editString, _state, Graphics::kTextAlignLeft, ThemeEngine::kTextInversionNone,
-_editScrollOffset, false, _font, ThemeEngine::kFontColorNormal, true, _textDrawableArea);
}
Expand Down
6 changes: 3 additions & 3 deletions gui/widgets/list.cpp
Expand Up @@ -41,7 +41,7 @@ ListWidget::ListWidget(Dialog *boss, const String &name, const char *tooltip, ui
// This ensures that _entriesPerPage is properly initialized.
reflowLayout();

_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h);
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
_scrollBar->setTarget(this);

setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
Expand Down Expand Up @@ -72,7 +72,7 @@ ListWidget::ListWidget(Dialog *boss, int x, int y, int w, int h, const char *too
// This ensures that _entriesPerPage is properly initialized.
reflowLayout();

_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h);
_scrollBar = new ScrollBarWidget(this, _w - _scrollBarWidth, 0, _scrollBarWidth, _h);
_scrollBar->setTarget(this);

setFlags(WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | WIDGET_WANT_TICKLE);
Expand Down Expand Up @@ -658,7 +658,7 @@ void ListWidget::reflowLayout() {
assert(_entriesPerPage > 0);

if (_scrollBar) {
_scrollBar->resize(_w - _scrollBarWidth + 1, 0, _scrollBarWidth, _h);
_scrollBar->resize(_w - _scrollBarWidth, 0, _scrollBarWidth, _h);
scrollBarRecalc();
scrollToCurrent();
}
Expand Down
8 changes: 4 additions & 4 deletions gui/widgets/scrollcontainer.cpp
Expand Up @@ -80,8 +80,8 @@ void ScrollContainerWidget::recalc() {
_verticalScroll->_currentPos = _scrolledY;
_verticalScroll->_entriesPerPage = _limitH;
_verticalScroll->_singleStep = kLineHeight;
_verticalScroll->setPos(_w - scrollbarWidth, _scrolledY+1);
_verticalScroll->setSize(scrollbarWidth, _limitH -2);
_verticalScroll->setPos(_w - scrollbarWidth, _scrolledY);
_verticalScroll->setSize(scrollbarWidth, _limitH-1);
}


Expand Down Expand Up @@ -147,7 +147,7 @@ void ScrollContainerWidget::reflowLayout() {
}

void ScrollContainerWidget::drawWidget() {
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), _backgroundType);
g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight()), _backgroundType);
}

bool ScrollContainerWidget::containsWidget(Widget *w) const {
Expand All @@ -167,7 +167,7 @@ Widget *ScrollContainerWidget::findWidget(int x, int y) {

Common::Rect ScrollContainerWidget::getClipRect() const {
// Make sure the clipping rect contains the scrollbar so it is properly redrawn
return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight());
return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight() - 1); // this -1 is because of container border, which might not be present actually
}

void ScrollContainerWidget::setBackgroundType(ThemeEngine::DialogBackground backgroundType) {
Expand Down
8 changes: 4 additions & 4 deletions gui/widgets/tab.cpp
Expand Up @@ -62,7 +62,7 @@ void TabWidget::init() {
_bodyLP = g_gui.xmlEval()->getVar("Globals.TabWidget.Body.Padding.Left");
_bodyRP = g_gui.xmlEval()->getVar("Globals.TabWidget.Body.Padding.Right");

_butRP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButtonPadding.Right", 0);
_butRP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Padding.Right", 0);
_butTP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Padding.Top", 0);
_butW = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Width", 10);
_butH = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Height", 10);
Expand Down Expand Up @@ -258,9 +258,9 @@ void TabWidget::reflowLayout() {
_minTabWidth = g_gui.xmlEval()->getVar("Globals.TabWidget.Tab.Width");
_titleVPad = g_gui.xmlEval()->getVar("Globals.TabWidget.Tab.Padding.Top");

_butRP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.PaddingRight", 0);
_butRP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Padding.Right", 0);
_butTP = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Padding.Top", 0);
_butW = g_gui.xmlEval()->getVar("GlobalsTabWidget.NavButton.Width", 10);
_butW = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Width", 10);
_butH = g_gui.xmlEval()->getVar("Globals.TabWidget.NavButton.Height", 10);

// If widgets were added or removed in the current tab, without tabs
Expand Down Expand Up @@ -375,7 +375,7 @@ Widget *TabWidget::findWidget(int x, int y) {
void TabWidget::computeLastVisibleTab(bool adjustFirstIfRoom) {
int availableWidth = _w;
if (_navButtonsVisible)
availableWidth -= 2 + _butW * 2;
availableWidth -= 2 + _butW * 2 + _butRP;

_lastVisibleTab = _tabs.size() - 1;
for (int i = _firstVisibleTab; i < (int)_tabs.size(); ++i) {
Expand Down