From b7c2c345e318e1d359b0ce64c8b2d898e37b5e73 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 8 Jul 2015 19:10:42 -0400 Subject: SHERLOCK: RT: Fix display of tooltips in scrolled scenes --- engines/sherlock/tattoo/widget_base.cpp | 8 ++++---- engines/sherlock/tattoo/widget_tooltip.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp index cdebe698aa..905dd31be0 100644 --- a/engines/sherlock/tattoo/widget_base.cpp +++ b/engines/sherlock/tattoo/widget_base.cpp @@ -143,12 +143,12 @@ Common::String WidgetBase::splitLines(const Common::String &str, Common::StringA void WidgetBase::restrictToScreen() { Screen &screen = *_vm->_screen; - if (_bounds.left < 0) - _bounds.moveTo(0, _bounds.top); + if (_bounds.left < screen._currentScroll.x) + _bounds.moveTo(screen._currentScroll.x, _bounds.top); if (_bounds.top < 0) _bounds.moveTo(_bounds.left, 0); - if (_bounds.right > screen._backBuffer1.w()) - _bounds.moveTo(screen._backBuffer1.w() - _bounds.width(), _bounds.top); + if (_bounds.right > SHERLOCK_SCENE_WIDTH) + _bounds.moveTo(SHERLOCK_SCENE_WIDTH - _bounds.width(), _bounds.top); if (_bounds.bottom > SHERLOCK_SCREEN_HEIGHT) _bounds.moveTo(_bounds.left, SHERLOCK_SCREEN_HEIGHT - _bounds.height()); } diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp index 7e211bbe9f..b1c13c7a29 100644 --- a/engines/sherlock/tattoo/widget_tooltip.cpp +++ b/engines/sherlock/tattoo/widget_tooltip.cpp @@ -39,6 +39,8 @@ void WidgetTooltipBase::draw() { erase(); if (_bounds.width() > 0 && !_surface.empty()) { + restrictToScreen(); + // Blit the affected area to the screen screen.slamRect(_bounds); @@ -140,8 +142,8 @@ void WidgetTooltip::setText(const Common::String &str) { } // Set the initial display position for the tooltip text - int tagX = CLIP(mousePos.x - width / 2, 0, SHERLOCK_SCREEN_WIDTH - width); - int tagY = MAX(mousePos.y - height, 0); + int tagX = mousePos.x - width / 2; + int tagY = mousePos.y - height; _bounds = Common::Rect(tagX, tagY, tagX + width, tagY + height); } else { @@ -158,8 +160,8 @@ void WidgetTooltip::handleEvents() { Common::Point mousePos = events.mousePos(); // Set the new position for the tooltip - int xp = CLIP(mousePos.x - _bounds.width() / 2, 0, SHERLOCK_SCREEN_WIDTH - _bounds.width()); - int yp = MAX(mousePos.y - _bounds.height(), 0); + int xp = mousePos.x - _bounds.width() / 2; + int yp = mousePos.y - _bounds.height(); _bounds.moveTo(xp, yp); } -- cgit v1.2.3