WAGE: Basic stuff to MacWindowManager

This commit is contained in:
Eugene Sandulenko 2016-04-13 21:23:02 +02:00
parent f486cddf56
commit b4a3c06d91
4 changed files with 80 additions and 5 deletions

View File

@ -49,7 +49,7 @@
namespace Wage {
MacWindow::MacWindow(WindowType type) : _type(type) {
MacWindow::MacWindow(bool scrollable, int id) : _scrollable(scrollable), _id(id) {
_active = false;
_borderIsDirty = true;
}
@ -69,9 +69,16 @@ void MacWindow::resize(int w, int h) {
_surface.free();
_surface.create(w, h, Graphics::PixelFormat::createFormatCLUT8());
_dims.setWidth(w);
_dims.setHeight(h);
}
void MacWindow::draw(Graphics::Surface *g, int x, int y) {
void MacWindow::move(int x, int y) {
_dims.moveTo(x, y);
}
void MacWindow::draw(Graphics::Surface *g) {
if (_borderIsDirty)
drawBorder();
}

View File

@ -58,10 +58,12 @@ enum WindowType {
};
class MacWindow {
MacWindow(WindowType type);
public:
MacWindow(bool scrollable, int id);
~MacWindow();
void move(int x, int y);
void resize(int w, int h);
void draw(Graphics::Surface *g, int x, int y);
void draw(Graphics::Surface *g);
void setActive(bool active);
Graphics::ManagedSurface *getSurface() { return &_surface; }
@ -71,9 +73,12 @@ private:
private:
Graphics::ManagedSurface _surface;
Graphics::ManagedSurface _borderSurface;
WindowType _type;
bool _scrollable;
int _id;
bool _active;
bool _borderIsDirty;
Common::Rect _dims;
};
} // End of namespace Wage

View File

@ -45,14 +45,60 @@
*
*/
#include "common/list.h"
#include "common/array.h"
#include "graphics/surface.h"
#include "wage/macwindow.h"
#include "wage/macwindowmanager.h"
namespace Wage {
MacWindowManager::MacWindowManager() {
_lastId = 0;
_activeWindow = -1;
}
MacWindowManager::~MacWindowManager() {
for (uint i = 0; i < _lastId; i++)
delete _windows[i];
}
int MacWindowManager::add(bool scrollable) {
MacWindow *w = new MacWindow(scrollable, _lastId);
_windows.push_back(w);
_windowStack.push_back(w);
_activeWindow = _lastId;
_lastId++;
return _activeWindow;
}
void MacWindowManager::setActive(int id) {
if (_activeWindow == id)
return;
if (_activeWindow != -1)
_windows[_activeWindow]->setActive(false);
_windows[id]->setActive(true);
_windowStack.remove(_windows[id]);
_windowStack.push_back(_windows[id]);
_fullRefresh = true;
}
void MacWindowManager::draw(Graphics::Surface *g) {
if (_fullRefresh) {
for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++)
(*it)->draw(g);
} else {
_windowStack.back()->draw(g);
}
}
} // End of namespace Wage

View File

@ -50,9 +50,26 @@
namespace Wage {
class MacWindow;
class MacWindowManager {
public:
MacWindowManager();
~MacWindowManager();
int add(bool scrollable);
void setActive(int id);
void draw(Graphics::Surface *g);
private:
Common::List<MacWindow *> _windowStack;
Common::Array<MacWindow *> _windows;
int _lastId;
int _activeWindow;
bool _fullRefresh;
};
} // End of namespace Wage