aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp2
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h4
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp42
-rw-r--r--engines/sherlock/tattoo/widget_base.h6
-rw-r--r--engines/sherlock/tattoo/widget_inventory.cpp2
-rw-r--r--engines/sherlock/tattoo/widget_talk.cpp11
-rw-r--r--engines/sherlock/tattoo/widget_talk.h1
7 files changed, 58 insertions, 10 deletions
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 2179dd132c..12cf4aec6d 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -45,7 +45,7 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm),
_activeObj = -1;
_cAnimFramePause = 0;
_widget = nullptr;
- _scrollHighlight = 0;
+ _scrollHighlight = SH_NONE;
_mask = _mask1 = nullptr;
_maskCounter = 0;
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index baf5cdcf25..8027a203b4 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -40,6 +40,8 @@ namespace Tattoo {
class WidgetBase;
+enum ScrollHighlight { SH_NONE = 0, SH_SCROLL_UP = 1, SH_PAGE_UP = 2, SH_THUMBNAIL = 3, SH_PAGE_DOWN = 4, SH_SCROLL_DOWN = 5 };
+
class TattooUserInterface : public UserInterface {
friend class WidgetBase;
private:
@@ -110,7 +112,7 @@ public:
int _activeObj;
Common::KeyState _keyState;
Common::Point _lookPos;
- int _scrollHighlight;
+ ScrollHighlight _scrollHighlight;
ImageFile *_mask, *_mask1;
Common::Point _maskOffset;
int _maskCounter;
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index c33e9017d2..f958e42774 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -30,6 +30,7 @@ namespace Sherlock {
namespace Tattoo {
WidgetBase::WidgetBase(SherlockEngine *vm) : _vm(vm) {
+ _scroll = false;
}
void WidgetBase::summonWindow() {
@@ -204,7 +205,6 @@ const Common::Point &WidgetBase::getCurrentScroll() const {
void WidgetBase::checkTabbingKeys(int numOptions) {
}
-
void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
bool raised;
@@ -256,6 +256,46 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true);
}
+void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count) {
+ Events &events = *_vm->_events;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ Common::Point mousePos = events.mousePos();
+
+ // If they have selected the sollbar, return with the Scroll Bar Still selected
+ if (ui._scrollHighlight == 3)
+ return;
+
+ ui._scrollHighlight = SH_NONE;
+
+ if ((!events._pressed && !events._rightReleased) || !_scroll)
+ return;
+
+ Common::Rect r(_bounds.right - BUTTON_SIZE - 3, _bounds.top, _bounds.right - 3, _bounds.bottom - 6);
+
+ // Calculate the Scroll Position bar
+ int barHeight = pageSize * (r.height() - BUTTON_SIZE * 2) / count;
+ barHeight = CLIP(barHeight, BUTTON_SIZE, r.height() - BUTTON_SIZE * 2);
+
+ int barY = (count <= pageSize) ? 3 + BUTTON_SIZE : (r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER
+ / (count - pageSize) * index / FIXED_INT_MULTIPLIER + 3 + BUTTON_SIZE;
+
+ if (Common::Rect(r.left, r.top + 3, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE + 3).contains(mousePos))
+ // Mouse on scroll up button
+ ui._scrollHighlight = SH_SCROLL_UP;
+ else if (Common::Rect(r.left, r.top + BUTTON_SIZE + 3, r.left + BUTTON_SIZE, barY - BUTTON_SIZE - 3).contains(mousePos))
+ // Mouse on paging up area (the area of the vertical bar above the thumbnail)
+ ui._scrollHighlight = SH_PAGE_UP;
+ else if (Common::Rect(r.left, r.top + barY, r.left + BUTTON_SIZE, r.top + barY + barHeight).contains(mousePos))
+ // Mouse on scrollbar thumb
+ ui._scrollHighlight = SH_THUMBNAIL;
+ else if (Common::Rect(r.left, r.top + barY + barHeight, r.left + BUTTON_SIZE, r.bottom - BUTTON_SIZE + 3).contains(mousePos))
+ // Mouse on paging down area (the area of the vertical bar below the thumbnail)
+ ui._scrollHighlight = SH_PAGE_DOWN;
+ else if (Common::Rect(r.left, r.bottom - BUTTON_SIZE + 3, r.left + BUTTON_SIZE, r.bottom).contains(mousePos))
+ // Mouse on scroll down button
+ ui._scrollHighlight = SH_SCROLL_DOWN;
+}
+
} // End of namespace Tattoo
} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
index 67a8332397..a6c11bdb64 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -42,6 +42,7 @@ protected:
Common::Rect _oldBounds;
Surface _surface;
bool _outsideMenu;
+ bool _scroll;
/**
* Used by descendent classes to split up long text for display across multiple lines
@@ -69,6 +70,11 @@ protected:
void drawScrollBar(int index, int pageSize, int count);
/**
+ * Handles any events when the mouse is on the scrollbar
+ */
+ void handleScrollbarEvents(int index, int pageSize, int count);
+
+ /**
* Returns the current scroll position
*/
virtual const Common::Point &getCurrentScroll() const;
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index bc2ae66ea0..3d43dbe90f 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -379,7 +379,7 @@ void WidgetInventory::handleEvents() {
// See if they released a mouse button button
if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
_dialogTimer = -1;
- ui._scrollHighlight = 0;
+ ui._scrollHighlight = SH_NONE;
// See if they have a Verb List open for an Inventry Item
if (_invVerbMode == 1) {
diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp
index bfbf10e24f..e53a3d8170 100644
--- a/engines/sherlock/tattoo/widget_talk.cpp
+++ b/engines/sherlock/tattoo/widget_talk.cpp
@@ -35,7 +35,6 @@ namespace Tattoo {
#define VISIBLE_TALK_LINES 6
WidgetTalk::WidgetTalk(SherlockEngine *vm) : WidgetBase(vm) {
- _talkScroll = false;
_talkScrollIndex = 0;
_selector = _oldSelector = -1;
_talkTextX = 0;
@@ -71,12 +70,12 @@ void WidgetTalk::getTalkWindowSize() {
// Make sure that the window does not get too big
if (numLines < 7) {
height = (_surface.fontHeight() + 1) * numLines + 9;
- _talkScroll = false;
+ _scroll = false;
} else {
// Set up the height to a constrained amount, and add extra width for the scrollbar
width += BUTTON_SIZE + 3;
height = (_surface.fontHeight() + 1) * 6 + 9;
- _talkScroll = false;
+ _scroll = false;
}
_bounds = Common::Rect(width, height);
@@ -129,7 +128,7 @@ void WidgetTalk::load() {
makeInfoArea();
// If a scrollbar is needed, draw it in
- if (_talkScroll) {
+ if (_scroll) {
int xp = _surface.w() - BUTTON_SIZE - 6;
_surface.vLine(xp, 3, _surface.h() - 4, INFO_TOP);
_surface.vLine(xp + 1, 3, _surface.h() - 4, INFO_MIDDLE);
@@ -140,6 +139,8 @@ void WidgetTalk::load() {
}
void WidgetTalk::handleEvents() {
+ handleScrollbarEvents(_talkScrollIndex, VISIBLE_TALK_LINES, _statementLines.size());
+
// TODO
}
@@ -189,7 +190,7 @@ void WidgetTalk::render(Highlight highlightMode) {
}
// See if the scroll bar needs to be drawn
- if (_talkScroll && highlightMode != HL_CHANGED_HIGHLIGHTS)
+ if (_scroll && highlightMode != HL_CHANGED_HIGHLIGHTS)
drawScrollBar(_talkScrollIndex, VISIBLE_TALK_LINES, _statementLines.size());
}
diff --git a/engines/sherlock/tattoo/widget_talk.h b/engines/sherlock/tattoo/widget_talk.h
index c399f2f4c5..72a6441a4e 100644
--- a/engines/sherlock/tattoo/widget_talk.h
+++ b/engines/sherlock/tattoo/widget_talk.h
@@ -43,7 +43,6 @@ class WidgetTalk: public WidgetBase {
int _num;
};
private:
- bool _talkScroll;
int _talkScrollIndex;
Common::Array<StatementLine> _statementLines;
int _selector, _oldSelector;