Skip to content

Commit

Permalink
SHERLOCK: RT: Fix display of scrollbar in the talk window
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 16, 2015
1 parent 20d122b commit f4bd1b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
11 changes: 3 additions & 8 deletions engines/sherlock/tattoo/widget_base.cpp
Expand Up @@ -218,7 +218,7 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
_surface.fillRect(Common::Rect(r.right / 2 - 3, r.top + 1 + BUTTON_SIZE / 2,
r.right / 2 + 3, r.top + 1 + BUTTON_SIZE / 2), color);

color = (index + NUM_INVENTORY_SHOWN) < count ? INFO_BOTTOM + 2 : INFO_BOTTOM;
color = (index + pageSize) < count ? INFO_BOTTOM + 2 : INFO_BOTTOM;
_surface.fillRect(Common::Rect(r.right / 2 - 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2,
r.right / 2 + 3, r.bottom - 1 - BUTTON_SIZE + BUTTON_SIZE / 2), color);
_surface.fillRect(Common::Rect(r.right / 2 - 2, r.bottom - 1 - BUTTON_SIZE + 1 + BUTTON_SIZE / 2,
Expand All @@ -229,15 +229,10 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color);

// Draw the scroll position bar
int idx = count;
if (idx % (NUM_INVENTORY_SHOWN / 2))
idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2);
int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx;
int barHeight = (_bounds.height() - BUTTON_SIZE * 2) * pageSize / count;
barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);
int barY = (r.height() - BUTTON_SIZE * 2 - barHeight) * index / pageSize + r.top + BUTTON_SIZE;

int barY = (idx<= NUM_INVENTORY_SHOWN) ? r.top + BUTTON_SIZE :
(r.height() - BUTTON_SIZE * 2 - barHeight) * FIXED_INT_MULTIPLIER / (idx- NUM_INVENTORY_SHOWN)
* index / FIXED_INT_MULTIPLIER + r.top + BUTTON_SIZE;
_surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE);
ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true);
}
Expand Down
20 changes: 1 addition & 19 deletions engines/sherlock/tattoo/widget_talk.cpp
Expand Up @@ -78,18 +78,10 @@ void WidgetTalk::getTalkWindowSize() {
// 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;
_scroll = false;
_scroll = true;
}

_bounds = Common::Rect(width, height);

// Allocate a surface for the window
_surface.create(_bounds.width(), _bounds.height());
_surface.fill(TRANSPARENCY);

// Form the background for the new window
makeInfoArea();
render(HL_CHANGED_HIGHLIGHTS);
}

void WidgetTalk::load() {
Expand Down Expand Up @@ -124,16 +116,6 @@ void WidgetTalk::load() {

// Form the background for the new window
makeInfoArea();

// If a scrollbar is needed, draw it in
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);
_surface.vLine(xp + 2, 3, _surface.h() - 4, INFO_BOTTOM);
_surface.transBlitFrom(images[6], Common::Point(xp - 1, 1));
_surface.transBlitFrom(images[7], Common::Point(xp - 1, _surface.h() - 4));
}
}

void WidgetTalk::handleEvents() {
Expand Down

0 comments on commit f4bd1b5

Please sign in to comment.