Skip to content

Commit

Permalink
WAGE: Started mouse processing in the WM
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Apr 19, 2016
1 parent e5a64e7 commit e6c5c96
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions engines/wage/gui.cpp
Expand Up @@ -645,6 +645,8 @@ Designed *Gui::mouseUp(int x, int y) {
void Gui::mouseDown(int x, int y) {
int borderClick;

_wm.mouseDown(x, y);

if (_menu->mouseClick(x, y)) {
_menuDirty = true;
} else if (_consoleTextArea.contains(x, y)) {
Expand Down
6 changes: 5 additions & 1 deletion engines/wage/macwindow.cpp
Expand Up @@ -53,7 +53,7 @@

namespace Wage {

MacWindow::MacWindow(bool scrollable) : _scrollable(scrollable) {
MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id) {
_active = false;
_borderIsDirty = true;

Expand Down Expand Up @@ -235,4 +235,8 @@ 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) {
return kBorderNone;
}

} // End of namespace Wage
14 changes: 9 additions & 5 deletions engines/wage/macwindow.h
Expand Up @@ -61,16 +61,17 @@ enum {
kBorderWidth = 17
};

enum BorderHighlight {
enum WindowClick {
kBorderNone = 0,
kBorderScrollUp,
kBorderScrollDown,
kBorderCloseButton
kBorderCloseButton,
kBorderInner
};

class MacWindow {
public:
MacWindow(bool scrollable);
MacWindow(int id, bool scrollable);
~MacWindow();
void move(int x, int y);
void resize(int w, int h);
Expand All @@ -80,9 +81,11 @@ class MacWindow {
void setActive(bool active);
Graphics::ManagedSurface *getSurface() { return &_surface; }
void setTitle(Common::String &title) { _title = title; }
void setHighlight(BorderHighlight highlightedPart) { _highlightedPart = highlightedPart; }
void setHighlight(WindowClick highlightedPart) { _highlightedPart = highlightedPart; }
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);

private:
void drawBorder();
Expand All @@ -99,8 +102,9 @@ class MacWindow {
bool _active;
bool _borderIsDirty;
bool _contentIsDirty;
int _id;

BorderHighlight _highlightedPart;
WindowClick _highlightedPart;
float _scrollPos, _scrollSize;

Common::Rect _dims;
Expand Down
25 changes: 24 additions & 1 deletion engines/wage/macwindowmanager.cpp
Expand Up @@ -69,7 +69,7 @@ MacWindowManager::~MacWindowManager() {
}

int MacWindowManager::add(bool scrollable) {
MacWindow *w = new MacWindow(scrollable);
MacWindow *w = new MacWindow(_lastId, scrollable);

_windows.push_back(w);
_windowStack.push_back(w);
Expand Down Expand Up @@ -113,4 +113,27 @@ void MacWindowManager::draw() {
_fullRefresh = false;
}

bool MacWindowManager::mouseDown(int x, int y) {
for (Common::List<MacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) {
it--;
MacWindow *w = *it;

if (w->getDimensions().contains(x, y)) {
setActive(w->getId());

WindowClick click = w->mouseDown(x, y);

if (click == kBorderInner) {

} else {
w->setHighlight(click);
}

return true;
}
}

return false;
}

} // End of namespace Wage
2 changes: 2 additions & 0 deletions engines/wage/macwindowmanager.h
Expand Up @@ -66,6 +66,8 @@ class MacWindowManager {

void draw();

bool mouseDown(int x, int y);

MacWindow *getWindow(int id) { return _windows[id]; }

private:
Expand Down

0 comments on commit e6c5c96

Please sign in to comment.