[Scummvm-git-logs] scummvm master -> c5010fbc130f8cf5249551abc9e341c3bb197f83
sev-
sev at scummvm.org
Sat Apr 25 11:44:35 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:
7242a104ab GRAPHICS: MACGUI: Inherit enable/disable methods from MacWidget
7a4d5f45e9 GRAPHICS: MACGUI: Renamed clashing methods
c5010fbc13 GRAPHICS: MACGUI: Install cursor timer only on active MacEditableText
Commit: 7242a104ab809f3db8e5835f8c34335d890d9b3c
https://github.com/scummvm/scummvm/commit/7242a104ab809f3db8e5835f8c34335d890d9b3c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-25T13:44:18+02:00
Commit Message:
GRAPHICS: MACGUI: Inherit enable/disable methods from MacWidget
Changed paths:
graphics/macgui/macwidget.cpp
graphics/macgui/macwidget.h
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
diff --git a/graphics/macgui/macwidget.cpp b/graphics/macgui/macwidget.cpp
index f2f79a6991..873e4feaf5 100644
--- a/graphics/macgui/macwidget.cpp
+++ b/graphics/macgui/macwidget.cpp
@@ -39,6 +39,8 @@ MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, bool focusab
parent->_children.push_back(this);
_composeSurface = nullptr;
+
+ _active = false;
}
MacWidget::~MacWidget() {
@@ -46,6 +48,16 @@ MacWidget::~MacWidget() {
_parent->removeWidget(this, false);
}
+void MacWidget::setActive(bool active) {
+ if (!_focusable)
+ return;
+
+ if (active == _active)
+ return;
+
+ _active = active;
+}
+
void MacWidget::removeWidget(MacWidget *child, bool del) {
for (uint i = 0; i < _children.size(); i++) {
if (_children[i] == child) {
diff --git a/graphics/macgui/macwidget.h b/graphics/macgui/macwidget.h
index 7bbd480e1a..2310d8cabc 100644
--- a/graphics/macgui/macwidget.h
+++ b/graphics/macgui/macwidget.h
@@ -49,7 +49,13 @@ public:
const Common::Rect &getDimensions() { return _dims; }
bool isFocusable() { return _focusable; }
- virtual void setActive(bool active) = 0;
+
+ /**
+ * Method for indicating whether the widget is active or inactive.
+ * Used by the WM to handle focus on windows, etc.
+ * @param active Desired state of the widget.
+ */
+ virtual void setActive(bool active);
/**
* Method for marking the widget for redraw.
@@ -61,7 +67,7 @@ public:
virtual bool draw(bool forceRedraw = false) = 0;
virtual void blit(ManagedSurface *g, Common::Rect &dest) = 0;
virtual bool processEvent(Common::Event &event) = 0;
- virtual bool hasAllFocus() = 0;
+ virtual bool hasAllFocus() { return _active; }
virtual void setDimensions(const Common::Rect &r) {
_dims = r;
@@ -77,6 +83,7 @@ public:
protected:
bool _focusable;
bool _contentIsDirty;
+ bool _active;
Common::Rect _dims;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 1fbeb8eb7d..e5ba409a37 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -43,7 +43,6 @@ BaseMacWindow::BaseMacWindow(int id, bool editable, MacWindowManager *wm) :
MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, MacWindowManager *wm) :
BaseMacWindow(id, editable, wm), _scrollable(scrollable), _resizable(resizable) {
- _active = false;
_borderIsDirty = true;
_pattern = 0;
@@ -101,10 +100,8 @@ const Font *MacWindow::getTitleFont() {
}
void MacWindow::setActive(bool active) {
- if (active == _active)
- return;
+ MacWidget::setActive(active);
- _active = active;
_borderIsDirty = true;
}
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 807495872d..deed053953 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -104,13 +104,6 @@ public:
*/
ManagedSurface *getWindowSurface() { return &_surface; }
- /**
- * Abstract method for indicating whether the window is active or inactive.
- * Used by the WM to handle focus on windows, etc.
- * @param active Desired state of the window.
- */
- virtual void setActive(bool active) = 0;
-
/**
* Method called to draw the window into the target surface.
* This method is most often called by the WM, and relies on
@@ -308,7 +301,6 @@ private:
bool _scrollable;
bool _resizable;
- bool _active;
bool _closeable;
Commit: 7a4d5f45e91f430e06f93d577e42e6d8dbf77c44
https://github.com/scummvm/scummvm/commit/7a4d5f45e91f430e06f93d577e42e6d8dbf77c44
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-25T13:44:18+02:00
Commit Message:
GRAPHICS: MACGUI: Renamed clashing methods
Changed paths:
graphics/macgui/maceditabletext.h
graphics/macgui/macmenu.cpp
graphics/macgui/macmenu.h
graphics/macgui/mactextwindow.cpp
graphics/macgui/macwindow.h
graphics/macgui/macwindowmanager.cpp
graphics/macgui/macwindowmanager.h
diff --git a/graphics/macgui/maceditabletext.h b/graphics/macgui/maceditabletext.h
index 9345e2d923..eed7604a21 100644
--- a/graphics/macgui/maceditabletext.h
+++ b/graphics/macgui/maceditabletext.h
@@ -90,9 +90,6 @@ public:
Common::U32String cutSelection();
const SelectedText *getSelectedText() { return &_selectedText; }
- void setActive(bool active) {}
- bool hasAllFocus() { return false; }
-
private:
void init();
bool isCutAllowed();
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index d5150f58cc..3367b02e64 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -114,8 +114,6 @@ MacMenu::MacMenu(int id, const Common::Rect &bounds, MacWindowManager *wm)
_bbox.right = _screen.w;
_bbox.bottom = kMenuHeight;
- _menuActivated = false;
-
_dimensionsDirty = true;
if (_wm->_mode & kWMModeAutohideMenu)
@@ -982,10 +980,10 @@ bool MacMenu::mouseClick(int x, int y) {
}
}
- if (!_menuActivated)
+ if (!_active)
_wm->activateMenu();
- _menuActivated = true;
+ setActive(true);
_contentIsDirty = true;
_wm->setFullRefresh(true);
@@ -1002,7 +1000,7 @@ bool MacMenu::mouseClick(int x, int y) {
return true;
}
- if (!_menuActivated)
+ if (!_active)
return false;
if (_menustack.size() > 0 && _menustack.back()->bbox.contains(x, y)) {
@@ -1083,7 +1081,7 @@ bool MacMenu::mouseClick(int x, int y) {
}
bool MacMenu::mouseMove(int x, int y) {
- if (_menuActivated) {
+ if (_active) {
if (mouseClick(x, y))
return true;
} else if ((_wm->_mode & kWMModeAutohideMenu) && !_bbox.contains(x, y)) {
@@ -1115,8 +1113,8 @@ bool MacMenu::checkCallback(bool unicode) {
}
bool MacMenu::mouseRelease(int x, int y) {
- if (_menuActivated) {
- _menuActivated = false;
+ if (_active) {
+ setActive(false);
if (_wm->_mode & kWMModeAutohideMenu)
_isVisible = false;
@@ -1242,7 +1240,7 @@ void MacMenu::disableAllMenus() {
void MacMenu::eventLoop() {
_contentIsDirty = true;
- while (_menuActivated) {
+ while (_active) {
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
@@ -1251,7 +1249,7 @@ void MacMenu::eventLoop() {
draw(_wm->_screen);
}
- if (_menuActivated) {
+ if (_active) {
g_system->updateScreen();
g_system->delayMillis(10);
}
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index dd9e2098d1..e1a1e041da 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -81,9 +81,6 @@ public:
void enableCommand(const Common::U32String &menuitem, const Common::U32String &menuaction, bool state);
void disableAllMenus();
- void setActive(bool active) { _menuActivated = active; }
- bool hasAllFocus() { return _menuActivated; }
-
bool isVisible() { return _isVisible; }
void setVisible(bool visible) { _isVisible = visible; _contentIsDirty = true; }
@@ -121,7 +118,6 @@ private:
const Font *_font;
- bool _menuActivated;
bool _isVisible;
bool _dimensionsDirty;
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 9d5f6890b6..d8f9902122 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -302,7 +302,7 @@ bool MacTextWindow::processEvent(Common::Event &event) {
if (!_editable)
return false;
- _wm->setActive(getId());
+ _wm->setActiveWindow(getId());
if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
return false;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index deed053953..279140581c 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -122,8 +122,6 @@ public:
*/
virtual bool processEvent(Common::Event &event) = 0;
- virtual bool hasAllFocus() = 0;
-
/**
* Set the callback that will be used when an event needs to be processed.
* @param callback A function pointer to a function that accepts:
@@ -187,7 +185,7 @@ public:
* of the window, although move() and resize() might be more comfortable.
* @param r The desired dimensions of the window.
*/
- virtual void setDimensions(const Common::Rect &r);
+ virtual void setDimensions(const Common::Rect &r) override;
/**
* Accessor to retrieve the dimensions of the inner surface of the window
@@ -209,17 +207,17 @@ public:
* @param g See BaseMacWindow.
* @param forceRedraw If true, the borders are guarranteed to redraw.
*/
- virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(ManagedSurface *g, bool forceRedraw = false) override;
- virtual bool draw(bool forceRedraw = false);
- virtual void blit(ManagedSurface *g, Common::Rect &dest);
+ virtual bool draw(bool forceRedraw = false) override;
+ virtual void blit(ManagedSurface *g, Common::Rect &dest) override;
/**
* Mutator to change the active state of the window.
* Most often called from the WM.
* @param active Target state.
*/
- void setActive(bool active);
+ virtual void setActive(bool active) override;
/**
* Accessor to determine whether a window is active.
* @return True if the window is active.
@@ -246,8 +244,8 @@ public:
/**
* See BaseMacWindow.
*/
- virtual bool processEvent(Common::Event &event);
- bool hasAllFocus() { return _beingDragged || _beingResized; }
+ virtual bool processEvent(Common::Event &event) override;
+ virtual bool hasAllFocus() override { return _beingDragged || _beingResized; }
/**
* Set arbitrary border from a BMP data stream, with custom border offsets.
diff --git a/graphics/macgui/macwindowmanager.cpp b/graphics/macgui/macwindowmanager.cpp
index ec660e6193..5820539c11 100644
--- a/graphics/macgui/macwindowmanager.cpp
+++ b/graphics/macgui/macwindowmanager.cpp
@@ -216,7 +216,7 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool edi
addWindowInitialized(w);
- setActive(getNextId());
+ setActiveWindow(getNextId());
return w;
}
@@ -226,7 +226,7 @@ MacTextWindow *MacWindowManager::addTextWindow(const MacFont *font, int fgcolor,
addWindowInitialized(w);
- setActive(getNextId());
+ setActiveWindow(getNextId());
return w;
}
@@ -272,7 +272,7 @@ bool MacWindowManager::isMenuActive() {
return _menu->isVisible();
}
-void MacWindowManager::setActive(int id) {
+void MacWindowManager::setActiveWindow(int id) {
if (_activeWindow == id)
return;
@@ -434,7 +434,7 @@ bool MacWindowManager::processEvent(Common::Event &event) {
if (w->hasAllFocus() || (w->isEditable() && event.type == Common::EVENT_KEYDOWN) ||
w->getDimensions().contains(event.mouse.x, event.mouse.y)) {
if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)
- setActive(w->getId());
+ setActiveWindow(w->getId());
return w->processEvent(event);
}
diff --git a/graphics/macgui/macwindowmanager.h b/graphics/macgui/macwindowmanager.h
index ed69488084..204007e109 100644
--- a/graphics/macgui/macwindowmanager.h
+++ b/graphics/macgui/macwindowmanager.h
@@ -164,7 +164,7 @@ public:
* Set the desired window state to active.
* @param id ID of the window that has to be set to active.
*/
- void setActive(int id);
+ void setActiveWindow(int id);
/**
* Mark a window for removal.
* Note that the window data will be destroyed.
Commit: c5010fbc130f8cf5249551abc9e341c3bb197f83
https://github.com/scummvm/scummvm/commit/c5010fbc130f8cf5249551abc9e341c3bb197f83
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-25T13:44:18+02:00
Commit Message:
GRAPHICS: MACGUI: Install cursor timer only on active MacEditableText
Changed paths:
graphics/macgui/maceditabletext.cpp
graphics/macgui/maceditabletext.h
diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index cbfa75ee8d..0d8a6b0bc5 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -93,16 +93,27 @@ void MacEditableText::init() {
_composeSurface = new ManagedSurface(_dims.width(), _dims.height());
_composeSurface->clear(_wm->_colorWhite);
-
- g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "macEditableText");
}
MacEditableText::~MacEditableText() {
+ setActive(false);
+
delete _cursorRect;
delete _cursorSurface;
delete _composeSurface;
+}
- g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
+void MacEditableText::setActive(bool active) {
+ if (_active == active)
+ return;
+
+ MacWidget::setActive(active);
+
+ if (_active) {
+ g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "macEditableText");
+ } else {
+ g_system->getTimerManager()->removeTimerProc(&cursorTimerHandler);
+ }
}
void MacEditableText::resize(int w, int h) {
diff --git a/graphics/macgui/maceditabletext.h b/graphics/macgui/maceditabletext.h
index eed7604a21..88573f2813 100644
--- a/graphics/macgui/maceditabletext.h
+++ b/graphics/macgui/maceditabletext.h
@@ -62,15 +62,17 @@ public:
virtual void resize(int w, int h);
- virtual bool processEvent(Common::Event &event);
+ virtual bool processEvent(Common::Event &event) override;
- virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
- virtual bool draw(bool forceRedraw = false);
- virtual void blit(ManagedSurface *g, Common::Rect &dest);
+ virtual bool draw(ManagedSurface *g, bool forceRedraw = false) override;
+ virtual bool draw(bool forceRedraw = false) override;
+ virtual void blit(ManagedSurface *g, Common::Rect &dest) override;
void setTextFont(const MacFont *macFont);
const MacFont *getTextFont();
+ virtual void setActive(bool active) override;
+
void appendText(Common::U32String str, const MacFont *macFont, bool skipAdd = false);
void appendText(const Common::String &str, const MacFont *macFont, bool skipAdd = false);
void clearText();
More information about the Scummvm-git-logs
mailing list