mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 19:32:11 +00:00
WAGE: Manage window redraws in the WM
This commit is contained in:
parent
56a20ef926
commit
024d1305a2
@ -154,6 +154,8 @@ Gui::Gui(WageEngine *engine) {
|
|||||||
_consoleFullRedraw = true;
|
_consoleFullRedraw = true;
|
||||||
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
|
_screen.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
|
||||||
|
|
||||||
|
_wm.setScreen(&_screen);
|
||||||
|
|
||||||
_scrollPos = 0;
|
_scrollPos = 0;
|
||||||
_consoleLineHeight = 8; // Dummy value which makes sense
|
_consoleLineHeight = 8; // Dummy value which makes sense
|
||||||
_consoleNumLines = 24; // Dummy value
|
_consoleNumLines = 24; // Dummy value
|
||||||
@ -287,6 +289,7 @@ void Gui::drawScene() {
|
|||||||
w->setTitle(_scene->_name);
|
w->setTitle(_scene->_name);
|
||||||
_scene->paint(w->getSurface(), 0, 0);
|
_scene->paint(w->getSurface(), 0, 0);
|
||||||
w->draw(&_screen);
|
w->draw(&_screen);
|
||||||
|
w->setDirty(true);
|
||||||
g_system->copyRectToScreen(_screen.getBasePtr(_scene->_designBounds->left - 2, _scene->_designBounds->top - 2),
|
g_system->copyRectToScreen(_screen.getBasePtr(_scene->_designBounds->left - 2, _scene->_designBounds->top - 2),
|
||||||
_screen.pitch, _scene->_designBounds->left - 2, _scene->_designBounds->top - 2,
|
_screen.pitch, _scene->_designBounds->left - 2, _scene->_designBounds->top - 2,
|
||||||
_scene->_designBounds->width(), _scene->_designBounds->height());
|
_scene->_designBounds->width(), _scene->_designBounds->height());
|
||||||
@ -317,6 +320,7 @@ void Gui::drawConsole() {
|
|||||||
renderConsole(w->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2,
|
renderConsole(w->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2,
|
||||||
_scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth));
|
_scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth));
|
||||||
w->draw(&_screen);
|
w->draw(&_screen);
|
||||||
|
w->setDirty(true);
|
||||||
g_system->copyRectToScreen(_screen.getBasePtr(_scene->_textBounds->left - 2, _scene->_textBounds->top - 2),
|
g_system->copyRectToScreen(_screen.getBasePtr(_scene->_textBounds->left - 2, _scene->_textBounds->top - 2),
|
||||||
_screen.pitch, _scene->_textBounds->left - 2, _scene->_textBounds->top - 2,
|
_screen.pitch, _scene->_textBounds->left - 2, _scene->_textBounds->top - 2,
|
||||||
_scene->_textBounds->width(), _scene->_textBounds->height());
|
_scene->_textBounds->width(), _scene->_textBounds->height());
|
||||||
|
@ -97,7 +97,10 @@ void MacWindow::setDimensions(const Common::Rect &r) {
|
|||||||
_dims.moveTo(r.left, r.top);
|
_dims.moveTo(r.left, r.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
|
bool MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
|
||||||
|
if (!_borderIsDirty && !_contentIsDirty && !forceRedraw)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (_borderIsDirty || forceRedraw)
|
if (_borderIsDirty || forceRedraw)
|
||||||
drawBorder();
|
drawBorder();
|
||||||
|
|
||||||
@ -106,6 +109,8 @@ void MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
|
|||||||
_composeSurface.transBlitFrom(_borderSurface, kColorGreen);
|
_composeSurface.transBlitFrom(_borderSurface, kColorGreen);
|
||||||
|
|
||||||
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
|
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Graphics::Font *MacWindow::getTitleFont() {
|
const Graphics::Font *MacWindow::getTitleFont() {
|
||||||
|
@ -75,12 +75,14 @@ public:
|
|||||||
void move(int x, int y);
|
void move(int x, int y);
|
||||||
void resize(int w, int h);
|
void resize(int w, int h);
|
||||||
void setDimensions(const Common::Rect &r);
|
void setDimensions(const Common::Rect &r);
|
||||||
void draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
|
const Common::Rect &getDimensions() { return _dims; }
|
||||||
|
bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
|
||||||
void setActive(bool active);
|
void setActive(bool active);
|
||||||
Graphics::ManagedSurface *getSurface() { return &_surface; }
|
Graphics::ManagedSurface *getSurface() { return &_surface; }
|
||||||
void setTitle(Common::String &title) { _title = title; }
|
void setTitle(Common::String &title) { _title = title; }
|
||||||
void setHighlight(BorderHighlight highlightedPart) { _highlightedPart = highlightedPart; }
|
void setHighlight(BorderHighlight highlightedPart) { _highlightedPart = highlightedPart; }
|
||||||
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
|
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
|
||||||
|
void setDirty(bool dirty) { _contentIsDirty = dirty; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawBorder();
|
void drawBorder();
|
||||||
@ -96,6 +98,7 @@ private:
|
|||||||
bool _scrollable;
|
bool _scrollable;
|
||||||
bool _active;
|
bool _active;
|
||||||
bool _borderIsDirty;
|
bool _borderIsDirty;
|
||||||
|
bool _contentIsDirty;
|
||||||
|
|
||||||
BorderHighlight _highlightedPart;
|
BorderHighlight _highlightedPart;
|
||||||
float _scrollPos, _scrollSize;
|
float _scrollPos, _scrollSize;
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
#include "common/system.h"
|
||||||
|
|
||||||
#include "graphics/managed_surface.h"
|
#include "graphics/managed_surface.h"
|
||||||
|
|
||||||
@ -57,6 +58,7 @@
|
|||||||
namespace Wage {
|
namespace Wage {
|
||||||
|
|
||||||
MacWindowManager::MacWindowManager() {
|
MacWindowManager::MacWindowManager() {
|
||||||
|
_screen = 0;
|
||||||
_lastId = 0;
|
_lastId = 0;
|
||||||
_activeWindow = -1;
|
_activeWindow = -1;
|
||||||
}
|
}
|
||||||
@ -94,9 +96,19 @@ void MacWindowManager::setActive(int id) {
|
|||||||
_fullRefresh = true;
|
_fullRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacWindowManager::draw(Graphics::ManagedSurface *g) {
|
void MacWindowManager::draw() {
|
||||||
for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++)
|
assert(_screen);
|
||||||
(*it)->draw(g, _fullRefresh);
|
|
||||||
|
for (Common::List<MacWindow *>::const_iterator it = _windowStack.begin(); it != _windowStack.end(); it++) {
|
||||||
|
MacWindow *w = *it;
|
||||||
|
if (w->draw(_screen, _fullRefresh)) {
|
||||||
|
w->setDirty(false);
|
||||||
|
|
||||||
|
g_system->copyRectToScreen(_screen->getBasePtr(w->getDimensions().left - 2, w->getDimensions().top - 2),
|
||||||
|
_screen->pitch, w->getDimensions().left - 2, w->getDimensions().top - 2,
|
||||||
|
w->getDimensions().width(), w->getDimensions().height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_fullRefresh = false;
|
_fullRefresh = false;
|
||||||
}
|
}
|
||||||
|
@ -57,14 +57,18 @@ public:
|
|||||||
MacWindowManager();
|
MacWindowManager();
|
||||||
~MacWindowManager();
|
~MacWindowManager();
|
||||||
|
|
||||||
|
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
|
||||||
|
|
||||||
int add(bool scrollable);
|
int add(bool scrollable);
|
||||||
void setActive(int id);
|
void setActive(int id);
|
||||||
|
|
||||||
void draw(Graphics::ManagedSurface *g);
|
void draw();
|
||||||
|
|
||||||
MacWindow *getWindow(int id) { return _windows[id]; }
|
MacWindow *getWindow(int id) { return _windows[id]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Graphics::ManagedSurface *_screen;
|
||||||
|
|
||||||
Common::List<MacWindow *> _windowStack;
|
Common::List<MacWindow *> _windowStack;
|
||||||
Common::Array<MacWindow *> _windows;
|
Common::Array<MacWindow *> _windows;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user