OpenToonz - An open-source full-featured 2D animation creation software
C
feat(ui): implement Bind to Room system for standard and custom panels
Ahl7656f9b0582b34
diff --git a/toonz/sources/include/toonz/preferencesitemids.h b/toonz/sources/include/toonz/preferencesitemids.hindex f10ec4a7d..dfea7896f 100644--- a/toonz/sources/include/toonz/preferencesitemids.h+++ b/toonz/sources/include/toonz/preferencesitemids.h@@ -40,6 +40,7 @@ enum PreferencesItemId {colorCalibrationEnabled,colorCalibrationLutPaths,showIconsInMenu,+ showRoomBindButtons,displayIn30bit,viewerIndicatorEnabled,diff --git a/toonz/sources/toonz/audiorecordingpopup.cpp b/toonz/sources/toonz/audiorecordingpopup.cppindex 03c72db47..886428b3e 100644--- a/toonz/sources/toonz/audiorecordingpopup.cpp+++ b/toonz/sources/toonz/audiorecordingpopup.cpp@@ -3,6 +3,7 @@// Tnz6 includes#include "tapp.h"#include "menubarcommandids.h"+#include "mainwindow.h"// TnzQt includes#include "toonzqt/menubarcommand.h"@@ -50,6 +51,8 @@#include <QMultimedia>#include <QPainter>#include <QElapsedTimer>+#include <QMenu>+#include <QContextMenuEvent>#ifndef WAVE_FORMAT_PCM#define WAVE_FORMAT_PCM 1@@ -61,7 +64,9 @@//=============================================================================AudioRecordingPopup::AudioRecordingPopup()- : Dialog(TApp::instance()->getMainWindow(), false, true, "AudioRecording") {+ : Dialog(TApp::instance()->getMainWindow(), false, true, "AudioRecording")+ , m_isRoomBound(false)+ , m_boundRoomName("") {setWindowTitle(tr("Audio Recording"));m_isPlaying = false;@@ -277,6 +282,43 @@ AudioRecordingPopup::~AudioRecordingPopup() {}//-----------------------------------------------------------------------------+void AudioRecordingPopup::contextMenuEvent(QContextMenuEvent *event) {+ QMenu *menu = new QMenu(this);++ // Add "Bind to Current Room" option+ QAction *bindAction = menu->addAction(tr("Bind to Current Room"));+ bindAction->setCheckable(true);+ bindAction->setChecked(m_isRoomBound);++ connect(bindAction, &QAction::triggered, [this](bool checked) {+ MainWindow *mw = dynamic_cast<MainWindow *>(+ TApp::instance()->getMainWindow());+ if (!mw) return;++ Room *currentRoom = mw->getCurrentRoom();+ if (!currentRoom) return;++ // Update binding state+ setRoomBound(checked);+ if (checked) {+ // Bind to current room+ setBoundRoomName(currentRoom->getName());+ } else {+ // Unbind+ setBoundRoomName("");+ // Show if hidden+ if (isHidden()) {+ show();+ }+ }+ });++ menu->exec(event->globalPos());+ delete menu;+}++//-----------------------------------------------------------------------------+void AudioRecordingPopup::onRecordButtonPressed() {if (m_audioInput->state() == QAudio::StoppedState) {if (!m_console) {diff --git a/toonz/sources/toonz/audiorecordingpopup.h b/toonz/sources/toonz/audiorecordingpopup.hindex 6a07f66f8..82f79372c 100644--- a/toonz/sources/toonz/audiorecordingpopup.h+++ b/toonz/sources/toonz/audiorecordingpopup.h@@ -56,14 +56,25 @@ class AudioRecordingPopup : public DVGui::Dialog {QLabel *m_labelDevice, *m_labelSamplerate, *m_labelSamplefmt;QComboBox *m_comboSamplerate, *m_comboSamplefmt;bool m_blockAudioSettings;++ // Room binding members+ bool m_isRoomBound;+ QString m_boundRoomName;public:AudioRecordingPopup();~AudioRecordingPopup();++ // Room binding methods+ bool isRoomBound() const { return m_isRoomBound; }+ void setRoomBound(bool bound) { m_isRoomBound = bound; }+ QString getBoundRoomName() const { return m_boundRoomName; }+ void setBoundRoomName(const QString &roomName) { m_boundRoomName = roomName; }protected:- void showEvent(QShowEvent *event);- void hideEvent(QHideEvent *event);+ void contextMenuEvent(QContextMenuEvent *event) override;+ void showEvent(QShowEvent *event) override;+ void hideEvent(QHideEvent *event) override;void makePaths();void resetEverything();void enumerateAudioDevices(const QString &deviceName);diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex 2467024a3..69f803538 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -15,6 +15,8 @@#include "startuppopup.h"#include "tooloptionsshortcutinvoker.h"#include "custompanelmanager.h"+#include "audiorecordingpopup.h"+#include "pltgizmopopup.h"// TnzTools includes#include "tools/toolcommandids.h"@@ -301,6 +303,9 @@ void Room::save() {TPanel *pane = static_cast<TPanel *>(layout->itemAt(i)->widget());settings.setValue("name", pane->objectName());settings.setValue("geometry", geometries[i]); // Use passed geometry+ // Room binding state persistence (custom panel feature)+ settings.setValue("roomBound", pane->isRoomBound());+ settings.setValue("boundRoomName", pane->getBoundRoomName());if (SaveLoadQSettings *persistent =dynamic_cast<SaveLoadQSettings *>(pane->widget()))persistent->save(settings);@@ -382,6 +387,10 @@ void Room::load(const TFilePath &fp, RoomLoadParams ¶ms) {pane->setObjectName(paneObjectName);+ // Restore room binding state (custom panel feature)+ pane->setRoomBound(m_settings->value("roomBound", false).toBool());+ pane->setBoundRoomName(m_settings->value("boundRoomName", "").toString());+// Add panel to roomaddDockWidget(pane);@@ -646,6 +655,11 @@ void MainWindow::readSettings(const QString &argumentLayoutFileName) {params.activeRoomName = currentRoomName;params.forceBuildGui = !Preferences::instance()->isLazyLoadRoomsEnabled();+ // === CRITICAL FIX: Register dynamic commands BEFORE loading rooms ===+ // Custom Panels in rooms will try to link to these commands during load.+ // If commands don't exist yet, buttons become "empty shells".+ CustomPanelManager::instance()->loadCustomPanelEntries();+for (int i = 0; i < (int)roomPaths.size(); i++) {TFilePath roomPath = roomPaths[i];if (TFileStatus(roomPath).doesExist()) {@@ -729,7 +743,8 @@ void MainWindow::readSettings(const QString &argumentLayoutFileName) {}RecentFiles::instance()->loadRecentFiles();- CustomPanelManager::instance()->loadCustomPanelEntries();+ // Note: loadCustomPanelEntries() now called BEFORE loading rooms+ // to ensure dynamic commands exist when Custom Panels initialize}//-----------------------------------------------------------------------------@@ -1213,11 +1228,53 @@ void MainWindow::onCurrentRoomChanged(int newRoomIndex) {Room *oldRoom = getRoom(m_oldRoomIndex);Room *newRoom = getRoom(newRoomIndex);+ QString newRoomName = newRoom->getName();++ // Handle room-bound panels (all panels with binding enabled)+ // Use DockLayout directly instead of findChildren to avoid deep widget tree traversal+ // which can trigger expensive operations in complex panels like FileBrowser+ QList<TPanel *> panelsToUpdate;+ for (int i = 0; i < m_stackedWidget->count(); i++) {+ Room *room = getRoom(i);+ DockLayout *layout = room->dockLayout();+ if (!layout) continue;++ // Iterate only through docked panels (shallow traversal, not recursive)+ for (int j = 0; j < layout->count(); j++) {+ TPanel *panel = static_cast<TPanel *>(layout->itemAt(j)->widget());+ if (panel && panel->isRoomBound()) {+ panelsToUpdate.append(panel);+ }+ }+ }++ // Process room-bound panels (only visibility changes, no reparenting)+ for (TPanel *panel : panelsToUpdate) {+ QString boundRoomName = panel->getBoundRoomName();++ if (boundRoomName == newRoomName) {+ // Show panel when entering its bound room+ if (panel->isHidden()) {+ panel->show();+ panel->raise();+ }+ } else {+ // Hide panel when leaving its bound room+ if (!panel->isHidden()) {+ panel->hide();+ }+ }+ }+QList<TPanel *> paneList = oldRoom->findChildren<TPanel *>();- // Change the parent of all the floating dockWidgets+ // Change the parent of all the floating dockWidgets (non-room-bound)for (int i = 0; i < paneList.size(); i++) {TPanel *pane = paneList.at(i);+ // Skip room-bound panels (already handled above)+ if (pane->isRoomBound()) {+ continue;+ }if (pane->isFloating() && !pane->isHidden()) {// Close floating Locator panesif (pane->getPanelType() == "Locator") {@@ -1237,12 +1294,87 @@ void MainWindow::onCurrentRoomChanged(int newRoomIndex) {pane->show();}}++ // Handle room-bound persistent popups (DVGui::Dialog-based)+ // AudioRecordingPopup+ AudioRecordingPopup *audioPopup = findChild<AudioRecordingPopup *>();+ if (audioPopup && audioPopup->isRoomBound()) {+ QString boundRoomName = audioPopup->getBoundRoomName();+ if (boundRoomName == newRoomName) {+ if (!audioPopup->isVisible()) {+ audioPopup->show();+ }+ } else {+ if (audioPopup->isVisible()) {+ audioPopup->hide();+ }+ }+ }++ // PltGizmoPopup+ PltGizmoPopup *pltGizmoPopup = findChild<PltGizmoPopup *>();+ if (pltGizmoPopup && pltGizmoPopup->isRoomBound()) {+ QString boundRoomName = pltGizmoPopup->getBoundRoomName();+ if (boundRoomName == newRoomName) {+ if (!pltGizmoPopup->isVisible()) {+ pltGizmoPopup->show();+ }+ } else {+ if (pltGizmoPopup->isVisible()) {+ pltGizmoPopup->hide();+ }+ }+ }+m_oldRoomIndex = newRoomIndex;TSelection::setCurrent(0);}//-----------------------------------------------------------------------------+void MainWindow::updatePanelVisibility() {+ Room *currentRoom = getCurrentRoom();+ if (!currentRoom) return;++ QString currentRoomName = currentRoom->getName();++ // Use DockLayout directly to avoid expensive findChildren() traversal+ QList<TPanel *> panelsToUpdate;+ for (int i = 0; i < m_stackedWidget->count(); i++) {+ Room *room = getRoom(i);+ DockLayout *layout = room->dockLayout();+ if (!layout) continue;++ // Iterate only through docked panels (shallow, not recursive)+ for (int j = 0; j < layout->count(); j++) {+ TPanel *panel = static_cast<TPanel *>(layout->itemAt(j)->widget());+ if (panel && panel->isRoomBound()) {+ panelsToUpdate.append(panel);+ }+ }+ }++ // Update visibility of all room-bound panels+ for (TPanel *panel : panelsToUpdate) {+ QString boundRoomName = panel->getBoundRoomName();++ if (boundRoomName == currentRoomName) {+ // Show panel in its bound room+ if (panel->isHidden()) {+ panel->show();+ panel->raise();+ }+ } else {+ // Hide panel outside its bound room+ if (!panel->isHidden()) {+ panel->hide();+ }+ }+ }+}++//-----------------------------------------------------------------------------+void MainWindow::onIndexSwapped(int firstIndex, int secondIndex) {assert(firstIndex >= 0 && secondIndex >= 0);Room *mainWindow = getRoom(firstIndex);@@ -1293,7 +1425,35 @@ void MainWindow::deleteRoom(int index) {void MainWindow::renameRoom(int index, const QString name) {Room *room = getRoom(index);++ // Store the old name before renaming+ QString oldName = room->getName();++ // Rename the roomroom->setName(name);++ // Update all room-bound panels with the new room name+ // This ensures the panel-room link persists after renaming+ for (int i = 0; i < m_stackedWidget->count(); i++) {+ Room *currentRoom = getRoom(i);+ DockLayout *layout = currentRoom->dockLayout();+ if (!layout) continue;++ // Iterate through all docked panels+ for (int j = 0; j < layout->count(); j++) {+ TPanel *panel = static_cast<TPanel *>(layout->itemAt(j)->widget());+ if (panel &&+ panel->isRoomBound() &&+ panel->getBoundRoomName() == oldName) {+ // Update the bound room name to the new name+ panel->setBoundRoomName(name);+ }+ }+ }++ // Update visibility immediately to reflect the change+ updatePanelVisibility();+if (m_saveSettingsOnQuit) room->save();}diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.hindex a58033246..d51d47333 100644--- a/toonz/sources/toonz/mainwindow.h+++ b/toonz/sources/toonz/mainwindow.h@@ -126,6 +126,9 @@ public:QString getLayoutName() { return m_layoutName; }+ // Update visibility of all room-bound panels (native and custom)+ void updatePanelVisibility();+protected:void showEvent(QShowEvent *) override;void closeEvent(QCloseEvent *) override;diff --git a/toonz/sources/toonz/pane.cpp b/toonz/sources/toonz/pane.cppindex 15f1d61ef..e52130499 100644--- a/toonz/sources/toonz/pane.cpp+++ b/toonz/sources/toonz/pane.cpp@@ -27,6 +27,7 @@#include <QSettings>#include <QToolBar>#include <QMap>+#include <QMenu>#include <QApplication>#include <QFile>#include <qdrawutil.h>@@ -36,7 +37,6 @@#include <QLineEdit>#include <QTextEdit>#include <QScreen>-#include <QDebug>extern TEnv::StringVar EnvSafeAreaName;extern TEnv::IntVar EnvViewerPreviewBehavior;@@ -52,7 +52,10 @@ TPanel::TPanel(QWidget *parent, Qt::WindowFlags flags,, m_isMaximizable(true), m_isMaximized(false), m_panelTitleBar(0)- , m_multipleInstancesAllowed(true) {+ , m_multipleInstancesAllowed(true)+ , m_isRoomBound(false)+ , m_boundRoomName("")+ , m_roomBindButton(0) {// setFeatures(QDockWidget::DockWidgetMovable |// QDockWidget::DockWidgetFloatable);// setFloating(false);@@ -64,6 +67,11 @@ TPanel::TPanel(QWidget *parent, Qt::WindowFlags flags,connect(m_panelTitleBar, SIGNAL(closeButtonPressed()), this,SLOT(onCloseButtonPressed()));setOrientation(orientation);++ // Enable context menu for room binding+ setContextMenuPolicy(Qt::CustomContextMenu);+ connect(this, &QWidget::customContextMenuRequested,+ this, &TPanel::onCustomContextMenuRequested);}//-----------------------------------------------------------------------------@@ -116,6 +124,45 @@ void TPanel::onCloseButtonPressed() {if (parentLayout()) parentLayout()->removeWidget(this);}+//-----------------------------------------------------------------------------++void TPanel::onCustomContextMenuRequested(const QPoint &pos) {+ QMenu *menu = new QMenu(this);++ // Add "Bind to Current Room" option+ QAction *bindAction = menu->addAction(tr("Bind to Current Room"));+ bindAction->setCheckable(true);+ bindAction->setChecked(m_isRoomBound);++ connect(bindAction, &QAction::triggered, [this](bool checked) {+ MainWindow *mw = dynamic_cast<MainWindow *>(+ TApp::instance()->getMainWindow());+ if (!mw) return;++ Room *currentRoom = mw->getCurrentRoom();+ if (!currentRoom) return;++ // Update binding state+ setRoomBound(checked);+ if (checked) {+ // Bind panel to current room+ setBoundRoomName(currentRoom->getName());+ // Update visibility immediately for all bound panels+ mw->updatePanelVisibility();+ } else {+ // Unbind panel from room+ setBoundRoomName("");+ // Show panel if it was hidden+ if (isHidden()) {+ show();+ }+ }+ });++ menu->exec(mapToGlobal(pos));+ delete menu;+}+//-----------------------------------------------------------------------------/*! activate the panel and set focus specified widget when mouse enters*/@@ -233,6 +280,70 @@ void TPanel::zoomContentsAndFitGeometry(bool forward) {setGeometry(newGeom);}+//-----------------------------------------------------------------------------++void TPanel::setRoomBound(bool bound) {+ m_isRoomBound = bound;+ if (m_roomBindButton) {+ m_roomBindButton->setPressed(bound);+ }+}++//-----------------------------------------------------------------------------++void TPanel::setBoundRoomName(const QString &roomName) {+ m_boundRoomName = roomName;+}++//-----------------------------------------------------------------------------++void TPanel::addRoomBindButton() {+ // Prevent adding button twice+ if (m_roomBindButton) return;++ // Check preference to see if room bind buttons should be shown+ Preferences *prefs = Preferences::instance();+ if (!prefs->getBoolValue(showRoomBindButtons)) return;++ TPanelTitleBar *titleBar = getTitleBar();+ if (!titleBar) return;++ // Create toggle button with simple circle indicator+ m_roomBindButton = new TPanelTitleBarButtonForBindToRoom(titleBar);+ m_roomBindButton->setToolTip(QObject::tr("Bind to Current Room"));+ m_roomBindButton->setPressed(m_isRoomBound); // Restore state if loaded from file++ // Position: -60 pixels from right edge (before close button)+ titleBar->add(QPoint(-60, 0), m_roomBindButton);++ // Connect toggle signal to handle room binding state changes+ QObject::connect(m_roomBindButton, &TPanelTitleBarButton::toggled,+ [this](bool checked) {+ MainWindow *mw = dynamic_cast<MainWindow *>(+ TApp::instance()->getMainWindow());+ if (!mw) return;++ Room *currentRoom = mw->getCurrentRoom();+ if (!currentRoom) return;++ // Update binding state+ setRoomBound(checked);+ if (checked) {+ // Bind panel to current room+ setBoundRoomName(currentRoom->getName());+ // Update visibility immediately for all bound panels+ mw->updatePanelVisibility();+ } else {+ // Unbind panel from room+ setBoundRoomName("");+ // Show panel if it was hidden+ if (isHidden()) {+ show();+ }+ }+ });+}+//=============================================================================// TPanelTitleBarButton//-----------------------------------------------------------------------------@@ -417,6 +528,39 @@ void TPanelTitleBarButton::mousePressEvent(QMouseEvent *e) {}}+//=============================================================================+// TPanelTitleBarButtonForBindToRoom+//-----------------------------------------------------------------------------++void TPanelTitleBarButtonForBindToRoom::paintEvent(QPaintEvent *) {+ QPainter p(this);+ p.setRenderHint(QPainter::Antialiasing);++ // Get title bar to access theme colors+ TPanelTitleBar *titleBar = qobject_cast<TPanelTitleBar *>(parentWidget());++ // Determine circle color based on state+ QColor circleColor;+ if (m_pressed) {+ // When bound, use active title color+ circleColor = titleBar ? titleBar->getActiveTitleColor() : QColor(0, 150, 255);+ } else {+ // When not bound, use dimmed title color+ circleColor = titleBar ? titleBar->getTitleColor() : QColor(160, 160, 160);+ circleColor.setAlpha(m_rollover ? 200 : 120); // Fade when not hovering+ }++ // Draw small circle in the center of the button+ QRect rect = this->rect();+ int diameter = 8; // Small circle (8px diameter)+ int centerX = rect.center().x();+ int centerY = rect.center().y();++ p.setPen(Qt::NoPen);+ p.setBrush(circleColor);+ p.drawEllipse(QPoint(centerX, centerY), diameter/2, diameter/2);+}+//=============================================================================// TPanelTitleBarButtonForSafeArea//-----------------------------------------------------------------------------@@ -764,8 +908,11 @@ TPanel *TPanelFactory::createPanel(QWidget *parent, QString panelType) {parent);}+ // Fallback: create generic TPanel for unknown panel typesTPanel *panel = new TPanel(parent);panel->setPanelType(panelType.toStdString());+ // Enable room binding feature for generic panels+ panel->addRoomBindButton();return panel;} else {TPanelFactory *factory = it.value();@@ -782,6 +929,10 @@ TPanel *TPanelFactory::createPanel(QWidget *parent) {panel->setObjectName(getPanelType());panel->setWindowTitle(getPanelType());initialize(panel);++ // Enable room binding feature for all native panels+ panel->addRoomBindButton();+return panel;}diff --git a/toonz/sources/toonz/pane.h b/toonz/sources/toonz/pane.hindex 4dda80d1a..98422c868 100644--- a/toonz/sources/toonz/pane.h+++ b/toonz/sources/toonz/pane.h@@ -9,6 +9,7 @@#include "../toonzqt/tdockwindows.h"class TPanelTitleBarButtonSet;+class TPanelTitleBarButton;class Room;//! icon buttons placed on the panel titlebar (cfr. viewerpane.h)@@ -38,11 +39,11 @@ class TPanelTitleBarButton : public QWidget {Q_PROPERTY(QColor FreezeColor READ getFreezeColor WRITE setFreezeColor);Q_PROPERTY(QColor PreviewColor READ getPreviewColor WRITE setPreviewColor);- bool m_rollover;TPanelTitleBarButtonSet *m_buttonSet;int m_id;protected:+ bool m_rollover;bool m_pressed;public:@@ -85,6 +86,24 @@ signals:void toggled(bool pressed);};+//-----------------------------------------------------------------------------+/*! specialized button for Bind to Room feature with a simple circle indicator+ */++class TPanelTitleBarButtonForBindToRoom final : public TPanelTitleBarButton {+ Q_OBJECT+public:+ TPanelTitleBarButtonForBindToRoom(QWidget *parent)+ : TPanelTitleBarButton(parent, "") {+ // Set a small size similar to close button+ setFixedSize(20, 18);+ setMouseTracking(true);+ }++protected:+ void paintEvent(QPaintEvent *) override;+};+//-----------------------------------------------------------------------------/*! specialized button for safe area which enables to choose safe area size by* context menu@@ -220,6 +239,11 @@ class TPanel : public TDockWidget {QList<TPanel *> m_hiddenDockWidgets;QByteArray m_currentRoomOldState;+ // Room binding for custom panels+ bool m_isRoomBound;+ QString m_boundRoomName;+ TPanelTitleBarButton *m_roomBindButton;+public:TPanel(QWidget *parent = 0, Qt::WindowFlags flags = Qt::WindowFlags(),TDockWidget::Orientation orientation = TDockWidget::vertical);@@ -248,6 +272,19 @@ public:TPanelTitleBar *getTitleBar() const { return m_panelTitleBar; }+ // Room binding methods (for all panels)+ bool isRoomBound() const { return m_isRoomBound; }+ void setRoomBound(bool bound);+ QString getBoundRoomName() const { return m_boundRoomName; }+ void setBoundRoomName(const QString &roomName);+ void setRoomBindButton(TPanelTitleBarButton *button) {+ m_roomBindButton = button;+ }++ // Add room binding toggle button to the title bar+ // This enables the "Bind to Room" feature for any panel+ void addRoomBindButton();+virtual void reset() {};virtual int getViewType() { return -1; };@@ -274,6 +311,7 @@ protected:protected slots:void onCloseButtonPressed();+ void onCustomContextMenuRequested(const QPoint &pos);virtual void widgetFocusOnEnter() {// by default, focus the panel contentif (widget()) widget()->setFocus();diff --git a/toonz/sources/toonz/pltgizmopopup.cpp b/toonz/sources/toonz/pltgizmopopup.cppindex 313fac9ef..c975bbd56 100644--- a/toonz/sources/toonz/pltgizmopopup.cpp+++ b/toonz/sources/toonz/pltgizmopopup.cpp@@ -5,6 +5,7 @@// Tnz6 includes#include "menubarcommandids.h"#include "tapp.h"+#include "mainwindow.h"// TnzQt includes#include "toonzqt/menubarcommand.h"@@ -29,6 +30,8 @@#include <QMainWindow>#include <QGroupBox>#include <QMessageBox>+#include <QMenu>+#include <QContextMenuEvent>using namespace DVGui;@@ -587,7 +590,9 @@ void ColorFader::onClicked() {//-----------------------------------------------------------------------------PltGizmoPopup::PltGizmoPopup()- : Dialog(TApp::instance()->getMainWindow(), false, true, "PltGizmo") {+ : Dialog(TApp::instance()->getMainWindow(), false, true, "PltGizmo")+ , m_isRoomBound(false)+ , m_boundRoomName("") {setWindowTitle(tr("Palette Gizmo"));ValueAdjuster *luminanceValue = new ValueAdjuster(this);@@ -691,6 +696,43 @@ PltGizmoPopup::~PltGizmoPopup() {}//-----------------------------------------------------------------------------+void PltGizmoPopup::contextMenuEvent(QContextMenuEvent *event) {+ QMenu *menu = new QMenu(this);++ // Add "Bind to Current Room" option+ QAction *bindAction = menu->addAction(tr("Bind to Current Room"));+ bindAction->setCheckable(true);+ bindAction->setChecked(m_isRoomBound);++ connect(bindAction, &QAction::triggered, [this](bool checked) {+ MainWindow *mw = dynamic_cast<MainWindow *>(+ TApp::instance()->getMainWindow());+ if (!mw) return;++ Room *currentRoom = mw->getCurrentRoom();+ if (!currentRoom) return;++ // Update binding state+ setRoomBound(checked);+ if (checked) {+ // Bind to current room+ setBoundRoomName(currentRoom->getName());+ } else {+ // Unbind+ setBoundRoomName("");+ // Show if hidden+ if (isHidden()) {+ show();+ }+ }+ });++ menu->exec(event->globalPos());+ delete menu;+}++//-----------------------------------------------------------------------------+void PltGizmoPopup::adjustV(double p) {modifyColor(LuminanceModifier((int)(p)));}diff --git a/toonz/sources/toonz/pltgizmopopup.h b/toonz/sources/toonz/pltgizmopopup.hindex af6db441a..3ed9dd759 100644--- a/toonz/sources/toonz/pltgizmopopup.h+++ b/toonz/sources/toonz/pltgizmopopup.h@@ -82,11 +82,24 @@ class PltGizmoPopup final : public DVGui::Dialog {Q_OBJECTDVGui::ColorField *m_colorFld;++ // Room binding members+ bool m_isRoomBound;+ QString m_boundRoomName;public:PltGizmoPopup();~PltGizmoPopup();++ // Room binding methods+ bool isRoomBound() const { return m_isRoomBound; }+ void setRoomBound(bool bound) { m_isRoomBound = bound; }+ QString getBoundRoomName() const { return m_boundRoomName; }+ void setBoundRoomName(const QString &roomName) { m_boundRoomName = roomName; }++protected:+ void contextMenuEvent(QContextMenuEvent *event) override;public slots:diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex 4cd74ba34..eaccedad1 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -1239,6 +1239,7 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {.arg(LutManager::instance()->getMonitorName())},{displayIn30bit, tr("30bit Display*")},{showIconsInMenu, tr("Show Icons In Menu*")},+ {showRoomBindButtons, tr("Show Room Bind Buttons*")},{viewerIndicatorEnabled, tr("Show Viewer Indicators")},// Visualization@@ -1797,6 +1798,7 @@ QWidget* PreferencesPopup::createInterfacePage() {row = lay->rowCount();lay->addWidget(check30bitBtn, row - 1, 2, Qt::AlignRight);insertUI(showIconsInMenu, lay);+ insertUI(showRoomBindButtons, lay);lay->setRowStretch(lay->rowCount(), 1);insertFootNote(lay);diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex e0e42ed50..36cd61a2b 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -454,6 +454,7 @@ void Preferences::definePreferenceItems() {bool defIconsVisible = true;#endifdefine(showIconsInMenu, "showIconsInMenu", QMetaType::Bool, defIconsVisible);+ define(showRoomBindButtons, "showRoomBindButtons", QMetaType::Bool, true);setCallBack(pixelsOnly, &Preferences::setPixelsOnly);setCallBack(linearUnits, &Preferences::setUnits);