Browse Source

Make some macOS dialogs modal, hack around edit dialog on top

tags/v2.3.1
falkTX 3 years ago
parent
commit
e2430861ed
7 changed files with 59 additions and 7 deletions
  1. +1
    -0
      source/backend/CarlaUtils.h
  2. +13
    -0
      source/backend/utils/Windows.cpp
  3. +6
    -2
      source/frontend/carla_database.py
  4. +9
    -0
      source/frontend/carla_settings.py
  5. +6
    -0
      source/frontend/carla_utils.py
  6. +15
    -1
      source/frontend/carla_widgets.py
  7. +9
    -4
      source/frontend/widgets/paramspinbox.py

+ 1
- 0
source/backend/CarlaUtils.h View File

@@ -305,6 +305,7 @@ CARLA_EXPORT void carla_set_process_name(const char* name);
* window control */ * window control */


CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr);
CARLA_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent);


CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2); CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2);




+ 13
- 0
source/backend/utils/Windows.cpp View File

@@ -43,6 +43,19 @@ int carla_cocoa_get_window(void* nsViewPtr)
#endif #endif
} }


void carla_cocoa_set_transient_window_for(void* nsViewChildPtr, void* nsViewParentPtr)
{
CARLA_SAFE_ASSERT_RETURN(nsViewChildPtr != nullptr,);
CARLA_SAFE_ASSERT_RETURN(nsViewParentPtr != nullptr,);

#if defined(CARLA_OS_MAC) && !defined(CARLA_PLUGIN_EXPORT)
NSView* const nsViewChild = (NSView*)nsViewChildPtr;
NSView* const nsViewParent = (NSView*)nsViewParentPtr;
[[nsViewParent window] addChildWindow:[nsViewChild window]
ordered:NSWindowAbove];
#endif
}

void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2) void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2)
{ {
CARLA_SAFE_ASSERT_RETURN(winId1 != 0,); CARLA_SAFE_ASSERT_RETURN(winId1 != 0,);


+ 6
- 2
source/frontend/carla_database.py View File

@@ -1122,7 +1122,9 @@ class PluginRefreshW(QDialog):
self.ui.ch_vst3.setEnabled(False) self.ui.ch_vst3.setEnabled(False)
self.ui.ch_vst3.setVisible(False) self.ui.ch_vst3.setVisible(False)


if not MACOS:
if MACOS:
self.setWindowModality(Qt.WindowModal)
else:
self.ui.ch_au.setEnabled(False) self.ui.ch_au.setEnabled(False)
self.ui.ch_au.setVisible(False) self.ui.ch_au.setVisible(False)


@@ -1434,7 +1436,9 @@ class PluginDatabaseW(QDialog):
self.ui.ch_bridged_wine.setChecked(False) self.ui.ch_bridged_wine.setChecked(False)
self.ui.ch_bridged_wine.setEnabled(False) self.ui.ch_bridged_wine.setEnabled(False)


if not MACOS:
if MACOS:
self.setWindowModality(Qt.WindowModal)
else:
self.ui.ch_au.setChecked(False) self.ui.ch_au.setChecked(False)
self.ui.ch_au.setEnabled(False) self.ui.ch_au.setEnabled(False)
self.ui.ch_au.setVisible(False) self.ui.ch_au.setVisible(False)


+ 9
- 0
source/frontend/carla_settings.py View File

@@ -214,6 +214,9 @@ class DriverSettingsW(QDialog):


self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)


if MACOS:
self.setWindowModality(Qt.WindowModal)

# ------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------
# Load settings # Load settings


@@ -372,6 +375,9 @@ class RuntimeDriverSettingsW(QDialog):
self.adjustSize() self.adjustSize()
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)


if MACOS:
self.setWindowModality(Qt.WindowModal)

# ------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------
# Load runtime settings # Load runtime settings


@@ -554,6 +560,9 @@ class CarlaSettingsW(QDialog):


self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)


if MACOS:
self.setWindowModality(Qt.WindowModal)

# ------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------
# Load settings # Load settings




+ 6
- 0
source/frontend/carla_utils.py View File

@@ -330,6 +330,9 @@ class CarlaUtils():
self.lib.carla_cocoa_get_window.argtypes = [c_uintptr] self.lib.carla_cocoa_get_window.argtypes = [c_uintptr]
self.lib.carla_cocoa_get_window.restype = c_int self.lib.carla_cocoa_get_window.restype = c_int


self.lib.carla_cocoa_set_transient_window_for.argtypes = [c_uintptr, c_uintptr]
self.lib.carla_cocoa_set_transient_window_for.restype = None

self.lib.carla_x11_reparent_window.argtypes = [c_uintptr, c_uintptr] self.lib.carla_x11_reparent_window.argtypes = [c_uintptr, c_uintptr]
self.lib.carla_x11_reparent_window.restype = None self.lib.carla_x11_reparent_window.restype = None


@@ -480,6 +483,9 @@ class CarlaUtils():
def cocoa_get_window(self, winId): def cocoa_get_window(self, winId):
return self.lib.carla_cocoa_get_window(winId) return self.lib.carla_cocoa_get_window(winId)


def cocoa_set_transient_window_for(self, childWinId, parentWinId):
self.lib.carla_cocoa_set_transient_window_for(childWinId, parentWinId)

def x11_reparent_window(self, winId1, winId2): def x11_reparent_window(self, winId1, winId2):
self.lib.carla_x11_reparent_window(winId1, winId2) self.lib.carla_x11_reparent_window(winId1, winId2)




+ 15
- 1
source/frontend/carla_widgets.py View File

@@ -240,6 +240,9 @@ class CarlaAboutW(QDialog):


self.setWindowFlags(flags) self.setWindowFlags(flags)


if MACOS:
self.setWindowModality(Qt.WindowModal)

# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# JUCE About dialog # JUCE About dialog


@@ -262,6 +265,9 @@ class JuceAboutW(QDialog):


self.setWindowFlags(flags) self.setWindowFlags(flags)


if MACOS:
self.setWindowModality(Qt.WindowModal)

# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Plugin Parameter # Plugin Parameter


@@ -737,7 +743,9 @@ class PluginEdit(QDialog):
self.ui.rb_pan.setEnabled(False) self.ui.rb_pan.setEnabled(False)
self.ui.rb_pan.setVisible(False) self.ui.rb_pan.setVisible(False)


self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
flags = self.windowFlags()
flags &= ~Qt.WindowContextHelpButtonHint
self.setWindowFlags(flags)


self.reloadAll() self.reloadAll()


@@ -1292,6 +1300,12 @@ class PluginEdit(QDialog):


QDialog.setVisible(self, yesNo) QDialog.setVisible(self, yesNo)


if MACOS and yesNo:
parent = self.parent()
if parent is None:
return
gCarla.utils.cocoa_set_transient_window_for(self.windowHandle().winId(), parent.windowHandle().winId())

#------------------------------------------------------------------ #------------------------------------------------------------------


def idleSlow(self): def idleSlow(self):


+ 9
- 4
source/frontend/widgets/paramspinbox.py View File

@@ -31,7 +31,7 @@ from PyQt5.QtWidgets import QAbstractSpinBox, QApplication, QComboBox, QDialog,


import ui_inputdialog_value import ui_inputdialog_value


from carla_shared import countDecimalPoints
from carla_shared import countDecimalPoints, MACOS


# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Get a fixed value within min/max bounds # Get a fixed value within min/max bounds
@@ -57,27 +57,32 @@ class CustomInputDialog(QDialog):
self.ui = ui_inputdialog_value.Ui_Dialog() self.ui = ui_inputdialog_value.Ui_Dialog()
self.ui.setupUi(self) self.ui.setupUi(self)


decimals = countDecimalPoints(step, stepSmall)
self.ui.label.setText(label) self.ui.label.setText(label)
self.ui.doubleSpinBox.setDecimals(countDecimalPoints(step, stepSmall))
self.ui.doubleSpinBox.setDecimals(decimals)
self.ui.doubleSpinBox.setRange(minimum, maximum) self.ui.doubleSpinBox.setRange(minimum, maximum)
self.ui.doubleSpinBox.setSingleStep(step) self.ui.doubleSpinBox.setSingleStep(step)
self.ui.doubleSpinBox.setValue(current) self.ui.doubleSpinBox.setValue(current)
self.ui.doubleSpinBox.setPrefix(prefix) self.ui.doubleSpinBox.setPrefix(prefix)
self.ui.doubleSpinBox.setSuffix(suffix) self.ui.doubleSpinBox.setSuffix(suffix)


if MACOS:
self.setWindowModality(Qt.WindowModal)

if not scalePoints: if not scalePoints:
self.ui.groupBox.setVisible(False) self.ui.groupBox.setVisible(False)
self.resize(200, 0) self.resize(200, 0)
else: else:
text = "<table>" text = "<table>"
for scalePoint in scalePoints: for scalePoint in scalePoints:
text += "<tr><td align='right'>%f</td><td align='left'> - %s</td></tr>" % (scalePoint['value'], scalePoint['label'])
valuestr = ("%i" if decimals == 0 else "%f") % scalePoint['value']
text += "<tr><td align='right'>%s</td><td align='left'> - %s</td></tr>" % (valuestr, scalePoint['label'])
text += "</table>" text += "</table>"
self.ui.textBrowser.setText(text) self.ui.textBrowser.setText(text)
self.resize(200, 300) self.resize(200, 300)


self.fRetValue = current self.fRetValue = current
self.adjustSize()
self.accepted.connect(self.slot_setReturnValue) self.accepted.connect(self.slot_setReturnValue)


def returnValue(self): def returnValue(self):


Loading…
Cancel
Save