Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-10-09 14:36:56 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-10-09 14:41:26 +0300
commitcf682b9dab36c4b96084c6f7b5e4ebc1f33ca28e (patch)
tree623402d486f638d4157742903899d80945117f1b /intern
parent26b1216629c8a7f6201333514b8fdbf43e10b385 (diff)
GPU: show more descriptive labels on unsupported GPU dialog
Thanks to Ray Molenkamp for the help with the Windows implementation. Fixes T70521 Differential Revision: https://developer.blender.org/D6023
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/GHOST_C-api.h4
-rw-r--r--intern/ghost/GHOST_ISystem.h4
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp4
-rw-r--r--intern/ghost/intern/GHOST_System.h4
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp73
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h7
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp20
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h4
8 files changed, 82 insertions, 38 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 5e0216c0339..720929ce945 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -70,6 +70,8 @@ extern GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle);
* \param systemhandle The handle to the system
* \param title Title of the message box
* \param message Message of the message box
+ * \param help_label Text to show on the help button that opens a link
+ * \param continue_label Text to show on the ok button that continues
* \param link Optional (hyper)link to a webpage to show when pressing help
* \param dialog_options Options to configure the message box.
* \return void.
@@ -77,6 +79,8 @@ extern GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle);
extern void GHOST_ShowMessageBox(GHOST_SystemHandle systemhandle,
const char *title,
const char *message,
+ const char *help_label,
+ const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options);
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index d89785ad9b2..fe2f42df8a6 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -446,11 +446,15 @@ class GHOST_ISystem {
*
* \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 = 0;
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 4d755de77ff..eeb23ea7471 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -50,11 +50,13 @@ GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
void GHOST_ShowMessageBox(GHOST_SystemHandle systemhandle,
const char *title,
const char *message,
+ const char *help_label,
+ const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options)
{
GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
- system->showMessageBox(title, message, link, dialog_options);
+ system->showMessageBox(title, message, help_label, continue_label, link, dialog_options);
}
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback,
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index ea85611870a..893592e3cf5 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -313,11 +313,15 @@ class GHOST_System : public GHOST_ISystem {
* 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
{
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 1423e0df8ec..c86accf4ede 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -28,6 +28,13 @@
# define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */
#endif
+/* clang-format off */
+#pragma comment(linker,"\"/manifestdependency:type='win32' \
+name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
+processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+/* clang-format on */
+
+#include <commctrl.h>
#include <shlobj.h>
#include <tlhelp32.h>
#include <psapi.h>
@@ -35,6 +42,7 @@
#include <windowsx.h>
#include "utfconv.h"
+#include "utf_winfunc.h"
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_EventButton.h"
@@ -511,6 +519,7 @@ GHOST_TSuccess GHOST_SystemWin32::getButtons(GHOST_Buttons &buttons) const
GHOST_TSuccess GHOST_SystemWin32::init()
{
GHOST_TSuccess success = GHOST_System::init();
+ InitCommonControls();
/* Disable scaling on high DPI displays on Vista */
HMODULE
@@ -1773,41 +1782,51 @@ void GHOST_SystemWin32::putClipboard(GHOST_TInt8 *buffer, bool selection) const
/** \name Message Box
* \{ */
-static const char *MESSAGE_BOX_HELP_LINK_PTR = NULL;
-VOID CALLBACK showMessageBoxCallBack(LPHELPINFO lpHelpInfo)
-{
- if (MESSAGE_BOX_HELP_LINK_PTR) {
- ShellExecute(NULL, "open", MESSAGE_BOX_HELP_LINK_PTR, NULL, NULL, SW_SHOWNORMAL);
- }
-}
-
GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title,
const char *message,
+ const char *help_label,
+ const char *continue_label,
const char *link,
GHOST_DialogOptions dialog_options) const
{
- uint style = MB_OK |
- (dialog_options & GHOST_DialogError ?
- MB_ICONERROR :
- dialog_options & GHOST_DialogWarning ? MB_ICONWARNING : MB_ICONINFORMATION);
- bool show_help = link && strlen(link);
- if (show_help) {
- GHOST_ASSERT(MESSAGE_BOX_HELP_LINK_PTR == NULL,
- "showMessageBox: MESSAGE_BOX_HELP_LINK_PTR is in use");
- style |= MB_HELP;
- MESSAGE_BOX_HELP_LINK_PTR = link;
+ const wchar_t *title_16 = alloc_utf16_from_8(title, 0);
+ const wchar_t *message_16 = alloc_utf16_from_8(message, 0);
+ const wchar_t *help_label_16 = alloc_utf16_from_8(help_label, 0);
+ const wchar_t *continue_label_16 = alloc_utf16_from_8(continue_label, 0);
+
+ int nButtonPressed = 0;
+ TASKDIALOGCONFIG config = {0};
+ const TASKDIALOG_BUTTON buttons[] = {{IDOK, help_label_16}, {IDCONTINUE, continue_label_16}};
+
+ config.cbSize = sizeof(config);
+ config.hInstance = 0;
+ config.dwCommonButtons = 0;
+ config.pszMainIcon = (dialog_options & GHOST_DialogError ?
+ TD_ERROR_ICON :
+ dialog_options & GHOST_DialogWarning ? TD_WARNING_ICON :
+ TD_INFORMATION_ICON);
+ config.pszWindowTitle = L"Blender";
+ config.pszMainInstruction = title_16;
+ config.pszContent = message_16;
+ config.pButtons = (link) ? buttons : buttons + 1;
+ config.cButtons = (link) ? 2 : 1;
+
+ TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL);
+ switch (nButtonPressed) {
+ case IDOK:
+ ShellExecute(NULL, "open", link, NULL, NULL, SW_SHOWNORMAL);
+ break;
+ case IDCONTINUE:
+ break;
+ default:
+ break; // should never happen
}
- MSGBOXPARAMSA message_box_params = {0};
- message_box_params.cbSize = sizeof(MSGBOXCALLBACK);
- message_box_params.lpszText = message;
- message_box_params.lpszCaption = title;
- message_box_params.dwStyle = style;
- message_box_params.lpszText = message;
- message_box_params.lpfnMsgBoxCallback = showMessageBoxCallBack;
+ free((void *)title_16);
+ free((void *)message_16);
+ free((void *)help_label_16);
+ free((void *)continue_label_16);
- MessageBoxIndirectA(&message_box_params);
- MESSAGE_BOX_HELP_LINK_PTR = NULL;
return GHOST_kSuccess;
}
/* \} */
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 6e803b3d760..391f0866cd7 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -29,9 +29,6 @@
# error WIN32 only!
#endif // WIN32
-/* require Windows XP or newer */
-#undef _WIN32_WINNT
-#define _WIN32_WINNT 0x501
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -208,11 +205,15 @@ class GHOST_SystemWin32 : public GHOST_System {
* 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
*/
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;
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index a6c6aaffd6f..1ca412fbccc 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -2176,7 +2176,7 @@ class DialogData {
height(175),
padding_x(10),
padding_y(5),
- button_width(50),
+ button_width(130),
button_height(24),
button_inset_x(10),
button_border_size(1),
@@ -2247,6 +2247,8 @@ static void split(const char *text, const char *seps, char ***str, int *count)
GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
const char *message,
+ const char *help_label,
+ const char *continue_label,
const char *link,
GHOST_DialogOptions) const
{
@@ -2325,20 +2327,24 @@ GHOST_TSuccess GHOST_SystemX11::showMessageBox(const char *title,
text_splitted[i],
(int)strlen(text_splitted[i]));
}
- dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 1, "Ok");
+ dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 1, continue_label);
if (strlen(link)) {
- dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 2, "Help");
+ dialog_data.drawButton(m_display, window, buttonBorderGC, buttonGC, 2, help_label);
}
}
else if (e.type == ButtonRelease) {
if (dialog_data.isInsideButton(e, 1)) {
break;
}
- else if (strlen(link) && dialog_data.isInsideButton(e, 2)) {
- string cmd = "xdg-open \"" + string(link) + "\"";
- if (system(cmd.c_str()) != 0) {
- GHOST_PRINTF("GHOST_SystemX11::showMessageBox: Unable to run system command [%s]", cmd);
+ else if (dialog_data.isInsideButton(e, 2)) {
+ if (strlen(link)) {
+ string cmd = "xdg-open \"" + string(link) + "\"";
+ if (system(cmd.c_str()) != 0) {
+ GHOST_PRINTF("GHOST_SystemX11::showMessageBox: Unable to run system command [%s]",
+ cmd);
+ }
}
+ break;
}
}
}
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index ba7371c6ea0..67dd0789ac3 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -237,11 +237,15 @@ class GHOST_SystemX11 : public GHOST_System {
* 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
*/
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;
#ifdef WITH_XDND