aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/macwindow.cpp46
-rw-r--r--engines/wage/macwindow.h3
-rw-r--r--engines/wage/macwindowmanager.cpp9
3 files changed, 48 insertions, 10 deletions
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index e517b7230b..490ab9e886 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -90,11 +90,15 @@ void MacWindow::resize(int w, int h) {
void MacWindow::move(int x, int y) {
_dims.moveTo(x, y);
+
+ _innerDims.setWidth(0); // Invalidate rect
}
void MacWindow::setDimensions(const Common::Rect &r) {
resize(r.width(), r.height());
_dims.moveTo(r.left, r.top);
+
+ _innerDims.setWidth(0); // Invalidate rect
}
bool MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
@@ -144,6 +148,11 @@ static void drawPixelInverted(int x, int y, int color, void *data) {
void MacWindow::drawBorder() {
_borderIsDirty = false;
+ if (_innerDims.isEmpty()) {
+ _innerDims = _dims;
+ _innerDims.grow(-kBorderWidth);
+ }
+
bool active = _active, scrollable = _scrollable, closeable = _active, drawTitle = !_title.empty();
const int size = kBorderWidth;
int x = 0;
@@ -235,8 +244,43 @@ void MacWindow::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h
g->fillRect(r, color);
}
-WindowClick MacWindow::mouseDown(int x, int y) {
+static WindowClick isInBorder(Common::Rect &rect, int x, int y) {
+ if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top)
+ return kBorderCloseButton;
+
+ if (x >= rect.right && x < rect.right + kBorderWidth) {
+ if (y < rect.top - kBorderWidth)
+ return kBorderNone;
+
+ if (y >= rect.bottom + kBorderWidth)
+ return kBorderNone;
+
+ if (y >= rect.top + rect.height() / 2)
+ return kBorderScrollDown;
+
+ return kBorderScrollUp;
+ }
+
return kBorderNone;
}
+void MacWindow::mouseDown(int x, int y) {
+ if (_innerDims.contains(x, y)) {
+ // (*callback)(x - _dims.left, y - dims.top);
+ return;
+ }
+
+ WindowClick click = isInBorder(_innerDims, x, y);
+
+ if (click == kBorderNone)
+ return;
+
+ setHighlight(click);
+
+ if (click == kBorderScrollUp || click == kBorderScrollDown) {
+ // TODO
+ }
+
+}
+
} // End of namespace Wage
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index c47675ef83..73984b0f34 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -85,7 +85,7 @@ public:
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
- WindowClick mouseDown(int x, int y);
+ void mouseDown(int x, int y);
private:
void drawBorder();
@@ -108,6 +108,7 @@ private:
float _scrollPos, _scrollSize;
Common::Rect _dims;
+ Common::Rect _innerDims;
Common::String _title;
};
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 61beca8d4d..08c8a4df3a 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -122,14 +122,7 @@ bool MacWindowManager::mouseDown(int x, int y) {
if (w->getDimensions().contains(x, y)) {
setActive(w->getId());
-
- WindowClick click = w->mouseDown(x, y);
-
- if (click == kBorderInner) {
-
- } else {
- w->setHighlight(click);
- }
+ w->mouseDown(x, y);
return true;
}