diff options
author | Eugene Sandulenko | 2016-04-24 10:47:09 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-04-24 10:47:09 +0200 |
commit | 9877abe93697c016d18f7fee1c252577e6fd47df (patch) | |
tree | 6ddd7ffedecefae9ab80ea7f9f1417273d245855 /engines | |
parent | b4a2361bf726dfd7939b70e62fd902d80d73161f (diff) | |
download | scummvm-rg350-9877abe93697c016d18f7fee1c252577e6fd47df.tar.gz scummvm-rg350-9877abe93697c016d18f7fee1c252577e6fd47df.tar.bz2 scummvm-rg350-9877abe93697c016d18f7fee1c252577e6fd47df.zip |
WAGE: Implemented window resizing
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/gui-console.cpp | 10 | ||||
-rw-r--r-- | engines/wage/gui.cpp | 22 | ||||
-rw-r--r-- | engines/wage/gui.h | 1 | ||||
-rw-r--r-- | engines/wage/macwindow.cpp | 7 | ||||
-rw-r--r-- | engines/wage/macwindow.h | 1 |
5 files changed, 19 insertions, 22 deletions
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp index ea66826c3b..ca1917b96d 100644 --- a/engines/wage/gui-console.cpp +++ b/engines/wage/gui-console.cpp @@ -114,7 +114,7 @@ enum { void Gui::flowText(Common::String &str) { Common::StringArray wrappedLines; - int textW = _consoleTextArea.width() - kConWPadding * 2; + int textW = _consoleWindow->getInnerDimensions().width() - kConWPadding * 2; const Graphics::Font *font = getConsoleFont(); font->wordWrapText(str, textW, wrappedLines); @@ -297,17 +297,17 @@ void Gui::drawInput() { if (_engine->_inputText.contains('\n')) { _consoleDirty = true; } else { - int x = kConWPadding + _consoleTextArea.left; - int y = _cursorY + _consoleTextArea.top; + int x = kConWPadding + _consoleWindow->getInnerDimensions().left; + int y = _cursorY + _consoleWindow->getInnerDimensions().top; - Common::Rect r(x, y, x + _consoleTextArea.width() - kConWPadding, y + font->getFontHeight()); + Common::Rect r(x, y, x + _consoleWindow->getInnerDimensions().width() - kConWPadding, y + font->getFontHeight()); _screen.fillRect(r, kColorWhite); undrawCursor(); font->drawString(&_screen, _out[_inputTextLineNum], x, y, _screen.w, kColorBlack); - g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleTextArea.width(), font->getFontHeight()); + g_system->copyRectToScreen(_screen.getBasePtr(x, y), _screen.pitch, x, y, _consoleWindow->getInnerDimensions().width(), font->getFontHeight()); } _cursorX = font->getStringWidth(_out[_inputTextLineNum]) + kConHPadding; diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp index f2de8ad6b6..09eeb0f3ee 100644 --- a/engines/wage/gui.cpp +++ b/engines/wage/gui.cpp @@ -127,8 +127,8 @@ static void cursorTimerHandler(void *refCon) { if (!gui->_screen.getPixels()) return; - x += gui->_consoleTextArea.left; - y += gui->_consoleTextArea.top; + x += gui->_consoleWindow->getInnerDimensions().left; + y += gui->_consoleWindow->getInnerDimensions().top; gui->_screen.vLine(x, y, y + kCursorHeight, gui->_cursorState ? kColorBlack : kColorWhite); @@ -302,11 +302,6 @@ void Gui::drawScene() { _consoleDirty = true; _menuDirty = true; _consoleFullRedraw = true; - - _consoleTextArea.left = _scene->_textBounds->left + kBorderWidth - 2; - _consoleTextArea.top = _scene->_textBounds->top + kBorderWidth - 2; - _consoleTextArea.setWidth(_scene->_textBounds->width() - 2 * kBorderWidth); - _consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth); } static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *g) { @@ -340,7 +335,7 @@ void Gui::drawConsole() { return; renderConsole(_consoleWindow->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2, - _scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth)); + _consoleWindow->getDimensions().width(), _consoleWindow->getDimensions().height())); _consoleWindow->setDirty(true); } @@ -358,9 +353,10 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) { if (click == kBorderScrollUp || click == kBorderScrollDown) { if (event.type == Common::EVENT_LBUTTONDOWN) { - int textFullSize = _lines.size() * _consoleLineHeight + _consoleTextArea.height(); + int consoleHeight = _consoleWindow->getInnerDimensions().height(); + int textFullSize = _lines.size() * _consoleLineHeight + consoleHeight; float scrollPos = (float)_scrollPos / textFullSize; - float scrollSize = (float)_consoleTextArea.height() / textFullSize; + float scrollSize = (float)consoleHeight / textFullSize; _consoleWindow->setScroll(scrollPos, scrollSize); @@ -374,7 +370,7 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) { undrawCursor(); _cursorY -= (_scrollPos - oldScrollPos); _consoleDirty = true; - _consoleFullRedraw = true; + _consoleFullRedraw = true; break; case kBorderScrollDown: _scrollPos = MIN<int>((_lines.size() - 2) * _consoleLineHeight, _scrollPos + _consoleLineHeight); @@ -569,7 +565,7 @@ int Gui::calcTextX(int x, int textLine) { Common::String str = _lines[textLine]; - x -= _consoleTextArea.left; + x -= _consoleWindow->getInnerDimensions().left; for (int i = str.size(); i >= 0; i--) { if (font->getStringWidth(str) < x) { @@ -583,7 +579,7 @@ int Gui::calcTextX(int x, int textLine) { } int Gui::calcTextY(int y) { - y -= _consoleTextArea.top; + y -= _consoleWindow->getInnerDimensions().top; if (y < 0) y = 0; diff --git a/engines/wage/gui.h b/engines/wage/gui.h index 4816dac634..8a819822c6 100644 --- a/engines/wage/gui.h +++ b/engines/wage/gui.h @@ -136,7 +136,6 @@ public: Graphics::ManagedSurface _screen; int _cursorX, _cursorY; bool _cursorState; - Common::Rect _consoleTextArea; bool _builtInFonts; WageEngine *_engine; diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp index 42e03625e8..034a52e63c 100644 --- a/engines/wage/macwindow.cpp +++ b/engines/wage/macwindow.cpp @@ -96,6 +96,8 @@ void MacWindow::resize(int w, int h) { _dims.setWidth(w); _dims.setHeight(h); + updateInnerDims(); + _contentIsDirty = true; _borderIsDirty = true; } @@ -322,9 +324,8 @@ bool MacWindow::processEvent(Common::Event &event) { } if (_beingResized) { - _dims.setWidth(MAX(kBorderWidth * 4, _dims.width() + event.mouse.x - _draggedX)); - _dims.setHeight(MAX(kBorderWidth * 4, _dims.height() + event.mouse.y - _draggedY)); - updateInnerDims(); + resize(MAX(kBorderWidth * 4, _dims.width() + event.mouse.x - _draggedX), + MAX(kBorderWidth * 4, _dims.height() + event.mouse.y - _draggedY)); _draggedX = event.mouse.x; _draggedY = event.mouse.y; diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h index 527de4a13a..315203b491 100644 --- a/engines/wage/macwindow.h +++ b/engines/wage/macwindow.h @@ -79,6 +79,7 @@ public: void resize(int w, int h); void setDimensions(const Common::Rect &r); const Common::Rect &getDimensions() { return _dims; } + const Common::Rect &getInnerDimensions() { return _innerDims; } bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false); void setActive(bool active); Graphics::ManagedSurface *getSurface() { return &_surface; } |