Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

specially handle hand tool

konero62364c41736c
diff --git a/toonz/sources/include/tools/toolhandle.h b/toonz/sources/include/tools/toolhandle.h
index 0fd1f71c3..a4b6aad4c 100644
--- a/toonz/sources/include/tools/toolhandle.h
+++ b/toonz/sources/include/tools/toolhandle.h
@@ -55,6 +55,9 @@ public:
void storeTool();
void restoreTool();
+ // TODO
+ bool isTemporaryTool() const { return !m_storedToolName.isEmpty(); }
+
// used to set a tool that is not listed in the toolbar (e.g. the
// ShiftTraceTool).
void setPseudoTool(QString name);
diff --git a/toonz/sources/tnztools/toolhandle.cpp b/toonz/sources/tnztools/toolhandle.cpp
index c3c126792..5e8bdf5eb 100644
--- a/toonz/sources/tnztools/toolhandle.cpp
+++ b/toonz/sources/tnztools/toolhandle.cpp
@@ -5,7 +5,7 @@
#include "tools/tool.h"
#include "tools/toolcommandids.h"
#include "timage.h"
-//#include "tapp.h"
+// #include "tapp.h"
#include "toonzqt/menubarcommand.h"
#include "toonz/preferences.h"
#include <QAction>
@@ -72,10 +72,17 @@ void ToolHandle::storeTool() {
void ToolHandle::restoreTool() {
// qDebug() << m_storedToolTime.elapsed();
- if (m_storedToolName != m_toolName && m_storedToolName != "" &&
- m_storedToolTime.elapsed() >
- Preferences::instance()->getTempToolSwitchTimer()) {
- setTool(m_storedToolName);
+ if (m_storedToolName != m_toolName && m_storedToolName != "") {
+ // Always restore previous tool when switching from Hand tool regardless of
+ // time
+ if (m_toolName == "T_Hand") {
+ setTool(m_storedToolName);
+ }
+ // For all other tools, use the timer check
+ else if (m_storedToolTime.elapsed() >
+ Preferences::instance()->getTempToolSwitchTimer()) {
+ setTool(m_storedToolName);
+ }
}
}
diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp
index f268b0244..e7d4b6580 100644
--- a/toonz/sources/tnztools/tooloptions.cpp
+++ b/toonz/sources/tnztools/tooloptions.cpp
@@ -2898,27 +2898,35 @@ void ToolOptions::onToolOptionsBoxChanged() {
//-----------------------------------------------------------------------------
void ToolOptions::onToolSwitched() {
+ TTool::Application *app = TTool::getApplication();
+ ToolHandle *currTool = app->getCurrentTool();
+ TTool *tool = currTool->getTool();
+
+ // Skip panel updates only when temporarily switching to Hand tool via
+ // spacebar
+ if (currTool->isTemporaryTool() && tool && tool->getName() == T_Hand) {
+ return;
+ }
+
+ // Hide current panel if it exists
if (m_panel) m_panel->hide();
m_panel = 0;
- TTool::Application *app = TTool::getApplication();
-
- // Quando i seguenti non serviranno piu', rimuovere gli header corrispondenti
- // in cima, thx
+ // Get current context handles
+ // TODO: When these are no longer needed, remove corresponding headers
TFrameHandle *currFrame = app->getCurrentFrame();
TObjectHandle *currObject = app->getCurrentObject();
TXsheetHandle *currXsheet = app->getCurrentXsheet();
TPaletteHandle *currPalette =
app->getPaletteController()->getCurrentLevelPalette();
- ToolHandle *currTool = app->getCurrentTool();
- TTool *tool = app->getCurrentTool()->getTool();
if (tool) {
- // c'e' un tool corrente
+ // Check if we have a current tool
ToolOptionsBox *panel = 0;
std::map<TTool *, ToolOptionsBox *>::iterator it = m_panels.find(tool);
+
if (it == m_panels.end()) {
- // ... senza panel associato
+ // Create new panel if one doesn't exist for this tool
if (tool->getName() == T_Edit) {
TPropertyGroup *pg = tool->getProperties(0);
panel = new ArrowToolOptionsBox(0, tool, pg, currFrame, currObject,
@@ -2961,29 +2969,19 @@ void ToolOptions::onToolSwitched() {
else if (tool->getName() == T_Hand)
panel = new HandToolOptionsBox(0, tool, currPalette, currTool);
else
- panel = tool->createOptionsBox(); // Only this line should remain out
- // of that if/else monstrosity
-
- /* DANIELE: Regola per il futuro - NON FARE PIU' COME SOPRA.
-Bisogna cominciare a collegare il metodo virtuale
-createOptionsBox() di ogni tool.
-
-Chi ha tempo si adoperi un pochino per normalizzare
-la situazione anche per i tool sopra, plz - basta spostare
-un po' di codice... */
+ panel = tool->createOptionsBox(); // Future: Use this virtual method
+ // for all tools
m_panels[tool] = panel;
layout()->addWidget(panel);
emit newPanelCreated();
} else {
- // il panel c'e' gia'.
+ // Use existing panel
panel = it->second;
panel->updateStatus();
}
m_panel = panel;
m_panel->show();
- } else {
- // niente tool
}
}