Merge pull request #758 from manongjohn/stop_column_button_switching

Stop switching columns on column button press
This commit is contained in:
manongjohn 2021-08-27 13:35:43 -04:00 committed by GitHub
commit fe48fb7d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 67 deletions

View file

@ -40,6 +40,8 @@
#include "toonz/preferences.h" #include "toonz/preferences.h"
#include "toonz/tstageobjectid.h" #include "toonz/tstageobjectid.h"
#include "../toonz/xsheetviewer.h"
// TnzBase includes // TnzBase includes
#include "tfx.h" #include "tfx.h"
#include "tfxattributes.h" #include "tfxattributes.h"
@ -1397,7 +1399,8 @@ public:
TColumnSelection *selection = dynamic_cast<TColumnSelection *>( TColumnSelection *selection = dynamic_cast<TColumnSelection *>(
TApp::instance()->getCurrentSelection()->getSelection()); TApp::instance()->getCurrentSelection()->getSelection());
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
int cc = TApp::instance()->getCurrentColumn()->getColumnIndex(); XsheetViewer *xviewer = TApp::instance()->getCurrentXsheetViewer();
int cc = xviewer->getClickedColumn();
bool sound_changed = false; bool sound_changed = false;
TTool *tool = TApp::instance()->getCurrentTool()->getTool(); TTool *tool = TApp::instance()->getCurrentTool()->getTool();
TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr; TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr;

View file

@ -2194,9 +2194,6 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
return; return;
} }
// set the clicked column to current
else
m_viewer->setCurrentColumn(m_col);
TXshColumn *column = xsh->getColumn(m_col); TXshColumn *column = xsh->getColumn(m_col);
bool isEmpty = !column || column->isEmpty(); bool isEmpty = !column || column->isEmpty();
@ -2212,17 +2209,22 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
// clicking on the camera column // clicking on the camera column
if (m_col < 0) { if (m_col < 0) {
if (o->rect(PredefinedRect::CAMERA_LOCK_AREA).contains(mouseInCell)) {
// lock button // lock button
if (o->rect(PredefinedRect::CAMERA_LOCK_AREA).contains(mouseInCell) && if (event->button() == Qt::LeftButton)
event->button() == Qt::LeftButton)
m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock;
else
return;
} else if (o->rect(PredefinedRect::CAMERA_CONFIG_AREA)
.contains(mouseInCell)) {
// config button // config button
else if (o->rect(PredefinedRect::CAMERA_CONFIG_AREA) if (event->button() == Qt::LeftButton)
.contains(mouseInCell) &&
event->button() == Qt::LeftButton)
m_doOnRelease = OpenSettings; m_doOnRelease = OpenSettings;
else
return;
} else {
// clicking another area means column selection // clicking another area means column selection
else { m_viewer->setCurrentColumn(m_col);
if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && if (m_viewer->getColumnSelection()->isColumnSelected(m_col) &&
event->button() == Qt::RightButton) event->button() == Qt::RightButton)
return; return;
@ -2239,15 +2241,15 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
&& (o->rect(PredefinedRect::LAYER_NUMBER).contains(mouseInCell) || && (o->rect(PredefinedRect::LAYER_NUMBER).contains(mouseInCell) ||
o->rect(PredefinedRect::LAYER_NAME).contains(mouseInCell)))) { o->rect(PredefinedRect::LAYER_NAME).contains(mouseInCell)))) {
setDragTool(XsheetGUI::DragTool::makeColumnMoveTool(m_viewer)); setDragTool(XsheetGUI::DragTool::makeColumnMoveTool(m_viewer));
} } else if (o->rect(PredefinedRect::LOCK_AREA).contains(mouseInCell)) {
// lock button // lock button
else if (o->rect(PredefinedRect::LOCK_AREA).contains(mouseInCell) && if (event->button() == Qt::LeftButton)
event->button() == Qt::LeftButton) {
m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock; m_doOnRelease = isCtrlPressed ? ToggleAllLock : ToggleLock;
} else
return;
} else if (o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell)) {
// preview button // preview button
else if (o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell) && if (event->button() == Qt::LeftButton) {
event->button() == Qt::LeftButton) {
if (column->getSoundTextColumn()) { if (column->getSoundTextColumn()) {
// do nothing // do nothing
} else { } else {
@ -2256,11 +2258,12 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
if (column->getSoundColumn()) if (column->getSoundColumn())
TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged(); TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged();
} }
} } else
return;
} else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA)
.contains(mouseInCell)) {
// camstand button // camstand button
else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA) if (event->button() == Qt::LeftButton) {
.contains(mouseInCell) &&
event->button() == Qt::LeftButton) {
if (column->getPaletteColumn() || column->getSoundTextColumn()) { if (column->getPaletteColumn() || column->getSoundTextColumn()) {
// do nothing // do nothing
} else { } else {
@ -2270,10 +2273,11 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
!column->getSoundColumn()) !column->getSoundColumn())
startTransparencyPopupTimer(event); startTransparencyPopupTimer(event);
} }
} } else
return;
} else if (o->rect(PredefinedRect::CONFIG_AREA).contains(mouseInCell)) {
// config button // config button
else if (o->rect(PredefinedRect::CONFIG_AREA).contains(mouseInCell) && if (event->button() == Qt::LeftButton) {
event->button() == Qt::LeftButton) {
TXshZeraryFxColumn *zColumn = TXshZeraryFxColumn *zColumn =
dynamic_cast<TXshZeraryFxColumn *>(column); dynamic_cast<TXshZeraryFxColumn *>(column);
@ -2282,9 +2286,10 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
// do nothing // do nothing
} else } else
m_doOnRelease = OpenSettings; m_doOnRelease = OpenSettings;
} } else
return;
} else if (column && column->getSoundColumn()) {
// sound column // sound column
else if (column && column->getSoundColumn()) {
if (o->rect(PredefinedRect::SOUND_ICON).contains(mouseInCell)) { if (o->rect(PredefinedRect::SOUND_ICON).contains(mouseInCell)) {
TXshSoundColumn *s = column->getSoundColumn(); TXshSoundColumn *s = column->getSoundColumn();
if (s) { if (s) {
@ -2314,9 +2319,9 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
setDragTool(XsheetGUI::DragTool::makeVolumeDragTool(m_viewer)); setDragTool(XsheetGUI::DragTool::makeVolumeDragTool(m_viewer));
else else
setDragTool(XsheetGUI::DragTool::makeColumnSelectionTool(m_viewer)); setDragTool(XsheetGUI::DragTool::makeColumnSelectionTool(m_viewer));
} } else {
// clicking another area means column selection // clicking another area means column selection
else { m_viewer->setCurrentColumn(m_col);
if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && if (m_viewer->getColumnSelection()->isColumnSelected(m_col) &&
event->button() == Qt::RightButton) event->button() == Qt::RightButton)
return; return;
@ -2378,6 +2383,7 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
TApp::instance()->getCurrentFx()->setFx(fx); TApp::instance()->getCurrentFx()->setFx(fx);
} }
} else { } else {
m_viewer->setCurrentColumn(m_col);
if (m_viewer->getColumnSelection()->isColumnSelected(m_col) && if (m_viewer->getColumnSelection()->isColumnSelected(m_col) &&
event->button() == Qt::RightButton) event->button() == Qt::RightButton)
return; return;
@ -2388,6 +2394,7 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
update(); update();
} else if (event->button() == Qt::MidButton) { } else if (event->button() == Qt::MidButton) {
m_viewer->setCurrentColumn(m_col);
m_pos = event->pos(); m_pos = event->pos();
m_isPanning = true; m_isPanning = true;
} }
@ -2678,7 +2685,6 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
bool isCamera = col < 0; bool isCamera = col < 0;
m_viewer->setCurrentColumn(col);
TXsheet *xsh = m_viewer->getXsheet(); TXsheet *xsh = m_viewer->getXsheet();
QPoint topLeft = m_viewer->positionToXY(CellPosition(0, col)); QPoint topLeft = m_viewer->positionToXY(CellPosition(0, col));
QPoint mouseInCell = event->pos() - topLeft; QPoint mouseInCell = event->pos() - topLeft;

View file

@ -358,6 +358,8 @@ public:
QPixmap getColumnIcon(int columnIndex); QPixmap getColumnIcon(int columnIndex);
int getClickedColumn() { return m_col; }
class Pixmaps { class Pixmaps {
public: public:
static const QPixmap &sound(); static const QPixmap &sound();

View file

@ -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 { int XsheetViewer::getCurrentRow() const {
return TApp::instance()->getCurrentFrame()->getFrame(); return TApp::instance()->getCurrentFrame()->getFrame();
} }

View file

@ -675,6 +675,7 @@ public:
TXsheet *getXsheet() const; TXsheet *getXsheet() const;
int getCurrentColumn() const; int getCurrentColumn() const;
int getClickedColumn() const;
int getCurrentRow() const; int getCurrentRow() const;
//! Restituisce la \b objectId corrispondente alla colonna \b col //! Restituisce la \b objectId corrispondente alla colonna \b col
TStageObjectId getObjectId(int col) const; TStageObjectId getObjectId(int col) const;