mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
GRAPHICS: MACGUI: Refactor resize() to extract inner window resizing
resize function is extracted to new function resize and resizeInner, also a new private function rebuildSurface is created to handle common code of refreshing/rebuilding surface after modifying inner or outer window dimensions.
This commit is contained in:
parent
84b2442fac
commit
23f1229e67
@ -3183,7 +3183,7 @@ void LB::b_window(int nargs) {
|
||||
Window *window = new Window(wm->getNextId(), false, false, false, wm, g_director, false);
|
||||
window->setName(windowName);
|
||||
window->setTitle(windowName);
|
||||
window->resize(1, 1, true);
|
||||
window->resizeInner(1, 1);
|
||||
window->setVisible(false, true);
|
||||
wm->addWindowInitialized(window);
|
||||
windowList->arr.push_back(window);
|
||||
|
@ -209,7 +209,7 @@ bool Movie::loadArchive() {
|
||||
// If the stage dimensions are different, delete it and start again.
|
||||
// Otherwise, do not clear it so there can be a nice transition.
|
||||
if (_window->getSurface()->w != _movieRect.width() || _window->getSurface()->h != _movieRect.height()) {
|
||||
_window->resize(_movieRect.width(), _movieRect.height(), true);
|
||||
_window->resizeInner(_movieRect.width(), _movieRect.height());
|
||||
recenter = true;
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ Datum Window::getStageRect() {
|
||||
}
|
||||
|
||||
void Window::reset() {
|
||||
resize(_composeSurface->w, _composeSurface->h, true);
|
||||
resizeInner(_composeSurface->w, _composeSurface->h);
|
||||
_contentIsDirty = true;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ void MacTextWindow::init(bool cursorHandler) {
|
||||
}
|
||||
}
|
||||
|
||||
void MacTextWindow::resize(int w, int h, bool inner) {
|
||||
void MacTextWindow::resize(int w, int h) {
|
||||
if (_composeSurface->w == w && _composeSurface->h == h)
|
||||
return;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
MacTextWindow(MacWindowManager *wm, const Font *font, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, MacMenu *menu, bool cursorHandler = true);
|
||||
virtual ~MacTextWindow();
|
||||
|
||||
virtual void resize(int w, int h, bool inner = false) override;
|
||||
virtual void resize(int w, int h) override;
|
||||
void setDimensions(const Common::Rect &r) override;
|
||||
|
||||
virtual bool processEvent(Common::Event &event) override;
|
||||
|
@ -90,20 +90,29 @@ void MacWindow::setActive(bool active) {
|
||||
|
||||
bool MacWindow::isActive() const { return _active; }
|
||||
|
||||
void MacWindow::resize(int w, int h, bool inner) {
|
||||
void MacWindow::resize(int w, int h) {
|
||||
if (_composeSurface->w == w && _composeSurface->h == h)
|
||||
return;
|
||||
|
||||
if (inner) {
|
||||
_innerDims.setWidth(w);
|
||||
_innerDims.setHeight(h);
|
||||
updateOuterDims();
|
||||
} else {
|
||||
_dims.setWidth(w);
|
||||
_dims.setHeight(h);
|
||||
updateInnerDims();
|
||||
}
|
||||
_dims.setWidth(w);
|
||||
_dims.setHeight(h);
|
||||
updateInnerDims();
|
||||
|
||||
rebuildSurface();
|
||||
}
|
||||
|
||||
void MacWindow::resizeInner(int w, int h) {
|
||||
if (_composeSurface->w == w && _composeSurface->h == h)
|
||||
return;
|
||||
|
||||
_innerDims.setWidth(w);
|
||||
_innerDims.setHeight(h);
|
||||
updateOuterDims();
|
||||
|
||||
rebuildSurface();
|
||||
}
|
||||
|
||||
void MacWindow::rebuildSurface() {
|
||||
_composeSurface->free();
|
||||
_composeSurface->create(_innerDims.width(), _innerDims.height(), _wm->_pixelformat);
|
||||
|
||||
|
@ -212,12 +212,18 @@ public:
|
||||
void move(int x, int y);
|
||||
|
||||
/*
|
||||
* Change the width and the height of the window.
|
||||
* Change the width and the height of the window (outer dimensions).
|
||||
* @param w New width of the window.
|
||||
* @param h New height of the window.
|
||||
* @param inner True to set the inner dimensions.
|
||||
*/
|
||||
virtual void resize(int w, int h, bool inner = false);
|
||||
virtual void resize(int w, int h);
|
||||
|
||||
/*
|
||||
* Change the width and the height of the inner window.
|
||||
* @param w New width of the window.
|
||||
* @param h New height of the window.
|
||||
*/
|
||||
virtual void resizeInner(int w, int h);
|
||||
|
||||
/**
|
||||
* Change the dimensions of the window ([0, 0, 0, 0] by default).
|
||||
@ -354,6 +360,7 @@ public:
|
||||
void updateInnerDims();
|
||||
|
||||
private:
|
||||
void rebuildSurface(); // Propagate dimensions change and recreate patter/borders, etc.
|
||||
void drawBorderFromSurface(ManagedSurface *g, uint32 flags);
|
||||
void drawPattern();
|
||||
void drawBox(ManagedSurface *g, int x, int y, int w, int h);
|
||||
|
Loading…
Reference in New Issue
Block a user