[Scummvm-git-logs] scummvm master -> 874526c5634d12b34ac805959f03863013bd9afb

npjg nathanael.gentrydb8 at gmail.com
Sun Jun 14 14:13:18 UTC 2020


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

Summary:
9e69ea280e GRAPHICS: MACGUI: Fix text border computation
874526c563 GRAPHICS: MACGUI: Fix button alignment


Commit: 9e69ea280e8da5b97501ab34a649610330b42de5
    https://github.com/scummvm/scummvm/commit/9e69ea280e8da5b97501ab34a649610330b42de5
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-14T10:12:57-04:00

Commit Message:
GRAPHICS: MACGUI: Fix text border computation

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/macwidget.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 3a922f202d..917ec4a06e 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -95,7 +95,7 @@ uint MacTextLine::getChunkNum(int *col) {
 
 
 MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::U32String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow) :
-	MacWidget(parent, x, y, w, h, true, border, gutter, boxShadow) {
+	MacWidget(parent, x, y, w + 2, h, true, border, gutter, boxShadow) {
 
 	_str = s;
 	_fullRefresh = true;
@@ -120,22 +120,11 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
 		_defaultFormatting.font = NULL;
 	}
 
-	_defaultFormatting.wm = wm;
-	_currentFormatting = _defaultFormatting;
-
-	splitString(_str);
-
-	recalcDims();
 	init();
-
-	reallocSurface();
-	setAlignOffset(_textAlignment);
-	updateCursorPos();
-	render();
 }
 
 MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, const Common::String &s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear, uint16 border, uint16 gutter, uint16 boxShadow, uint16 textShadow) :
-	MacWidget(parent, x, y, w, h, true, border, gutter, boxShadow) {
+	MacWidget(parent, x, y, w + 2, h, true, border, gutter, boxShadow) {
 
 	_str = Common::U32String(s);
 	_fullRefresh = true;
@@ -160,18 +149,7 @@ MacText::MacText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager
 		_defaultFormatting.font = NULL;
 	}
 
-	_defaultFormatting.wm = wm;
-	_currentFormatting = _defaultFormatting;
-
-	splitString(_str);
-
-	recalcDims();
 	init();
-
-	reallocSurface();
-	setAlignOffset(_textAlignment);
-	updateCursorPos();
-	render();
 }
 
 // NOTE: This constructor and the one afterward are for MacText engines that don't use widgets. This is the classic was MacText was constructed.
@@ -200,18 +178,7 @@ MacText::MacText(const Common::U32String &s, MacWindowManager *wm, const MacFont
 		_defaultFormatting.font = NULL;
 	}
 
-	_defaultFormatting.wm = wm;
-	_currentFormatting = _defaultFormatting;
-
-	splitString(_str);
-
-	recalcDims();
 	init();
-
-	reallocSurface();
-	setAlignOffset(_textAlignment);
-	updateCursorPos();
-	render();
 }
 
 MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
@@ -239,21 +206,17 @@ MacText::MacText(const Common::String &s, MacWindowManager *wm, const MacFont *m
 		_defaultFormatting.font = NULL;
 	}
 
-	_defaultFormatting.wm = wm;
+	init();
+}
+
+void MacText::init() {
+	_defaultFormatting.wm = _wm;
 	_currentFormatting = _defaultFormatting;
 
 	splitString(_str);
-
 	recalcDims();
-	init();
-
-	reallocSurface();
-	setAlignOffset(_textAlignment);
-	updateCursorPos();
-	render();
-}
 
-void MacText::init() {
+	_fullRefresh = true;
 	_inTextSelection = false;
 
 	_scrollPos = 0;
@@ -276,6 +239,11 @@ void MacText::init() {
 
 	_cursorSurface = new ManagedSurface(1, kCursorHeight);
 	_cursorSurface->clear(_wm->_colorBlack);
+
+	reallocSurface();
+	setAlignOffset(_textAlignment);
+	updateCursorPos();
+	render();
 }
 
 MacText::~MacText() {
@@ -741,12 +709,11 @@ void MacText::setAlignOffset(TextAlign align) {
 		_fullRefresh = true;
 		_alignOffset = offset;
 		_textAlignment = align;
-		render();
 	}
 }
 
 Common::Point MacText::calculateOffset() {
-	return Common::Point(_alignOffset.x + _border + _gutter + 1, _alignOffset.y + _border + _gutter/2);
+	return Common::Point(_alignOffset.x + _border + _gutter + 2, _alignOffset.y + _border + _gutter/2);
 }
 
 void MacText::setActive(bool active) {
@@ -899,19 +866,19 @@ bool MacText::draw(bool forceRedraw) {
 	_contentIsDirty = false;
 	_cursorDirty = false;
 
+	Common::Point offset(calculateOffset());
+	draw(_composeSurface, 0, _scrollPos, _surface->w, _scrollPos + _surface->h, offset.x, offset.y);
+
 	for (int bb = 0; bb < _shadow; bb ++) {
 		_composeSurface->hLine(_shadow, _composeSurface->h - _shadow + bb, _composeSurface->w, 0);
 		_composeSurface->vLine(_composeSurface->w - _shadow + bb, _shadow, _composeSurface->h - _shadow, 0);
 	}
 
 	for (int bb = 0; bb < _border; bb++) {
-		Common::Rect borderRect(bb, bb, _composeSurface->w - _shadow - bb, _composeSurface->h - _shadow - bb);
+		Common::Rect borderRect(bb, bb, _composeSurface->w - bb, _composeSurface->h - bb);
 		_composeSurface->frameRect(borderRect, 0);
 	}
 
-	Common::Point offset(calculateOffset());
-	draw(_composeSurface, 0, _scrollPos, _surface->w, _scrollPos + _surface->h, offset.x, offset.y);
-
 	if (_cursorState)
 		_composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX, _cursorY + offset.y + 1));
 
diff --git a/graphics/macgui/macwidget.cpp b/graphics/macgui/macwidget.cpp
index 29fc2cba97..9f7a00f1e1 100644
--- a/graphics/macgui/macwidget.cpp
+++ b/graphics/macgui/macwidget.cpp
@@ -27,15 +27,15 @@
 
 namespace Graphics {
 
-	MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, bool focusable, uint16 border, uint16 gutter, uint16 shadow) :
+MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, bool focusable, uint16 border, uint16 gutter, uint16 shadow) :
 	_focusable(focusable), _parent(parent), _border(border), _gutter(gutter), _shadow(shadow) {
 	_contentIsDirty = true;
 	_priority = 0;
 
 	_dims.left = x;
-	_dims.right = x + w + 2 * border + 2 * gutter + shadow + 1;
+	_dims.right = x + w + (2 * border) + (2 * gutter) + shadow;
 	_dims.top = y;
-	_dims.bottom = y + h + 2 * border + gutter + shadow;
+	_dims.bottom = y + h + (2 * border) + gutter + shadow;
 
 	if (parent)
 		parent->_children.push_back(this);


Commit: 874526c5634d12b34ac805959f03863013bd9afb
    https://github.com/scummvm/scummvm/commit/874526c5634d12b34ac805959f03863013bd9afb
Author: Nathanael Gentry (nathanael.gentrydb8 at gmail.com)
Date: 2020-06-14T10:12:58-04:00

Commit Message:
GRAPHICS: MACGUI: Fix button alignment

Changed paths:
    graphics/macgui/macbutton.cpp
    graphics/macgui/macbutton.h
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/macbutton.cpp b/graphics/macgui/macbutton.cpp
index 627212cc18..ab5312b891 100644
--- a/graphics/macgui/macbutton.cpp
+++ b/graphics/macgui/macbutton.cpp
@@ -164,4 +164,8 @@ bool MacButton::processEvent(Common::Event &event) {
 	return false;
 }
 
+Common::Point MacButton::calculateOffset() {
+	return Common::Point(_alignOffset.x + _border + _gutter, _alignOffset.y + _border + _gutter/2);
+}
+
 } // End of namespace Graphics
diff --git a/graphics/macgui/macbutton.h b/graphics/macgui/macbutton.h
index 230186725b..7f1cccc4c5 100644
--- a/graphics/macgui/macbutton.h
+++ b/graphics/macgui/macbutton.h
@@ -48,6 +48,7 @@ public:
 	virtual bool draw(ManagedSurface *g, bool forceRedraw = false) override;
 	virtual bool draw(bool forceRedraw = false) override;
 	virtual bool processEvent(Common::Event &event) override;
+	virtual Common::Point calculateOffset() override;
 
 private:
 	MacButtonType _buttonType;
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index eeff44f54d..ff12b0b906 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -162,7 +162,7 @@ public:
 
 	void setAlignOffset(TextAlign align);
 	TextAlign getAlign() { return _textAlignment; }
-	Common::Point calculateOffset();
+	virtual Common::Point calculateOffset();
 	virtual void setActive(bool active) override;
 	void setEditable(bool editable);
 




More information about the Scummvm-git-logs mailing list