Skip to content

Commit

Permalink
Improve the way size constraints are placed
Browse files Browse the repository at this point in the history
  • Loading branch information
SpomJ committed Nov 23, 2024
1 parent 82a94cb commit e3501e7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 30 deletions.
7 changes: 1 addition & 6 deletions src/gui/ControllerRackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 3 additions & 6 deletions src/gui/MicrotunerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/gui/MidiCCRackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/gui/SubWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <QPushButton>
#include <QWindow>
#include <QStyleOption>
#include <QLayout>

#include "embed.h"

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -518,4 +521,5 @@ bool SubWindow::eventFilter(QObject* obj, QEvent* event)
}
}


} // namespace lmms::gui
6 changes: 3 additions & 3 deletions src/gui/instrument/InstrumentTrackWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/TempoSyncBarModelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/widgets/TempoSyncKnob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down

0 comments on commit e3501e7

Please sign in to comment.