diff --git a/toonz/sources/toonz/columncommand.cpp b/toonz/sources/toonz/columncommand.cpp index 504fb98a..bdca0416 100644 --- a/toonz/sources/toonz/columncommand.cpp +++ b/toonz/sources/toonz/columncommand.cpp @@ -40,6 +40,8 @@ #include "toonz/preferences.h" #include "toonz/tstageobjectid.h" +#include "../toonz/xsheetviewer.h" + // TnzBase includes #include "tfx.h" #include "tfxattributes.h" @@ -1396,10 +1398,11 @@ public: void execute() override { TColumnSelection *selection = dynamic_cast( TApp::instance()->getCurrentSelection()->getSelection()); - TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); - int cc = TApp::instance()->getCurrentColumn()->getColumnIndex(); - bool sound_changed = false; - TTool *tool = TApp::instance()->getCurrentTool()->getTool(); + TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); + XsheetViewer *xviewer = TApp::instance()->getCurrentXsheetViewer(); + int cc = xviewer->getClickedColumn(); + bool sound_changed = false; + TTool *tool = TApp::instance()->getCurrentTool()->getTool(); TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr; bool viewer_changed = false; diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index f99e2769..8a56efe0 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -2194,9 +2194,6 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); return; } - // set the clicked column to current - else - m_viewer->setCurrentColumn(m_col); TXshColumn *column = xsh->getColumn(m_col); bool isEmpty = !column || column->isEmpty(); @@ -2212,17 +2209,22 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { // clicking on the camera column if (m_col < 0) { - // lock button - if (o->rect(PredefinedRect::CAMERA_LOCK_AREA).contains(mouseInCell) && - event->button() == Qt::LeftButton) - m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; - // config button - else if (o->rect(PredefinedRect::CAMERA_CONFIG_AREA) - .contains(mouseInCell) && - event->button() == Qt::LeftButton) - m_doOnRelease = OpenSettings; - // clicking another area means column selection - else { + if (o->rect(PredefinedRect::CAMERA_LOCK_AREA).contains(mouseInCell)) { + // lock button + if (event->button() == Qt::LeftButton) + m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; + else + return; + } else if (o->rect(PredefinedRect::CAMERA_CONFIG_AREA) + .contains(mouseInCell)) { + // config button + if (event->button() == Qt::LeftButton) + m_doOnRelease = OpenSettings; + else + return; + } else { + // clicking another area means column selection + m_viewer->setCurrentColumn(m_col); if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && event->button() == Qt::RightButton) return; @@ -2239,52 +2241,55 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { && (o->rect(PredefinedRect::LAYER_NUMBER).contains(mouseInCell) || o->rect(PredefinedRect::LAYER_NAME).contains(mouseInCell)))) { setDragTool(XsheetGUI::DragTool::makeColumnMoveTool(m_viewer)); - } - // lock button - else if (o->rect(PredefinedRect::LOCK_AREA).contains(mouseInCell) && - event->button() == Qt::LeftButton) { - m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; - } - // preview button - else if (o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell) && - event->button() == Qt::LeftButton) { - if (column->getSoundTextColumn()) { - // do nothing - } else { - m_doOnRelease = - isCtrlPressed ? ToggleAllPreviewVisible : TogglePreviewVisible; - if (column->getSoundColumn()) - TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged(); - } - } - // camstand button - else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA) - .contains(mouseInCell) && - event->button() == Qt::LeftButton) { - if (column->getPaletteColumn() || column->getSoundTextColumn()) { - // do nothing - } else { - m_doOnRelease = - isCtrlPressed ? ToggleAllTransparency : ToggleTransparency; - if (!o->flag(PredefinedFlag::CONFIG_AREA_VISIBLE) && - !column->getSoundColumn()) - startTransparencyPopupTimer(event); - } - } - // config button - else if (o->rect(PredefinedRect::CONFIG_AREA).contains(mouseInCell) && - event->button() == Qt::LeftButton) { - TXshZeraryFxColumn *zColumn = - dynamic_cast(column); - - if (column && (zColumn || column->getPaletteColumn() || - column->getSoundTextColumn())) { - // do nothing + } else if (o->rect(PredefinedRect::LOCK_AREA).contains(mouseInCell)) { + // lock button + if (event->button() == Qt::LeftButton) + m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; + else + return; + } else if (o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell)) { + // preview button + if (event->button() == Qt::LeftButton) { + if (column->getSoundTextColumn()) { + // do nothing + } else { + m_doOnRelease = + isCtrlPressed ? ToggleAllPreviewVisible : TogglePreviewVisible; + if (column->getSoundColumn()) + TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged(); + } } else - m_doOnRelease = OpenSettings; - } - // sound column - else if (column && column->getSoundColumn()) { + return; + } else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA) + .contains(mouseInCell)) { + // camstand button + if (event->button() == Qt::LeftButton) { + if (column->getPaletteColumn() || column->getSoundTextColumn()) { + // do nothing + } else { + m_doOnRelease = + isCtrlPressed ? ToggleAllTransparency : ToggleTransparency; + if (!o->flag(PredefinedFlag::CONFIG_AREA_VISIBLE) && + !column->getSoundColumn()) + startTransparencyPopupTimer(event); + } + } else + return; + } else if (o->rect(PredefinedRect::CONFIG_AREA).contains(mouseInCell)) { + // config button + if (event->button() == Qt::LeftButton) { + TXshZeraryFxColumn *zColumn = + dynamic_cast(column); + + if (column && (zColumn || column->getPaletteColumn() || + column->getSoundTextColumn())) { + // do nothing + } else + m_doOnRelease = OpenSettings; + } else + return; + } else if (column && column->getSoundColumn()) { + // sound column if (o->rect(PredefinedRect::SOUND_ICON).contains(mouseInCell)) { TXshSoundColumn *s = column->getSoundColumn(); if (s) { @@ -2314,9 +2319,9 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { setDragTool(XsheetGUI::DragTool::makeVolumeDragTool(m_viewer)); else setDragTool(XsheetGUI::DragTool::makeColumnSelectionTool(m_viewer)); - } - // clicking another area means column selection - else { + } else { + // clicking another area means column selection + m_viewer->setCurrentColumn(m_col); if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && event->button() == Qt::RightButton) return; @@ -2378,6 +2383,7 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { TApp::instance()->getCurrentFx()->setFx(fx); } } else { + m_viewer->setCurrentColumn(m_col); if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && event->button() == Qt::RightButton) return; @@ -2388,6 +2394,7 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { update(); } else if (event->button() == Qt::MidButton) { + m_viewer->setCurrentColumn(m_col); m_pos = event->pos(); m_isPanning = true; } @@ -2678,7 +2685,6 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) { bool isCamera = col < 0; - m_viewer->setCurrentColumn(col); TXsheet *xsh = m_viewer->getXsheet(); QPoint topLeft = m_viewer->positionToXY(CellPosition(0, col)); QPoint mouseInCell = event->pos() - topLeft; diff --git a/toonz/sources/toonz/xshcolumnviewer.h b/toonz/sources/toonz/xshcolumnviewer.h index ddc9e1e5..2f9b66f5 100644 --- a/toonz/sources/toonz/xshcolumnviewer.h +++ b/toonz/sources/toonz/xshcolumnviewer.h @@ -358,6 +358,8 @@ public: QPixmap getColumnIcon(int columnIndex); + int getClickedColumn() { return m_col; } + class Pixmaps { public: static const QPixmap &sound(); diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cpp index 5a9d8aa0..bc53054e 100644 --- a/toonz/sources/toonz/xsheetviewer.cpp +++ b/toonz/sources/toonz/xsheetviewer.cpp @@ -497,6 +497,14 @@ int XsheetViewer::getCurrentColumn() const { //----------------------------------------------------------------------------- +int XsheetViewer::getClickedColumn() const { + if (!m_columnArea) return -1; + + return m_columnArea->getClickedColumn(); +} + +//----------------------------------------------------------------------------- + int XsheetViewer::getCurrentRow() const { return TApp::instance()->getCurrentFrame()->getFrame(); } diff --git a/toonz/sources/toonz/xsheetviewer.h b/toonz/sources/toonz/xsheetviewer.h index d383717e..3f448dd1 100644 --- a/toonz/sources/toonz/xsheetviewer.h +++ b/toonz/sources/toonz/xsheetviewer.h @@ -675,6 +675,7 @@ public: TXsheet *getXsheet() const; int getCurrentColumn() const; + int getClickedColumn() const; int getCurrentRow() const; //! Restituisce la \b objectId corrispondente alla colonna \b col TStageObjectId getObjectId(int col) const;