Remove wxSTAY_ON_TOP from splash screen on Windows to stop it hiding
[dcpomatic.git] / src / wx / wx_util.cc
index 8b6d0961ba74a0f91b3e59d11c3b309a9ade9bc5..77980a0133ac43243172c4e7f12dca3f3e3b29a0 100644 (file)
@@ -38,6 +38,7 @@ DCPOMATIC_DISABLE_WARNINGS
 #include <wx/splash.h>
 #include <wx/progdlg.h>
 #include <wx/filepicker.h>
+#include <wx/sizer.h>
 DCPOMATIC_ENABLE_WARNINGS
 #include <boost/thread.hpp>
 
@@ -64,6 +65,22 @@ create_label (wxWindow* p, wxString t, bool)
        return new StaticText (p, t);
 }
 
+
+#ifdef __WXOSX__
+static
+void
+setup_osx_flags (wxSizer* s, bool left, int& flags)
+{
+       if (left) {
+               auto box = dynamic_cast<wxBoxSizer*>(s);
+               if (!box || box->GetOrientation() != wxHORIZONTAL) {
+                       flags |= wxALIGN_RIGHT;
+               }
+       }
+}
+#endif
+
+
 /** Add a wxStaticText to a wxSizer, aligning it at vertical centre.
  *  @param s Sizer to add to.
  *  @param p Parent window for the wxStaticText.
@@ -76,9 +93,7 @@ wxStaticText *
 add_label_to_sizer (wxSizer* s, wxWindow* p, wxString t, bool left, int prop, int flags)
 {
 #ifdef __WXOSX__
-       if (left) {
-               flags |= wxALIGN_RIGHT;
-       }
+       setup_osx_flags (s, left, flags);
 #endif
        auto m = create_label (p, t, left);
        s->Add (m, prop, flags, 6);
@@ -93,9 +108,7 @@ add_label_to_sizer (wxSizer* s, wxStaticText* t, bool, int prop, int flags)
 #endif
 {
 #ifdef __WXOSX__
-       if (left) {
-               flags |= wxALIGN_RIGHT;
-       }
+       setup_osx_flags (s, left, flags);
 #endif
        s->Add (t, prop, flags, 6);
        return t;
@@ -106,9 +119,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBP
 {
        int flags = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT;
 #ifdef __WXOSX__
-       if (left) {
-               flags |= wxALIGN_RIGHT;
-       }
+       setup_osx_flags (s, left, flags);
 #endif
        auto m = create_label (p, t, left);
        s->Add (m, pos, span, flags);
@@ -124,9 +135,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos,
 {
        int flags = wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT;
 #ifdef __WXOSX__
-       if (left) {
-               flags |= wxALIGN_RIGHT;
-       }
+       setup_osx_flags (s, left, flags);
 #endif
        s->Add (t, pos, span, flags);
        return t;
@@ -467,6 +476,7 @@ setup_audio_channels_choice (wxChoice* choice, int minimum)
        checked_set (choice, items);
 }
 
+
 wxSplashScreen *
 maybe_show_splash ()
 {
@@ -474,7 +484,12 @@ maybe_show_splash ()
        try {
                wxBitmap bitmap;
                if (bitmap.LoadFile(bitmap_path("splash"), wxBITMAP_TYPE_PNG)) {
+#ifdef DCPOMATIC_WINDOWS
+                       /* Having wxSTAY_ON_TOP means error dialogues hide behind the splash screen on Windows, no matter what I try */
+                       splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE | wxFRAME_NO_TASKBAR);
+#else
                        splash = new wxSplashScreen (bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, 0, -1);
+#endif
                        wxYield ();
                }
        } catch (boost::filesystem::filesystem_error& e) {