diff options
author | Paul Gilbert | 2018-10-23 20:28:10 -0700 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 4ddda5cebc3d0f11cc10746e4dcac5bd0e1a7b19 (patch) | |
tree | 6a4705acdebc7861587c9dbe2a59658b0da7a162 | |
parent | ba907c9aec333903acb013e9d3a25962c69b6ca6 (diff) | |
download | scummvm-rg350-4ddda5cebc3d0f11cc10746e4dcac5bd0e1a7b19.tar.gz scummvm-rg350-4ddda5cebc3d0f11cc10746e4dcac5bd0e1a7b19.tar.bz2 scummvm-rg350-4ddda5cebc3d0f11cc10746e4dcac5bd0e1a7b19.zip |
GLK: Windows focus / iteration
-rw-r--r-- | engines/gargoyle/draw.cpp | 4 | ||||
-rw-r--r-- | engines/gargoyle/draw.h | 2 | ||||
-rw-r--r-- | engines/gargoyle/window_graphics.cpp | 2 | ||||
-rw-r--r-- | engines/gargoyle/window_pair.cpp | 2 | ||||
-rw-r--r-- | engines/gargoyle/window_text_buffer.cpp | 7 | ||||
-rw-r--r-- | engines/gargoyle/window_text_grid.cpp | 2 | ||||
-rw-r--r-- | engines/gargoyle/windows.cpp | 84 | ||||
-rw-r--r-- | engines/gargoyle/windows.h | 23 |
8 files changed, 81 insertions, 45 deletions
diff --git a/engines/gargoyle/draw.cpp b/engines/gargoyle/draw.cpp index f16d1a56ab..64c9a100e1 100644 --- a/engines/gargoyle/draw.cpp +++ b/engines/gargoyle/draw.cpp @@ -48,4 +48,8 @@ void Draw::drawCaret(const Common::Point &pos) { // TODO } +void Draw::fillArea(const byte *rgb) { + // TODO: gli_draw_clear +} + } // End of namespace Gargoyle diff --git a/engines/gargoyle/draw.h b/engines/gargoyle/draw.h index e0ec133642..f60d57399e 100644 --- a/engines/gargoyle/draw.h +++ b/engines/gargoyle/draw.h @@ -39,6 +39,8 @@ protected: int stringWidthUni(int fidx, const glui32 *s, int n, int spw); void drawCaret(const Common::Point &pos); + + void fillArea(const byte *rgb); }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/window_graphics.cpp b/engines/gargoyle/window_graphics.cpp index 732686d2da..feddf4e070 100644 --- a/engines/gargoyle/window_graphics.cpp +++ b/engines/gargoyle/window_graphics.cpp @@ -83,6 +83,8 @@ void GraphicsWindow::touch() { } void GraphicsWindow::redraw() { + Window::redraw(); + // TODO } diff --git a/engines/gargoyle/window_pair.cpp b/engines/gargoyle/window_pair.cpp index af3ed4ca38..7a11597680 100644 --- a/engines/gargoyle/window_pair.cpp +++ b/engines/gargoyle/window_pair.cpp @@ -119,6 +119,8 @@ void PairWindow::rearrange(const Common::Rect &box) { } void PairWindow::redraw() { + Window::redraw(); + // TODO } diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp index 3df2e5cd18..99bef252b8 100644 --- a/engines/gargoyle/window_text_buffer.cpp +++ b/engines/gargoyle/window_text_buffer.cpp @@ -228,7 +228,7 @@ void TextBufferWindow::reflow() { } void TextBufferWindow::touchScroll() { - _windows->clearSelection(); + g_vm->_windowMask->clearSelection(); _windows->repaint(_bbox); for (int i = 0; i < _scrollMax; i++) @@ -370,7 +370,7 @@ void TextBufferWindow::putTextUni(const glui32 *buf, int len, int pos, int oldle void TextBufferWindow::touch(int line) { int y = _bbox.top + g_conf->_tMarginY + (_height - line - 1) * g_conf->_leading; _lines[line]._dirty = 1; - _windows->clearSelection(); + g_vm->_windowMask->clearSelection(); _windows->repaint(Common::Rect(_bbox.left, y - 2, _bbox.right, y + g_conf->_leading + 2)); } @@ -796,7 +796,10 @@ void TextBufferWindow::redraw() { int selbuf, selrow, selchar, sx0, sx1, selleft, selright; int tx, tsc, tsw, lsc, rsc; + Window::redraw(); + _lines[0]._len = _numChars; + sx0 = sx1 = selleft = selright = 0; ln = new TextBufferRow(); if (!ln) diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp index 91331d7ff8..c20bafea35 100644 --- a/engines/gargoyle/window_text_grid.cpp +++ b/engines/gargoyle/window_text_grid.cpp @@ -577,6 +577,8 @@ void TextGridWindow::redraw() { int font; byte *fgcolor, *bgcolor; + Window::redraw(); + x0 = _bbox.left; y0 = _bbox.top; diff --git a/engines/gargoyle/windows.cpp b/engines/gargoyle/windows.cpp index c1c28e5123..9c8e22c4ef 100644 --- a/engines/gargoyle/windows.cpp +++ b/engines/gargoyle/windows.cpp @@ -51,8 +51,7 @@ byte Windows::_zcolor_Bright[3]; /*--------------------------------------------------------------------------*/ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullptr), - _rootWin(nullptr), _focusWin(nullptr), _mask(nullptr) { - _mask = new WindowMask(); + _rootWin(nullptr), _focusWin(nullptr) { _overrideReverse = false; _overrideFgSet = false; _overrideBgSet = false; @@ -62,6 +61,7 @@ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullpt _overrideFgVal = 0; _overrideBgVal = 0; _zcolor_fg = _zcolor_bg = 0; + _drawSelect = false; _zcolor_LightGrey[0] = _zcolor_LightGrey[1] = _zcolor_LightGrey[2] = 181; _zcolor_Foreground[0] = _zcolor_Foreground[1] = _zcolor_Foreground[2] = 0; @@ -69,10 +69,6 @@ Windows::Windows(Graphics::Screen *screen) : _screen(screen), _windowList(nullpt _zcolor_Bright[0] = _zcolor_Bright[1] = _zcolor_Bright[2] = 0; } -Windows::~Windows() { - delete _mask; -} - Window *Windows::windowOpen(Window *splitwin, glui32 method, glui32 size, glui32 wintype, glui32 rock) { Window *newwin, *oldparent; @@ -229,20 +225,30 @@ void Windows::selectionChanged() { redraw(); } -void Windows::clearSelection() { - _mask->clearSelection(); -} - void Windows::redraw() { - // TODO: gli_windows_redraw + _claimSelect = false; + + if (_forceRedraw) { + repaint(Common::Rect(0, 0, g_conf->_imageW, g_conf->_imageH)); + fillArea(g_conf->_windowColor); + } + + if (_rootWin) + _rootWin->redraw(); + + if (_moreFocus) + refocus(_focusWin); + + _forceRedraw = 0; } void Windows::redrawRect(const Common::Rect &r) { - // TODO: gli_redraw_rect + _drawSelect = true; + repaint(r); } void Windows::repaint(const Common::Rect &box) { - // TODO + // No implementation } void Windows::drawRect(int x0, int y0, int w, int h, const byte *rgb) { @@ -260,36 +266,52 @@ byte *Windows::rgbShift(byte *rgb) { /*--------------------------------------------------------------------------*/ Windows::iterator &Windows::iterator::operator++() { - if (!_current) - return *this; + _current = _windows->iterateTreeOrder(_current); + return *this; +} + +void Windows::refocus(Window *win) { + Window *focus = win; + do { + if (focus && focus->_moreRequest) { + _focusWin = focus; + return; + } - PairWindow *pairWin = dynamic_cast<PairWindow *>(_current); + focus = iterateTreeOrder(focus); + } while (focus != win); + + _moreFocus = false; +} +Window *Windows::iterateTreeOrder(Window *win) { + if (!win) + return _rootWin; + + PairWindow *pairWin = dynamic_cast<PairWindow *>(win); if (pairWin) { - _current = !pairWin->_backward ? pairWin->_child1 : pairWin->_child2; + if (!pairWin->_backward) + return pairWin->_child1; + else + return pairWin->_child2; } else { - while (_current->_parent) { - pairWin = dynamic_cast<PairWindow *>(_current->_parent); + while (win->_parent) { + pairWin = dynamic_cast<PairWindow *>(win->_parent); + assert(pairWin); if (!pairWin->_backward) { - if (_current == pairWin->_child1) { - _current = pairWin->_child2; - return *this; - } + if (win == pairWin->_child1) + return pairWin->_child2; } else { - if (_current == pairWin->_child2) { - _current = pairWin->_child1; - return *this; - } + if (win == pairWin->_child2) + return pairWin->_child1; } - _current = pairWin; + win = pairWin; } - _current = nullptr; + return nullptr; } - - return *this; } /*--------------------------------------------------------------------------*/ diff --git a/engines/gargoyle/windows.h b/engines/gargoyle/windows.h index 3f5c0bc274..1f1572070d 100644 --- a/engines/gargoyle/windows.h +++ b/engines/gargoyle/windows.h @@ -48,17 +48,18 @@ class PairWindow; /** * Main windows manager */ -class Windows { +class Windows : public Draw { friend class Window; public: class iterator { private: + Windows *_windows; Window *_current; public: /** * Constructor */ - iterator(Window *start) : _current(start) {} + iterator(Windows *windows, Window *start) : _windows(windows), _current(start) {} /** * Dereference @@ -80,12 +81,13 @@ public: */ bool operator!=(const iterator &i) { return _current != i._current; } }; + friend class iterator; private: Graphics::Screen *_screen; Window * _windowList; ///< List of all windows Window *_rootWin; ///< The topmost window Window *_focusWin; ///< The window selected by the player - WindowMask *_mask; + bool _drawSelect; private: /** * Create a new window @@ -101,6 +103,10 @@ private: * Rearrange windows */ void rearrange(); + + void refocus(Window *win); + + Window *iterateTreeOrder(Window *win); public: static bool _overrideReverse; static bool _overrideFgSet; @@ -124,11 +130,6 @@ public: Windows(Graphics::Screen *screen); /** - * Destructor - */ - ~Windows(); - - /** * Open a new window */ Window *windowOpen(Window *splitwin, glui32 method, glui32 size, @@ -149,8 +150,6 @@ public: */ void setFocus(Window *win) { _focusWin = win; } - void clearSelection(); - void selectionChanged(); void clearClaimSelect() { _claimSelect = false; } @@ -172,12 +171,12 @@ public: /** * Get an iterator that will move over the tree */ - iterator begin() { return iterator(_windowList); } + iterator begin() { return iterator(this, _windowList); } /** * Returns the end point of window iteration */ - iterator end() { return iterator(nullptr); } + iterator end() { return iterator(this, nullptr); } }; /** |