From 5aed06d139b702cf848c0799a4c316d7e7937901 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Thu, 3 Dec 2026 13:31:22 -0500 Subject: [PATCH 1/7] Show the cues of a video in a bottom section, as a list or a grid of pads A section under the input and output views, hidden at first, holds a tab of the cues of the video chosen in the Library or the Layers: the bar of their marks, then rows of the cues, a grid of eight pads, or both. A click on a pad jumps to its cue; a right click renames it, colours it, sets it or clears it. The cue the video last reached stands out, and a narrow section drops the time, then Set and Clear, before the number and the name. The cues leave the inspector; their paths do not change. The Window menu, two buttons beside the tabs and /mapmap/view/panels show the editor, the bottom section, or both; the choice and the heights are kept in the preferences. --- src/control/OscAction.cpp | 17 ++ src/control/OscAction.h | 7 + src/control/OscInterface.cpp | 3 + src/core/Source.cpp | 3 +- src/gui/BottomPanel.cpp | 117 ++++++++ src/gui/BottomPanel.h | 76 +++++ src/gui/CueBar.cpp | 25 +- src/gui/CueBar.h | 10 +- src/gui/CuePanel.cpp | 544 +++++++++++++++++++++++++++++++++++ src/gui/CuePanel.h | 184 ++++++++++++ src/gui/LayerGui.cpp | 2 - src/gui/MainWindow.cpp | 109 ++++++- src/gui/MainWindow.h | 30 ++ src/gui/PanelsShown.h | 63 ++++ src/gui/SourceGui.cpp | 2 - src/gui/gui.pri | 5 + tests/TestInspector.cpp | 43 --- tests/TestInspector.h | 1 - tests/TestMediaCues.cpp | 296 ++++++++++++++++++- tests/TestMediaCues.h | 9 + tests/TestOsc.cpp | 12 + tests/TestOsc.h | 1 + tests/tests.pro | 5 + 23 files changed, 1480 insertions(+), 84 deletions(-) create mode 100644 src/gui/BottomPanel.cpp create mode 100644 src/gui/BottomPanel.h create mode 100644 src/gui/CuePanel.cpp create mode 100644 src/gui/CuePanel.h create mode 100644 src/gui/PanelsShown.h diff --git a/src/control/OscAction.cpp b/src/control/OscAction.cpp index 0e3cf49c..f33ff40b 100644 --- a/src/control/OscAction.cpp +++ b/src/control/OscAction.cpp @@ -297,6 +297,20 @@ OscAction parseOutput(const QStringList& sub, const QVariantList& args) return invalid("unknown output command: " + sub.join('/')); } +// Parses /mapmap/view/panels: sub is what follows "view". +OscAction parseView(const QStringList& sub, const QVariantList& args) +{ + if (sub.size() != 1 || sub.first() != QLatin1String("panels")) + return invalid("unknown view command: " + sub.join('/')); + OscAction a; + if (args.isEmpty()) + return invalid("view panels needs editor, bottom or both"); + if (!panelsShownFromName(args.at(0).toString(), &a.panelsShown)) + return invalid("view panels needs editor, bottom or both, not: " + args.at(0).toString()); + a.type = OscAction::ViewSetPanels; + return a; +} + } // namespace OscAction parseOscAction(const QString& address, const QVariantList& args) @@ -343,6 +357,9 @@ OscAction parseOscAction(const QString& address, const QVariantList& args) if (head == QLatin1String("output")) return parseOutput(rest.mid(1), args); + if (head == QLatin1String("view")) + return parseView(rest.mid(1), args); + return invalid("unknown command: " + address); } diff --git a/src/control/OscAction.h b/src/control/OscAction.h index 406a20a3..256d5c5c 100644 --- a/src/control/OscAction.h +++ b/src/control/OscAction.h @@ -25,6 +25,7 @@ #include #include "OutputScreen.h" +#include "PanelsShown.h" namespace mmp { @@ -68,6 +69,9 @@ struct OscAction { OutputSetMode, ///< Hide the output, show it in a window, or cover a screen. OutputSetScreen, ///< Choose the output screen, by name or by number from 1 (selector). OutputSetWindow, ///< Place the ordinary output window. + + // The main window. + ViewSetPanels, ///< Show the editor, the bottom section, or both. }; /// Direction of a LayerFlip. @@ -113,6 +117,9 @@ struct OscAction { OutputMode outputMode = OutputMode::Hidden; QRect windowGeometry; ///< In the coordinates of the desktop. + // --- Payload for ViewSetPanels. --- + PanelsShown panelsShown = PanelsShown::Editor; + // Human-readable reason, set when type == Invalid (for verbose logging / tests). QString error; diff --git a/src/control/OscInterface.cpp b/src/control/OscInterface.cpp index 14bbd8f4..914baf1b 100644 --- a/src/control/OscInterface.cpp +++ b/src/control/OscInterface.cpp @@ -249,6 +249,9 @@ bool OscInterface::applyAction(MainWindow &main_window, const OscAction& action) case OscAction::OutputSetMode: main_window.setOutputMode(action.outputMode); return true; + case OscAction::ViewSetPanels: + main_window.setPanelsShown(action.panelsShown); + return true; case OscAction::OutputSetScreen: { const bool found = action.selectByName ? main_window.setOutputScreenByName(action.name) diff --git a/src/core/Source.cpp b/src/core/Source.cpp index e8af7a28..719497e2 100644 --- a/src/core/Source.cpp +++ b/src/core/Source.cpp @@ -550,7 +550,8 @@ void Video::_addPlaybackSettings() void Video::_addCueSettings() { SettingGroup* cues = settings()->addGroup(ProjectLabels::CUES); - cues->setPanelTitle(tr("Cues"), false); + // Shown in the bottom section of the window, not with the other settings of the video. + cues->setHiddenFromPanel(true); for (int number = 1; number <= MediaCues::CUE_COUNT; ++number) { SettingGroup* group = cues->addGroup(QString::number(number)); diff --git a/src/gui/BottomPanel.cpp b/src/gui/BottomPanel.cpp new file mode 100644 index 00000000..8dd8dfc2 --- /dev/null +++ b/src/gui/BottomPanel.cpp @@ -0,0 +1,117 @@ +/* + * BottomPanel.cpp + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "BottomPanel.h" + +#include +#include +#include +#include +#include + +namespace mmp { + +namespace { + +/// Margins around the tabs and the pages, in pixels. +const int PANEL_MARGIN = 4; + +/// Space between the tabs and the page, in pixels. +const int PANEL_SPACING = 2; + +/// Text of the button that hides the editor: an arrow up, the section grows to the top. +const QString HIDE_EDITOR_TEXT = QStringLiteral("⤒"); // ⤒ + +/// Text of the button that shows the editor again: an arrow down. +const QString SHOW_EDITOR_TEXT = QStringLiteral("⤓"); // ⤓ + +/// Text of the button that hides the section: a cross. +const QString HIDE_SECTION_TEXT = QStringLiteral("✕"); // ✕ + +} // namespace + +BottomPanel::BottomPanel(QWidget* parent) + : QWidget(parent), + _tabs(new QTabBar(this)), + _pages(new QStackedWidget(this)), + _editorButton(new QToolButton(this)), + _hideButton(new QToolButton(this)) +{ + setObjectName(QStringLiteral("bottomPanel")); + + _tabs->setExpanding(false); + _tabs->setDrawBase(false); + connect(_tabs, &QTabBar::currentChanged, _pages, &QStackedWidget::setCurrentIndex); + + _editorButton->setAutoRaise(true); + _editorButton->setCheckable(true); + connect(_editorButton, &QToolButton::toggled, this, [this](bool hidden) { + setEditorShown(!hidden); + emit editorHiddenRequested(hidden); + }); + setEditorShown(true); + + _hideButton->setAutoRaise(true); + _hideButton->setText(HIDE_SECTION_TEXT); + _hideButton->setToolTip(tr("Hide this section")); + _hideButton->setAccessibleName(tr("Hide this section")); + connect(_hideButton, &QToolButton::clicked, this, &BottomPanel::hideRequested); + + QHBoxLayout* header = new QHBoxLayout; + header->setContentsMargins(0, 0, 0, 0); + header->addWidget(_tabs); + header->addStretch(1); + header->addWidget(_editorButton); + header->addWidget(_hideButton); + + QVBoxLayout* layout = new QVBoxLayout(this); + layout->setContentsMargins(PANEL_MARGIN, PANEL_MARGIN, PANEL_MARGIN, PANEL_MARGIN); + layout->setSpacing(PANEL_SPACING); + layout->addLayout(header); + layout->addWidget(_pages, 1); +} + +int BottomPanel::addPage(const QString& title, QWidget* page) +{ + _pages->addWidget(page); + return _tabs->addTab(title); +} + +int BottomPanel::count() const +{ + return _tabs->count(); +} + +QWidget* BottomPanel::currentPage() const +{ + return _pages->currentWidget(); +} + +void BottomPanel::setEditorShown(bool shown) +{ + const QString text = shown ? tr("Hide the editor above") : tr("Show the editor above"); + _editorButton->blockSignals(true); + _editorButton->setChecked(!shown); + _editorButton->blockSignals(false); + _editorButton->setText(shown ? HIDE_EDITOR_TEXT : SHOW_EDITOR_TEXT); + _editorButton->setToolTip(text); + _editorButton->setAccessibleName(text); +} + +} // namespace mmp diff --git a/src/gui/BottomPanel.h b/src/gui/BottomPanel.h new file mode 100644 index 00000000..5ad11cc0 --- /dev/null +++ b/src/gui/BottomPanel.h @@ -0,0 +1,76 @@ +/* + * BottomPanel.h + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef BOTTOM_PANEL_H_ +#define BOTTOM_PANEL_H_ + +#include + +class QStackedWidget; +class QTabBar; +class QToolButton; + +namespace mmp { + +/** + * The section under the input and output views: a row of tabs, a page per tab, and, at the + * right of the tabs, a button that hides or shows the editor above and one that hides the + * section. The main window decides what these buttons do. + */ +class BottomPanel : public QWidget { + Q_OBJECT + +public: + explicit BottomPanel(QWidget* parent = nullptr); + + /// Adds a page under a tab; returns the index of the tab. + int addPage(const QString& title, QWidget* page); + + /// Returns the number of tabs. + int count() const; + + /// Returns the page shown. + QWidget* currentPage() const; + + /// Says whether the editor above is shown, which the first button shows. + void setEditorShown(bool shown); + + /// Returns the button that hides or shows the editor, for tests. + QToolButton* editorButton() const { return _editorButton; } + + /// Returns the button that hides the section, for tests. + QToolButton* hideButton() const { return _hideButton; } + +signals: + /// The user asked to hide the editor above (true) or to show it again (false). + void editorHiddenRequested(bool hidden); + + /// The user asked to hide the section. + void hideRequested(); + +private: + QTabBar* _tabs; + QStackedWidget* _pages; + QToolButton* _editorButton; + QToolButton* _hideButton; +}; + +} // namespace mmp + +#endif /* BOTTOM_PANEL_H_ */ diff --git a/src/gui/CueBar.cpp b/src/gui/CueBar.cpp index e4bd2546..7147c621 100644 --- a/src/gui/CueBar.cpp +++ b/src/gui/CueBar.cpp @@ -22,9 +22,7 @@ #include #include -#include "Inspector.h" #include "MediaCues.h" -#include "ProjectLabels.h" #include "Source.h" namespace mmp { @@ -63,8 +61,16 @@ CueBar::CueBar(Video* video, QWidget* parent) setToolTip(tr("Where the cues are, and where the video plays")); _timer->setInterval(REFRESH_INTERVAL_MS); connect(_timer, &QTimer::timeout, this, QOverload<>::of(&QWidget::update)); - if (video) - connect(video->cueStore(), &MediaCues::changed, this, QOverload<>::of(&QWidget::update)); + setVideo(video); +} + +void CueBar::setVideo(Video* video) +{ + disconnect(_cuesConnection); + _video = video; + if (video && video->cueStore()) + _cuesConnection = connect(video->cueStore(), &MediaCues::changed, this, QOverload<>::of(&QWidget::update)); + update(); } int CueBar::xOf(double seconds) const @@ -116,15 +122,4 @@ void CueBar::hideEvent(QHideEvent* event) QWidget::hideEvent(event); } -void showCueBar(InspectorPage* page, Source* source) -{ - Video* video = qobject_cast(source); - if (video && video->isCamera()) - video = nullptr; - QPointer