diff options
author | Paul Gilbert | 2015-07-25 23:24:39 -0400 |
---|---|---|
committer | Paul Gilbert | 2015-07-25 23:24:39 -0400 |
commit | 05eb787ce5fcc41daf2d26eec015e895f7e7ed02 (patch) | |
tree | f864ff6b4be50eb64bc34a89a39866352eca1bb0 /engines/sherlock/tattoo/widget_files.cpp | |
parent | 1d16677e3571add7baefecb9ee630e2e99e8e48d (diff) | |
download | scummvm-rg350-05eb787ce5fcc41daf2d26eec015e895f7e7ed02.tar.gz scummvm-rg350-05eb787ce5fcc41daf2d26eec015e895f7e7ed02.tar.bz2 scummvm-rg350-05eb787ce5fcc41daf2d26eec015e895f7e7ed02.zip |
SHERLOCK: RT: Refactoring scrolling code to WidgetBase
Diffstat (limited to 'engines/sherlock/tattoo/widget_files.cpp')
-rw-r--r-- | engines/sherlock/tattoo/widget_files.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp index 21dd10851f..4a0c0495e0 100644 --- a/engines/sherlock/tattoo/widget_files.cpp +++ b/engines/sherlock/tattoo/widget_files.cpp @@ -38,7 +38,6 @@ WidgetFiles::WidgetFiles(SherlockEngine *vm, const Common::String &target) : SaveManager(vm, target), WidgetBase(vm), _vm(vm) { _fileMode = SAVEMODE_NONE; _selector = _oldSelector = -1; - savegameIndex = 0; } void WidgetFiles::show(SaveMode mode) { @@ -162,11 +161,8 @@ void WidgetFiles::render(FilesRenderMode mode) { } // Draw the Scrollbar if neccessary - if (mode != RENDER_NAMES) { - Common::Rect scrollRect(BUTTON_SIZE, _bounds.height() - _surface.fontHeight() - 16); - scrollRect.moveTo(_bounds.width() - BUTTON_SIZE - 3, _surface.fontHeight() + 13); - drawScrollBar(_savegameIndex, FILES_LINES_COUNT, _savegames.size(), scrollRect); - } + if (mode != RENDER_NAMES) + drawScrollBar(_savegameIndex, FILES_LINES_COUNT, _savegames.size()); } void WidgetFiles::handleEvents() { @@ -175,17 +171,25 @@ void WidgetFiles::handleEvents() { // Handle scrollbar events ScrollHighlight oldHighlight = ui._scrollHighlight; - Common::Rect scrollRect(BUTTON_SIZE, _bounds.height() - _surface.fontHeight() - 16); - scrollRect.moveTo(_bounds.right - BUTTON_SIZE - 3, _bounds.top + _surface.fontHeight() + 13); - handleScrollbarEvents(_savegameIndex, FILES_LINES_COUNT, _savegames.size(), scrollRect); + handleScrollbarEvents(_savegameIndex, FILES_LINES_COUNT, _savegames.size()); - // If the highlight has changed, redraw the scrollbar - if (ui._scrollHighlight != oldHighlight) + int oldScrollIndex = _savegameIndex; + handleScrolling(_savegameIndex, FILES_LINES_COUNT, _savegames.size()); + + // Only redraw the window if the the scrollbar position has changed + if (ui._scrollHighlight != oldHighlight || oldScrollIndex != _savegameIndex) render(RENDER_NAMES_AND_SCROLLBAR); // TODO } +Common::Rect WidgetFiles::getScrollBarBounds() const { + Common::Rect scrollRect(BUTTON_SIZE, _bounds.height() - _surface.fontHeight() - 16); + scrollRect.moveTo(_bounds.width() - BUTTON_SIZE - 3, _surface.fontHeight() + 13); + + return scrollRect; +} + } // End of namespace Tattoo } // End of namespace Sherlock |