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/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<TColumnSelection *>(
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;

View file

@ -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<TXshZeraryFxColumn *>(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<TXshZeraryFxColumn *>(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;

View file

@ -358,6 +358,8 @@ public:
QPixmap getColumnIcon(int columnIndex);
int getClickedColumn() { return m_col; }
class Pixmaps {
public:
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 {
return TApp::instance()->getCurrentFrame()->getFrame();
}

View file

@ -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;