[Scummvm-git-logs] scummvm master -> 3b47e56155258ec6e4a3d624955127d11c175809
sev-
sev at scummvm.org
Mon Apr 12 12:04:41 UTC 2021
This automated email contains information about 19 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
179654939e GRAPHICS: add title to 9-patch image
8894317e89 GRAPHICS: MACGUI: add titleIndex and titleWidth to macborder in order suit to 9-patch
1f3f8f55a8 WAGE: add title to wage border
9298eba78d GRAPHICS: MACGUI: remove the check that is not needed
307147c565 GRAPHICS: MACGUI: use titlePos to calc titleIndex, change the titleWidth in 9-patch when title is changed
6d7e794ed3 GRAPHICS: MACGUI: Add flag to indicate the border type, move drawTitle and drawScrollBar into macwindowborder
858624c0c9 GRAPHICS: MACGUI: fix the bug of the border flag is not correctly initialized
a0964d690c GRAPHICS: MACGUI: Add border flags to the builtin border types, fix the remaining part of macgui which are not adapt to
83341beddd GRAPHICS: MACGUI: modify the way that setBorderType set the border, currently, it will set all borders which is the subs
aeacf0d4d2 GRAPHICS: MACGUI: modify the position where it draws the title, currently, it will draw title at the center of title box
c2353d3797 GRAPHICS: MACGUI: use lazy load to load built-in border types, add scrollbar flag to indicate whether the window has scr
7ea12368cf WAGE: set scrollbar of consoleWindow true, to suit for new logic in macgui
7f47b9f6c0 GRAPHICS: MACGUI: move border stuff into macwindowborder
3b53a4f2f7 GRAPHICS: MACGUI: move titlePos into BorderOffsets
dc2861dbed GRAPHICS: MACGUI: fix the bug when we calc the 9-patch offset
b8f8fdbf19 GRAPHICS: MACGUI: make title color depend on the border color
39b84a1574 GRAPHICS: MACGUI: modify the titlePos in datafiles
0d825ef4de GRAPHICS: MACGUI: add title for 9-patch images of build-in borders
3b47e56155 GRAPHICS: MACGUI: clean the codes
Commit: 179654939e54c4fd957b6bd81fb40bb5509cf1cb
https://github.com/scummvm/scummvm/commit/179654939e54c4fd957b6bd81fb40bb5509cf1cb
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: add title to 9-patch image
Changed paths:
graphics/nine_patch.cpp
graphics/nine_patch.h
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 6e74d4f464..6616eff9fc 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -61,11 +61,12 @@ NinePatchSide::~NinePatchSide() {
}
-bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical) {
+bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int titleIndex, int titleWidth) {
const uint len = vertical ? bmp->h : bmp->w;
uint i;
int s, t, z;
+ int index = 0;
_m.clear();
for (i = 1, s = -1, t = 0, z = -1; i < len; ++i) {
@@ -97,7 +98,10 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical) {
} else {
mrk->ratio = 0;
}
+ // if there is title, then we try to recalc the t, because we want to fix the title width
+ if (titleIndex > 0 && index == titleIndex) t -= mrk->length;
_m.push_back(mrk);
+ index++;
}
s = i;
z = zz;
@@ -113,21 +117,29 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical) {
return true;
}
-void NinePatchSide::calcOffsets(int len) {
+void NinePatchSide::calcOffsets(int len, int titleIndex, int titleWidth) {
uint i, j;
int dest_offset = 0;
- int remaining_stretch = len - _fix;
+ // if we don't got titleIndex, then we better set titleWidth to 0
+ if (titleIndex == 0) titleWidth = 0;
+ int remaining_stretch = len - _fix - titleWidth;
+ // if titleWidth is too big, which may cause the remaining_stretch be 0, so we check it here
+ if (remaining_stretch < 0) remaining_stretch = 0;
for (i = 0, j = 0; i < _m.size(); ++i) {
_m[i]->dest_offset = dest_offset;
- if (_m[i]->ratio == 0) {
- _m[i]->dest_length = _m[i]->length;
+
+ if (titleIndex > 0 && i == (uint)titleIndex) {
+ _m[i]->dest_length = titleWidth;
} else {
- _m[i]->dest_length = (len - _fix) * _m[i]->ratio;
- remaining_stretch -= _m[i]->dest_length;
- j = i;
+ if (_m[i]->ratio == 0) {
+ _m[i]->dest_length = _m[i]->length;
+ } else {
+ _m[i]->dest_length = (len - _fix - titleWidth) * _m[i]->ratio;
+ remaining_stretch -= _m[i]->dest_length;
+ j = i;
+ }
}
-
dest_offset += _m[i]->dest_length;
}
@@ -138,7 +150,7 @@ void NinePatchSide::calcOffsets(int len) {
}
}
-NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap) {
+NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titleIndex, int titleWidth) {
int i;
uint8 r, g, b, a;
@@ -150,6 +162,8 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
_cached_dh = 0;
_width = bmp->w - 2;
_height = bmp->h - 2;
+ _titleIndex = titleIndex;
+ _titleWidth = titleWidth;
if (_width <= 0 || _height <= 0)
goto bad_bitmap;
@@ -199,7 +213,7 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
++i;
}
- if (!_h.init(bmp, false) || !_v.init(bmp, true)) {
+ if (!_h.init(bmp, false, titleIndex, titleWidth) || !_v.init(bmp, true)) {
bad_bitmap:
warning("NinePatchBitmap::NinePatchBitmap(): Bad bitmap");
@@ -213,6 +227,7 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
if (dw < _h._fix || dh < _v._fix)
return;
+ if (dw < _h._fix + _titleWidth) dw = _h._fix + _titleWidth;
/* if the bitmap is the same size as the origin, then draw it as-is */
if (dw == _width && dh == _height) {
Common::Rect r(1, 1, dw, dh);
@@ -223,7 +238,7 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
/* only recalculate the offsets if they have changed since the last draw */
if (_cached_dw != dw || _cached_dh != dh) {
- _h.calcOffsets(dw);
+ _h.calcOffsets(dw, _titleIndex, _titleWidth);
_v.calcOffsets(dh);
_cached_dw = dw;
diff --git a/graphics/nine_patch.h b/graphics/nine_patch.h
index 24b8be4236..8c1f503d20 100644
--- a/graphics/nine_patch.h
+++ b/graphics/nine_patch.h
@@ -72,8 +72,8 @@ public:
NinePatchSide() : _fix(0) { _m.clear(); }
~NinePatchSide();
- bool init(Graphics::TransparentSurface *bmp, bool vertical);
- void calcOffsets(int len);
+ bool init(Graphics::TransparentSurface *bmp, bool vertical, int titleIndex = 0, int titleWidth = 0);
+ void calcOffsets(int len, int titleIndex = 0, int titleWidth = 0);
};
class NinePatchBitmap {
@@ -83,10 +83,11 @@ class NinePatchBitmap {
bool _destroy_bmp;
int _width, _height;
int _cached_dw, _cached_dh;
+ int _titleIndex, _titleWidth;
Common::HashMap<uint32, int> _cached_colors;
public:
- NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap);
+ NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titleIndex = 0, int titleWidth = 0);
~NinePatchBitmap();
void blit(Graphics::Surface &target, int dx, int dy, int dw, int dh, byte *palette = NULL, int numColors = 0, MacWindowManager *wm = NULL, uint32 transColor = 0);
Commit: 8894317e89f822b928cde9c8bf24d6b3c507ee7b
https://github.com/scummvm/scummvm/commit/8894317e89f822b928cde9c8bf24d6b3c507ee7b
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: add titleIndex and titleWidth to macborder in order suit to 9-patch
Changed paths:
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 2d660e72f8..382bd7cb37 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -252,7 +252,7 @@ void MacWindow::drawBorder() {
if (_macBorder.hasBorder(_active)) {
drawBorderFromSurface(g);
- titleColor = _wm->_colorGray88;
+ titleColor = _wm->_colorBlack;
if (_active)
titleColor = _macBorder.getOffset().dark ? _wm->_colorWhite : _wm->_colorBlack;
@@ -290,8 +290,6 @@ void MacWindow::drawBorder() {
if (_macBorder.hasBorder(_active)) {
if (_active && !_macBorder.getOffset().dark)
fillRect(g, (width - w) / 2, titleY, w, titleHeight, _wm->_colorGrayEE);
- } else {
- drawBox(g, (width - w) / 2, titleY, w, titleHeight);
}
font->drawString(g, _title, (width - w) / 2 + 5, titleY + yOff, w, titleColor);
}
@@ -356,7 +354,7 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
loadBorder(file, active, offsets);
}
-void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets) {
+void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titleIndex, int titleWidth) {
Image::BitmapDecoder bmpDecoder;
Graphics::Surface *source;
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
@@ -370,7 +368,7 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, Border
source->free();
delete source;
- setBorder(surface, active, offsets);
+ setBorder(surface, active, offsets, titleIndex, titleWidth);
}
void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, int lo, int ro, int to, int bo) {
@@ -385,13 +383,14 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, in
setBorder(surface, active, offsets);
}
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets) {
+void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets, int titleIndex, int titleWidth) {
surface->applyColorKey(255, 0, 255, false);
if (active)
- _macBorder.addActiveBorder(surface);
+ _macBorder.addActiveBorder(surface, titleIndex, titleWidth);
else
- _macBorder.addInactiveBorder(surface);
+ _macBorder.addInactiveBorder(surface, titleIndex, titleWidth);
+
if (active && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
_macBorder.setOffsets(offsets);
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index f27cdc884f..c3f5785759 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -302,9 +302,9 @@ public:
* @param bo Width of the bottom side of the border, in pixels.
*/
void loadBorder(Common::SeekableReadStream &file, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets);
+ void loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titleIndex = 0, int titleWidth = 0);
void setBorder(TransparentSurface *border, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void setBorder(TransparentSurface *border, bool active, BorderOffsets offsets);
+ void setBorder(TransparentSurface *border, bool active, BorderOffsets offsets, int titleIndex = 0, int titleWidth = 0);
void disableBorder();
/**
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 45a35a906c..280184d7cc 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -53,22 +53,22 @@ bool MacWindowBorder::hasBorder(bool active) {
return active ? _activeInitialized : _inactiveInitialized;
}
-void MacWindowBorder::addActiveBorder(TransparentSurface *source) {
+void MacWindowBorder::addActiveBorder(TransparentSurface *source, int titleIndex, int titleWidth) {
if (_activeBorder)
delete _activeBorder;
- _activeBorder = new NinePatchBitmap(source, true);
+ _activeBorder = new NinePatchBitmap(source, true, titleIndex, titleWidth);
_activeInitialized = true;
if (_activeBorder->getPadding().isValidRect())
setOffsets(_activeBorder->getPadding());
}
-void MacWindowBorder::addInactiveBorder(TransparentSurface *source) {
+void MacWindowBorder::addInactiveBorder(TransparentSurface *source, int titleIndex, int titleWidth) {
if (_inactiveBorder)
delete _inactiveBorder;
- _inactiveBorder = new NinePatchBitmap(source, true);
+ _inactiveBorder = new NinePatchBitmap(source, true, titleIndex, titleWidth);
_inactiveInitialized = true;
if (!_inactiveBorder->getPadding().isValidRect())
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 5d72c473da..606e2e6296 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -63,15 +63,19 @@ public:
* Add the given surface as the display of the border in the active state.
* Will fail if there is already an active border.
* @param The surface that will be displayed.
+ * @param The title index of bmp image
+ * @param The title width that you want to set
*/
- void addActiveBorder(TransparentSurface *source);
+ void addActiveBorder(TransparentSurface *source, int titleIndex = 0, int titleWidth = 0);
/**
* Add the given surface as the display of the border in the inactive state.
* Will fail if there is already an inactive border.
* @param The surface that will be displayed.
+ * @param The title index of bmp image
+ * @param The title width that you want to set
*/
- void addInactiveBorder(TransparentSurface *source);
+ void addInactiveBorder(TransparentSurface *source, int titleIndex = 0, int titleWidth = 0);
/**
* Accessor function for the custom offsets.
Commit: 1f3f8f55a80e77edd2ae4122efdb9a968b7b2d12
https://github.com/scummvm/scummvm/commit/1f3f8f55a80e77edd2ae4122efdb9a968b7b2d12
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
WAGE: add title to wage border
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 728a2c27d5..e9a83bd823 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -314,13 +314,13 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
}
void Gui::loadBorders() {
- loadBorder(_sceneWindow, "wage_border_inact.bmp", false);
- loadBorder(_sceneWindow, "wage_border_act-noscrollbar.bmp", true);
- loadBorder(_consoleWindow, "wage_border_inact.bmp", false);
- loadBorder(_consoleWindow, "wage_border_act.bmp", true);
+ loadBorder(_sceneWindow, "wage_border_inact-title.bmp", false, 3, 36);
+ loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", true, 3, 36);
+ loadBorder(_consoleWindow, "wage_border_inact.bmp", false, 0, 0);
+ loadBorder(_consoleWindow, "wage_border_act.bmp", true, 0, 0);
}
-void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active) {
+void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titleIndex, int titleWidth) {
Common::File borderfile;
if (!borderfile.open(filename)) {
@@ -332,7 +332,19 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool
Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
if (stream) {
- target->loadBorder(*stream, active);
+ if (titleIndex != 0) {
+ Graphics::BorderOffsets offsets;
+ offsets.left = 16;
+ offsets.right = 16;
+ offsets.top = 16;
+ offsets.bottom = 16;
+ offsets.titleTop = 0;
+ offsets.titleBottom = 0;
+ offsets.dark = false;
+ target->loadBorder(*stream, active, offsets, titleIndex, titleWidth);
+ } else {
+ target->loadBorder(*stream, active);
+ }
borderfile.close();
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index a3f3c4d52a..e8eca8b73a 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -150,7 +150,7 @@ private:
const Graphics::Font *getTitleFont();
void loadBorders();
- void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active);
+ void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titleIndex = 0, int titleWidth = 0);
public:
Graphics::ManagedSurface _screen;
Commit: 9298eba78dd14176240a727b34543c4b0897a835
https://github.com/scummvm/scummvm/commit/9298eba78dd14176240a727b34543c4b0897a835
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: remove the check that is not needed
Changed paths:
graphics/macgui/macwindowmanager.cpp
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index f85fba1460..48116b02e6 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -204,9 +204,10 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns) {
g_system->getPaletteManager()->setPalette(palette, 0, ARRAYSIZE(palette) / 3);
_paletteSize = ARRAYSIZE(palette) / 3;
- _palette = (byte *)malloc(_paletteSize * 3);
- if (_palette)
+ if (_paletteSize) {
+ _palette = (byte *)malloc(_paletteSize * 3);
memcpy(_palette, palette, _paletteSize * 3);
+ }
_fontMan = new MacFontManager(mode);
@@ -986,9 +987,10 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
if (_palette)
free(_palette);
- _palette = (byte *)malloc(size * 3);
- if (_palette)
+ if (size) {
+ _palette = (byte *)malloc(size * 3);
memcpy(_palette, pal, size * 3);
+ }
_paletteSize = size;
_colorHash.clear();
Commit: 307147c5652a89f03e461d1dcce1cac4c6798aa1
https://github.com/scummvm/scummvm/commit/307147c5652a89f03e461d1dcce1cac4c6798aa1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: use titlePos to calc titleIndex, change the titleWidth in 9-patch when title is changed
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
graphics/nine_patch.cpp
graphics/nine_patch.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e9a83bd823..42283326d7 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -314,13 +314,13 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
}
void Gui::loadBorders() {
- loadBorder(_sceneWindow, "wage_border_inact-title.bmp", false, 3, 36);
- loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", true, 3, 36);
+ loadBorder(_sceneWindow, "wage_border_inact-title.bmp", false, 22, 36);
+ loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", true, 22, 36);
loadBorder(_consoleWindow, "wage_border_inact.bmp", false, 0, 0);
loadBorder(_consoleWindow, "wage_border_act.bmp", true, 0, 0);
}
-void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titleIndex, int titleWidth) {
+void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titlePos, int titleWidth) {
Common::File borderfile;
if (!borderfile.open(filename)) {
@@ -332,7 +332,7 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool
Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
if (stream) {
- if (titleIndex != 0) {
+ if (titlePos != 0) {
Graphics::BorderOffsets offsets;
offsets.left = 16;
offsets.right = 16;
@@ -341,7 +341,7 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool
offsets.titleTop = 0;
offsets.titleBottom = 0;
offsets.dark = false;
- target->loadBorder(*stream, active, offsets, titleIndex, titleWidth);
+ target->loadBorder(*stream, active, offsets, titlePos, titleWidth);
} else {
target->loadBorder(*stream, active);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index e8eca8b73a..1d50bbfa15 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -150,7 +150,7 @@ private:
const Graphics::Font *getTitleFont();
void loadBorders();
- void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titleIndex = 0, int titleWidth = 0);
+ void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titlePos = 0, int titleWidth = 0);
public:
Graphics::ManagedSurface _screen;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 382bd7cb37..992427f5b0 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -244,24 +244,33 @@ void MacWindow::drawBorder() {
ManagedSurface *g = &_borderSurface;
int width = _borderSurface.w;
- int titleColor;
- int titleY;
- int titleHeight;
- int sidesWidth;
if (_macBorder.hasBorder(_active)) {
- drawBorderFromSurface(g);
- titleColor = _wm->_colorBlack;
- if (_active)
- titleColor = _macBorder.getOffset().dark ? _wm->_colorWhite : _wm->_colorBlack;
-
- titleY = _macBorder.getOffset().titleTop;
- titleHeight = _macBorder.getOffset().top - titleY - _macBorder.getOffset().titleBottom;
- sidesWidth = _macBorder.getOffset().left + _macBorder.getOffset().right;
+ if (_title.empty())
+ drawBorderFromSurface(g);
+ else {
+ const Graphics::Font *font = getTitleFont();
+ int titleColor = _wm->_colorBlack;
+ int titleY = _macBorder.getOffset().titleTop;
+ int sidesWidth = _macBorder.getOffset().left + _macBorder.getOffset().right;
+ int titleWidth = font->getStringWidth(_title) + 10;
+ int yOff = _wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
+ int maxWidth = width - sidesWidth - 7;
+ if (titleWidth > maxWidth)
+ titleWidth = maxWidth;
+
+ // if titleWidth is changed, then we modify it
+ if (titleWidth != _macBorder.getTitleWidth())
+ _macBorder.modifyTitleWidth(titleWidth);
+
+ drawBorderFromSurface(g);
+ font->drawString(g, _title, (width - titleWidth) / 2 + 5, titleY + yOff, titleWidth, titleColor);
+ }
} else {
warning("MacWindow: No Border Loaded");
setBorderType(0xff);
+ return;
}
// draw highlight scroll bar
@@ -277,22 +286,6 @@ void MacWindow::drawBorder() {
Graphics::drawFilledRect(rr, _wm->_colorWhite, _wm->getDrawInvertPixel(), &pd);
setHighlight(kBorderNone);
}
-
- if (!_title.empty()) {
- const Graphics::Font *font = getTitleFont();
- int yOff = _wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
-
- int w = font->getStringWidth(_title) + 10;
- int maxWidth = width - sidesWidth * 2 - 7;
- if (w > maxWidth)
- w = maxWidth;
-
- if (_macBorder.hasBorder(_active)) {
- if (_active && !_macBorder.getOffset().dark)
- fillRect(g, (width - w) / 2, titleY, w, titleHeight, _wm->_colorGrayEE);
- }
- font->drawString(g, _title, (width - w) / 2 + 5, titleY + yOff, w, titleColor);
- }
}
void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
@@ -354,7 +347,7 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
loadBorder(file, active, offsets);
}
-void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titleIndex, int titleWidth) {
+void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titlePos, int titleWidth) {
Image::BitmapDecoder bmpDecoder;
Graphics::Surface *source;
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
@@ -368,7 +361,7 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, Border
source->free();
delete source;
- setBorder(surface, active, offsets, titleIndex, titleWidth);
+ setBorder(surface, active, offsets, titlePos, titleWidth);
}
void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, int lo, int ro, int to, int bo) {
@@ -383,13 +376,13 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, in
setBorder(surface, active, offsets);
}
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets, int titleIndex, int titleWidth) {
+void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets, int titlePos, int titleWidth) {
surface->applyColorKey(255, 0, 255, false);
if (active)
- _macBorder.addActiveBorder(surface, titleIndex, titleWidth);
+ _macBorder.addActiveBorder(surface, titlePos, titleWidth);
else
- _macBorder.addInactiveBorder(surface, titleIndex, titleWidth);
+ _macBorder.addInactiveBorder(surface, titlePos, titleWidth);
if (active && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index c3f5785759..cc7148a8f6 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -302,9 +302,9 @@ public:
* @param bo Width of the bottom side of the border, in pixels.
*/
void loadBorder(Common::SeekableReadStream &file, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titleIndex = 0, int titleWidth = 0);
+ void loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
void setBorder(TransparentSurface *border, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void setBorder(TransparentSurface *border, bool active, BorderOffsets offsets, int titleIndex = 0, int titleWidth = 0);
+ void setBorder(TransparentSurface *border, bool active, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
void disableBorder();
/**
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 280184d7cc..27d74c82ab 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -53,28 +53,35 @@ bool MacWindowBorder::hasBorder(bool active) {
return active ? _activeInitialized : _inactiveInitialized;
}
-void MacWindowBorder::addActiveBorder(TransparentSurface *source, int titleIndex, int titleWidth) {
+void MacWindowBorder::addActiveBorder(TransparentSurface *source, int titlePos, int titleWidth) {
if (_activeBorder)
delete _activeBorder;
- _activeBorder = new NinePatchBitmap(source, true, titleIndex, titleWidth);
+ _activeBorder = new NinePatchBitmap(source, true, titlePos, titleWidth);
_activeInitialized = true;
if (_activeBorder->getPadding().isValidRect())
setOffsets(_activeBorder->getPadding());
}
-void MacWindowBorder::addInactiveBorder(TransparentSurface *source, int titleIndex, int titleWidth) {
+void MacWindowBorder::addInactiveBorder(TransparentSurface *source, int titlePos, int titleWidth) {
if (_inactiveBorder)
delete _inactiveBorder;
- _inactiveBorder = new NinePatchBitmap(source, true, titleIndex, titleWidth);
+ _inactiveBorder = new NinePatchBitmap(source, true, titlePos, titleWidth);
_inactiveInitialized = true;
if (!_inactiveBorder->getPadding().isValidRect())
setOffsets(_inactiveBorder->getPadding());
}
+void MacWindowBorder::modifyTitleWidth(int titleWidth) {
+ if (_inactiveBorder)
+ _inactiveBorder->modifyTitleWidth(titleWidth);
+ if (_activeBorder)
+ _activeBorder->modifyTitleWidth(titleWidth);
+}
+
bool MacWindowBorder::hasOffsets() {
return _borderOffsets.left > -1 && _borderOffsets.right > -1
&& _borderOffsets.top > -1 && _borderOffsets.bottom > -1;
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 606e2e6296..d092206324 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -63,19 +63,19 @@ public:
* Add the given surface as the display of the border in the active state.
* Will fail if there is already an active border.
* @param The surface that will be displayed.
- * @param The title index of bmp image
+ * @param The title position of bmp image
* @param The title width that you want to set
*/
- void addActiveBorder(TransparentSurface *source, int titleIndex = 0, int titleWidth = 0);
+ void addActiveBorder(TransparentSurface *source, int titlePos = 0, int titleWidth = 0);
/**
* Add the given surface as the display of the border in the inactive state.
* Will fail if there is already an inactive border.
* @param The surface that will be displayed.
- * @param The title index of bmp image
+ * @param The title position of bmp image
* @param The title width that you want to set
*/
- void addInactiveBorder(TransparentSurface *source, int titleIndex = 0, int titleWidth = 0);
+ void addInactiveBorder(TransparentSurface *source, int titlePos = 0, int titleWidth = 0);
/**
* Accessor function for the custom offsets.
@@ -117,6 +117,10 @@ public:
*/
void blitBorderInto(ManagedSurface &destination, bool active, MacWindowManager *wm);
+ void modifyTitleWidth(int titleWidth);
+ // in this implement, we should guarantee the titleWidth of activeBorder and inactiveBorder is the same
+ int getTitleWidth() { return _activeBorder->getTitleWidth(); }
+
private:
NinePatchBitmap *_activeBorder;
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 6616eff9fc..19a2cbd466 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -61,7 +61,7 @@ NinePatchSide::~NinePatchSide() {
}
-bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int titleIndex, int titleWidth) {
+bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos, int titleWidth, int *titleIndex) {
const uint len = vertical ? bmp->h : bmp->w;
uint i;
int s, t, z;
@@ -99,7 +99,11 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int t
mrk->ratio = 0;
}
// if there is title, then we try to recalc the t, because we want to fix the title width
- if (titleIndex > 0 && index == titleIndex) t -= mrk->length;
+ if (titlePos > 0 && (int)i == titlePos) {
+ t -= mrk->length;
+ if (titleIndex)
+ *titleIndex = index;
+ }
_m.push_back(mrk);
index++;
}
@@ -150,7 +154,7 @@ void NinePatchSide::calcOffsets(int len, int titleIndex, int titleWidth) {
}
}
-NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titleIndex, int titleWidth) {
+NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos, int titleWidth) {
int i;
uint8 r, g, b, a;
@@ -162,8 +166,9 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
_cached_dh = 0;
_width = bmp->w - 2;
_height = bmp->h - 2;
- _titleIndex = titleIndex;
+ _titleIndex = 0;
_titleWidth = titleWidth;
+ _titlePos = titlePos;
if (_width <= 0 || _height <= 0)
goto bad_bitmap;
@@ -213,7 +218,7 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
++i;
}
- if (!_h.init(bmp, false, titleIndex, titleWidth) || !_v.init(bmp, true)) {
+ if (!_h.init(bmp, false, titlePos, titleWidth, &_titleIndex) || !_v.init(bmp, true)) {
bad_bitmap:
warning("NinePatchBitmap::NinePatchBitmap(): Bad bitmap");
@@ -222,6 +227,12 @@ bad_bitmap:
}
}
+void NinePatchBitmap::modifyTitleWidth(int titleWidth) {
+ if (_titlePos == 0) return;
+ _titleWidth = titleWidth;
+ _h.calcOffsets(_cached_dw, _titleIndex, _titleWidth);
+}
+
void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, int dh, byte *palette, int numColors, MacWindowManager *wm, uint32 transColor) {
/* don't draw bitmaps that are smaller than the fixed area */
if (dw < _h._fix || dh < _v._fix)
diff --git a/graphics/nine_patch.h b/graphics/nine_patch.h
index 8c1f503d20..4949cee3c4 100644
--- a/graphics/nine_patch.h
+++ b/graphics/nine_patch.h
@@ -72,7 +72,8 @@ public:
NinePatchSide() : _fix(0) { _m.clear(); }
~NinePatchSide();
- bool init(Graphics::TransparentSurface *bmp, bool vertical, int titleIndex = 0, int titleWidth = 0);
+ bool init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos = 0, int titleWidth = 0, int *titleIndex = nullptr);
+
void calcOffsets(int len, int titleIndex = 0, int titleWidth = 0);
};
@@ -83,20 +84,22 @@ class NinePatchBitmap {
bool _destroy_bmp;
int _width, _height;
int _cached_dw, _cached_dh;
- int _titleIndex, _titleWidth;
+ int _titleIndex, _titleWidth, _titlePos;
Common::HashMap<uint32, int> _cached_colors;
public:
- NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titleIndex = 0, int titleWidth = 0);
+ NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos = 0, int titleWidth = 0);
~NinePatchBitmap();
void blit(Graphics::Surface &target, int dx, int dy, int dw, int dh, byte *palette = NULL, int numColors = 0, MacWindowManager *wm = NULL, uint32 transColor = 0);
void blitClip(Graphics::Surface &target, Common::Rect clip, int dx, int dy, int dw, int dh);
+ void modifyTitleWidth(int titleWidth);
int getWidth() { return _width; }
int getHeight() { return _height; }
int getMinWidth() { return _h._fix; }
int getMinHeight() { return _v._fix; }
+ int getTitleWidth() { return _titleWidth; }
Graphics::TransparentSurface *getSource() { return _bmp; }
Common::Rect &getPadding() { return _padding; }
Commit: 6d7e794ed3dea68e95919f0ed34a25e3aa230b04
https://github.com/scummvm/scummvm/commit/6d7e794ed3dea68e95919f0ed34a25e3aa230b04
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: Add flag to indicate the border type, move drawTitle and drawScrollBar into macwindowborder
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 42283326d7..6699d4576d 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -314,13 +314,13 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
}
void Gui::loadBorders() {
- loadBorder(_sceneWindow, "wage_border_inact-title.bmp", false, 22, 36);
- loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", true, 22, 36);
- loadBorder(_consoleWindow, "wage_border_inact.bmp", false, 0, 0);
- loadBorder(_consoleWindow, "wage_border_act.bmp", true, 0, 0);
+ loadBorder(_sceneWindow, "wage_border_inact-title.bmp", Graphics::kWindowBorderTitle, 22, 36);
+ loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", Graphics::kWindowBorderActive|Graphics::kWindowBorderTitle, 22, 36);
+ loadBorder(_consoleWindow, "wage_border_inact.bmp", Graphics::kWindowBorderScrollbar, 0, 0);
+ loadBorder(_consoleWindow, "wage_border_act.bmp", Graphics::kWindowBorderScrollbar|Graphics::kWindowBorderActive, 0, 0);
}
-void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titlePos, int titleWidth) {
+void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos, int titleWidth) {
Common::File borderfile;
if (!borderfile.open(filename)) {
@@ -341,9 +341,9 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, bool
offsets.titleTop = 0;
offsets.titleBottom = 0;
offsets.dark = false;
- target->loadBorder(*stream, active, offsets, titlePos, titleWidth);
+ target->loadBorder(*stream, flags, offsets, titlePos, titleWidth);
} else {
- target->loadBorder(*stream, active);
+ target->loadBorder(*stream, flags);
}
borderfile.close();
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 1d50bbfa15..3b66fdf12b 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -150,7 +150,7 @@ private:
const Graphics::Font *getTitleFont();
void loadBorders();
- void loadBorder(Graphics::MacWindow *target, Common::String filename, bool active, int titlePos = 0, int titleWidth = 0);
+ void loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos = 0, int titleWidth = 0);
public:
Graphics::ManagedSurface _screen;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 992427f5b0..2823a1d8d6 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -56,8 +56,6 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_highlightedPart = kBorderNone;
- _scrollPos = _scrollSize = 0.0;
-
_beingDragged = false;
_beingResized = false;
@@ -243,59 +241,40 @@ void MacWindow::drawBorder() {
_borderIsDirty = false;
ManagedSurface *g = &_borderSurface;
- int width = _borderSurface.w;
-
- if (_macBorder.hasBorder(_active)) {
-
- if (_title.empty())
- drawBorderFromSurface(g);
- else {
- const Graphics::Font *font = getTitleFont();
- int titleColor = _wm->_colorBlack;
- int titleY = _macBorder.getOffset().titleTop;
- int sidesWidth = _macBorder.getOffset().left + _macBorder.getOffset().right;
- int titleWidth = font->getStringWidth(_title) + 10;
- int yOff = _wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
- int maxWidth = width - sidesWidth - 7;
- if (titleWidth > maxWidth)
- titleWidth = maxWidth;
-
- // if titleWidth is changed, then we modify it
- if (titleWidth != _macBorder.getTitleWidth())
- _macBorder.modifyTitleWidth(titleWidth);
-
- drawBorderFromSurface(g);
- font->drawString(g, _title, (width - titleWidth) / 2 + 5, titleY + yOff, titleWidth, titleColor);
- }
+
+ uint32 flags = 0;
+ if (_active)
+ flags |= kWindowBorderActive;
+ if (!_title.empty())
+ flags |= kWindowBorderTitle;
+ if (_borderFlags & kWindowBorderScrollbar)
+ flags |= kWindowBorderScrollbar;
+
+ if (_macBorder.hasBorder(flags)) {
+ drawBorderFromSurface(g, flags);
} else {
warning("MacWindow: No Border Loaded");
setBorderType(0xff);
return;
}
- // draw highlight scroll bar
- if (_highlightedPart == kBorderScrollUp || _highlightedPart == kBorderScrollDown) {
- int size = _borderWidth;
- int rx1 = 0 + width - size + 2;
- int ry1 = 0 + size + _scrollPos + 1;
- int rx2 = rx1 + size - 6;
- int ry2 = ry1 + _scrollSize ;
- Common::Rect rr(rx1, ry1, rx2, ry2);
-
- MacPlotData pd(g, nullptr, &_wm->getPatterns(), 1, 0, 0, 1, _wm->_colorWhite, true);
- Graphics::drawFilledRect(rr, _wm->_colorWhite, _wm->getDrawInvertPixel(), &pd);
+ if (_highlightedPart == kBorderScrollUp || _highlightedPart == kBorderScrollDown)
setHighlight(kBorderNone);
- }
}
-void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
+void MacWindow::drawBorderFromSurface(ManagedSurface *g, uint32 flags) {
if (_wm->_pixelformat.bytesPerPixel == 1) {
g->clear(_wm->_colorGreen);
}
- _macBorder.blitBorderInto(*g, _active, _wm);
+ _macBorder.blitBorderInto(*g, flags, _wm);
}
+void MacWindow::setTitle(const Common::String &title) {
+ _title = title;
+ _borderIsDirty = true;
+ _macBorder.setTitle(title, _borderSurface.w, _wm);
+}
void MacWindow::drawPattern() {
byte *pat = _wm->getPatterns()[_pattern - 1];
@@ -327,15 +306,11 @@ void MacWindow::setHighlight(WindowClick highlightedPart) {
}
void MacWindow::setScroll(float scrollPos, float scrollSize) {
- if (_scrollPos == scrollPos && _scrollSize == scrollSize)
- return;
-
- _scrollPos = scrollPos;
- _scrollSize = scrollSize;
+ _macBorder.setScroll(scrollPos, scrollSize);
_borderIsDirty = true;
}
-void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo, int ro, int to, int bo) {
+void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo, int ro, int to, int bo) {
BorderOffsets offsets;
offsets.left = lo;
offsets.right = ro;
@@ -344,10 +319,10 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
offsets.titleTop = -1;
offsets.titleBottom = -1;
offsets.dark = false;
- loadBorder(file, active, offsets);
+ loadBorder(file, flags, offsets);
}
-void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titlePos, int titleWidth) {
+void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
Image::BitmapDecoder bmpDecoder;
Graphics::Surface *source;
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
@@ -361,10 +336,10 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, Border
source->free();
delete source;
- setBorder(surface, active, offsets, titlePos, titleWidth);
+ setBorder(surface, flags, offsets, titlePos, titleWidth);
}
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, int lo, int ro, int to, int bo) {
+void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo, int ro, int to, int bo) {
BorderOffsets offsets;
offsets.left = lo;
offsets.right = ro;
@@ -373,19 +348,15 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, in
offsets.titleTop = -1;
offsets.titleBottom = -1;
offsets.dark = false;
- setBorder(surface, active, offsets);
+ setBorder(surface, flags, offsets);
}
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets, int titlePos, int titleWidth) {
+void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
surface->applyColorKey(255, 0, 255, false);
- if (active)
- _macBorder.addActiveBorder(surface, titlePos, titleWidth);
- else
- _macBorder.addInactiveBorder(surface, titlePos, titleWidth);
-
+ _macBorder.addBorder(surface, flags, titlePos, titleWidth);
- if (active && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
+ if ((flags & kWindowBorderActive) && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
_macBorder.setOffsets(offsets);
updateOuterDims();
_borderSurface.free();
@@ -394,6 +365,7 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, Bo
_borderIsDirty = true;
_wm->setFullRefresh(true);
+ _borderFlags = flags;
}
void MacWindow::setCloseable(bool closeable) {
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index cc7148a8f6..3e9e66e398 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -265,7 +265,7 @@ public:
* Mutator to change the title of the window.
* @param title Target title.
*/
- void setTitle(const Common::String &title) { _title = title; _borderIsDirty = true; }
+ void setTitle(const Common::String &title);
/**
* Accessor to get the title of the window.
* @return Title.
@@ -301,10 +301,10 @@ public:
* @param to Width of the top side of the border, in pixels.
* @param bo Width of the bottom side of the border, in pixels.
*/
- void loadBorder(Common::SeekableReadStream &file, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
- void setBorder(TransparentSurface *border, bool active, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void setBorder(TransparentSurface *border, bool active, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void setBorder(TransparentSurface *border, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
+ void setBorder(TransparentSurface *border, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
void disableBorder();
/**
@@ -332,7 +332,7 @@ public:
virtual bool isDirty() override { return _borderIsDirty || _contentIsDirty; }
private:
- void drawBorderFromSurface(ManagedSurface *g);
+ void drawBorderFromSurface(ManagedSurface *g, uint32 flags);
void drawPattern();
void drawBox(ManagedSurface *g, int x, int y, int w, int h);
void fillRect(ManagedSurface *g, int x, int y, int w, int h, int color);
@@ -358,6 +358,7 @@ protected:
private:
MacWindowBorder _macBorder;
+ uint32 _borderFlags;
int _pattern;
bool _hasPattern;
@@ -373,7 +374,6 @@ private:
int _draggedX, _draggedY;
WindowClick _highlightedPart;
- float _scrollPos, _scrollSize;
Common::String _title;
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 27d74c82ab..98dc919b08 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -29,9 +29,15 @@ namespace Graphics {
using namespace Graphics::MacGUIConstants;
-MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitialized(false) {
- _activeBorder = nullptr;
- _inactiveBorder = nullptr;
+MacWindowBorder::MacWindowBorder() {
+
+ _borderInitialized = Common::Array<bool>(_borderTypeNum);
+ _border = Common::Array<NinePatchBitmap *>(_borderTypeNum);
+
+ for (uint32 i = 0; i < _borderTypeNum; i++) {
+ _border[i] = nullptr;
+ _borderInitialized[i] = false;
+ }
_borderOffsets.left = -1;
_borderOffsets.right = -1;
@@ -43,43 +49,45 @@ MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitial
}
MacWindowBorder::~MacWindowBorder() {
- if (_activeBorder)
- delete _activeBorder;
- if (_inactiveBorder)
- delete _inactiveBorder;
-}
-
-bool MacWindowBorder::hasBorder(bool active) {
- return active ? _activeInitialized : _inactiveInitialized;
+ for (uint32 i = 0; i < _borderTypeNum; i++) {
+ if (_border[i])
+ delete _border[i];
+ }
}
-void MacWindowBorder::addActiveBorder(TransparentSurface *source, int titlePos, int titleWidth) {
- if (_activeBorder)
- delete _activeBorder;
-
- _activeBorder = new NinePatchBitmap(source, true, titlePos, titleWidth);
- _activeInitialized = true;
-
- if (_activeBorder->getPadding().isValidRect())
- setOffsets(_activeBorder->getPadding());
+bool MacWindowBorder::hasBorder(uint32 flags) {
+ if (flags >= _borderTypeNum) {
+ warning("Accessing non-existed border type");
+ return false;
+ }
+ return _borderInitialized[flags];
}
-void MacWindowBorder::addInactiveBorder(TransparentSurface *source, int titlePos, int titleWidth) {
- if (_inactiveBorder)
- delete _inactiveBorder;
+void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int titlePos, int titleWidth) {
+ if (flags >= _borderTypeNum) {
+ warning("Accessing non-existed border type");
+ return;
+ }
+ if (_border[flags])
+ delete _border[flags];
- _inactiveBorder = new NinePatchBitmap(source, true, titlePos, titleWidth);
- _inactiveInitialized = true;
+ _border[flags] = new NinePatchBitmap(source, true, titlePos, titleWidth);
+ _borderInitialized[flags] = true;
- if (!_inactiveBorder->getPadding().isValidRect())
- setOffsets(_inactiveBorder->getPadding());
+ if (_border[flags]->getPadding().isValidRect())
+ setOffsets(_border[flags]->getPadding());
}
-void MacWindowBorder::modifyTitleWidth(int titleWidth) {
- if (_inactiveBorder)
- _inactiveBorder->modifyTitleWidth(titleWidth);
- if (_activeBorder)
- _activeBorder->modifyTitleWidth(titleWidth);
+void MacWindowBorder::modifyTitleWidth(uint32 flags, int titleWidth) {
+ if (flags >= _borderTypeNum) {
+ warning("Accessing non-existed border type");
+ return;
+ }
+ if (!_borderInitialized[flags]) {
+ warning("Trying to modify title width of an uninitialized border");
+ return;
+ }
+ _border[flags]->modifyTitleWidth(titleWidth);
}
bool MacWindowBorder::hasOffsets() {
@@ -109,13 +117,67 @@ BorderOffsets &MacWindowBorder::getOffset() {
return _borderOffsets;
}
-void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active, MacWindowManager *wm) {
+void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindowManager *wm) {
+ _title = title;
+ const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
+ int sidesWidth = getOffset().left + getOffset().right;
+ int titleWidth = font->getStringWidth(_title) + 10;
+ int maxWidth = width - sidesWidth - 7;
+ if (titleWidth > maxWidth)
+ titleWidth = maxWidth;
+
+ // if titleWidth is changed, then we modify it
+ // here, we change all the border that has title
+ for (uint32 i = 0; i < _borderTypeNum; i++) {
+ if (_borderInitialized[i] && (i & kWindowBorderTitle))
+ _border[i]->modifyTitleWidth(titleWidth);
+ }
+}
+
+void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
+ // here, we first check the _scrollSize, and if it is negative, then we don't draw the scrollBar
+ if (_scrollSize < 0)
+ return;
+ int size = kBorderWidth;
+ int rx1 = 0 + g->w - size + 2;
+ int ry1 = 0 + size + _scrollPos + 1;
+ int rx2 = rx1 + size - 6;
+ int ry2 = ry1 + _scrollSize ;
+ Common::Rect rr(rx1, ry1, rx2, ry2);
+
+ MacPlotData pd(g, nullptr, &wm->getPatterns(), 1, 0, 0, 1, wm->_colorWhite, true);
+ Graphics::drawFilledRect(rr, wm->_colorWhite, wm->getDrawInvertPixel(), &pd);
+
+ // after drawing, we set the _scrollSize negative, to indicate no more drawing is needed
+ _scrollSize = -1;
+}
+
+void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm) {
+ const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
+ int width = g->w;
+ int titleColor = wm->_colorBlack;
+ int titleY = getOffset().titleTop;
+ int sidesWidth = getOffset().left + getOffset().right;
+ int titleWidth = font->getStringWidth(_title) + 10;
+ int yOff = wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
+ int maxWidth = width - sidesWidth - 7;
+ if (titleWidth > maxWidth)
+ titleWidth = maxWidth;
+
+ font->drawString(g, _title, (width - titleWidth) / 2 + 5, titleY + yOff, titleWidth, titleColor);
+}
+
+void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags, MacWindowManager *wm) {
+ if (flags >= _borderTypeNum) {
+ warning("Accessing non-existed border type");
+ return;
+ }
TransparentSurface srf;
- NinePatchBitmap *src = active ? _activeBorder : _inactiveBorder;
+ NinePatchBitmap *src = _border[flags];
- if ((active && !_activeInitialized) || (!active && !_inactiveInitialized)) {
- warning("Attempt to blit unitialised border");
+ if (!_borderInitialized[flags]) {
+ warning("Attempt to blit uninitialized border");
}
if (destination.w == 0 || destination.h == 0) {
@@ -129,6 +191,12 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, bool active, M
src->blit(srf, 0, 0, srf.w, srf.h, NULL, 0, wm);
destination.transBlitFrom(srf, wm->_colorGreen2);
srf.free();
+
+ if (flags & kWindowBorderTitle)
+ drawTitle(&destination, wm);
+
+ if (flags & kWindowBorderScrollbar)
+ drawScrollBar(&destination, wm);
}
} // End of namespace Graphics
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index d092206324..cd056c6275 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -29,9 +29,17 @@
#include "graphics/nine_patch.h"
#include "graphics/managed_surface.h"
#include "graphics/transparent_surface.h"
+#include "graphics/macgui/macfontmanager.h"
+#include "graphics/primitives.h"
namespace Graphics {
+enum {
+ kWindowBorderActive = 1 << 0,
+ kWindowBorderTitle = 1 << 1,
+ kWindowBorderScrollbar = 1 << 2
+};
+
struct BorderOffsets {
int left;
int right;
@@ -54,28 +62,20 @@ public:
/**
* Accessor to check whether or not a border is loaded.
- * @param active State that we want to check. If true it checks for active border, if false it checks for inactive.
+ * @param check whether the border type we want has been initialized.
* @return True if the checked state has a border loaded, false otherwise.
*/
- bool hasBorder(bool active);
+ bool hasBorder(uint32 flags);
/**
- * Add the given surface as the display of the border in the active state.
- * Will fail if there is already an active border.
+ * Add the given surface as the display of the border in the state that is instructed by flag.
+ * Will fail if there is already an border.
* @param The surface that will be displayed.
+ * @param The border type indicated by flag
* @param The title position of bmp image
* @param The title width that you want to set
*/
- void addActiveBorder(TransparentSurface *source, int titlePos = 0, int titleWidth = 0);
-
- /**
- * Add the given surface as the display of the border in the inactive state.
- * Will fail if there is already an inactive border.
- * @param The surface that will be displayed.
- * @param The title position of bmp image
- * @param The title width that you want to set
- */
- void addInactiveBorder(TransparentSurface *source, int titlePos = 0, int titleWidth = 0);
+ void addBorder(TransparentSurface *source, uint32 flags, int titlePos = 0, int titleWidth = 0);
/**
* Accessor function for the custom offsets.
@@ -112,22 +112,30 @@ public:
* Blit the desired border (active or inactive) into a destination surface.
* It automatically resizes the border to fit the given surface.
* @param destination The surface we want to blit into.
- * @param active True if we want to blit the active border, false otherwise.
+ * @param border type that you want to draw
* @param wm The window manager.
*/
- void blitBorderInto(ManagedSurface &destination, bool active, MacWindowManager *wm);
+ void blitBorderInto(ManagedSurface &destination, uint32 flags, MacWindowManager *wm);
+
+ void modifyTitleWidth(uint32 flags, int titleWidth);
+
+ void setTitle(const Common::String& title, int width, MacWindowManager *wm);
- void modifyTitleWidth(int titleWidth);
- // in this implement, we should guarantee the titleWidth of activeBorder and inactiveBorder is the same
- int getTitleWidth() { return _activeBorder->getTitleWidth(); }
+ void setScroll(int scrollPos, int scrollSize) { _scrollPos = scrollPos, _scrollSize = scrollSize; }
+
+ void drawTitle(ManagedSurface *g, MacWindowManager *wm);
+
+ void drawScrollBar(ManagedSurface *g, MacWindowManager *wm);
private:
+ int _scrollPos, _scrollSize;
+ Common::String _title;
+
+ const uint32 _borderTypeNum = 8;
- NinePatchBitmap *_activeBorder;
- NinePatchBitmap *_inactiveBorder;
+ Common::Array<NinePatchBitmap *> _border;
- bool _activeInitialized;
- bool _inactiveInitialized;
+ Common::Array<bool> _borderInitialized;
BorderOffsets _borderOffsets;
Commit: 858624c0c9792f333e07a399b78682bc63a1125d
https://github.com/scummvm/scummvm/commit/858624c0c9792f333e07a399b78682bc63a1125d
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: fix the bug of the border flag is not correctly initialized
Changed paths:
graphics/macgui/macwindow.cpp
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 2823a1d8d6..aabb73121f 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -85,10 +85,10 @@ void MacWindow::disableBorder() {
for (int x = 0; x < 3; x++)
*((uint32 *)noborder->getBasePtr(x, y)) = noborderData[y][x] ? colorBlack : colorPink;
- setBorder(noborder, true);
+ setBorder(noborder, kWindowBorderActive);
Graphics::TransparentSurface *noborder2 = new Graphics::TransparentSurface(*noborder, true);
- setBorder(noborder2, false);
+ setBorder(noborder2, 0);
}
const Font *MacWindow::getTitleFont() {
@@ -245,7 +245,7 @@ void MacWindow::drawBorder() {
uint32 flags = 0;
if (_active)
flags |= kWindowBorderActive;
- if (!_title.empty())
+ if (_borderFlags & kWindowBorderTitle)
flags |= kWindowBorderTitle;
if (_borderFlags & kWindowBorderScrollbar)
flags |= kWindowBorderScrollbar;
@@ -562,13 +562,13 @@ void MacWindow::setBorderType(int borderType) {
Common::SeekableReadStream *activeFile = _wm->getBorderFile(borderType, true);
if (activeFile) {
- loadBorder(*activeFile, true, offsets);
+ loadBorder(*activeFile, kWindowBorderActive, offsets);
delete activeFile;
}
Common::SeekableReadStream *inactiveFile = _wm->getBorderFile(borderType, false);
if (inactiveFile) {
- loadBorder(*inactiveFile, false, offsets);
+ loadBorder(*inactiveFile, 0, offsets);
delete inactiveFile;
}
}
Commit: a0964d690cd9b32476d0fd57b96d4a1577f692f1
https://github.com/scummvm/scummvm/commit/a0964d690cd9b32476d0fd57b96d4a1577f692f1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: Add border flags to the builtin border types, fix the remaining part of macgui which are not adapt to border flags.
Changed paths:
graphics/macgui/datafiles.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowmanager.h
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 874f2ed7bc..864dbb7553 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -41,10 +41,14 @@ struct BorderName {
byte type;
const char *name;
BorderOffsets offsets;
+ uint32 flags;
+ int titlePos;
+ BorderName(byte _type, const char *_name, BorderOffsets _offsets, uint32 _flags = 0, int _titlePos = 0):
+ type(_type), name(_name), offsets(_offsets), flags(_flags), titlePos(_titlePos) {}
};
static const BorderName borders[] = {
- {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}},
+ {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, kWindowBorderTitle, 23},
{0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}},
{0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}},
{0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}},
@@ -92,12 +96,34 @@ BorderOffsets MacWindowManager::getBorderOffsets(byte windowType) {
return borders[i].offsets;
}
-Common::SeekableReadStream *MacWindowManager::getBorderFile(byte windowType, bool isActive) {
+uint32 MacWindowManager::getBorderFlags(byte windowType) {
+ int i = 0;
+ while (borders[i].type != 0xFF) {
+ if (borders[i].type == windowType)
+ break;
+ i++;
+ }
+ return borders[i].flags;
+}
+
+int MacWindowManager::getBorderTitlePos(byte windowType) {
+ int i = 0;
+ while (borders[i].type != 0xFF) {
+ if (borders[i].type == windowType)
+ break;
+ i++;
+ }
+ return borders[i].titlePos;
+}
+
+Common::SeekableReadStream *MacWindowManager::getBorderFile(byte windowType, uint32 flags) {
if (!_dataBundle)
return NULL;
Common::String filename = windowTypeName(windowType);
- filename += (isActive ? "_act.bmp" : "_inac.bmp");
+ filename += (flags & kWindowBorderActive) ? "_act" : "_inac";
+ filename += (flags & kWindowBorderTitle) ? "_title" : "";
+ filename += ".bmp";
if (!_dataBundle->hasFile(filename)) {
warning("Missing border file '%s' in data bundle", filename.c_str());
return NULL;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index aabb73121f..24ae0ee54e 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -198,7 +198,7 @@ void MacWindow::center(bool toCenter) {
if (toCenter) {
move((screen.width() - _dims.width()) / 2, (screen.height() - _dims.height()) / 2);
- } else if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
+ } else if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
move(_macBorder.getOffset().left, _macBorder.getOffset().top);
} else {
move(0, 0);
@@ -209,7 +209,7 @@ void MacWindow::updateInnerDims() {
if (_dims.isEmpty())
return;
- if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
+ if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
_innerDims = Common::Rect(
_dims.left + _macBorder.getOffset().left,
_dims.top + _macBorder.getOffset().top,
@@ -225,7 +225,7 @@ void MacWindow::updateOuterDims() {
if (_innerDims.isEmpty())
return;
- if (_macBorder.hasBorder(_active) && _macBorder.hasOffsets()) {
+ if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
_dims = Common::Rect(
_innerDims.left - _macBorder.getOffset().left,
_innerDims.top - _macBorder.getOffset().top,
@@ -365,7 +365,9 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, B
_borderIsDirty = true;
_wm->setFullRefresh(true);
- _borderFlags = flags;
+ // here we set the first bit zero, which indicate the active and inactive
+ // because we will use _active flag to decide whether it's active or not
+ _borderFlags = flags & 0xfffffffe;
}
void MacWindow::setCloseable(bool closeable) {
@@ -559,16 +561,19 @@ void MacWindow::setBorderType(int borderType) {
disableBorder();
} else {
BorderOffsets offsets = _wm->getBorderOffsets(borderType);
-
- Common::SeekableReadStream *activeFile = _wm->getBorderFile(borderType, true);
+ uint32 flags = _wm->getBorderFlags(borderType);
+ int titlePos = 0;
+ if (flags & kWindowBorderTitle)
+ titlePos = _wm->getBorderTitlePos(borderType);
+ Common::SeekableReadStream *activeFile = _wm->getBorderFile(borderType, flags | kWindowBorderActive);
if (activeFile) {
- loadBorder(*activeFile, kWindowBorderActive, offsets);
+ loadBorder(*activeFile, flags | kWindowBorderActive, offsets, titlePos);
delete activeFile;
}
- Common::SeekableReadStream *inactiveFile = _wm->getBorderFile(borderType, false);
+ Common::SeekableReadStream *inactiveFile = _wm->getBorderFile(borderType, flags);
if (inactiveFile) {
- loadBorder(*inactiveFile, 0, offsets);
+ loadBorder(*inactiveFile, flags, offsets, titlePos);
delete inactiveFile;
}
}
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 98dc919b08..425beadef3 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -74,7 +74,7 @@ void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int ti
_border[flags] = new NinePatchBitmap(source, true, titlePos, titleWidth);
_borderInitialized[flags] = true;
- if (_border[flags]->getPadding().isValidRect())
+ if (_border[flags]->getPadding().isValidRect() && _border[flags]->getPadding().left > -1 && _border[flags]->getPadding().top > -1)
setOffsets(_border[flags]->getPadding());
}
@@ -122,7 +122,7 @@ void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindow
const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
int sidesWidth = getOffset().left + getOffset().right;
int titleWidth = font->getStringWidth(_title) + 10;
- int maxWidth = width - sidesWidth - 7;
+ int maxWidth = MAX<int>(width - sidesWidth - 7, 0);
if (titleWidth > maxWidth)
titleWidth = maxWidth;
@@ -184,6 +184,11 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags,
warning("Attempt to draw %d x %d window", destination.w, destination.h);
return;
}
+
+ // we add a special check here, if we have title but the titleWidth is zero, then we try to recalc it
+ if ((flags & kWindowBorderTitle) && _border[flags]->getTitleWidth() == 0) {
+ setTitle(_title, destination.w, wm);
+ }
srf.create(destination.w, destination.h, destination.format);
srf.fillRect(Common::Rect(srf.w, srf.h), wm->_colorGreen2);
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 005c9b85e2..9fbc1d8623 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -306,7 +306,9 @@ public:
void loadDataBundle();
BorderOffsets getBorderOffsets(byte windowType);
- Common::SeekableReadStream *getBorderFile(byte windowType, bool isActive);
+ uint32 getBorderFlags(byte windowType);
+ int getBorderTitlePos(byte windowType);
+ Common::SeekableReadStream *getBorderFile(byte windowType, uint32 flags);
Common::SeekableReadStream *getFile(const Common::String &filename);
public:
Commit: 83341bedddf872ae4c82989c1d03856ef971766f
https://github.com/scummvm/scummvm/commit/83341bedddf872ae4c82989c1d03856ef971766f
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: modify the way that setBorderType set the border, currently, it will set all borders which is the subset of flag
Changed paths:
graphics/macgui/datafiles.cpp
graphics/macgui/macwindow.cpp
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 864dbb7553..1e0e6c376b 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -49,23 +49,23 @@ struct BorderName {
static const BorderName borders[] = {
{0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, kWindowBorderTitle, 23},
- {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}},
- {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}},
- {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}},
- {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false}},
- {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false}},
- {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}},
- {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}},
- {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}},
- {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}},
- {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}},
- {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}},
- {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}},
- {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}},
- {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}},
- {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}},
- {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true}},
- {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false}}
+ {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}, 0, 0},
+ {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
+ {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
+ {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
+ {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
+ {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
+ {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
+ {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
+ {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
+ {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
+ {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
+ {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
+ {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
+ {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
+ {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
+ {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true}, 0, 0},
+ {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false}, 0, 0}
};
Common::String windowTypeName(byte windowType) {
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 24ae0ee54e..3bf7904ed2 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -245,7 +245,7 @@ void MacWindow::drawBorder() {
uint32 flags = 0;
if (_active)
flags |= kWindowBorderActive;
- if (_borderFlags & kWindowBorderTitle)
+ if (!_title.empty())
flags |= kWindowBorderTitle;
if (_borderFlags & kWindowBorderScrollbar)
flags |= kWindowBorderScrollbar;
@@ -561,21 +561,19 @@ void MacWindow::setBorderType(int borderType) {
disableBorder();
} else {
BorderOffsets offsets = _wm->getBorderOffsets(borderType);
- uint32 flags = _wm->getBorderFlags(borderType);
- int titlePos = 0;
- if (flags & kWindowBorderTitle)
- titlePos = _wm->getBorderTitlePos(borderType);
- Common::SeekableReadStream *activeFile = _wm->getBorderFile(borderType, flags | kWindowBorderActive);
- if (activeFile) {
- loadBorder(*activeFile, flags | kWindowBorderActive, offsets, titlePos);
- delete activeFile;
- }
-
- Common::SeekableReadStream *inactiveFile = _wm->getBorderFile(borderType, flags);
- if (inactiveFile) {
- loadBorder(*inactiveFile, flags, offsets, titlePos);
- delete inactiveFile;
- }
+ uint32 flags = _wm->getBorderFlags(borderType) | kWindowBorderActive;
+ uint32 i = flags;
+ do {
+ int titlePos = 0;
+ if (i & kWindowBorderTitle)
+ titlePos = _wm->getBorderTitlePos(borderType);
+ Common::SeekableReadStream *file = _wm->getBorderFile(borderType, i);
+ if (file) {
+ loadBorder(*file, i, offsets, titlePos);
+ delete file;
+ }
+ i = (i - 1) & flags;
+ } while (i != flags);
}
}
Commit: aeacf0d4d2dc6ee28f4dc63aaf89232116b5298a
https://github.com/scummvm/scummvm/commit/aeacf0d4d2dc6ee28f4dc63aaf89232116b5298a
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: modify the position where it draws the title, currently, it will draw title at the center of title box
Changed paths:
graphics/macgui/datafiles.cpp
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
graphics/nine_patch.cpp
graphics/nine_patch.h
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 1e0e6c376b..f8a7fb1679 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -48,7 +48,7 @@ struct BorderName {
};
static const BorderName borders[] = {
- {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, kWindowBorderTitle, 23},
+ {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, kWindowBorderTitle, 25},
{0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}, 0, 0},
{0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
{0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 425beadef3..df5d49f40a 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -152,7 +152,7 @@ void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
_scrollSize = -1;
}
-void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm) {
+void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm, int titleOffset) {
const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
int width = g->w;
int titleColor = wm->_colorBlack;
@@ -164,7 +164,7 @@ void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm) {
if (titleWidth > maxWidth)
titleWidth = maxWidth;
- font->drawString(g, _title, (width - titleWidth) / 2 + 5, titleY + yOff, titleWidth, titleColor);
+ font->drawString(g, _title, titleOffset + 5, titleY + yOff, titleWidth, titleColor);
}
void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags, MacWindowManager *wm) {
@@ -198,7 +198,7 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags,
srf.free();
if (flags & kWindowBorderTitle)
- drawTitle(&destination, wm);
+ drawTitle(&destination, wm, src->getTitleOffset());
if (flags & kWindowBorderScrollbar)
drawScrollBar(&destination, wm);
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index cd056c6275..8407cd6918 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -123,7 +123,7 @@ public:
void setScroll(int scrollPos, int scrollSize) { _scrollPos = scrollPos, _scrollSize = scrollSize; }
- void drawTitle(ManagedSurface *g, MacWindowManager *wm);
+ void drawTitle(ManagedSurface *g, MacWindowManager *wm, int titleOffset);
void drawScrollBar(ManagedSurface *g, MacWindowManager *wm);
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index 19a2cbd466..d8792f47e7 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -154,6 +154,12 @@ void NinePatchSide::calcOffsets(int len, int titleIndex, int titleWidth) {
}
}
+int NinePatchBitmap::getTitleOffset() {
+ if (_titleIndex == 0)
+ return 0;
+ return _h._m[_titleIndex]->dest_offset;
+}
+
NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos, int titleWidth) {
int i;
uint8 r, g, b, a;
diff --git a/graphics/nine_patch.h b/graphics/nine_patch.h
index 4949cee3c4..1b6f64feac 100644
--- a/graphics/nine_patch.h
+++ b/graphics/nine_patch.h
@@ -100,6 +100,8 @@ public:
int getMinWidth() { return _h._fix; }
int getMinHeight() { return _v._fix; }
int getTitleWidth() { return _titleWidth; }
+ // always call it after you calc the offset, such as after you call blit, then you will get the right offset
+ int getTitleOffset();
Graphics::TransparentSurface *getSource() { return _bmp; }
Common::Rect &getPadding() { return _padding; }
Commit: c2353d3797713cc3c99b17017d01415e2043bde1
https://github.com/scummvm/scummvm/commit/c2353d3797713cc3c99b17017d01415e2043bde1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: use lazy load to load built-in border types, add scrollbar flag to indicate whether the window has scroll bar
Changed paths:
graphics/macgui/datafiles.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
graphics/macgui/macwindowmanager.h
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index f8a7fb1679..62842acaa5 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -41,31 +41,28 @@ struct BorderName {
byte type;
const char *name;
BorderOffsets offsets;
- uint32 flags;
int titlePos;
- BorderName(byte _type, const char *_name, BorderOffsets _offsets, uint32 _flags = 0, int _titlePos = 0):
- type(_type), name(_name), offsets(_offsets), flags(_flags), titlePos(_titlePos) {}
};
static const BorderName borders[] = {
- {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, kWindowBorderTitle, 25},
- {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}, 0, 0},
- {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
- {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
- {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
- {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
- {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
- {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
- {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
- {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
- {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
- {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
- {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0, 0},
- {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0, 0},
- {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0, 0},
- {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0, 0},
- {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true}, 0, 0},
- {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false}, 0, 0}
+ {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 25},
+ {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}, 0},
+ {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
+ {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
+ {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 0},
+ {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false}, 0},
+ {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
+ {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
+ {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0},
+ {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0},
+ {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
+ {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
+ {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0},
+ {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0},
+ {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
+ {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
+ {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true}, 0},
+ {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false}, 0}
};
Common::String windowTypeName(byte windowType) {
@@ -96,16 +93,6 @@ BorderOffsets MacWindowManager::getBorderOffsets(byte windowType) {
return borders[i].offsets;
}
-uint32 MacWindowManager::getBorderFlags(byte windowType) {
- int i = 0;
- while (borders[i].type != 0xFF) {
- if (borders[i].type == windowType)
- break;
- i++;
- }
- return borders[i].flags;
-}
-
int MacWindowManager::getBorderTitlePos(byte windowType) {
int i = 0;
while (borders[i].type != 0xFF) {
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 3bf7904ed2..de358d21ff 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -67,6 +67,10 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_borderType = -1;
_borderWidth = kBorderWidth;
+
+ _macBorder.setWindow(this);
+
+ _hasScrollBar = false;
}
static const byte noborderData[3][3] = {
@@ -196,9 +200,17 @@ void MacWindow::center(bool toCenter) {
Common::Rect screen = _wm->getScreenBounds();
+ uint32 flags = 0;
+ if (_active)
+ flags |= kWindowBorderActive;
+ if (!_title.empty())
+ flags |= kWindowBorderTitle;
+ if (_hasScrollBar)
+ flags |= kWindowBorderScrollbar;
+
if (toCenter) {
move((screen.width() - _dims.width()) / 2, (screen.height() - _dims.height()) / 2);
- } else if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
+ } else if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
move(_macBorder.getOffset().left, _macBorder.getOffset().top);
} else {
move(0, 0);
@@ -209,7 +221,15 @@ void MacWindow::updateInnerDims() {
if (_dims.isEmpty())
return;
- if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
+ uint32 flags = 0;
+ if (_active)
+ flags |= kWindowBorderActive;
+ if (!_title.empty())
+ flags |= kWindowBorderTitle;
+ if (_hasScrollBar)
+ flags |= kWindowBorderScrollbar;
+
+ if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
_innerDims = Common::Rect(
_dims.left + _macBorder.getOffset().left,
_dims.top + _macBorder.getOffset().top,
@@ -225,7 +245,15 @@ void MacWindow::updateOuterDims() {
if (_innerDims.isEmpty())
return;
- if (_macBorder.hasBorder(_borderFlags | _active) && _macBorder.hasOffsets()) {
+ uint32 flags = 0;
+ if (_active)
+ flags |= kWindowBorderActive;
+ if (!_title.empty())
+ flags |= kWindowBorderTitle;
+ if (_hasScrollBar)
+ flags |= kWindowBorderScrollbar;
+
+ if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
_dims = Common::Rect(
_innerDims.left - _macBorder.getOffset().left,
_innerDims.top - _macBorder.getOffset().top,
@@ -247,7 +275,7 @@ void MacWindow::drawBorder() {
flags |= kWindowBorderActive;
if (!_title.empty())
flags |= kWindowBorderTitle;
- if (_borderFlags & kWindowBorderScrollbar)
+ if (_hasScrollBar)
flags |= kWindowBorderScrollbar;
if (_macBorder.hasBorder(flags)) {
@@ -365,9 +393,6 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, B
_borderIsDirty = true;
_wm->setFullRefresh(true);
- // here we set the first bit zero, which indicate the active and inactive
- // because we will use _active flag to decide whether it's active or not
- _borderFlags = flags & 0xfffffffe;
}
void MacWindow::setCloseable(bool closeable) {
@@ -560,20 +585,25 @@ void MacWindow::setBorderType(int borderType) {
if (borderType < 0) {
disableBorder();
} else {
- BorderOffsets offsets = _wm->getBorderOffsets(borderType);
- uint32 flags = _wm->getBorderFlags(borderType) | kWindowBorderActive;
- uint32 i = flags;
- do {
- int titlePos = 0;
- if (i & kWindowBorderTitle)
- titlePos = _wm->getBorderTitlePos(borderType);
- Common::SeekableReadStream *file = _wm->getBorderFile(borderType, i);
- if (file) {
- loadBorder(*file, i, offsets, titlePos);
- delete file;
- }
- i = (i - 1) & flags;
- } while (i != flags);
+ for (uint i = 0; i < kWindowBorderMaxFlag; i++) {
+ _macBorder.lazyLoad(i);
+ }
+ }
+}
+
+void MacWindow::loadLazyBorder(uint32 flags) {
+ if (_borderType < 0) {
+ warning("trying to lazy load non-existing border type");
+ return;
+ }
+ BorderOffsets offsets = _wm->getBorderOffsets(_borderType);
+ Common::SeekableReadStream *file = _wm->getBorderFile(_borderType, flags);
+ int titlePos = 0;
+ if (flags & kWindowBorderTitle)
+ titlePos = _wm->getBorderTitlePos(_borderType);
+ if (file) {
+ loadBorder(*file, flags, offsets, titlePos);
+ delete file;
}
}
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 3e9e66e398..f1554ccda7 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -287,6 +287,7 @@ public:
/**
* See BaseMacWindow.
*/
+ void setScrollBar(bool active) { _hasScrollBar = active; }
virtual bool processEvent(Common::Event &event) override;
virtual bool hasAllFocus() override { return _beingDragged || _beingResized; }
@@ -307,6 +308,7 @@ public:
void setBorder(TransparentSurface *border, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
void disableBorder();
+ void loadLazyBorder(uint32 flags);
/**
* Indicate whether the window can be closed (false by default).
* @param closeable True if the window can be closed.
@@ -358,7 +360,6 @@ protected:
private:
MacWindowBorder _macBorder;
- uint32 _borderFlags;
int _pattern;
bool _hasPattern;
@@ -377,6 +378,7 @@ private:
Common::String _title;
+ bool _hasScrollBar;
int _borderType;
};
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index df5d49f40a..cd380aa0ac 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -33,10 +33,13 @@ MacWindowBorder::MacWindowBorder() {
_borderInitialized = Common::Array<bool>(_borderTypeNum);
_border = Common::Array<NinePatchBitmap *>(_borderTypeNum);
+ _lazyTag = Common::Array<bool>(_borderTypeNum);
+ _window = nullptr;
for (uint32 i = 0; i < _borderTypeNum; i++) {
_border[i] = nullptr;
_borderInitialized[i] = false;
+ _lazyTag[i] = false;
}
_borderOffsets.left = -1;
@@ -57,9 +60,13 @@ MacWindowBorder::~MacWindowBorder() {
bool MacWindowBorder::hasBorder(uint32 flags) {
if (flags >= _borderTypeNum) {
- warning("Accessing non-existed border type");
+ warning("Accessing non-existed border type, %d", flags);
return false;
}
+ if (_lazyTag[flags]) {
+ _lazyTag[flags] = false;
+ _window->loadLazyBorder(flags);
+ }
return _borderInitialized[flags];
}
@@ -134,6 +141,14 @@ void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindow
}
}
+void MacWindowBorder::lazyLoad(uint32 flags) {
+ if (flags >= _borderTypeNum) {
+ warning("trying to load non-existing border type");
+ return;
+ }
+ _lazyTag[flags] = true;
+}
+
void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
// here, we first check the _scrollSize, and if it is negative, then we don't draw the scrollBar
if (_scrollSize < 0)
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 8407cd6918..412444d9d3 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -34,10 +34,14 @@
namespace Graphics {
+class MacWindow;
+
enum {
- kWindowBorderActive = 1 << 0,
- kWindowBorderTitle = 1 << 1,
- kWindowBorderScrollbar = 1 << 2
+ kWindowBorderActive = 1 << 0,
+ kWindowBorderTitle = 1 << 1,
+ kWindowBorderScrollbar = 1 << 2,
+
+ kWindowBorderMaxFlag = 1 << 3
};
struct BorderOffsets {
@@ -127,16 +131,25 @@ public:
void drawScrollBar(ManagedSurface *g, MacWindowManager *wm);
+ void lazyLoad(uint32 flags);
+
+ // we should call this method as soon as the macwindowborder is constructed
+ void setWindow(MacWindow *window) { _window = window; }
+
private:
int _scrollPos, _scrollSize;
Common::String _title;
- const uint32 _borderTypeNum = 8;
+ const uint32 _borderTypeNum = kWindowBorderMaxFlag;
Common::Array<NinePatchBitmap *> _border;
Common::Array<bool> _borderInitialized;
+ Common::Array<bool> _lazyTag;
+
+ MacWindow *_window;
+
BorderOffsets _borderOffsets;
};
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 9fbc1d8623..105e7db2f9 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -306,7 +306,6 @@ public:
void loadDataBundle();
BorderOffsets getBorderOffsets(byte windowType);
- uint32 getBorderFlags(byte windowType);
int getBorderTitlePos(byte windowType);
Common::SeekableReadStream *getBorderFile(byte windowType, uint32 flags);
Common::SeekableReadStream *getFile(const Common::String &filename);
Commit: 7ea12368cf602a409b996a069e18723bdb30cdf7
https://github.com/scummvm/scummvm/commit/7ea12368cf602a409b996a069e18723bdb30cdf7
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
WAGE: set scrollbar of consoleWindow true, to suit for new logic in macgui
Changed paths:
engines/wage/gui.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6699d4576d..53baac0008 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -318,6 +318,7 @@ void Gui::loadBorders() {
loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", Graphics::kWindowBorderActive|Graphics::kWindowBorderTitle, 22, 36);
loadBorder(_consoleWindow, "wage_border_inact.bmp", Graphics::kWindowBorderScrollbar, 0, 0);
loadBorder(_consoleWindow, "wage_border_act.bmp", Graphics::kWindowBorderScrollbar|Graphics::kWindowBorderActive, 0, 0);
+ _consoleWindow->setScrollBar(true);
}
void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos, int titleWidth) {
Commit: 7f47b9f6c0135089348925d9ff24966de304f702
https://github.com/scummvm/scummvm/commit/7f47b9f6c0135089348925d9ff24966de304f702
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: move border stuff into macwindowborder
Changed paths:
engines/wage/gui.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 53baac0008..ac23c6e955 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -318,7 +318,7 @@ void Gui::loadBorders() {
loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", Graphics::kWindowBorderActive|Graphics::kWindowBorderTitle, 22, 36);
loadBorder(_consoleWindow, "wage_border_inact.bmp", Graphics::kWindowBorderScrollbar, 0, 0);
loadBorder(_consoleWindow, "wage_border_act.bmp", Graphics::kWindowBorderScrollbar|Graphics::kWindowBorderActive, 0, 0);
- _consoleWindow->setScrollBar(true);
+ _consoleWindow->enableScrollbar(true);
}
void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos, int titleWidth) {
@@ -329,7 +329,6 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint3
return;
}
- Image::BitmapDecoder bmpDecoder;
Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
if (stream) {
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index de358d21ff..156f6a1039 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -73,26 +73,8 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_hasScrollBar = false;
}
-static const byte noborderData[3][3] = {
- { 0, 1, 0 },
- { 1, 0, 1 },
- { 0, 1, 0 },
-};
-
void MacWindow::disableBorder() {
- Graphics::TransparentSurface *noborder = new Graphics::TransparentSurface();
- noborder->create(3, 3, noborder->getSupportedPixelFormat());
- uint32 colorBlack = noborder->getSupportedPixelFormat().RGBToColor(0, 0, 0);
- uint32 colorPink = noborder->getSupportedPixelFormat().RGBToColor(255, 0, 255);
-
- for (int y = 0; y < 3; y++)
- for (int x = 0; x < 3; x++)
- *((uint32 *)noborder->getBasePtr(x, y)) = noborderData[y][x] ? colorBlack : colorPink;
-
- setBorder(noborder, kWindowBorderActive);
-
- Graphics::TransparentSurface *noborder2 = new Graphics::TransparentSurface(*noborder, true);
- setBorder(noborder2, 0);
+ _macBorder.disableBorder();
}
const Font *MacWindow::getTitleFont() {
@@ -339,60 +321,17 @@ void MacWindow::setScroll(float scrollPos, float scrollSize) {
}
void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo, int ro, int to, int bo) {
- BorderOffsets offsets;
- offsets.left = lo;
- offsets.right = ro;
- offsets.top = to;
- offsets.bottom = bo;
- offsets.titleTop = -1;
- offsets.titleBottom = -1;
- offsets.dark = false;
- loadBorder(file, flags, offsets);
+ _macBorder.loadBorder(file, flags, lo, ro, to, bo);
}
void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
- Image::BitmapDecoder bmpDecoder;
- Graphics::Surface *source;
- Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
-
- bmpDecoder.loadStream(file);
- source = bmpDecoder.getSurface()->convertTo(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
-
- surface->create(source->w, source->h, _wm->_pixelformat);
- surface->copyFrom(*source);
-
- source->free();
- delete source;
-
- setBorder(surface, flags, offsets, titlePos, titleWidth);
-}
-
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo, int ro, int to, int bo) {
- BorderOffsets offsets;
- offsets.left = lo;
- offsets.right = ro;
- offsets.top = to;
- offsets.bottom = bo;
- offsets.titleTop = -1;
- offsets.titleBottom = -1;
- offsets.dark = false;
- setBorder(surface, flags, offsets);
+ _macBorder.loadBorder(file, flags, offsets, titlePos, titleWidth);
}
-void MacWindow::setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
- surface->applyColorKey(255, 0, 255, false);
-
- _macBorder.addBorder(surface, flags, titlePos, titleWidth);
-
- if ((flags & kWindowBorderActive) && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
- _macBorder.setOffsets(offsets);
- updateOuterDims();
- _borderSurface.free();
- _borderSurface.create(_dims.width(), _dims.height(), _wm->_pixelformat);
- }
-
- _borderIsDirty = true;
- _wm->setFullRefresh(true);
+void MacWindow::resizeBorderSurface() {
+ updateOuterDims();
+ _borderSurface.free();
+ _borderSurface.create(_dims.width(), _dims.height(), _wm->_pixelformat);
}
void MacWindow::setCloseable(bool closeable) {
@@ -583,27 +522,9 @@ bool MacWindow::processEvent(Common::Event &event) {
void MacWindow::setBorderType(int borderType) {
_borderType = borderType;
if (borderType < 0) {
- disableBorder();
+ _macBorder.disableBorder();
} else {
- for (uint i = 0; i < kWindowBorderMaxFlag; i++) {
- _macBorder.lazyLoad(i);
- }
- }
-}
-
-void MacWindow::loadLazyBorder(uint32 flags) {
- if (_borderType < 0) {
- warning("trying to lazy load non-existing border type");
- return;
- }
- BorderOffsets offsets = _wm->getBorderOffsets(_borderType);
- Common::SeekableReadStream *file = _wm->getBorderFile(_borderType, flags);
- int titlePos = 0;
- if (flags & kWindowBorderTitle)
- titlePos = _wm->getBorderTitlePos(_borderType);
- if (file) {
- loadBorder(*file, flags, offsets, titlePos);
- delete file;
+ _macBorder.setBorderType(borderType);
}
}
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index f1554ccda7..f373dc1d0e 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -287,7 +287,7 @@ public:
/**
* See BaseMacWindow.
*/
- void setScrollBar(bool active) { _hasScrollBar = active; }
+ void enableScrollbar(bool active) { _hasScrollBar = active; }
virtual bool processEvent(Common::Event &event) override;
virtual bool hasAllFocus() override { return _beingDragged || _beingResized; }
@@ -304,11 +304,8 @@ public:
*/
void loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
- void setBorder(TransparentSurface *border, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void setBorder(TransparentSurface *border, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
void disableBorder();
- void loadLazyBorder(uint32 flags);
/**
* Indicate whether the window can be closed (false by default).
* @param closeable True if the window can be closed.
@@ -333,6 +330,9 @@ public:
virtual bool isDirty() override { return _borderIsDirty || _contentIsDirty; }
+ void setBorderDirty(bool dirty) { _borderIsDirty = true; }
+ void resizeBorderSurface();
+
private:
void drawBorderFromSurface(ManagedSurface *g, uint32 flags);
void drawPattern();
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index cd380aa0ac..de0169eb87 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -29,18 +29,20 @@ namespace Graphics {
using namespace Graphics::MacGUIConstants;
+static const byte noborderData[3][3] = {
+ { 0, 1, 0 },
+ { 1, 0, 1 },
+ { 0, 1, 0 },
+};
+
MacWindowBorder::MacWindowBorder() {
- _borderInitialized = Common::Array<bool>(_borderTypeNum);
- _border = Common::Array<NinePatchBitmap *>(_borderTypeNum);
- _lazyTag = Common::Array<bool>(_borderTypeNum);
+ _border = Common::Array<NinePatchBitmap *>(kWindowBorderMaxFlag);
_window = nullptr;
+ _useInternalBorder = false;
- for (uint32 i = 0; i < _borderTypeNum; i++) {
+ for (uint32 i = 0; i < kWindowBorderMaxFlag; i++)
_border[i] = nullptr;
- _borderInitialized[i] = false;
- _lazyTag[i] = false;
- }
_borderOffsets.left = -1;
_borderOffsets.right = -1;
@@ -52,26 +54,41 @@ MacWindowBorder::MacWindowBorder() {
}
MacWindowBorder::~MacWindowBorder() {
- for (uint32 i = 0; i < _borderTypeNum; i++) {
+ for (uint32 i = 0; i < kWindowBorderMaxFlag; i++) {
if (_border[i])
delete _border[i];
}
}
bool MacWindowBorder::hasBorder(uint32 flags) {
- if (flags >= _borderTypeNum) {
+ if (flags >= kWindowBorderMaxFlag) {
warning("Accessing non-existed border type, %d", flags);
return false;
}
- if (_lazyTag[flags]) {
- _lazyTag[flags] = false;
- _window->loadLazyBorder(flags);
+ if (_useInternalBorder && !_border[flags]) {
+ loadInternalBorder(flags);
}
- return _borderInitialized[flags];
+ return _border[flags] != nullptr;
+}
+
+void MacWindowBorder::disableBorder() {
+ Graphics::TransparentSurface *noborder = new Graphics::TransparentSurface();
+ noborder->create(3, 3, noborder->getSupportedPixelFormat());
+ uint32 colorBlack = noborder->getSupportedPixelFormat().RGBToColor(0, 0, 0);
+ uint32 colorPink = noborder->getSupportedPixelFormat().RGBToColor(255, 0, 255);
+
+ for (int y = 0; y < 3; y++)
+ for (int x = 0; x < 3; x++)
+ *((uint32 *)noborder->getBasePtr(x, y)) = noborderData[y][x] ? colorBlack : colorPink;
+
+ setBorder(noborder, kWindowBorderActive);
+
+ Graphics::TransparentSurface *noborder2 = new Graphics::TransparentSurface(*noborder, true);
+ setBorder(noborder2, 0);
}
void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int titlePos, int titleWidth) {
- if (flags >= _borderTypeNum) {
+ if (flags >= kWindowBorderMaxFlag) {
warning("Accessing non-existed border type");
return;
}
@@ -79,24 +96,11 @@ void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int ti
delete _border[flags];
_border[flags] = new NinePatchBitmap(source, true, titlePos, titleWidth);
- _borderInitialized[flags] = true;
if (_border[flags]->getPadding().isValidRect() && _border[flags]->getPadding().left > -1 && _border[flags]->getPadding().top > -1)
setOffsets(_border[flags]->getPadding());
}
-void MacWindowBorder::modifyTitleWidth(uint32 flags, int titleWidth) {
- if (flags >= _borderTypeNum) {
- warning("Accessing non-existed border type");
- return;
- }
- if (!_borderInitialized[flags]) {
- warning("Trying to modify title width of an uninitialized border");
- return;
- }
- _border[flags]->modifyTitleWidth(titleWidth);
-}
-
bool MacWindowBorder::hasOffsets() {
return _borderOffsets.left > -1 && _borderOffsets.right > -1
&& _borderOffsets.top > -1 && _borderOffsets.bottom > -1;
@@ -135,20 +139,12 @@ void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindow
// if titleWidth is changed, then we modify it
// here, we change all the border that has title
- for (uint32 i = 0; i < _borderTypeNum; i++) {
- if (_borderInitialized[i] && (i & kWindowBorderTitle))
+ for (uint32 i = 0; i < kWindowBorderMaxFlag; i++) {
+ if ((_border[i] != nullptr) && (i & kWindowBorderTitle))
_border[i]->modifyTitleWidth(titleWidth);
}
}
-void MacWindowBorder::lazyLoad(uint32 flags) {
- if (flags >= _borderTypeNum) {
- warning("trying to load non-existing border type");
- return;
- }
- _lazyTag[flags] = true;
-}
-
void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
// here, we first check the _scrollSize, and if it is negative, then we don't draw the scrollBar
if (_scrollSize < 0)
@@ -182,8 +178,83 @@ void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm, int tit
font->drawString(g, _title, titleOffset + 5, titleY + yOff, titleWidth, titleColor);
}
+void MacWindowBorder::setBorderType(int type) {
+ _useInternalBorder = true;
+ _borderType = type;
+}
+
+void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo, int ro, int to, int bo) {
+ BorderOffsets offsets;
+ offsets.left = lo;
+ offsets.right = ro;
+ offsets.top = to;
+ offsets.bottom = bo;
+ offsets.titleTop = -1;
+ offsets.titleBottom = -1;
+ offsets.dark = false;
+ loadBorder(file, flags, offsets);
+}
+
+void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
+ Image::BitmapDecoder bmpDecoder;
+ Graphics::Surface *source;
+ Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
+
+ bmpDecoder.loadStream(file);
+ source = bmpDecoder.getSurface()->convertTo(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
+
+ surface->create(source->w, source->h, _window->_wm->_pixelformat);
+ surface->copyFrom(*source);
+
+ source->free();
+ delete source;
+
+ setBorder(surface, flags, offsets, titlePos, titleWidth);
+}
+
+void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo, int ro, int to, int bo) {
+ BorderOffsets offsets;
+ offsets.left = lo;
+ offsets.right = ro;
+ offsets.top = to;
+ offsets.bottom = bo;
+ offsets.titleTop = -1;
+ offsets.titleBottom = -1;
+ offsets.dark = false;
+ setBorder(surface, flags, offsets);
+}
+
+void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
+ surface->applyColorKey(255, 0, 255, false);
+ addBorder(surface, flags, titlePos, titleWidth);
+
+ if ((flags & kWindowBorderActive) && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
+ setOffsets(offsets);
+ _window->resizeBorderSurface();
+ }
+
+ _window->setBorderDirty(true);
+ _window->_wm->setFullRefresh(true);
+}
+
+void MacWindowBorder::loadInternalBorder(uint32 flags) {
+ if (_borderType < 0) {
+ warning("trying to load non-existing internal border type");
+ return;
+ }
+ BorderOffsets offsets = _window->_wm->getBorderOffsets(_borderType);
+ Common::SeekableReadStream *file = _window->_wm->getBorderFile(_borderType, flags);
+ int titlePos = 0;
+ if (flags & kWindowBorderTitle)
+ titlePos = _window->_wm->getBorderTitlePos(_borderType);
+ if (file) {
+ loadBorder(*file, flags, offsets, titlePos);
+ delete file;
+ }
+}
+
void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags, MacWindowManager *wm) {
- if (flags >= _borderTypeNum) {
+ if (flags >= kWindowBorderMaxFlag) {
warning("Accessing non-existed border type");
return;
}
@@ -191,8 +262,9 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags,
TransparentSurface srf;
NinePatchBitmap *src = _border[flags];
- if (!_borderInitialized[flags]) {
+ if (!src) {
warning("Attempt to blit uninitialized border");
+ return;
}
if (destination.w == 0 || destination.h == 0) {
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 412444d9d3..6183fe9deb 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -32,6 +32,8 @@
#include "graphics/macgui/macfontmanager.h"
#include "graphics/primitives.h"
+#include "image/bmp.h"
+
namespace Graphics {
class MacWindow;
@@ -121,8 +123,6 @@ public:
*/
void blitBorderInto(ManagedSurface &destination, uint32 flags, MacWindowManager *wm);
- void modifyTitleWidth(uint32 flags, int titleWidth);
-
void setTitle(const Common::String& title, int width, MacWindowManager *wm);
void setScroll(int scrollPos, int scrollSize) { _scrollPos = scrollPos, _scrollSize = scrollSize; }
@@ -131,27 +131,32 @@ public:
void drawScrollBar(ManagedSurface *g, MacWindowManager *wm);
- void lazyLoad(uint32 flags);
-
// we should call this method as soon as the macwindowborder is constructed
void setWindow(MacWindow *window) { _window = window; }
+ void setBorderType(int type);
+
+ void disableBorder();
+
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void loadInternalBorder(uint32 flags);
+
+ void setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
+ void setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
private:
int _scrollPos, _scrollSize;
Common::String _title;
- const uint32 _borderTypeNum = kWindowBorderMaxFlag;
-
Common::Array<NinePatchBitmap *> _border;
- Common::Array<bool> _borderInitialized;
-
- Common::Array<bool> _lazyTag;
-
MacWindow *_window;
BorderOffsets _borderOffsets;
+ bool _useInternalBorder;
+
+ int _borderType;
};
} // End of namespace Graphics
Commit: 3b53a4f2f71a827e99ba359465219d8010c58630
https://github.com/scummvm/scummvm/commit/3b53a4f2f71a827e99ba359465219d8010c58630
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: move titlePos into BorderOffsets
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
graphics/macgui/datafiles.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
graphics/macgui/macwindowmanager.h
graphics/nine_patch.cpp
graphics/nine_patch.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index ac23c6e955..83f41cb6f9 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -314,14 +314,14 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
}
void Gui::loadBorders() {
- loadBorder(_sceneWindow, "wage_border_inact-title.bmp", Graphics::kWindowBorderTitle, 22, 36);
- loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", Graphics::kWindowBorderActive|Graphics::kWindowBorderTitle, 22, 36);
- loadBorder(_consoleWindow, "wage_border_inact.bmp", Graphics::kWindowBorderScrollbar, 0, 0);
- loadBorder(_consoleWindow, "wage_border_act.bmp", Graphics::kWindowBorderScrollbar|Graphics::kWindowBorderActive, 0, 0);
+ loadBorder(_sceneWindow, "wage_border_inact-title.bmp", Graphics::kWindowBorderTitle, 22);
+ loadBorder(_sceneWindow, "wage_border_act-noscrollbar-title.bmp", Graphics::kWindowBorderActive|Graphics::kWindowBorderTitle, 22);
+ loadBorder(_consoleWindow, "wage_border_inact.bmp", Graphics::kWindowBorderScrollbar, 0);
+ loadBorder(_consoleWindow, "wage_border_act.bmp", Graphics::kWindowBorderScrollbar|Graphics::kWindowBorderActive, 0);
_consoleWindow->enableScrollbar(true);
}
-void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos, int titleWidth) {
+void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos) {
Common::File borderfile;
if (!borderfile.open(filename)) {
@@ -341,7 +341,8 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint3
offsets.titleTop = 0;
offsets.titleBottom = 0;
offsets.dark = false;
- target->loadBorder(*stream, flags, offsets, titlePos, titleWidth);
+ offsets.titlePos = titlePos;
+ target->loadBorder(*stream, flags, offsets);
} else {
target->loadBorder(*stream, flags);
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 3b66fdf12b..83dc54bbb9 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -150,7 +150,7 @@ private:
const Graphics::Font *getTitleFont();
void loadBorders();
- void loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos = 0, int titleWidth = 0);
+ void loadBorder(Graphics::MacWindow *target, Common::String filename, uint32 flags, int titlePos = 0);
public:
Graphics::ManagedSurface _screen;
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 62842acaa5..e08a43c6b1 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -41,28 +41,27 @@ struct BorderName {
byte type;
const char *name;
BorderOffsets offsets;
- int titlePos;
};
static const BorderName borders[] = {
- {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 25},
- {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false}, 0},
- {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
- {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
- {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false}, 0},
- {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false}, 0},
- {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
- {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
- {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0},
- {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0},
- {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
- {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
- {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false}, 0},
- {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false}, 0},
- {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false}, 0},
- {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false}, 0},
- {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true}, 0},
- {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false}, 0}
+ {0x00, "StandardClose", { 1, 2, 19, 2, 2, 2, false, 25}},
+ {0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false, 0}},
+ {0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
+ {0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
+ {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false, 0}},
+ {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
+ {0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
+ {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 0}},
+ {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
+ {0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
+ {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 0}},
+ {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
+ {0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
+ {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true, 0}},
+ {0xFF, "No type", {-1, -1, -1, -1, -1, -1, false, 0}}
};
Common::String windowTypeName(byte windowType) {
@@ -93,16 +92,6 @@ BorderOffsets MacWindowManager::getBorderOffsets(byte windowType) {
return borders[i].offsets;
}
-int MacWindowManager::getBorderTitlePos(byte windowType) {
- int i = 0;
- while (borders[i].type != 0xFF) {
- if (borders[i].type == windowType)
- break;
- i++;
- }
- return borders[i].titlePos;
-}
-
Common::SeekableReadStream *MacWindowManager::getBorderFile(byte windowType, uint32 flags) {
if (!_dataBundle)
return NULL;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 156f6a1039..e0d4f83c01 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -324,8 +324,8 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, int l
_macBorder.loadBorder(file, flags, lo, ro, to, bo);
}
-void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
- _macBorder.loadBorder(file, flags, offsets, titlePos, titleWidth);
+void MacWindow::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets) {
+ _macBorder.loadBorder(file, flags, offsets);
}
void MacWindow::resizeBorderSurface() {
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index f373dc1d0e..f2ba347421 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -303,7 +303,7 @@ public:
* @param bo Width of the bottom side of the border, in pixels.
*/
void loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets);
void disableBorder();
/**
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index de0169eb87..1c82a8ea33 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -87,7 +87,7 @@ void MacWindowBorder::disableBorder() {
setBorder(noborder2, 0);
}
-void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int titlePos, int titleWidth) {
+void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int titlePos) {
if (flags >= kWindowBorderMaxFlag) {
warning("Accessing non-existed border type");
return;
@@ -95,7 +95,7 @@ void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int ti
if (_border[flags])
delete _border[flags];
- _border[flags] = new NinePatchBitmap(source, true, titlePos, titleWidth);
+ _border[flags] = new NinePatchBitmap(source, true, titlePos);
if (_border[flags]->getPadding().isValidRect() && _border[flags]->getPadding().left > -1 && _border[flags]->getPadding().top > -1)
setOffsets(_border[flags]->getPadding());
@@ -191,11 +191,12 @@ void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags,
offsets.bottom = bo;
offsets.titleTop = -1;
offsets.titleBottom = -1;
+ offsets.titlePos = 0;
offsets.dark = false;
loadBorder(file, flags, offsets);
}
-void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
+void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets) {
Image::BitmapDecoder bmpDecoder;
Graphics::Surface *source;
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
@@ -209,7 +210,7 @@ void MacWindowBorder::loadBorder(Common::SeekableReadStream &file, uint32 flags,
source->free();
delete source;
- setBorder(surface, flags, offsets, titlePos, titleWidth);
+ setBorder(surface, flags, offsets);
}
void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo, int ro, int to, int bo) {
@@ -220,13 +221,14 @@ void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 fl
offsets.bottom = bo;
offsets.titleTop = -1;
offsets.titleBottom = -1;
+ offsets.titlePos = 0;
offsets.dark = false;
setBorder(surface, flags, offsets);
}
-void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos, int titleWidth) {
+void MacWindowBorder::setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets) {
surface->applyColorKey(255, 0, 255, false);
- addBorder(surface, flags, titlePos, titleWidth);
+ addBorder(surface, flags, offsets.titlePos);
if ((flags & kWindowBorderActive) && offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
setOffsets(offsets);
@@ -244,11 +246,8 @@ void MacWindowBorder::loadInternalBorder(uint32 flags) {
}
BorderOffsets offsets = _window->_wm->getBorderOffsets(_borderType);
Common::SeekableReadStream *file = _window->_wm->getBorderFile(_borderType, flags);
- int titlePos = 0;
- if (flags & kWindowBorderTitle)
- titlePos = _window->_wm->getBorderTitlePos(_borderType);
if (file) {
- loadBorder(*file, flags, offsets, titlePos);
+ loadBorder(*file, flags, offsets);
delete file;
}
}
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 6183fe9deb..52abbb41e7 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -54,6 +54,7 @@ struct BorderOffsets {
int titleTop;
int titleBottom;
bool dark;
+ int titlePos;
};
/**
@@ -79,9 +80,8 @@ public:
* @param The surface that will be displayed.
* @param The border type indicated by flag
* @param The title position of bmp image
- * @param The title width that you want to set
*/
- void addBorder(TransparentSurface *source, uint32 flags, int titlePos = 0, int titleWidth = 0);
+ void addBorder(TransparentSurface *source, uint32 flags, int titlePos = 0);
/**
* Accessor function for the custom offsets.
@@ -139,11 +139,11 @@ public:
void disableBorder();
void loadBorder(Common::SeekableReadStream &file, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void loadBorder(Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets);
void loadInternalBorder(uint32 flags);
void setBorder(Graphics::TransparentSurface *surface, uint32 flags, int lo = -1, int ro = -1, int to = -1, int bo = -1);
- void setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets, int titlePos = 0, int titleWidth = 0);
+ void setBorder(Graphics::TransparentSurface *surface, uint32 flags, BorderOffsets offsets);
private:
int _scrollPos, _scrollSize;
Common::String _title;
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 105e7db2f9..d0b2149053 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -306,7 +306,6 @@ public:
void loadDataBundle();
BorderOffsets getBorderOffsets(byte windowType);
- int getBorderTitlePos(byte windowType);
Common::SeekableReadStream *getBorderFile(byte windowType, uint32 flags);
Common::SeekableReadStream *getFile(const Common::String &filename);
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index d8792f47e7..f8068c85c2 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -61,7 +61,7 @@ NinePatchSide::~NinePatchSide() {
}
-bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos, int titleWidth, int *titleIndex) {
+bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos, int *titleIndex) {
const uint len = vertical ? bmp->h : bmp->w;
uint i;
int s, t, z;
@@ -160,7 +160,7 @@ int NinePatchBitmap::getTitleOffset() {
return _h._m[_titleIndex]->dest_offset;
}
-NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos, int titleWidth) {
+NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos) {
int i;
uint8 r, g, b, a;
@@ -173,7 +173,7 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
_width = bmp->w - 2;
_height = bmp->h - 2;
_titleIndex = 0;
- _titleWidth = titleWidth;
+ _titleWidth = 0;
_titlePos = titlePos;
if (_width <= 0 || _height <= 0)
@@ -224,7 +224,7 @@ NinePatchBitmap::NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bi
++i;
}
- if (!_h.init(bmp, false, titlePos, titleWidth, &_titleIndex) || !_v.init(bmp, true)) {
+ if (!_h.init(bmp, false, titlePos, &_titleIndex) || !_v.init(bmp, true)) {
bad_bitmap:
warning("NinePatchBitmap::NinePatchBitmap(): Bad bitmap");
diff --git a/graphics/nine_patch.h b/graphics/nine_patch.h
index 1b6f64feac..fe9caf6d2f 100644
--- a/graphics/nine_patch.h
+++ b/graphics/nine_patch.h
@@ -72,7 +72,7 @@ public:
NinePatchSide() : _fix(0) { _m.clear(); }
~NinePatchSide();
- bool init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos = 0, int titleWidth = 0, int *titleIndex = nullptr);
+ bool init(Graphics::TransparentSurface *bmp, bool vertical, int titlePos = 0, int *titleIndex = nullptr);
void calcOffsets(int len, int titleIndex = 0, int titleWidth = 0);
};
@@ -88,7 +88,7 @@ class NinePatchBitmap {
Common::HashMap<uint32, int> _cached_colors;
public:
- NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos = 0, int titleWidth = 0);
+ NinePatchBitmap(Graphics::TransparentSurface *bmp, bool owns_bitmap, int titlePos = 0);
~NinePatchBitmap();
void blit(Graphics::Surface &target, int dx, int dy, int dw, int dh, byte *palette = NULL, int numColors = 0, MacWindowManager *wm = NULL, uint32 transColor = 0);
Commit: dc2861dbed7f3fd572a6aea60a8b4a32063a9eb4
https://github.com/scummvm/scummvm/commit/dc2861dbed7f3fd572a6aea60a8b4a32063a9eb4
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: fix the bug when we calc the 9-patch offset
Changed paths:
graphics/nine_patch.cpp
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index f8068c85c2..ea54e42b21 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -66,6 +66,7 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int t
uint i;
int s, t, z;
+ int titleWidth = 0;
int index = 0;
_m.clear();
@@ -101,6 +102,7 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int t
// if there is title, then we try to recalc the t, because we want to fix the title width
if (titlePos > 0 && (int)i == titlePos) {
t -= mrk->length;
+ titleWidth = mrk->length;
if (titleIndex)
*titleIndex = index;
}
@@ -113,6 +115,10 @@ bool NinePatchSide::init(Graphics::TransparentSurface *bmp, bool vertical, int t
}
_fix = len - 2 - t;
+ // here, titleWidth represent the width in 9-patch image, and we delete it from fix size
+ // so, currently, we will have 3 part, fix size, stretchable size and title size
+ if (titleWidth)
+ _fix -= titleWidth;
for (i = 0; i < _m.size(); ++i) {
if (_m[i]->ratio)
_m[i]->ratio = _m[i]->length / (float)t;
Commit: b8f8fdbf19102fb5e67428c1e3e639c5a4879bcf
https://github.com/scummvm/scummvm/commit/b8f8fdbf19102fb5e67428c1e3e639c5a4879bcf
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: make title color depend on the border color
Changed paths:
graphics/macgui/macwindowborder.cpp
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 1c82a8ea33..7c9f792af7 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -166,7 +166,7 @@ void MacWindowBorder::drawScrollBar(ManagedSurface *g, MacWindowManager *wm) {
void MacWindowBorder::drawTitle(ManagedSurface *g, MacWindowManager *wm, int titleOffset) {
const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
int width = g->w;
- int titleColor = wm->_colorBlack;
+ int titleColor = getOffset().dark ? wm->_colorWhite: wm->_colorBlack;
int titleY = getOffset().titleTop;
int sidesWidth = getOffset().left + getOffset().right;
int titleWidth = font->getStringWidth(_title) + 10;
Commit: 39b84a1574f0070477b995b7732d596dee249ebf
https://github.com/scummvm/scummvm/commit/39b84a1574f0070477b995b7732d596dee249ebf
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: modify the titlePos in datafiles
Changed paths:
graphics/macgui/datafiles.cpp
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index e08a43c6b1..d834b89ae4 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -48,19 +48,19 @@ static const BorderName borders[] = {
{0x01, "ThickNoTitle", { 5, 5, 5, 5, -1, -1, false, 0}},
{0x02, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
{0x03, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
- {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false, 0}},
- {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x04, "StandardClose", { 1, 2, 19, 2, 2, 2, false, 25}},
+ {0x05, "Thick", { 5, 5, 20, 5, 2, 3, false, 13}},
{0x06, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
{0x07, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
- {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 0}},
- {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x08, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 25}},
+ {0x09, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 13}},
{0x0A, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
{0x0B, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
- {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 0}},
- {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 0}},
+ {0x0C, "StandardCloseZoom", { 1, 2, 19, 2, 2, 2, false, 25}},
+ {0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 13}},
{0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
{0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
- {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true, 0}},
+ {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true, 25}},
{0xFF, "No type", {-1, -1, -1, -1, -1, -1, false, 0}}
};
Commit: 0d825ef4de1021eabe44bf259f9051a31ed46c8e
https://github.com/scummvm/scummvm/commit/0d825ef4de1021eabe44bf259f9051a31ed46c8e
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: add title for 9-patch images of build-in borders
Changed paths:
dists/engine-data/macgui.dat
diff --git a/dists/engine-data/macgui.dat b/dists/engine-data/macgui.dat
index 5988afd319..24872936ff 100644
Binary files a/dists/engine-data/macgui.dat and b/dists/engine-data/macgui.dat differ
Commit: 3b47e56155258ec6e4a3d624955127d11c175809
https://github.com/scummvm/scummvm/commit/3b47e56155258ec6e4a3d624955127d11c175809
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-04-12T14:04:25+02:00
Commit Message:
GRAPHICS: MACGUI: clean the codes
Changed paths:
engines/wage/gui.cpp
graphics/macgui/datafiles.cpp
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
graphics/nine_patch.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 83f41cb6f9..c922526f28 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -332,6 +332,8 @@ void Gui::loadBorder(Graphics::MacWindow *target, Common::String filename, uint3
Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
if (stream) {
+ // if titlePos != 0, then we will draw title for that window
+ // here, we draw title for scene window
if (titlePos != 0) {
Graphics::BorderOffsets offsets;
offsets.left = 16;
diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index d834b89ae4..a0f7fdffdc 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -60,7 +60,7 @@ static const BorderName borders[] = {
{0x0D, "ThickZoom", { 5, 5, 20, 5, 2, 3, false, 13}},
{0x0E, "ThinNoTitle", { 1, 1, 1, 1, -1, -1, false, 0}},
{0x0F, "ThinNoTitleShadow", { 1, 3, 1, 3, -1, -1, false, 0}},
- {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true, 25}},
+ {0x10, "RoundClose", { 1, 1, 19, 6, 1, 1, true, 25}},
{0xFF, "No type", {-1, -1, -1, -1, -1, -1, false, 0}}
};
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index e0d4f83c01..41eb43c6b2 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -176,12 +176,7 @@ void MacWindow::blit(ManagedSurface *g, Common::Rect &dest) {
g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, transcolor);
}
-void MacWindow::center(bool toCenter) {
- if (!_wm)
- return;
-
- Common::Rect screen = _wm->getScreenBounds();
-
+uint32 MacWindow::getBorderFlags() {
uint32 flags = 0;
if (_active)
flags |= kWindowBorderActive;
@@ -189,7 +184,16 @@ void MacWindow::center(bool toCenter) {
flags |= kWindowBorderTitle;
if (_hasScrollBar)
flags |= kWindowBorderScrollbar;
+ return flags;
+}
+void MacWindow::center(bool toCenter) {
+ if (!_wm)
+ return;
+
+ Common::Rect screen = _wm->getScreenBounds();
+
+ uint32 flags = getBorderFlags();
if (toCenter) {
move((screen.width() - _dims.width()) / 2, (screen.height() - _dims.height()) / 2);
} else if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
@@ -203,13 +207,7 @@ void MacWindow::updateInnerDims() {
if (_dims.isEmpty())
return;
- uint32 flags = 0;
- if (_active)
- flags |= kWindowBorderActive;
- if (!_title.empty())
- flags |= kWindowBorderTitle;
- if (_hasScrollBar)
- flags |= kWindowBorderScrollbar;
+ uint32 flags = getBorderFlags();
if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
_innerDims = Common::Rect(
@@ -227,13 +225,7 @@ void MacWindow::updateOuterDims() {
if (_innerDims.isEmpty())
return;
- uint32 flags = 0;
- if (_active)
- flags |= kWindowBorderActive;
- if (!_title.empty())
- flags |= kWindowBorderTitle;
- if (_hasScrollBar)
- flags |= kWindowBorderScrollbar;
+ uint32 flags = getBorderFlags();
if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
_dims = Common::Rect(
@@ -252,13 +244,7 @@ void MacWindow::drawBorder() {
ManagedSurface *g = &_borderSurface;
- uint32 flags = 0;
- if (_active)
- flags |= kWindowBorderActive;
- if (!_title.empty())
- flags |= kWindowBorderTitle;
- if (_hasScrollBar)
- flags |= kWindowBorderScrollbar;
+ uint32 flags = getBorderFlags();
if (_macBorder.hasBorder(flags)) {
drawBorderFromSurface(g, flags);
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index f2ba347421..36342f3afe 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -323,6 +323,12 @@ public:
*/
int getBorderType() { return _borderType; };
+ /**
+ * We should call this method whenever we need border flags
+ * don't calc border flags yourself
+ * @return Border flags
+ */
+ uint32 getBorderFlags();
void addDirtyRect(const Common::Rect &r);
void markAllDirty();
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index 7c9f792af7..8250aeaa12 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -24,6 +24,7 @@
#include "graphics/macgui/macwindowborder.h"
#include "graphics/macgui/macwindowmanager.h"
+#include "graphics/macgui/macfontmanager.h"
namespace Graphics {
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 52abbb41e7..b43575378a 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -26,10 +26,8 @@
#include "common/str.h"
#include "common/list.h"
-#include "graphics/nine_patch.h"
#include "graphics/managed_surface.h"
#include "graphics/transparent_surface.h"
-#include "graphics/macgui/macfontmanager.h"
#include "graphics/primitives.h"
#include "image/bmp.h"
@@ -37,13 +35,15 @@
namespace Graphics {
class MacWindow;
+class MacWindowManager;
+class NinePatchBitmap;
enum {
- kWindowBorderActive = 1 << 0,
- kWindowBorderTitle = 1 << 1,
+ kWindowBorderActive = 1 << 0,
+ kWindowBorderTitle = 1 << 1,
kWindowBorderScrollbar = 1 << 2,
- kWindowBorderMaxFlag = 1 << 3
+ kWindowBorderMaxFlag = 1 << 3
};
struct BorderOffsets {
diff --git a/graphics/nine_patch.cpp b/graphics/nine_patch.cpp
index ea54e42b21..71c8c973e9 100644
--- a/graphics/nine_patch.cpp
+++ b/graphics/nine_patch.cpp
@@ -131,10 +131,12 @@ void NinePatchSide::calcOffsets(int len, int titleIndex, int titleWidth) {
uint i, j;
int dest_offset = 0;
// if we don't got titleIndex, then we better set titleWidth to 0
- if (titleIndex == 0) titleWidth = 0;
+ if (titleIndex == 0)
+ titleWidth = 0;
int remaining_stretch = len - _fix - titleWidth;
// if titleWidth is too big, which may cause the remaining_stretch be 0, so we check it here
- if (remaining_stretch < 0) remaining_stretch = 0;
+ if (remaining_stretch < 0)
+ remaining_stretch = 0;
for (i = 0, j = 0; i < _m.size(); ++i) {
_m[i]->dest_offset = dest_offset;
@@ -250,7 +252,8 @@ void NinePatchBitmap::blit(Graphics::Surface &target, int dx, int dy, int dw, in
if (dw < _h._fix || dh < _v._fix)
return;
- if (dw < _h._fix + _titleWidth) dw = _h._fix + _titleWidth;
+ if (dw < _h._fix + _titleWidth)
+ dw = _h._fix + _titleWidth;
/* if the bitmap is the same size as the origin, then draw it as-is */
if (dw == _width && dh == _height) {
Common::Rect r(1, 1, dw, dh);
More information about the Scummvm-git-logs
mailing list