[Bf-blender-cvs] [cf682b9dab3] master: GPU: show more descriptive labels on unsupported GPU dialog

Brecht Van Lommel noreply at git.blender.org
Wed Oct 9 13:42:57 CEST 2019


Commit: cf682b9dab36c4b96084c6f7b5e4ebc1f33ca28e
Author: Brecht Van Lommel
Date:   Wed Oct 9 13:36:56 2019 +0200
Branches: master
https://developer.blender.org/rBcf682b9dab36c4b96084c6f7b5e4ebc1f33ca28e

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

===================================================================

M	build_files/cmake/platform/platform_win32.cmake
M	intern/ghost/GHOST_C-api.h
M	intern/ghost/GHOST_ISystem.h
M	intern/ghost/intern/GHOST_C-api.cpp
M	intern/ghost/intern/GHOST_System.h
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_SystemWin32.h
M	intern/ghost/intern/GHOST_SystemX11.cpp
M	intern/ghost/intern/GHOST_SystemX11.h
M	source/blender/windowmanager/intern/wm_platform_support.c
M	source/blender/windowmanager/intern/wm_window.c
M	source/blender/windowmanager/intern/wm_window_private.h

===================================================================

diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 7e0fff00a37..7956a299320 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -112,7 +112,7 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
 
 list(APPEND PLATFORM_LINKLIBS
-  ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32
+  ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32
   advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp
 )
 
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
   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list