GRAPHICS: MACGUI: Don't draw border over contents
This commit is contained in:
parent
6744b550ab
commit
d8725510b6
5 changed files with 40 additions and 17 deletions
|
@ -99,7 +99,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 (_stage->getSurface()->w != _movieRect.width() || _stage->getSurface()->h != _movieRect.height()) {
|
||||
_stage->resize(_movieRect.width(), _movieRect.height());
|
||||
_stage->resize(_movieRect.width(), _movieRect.height(), true);
|
||||
}
|
||||
// TODO: Add more options for desktop dimensions
|
||||
uint16 windowWidth = debugChannelSet(-1, kDebugDesktop) ? 1024 : _movieRect.width();
|
||||
|
|
|
@ -111,7 +111,7 @@ void Stage::reset() {
|
|||
|
||||
void Stage::addDirtyRect(const Common::Rect &r) {
|
||||
Common::Rect bounds = r;
|
||||
Common::Rect clip = _dims;
|
||||
Common::Rect clip = _innerDims;
|
||||
clip.moveTo(0, 0);
|
||||
bounds.clip(clip);
|
||||
|
||||
|
@ -222,7 +222,7 @@ void Stage::inkBlitSurface(DirectorPlotData *pd, Common::Rect &srcRect, const Gr
|
|||
}
|
||||
|
||||
Common::Point Stage::getMousePos() {
|
||||
return g_system->getEventManager()->getMousePos() - Common::Point(_dims.left, _dims.top);
|
||||
return g_system->getEventManager()->getMousePos() - Common::Point(_innerDims.left, _innerDims.top);
|
||||
}
|
||||
|
||||
bool Stage::step() {
|
||||
|
|
|
@ -188,7 +188,7 @@ void Stage::playTransition(uint16 transDuration, uint8 transArea, uint8 transChu
|
|||
g_director->getCurrentMovie()->getScore()->renderSprites(t.frame, kRenderForceUpdate);
|
||||
render(true, nextFrame);
|
||||
|
||||
clipRect = _dims;
|
||||
clipRect = _innerDims;
|
||||
clipRect.moveTo(0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,25 +107,30 @@ void MacWindow::setActive(bool active) {
|
|||
|
||||
bool MacWindow::isActive() { return _active; }
|
||||
|
||||
void MacWindow::resize(int w, int h) {
|
||||
void MacWindow::resize(int w, int h, bool inner) {
|
||||
if (_surface.w == w && _surface.h == h)
|
||||
return;
|
||||
|
||||
if (inner) {
|
||||
_innerDims.setWidth(w);
|
||||
_innerDims.setHeight(h);
|
||||
updateOuterDims();
|
||||
} else {
|
||||
_dims.setWidth(w);
|
||||
_dims.setHeight(h);
|
||||
updateInnerDims();
|
||||
}
|
||||
|
||||
_surface.free();
|
||||
_surface.create(w, h, PixelFormat::createFormatCLUT8());
|
||||
_surface.create(_innerDims.width(), _innerDims.height(), PixelFormat::createFormatCLUT8());
|
||||
|
||||
if (_hasPattern)
|
||||
drawPattern();
|
||||
|
||||
_borderSurface.free();
|
||||
_borderSurface.create(w, h, PixelFormat::createFormatCLUT8());
|
||||
_borderSurface.create(_dims.width(), _dims.height(), PixelFormat::createFormatCLUT8());
|
||||
_composeSurface->free();
|
||||
_composeSurface->create(w, h, PixelFormat::createFormatCLUT8());
|
||||
|
||||
_dims.setWidth(w);
|
||||
_dims.setHeight(h);
|
||||
|
||||
updateInnerDims();
|
||||
_composeSurface->create(_dims.width(), _dims.height(), PixelFormat::createFormatCLUT8());
|
||||
|
||||
_contentIsDirty = true;
|
||||
_borderIsDirty = true;
|
||||
|
@ -166,7 +171,7 @@ bool MacWindow::draw(bool forceRedraw) {
|
|||
_contentIsDirty = false;
|
||||
|
||||
// Compose
|
||||
_composeSurface->blitFrom(_surface, Common::Rect(0, 0, _surface.w - 2, _surface.h - 2), Common::Point(2, 2));
|
||||
_composeSurface->blitFrom(_surface, Common::Rect(0, 0, _surface.w, _surface.h), Common::Point(_innerDims.left - _dims.left, _innerDims.top - _dims.top));
|
||||
_composeSurface->transBlitFrom(_borderSurface, kColorGreen);
|
||||
|
||||
return true;
|
||||
|
@ -176,7 +181,7 @@ bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
|
|||
if (!draw(forceRedraw))
|
||||
return false;
|
||||
|
||||
g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
|
||||
g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), Common::Point(_dims.left, _dims.top), kColorGreen2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -211,6 +216,22 @@ void MacWindow::updateInnerDims() {
|
|||
}
|
||||
}
|
||||
|
||||
void MacWindow::updateOuterDims() {
|
||||
if (_innerDims.isEmpty())
|
||||
return;
|
||||
|
||||
if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
|
||||
_dims = Common::Rect(
|
||||
_innerDims.left - _macBorder.getOffset().left,
|
||||
_innerDims.top - _macBorder.getOffset().top,
|
||||
_innerDims.right + _macBorder.getOffset().right,
|
||||
_innerDims.bottom + _macBorder.getOffset().bottom);
|
||||
} else {
|
||||
_dims = _innerDims;
|
||||
_dims.grow(kBorderWidth);
|
||||
}
|
||||
}
|
||||
|
||||
void MacWindow::drawBorder() {
|
||||
_borderIsDirty = false;
|
||||
|
||||
|
|
|
@ -173,8 +173,9 @@ public:
|
|||
* Change the width and the height of the window.
|
||||
* @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);
|
||||
virtual void resize(int w, int h, bool inner = false);
|
||||
|
||||
/**
|
||||
* Change the dimensions of the window ([0, 0, 0, 0] by default).
|
||||
|
@ -274,6 +275,7 @@ private:
|
|||
void fillRect(ManagedSurface *g, int x, int y, int w, int h, int color);
|
||||
const Font *getTitleFont();
|
||||
void updateInnerDims();
|
||||
void updateOuterDims();
|
||||
|
||||
bool isInCloseButton(int x, int y);
|
||||
bool isInResizeButton(int x, int y);
|
||||
|
@ -287,6 +289,7 @@ protected:
|
|||
ManagedSurface _borderSurface;
|
||||
|
||||
bool _borderIsDirty;
|
||||
Common::Rect _innerDims;
|
||||
|
||||
private:
|
||||
MacWindowBorder _macBorder;
|
||||
|
@ -300,7 +303,6 @@ private:
|
|||
bool _closeable;
|
||||
|
||||
int _borderWidth;
|
||||
Common::Rect _innerDims;
|
||||
|
||||
bool _beingDragged, _beingResized;
|
||||
int _draggedX, _draggedY;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue