GPU: Add Dummy Backend For Unsupported Platforms #110919

Merged
Jeroen Bakker merged 10 commits from Jeroen-Bakker/blender:gpu/dummy-backend into main 2023-08-15 14:15:18 +02:00
3 changed files with 59 additions and 2 deletions
Showing only changes of commit 6fc0a3cb1c - Show all commits

View File

@ -267,6 +267,22 @@ class GHOST_SystemCocoa : public GHOST_System {
*/
GHOST_TSuccess handleKeyEvent(void *eventPtr);
/**
* Show a system message box
* \param title: The title of the message box.
* \param message: The message to display.
* \param help_label: Help button label.
* \param continue_label: Continue button label.
* \param link: An optional hyperlink.
* \param dialog_options: Options how to display the message.
*/
virtual GHOST_TSuccess showMessageBox(const char *title,
const char *message,
const char *help_label,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options) const;
protected:
/**
* Initializes the system.

View File

@ -2013,3 +2013,44 @@ void GHOST_SystemCocoa::putClipboard(const char *buffer, bool selection) const
[pasteBoard setString:textToCopy forType:NSPasteboardTypeString];
}
}
GHOST_TSuccess GHOST_SystemCocoa::showMessageBox(const char *title,
const char *message,
const char *help_label,
const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options) const
{
@autoreleasepool {
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
Jeroen-Bakker marked this conversation as resolved

Nitpicky, but can we make this dialog a bit wider?
https://stackoverflow.com/a/26502127

Nitpicky, but can we make this dialog a bit wider? https://stackoverflow.com/a/26502127
NSString *titleString = [NSString stringWithCString:title];
NSString *messageString = [NSString stringWithCString:message];
NSString *continueString = [NSString stringWithCString:continue_label];
NSString *helpString = [NSString stringWithCString:help_label];
if (dialog_options == GHOST_DialogError) {
[alert setAlertStyle:NSAlertStyleCritical];
}
else if (dialog_options == GHOST_DialogWarning) {
[alert setAlertStyle:NSAlertStyleWarning];
}
else {
[alert setAlertStyle:NSAlertStyleInformational];
}
[alert setMessageText:titleString];
[alert setInformativeText:messageString];
[alert addButtonWithTitle:continueString];
if (strlen(link)) {
[alert addButtonWithTitle:helpString];
}
NSModalResponse response = [alert runModal];
if (response == NSAlertSecondButtonReturn) {
NSString *linkString = [NSString stringWithCString:link];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:linkString]];
}
}
return GHOST_kSuccess;
}

View File

@ -2588,8 +2588,8 @@ GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title,
config.pszWindowTitle = L"Blender";
config.pszMainInstruction = title_16;
config.pszContent = message_16;
config.pButtons = (link) ? buttons : buttons + 1;
config.cButtons = (link) ? 2 : 1;
config.pButtons = strlen(link) ? buttons : buttons + 1;
Jeroen-Bakker marked this conversation as resolved Outdated

link is documented as being optional so I would still check for nullptr before strlen.

`link` is documented as being optional so I would still check for nullptr before strlen.
config.cButtons = strlen(link) ? 2 : 1;
TaskDialogIndirect(&config, &nButtonPressed, nullptr, nullptr);
switch (nButtonPressed) {