[Scummvm-git-logs] scummvm master -> 2920a76611a81e0f41d80c029541c1eb33a47ae7
sev-
sev at scummvm.org
Mon Apr 13 22:43:45 UTC 2020
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1308feadb9 DIRECTOR: Moved MacWidget from Sprite to Cast to avoid duplication
e7b2b87acf GRAPHICS: MACGUI: Cleanup MacEditableText of border logic
06fc491663 GRAPHOCS: MACGUI: Renamed MacWindow::getSurface() to getWindowSurface()
fb11113d00 GRAPHICS: MACGUI: Properly initialize font in MacEditableText
2fb21ba90a GRAPHICS: MACGUI: Split drawing and blitting operations for widgets
2920a76611 DIRECTOR: Further work on editable text rendering
Commit: 1308feadb9b79fc3a48ff7816379928f1b4185fc
https://github.com/scummvm/scummvm/commit/1308feadb9b79fc3a48ff7816379928f1b4185fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-13T14:50:42+02:00
Commit Message:
DIRECTOR: Moved MacWidget from Sprite to Cast to avoid duplication
Changed paths:
engines/director/cast.cpp
engines/director/cast.h
engines/director/frame.cpp
engines/director/sprite.cpp
engines/director/sprite.h
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index f54f97b039..dd25d68446 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -36,6 +36,8 @@ namespace Director {
Cast::Cast() {
_type = kCastTypeNull;
_surface = nullptr;
+ _widget = nullptr;
+
_img = nullptr;
_modified = true;
diff --git a/engines/director/cast.h b/engines/director/cast.h
index e07fbda4ee..ab10af0336 100644
--- a/engines/director/cast.h
+++ b/engines/director/cast.h
@@ -28,6 +28,7 @@
namespace Graphics {
struct Surface;
+class MacWidget;
}
namespace Common {
@@ -59,6 +60,8 @@ public:
Image::ImageDecoder *_img;
bool _modified;
+
+ Graphics::MacWidget *_widget;
};
class BitmapCast : public Cast {
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 943457edef..5ef9e1e61c 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -884,8 +884,8 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
}
if (sprite->_editable) {
- if (!sprite->_widget) {
- sprite->_widget = new Graphics::MacEditableText(score->_window, x, y, width, height, g_director->_wm, "", nullptr, sprite->_foreColor, sprite->_backColor);
+ if (!textCast->_widget) {
+ textCast->_widget = new Graphics::MacEditableText(score->_window, x, y, width, height, g_director->_wm, "", nullptr, sprite->_foreColor, sprite->_backColor);
warning("Created MacEditableText");
}
}
diff --git a/engines/director/sprite.cpp b/engines/director/sprite.cpp
index ef94f56dae..af40871292 100644
--- a/engines/director/sprite.cpp
+++ b/engines/director/sprite.cpp
@@ -55,7 +55,6 @@ Sprite::Sprite() {
_type = kInactiveSprite;
_cast = nullptr;
- _widget = nullptr;
_blend = 0;
_thickness = 0;
diff --git a/engines/director/sprite.h b/engines/director/sprite.h
index a532b70daf..791c509d26 100644
--- a/engines/director/sprite.h
+++ b/engines/director/sprite.h
@@ -23,10 +23,6 @@
#ifndef DIRECTOR_SPRITE_H
#define DIRECTOR_SPRITE_H
-namespace Graphics {
-class MacWidget;
-}
-
namespace Director {
class BitmapCast;
@@ -114,8 +110,6 @@ public:
// Using in text sprites
Common::String _editableText;
-
- Graphics::MacWidget *_widget;
};
} // End of namespace Director
Commit: e7b2b87acfc332bd4db3735f30d96b7298b7343f
https://github.com/scummvm/scummvm/commit/e7b2b87acfc332bd4db3735f30d96b7298b7343f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-13T15:48:01+02:00
Commit Message:
GRAPHICS: MACGUI: Cleanup MacEditableText of border logic
Changed paths:
graphics/macgui/maceditabletext.cpp
diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index bdf8a1186b..7ad29fe0ef 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -71,6 +71,8 @@ void MacEditableText::init() {
_editable = true;
_selectable = true;
+ _menu = nullptr;
+
_cursorX = 0;
_cursorY = 0;
_cursorState = false;
@@ -168,8 +170,6 @@ bool MacEditableText::draw(ManagedSurface *g, bool forceRedraw) {
if (_selectedText.endY != -1)
drawSelection();
- //_composeSurface.transBlitFrom(_borderSurface, kColorGreen);
-
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
return true;
@@ -291,8 +291,6 @@ Common::U32String MacEditableText::cutSelection() {
}
bool MacEditableText::processEvent(Common::Event &event) {
- WindowClick click = kBorderInner; //_parent->isInBorder(event.mouse.x, event.mouse.y);
-
if (event.type == Common::EVENT_KEYDOWN) {
if (!_editable)
return false;
@@ -341,73 +339,41 @@ bool MacEditableText::processEvent(Common::Event &event) {
return true;
}
- if (click == kBorderScrollUp || click == kBorderScrollDown) {
- if (event.type == Common::EVENT_LBUTTONDOWN) {
- int consoleHeight = getDimensions().height();
- int textFullSize = MacText::getTextHeight();
- float scrollPos = (float)_scrollPos / textFullSize;
- float scrollSize = (float)consoleHeight / textFullSize;
-
- setScroll(scrollPos, scrollSize);
-
- return true;
- } else if (event.type == Common::EVENT_LBUTTONUP) {
- switch (click) {
- case kBorderScrollUp:
- scroll(-1);
- break;
- case kBorderScrollDown:
- scroll(1);
- break;
- default:
- return false;
- }
-
- return true;
- }
-
+ if (!_selectable)
return false;
- }
-
- if (click == kBorderInner) {
- if (!_selectable)
- return false;
- if (event.type == Common::EVENT_LBUTTONDOWN) {
- startMarking(event.mouse.x, event.mouse.y);
+ if (event.type == Common::EVENT_LBUTTONDOWN) {
+ startMarking(event.mouse.x, event.mouse.y);
- return true;
- } else if (event.type == Common::EVENT_LBUTTONUP && _menu) {
- if (_inTextSelection) {
- _inTextSelection = false;
-
- if (_selectedText.endY == -1 ||
- (_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) {
- _selectedText.startY = _selectedText.endY = -1;
- _contentIsDirty = true;
- _menu->enableCommand("Edit", "Copy", false);
- } else {
- _menu->enableCommand("Edit", "Copy", true);
-
- bool cutAllowed = isCutAllowed();
-
- _menu->enableCommand("Edit", "Cut", cutAllowed);
- _menu->enableCommand("Edit", "Clear", cutAllowed);
- }
+ return true;
+ } else if (event.type == Common::EVENT_LBUTTONUP && _menu) {
+ if (_inTextSelection) {
+ _inTextSelection = false;
+
+ if (_selectedText.endY == -1 ||
+ (_selectedText.endX == _selectedText.startX && _selectedText.endY == _selectedText.startY)) {
+ _selectedText.startY = _selectedText.endY = -1;
+ _contentIsDirty = true;
+ _menu->enableCommand("Edit", "Copy", false);
+ } else {
+ _menu->enableCommand("Edit", "Copy", true);
+
+ bool cutAllowed = isCutAllowed();
+
+ _menu->enableCommand("Edit", "Cut", cutAllowed);
+ _menu->enableCommand("Edit", "Clear", cutAllowed);
}
+ }
+ return true;
+ } else if (event.type == Common::EVENT_MOUSEMOVE) {
+ if (_inTextSelection) {
+ updateTextSelection(event.mouse.x, event.mouse.y);
return true;
- } else if (event.type == Common::EVENT_MOUSEMOVE) {
- if (_inTextSelection) {
- updateTextSelection(event.mouse.x, event.mouse.y);
- return true;
- }
}
-
- return false;
}
- return _parent->processEvent(event);
+ return false;
}
void MacEditableText::scroll(int delta) {
Commit: 06fc49166320e592b2fe6afd875a45fc9f57bb63
https://github.com/scummvm/scummvm/commit/06fc49166320e592b2fe6afd875a45fc9f57bb63
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-14T00:27:49+02:00
Commit Message:
GRAPHOCS: MACGUI: Renamed MacWindow::getSurface() to getWindowSurface()
Changed paths:
engines/director/score.cpp
engines/macventure/gui.cpp
engines/wage/gui.cpp
graphics/macgui/macwindow.h
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 70b0114a86..11dd784a0f 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -1523,7 +1523,7 @@ void Score::startLoop() {
_window->disableBorder();
_window->resize(_movieRect.width(), _movieRect.height());
- _surface = _window->getSurface();
+ _surface = _window->getWindowSurface();
_trailSurface = new Graphics::ManagedSurface;
_backSurface = new Graphics::ManagedSurface;
_backSurface2 = new Graphics::ManagedSurface;
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index d7b640571d..6db7a1201b 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -195,7 +195,7 @@ void Gui::draw() {
drawDraggedObject();
drawDialog();
// TODO: When window titles with custom borders are in MacGui, this should be used.
- //drawWindowTitle(kMainGameWindow, _mainGameWindow->getSurface());
+ //drawWindowTitle(kMainGameWindow, _mainGameWindow->getWindowSurface());
}
void Gui::drawMenu() {
@@ -574,7 +574,7 @@ void Gui::drawWindows() {
void Gui::drawCommandsWindow() {
if (_engine->needsClickToContinue()) {
- Graphics::ManagedSurface *srf = _controlsWindow->getSurface();
+ Graphics::ManagedSurface *srf = _controlsWindow->getWindowSurface();
WindowData data = getWindowData(kCommandsWindow);
srf->fillRect(Common::Rect(0, 0, srf->w, srf->h), kColorWhite);
getCurrentFont().drawString(
@@ -590,7 +590,7 @@ void Gui::drawCommandsWindow() {
for (; it != _controlData->end(); ++it) {
CommandButton button = *it;
if (button.getData().type != kControlExitBox)
- button.draw(*_controlsWindow->getSurface());
+ button.draw(*_controlsWindow->getWindowSurface());
}
}
}
@@ -606,13 +606,13 @@ void Gui::drawMainGameWindow() {
ensureAssetLoaded(objRef);
_assets[objRef]->blitInto(
- _mainGameWindow->getSurface(),
+ _mainGameWindow->getWindowSurface(),
border.leftOffset,
border.topOffset,
kBlitDirect);
}
- drawObjectsInWindow(data, _mainGameWindow->getSurface());
+ drawObjectsInWindow(data, _mainGameWindow->getWindowSurface());
if (DebugMan.isDebugChannelEnabled(kMVDebugGUI)) {
Graphics::MacWindow *win = findWindow(data.refcon);
@@ -620,14 +620,14 @@ void Gui::drawMainGameWindow() {
int x = win->getDimensions().left;
int y = win->getDimensions().top;
innerDims.translate(-x, -y);
- win->getSurface()->frameRect(innerDims, kColorGreen);
+ win->getWindowSurface()->frameRect(innerDims, kColorGreen);
}
findWindow(kMainGameWindow)->setDirty(true);
}
void Gui::drawSelfWindow() {
- drawObjectsInWindow(getWindowData(kSelfWindow), _selfWindow->getSurface());
+ drawObjectsInWindow(getWindowData(kSelfWindow), _selfWindow->getWindowSurface());
if (_engine->isObjSelected(1)) {
invertWindowColors(kSelfWindow);
}
@@ -640,7 +640,7 @@ void Gui::drawInventories() {
for (uint i = 0; i < _inventoryWindows.size(); i++) {
const WindowData &data = getWindowData((WindowReference)(kInventoryStart + i));
Graphics::MacWindow *win = findWindow(data.refcon);
- srf = win->getSurface();
+ srf = win->getWindowSurface();
srf->clear(kColorGreen);
srf->fillRect(srf->getBounds(), kColorWhite);
drawObjectsInWindow(data, srf);
@@ -661,7 +661,7 @@ void Gui::drawInventories() {
void Gui::drawExitsWindow() {
_exitsWindow->setBackgroundPattern(kPatternLightGray);
- Graphics::ManagedSurface *srf = _exitsWindow->getSurface();
+ Graphics::ManagedSurface *srf = _exitsWindow->getWindowSurface();
Common::Array<CommandButton>::const_iterator it = _exitsData->begin();
for (; it != _exitsData->end(); ++it) {
@@ -674,7 +674,7 @@ void Gui::drawExitsWindow() {
void Gui::drawConsoleWindow() {
- Graphics::ManagedSurface *srf = _outConsoleWindow->getSurface();
+ Graphics::ManagedSurface *srf = _outConsoleWindow->getWindowSurface();
BorderBounds bounds = borderBounds(getWindowData(kOutConsoleWindow).type);
_consoleText->renderInto(srf, bounds, kConsoleLeftOffset);
}
@@ -820,7 +820,7 @@ void Gui::updateWindow(WindowReference winID, bool containerOpen) {
drawMainGameWindow();
} else {
Graphics::MacWindow *winRef = findWindow(winID);
- winRef->getSurface()->fillRect(data.bounds, kColorGray);
+ winRef->getWindowSurface()->fillRect(data.bounds, kColorGray);
}
if (data.type == kZoomDoc && data.updateScroll) {
warning("Unimplemented: update scroll");
@@ -1240,7 +1240,7 @@ void menuCommandsCallback(int action, Common::String &text, void *data) {
void Gui::invertWindowColors(WindowReference winID) {
- Graphics::ManagedSurface *srf = findWindow(winID)->getSurface();
+ Graphics::ManagedSurface *srf = findWindow(winID)->getWindowSurface();
for (uint y = 0; y < srf->h; y++) {
for (uint x = 0; x < srf->w; x++) {
byte p = *(byte *)srf->getBasePtr(x, y);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 8138ff4b6a..2f527c7214 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -173,7 +173,7 @@ void Gui::drawScene() {
if (!_sceneDirty)
return;
- _scene->paint(_sceneWindow->getSurface(), 0, 0);
+ _scene->paint(_sceneWindow->getWindowSurface(), 0, 0);
_sceneWindow->setDirty(true);
_sceneDirty = true;
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index 8fbf2ab5e5..eabb55d3f5 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -102,7 +102,7 @@ public:
* Method to access the entire surface of the window (e.g. to draw an image).
* @return A pointer to the entire surface of the window.
*/
- ManagedSurface *getSurface() { return &_surface; }
+ ManagedSurface *getWindowSurface() { return &_surface; }
/**
* Abstract method for indicating whether the window is active or inactive.
Commit: fb11113d00e09943d83409c4c42bf5705243c884
https://github.com/scummvm/scummvm/commit/fb11113d00e09943d83409c4c42bf5705243c884
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-14T00:40:35+02:00
Commit Message:
GRAPHICS: MACGUI: Properly initialize font in MacEditableText
Changed paths:
graphics/macgui/maceditabletext.cpp
diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index 7ad29fe0ef..54b6adf5ba 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -45,12 +45,14 @@ enum {
static void cursorTimerHandler(void *refCon);
-MacEditableText::MacEditableText(MacWidget *parent,int x, int y, int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
+MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, Common::U32String s, const MacFont *macFont, int fgcolor, int bgcolor, int maxWidth, TextAlign textAlignment, int interlinear) :
MacWidget(parent, x, y, w, h, true), MacText(s, wm, macFont, fgcolor, bgcolor, maxWidth, textAlignment, interlinear) {
_maxWidth = maxWidth;
init();
+
+ _font = macFont;
}
MacEditableText::MacEditableText(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) :
@@ -59,6 +61,8 @@ MacEditableText::MacEditableText(MacWidget *parent, int x, int y, int w, int h,
_maxWidth = maxWidth;
init();
+
+ _font = macFont;
}
void MacEditableText::init() {
Commit: 2fb21ba90a70550dc30644a55d528331646fd20b
https://github.com/scummvm/scummvm/commit/2fb21ba90a70550dc30644a55d528331646fd20b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-14T00:42:39+02:00
Commit Message:
GRAPHICS: MACGUI: Split drawing and blitting operations for widgets
Changed paths:
graphics/macgui/maceditabletext.cpp
graphics/macgui/maceditabletext.h
graphics/macgui/macmenu.h
graphics/macgui/mactextwindow.cpp
graphics/macgui/mactextwindow.h
graphics/macgui/macwidget.cpp
graphics/macgui/macwidget.h
graphics/macgui/macwindow.cpp
graphics/macgui/macwindow.h
diff --git a/graphics/macgui/maceditabletext.cpp b/graphics/macgui/maceditabletext.cpp
index 54b6adf5ba..c4c23e2309 100644
--- a/graphics/macgui/maceditabletext.cpp
+++ b/graphics/macgui/maceditabletext.cpp
@@ -148,7 +148,7 @@ const MacFont *MacEditableText::getTextFont() {
return _font;
}
-bool MacEditableText::draw(ManagedSurface *g, bool forceRedraw) {
+bool MacEditableText::draw(bool forceRedraw) {
if (!_scrollbarIsDirty && !_contentIsDirty && !_cursorDirty && !_inputIsDirty && !forceRedraw)
return false;
@@ -174,11 +174,22 @@ bool MacEditableText::draw(ManagedSurface *g, bool forceRedraw) {
if (_selectedText.endY != -1)
drawSelection();
+ return true;
+}
+
+bool MacEditableText::draw(ManagedSurface *g, bool forceRedraw) {
+ if (!draw(forceRedraw))
+ return false;
+
g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
return true;
}
+void MacEditableText::blit(ManagedSurface *g, Common::Rect &dest) {
+ g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), dest, kColorGreen2);
+}
+
void MacEditableText::drawSelection() {
if (_selectedText.endY == -1)
return;
diff --git a/graphics/macgui/maceditabletext.h b/graphics/macgui/maceditabletext.h
index 448cac358d..ae864c9fd2 100644
--- a/graphics/macgui/maceditabletext.h
+++ b/graphics/macgui/maceditabletext.h
@@ -64,6 +64,8 @@ public:
virtual bool processEvent(Common::Event &event);
virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(bool forceRedraw = false);
+ virtual void blit(ManagedSurface *g, Common::Rect &dest);
void setTextFont(const MacFont *macFont);
const MacFont *getTextFont();
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 42eb2f3577..dd9e2098d1 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -70,7 +70,10 @@ public:
MacMenuSubMenu *getSubmenu(MacMenuSubMenu *submenu, int index);
- bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(bool forceRedraw = false) { return false; }
+ virtual void blit(ManagedSurface *g, Common::Rect &dest) {}
+
bool processEvent(Common::Event &event);
void enableCommand(int menunum, int action, bool state);
diff --git a/graphics/macgui/mactextwindow.cpp b/graphics/macgui/mactextwindow.cpp
index 12af27a908..96259c3ff6 100644
--- a/graphics/macgui/mactextwindow.cpp
+++ b/graphics/macgui/mactextwindow.cpp
@@ -135,14 +135,14 @@ const MacFont *MacTextWindow::getTextWindowFont() {
return _font;
}
-bool MacTextWindow::draw(ManagedSurface *g, bool forceRedraw) {
+bool MacTextWindow::draw(bool forceRedraw) {
if (!_borderIsDirty && !_contentIsDirty && !_cursorDirty && !_inputIsDirty && !forceRedraw)
return false;
if (_borderIsDirty || forceRedraw) {
drawBorder();
- _composeSurface.clear(_wm->_colorWhite);
+ _composeSurface->clear(_wm->_colorWhite);
}
if (_inputIsDirty || forceRedraw) {
@@ -153,21 +153,32 @@ bool MacTextWindow::draw(ManagedSurface *g, bool forceRedraw) {
_contentIsDirty = false;
// Compose
- _mactext->draw(&_composeSurface, 0, _scrollPos, _surface.w - 2, _scrollPos + _surface.h - 2, kConWOverlap - 2, kConWOverlap - 2);
+ _mactext->draw(_composeSurface, 0, _scrollPos, _surface.w - 2, _scrollPos + _surface.h - 2, kConWOverlap - 2, kConWOverlap - 2);
if (_cursorState)
- _composeSurface.blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX + kConWOverlap - 2, _cursorY + kConHOverlap - 2));
+ _composeSurface->blitFrom(*_cursorSurface, *_cursorRect, Common::Point(_cursorX + kConWOverlap - 2, _cursorY + kConHOverlap - 2));
if (_selectedText.endY != -1)
drawSelection();
- _composeSurface.transBlitFrom(_borderSurface, kColorGreen);
+ _composeSurface->transBlitFrom(_borderSurface, kColorGreen);
- g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
+ return true;
+}
+
+bool MacTextWindow::draw(ManagedSurface *g, bool forceRedraw) {
+ if (!draw(forceRedraw))
+ return false;
+
+ g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
return true;
}
+void MacTextWindow::blit(ManagedSurface *g, Common::Rect &dest) {
+ g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, kColorGreen2);
+}
+
void MacTextWindow::drawSelection() {
if (_selectedText.endY == -1)
return;
@@ -217,7 +228,7 @@ void MacTextWindow::drawSelection() {
numLines--;
}
- byte *ptr = (byte *)_composeSurface.getBasePtr(x1 + kConWOverlap - 2, y + kConWOverlap - 2);
+ byte *ptr = (byte *)_composeSurface->getBasePtr(x1 + kConWOverlap - 2, y + kConWOverlap - 2);
for (int x = x1; x < x2; x++, ptr++)
if (*ptr == _wm->_colorBlack)
diff --git a/graphics/macgui/mactextwindow.h b/graphics/macgui/mactextwindow.h
index 9ff7e7fbd1..592968e043 100644
--- a/graphics/macgui/mactextwindow.h
+++ b/graphics/macgui/mactextwindow.h
@@ -56,6 +56,8 @@ public:
virtual bool processEvent(Common::Event &event);
virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(bool forceRedraw = false);
+ virtual void blit(ManagedSurface *g, Common::Rect &dest);
void setTextWindowFont(const MacFont *macFont);
const MacFont *getTextWindowFont();
diff --git a/graphics/macgui/macwidget.cpp b/graphics/macgui/macwidget.cpp
index b17e1e3abd..f2f79a6991 100644
--- a/graphics/macgui/macwidget.cpp
+++ b/graphics/macgui/macwidget.cpp
@@ -37,6 +37,8 @@ MacWidget::MacWidget(MacWidget *parent, int x, int y, int w, int h, bool focusab
if (parent)
parent->_children.push_back(this);
+
+ _composeSurface = nullptr;
}
MacWidget::~MacWidget() {
diff --git a/graphics/macgui/macwidget.h b/graphics/macgui/macwidget.h
index 858bc23c90..7bbd480e1a 100644
--- a/graphics/macgui/macwidget.h
+++ b/graphics/macgui/macwidget.h
@@ -58,6 +58,8 @@ public:
void setDirty(bool dirty) { _contentIsDirty = dirty; }
virtual bool draw(ManagedSurface *g, bool forceRedraw = false) = 0;
+ 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;
@@ -70,12 +72,16 @@ public:
void removeWidget(MacWidget *child, bool del = true);
+ Graphics::ManagedSurface *getSurface() { return _composeSurface; }
+
protected:
bool _focusable;
bool _contentIsDirty;
Common::Rect _dims;
+ Graphics::ManagedSurface *_composeSurface;
+
public:
MacWidget *_parent;
Common::Array<MacWidget *> _children;
diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index 80ab084a21..1fbeb8eb7d 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -63,9 +63,15 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, Mac
_closeable = false;
_borderWidth = kBorderWidth;
+
+ _composeSurface = new Graphics::ManagedSurface();
}
MacWindow::~MacWindow() {
+ if (_composeSurface)
+ _composeSurface->free();
+
+ delete _composeSurface;
}
static const byte noborderData[3][3] = {
@@ -116,8 +122,8 @@ void MacWindow::resize(int w, int h) {
_borderSurface.free();
_borderSurface.create(w, h, PixelFormat::createFormatCLUT8());
- _composeSurface.free();
- _composeSurface.create(w, h, PixelFormat::createFormatCLUT8());
+ _composeSurface->free();
+ _composeSurface->create(w, h, PixelFormat::createFormatCLUT8());
_dims.setWidth(w);
_dims.setHeight(h);
@@ -153,7 +159,7 @@ void MacWindow::setBackgroundPattern(int pattern) {
_contentIsDirty = true;
}
-bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
+bool MacWindow::draw(bool forceRedraw) {
if (!_borderIsDirty && !_contentIsDirty && !forceRedraw)
return false;
@@ -163,14 +169,24 @@ bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
_contentIsDirty = false;
// Compose
- _composeSurface.blitFrom(_surface, Common::Rect(0, 0, _surface.w - 2, _surface.h - 2), Common::Point(2, 2));
- _composeSurface.transBlitFrom(_borderSurface, kColorGreen);
+ _composeSurface->blitFrom(_surface, Common::Rect(0, 0, _surface.w - 2, _surface.h - 2), Common::Point(2, 2));
+ _composeSurface->transBlitFrom(_borderSurface, kColorGreen);
+
+ return true;
+}
- g->transBlitFrom(_composeSurface, _composeSurface.getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
+bool MacWindow::draw(ManagedSurface *g, bool forceRedraw) {
+ if (!draw(forceRedraw))
+ return false;
+
+ g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), Common::Point(_dims.left - 2, _dims.top - 2), kColorGreen2);
return true;
}
+void MacWindow::blit(ManagedSurface *g, Common::Rect &dest) {
+ g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, kColorGreen2);
+}
#define ARROW_W 12
#define ARROW_H 6
diff --git a/graphics/macgui/macwindow.h b/graphics/macgui/macwindow.h
index eabb55d3f5..807495872d 100644
--- a/graphics/macgui/macwindow.h
+++ b/graphics/macgui/macwindow.h
@@ -218,6 +218,9 @@ public:
*/
virtual bool draw(ManagedSurface *g, bool forceRedraw = false);
+ virtual bool draw(bool forceRedraw = false);
+ virtual void blit(ManagedSurface *g, Common::Rect &dest);
+
/**
* Mutator to change the active state of the window.
* Most often called from the WM.
@@ -294,7 +297,6 @@ protected:
protected:
ManagedSurface _borderSurface;
- ManagedSurface _composeSurface;
bool _borderIsDirty;
Commit: 2920a76611a81e0f41d80c029541c1eb33a47ae7
https://github.com/scummvm/scummvm/commit/2920a76611a81e0f41d80c029541c1eb33a47ae7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-14T00:43:13+02:00
Commit Message:
DIRECTOR: Further work on editable text rendering
Changed paths:
engines/director/frame.cpp
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 5ef9e1e61c..ba612cb398 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -883,11 +883,22 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
return;
}
- if (sprite->_editable) {
+ if (sprite->_editable && 0) {
if (!textCast->_widget) {
- textCast->_widget = new Graphics::MacEditableText(score->_window, x, y, width, height, g_director->_wm, "", nullptr, sprite->_foreColor, sprite->_backColor);
+ textCast->_widget = new Graphics::MacEditableText(score->_window, x, y, width, height, g_director->_wm, "", new Graphics::MacFont(), sprite->_foreColor, sprite->_backColor);
warning("Created MacEditableText");
}
+
+ textCast->_widget->draw();
+
+ InkType ink = sprite->_ink;
+
+ if (spriteId == score->_currentMouseDownSpriteId)
+ ink = kInkTypeReverse;
+
+ inkBasedBlit(surface, textCast->_widget->getSurface()->rawSurface(), ink, Common::Rect(x, y, x + width, y + height), spriteId);
+
+ return;
}
debugC(3, kDebugText, "renderText: sprite: %d x: %d y: %d w: %d h: %d fontId: '%d' text: '%s'", spriteId, x, y, width, height, textCast->_fontId, Common::toPrintable(textCast->_ftext).c_str());
More information about the Scummvm-git-logs
mailing list