[Scummvm-git-logs] scummvm master -> c29ccaa0bbe450f2dd321613de769b3b2dbc3dd0

djsrv dservilla at gmail.com
Wed Aug 5 23:20:36 UTC 2020


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
43f999d8a8 GRAPHICS: MACGUI: Fix mistakes in border defs
74f0434d42 GRAPHICS: MACGUI: Add _colorOffWhite
c29ccaa0bb GRAPHICS: MACGUI: Draw title on ninepatch borders


Commit: 43f999d8a85f4bc71b7d82bbb8b7c03c6acf618f
    https://github.com/scummvm/scummvm/commit/43f999d8a85f4bc71b7d82bbb8b7c03c6acf618f
Author: djsrv (dservilla at gmail.com)
Date: 2020-08-05T19:20:14-04:00

Commit Message:
GRAPHICS: MACGUI: Fix mistakes in border defs

Changed paths:
    graphics/macgui/datafiles.cpp


diff --git a/graphics/macgui/datafiles.cpp b/graphics/macgui/datafiles.cpp
index 8d3fe6a93d..954e683371 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -47,19 +47,19 @@ struct BorderName {
 };
 
 static const BorderName borders[] = {
-	{0x00, "StandardClose",		1, 2, 20, 2},
+	{0x00, "StandardClose",		1, 2, 19, 2},
 	{0x01, "ThickNoTitle",		5, 5, 5, 5},
 	{0x02, "ThinNoTitle",		1, 1, 1, 1},
 	{0x03, "ThinNoTitleShadow",	1, 3, 1, 3},
-	{0x04, "StandardClose",		1, 2, 20, 2},
+	{0x04, "StandardClose",		1, 2, 19, 2},
 	{0x05, "Thick",				5, 5, 20, 5},
 	{0x06, "ThinNoTitle",		1, 1, 1, 1},
 	{0x07, "ThinNoTitleShadow",	1, 3, 1, 3},
-	{0x08, "StandardCloseZoom",	1, 2, 20, 2},
+	{0x08, "StandardCloseZoom",	1, 2, 19, 2},
 	{0x09, "ThickZoom",			5, 5, 20, 5},
 	{0x0A, "ThinNoTitle",		1, 1, 1, 1},
-	{0x0B, "ThinkNoTitleShadow", 1, 3, 1, 3},
-	{0x0C, "StandardCloseZoom",	1, 2, 20, 2},
+	{0x0B, "ThinNoTitleShadow", 1, 3, 1, 3},
+	{0x0C, "StandardCloseZoom",	1, 2, 19, 2},
 	{0x0D, "ThickZoom",			5, 5, 20, 5},
 	{0x0E, "ThinNoTitle",		1, 1, 1, 1},
 	{0x0F, "ThinNoTitleShadow", 1, 3, 1, 3},


Commit: 74f0434d42237d871ac47f056ba5acaad4b3ce33
    https://github.com/scummvm/scummvm/commit/74f0434d42237d871ac47f056ba5acaad4b3ce33
Author: djsrv (dservilla at gmail.com)
Date: 2020-08-05T19:20:14-04:00

Commit Message:
GRAPHICS: MACGUI: Add _colorOffWhite

Changed paths:
    graphics/macgui/macwindowmanager.cpp
    graphics/macgui/macwindowmanager.h


diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index daea2fa2d6..b41b80551f 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -41,7 +41,8 @@ static const byte palette[] = {
 	0x80, 0x80, 0x80,  // Gray
 	0xff, 0xff, 0xff,  // White
 	0x00, 0xff, 0x00,  // Green
-	0x00, 0xcf, 0x00   // Green2
+	0x00, 0xcf, 0x00,  // Green2
+	0xee, 0xee, 0xee   // OffWhite
 };
 
 static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
@@ -174,6 +175,7 @@ MacWindowManager::MacWindowManager(uint32 mode, MacPatterns *patterns) {
 
 	_colorBlack = 0;
 	_colorWhite = 2;
+	_colorOffWhite = 5;
 
 	_fullRefresh = true;
 
@@ -766,6 +768,7 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	_colorHash.clear();
 
 	_colorWhite = -1;
+	_colorOffWhite = -1;
 	_colorBlack = -1;
 
 	// Search pure white and black colors
@@ -773,6 +776,8 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 		if (_colorWhite == -1 && p[0] == 0xff && p[1] == 0xff && p[2] == 0xff)
 			_colorWhite = i;
 
+		if (_colorOffWhite == -1 && p[0] == 0xee && p[1] == 0xee && p[2] == 0xee)
+			_colorOffWhite = i;
 
 		if (_colorBlack == -1 && p[0] == 0x00 && p[1] == 0x00 && p[2] == 0x00)
 			_colorBlack = i;
@@ -782,7 +787,7 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 		_palette[i * 3 + 2] = *p++;
 	}
 
-	if (_colorWhite != -1 && _colorBlack != -1)
+	if (_colorWhite != -1 && _colorOffWhite != -1 && _colorBlack != -1)
 		return;
 
 	// We did not find some color. Let's find closest approximations
@@ -807,6 +812,7 @@ void MacWindowManager::passPalette(const byte *pal, uint size) {
 	}
 
 	_colorWhite = bi;
+	_colorOffWhite = bi;
 	_colorBlack = di;
 }
 
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index 80d89f4866..bc57b72533 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -50,6 +50,7 @@ enum {
 	kColorWhite = 2,
 	kColorGreen = 3,
 	kColorGreen2 = 4,
+	kColorOffWhite = 5,
 	kColorCount
 };
 
@@ -302,7 +303,7 @@ public:
 	bool _menuTimerActive;
 	bool _mouseDown;
 
-	int _colorBlack, _colorWhite;
+	int _colorBlack, _colorWhite, _colorOffWhite;
 
 	MacWidget *_hoveredWidget;
 


Commit: c29ccaa0bbe450f2dd321613de769b3b2dbc3dd0
    https://github.com/scummvm/scummvm/commit/c29ccaa0bbe450f2dd321613de769b3b2dbc3dd0
Author: djsrv (dservilla at gmail.com)
Date: 2020-08-05T19:20:14-04:00

Commit Message:
GRAPHICS: MACGUI: Draw title on ninepatch borders

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 954e683371..d0e5b78ad0 100644
--- a/graphics/macgui/datafiles.cpp
+++ b/graphics/macgui/datafiles.cpp
@@ -40,31 +40,28 @@ namespace Graphics {
 struct BorderName {
 	byte type;
 	const char *name;
-	int lo;
-	int ro;
-	int to;
-	int bo;
+	BorderOffsets offsets;
 };
 
 static const BorderName borders[] = {
-	{0x00, "StandardClose",		1, 2, 19, 2},
-	{0x01, "ThickNoTitle",		5, 5, 5, 5},
-	{0x02, "ThinNoTitle",		1, 1, 1, 1},
-	{0x03, "ThinNoTitleShadow",	1, 3, 1, 3},
-	{0x04, "StandardClose",		1, 2, 19, 2},
-	{0x05, "Thick",				5, 5, 20, 5},
-	{0x06, "ThinNoTitle",		1, 1, 1, 1},
-	{0x07, "ThinNoTitleShadow",	1, 3, 1, 3},
-	{0x08, "StandardCloseZoom",	1, 2, 19, 2},
-	{0x09, "ThickZoom",			5, 5, 20, 5},
-	{0x0A, "ThinNoTitle",		1, 1, 1, 1},
-	{0x0B, "ThinNoTitleShadow", 1, 3, 1, 3},
-	{0x0C, "StandardCloseZoom",	1, 2, 19, 2},
-	{0x0D, "ThickZoom",			5, 5, 20, 5},
-	{0x0E, "ThinNoTitle",		1, 1, 1, 1},
-	{0x0F, "ThinNoTitleShadow", 1, 3, 1, 3},
-	{0x10, "RoundClose",		1, 1, 19, 6},
-	{0xFF, "No type",			-1, -1, -1, -1}
+	{0x00, "StandardClose",		 1,  2, 19,  2,		 2,  2,		false},
+	{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}
 };
 
 Common::String windowTypeName(byte windowType) {
@@ -85,20 +82,14 @@ void MacWindowManager::loadDataBundle() {
 	}
 }
 
-Common::Rect MacWindowManager::getBorderOffsets(byte windowType) {
+BorderOffsets MacWindowManager::getBorderOffsets(byte windowType) {
 	int i = 0;
 	while (borders[i].type != 0xFF) {
-		if (borders[i].type == windowType) {
-			Common::Rect offsets;
-			offsets.left = borders[i].lo;
-			offsets.right = borders[i].ro;
-			offsets.top = borders[i].to;
-			offsets.bottom = borders[i].bo;
-			return offsets;
-		}
+		if (borders[i].type == windowType)
+			break;
 		i++;
 	}
-	return Common::Rect(-1, -1, -1, -1);
+	return borders[i].offsets;
 }
 
 Common::SeekableReadStream *MacWindowManager::getBorderFile(byte windowType, bool isActive) {
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 492aed6621..2ecf35c0e6 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -232,11 +232,42 @@ void MacWindow::drawBorder() {
 	_borderIsDirty = false;
 
 	ManagedSurface *g = &_borderSurface;
+	int width = _borderSurface.w;
+	int titleColor;
+	int titleY;
+	int titleHeight;
+	int sidesWidth;
 
 	if (_macBorder.hasBorder(_active)) {
 		drawBorderFromSurface(g);
+		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;
 	} else {
 		drawSimpleBorder(g);
+		titleColor = _wm->_colorBlack;
+		titleY = 0;
+		titleHeight = _borderWidth;
+		sidesWidth = _borderWidth * 2;
+	}
+
+	if (_titleVisible && !_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 (!_macBorder.getOffset().dark)
+				fillRect(g, (width - w) / 2, titleY, w, titleHeight, _wm->_colorOffWhite);
+		} else {
+			drawBox(g, (width - w) / 2, titleY, w, titleHeight);
+		}
+		font->drawString(g, _title, (width - w) / 2 + 5, titleY + yOff, w, titleColor);
 	}
 }
 
@@ -260,8 +291,7 @@ void MacWindow::drawBorderFromSurface(ManagedSurface *g) {
 }
 
 void MacWindow::drawSimpleBorder(ManagedSurface *g) {
-
-	bool active = _active, scrollable = _scrollable, closeable = _active, drawTitle = _titleVisible && !_title.empty();
+	bool active = _active, scrollable = _scrollable, closeable = _active;
 	const int size = kBorderWidth;
 	int x = 0;
 	int y = 0;
@@ -321,18 +351,6 @@ void MacWindow::drawSimpleBorder(ManagedSurface *g) {
 			}
 		}
 	}
-
-	if (drawTitle) {
-		const Graphics::Font *font = getTitleFont();
-		int yOff = _wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
-
-		int w = font->getStringWidth(_title) + 10;
-		int maxWidth = width - size * 2 - 7;
-		if (w > maxWidth)
-			w = maxWidth;
-		drawBox(g, x + (width - w) / 2, y, w, size);
-		font->drawString(g, _title, x + (width - w) / 2 + 5, y + yOff, w, _wm->_colorBlack);
-	}
 }
 
 void MacWindow::drawPattern() {
@@ -366,6 +384,18 @@ void MacWindow::setScroll(float scrollPos, float scrollSize) {
 }
 
 void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, 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, active, offsets);
+}
+
+void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, BorderOffsets offsets) {
 	Image::BitmapDecoder bmpDecoder;
 	Graphics::Surface *source;
 	Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
@@ -379,10 +409,22 @@ void MacWindow::loadBorder(Common::SeekableReadStream &file, bool active, int lo
 	source->free();
 	delete source;
 
-	setBorder(surface, active, lo, ro, to, bo);
+	setBorder(surface, active, offsets);
 }
 
 void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, 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, active, offsets);
+}
+
+void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, BorderOffsets offsets) {
 	surface->applyColorKey(255, 0, 255, false);
 
 	if (active)
@@ -390,8 +432,8 @@ void MacWindow::setBorder(Graphics::TransparentSurface *surface, bool active, in
 	else
 		_macBorder.addInactiveBorder(surface);
 
-	if (lo + ro + to + bo > -4) { // Checking against default -1
-		_macBorder.setOffsets(lo, ro, to, bo);
+	if (offsets.left + offsets.right + offsets.top + offsets.bottom > -4) { // Checking against default -1
+		_macBorder.setOffsets(offsets);
 	}
 
 	updateOuterDims();
@@ -584,17 +626,17 @@ void MacWindow::setBorderType(int borderType) {
 	if (borderType < 0) {
 		disableBorder();
 	} else {
-		Common::Rect offsets = _wm->getBorderOffsets(borderType);
+		BorderOffsets offsets = _wm->getBorderOffsets(borderType);
 	
 		Common::SeekableReadStream *activeFile = _wm->getBorderFile(borderType, true);
 		if (activeFile) {
-			loadBorder(*activeFile, true, offsets.left, offsets.right, offsets.top, offsets.bottom);
+			loadBorder(*activeFile, true, offsets);
 			delete activeFile;
 		}
 
 		Common::SeekableReadStream *inactiveFile = _wm->getBorderFile(borderType, false);
 		if (inactiveFile) {
-			loadBorder(*inactiveFile, false, offsets.left, offsets.right, offsets.top, offsets.bottom);
+			loadBorder(*inactiveFile, false, offsets);
 			delete inactiveFile;
 		}
 	}
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 1e99965389..352f4190f3 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -284,7 +284,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 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 disableBorder();
 
 	/**
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index c12df9a64b..9cff3a71ba 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -33,7 +33,13 @@ MacWindowBorder::MacWindowBorder() : _activeInitialized(false), _inactiveInitial
 	_activeBorder = nullptr;
 	_inactiveBorder = nullptr;
 
-	_borderOffsets.right = -1; // make invalid rect
+	_borderOffsets.left = -1;
+	_borderOffsets.right = -1;
+	_borderOffsets.top = -1;
+	_borderOffsets.bottom = -1;
+	_borderOffsets.titleTop = -1;
+	_borderOffsets.titleBottom = -1;
+	_borderOffsets.dark = false;
 }
 
 MacWindowBorder::~MacWindowBorder() {
@@ -78,10 +84,17 @@ void MacWindowBorder::setOffsets(int left, int right, int top, int bottom) {
 }
 
 void MacWindowBorder::setOffsets(Common::Rect &rect) {
-	_borderOffsets = rect;
+	_borderOffsets.left = rect.left;
+	_borderOffsets.right = rect.right;
+	_borderOffsets.top = rect.top;
+	_borderOffsets.bottom = rect.bottom;
 }
 
-Common::Rect &MacWindowBorder::getOffset() {
+void MacWindowBorder::setOffsets(const BorderOffsets &offsets) {
+	_borderOffsets = offsets;
+}
+
+BorderOffsets &MacWindowBorder::getOffset() {
 	return _borderOffsets;
 }
 
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index bfe6f25100..5d72c473da 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -32,6 +32,16 @@
 
 namespace Graphics {
 
+struct BorderOffsets {
+	int left;
+	int right;
+	int top;
+	int bottom;
+	int titleTop;
+	int titleBottom;
+	bool dark;
+};
+
 /**
  * A representation of a custom border, which allows for arbitrary border offsets
  * and nine-patch resizable displays for both active and inactive states.
@@ -83,6 +93,7 @@ public:
 	 */
 	void setOffsets(int left, int right, int top, int bottom);
 	void setOffsets(Common::Rect &rect);
+	void setOffsets(const BorderOffsets &offsets);
 
 	/**
 	 * Accessor method to retrieve a given border.
@@ -91,7 +102,7 @@ public:
 	 * @param offset The identifier of the offset wanted.
 	 * @return The desired offset in pixels.
 	 */
-	Common::Rect &getOffset();
+	BorderOffsets &getOffset();
 
 	/**
 	 * Blit the desired border (active or inactive) into a destination surface.
@@ -110,7 +121,7 @@ private:
 	bool _activeInitialized;
 	bool _inactiveInitialized;
 
-	Common::Rect _borderOffsets;
+	BorderOffsets _borderOffsets;
 
 };
 
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index bc57b72533..d6480eb101 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -289,7 +289,7 @@ public:
 	void removeMarked();
 
 	void loadDataBundle();
-	Common::Rect getBorderOffsets(byte windowType);
+	BorderOffsets getBorderOffsets(byte windowType);
 	Common::SeekableReadStream *getBorderFile(byte windowType, bool isActive);
 
 public:




More information about the Scummvm-git-logs mailing list