[Scummvm-git-logs] scummvm master -> 9f184bfad1bd85d9a9c317d69efe6d4aa7e0ff4e
sev-
noreply at scummvm.org
Sat Aug 9 19:11:32 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
9f184bfad1 GRAPHICS: MACGUI: Fix borders stop being drawn when resizing
Commit: 9f184bfad1bd85d9a9c317d69efe6d4aa7e0ff4e
https://github.com/scummvm/scummvm/commit/9f184bfad1bd85d9a9c317d69efe6d4aa7e0ff4e
Author: Alikhan Balpykov (luxrage1990 at gmail.com)
Date: 2025-08-09T21:11:29+02:00
Commit Message:
GRAPHICS: MACGUI: Fix borders stop being drawn when resizing
Changed paths:
graphics/macgui/macwindow.cpp
graphics/macgui/macwindowborder.cpp
graphics/macgui/macwindowborder.h
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index b881f6ccc54..ab48e59321a 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -494,8 +494,19 @@ bool MacWindow::processEvent(Common::Event &event) {
}
if (_beingResized) {
- resize(MAX(_borderWidth * 4, _dims.width() + event.mouse.x - _draggedX),
- MAX(_borderWidth * 4, _dims.height() + event.mouse.y - _draggedY));
+ int minWidth = _borderWidth * 4;
+ int minHeight = minWidth;
+
+ uint32 flags = getBorderFlags();
+ if (_macBorder.hasBorder(flags) && _macBorder.hasOffsets()) {
+ minWidth = MAX(minWidth, _macBorder.getMinWidth(flags));
+ minHeight = MAX(minHeight, _macBorder.getMinHeight(flags));
+ }
+
+ resize(MAX(minWidth, _dims.width() + event.mouse.x - _draggedX),
+ MAX(minHeight, _dims.height() + event.mouse.y - _draggedY));
+
+ setTitle(_title);
_draggedX = event.mouse.x;
_draggedY = event.mouse.y;
diff --git a/graphics/macgui/macwindowborder.cpp b/graphics/macgui/macwindowborder.cpp
index f2d3d3abb91..00d42edae1f 100644
--- a/graphics/macgui/macwindowborder.cpp
+++ b/graphics/macgui/macwindowborder.cpp
@@ -148,20 +148,28 @@ const BorderOffsets &MacWindowBorder::getOffset() const {
return _borderOffsets;
}
+int MacWindowBorder::getMinWidth(uint32 flags) const {
+ return _border[flags]->getMinWidth();
+}
+
+int MacWindowBorder::getMinHeight(uint32 flags) const {
+ return _border[flags]->getMinHeight();
+}
+
void MacWindowBorder::setTitle(const Common::String& title, int width) {
_title = title;
const Graphics::Font *font = _wm->_fontMan->getFont(Graphics::MacFont(kMacFontSystem, 12));
- int sidesWidth = getOffset().left + getOffset().right;
int titleWidth = font->getStringWidth(_title) + 8;
- int maxWidth = MAX<int>(width - sidesWidth - 7, 0);
- 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 < kWindowBorderMaxFlag; i++) {
- if ((_border[i] != nullptr) && (i & kWindowBorderTitle))
+ if ((_border[i] != nullptr) && (i & kWindowBorderTitle)) {
+ int maxWidth = MAX<int>(width - _border[i]->getMinWidth() - 7, 0);
+ if (titleWidth > maxWidth)
+ titleWidth = maxWidth;
_border[i]->modifyTitleWidth(titleWidth);
+ }
}
}
@@ -187,15 +195,14 @@ void MacWindowBorder::drawScrollBar(ManagedSurface *g) {
_scrollSize = -1;
}
-void MacWindowBorder::drawTitle(ManagedSurface *g, int titleOffset) {
+void MacWindowBorder::drawTitle(ManagedSurface *g, int titleOffset, int minWidth) {
const Graphics::Font *font = _wm->_fontMan->getFont(Graphics::MacFont(kMacFontSystem, 12));
int width = g->w;
int titleColor = getOffset().dark ? _wm->_colorWhite: _wm->_colorBlack;
int titleY = getOffset().titleTop;
- int sidesWidth = getOffset().left + getOffset().right;
int titleWidth = font->getStringWidth(_title) + 8;
int yOff = _wm->_fontMan->hasBuiltInFonts() ? 3 : 1;
- int maxWidth = width - sidesWidth - 7;
+ int maxWidth = MAX<int>(width - minWidth - 7 - 4, 0);
if (titleWidth > maxWidth)
titleWidth = maxWidth;
@@ -318,7 +325,7 @@ void MacWindowBorder::blitBorderInto(ManagedSurface &destination, uint32 flags)
src->blit(destination, 0, 0, destination.w, destination.h, _wm);
if (flags & kWindowBorderTitle)
- drawTitle(&destination, src->getTitleOffset());
+ drawTitle(&destination, src->getTitleOffset(), _border[flags]->getMinWidth());
if (flags & kWindowBorderScrollbar)
drawScrollBar(&destination);
diff --git a/graphics/macgui/macwindowborder.h b/graphics/macgui/macwindowborder.h
index 3cfeefdc94a..f21a83db085 100644
--- a/graphics/macgui/macwindowborder.h
+++ b/graphics/macgui/macwindowborder.h
@@ -125,6 +125,9 @@ public:
BorderOffsets &getOffset();
const BorderOffsets &getOffset() const;
+ int getMinWidth(uint32 flags) const;
+ int getMinHeight(uint32 flags) const;
+
/**
* Blit the desired border (active or inactive) into a destination surface.
* It automatically resizes the border to fit the given surface.
@@ -138,7 +141,7 @@ public:
void setScroll(int scrollPos, int scrollSize) { _scrollPos = scrollPos, _scrollSize = scrollSize; }
- void drawTitle(ManagedSurface *g, int titleOffset);
+ void drawTitle(ManagedSurface *g, int titleOffset, int minWidth);
void drawScrollBar(ManagedSurface *g);
More information about the Scummvm-git-logs
mailing list