Skip to content

Commit 02ea639

Browse files
committed
GUI - keep the metronome compact: size its dock to its controls rather than a fixed height
1 parent dc57920 commit 02ea639

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

‎app/gui/mainwindow.cpp‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,14 +1060,7 @@ void MainWindow::setupWindowStructure()
10601060
metroWidget->setFocusPolicy(Qt::NoFocus);
10611061
metroWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
10621062
metroWidget->setAllowedAreas(Qt::RightDockWidgetArea);
1063-
metroWidget->setMaximumHeight(ScaleHeightForDPI(110));
1064-
metroWidget->setWidget(metroPane);
1065-
// Let the dock grow when the streams panel expands, shrink on collapse.
1066-
connect(metroPane, &SonicPiMetro::linkAudioStreamsExpandedChanged, this,
1067-
[this](bool expanded) {
1068-
metroWidget->setMaximumHeight(
1069-
expanded ? QWIDGETSIZE_MAX : ScaleHeightForDPI(110));
1070-
});
1063+
metroWidget->setWidget(metroPane); // as tall as the pane needs (SonicPiMetro::fitHeightToContent)
10711064

10721065
addDockWidget(Qt::RightDockWidgetArea, outputWidget);
10731066
addDockWidget(Qt::RightDockWidgetArea, incomingWidget);

‎app/gui/widgets/sonicpimetro.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ SonicPiMetro::SonicPiMetro(std::shared_ptr<SonicPi::QtAPIClient> spClient, std::
251251
metro_layout->addStretch(1);
252252
metro_layout->addWidget(linkColumn, 0, Qt::AlignLeft);
253253
setLayout(metro_layout);
254+
fitHeightToContent(false);
254255

255256
// Restore visibility scope from QSettings (Local default). Link enable
256257
// is not persisted: joining a mesh is a per-session opt-in.
@@ -520,18 +521,28 @@ void SonicPiMetro::setFocusTimeWarpScrubber()
520521
timeWarpLineEdit->setVisible(true);
521522
}
522523

524+
// Compact unless the streams panel is open: no taller than the row of controls
525+
// needs, so the dock it sits in is as tall as its title and that row, whatever
526+
// the font and zoom, and no band of empty space opens above the controls. Open,
527+
// the panel may take what the dock can give it.
528+
void SonicPiMetro::fitHeightToContent(bool streamsOpen)
529+
{
530+
setSizePolicy(QSizePolicy::Preferred, streamsOpen ? QSizePolicy::Preferred : QSizePolicy::Maximum);
531+
updateGeometry();
532+
}
533+
523534
void SonicPiMetro::toggleLinkAudioStreams()
524535
{
525536
if (!linkStreamsWidget) return;
526537
const bool nowVisible = !linkStreamsWidget->isVisible();
527538
linkStreamsWidget->setVisible(nowVisible);
528539
linkStreamsButton->setChecked(nowVisible);
540+
fitHeightToContent(nowVisible);
529541
// ↓ when expanded, ↑ when collapsed.
530542
linkStreamsButton->setText(nowVisible
531543
? QString::fromUtf8("\xe2\x86\x93")
532544
: QString::fromUtf8("\xe2\x86\x91"));
533545
linkStreamsButton->setAccessibleName(nowVisible
534546
? tr("Hide Link Audio streams panel")
535547
: tr("Show Link Audio streams panel"));
536-
emit linkAudioStreamsExpandedChanged(nowVisible);
537548
}

‎app/gui/widgets/sonicpimetro.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ class SonicPiMetro : public QWidget
5858
// network visibility). MainWindow routes this to the status bar and the
5959
// screen reader via showStatusAndAnnounce().
6060
void statusMessage(const QString& message);
61-
// Emitted when the inline Link Audio Streams panel is shown/hidden.
62-
// MainWindow listens to resize the surrounding dock — the metro
63-
// dock is hard-capped to a small height when collapsed.
64-
void linkAudioStreamsExpandedChanged(bool expanded);
6561

6662
public slots:
6763
void tapTempo(int flashDelay=250);
@@ -74,6 +70,7 @@ public slots:
7470
void paintEvent(QPaintEvent *event);
7571

7672
private:
73+
void fitHeightToContent(bool streamsOpen);
7774
QPushButton *enableLinkButton = nullptr;
7875
QPushButton *linkStreamsButton;
7976
QPushButton *tapButton;

0 commit comments

Comments
 (0)