Skip to content

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

C

Show disabled tool preference

manongjohn2cd8cdf1abef
diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h
index 2dc09f055..3766f0e2d 100644
--- a/toonz/sources/include/toonz/preferences.h
+++ b/toonz/sources/include/toonz/preferences.h
@@ -401,6 +401,9 @@ public:
void enableCursorOutline(bool on);
bool isCursorOutlineEnabled() const { return m_cursorOutlineEnabled; }
+ void enableShowDisabledTools(bool on);
+ bool isShowDisabledToolsEnabled() const { return m_showDisabledTools; }
+
// Xsheet tab
void setXsheetStep(int step); //!< Sets the step used for the <I>next/prev
//! step</I> commands.
@@ -724,6 +727,8 @@ private:
bool m_enableWinInk = false;
bool m_useOnionColorsForShiftAndTraceGhosts = false;
+ bool m_showDisabledTools = true;
+
private:
Preferences();
~Preferences();
diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp
index 73c23e4f2..bafaf43fe 100644
--- a/toonz/sources/toonz/preferencespopup.cpp
+++ b/toonz/sources/toonz/preferencespopup.cpp
@@ -1252,6 +1252,13 @@ void PreferencesPopup::onRasterBackgroundColorChanged(const TPixel32 &color,
m_pref->setRasterBackgroundColor(color);
}
+//-----------------------------------------------------------------------------
+
+void PreferencesPopup::onShowDisabledToolsChanged(int index) {
+ m_pref->enableShowDisabledTools(index == Qt::Checked);
+ TApp::instance()->getCurrentLevel()->notifyLevelChange();
+}
+
//**********************************************************************************
// PrefencesPopup's constructor
//**********************************************************************************
@@ -1481,6 +1488,9 @@ PreferencesPopup::PreferencesPopup()
CheckBox *cursorOutlineCB =
new CheckBox(tr("Show Cursor Size Outlines"), this);
+ CheckBox *showDisabledToolsCB =
+ new CheckBox(tr("Show Disabled Tools In Toolbar"), this);
+
//--- Xsheet ------------------------------
categoryList->addItem(tr("Xsheet"));
@@ -1878,6 +1888,8 @@ PreferencesPopup::PreferencesPopup()
m_cursorBrushStyle->findData(m_pref->getCursorBrushStyle()));
cursorOutlineCB->setChecked(m_pref->isCursorOutlineEnabled());
+ showDisabledToolsCB->setChecked(m_pref->isShowDisabledToolsEnabled());
+
//--- Xsheet ------------------------------
xsheetAutopanDuringPlaybackCB->setChecked(m_pref->isXsheetAutopanEnabled());
m_cellsDragBehaviour->addItem(tr("Cells Only"));
@@ -2460,6 +2472,8 @@ PreferencesPopup::PreferencesPopup()
cursorStyleGroupBox->setLayout(cursorStylesLay);
}
ToolsTopLay->addWidget(cursorStyleGroupBox, 3, 0, 1, 3);
+
+ ToolsTopLay->addWidget(showDisabledToolsCB, 4, 0, 1, 3);
}
toolsFrameLay->addLayout(ToolsTopLay, 0);
@@ -2949,6 +2963,8 @@ PreferencesPopup::PreferencesPopup()
this, SLOT(onCursorBrushStyleChanged(int)));
ret = ret && connect(cursorOutlineCB, SIGNAL(stateChanged(int)), this,
SLOT(onCursorOutlineChanged(int)));
+ ret = ret && connect(showDisabledToolsCB, SIGNAL(stateChanged(int)),
+ SLOT(onShowDisabledToolsChanged(int)));
//--- Xsheet ----------------------
ret = ret && connect(xsheetAutopanDuringPlaybackCB, SIGNAL(stateChanged(int)),
diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h
index 02e1d6139..2fac241d6 100644
--- a/toonz/sources/toonz/preferencespopup.h
+++ b/toonz/sources/toonz/preferencespopup.h
@@ -83,7 +83,8 @@ private:
*m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB,
*m_syncLevelRenumberWithXsheet, *m_downArrowInLevelStripCreatesNewFrame,
*m_enableAutoStretch, *m_enableWinInk,
- *m_useOnionColorsForShiftAndTraceCB;
+ *m_useOnionColorsForShiftAndTraceCB,
+ *m_showDisabledTools;
DVGui::FileField *m_customProjectRootFileField;
@@ -221,6 +222,7 @@ private slots:
void onCurrentColumnDataChanged(const TPixel32 &, bool isDragging);
void onEnableWinInkChanged(int index);
void onRasterBackgroundColorChanged(const TPixel32 &, bool isDragging);
+ void onShowDisabledToolsChanged(int);
};
//**********************************************************************************
diff --git a/toonz/sources/toonz/toolbar.cpp b/toonz/sources/toonz/toolbar.cpp
index dd54cd40d..da289825b 100755
--- a/toonz/sources/toonz/toolbar.cpp
+++ b/toonz/sources/toonz/toolbar.cpp
@@ -12,6 +12,7 @@
#include "toonz/txshleveltypes.h"
#include "toonz/txshlevelhandle.h"
+#include "toonz/preferences.h"
// TnzBase includes
#include "tenv.h"
@@ -106,112 +107,159 @@ void Toolbar::updateToolbar() {
TXshLevel *level = currlevel ? currlevel->getLevel() : 0;
int levelType = level ? level->getType() : NO_XSHLEVEL;
+ bool showDisabled = Preferences::instance()->isShowDisabledToolsEnabled();
+
std::map<std::string, QAction *>::iterator it;
for (it = m_toolbarList.begin(); it != m_toolbarList.end(); it++) {
QAction *action = it->second;
if (!action) continue;
+ action->setDisabled(true);
removeAction(action);
}
bool actionEnabled = false;
+ bool activate = false;
- if (levelType != SND_XSHLEVEL && levelType != SND_TXT_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Edit]) || actionEnabled;
+ activate = (levelType != SND_XSHLEVEL && levelType != SND_TXT_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Edit], showDisabled, activate) ||
+ actionEnabled;
- if (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
- levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Selection]) || actionEnabled;
+ activate = (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
+ levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Selection], showDisabled, activate) ||
+ actionEnabled;
- if (actionEnabled) addAction(m_toolbarList["Separator_1"]);
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_1"], true, true);
actionEnabled = false;
- if (levelType == NO_XSHLEVEL || levelType == OVL_XSHLEVEL ||
- levelType == TZI_XSHLEVEL || levelType == PLI_XSHLEVEL ||
- levelType == TZP_XSHLEVEL) {
- actionEnabled = addAction(m_toolbarList[T_Brush]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Geometric]) || actionEnabled;
- if (m_isExpanded)
- actionEnabled = addAction(m_toolbarList[T_Type]) || actionEnabled;
- }
+ activate = (levelType == NO_XSHLEVEL || levelType == OVL_XSHLEVEL ||
+ levelType == TZI_XSHLEVEL || levelType == PLI_XSHLEVEL ||
+ levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Brush], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Geometric], showDisabled, activate) ||
+ actionEnabled;
+ if (m_isExpanded)
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Type], showDisabled, activate) ||
+ actionEnabled;
- if (levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Fill]) || actionEnabled;
+ activate = (levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Fill], showDisabled, activate) ||
+ actionEnabled;
- if (levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_PaintBrush]) || actionEnabled;
+ activate = (levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_PaintBrush], showDisabled, activate) ||
+ actionEnabled;
- if (actionEnabled) addAction(m_toolbarList["Separator_2"]);
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_2"], true, true);
actionEnabled = false;
- if (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
- levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Eraser]) || actionEnabled;
+ activate = (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
+ levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Eraser], showDisabled, activate) ||
+ actionEnabled;
- if (levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Tape]) || actionEnabled;
+ activate = (levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Tape], showDisabled, activate) ||
+ actionEnabled;
- if (levelType == TZP_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Finger]) || actionEnabled;
+ activate = (levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Finger], showDisabled, activate) ||
+ actionEnabled;
- if (actionEnabled) addAction(m_toolbarList["Separator_3"]);
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_3"], true, true);
actionEnabled = false;
- if (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
- levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL) {
- actionEnabled = addAction(m_toolbarList[T_StylePicker]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_RGBPicker]) || actionEnabled;
- }
+ activate = (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
+ levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_StylePicker], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_RGBPicker], showDisabled, activate) ||
+ actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Ruler]) || actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Ruler], true, true) || actionEnabled;
- if (actionEnabled) addAction(m_toolbarList["Separator_4"]);
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_4"], true, true);
actionEnabled = false;
- if (levelType == PLI_XSHLEVEL) {
+ activate = (levelType == PLI_XSHLEVEL);
+ actionEnabled = addOrShowAction(m_toolbarList[T_ControlPointEditor],
+ showDisabled, activate) ||
+ actionEnabled;
+ if (m_isExpanded) {
actionEnabled =
- addAction(m_toolbarList[T_ControlPointEditor]) || actionEnabled;
- if (m_isExpanded) {
- actionEnabled = addAction(m_toolbarList[T_Pinch]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Pump]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Magnet]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Bender]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Iron]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Cutter]) || actionEnabled;
- }
+ addOrShowAction(m_toolbarList[T_Pinch], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Pump], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Magnet], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Bender], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Iron], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Cutter], showDisabled, activate) ||
+ actionEnabled;
}
- if (actionEnabled) addAction(m_toolbarList["Separator_5"]);
-
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_5"], true, true);
actionEnabled = false;
- if (m_isExpanded && levelType != NO_XSHLEVEL && levelType != MESH_XSHLEVEL &&
- levelType != SND_XSHLEVEL && levelType != SND_TXT_XSHLEVEL)
- actionEnabled = addAction(m_toolbarList[T_Skeleton]) || actionEnabled;
-
- if (m_isExpanded &&
- (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
- levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL)) {
- actionEnabled = addAction(m_toolbarList[T_Hook]) || actionEnabled;
- actionEnabled = addAction(m_toolbarList[T_Tracker]) || actionEnabled;
- }
-
- if (m_isExpanded &&
- (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
- levelType == CHILD_XSHLEVEL || levelType == PLI_XSHLEVEL ||
- levelType == TZP_XSHLEVEL || levelType == MESH_XSHLEVEL))
- actionEnabled = addAction(m_toolbarList[T_Plastic]) || actionEnabled;
-
- if (actionEnabled) addAction(m_toolbarList["Separator_6"]);
-
+ activate =
+ (m_isExpanded && levelType != NO_XSHLEVEL && levelType != MESH_XSHLEVEL &&
+ levelType != SND_XSHLEVEL && levelType != SND_TXT_XSHLEVEL);
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Skeleton], showDisabled, activate) ||
+ actionEnabled;
+
+ activate = (m_isExpanded &&
+ (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
+ levelType == PLI_XSHLEVEL || levelType == TZP_XSHLEVEL));
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Hook], showDisabled, activate) ||
+ actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Tracker], showDisabled, activate) ||
+ actionEnabled;
+
+ activate = (m_isExpanded &&
+ (levelType == OVL_XSHLEVEL || levelType == TZI_XSHLEVEL ||
+ levelType == CHILD_XSHLEVEL || levelType == PLI_XSHLEVEL ||
+ levelType == TZP_XSHLEVEL || levelType == MESH_XSHLEVEL));
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Plastic], showDisabled, activate) ||
+ actionEnabled;
+
+ if (actionEnabled) addOrShowAction(m_toolbarList["Separator_6"], true, true);
actionEnabled = false;
- actionEnabled = addAction(m_toolbarList[T_Zoom]) || actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Zoom], true, true) || actionEnabled;
if (m_isExpanded)
- actionEnabled = addAction(m_toolbarList[T_Rotate]) || actionEnabled;
-
- actionEnabled = addAction(m_toolbarList[T_Hand]) || actionEnabled;
-
- actionEnabled = addAction(m_toolbarList["Expander"]) || actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Rotate], true, true) || actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList[T_Hand], true, true) || actionEnabled;
+ actionEnabled =
+ addOrShowAction(m_toolbarList["Expander"], true, true) || actionEnabled;
if (m_isExpanded) {
m_expandButton->setArrowType(
@@ -240,10 +288,15 @@ Toolbar::~Toolbar() {}
//-----------------------------------------------------------------------------
-bool Toolbar::addAction(QAction *act) {
+bool Toolbar::addOrShowAction(QAction *act, bool showDisabled, bool activate) {
if (!act) return false;
- QToolBar::addAction(act);
- return true;
+ if (showDisabled || activate) QToolBar::addAction(act);
+
+ if (activate) act->setDisabled(false);
+
+ if (showDisabled || activate) return true;
+
+ return false;
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonz/toolbar.h b/toonz/sources/toonz/toolbar.h
index a6aaddb0d..1c7a62e91 100755
--- a/toonz/sources/toonz/toolbar.h
+++ b/toonz/sources/toonz/toolbar.h
@@ -19,7 +19,7 @@ public:
~Toolbar();
protected:
- bool addAction(QAction *act);
+ bool addOrShowAction(QAction *act, bool showDisabled, bool activate);
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;
diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp
index 79b498b32..cc7e47e3e 100644
--- a/toonz/sources/toonzlib/preferences.cpp
+++ b/toonz/sources/toonzlib/preferences.cpp
@@ -347,7 +347,8 @@ Preferences::Preferences()
, m_currentColumnColor(TPixel::Black)
, m_enableWinInk(false)
, m_useOnionColorsForShiftAndTraceGhosts(false)
- , m_rasterBackgroundColor(TPixel::White) {
+ , m_rasterBackgroundColor(TPixel::White)
+ , m_showDisabledTools(true) {
TCamera camera;
m_defLevelType = PLI_XSHLEVEL;
m_defLevelWidth = camera.getSize().lx;
@@ -726,6 +727,8 @@ Preferences::Preferences()
getValue(*m_settings, "rasterBackgroundColor", m_rasterBackgroundColor);
TImageWriter::setBackgroundColor(m_rasterBackgroundColor);
+
+ getValue(*m_settings, "showDisabledTools", m_showDisabledTools);
}
//-----------------------------------------------------------------
@@ -1772,4 +1775,9 @@ void Preferences::setRasterBackgroundColor(const TPixel32 &color) {
QString::number((int)color.b));
m_settings->setValue("rasterBackgroundColor_M",
QString::number((int)color.m));
+}
+
+void Preferences::enableShowDisabledTools(bool on) {
+ m_showDisabledTools = on;
+ m_settings->setValue("showDisabledTools", on ? "1" : "0");
}
\ No newline at end of file