From 22f477dd0a28f5296ed6e0fc14119abfc13f9b19 Mon Sep 17 00:00:00 2001 From: SpomJ Date: Sat, 23 Nov 2024 15:16:03 +0300 Subject: [PATCH 1/4] Improve the way size constraints are placed --- src/gui/ControllerRackView.cpp | 7 +------ src/gui/MicrotunerConfig.cpp | 9 +++------ src/gui/MidiCCRackView.cpp | 7 +++---- src/gui/MixerView.cpp | 8 +------- src/gui/SubWindow.cpp | 4 ++++ src/gui/instrument/InstrumentTrackWindow.cpp | 6 +++--- src/gui/widgets/TempoSyncBarModelEditor.cpp | 4 ++-- src/gui/widgets/TempoSyncKnob.cpp | 4 ++-- 8 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/gui/ControllerRackView.cpp b/src/gui/ControllerRackView.cpp index d7d5ee8dee2..83e2165e130 100644 --- a/src/gui/ControllerRackView.cpp +++ b/src/gui/ControllerRackView.cpp @@ -78,15 +78,10 @@ ControllerRackView::ControllerRackView() layout->addWidget( m_addButton ); this->setLayout( layout ); - QMdiSubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget( this ); + SubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget(this); - // TODO: Automate setting one of these, stop hardcoding title bar height - // Set dimensions for detached mode setFixedWidth(350); setMinimumHeight(200); - // Set dimensions for embedded mode - subWin->setFixedWidth(350); - subWin->setMinimumHeight(230); // No maximize button Qt::WindowFlags flags = subWin->windowFlags(); diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 783c65e2870..bf191d9e74f 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -202,13 +202,10 @@ MicrotunerConfig::MicrotunerConfig() : this->setLayout(microtunerLayout); // Add to the main window and setup fixed size etc. - QMdiSubWindow *subWin = getGUI()->mainWindow()->addWindowedWidget(this); - + SubWindow *subWin = getGUI()->mainWindow()->addWindowedWidget(this); subWin->setAttribute(Qt::WA_DeleteOnClose, false); - subWin->setMinimumWidth(300); - subWin->setMinimumHeight(300); - subWin->setMaximumWidth(500); - subWin->setMaximumHeight(700); + setMinimumSize(300, 300); + setMaximumSize(500, 700); subWin->hide(); // No maximize button diff --git a/src/gui/MidiCCRackView.cpp b/src/gui/MidiCCRackView.cpp index a0b1496fb54..cef8898e760 100644 --- a/src/gui/MidiCCRackView.cpp +++ b/src/gui/MidiCCRackView.cpp @@ -49,7 +49,7 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : setWindowIcon(embed::getIconPixmap("midi_cc_rack")); setWindowTitle(tr("MIDI CC Rack - %1").arg(m_track->name())); - QMdiSubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget(this); + SubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget(this); // Remove maximize button Qt::WindowFlags flags = subWin->windowFlags(); @@ -58,9 +58,8 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : // Adjust window attributes, sizing and position subWin->setAttribute(Qt::WA_DeleteOnClose, false); - subWin->resize(350, 300); - subWin->setFixedWidth(350); - subWin->setMinimumHeight(300); + setFixedWidth(350); + setMinimumHeight(300); subWin->hide(); // Main window layout diff --git a/src/gui/MixerView.cpp b/src/gui/MixerView.cpp index e34e4ecbb97..0c3808f6a09 100644 --- a/src/gui/MixerView.cpp +++ b/src/gui/MixerView.cpp @@ -169,17 +169,11 @@ MixerView::MixerView(Mixer* mixer) : // adjust window size layout()->invalidate(); resize(sizeHint()); - if (parentWidget()) - { - parentWidget()->resize(parentWidget()->sizeHint()); - } setFixedHeight(height()); + layout()->setSizeConstraint(QLayout::SetMinimumSize); // add ourself to workspace QMdiSubWindow* subWin = mainWindow->addWindowedWidget(this); - layout()->setSizeConstraint(QLayout::SetMinimumSize); - subWin->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); - subWin->setFixedHeight(subWin->height()); parentWidget()->setAttribute(Qt::WA_DeleteOnClose, false); parentWidget()->move(5, 310); diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 533777d32ac..05d240aed63 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "embed.h" @@ -93,6 +94,8 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) : m_windowTitle->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_windowTitle->setGraphicsEffect( m_shadow ); + layout()->setSizeConstraint(QLayout::SetMinAndMaxSize); + // Disable the minimize button and make sure that the custom window hint is set setWindowFlags((this->windowFlags() & ~Qt::WindowMinimizeButtonHint) | Qt::CustomizeWindowHint); @@ -518,4 +521,5 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event) } } + } // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 7f598636534..f98a985d98c 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -283,7 +283,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : updateInstrumentView(); - QMdiSubWindow* subWin = getGUI()->mainWindow()->addWindowedWidget( this ); + SubWindow* subWin = getGUI()->mainWindow()->addWindowedWidget( this ); Qt::WindowFlags flags = subWin->windowFlags(); if (!m_instrumentView->isResizable()) { flags |= Qt::MSWindowsFixedSizeDialogHint; @@ -293,8 +293,8 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // Does the same thing, for detached detached windows, for other OSs. } else { - subWin->setMaximumSize(m_instrumentView->maximumWidth() + 12, m_instrumentView->maximumHeight() + 208); - subWin->setMinimumSize(m_instrumentView->minimumWidth() + 12, m_instrumentView->minimumHeight() + 208); + setMaximumSize(m_instrumentView->maximumWidth() + 12, m_instrumentView->maximumHeight() + 208); + setMinimumSize(m_instrumentView->minimumWidth() + 12, m_instrumentView->minimumHeight() + 208); } flags &= ~Qt::WindowMaximizeButtonHint; subWin->setWindowFlags( flags ); diff --git a/src/gui/widgets/TempoSyncBarModelEditor.cpp b/src/gui/widgets/TempoSyncBarModelEditor.cpp index 5ff2332e051..31644b72398 100644 --- a/src/gui/widgets/TempoSyncBarModelEditor.cpp +++ b/src/gui/widgets/TempoSyncBarModelEditor.cpp @@ -202,11 +202,11 @@ void TempoSyncBarModelEditor::showCustom() if(m_custom == nullptr) { m_custom = new MeterDialog(getGUI()->mainWindow()->workspace()); - QMdiSubWindow * subWindow = getGUI()->mainWindow()->addWindowedWidget(m_custom); + SubWindow * subWindow = getGUI()->mainWindow()->addWindowedWidget(m_custom); Qt::WindowFlags flags = subWindow->windowFlags(); flags &= ~Qt::WindowMaximizeButtonHint; subWindow->setWindowFlags(flags); - subWindow->setFixedSize(subWindow->size()); + setFixedSize(size()); m_custom->setWindowTitle("Meter"); m_custom->setModel(&model()->getCustomMeterModel()); } diff --git a/src/gui/widgets/TempoSyncKnob.cpp b/src/gui/widgets/TempoSyncKnob.cpp index 473cee28ca9..ced453d10bb 100644 --- a/src/gui/widgets/TempoSyncKnob.cpp +++ b/src/gui/widgets/TempoSyncKnob.cpp @@ -295,11 +295,11 @@ void TempoSyncKnob::showCustom() if( m_custom == nullptr ) { m_custom = new MeterDialog( getGUI()->mainWindow()->workspace() ); - QMdiSubWindow * subWindow = getGUI()->mainWindow()->addWindowedWidget( m_custom ); + SubWindow * subWindow = getGUI()->mainWindow()->addWindowedWidget(m_custom); Qt::WindowFlags flags = subWindow->windowFlags(); flags &= ~Qt::WindowMaximizeButtonHint; subWindow->setWindowFlags( flags ); - subWindow->setFixedSize( subWindow->size() ); + setFixedSize(size()); m_custom->setWindowTitle( "Meter" ); m_custom->setModel( &model()->m_custom ); } From 465b1e6d8a48eaf1ad41793e3f5592ec3b2e05f4 Mon Sep 17 00:00:00 2001 From: SpomJ Date: Sat, 23 Nov 2024 17:59:49 +0300 Subject: [PATCH 2/4] Transition VeSTige to patched SubWindow (fix missing minimize button and constraint issues) --- plugins/Vestige/Vestige.cpp | 9 +++------ plugins/Vestige/Vestige.h | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index 552f76406de..7c916f3a06b 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -937,12 +937,9 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume widget = new QWidget(this); l = new QGridLayout( this ); - m_vi->m_subWindow = getGUI()->mainWindow()->addWindowedWidget(nullptr, Qt::SubWindow | - Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); - m_vi->m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ); - m_vi->m_subWindow->setFixedWidth( 960 ); - m_vi->m_subWindow->setMinimumHeight( 300 ); - m_vi->m_subWindow->setWidget(m_vi->m_scrollArea); + m_vi->m_subWindow = getGUI()->mainWindow()->addWindowedWidget(m_vi->m_scrollArea); + m_vi->m_scrollArea->setFixedWidth(960); + m_vi->m_scrollArea->setMinimumHeight(300); m_vi->m_subWindow->setWindowTitle( m_vi->instrumentTrack()->name() + tr( " - VST plugin control" ) ); m_vi->m_subWindow->setWindowIcon( PLUGIN_NAME::getIconPixmap( "logo" ) ); diff --git a/plugins/Vestige/Vestige.h b/plugins/Vestige/Vestige.h index 6a308ad2c20..4dcc0b8e5d8 100644 --- a/plugins/Vestige/Vestige.h +++ b/plugins/Vestige/Vestige.h @@ -32,6 +32,7 @@ #include "Instrument.h" #include "InstrumentView.h" +#include "SubWindow.h" class QPixmap; @@ -87,7 +88,7 @@ protected slots: QMutex m_pluginMutex; QString m_pluginDLL; - QMdiSubWindow * m_subWindow; + gui::SubWindow* m_subWindow; QScrollArea * m_scrollArea; FloatModel ** knobFModel; QObject * p_subWindow; From 954c5e9952dce17e804e8b43581577ded3af08a0 Mon Sep 17 00:00:00 2001 From: SpomJ Date: Thu, 28 Nov 2024 18:43:06 +0300 Subject: [PATCH 3/4] Move window constraints to embed in LadspaBrowser (fix resizing) --- plugins/LadspaBrowser/LadspaBrowser.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/LadspaBrowser/LadspaBrowser.cpp b/plugins/LadspaBrowser/LadspaBrowser.cpp index e6a31e15a3c..6f2111234dc 100644 --- a/plugins/LadspaBrowser/LadspaBrowser.cpp +++ b/plugins/LadspaBrowser/LadspaBrowser.cpp @@ -140,18 +140,13 @@ LadspaBrowserView::LadspaBrowserView( ToolPlugin * _tool ) : hlayout->addWidget( ws ); hlayout->addSpacing( 10 ); hlayout->addStretch(); + + layout()->setSizeConstraint(QLayout::SetFixedSize); hide(); if( parentWidget() ) { parentWidget()->hide(); - parentWidget()->layout()->setSizeConstraint( - QLayout::SetFixedSize ); - - Qt::WindowFlags flags = parentWidget()->windowFlags(); - flags |= Qt::MSWindowsFixedSizeDialogHint; - flags &= ~Qt::WindowMaximizeButtonHint; - parentWidget()->setWindowFlags( flags ); } } From cb88b85ba793639906263fc817ac95e39be8d5c8 Mon Sep 17 00:00:00 2001 From: SpomJ Date: Thu, 28 Nov 2024 18:58:43 +0300 Subject: [PATCH 4/4] Fix detached window resizeability for TapTempo --- plugins/TapTempo/TapTempoView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TapTempo/TapTempoView.cpp b/plugins/TapTempo/TapTempoView.cpp index ed451eaa50e..9d6c58fa8c7 100644 --- a/plugins/TapTempo/TapTempoView.cpp +++ b/plugins/TapTempo/TapTempoView.cpp @@ -129,10 +129,10 @@ TapTempoView::TapTempoView(TapTempo* plugin) }); hide(); + layout()->setSizeConstraint(QLayout::SetFixedSize); if (parentWidget()) { parentWidget()->hide(); - parentWidget()->layout()->setSizeConstraint(QLayout::SetFixedSize); Qt::WindowFlags flags = parentWidget()->windowFlags(); flags |= Qt::MSWindowsFixedSizeDialogHint;