diff options
author | Bastien Bouclet | 2019-12-28 10:43:58 +0100 |
---|---|---|
committer | Bastien Bouclet | 2020-01-04 10:56:25 +0100 |
commit | eb28c5a09288e563011b11eafea1c772a7127e7f (patch) | |
tree | 0fc961ac83a19357d6941f93a1e2106e1c4f2b93 | |
parent | 346d53b0342d8a1d543887560a28cc45f211d9ad (diff) | |
download | scummvm-rg350-eb28c5a09288e563011b11eafea1c772a7127e7f.tar.gz scummvm-rg350-eb28c5a09288e563011b11eafea1c772a7127e7f.tar.bz2 scummvm-rg350-eb28c5a09288e563011b11eafea1c772a7127e7f.zip |
GUI: Use a dialog theme layout for the unknown game dialog
-rw-r--r-- | gui/ThemeEngine.cpp | 4 | ||||
-rw-r--r-- | gui/ThemeEngine.h | 2 | ||||
-rw-r--r-- | gui/editgamedialog.cpp | 2 | ||||
-rw-r--r-- | gui/options.cpp | 4 | ||||
-rw-r--r-- | gui/themes/default.inc | 46 | ||||
-rw-r--r-- | gui/themes/scummclassic.zip | bin | 157827 -> 158832 bytes | |||
-rw-r--r-- | gui/themes/scummclassic/classic_layout.stx | 26 | ||||
-rw-r--r-- | gui/themes/scummclassic/classic_layout_lowres.stx | 23 | ||||
-rw-r--r-- | gui/themes/scummmodern.zip | bin | 287886 -> 288886 bytes | |||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 27 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 31 | ||||
-rw-r--r-- | gui/themes/scummremastered.zip | bin | 285930 -> 286934 bytes | |||
-rw-r--r-- | gui/themes/scummremastered/remastered_layout.stx | 28 | ||||
-rw-r--r-- | gui/themes/scummremastered/remastered_layout_lowres.stx | 25 | ||||
-rw-r--r-- | gui/unknown-game-dialog.cpp | 95 | ||||
-rw-r--r-- | gui/widget.cpp | 4 | ||||
-rw-r--r-- | gui/widgets/edittext.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/list.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/popup.cpp | 2 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.cpp | 18 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.h | 6 |
21 files changed, 227 insertions, 120 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 946864bf47..9f28547e4d 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1047,7 +1047,7 @@ void ThemeEngine::drawSlider(const Common::Rect &r, int width, WidgetStateInfo s r2.setWidth(MIN((int16)width, r.width())); // r2.top++; r2.bottom--; r2.left++; r2.right--; - drawWidgetBackground(r, 0, kWidgetBackgroundSlider); + drawWidgetBackground(r, kWidgetBackgroundSlider); drawDD(dd, r2); } @@ -1160,7 +1160,7 @@ void ThemeEngine::drawSurface(const Common::Point &p, const Graphics::Surface &s addDirtyRect(dirtyRect); } -void ThemeEngine::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background) { +void ThemeEngine::drawWidgetBackground(const Common::Rect &r, WidgetBackground background) { if (!ready()) return; diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index db2794cd91..46c8c1ff91 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -402,7 +402,7 @@ public: /** @name WIDGET DRAWING METHODS */ //@{ - void drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background = kWidgetBackgroundPlain); + void drawWidgetBackground(const Common::Rect &r, WidgetBackground background); void drawButton(const Common::Rect &r, const Common::String &str, WidgetStateInfo state = kStateEnabled, uint16 hints = 0); diff --git a/gui/editgamedialog.cpp b/gui/editgamedialog.cpp index a1e368580f..60feac15d6 100644 --- a/gui/editgamedialog.cpp +++ b/gui/editgamedialog.cpp @@ -185,7 +185,7 @@ EditGameDialog::EditGameDialog(const String &domain) // _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GameOptions_Graphics"); ScrollContainerWidget *graphicsContainer = new ScrollContainerWidget(tab, "GameOptions_Graphics.Container", "GameOptions_Graphics_Container", kGraphicsTabContainerReflowCmd); - graphicsContainer->setBackgroundType(ThemeEngine::kDialogBackgroundNone); + graphicsContainer->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); graphicsContainer->setTarget(this); if (g_system->getOverlayWidth() > 320) diff --git a/gui/options.cpp b/gui/options.cpp index 599d865ffb..137494f211 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1551,7 +1551,7 @@ void GlobalOptionsDialog::build() { _graphicsTabId = tab->addTab(g_system->getOverlayWidth() > 320 ? _("Graphics") : _("GFX"), "GlobalOptions_Graphics"); ScrollContainerWidget *graphicsContainer = new ScrollContainerWidget(tab, "GlobalOptions_Graphics.Container", "GlobalOptions_Graphics_Container", kGraphicsTabContainerReflowCmd); graphicsContainer->setTarget(this); - graphicsContainer->setBackgroundType(ThemeEngine::kDialogBackgroundNone); + graphicsContainer->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); addGraphicControls(graphicsContainer, "GlobalOptions_Graphics_Container."); // @@ -1768,7 +1768,7 @@ void GlobalOptionsDialog::build() { ScrollContainerWidget *container = new ScrollContainerWidget(tab, "GlobalOptions_Cloud.Container", "GlobalOptions_Cloud_Container", kCloudTabContainerReflowCmd); container->setTarget(this); - container->setBackgroundType(ThemeEngine::kDialogBackgroundNone); + container->setBackgroundType(ThemeEngine::kWidgetBackgroundNo); setTarget(container); addCloudControls(container, "GlobalOptions_Cloud_Container.", g_system->getOverlayWidth() <= 320); diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 8a56822ba9..affbcb9b4d 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1812,9 +1812,9 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "</layout>" "</dialog>" "<dialog name='GameOptions' overlays='Dialog.Launcher.GameList' shading='dim'>" -"<layout type='vertical' padding='0,0,0,0' spacing='16'>" +"<layout type='vertical' padding='0,0,0,0'>" "<widget name='TabWidget' type='TabWidget'/>" -"<layout type='horizontal' padding='16,16,16,4'>" +"<layout type='horizontal' padding='16,16,16,16'>" "<space/>" "<widget name='Cancel' " "type='Button' " @@ -2641,6 +2641,27 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "</dialog>" "<dialog name='DropdownDialog' overlays='screen_center' shading='luminance'>" "</dialog>" +"<dialog name='UnknownGameDialog' overlays='Dialog.Launcher.GameList' shading='dim'>" +"<layout type='vertical' padding='8,8,8,0'>" +"<widget name='TextContainer' " +"/>" +"<layout type='horizontal' padding='0,0,16,16'>" +"<space/>" +"<widget name='Report' " +"type='Button' " +"/>" +"<widget name='Copy' " +"type='Button' " +"/>" +"<widget name='Close' " +"type='Button' " +"/>" +"<widget name='Add' " +"type='Button' " +"/>" +"</layout>" +"</layout>" +"</dialog>" "</layout_info>" ; const char *defaultXML4 = "<layout_info resolution='y<400'>" @@ -4339,6 +4360,27 @@ const char *defaultXML1 = "<?xml version = '1.0'?>" "</dialog>" "<dialog name='DropdownDialog' overlays='screen_center' shading='luminance'>" "</dialog>" +"<dialog name='UnknownGameDialog' overlays='screen' inset='8' shading='dim'>" +"<layout type='vertical' padding='8,8,8,0'>" +"<widget name='TextContainer' " +"/>" +"<layout type='horizontal' padding='0,0,8,8'>" +"<space/>" +"<widget name='Report' " +"type='Button' " +"/>" +"<widget name='Copy' " +"type='Button' " +"/>" +"<widget name='Close' " +"type='Button' " +"/>" +"<widget name='Add' " +"type='Button' " +"/>" +"</layout>" +"</layout>" +"</dialog>" "</layout_info>" ; const char *defaultXML[] = { defaultXML1, defaultXML2, defaultXML3, defaultXML4 }; diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip Binary files differindex 0414fd0b39..f7c4ddbb1f 100644 --- a/gui/themes/scummclassic.zip +++ b/gui/themes/scummclassic.zip diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx index 9ec0350f47..0cbe043da9 100644 --- a/gui/themes/scummclassic/classic_layout.stx +++ b/gui/themes/scummclassic/classic_layout.stx @@ -955,9 +955,9 @@ </dialog> <dialog name = 'GameOptions' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> - <layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> + <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'TabWidget' type = 'TabWidget'/> - <layout type = 'horizontal' padding = '16, 16, 16, 4'> + <layout type = 'horizontal' padding = '16, 16, 16, 16'> <space/> <widget name = 'Cancel' type = 'Button' @@ -1811,4 +1811,26 @@ </dialog> <dialog name = 'DropdownDialog' overlays = 'screen_center' shading = 'luminance'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 16, 16'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> </layout_info> diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx index 473c336a00..f735acb93c 100644 --- a/gui/themes/scummclassic/classic_layout_lowres.stx +++ b/gui/themes/scummclassic/classic_layout_lowres.stx @@ -1777,6 +1777,29 @@ </layout> </layout> </dialog> + <dialog name = 'DropdownDialog' overlays = 'screen_center' shading = 'luminance'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'screen' inset = '8' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 8, 8'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> </layout_info> diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip Binary files differindex 1c8f107df7..bf3bcc1e57 100644 --- a/gui/themes/scummmodern.zip +++ b/gui/themes/scummmodern.zip diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 71f3d78ff6..537368f6db 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -968,9 +968,9 @@ </dialog> <dialog name = 'GameOptions' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> - <layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> + <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'TabWidget' type = 'TabWidget'/> - <layout type = 'horizontal' padding = '16, 16, 16, 4'> + <layout type = 'horizontal' padding = '16, 16, 16, 16'> <space/> <widget name = 'Cancel' type = 'Button' @@ -1822,6 +1822,29 @@ </layout> </layout> </dialog> + <dialog name = 'DropdownDialog' overlays = 'screen_center'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 16, 16'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> </layout_info> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index c5e0155011..6d26505e56 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -922,12 +922,12 @@ <layout type='vertical' padding='16,16,16,16' spacing='16'> <widget name='TTSCheckbox' type='Checkbox' - /> + /> <widget name='TTSVoiceSelection' type='PopUp' - /> - </layout> - </dialog> + /> + </layout> + </dialog> <dialog name='KeysDialog' overlays='Dialog.GlobalOptions' shading='dim'> <layout type='vertical' padding='8,8,8,8' align = 'center'> @@ -1795,6 +1795,29 @@ </layout> </layout> </dialog> + <dialog name = 'DropdownDialog' overlays = 'screen_center'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'screen' inset = '8' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 8, 8'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> </layout_info> diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip Binary files differindex 5ed31519a3..bf23c0ac8a 100644 --- a/gui/themes/scummremastered.zip +++ b/gui/themes/scummremastered.zip diff --git a/gui/themes/scummremastered/remastered_layout.stx b/gui/themes/scummremastered/remastered_layout.stx index c5d8eef5c2..895b0b9e4c 100644 --- a/gui/themes/scummremastered/remastered_layout.stx +++ b/gui/themes/scummremastered/remastered_layout.stx @@ -968,9 +968,9 @@ </dialog> <dialog name = 'GameOptions' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> - <layout type = 'vertical' padding = '0, 0, 0, 0' spacing = '16'> + <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'TabWidget' type = 'TabWidget'/> - <layout type = 'horizontal' padding = '16, 16, 16, 4'> + <layout type = 'horizontal' padding = '16, 16, 16, 16'> <space/> <widget name = 'Cancel' type = 'Button' @@ -1822,6 +1822,30 @@ </layout> </layout> </dialog> + <dialog name = 'DropdownDialog' overlays = 'screen_center'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'Dialog.Launcher.GameList' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 16, 16'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> + </layout_info> diff --git a/gui/themes/scummremastered/remastered_layout_lowres.stx b/gui/themes/scummremastered/remastered_layout_lowres.stx index fa81408d82..6d26505e56 100644 --- a/gui/themes/scummremastered/remastered_layout_lowres.stx +++ b/gui/themes/scummremastered/remastered_layout_lowres.stx @@ -611,7 +611,7 @@ <layout type = 'vertical' padding = '0, 0, 0, 0'> <widget name = 'Container'/> </layout> - </dialog> + </dialog> <dialog name = 'GlobalOptions_Cloud_Container' overlays = 'GlobalOptions_Cloud.Container'> <layout type = 'vertical' padding = '10, 13, 10, 10' spacing = '8'> @@ -1795,6 +1795,29 @@ </layout> </layout> </dialog> + <dialog name = 'DropdownDialog' overlays = 'screen_center'> </dialog> + + <dialog name = 'UnknownGameDialog' overlays = 'screen' inset = '8' shading = 'dim'> + <layout type = 'vertical' padding = '8, 8, 8, 0'> + <widget name = 'TextContainer' + /> + <layout type = 'horizontal' padding = '0, 0, 8, 8'> + <space/> + <widget name = 'Report' + type = 'Button' + /> + <widget name = 'Copy' + type = 'Button' + /> + <widget name = 'Close' + type = 'Button' + /> + <widget name = 'Add' + type = 'Button' + /> + </layout> + </layout> + </dialog> </layout_info> diff --git a/gui/unknown-game-dialog.cpp b/gui/unknown-game-dialog.cpp index cdbfcd4e97..b443334347 100644 --- a/gui/unknown-game-dialog.cpp +++ b/gui/unknown-game-dialog.cpp @@ -38,36 +38,35 @@ enum { kCopyToClipboard = 'cpcl', kOpenBugtrackerURL = 'ourl', kClose = 'clse', - kAddAnyway = 'adda', - kScrollContainerReflow = 'SCRf' + kAddAnyway = 'adda' }; UnknownGameDialog::UnknownGameDialog(const DetectedGame &detectedGame) : - Dialog(30, 20, 260, 124), + Dialog("UnknownGameDialog"), _detectedGame(detectedGame) { - // For now place the buttons with a default place and size. They will be resized and moved when rebuild() is called. - _closeButton = new ButtonWidget(this, 0, 0, 0, 0, detectedGame.canBeAdded ? _("Cancel") : _("Close"), 0, kClose); if (detectedGame.canBeAdded) { - _addAnywayButton = new ButtonWidget(this, 0, 0, 0, 0, _("Add anyway"), 0, kAddAnyway); + _addAnywayButton = new ButtonWidget(this, "UnknownGameDialog.Add", _("Add anyway"), 0, kAddAnyway); } else { _addAnywayButton = nullptr; } + _closeButton = new ButtonWidget(this, "UnknownGameDialog.Close", detectedGame.canBeAdded ? _("Cancel") : _("Close"), 0, kClose); + //Check if we have clipboard functionality if (g_system->hasFeature(OSystem::kFeatureClipboardSupport)) { - _copyToClipboardButton = new ButtonWidget(this, 0, 0, 0, 0, _("Copy to clipboard"), 0, kCopyToClipboard); + _copyToClipboardButton = new ButtonWidget(this, "UnknownGameDialog.Copy", _("Copy to clipboard"), 0, kCopyToClipboard); } else _copyToClipboardButton = nullptr; //Check if we have support for opening URLs if (g_system->hasFeature(OSystem::kFeatureOpenUrl)) { - _openBugTrackerUrlButton = new ButtonWidget(this, 0, 0, 0, 0, _("Report game"), 0, kOpenBugtrackerURL); + _openBugTrackerUrlButton = new ButtonWidget(this, "UnknownGameDialog.Report", _("Report game"), 0, kOpenBugtrackerURL); } else _openBugTrackerUrlButton = nullptr; // Use a ScrollContainer for the report in case we have a lot of lines. - _textContainer = new ScrollContainerWidget(this, 0, 0, 0, 0, kScrollContainerReflow); + _textContainer = new ScrollContainerWidget(this, "UnknownGameDialog.TextContainer", ""); _textContainer->setTarget(this); rebuild(); @@ -78,28 +77,22 @@ void UnknownGameDialog::handleMouseWheel(int x, int y, int direction) { } void UnknownGameDialog::reflowLayout() { - rebuild(); Dialog::reflowLayout(); + rebuild(); } void UnknownGameDialog::rebuild() { - // TODO: Use a theme layout dialog definition - // First remove the old text widgets for (uint i = 0; i < _textWidgets.size() ; i++) { _textContainer->removeWidget(_textWidgets[i]); + + // Also remove the widget from the dialog for the case it was + // the active widget. + removeWidget(_textWidgets[i]); delete _textWidgets[i]; } _textWidgets.clear(); - // Work out dialog size and position of the various elements in the dialog. - // Limit the width of the dialog to 600 - 2 * 10 pixels. - const int screenW = MIN((int)g_system->getOverlayWidth(), 600); - const int screenH = g_system->getOverlayHeight(); - - int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0); - int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0); - Common::String reportTranslated = generateUnknownGameReport(_detectedGame, true, true); // Check if we have clipboard functionality and expand the reportTranslated message if needed... @@ -113,64 +106,14 @@ void UnknownGameDialog::rebuild() { reportTranslated += _("You can also directly report your game to the Bug Tracker."); } - // We use a ScrollContainer to display the text, with a 2 * 8 pixels margin to the dialog border, - // the scrollbar, and 2 * 10 margin for the text in the container. - // We also keep 2 * 10 pixels between the screen border and the dialog. - int scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0); + // We use a ScrollContainer to display the text, with a 2 * 10 margin for the text in the container. Common::Array<Common::String> lines; - int maxlineWidth = g_gui.getFont().wordWrapText(reportTranslated, screenW - 2 * 20 - 16 - scrollbarWidth, lines); - - int lineCount = lines.size() + 1; - - _h = MIN(screenH - 20, lineCount * kLineHeight + kLineHeight + buttonHeight + 24); - - int closeButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_closeButton->getLabel()) + 10); - int copyToClipboardButtonWidth = 0, openBugtrackerURLButtonWidth = 0, addAnywayButtonWidth = 0; - int totalButtonWidth = closeButtonWidth; - - if (_copyToClipboardButton) { - copyToClipboardButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_copyToClipboardButton->getLabel()) + 10); - totalButtonWidth += copyToClipboardButtonWidth + 10; - } - if (_openBugTrackerUrlButton) { - openBugtrackerURLButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_openBugTrackerUrlButton->getLabel()) + 10); - totalButtonWidth += openBugtrackerURLButtonWidth + 10; - } - if (_addAnywayButton) { - addAnywayButtonWidth = MAX(buttonWidth, g_gui.getFont().getStringWidth(_addAnywayButton->getLabel()) + 10); - totalButtonWidth += addAnywayButtonWidth + 10; - } + g_gui.getFont().wordWrapText(reportTranslated, _textContainer->getWidth() - 20, lines); - _w = MAX(MAX(maxlineWidth, 0) + 16 + scrollbarWidth, totalButtonWidth) + 20; - - // Center the dialog on the screen - _x = (g_system->getOverlayWidth() - _w) / 2; - _y = (g_system->getOverlayHeight() - _h) / 2; - - // Now move the buttons and text container to their proper place - int buttonPos = _w - 10; - if (_addAnywayButton) { - buttonPos -= addAnywayButtonWidth + 5; - _addAnywayButton->resize(buttonPos, _h - buttonHeight - 8, addAnywayButtonWidth, buttonHeight); - } - buttonPos -= closeButtonWidth + 5; - _closeButton->resize(buttonPos, _h - buttonHeight - 8, closeButtonWidth, buttonHeight); - if (_copyToClipboardButton) { - buttonPos -= copyToClipboardButtonWidth + 5; - _copyToClipboardButton->resize(buttonPos, _h - buttonHeight - 8, copyToClipboardButtonWidth, buttonHeight); - } - if (_openBugTrackerUrlButton) { - buttonPos -= openBugtrackerURLButtonWidth + 5; - _openBugTrackerUrlButton->resize(buttonPos, _h - buttonHeight - 8, openBugtrackerURLButtonWidth, buttonHeight); - } - - int containerHeight = _h - kLineHeight - buttonHeight - 16; - _textContainer->resize(8, 8, _w - 16, containerHeight); - - // And create text widgets + // Create text widgets uint y = 8; for (uint i = 0; i < lines.size() ; i++) { - StaticTextWidget *widget = new StaticTextWidget(_textContainer, 10, y, _w - 36 - scrollbarWidth, kLineHeight, lines[i], Graphics::kTextAlignLeft); + StaticTextWidget *widget = new StaticTextWidget(_textContainer, 10, y, _textContainer->getWidth() - 20, kLineHeight, lines[i], Graphics::kTextAlignLeft); _textWidgets.push_back(widget); y += kLineHeight; } @@ -228,10 +171,6 @@ void UnknownGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 case kOpenBugtrackerURL: g_system->openUrl(generateBugtrackerURL()); break; - case kScrollContainerReflow: - for (uint i = 0; i < _textWidgets.size() ; i++) - _textWidgets[i]->setVisible(true); - break; default: break; } diff --git a/gui/widget.cpp b/gui/widget.cpp index 17098df6ea..1a81d8fba1 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -115,7 +115,7 @@ void Widget::draw() { // Draw border if (_flags & WIDGET_BORDER) { - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundBorder); _x += 4; _y += 4; @@ -900,7 +900,7 @@ void ContainerWidget::setBackgroundType(ThemeEngine::WidgetBackground background } void ContainerWidget::drawWidget() { - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, _backgroundType); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), _backgroundType); } } // End of namespace GUI diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index e2dcd2be3e..ff21b3d3a9 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -90,7 +90,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount) { } void EditTextWidget::drawWidget() { - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundEditText); // Draw the text diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index 9144282e65..8bdc002a8e 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -520,7 +520,7 @@ void ListWidget::drawWidget() { Common::String buffer; // Draw a thin frame around the list. - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0, + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundBorder); // Draw the list items diff --git a/gui/widgets/popup.cpp b/gui/widgets/popup.cpp index ebb69f1e4d..aa87e1e835 100644 --- a/gui/widgets/popup.cpp +++ b/gui/widgets/popup.cpp @@ -130,7 +130,7 @@ void PopUpDialog::drawDialog(DrawLayer layerToDraw) { Dialog::drawDialog(layerToDraw); // Draw the menu border - g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), ThemeEngine::kWidgetBackgroundPlain); /*if (_twoColumns) g_gui.vLine(_x + _w / 2, _y, _y + _h - 2, g_gui._color);*/ diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp index e0680e123b..ac79f844f9 100644 --- a/gui/widgets/scrollcontainer.cpp +++ b/gui/widgets/scrollcontainer.cpp @@ -41,7 +41,7 @@ ScrollContainerWidget::ScrollContainerWidget(GuiObject *boss, const Common::Stri void ScrollContainerWidget::init() { setFlags(WIDGET_ENABLED); _type = kScrollContainerWidget; - _backgroundType = ThemeEngine::kDialogBackgroundDefault; + _backgroundType = ThemeEngine::kWidgetBackgroundPlain; _verticalScroll = new ScrollBarWidget(this, _w-16, 0, 16, _h); _verticalScroll->setTarget(this); _scrolledX = 0; @@ -136,24 +136,12 @@ void ScrollContainerWidget::reflowLayout() { //recalculate height recalc(); - //hide those widgets which are out of visible area - ptr = _firstWidget; - while (ptr) { - int y = ptr->getAbsY() - getChildY(); - int h = ptr->getHeight(); - bool visible = ptr->isVisible(); - if (y + h - _scrolledY < 0) visible = false; - if (y - _scrolledY > _limitH) visible = false; - ptr->setVisible(visible); - ptr = ptr->next(); - } - _verticalScroll->setVisible(_verticalScroll->_numEntries > _limitH); //show when there is something to scroll _verticalScroll->recalc(); } void ScrollContainerWidget::drawWidget() { - g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight()), _backgroundType); + g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight()), _backgroundType); } bool ScrollContainerWidget::containsWidget(Widget *w) const { @@ -176,7 +164,7 @@ Common::Rect ScrollContainerWidget::getClipRect() const { return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight() - 1); // this -1 is because of container border, which might not be present actually } -void ScrollContainerWidget::setBackgroundType(ThemeEngine::DialogBackground backgroundType) { +void ScrollContainerWidget::setBackgroundType(ThemeEngine::WidgetBackground backgroundType) { _backgroundType = backgroundType; } diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h index fd8db765a3..d534a6352b 100644 --- a/gui/widgets/scrollcontainer.h +++ b/gui/widgets/scrollcontainer.h @@ -34,7 +34,7 @@ class ScrollContainerWidget: public Widget, public CommandSender { int16 _scrolledX, _scrolledY; uint16 _limitH; uint32 _reflowCmd; - ThemeEngine::DialogBackground _backgroundType; + ThemeEngine::WidgetBackground _backgroundType; Common::String _dialogName; void recalc(); @@ -52,11 +52,10 @@ public: Common::Rect getClipRect() const override; - void setBackgroundType(ThemeEngine::DialogBackground backgroundType); + void setBackgroundType(ThemeEngine::WidgetBackground backgroundType); void handleMouseWheel(int x, int y, int direction) override; -protected: // We overload getChildY to make sure child widgets are positioned correctly. // Essentially this compensates for the space taken up by the tab title header. int16 getChildX() const override; @@ -64,6 +63,7 @@ protected: uint16 getWidth() const override; uint16 getHeight() const override; +protected: void drawWidget() override; Widget *findWidget(int x, int y) override; |