mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
GUI: Use a dialog theme layout for the unknown game dialog
This commit is contained in:
parent
346d53b034
commit
eb28c5a092
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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 };
|
||||
|
Binary file not shown.
@ -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>
|
||||
|
@ -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>
|
||||
|
Binary file not shown.
@ -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>
|
||||
|
@ -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>
|
||||
|
Binary file not shown.
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
g_gui.getFont().wordWrapText(reportTranslated, _textContainer->getWidth() - 20, 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;
|
||||
}
|
||||
|
||||
_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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user