Skip to content

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

C

Tool properties panel tools integration (#6974)

Ahl76a010fd6952d9
diff --git a/toonz/sources/include/tools/toolcommandids.h b/toonz/sources/include/tools/toolcommandids.h
index ea4bf54d5..10bfc06d7 100644
--- a/toonz/sources/include/tools/toolcommandids.h
+++ b/toonz/sources/include/tools/toolcommandids.h
@@ -32,6 +32,7 @@
#define T_Finger "T_Finger"
#define T_EditAssistants "T_EditAssistants"
#define T_CanvasSize "T_CanvasSize"
+#define T_ShiftTrace "T_ShiftTrace"
// Viewer Navigation tools (available only during the shortcut key is pressed)
#define T_ZoomView "T_ZoomView"
diff --git a/toonz/sources/include/tools/tooloptions.h b/toonz/sources/include/tools/tooloptions.h
index 5cd613db1..8d7ab4b0f 100644
--- a/toonz/sources/include/tools/tooloptions.h
+++ b/toonz/sources/include/tools/tooloptions.h
@@ -98,7 +98,7 @@ public:
// ToolOptionsBox declaration
//***********************************************************************************************
-class ToolOptionsBox : public QFrame {
+class DVAPI ToolOptionsBox : public QFrame {
Q_OBJECT
protected:
@@ -477,7 +477,7 @@ class PaintbrushToolOptionsBox final : public ToolOptionsBox {
ToolOptionCombo *m_colorMode;
ToolOptionCheckbox *m_selectiveMode;
- ToolOptionCheckbox* m_emptyOnlyMode;
+ ToolOptionCheckbox *m_emptyOnlyMode;
ToolOptionCheckbox *m_lockAlphaMode;
ToolOptionCheckbox *m_FillingMode;
@@ -520,10 +520,10 @@ class FillToolOptionsBox final : public ToolOptionsBox {
QLabel *m_fillDepthLabel;
ToolOptionCombo *m_colorMode, *m_toolType;
ToolOptionCheckbox *m_emptyOnly, *m_segmentMode, *m_onionMode,
- *m_multiFrameMode, *m_autopaintMode,*m_referFill, * m_closeGap,
+ *m_multiFrameMode, *m_autopaintMode, *m_referFill, *m_closeGap,
*m_extendFill;
ToolOptionPairSlider *m_fillDepthField;
- ToolOptionIntSlider* m_gapCloseDistance;
+ ToolOptionIntSlider *m_gapCloseDistance;
public:
FillToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
@@ -638,7 +638,7 @@ protected slots:
//
//=============================================================================
-class RulerToolOptionsBox final : public ToolOptionsBox {
+class DVAPI RulerToolOptionsBox final : public ToolOptionsBox {
Q_OBJECT
MeasuredValueField *m_Xfld;
@@ -654,9 +654,11 @@ class RulerToolOptionsBox final : public ToolOptionsBox {
QLabel *m_HpixelFld;
TTool *m_tool;
+ bool m_verticalLayout;
public:
- RulerToolOptionsBox(QWidget *parent, TTool *tool);
+ RulerToolOptionsBox(QWidget *parent, TTool *tool,
+ bool verticalLayout = false);
void updateValues(bool isRasterLevelEditing, double X, double Y, double W,
double H, double A, double L, int Xpix = 0, int Ypix = 0,
diff --git a/toonz/sources/tnztools/plastictool.cpp b/toonz/sources/tnztools/plastictool.cpp
index 2be02e848..c6e75bce2 100644
--- a/toonz/sources/tnztools/plastictool.cpp
+++ b/toonz/sources/tnztools/plastictool.cpp
@@ -23,6 +23,7 @@
#include "toonz/doubleparamcmd.h"
#include "toonz/palettecontroller.h"
#include "toonz/txshsimplelevel.h"
+#include "tools/toolhandle.h"
// TnzExt includes
#include "ext/plasticskeleton.h"
@@ -413,7 +414,7 @@ PlasticToolOptionsBox::PlasticToolOptionsBox(QWidget *parent, TTool *tool,
// Add sub-options for each mode group
for (int m = 0; m != PlasticTool::MODES_COUNT; ++m)
m_subToolbars[m] =
- new GenericToolOptionsBox(0, tool, pltHandle, m, 0, false);
+ new GenericToolOptionsBox(0, tool, pltHandle, m, toolHandle, false);
meshifyButton->setFixedHeight(20);
int buttonWidth = fontMetrics().horizontalAdvance(meshifyButton->text()) + 20;
@@ -445,7 +446,7 @@ PlasticToolOptionsBox::PlasticToolOptionsBox(QWidget *parent, TTool *tool,
bool ret = true;
ret = ret && connect(meshifyButton, SIGNAL(clicked()), meshifyAction,
- SLOT(trigger()));
+ SLOT(trigger()));
assert(ret);
// Add Animation mode fields corresponding to vertex properties
@@ -642,8 +643,9 @@ PlasticTool::PlasticTool()
, m_showSkeletonOS(true)
, m_recompileOnMouseRelease(false) {
// And now, a little trick about tool binding
- bind(TTool::AllImages | TTool::EmptyTarget); // Attach the tool to all types :)
- bind(TTool::MeshLevels); // But disable it for all but meshes :0
+ bind(TTool::AllImages |
+ TTool::EmptyTarget); // Attach the tool to all types :)
+ bind(TTool::MeshLevels); // But disable it for all but meshes :0
// This little trick is needed to associate the tool to common levels (the
// toolbar must appear), in
@@ -697,6 +699,36 @@ PlasticTool::~PlasticTool() {
//------------------------------------------------------------------------
+int PlasticTool::currentSkeletonId() const {
+ return PlasticToolLocals::skeletonId();
+}
+
+//------------------------------------------------------------------------
+
+void PlasticTool::keyframePlasticRelays(
+ TDoubleParamRelayProperty *editedRelay) {
+ auto setKeyframe = [](TDoubleParamRelayProperty *prop) {
+ if (!prop) return;
+ TDoubleParam *p = prop->getParam().getPointer();
+ if (!p) return;
+ const double f = prop->frame();
+ if (!p->isKeyframe(f)) {
+ KeyframeSetter setter(p, -1, true);
+ setter.createKeyframe(f);
+ }
+ };
+
+ if (m_globalKey.getValue()) {
+ setKeyframe(&m_distanceRelay);
+ setKeyframe(&m_angleRelay);
+ setKeyframe(&m_soRelay);
+ } else {
+ setKeyframe(editedRelay);
+ }
+}
+
+//------------------------------------------------------------------------
+
TTool::ToolType PlasticTool::getToolType() const {
switch (m_mode.getIndex()) {
case MESH_IDX:
@@ -715,13 +747,18 @@ TTool::ToolType PlasticTool::getToolType() const {
//------------------------------------------------------------------------
void PlasticTool::updateTranslation() {
+ const int modeIndex = m_mode.getIndex();
+
m_mode.setQStringName(tr("Mode:"));
m_mode.deleteAllValues();
m_mode.addValue(tr("Edit Mesh").toStdWString());
m_mode.addValue(tr("Paint Rigid").toStdWString());
m_mode.addValue(tr("Build Skeleton").toStdWString());
m_mode.addValue(tr("Animate").toStdWString());
- m_mode.setIndex(BUILD_IDX);
+ if (modeIndex >= 0 && modeIndex < MODES_COUNT)
+ m_mode.setIndex(modeIndex);
+ else
+ m_mode.setIndex(BUILD_IDX);
m_vertexName.setQStringName(tr("Vertex Name:"));
m_interpolate.setQStringName(tr("Allow Stretching"));
@@ -1069,6 +1106,9 @@ void PlasticTool::onSelectionChanged() {
m_distanceRelay.notifyListeners();
m_angleRelay.notifyListeners();
m_soRelay.notifyListeners();
+
+ if (ToolHandle *th = TTool::getApplication()->getCurrentTool())
+ th->notifyToolChanged();
}
//------------------------------------------------------------------------
@@ -1606,12 +1646,16 @@ bool PlasticTool::onPropertyChanged(std::string propertyName) {
m_sd->skeleton(skelId)->vertex(m_svSel).m_interpolate =
m_interpolate.getValue();
- m_interpolate.notifyListeners(); // NOTE: This should NOT invoke this
- // function recursively
-
PlasticDeformerStorage::instance()->invalidateSkeleton(
m_sd.getPointer(), skelId, PlasticDeformerStorage::ALL);
}
+ m_interpolate.notifyListeners();
+ } else if (propertyName == "snapToMesh") {
+ m_snapToMesh.notifyListeners();
+ } else if (propertyName == "globalKeyframe") {
+ m_globalKey.notifyListeners();
+ } else if (propertyName == "keepDistance") {
+ m_keepDistance.notifyListeners();
} else if (propertyName == "minAngle") {
if (m_sd && m_svSel >= 0) {
// Set maxAngle property to the associated skeleton vertex
diff --git a/toonz/sources/tnztools/plastictool.h b/toonz/sources/tnztools/plastictool.h
index 51be286cc..0523f41c4 100644
--- a/toonz/sources/tnztools/plastictool.h
+++ b/toonz/sources/tnztools/plastictool.h
@@ -56,10 +56,10 @@
// PlasticTool declaration
//****************************************************************************************
-class PlasticTool final : public QObject,
- public TTool,
- public TParamObserver,
- public TSelection::View {
+class DVAPI PlasticTool final : public QObject,
+ public TTool,
+ public TParamObserver,
+ public TSelection::View {
Q_OBJECT
friend class PlasticToolOptionsBox;
@@ -190,6 +190,14 @@ public:
TPropertyGroup *getProperties(int idx) override { return &m_propGroup[idx]; }
+ int currentSkeletonId() const;
+
+ void keyframePlasticRelays(TDoubleParamRelayProperty *editedRelay);
+
+ TDoubleParamRelayProperty &distanceRelayProperty() { return m_distanceRelay; }
+ TDoubleParamRelayProperty &angleRelayProperty() { return m_angleRelay; }
+ TDoubleParamRelayProperty &soRelayProperty() { return m_soRelay; }
+
void updateTranslation() override;
void onSetViewer() override;
diff --git a/toonz/sources/tnztools/rulertool.cpp b/toonz/sources/tnztools/rulertool.cpp
index 98f1b426c..f1aa916c9 100644
--- a/toonz/sources/tnztools/rulertool.cpp
+++ b/toonz/sources/tnztools/rulertool.cpp
@@ -18,6 +18,8 @@
#include "tconst.h"
#include "toonz/tframehandle.h"
+#include <algorithm>
+
//----------------------------------------------------------------------------------------------
RulerTool::RulerTool()
@@ -36,6 +38,12 @@ void RulerTool::setToolOptionsBox(RulerToolOptionsBox *toolOptionsBox) {
m_toolOptionsBox.push_back(toolOptionsBox);
}
+void RulerTool::unsetToolOptionsBox(RulerToolOptionsBox *toolOptionsBox) {
+ m_toolOptionsBox.erase(std::remove(m_toolOptionsBox.begin(),
+ m_toolOptionsBox.end(), toolOptionsBox),
+ m_toolOptionsBox.end());
+}
+
//----------------------------------------------------------------------------------------------
void RulerTool::onImageChanged() {
@@ -209,15 +217,15 @@ void RulerTool::updateToolOption() {
if (ti) {
TDimension size = ti->getSize();
pix1 = TPoint(tround(0.5 * size.lx + p1.x),
- tround(0.5 * size.ly + p1.y));
- pix2 = TPoint(tround(0.5 * size.lx + p2.x),
- tround(0.5 * size.ly + p2.y));
+ tround(0.5 * size.ly + p1.y));
+ pix2 = TPoint(tround(0.5 * size.lx + p2.x),
+ tround(0.5 * size.ly + p2.y));
} else if (ri) {
TDimension size = ri->getRaster()->getSize();
pix1 = TPoint(tround(0.5 * size.lx + p1.x),
- tround(0.5 * size.ly + p1.y));
- pix2 = TPoint(tround(0.5 * size.lx + p2.x),
- tround(0.5 * size.ly + p2.y));
+ tround(0.5 * size.ly + p1.y));
+ pix2 = TPoint(tround(0.5 * size.lx + p2.x),
+ tround(0.5 * size.ly + p2.y));
}
int xPix, yPix, wPix, hPix;
TPointD dpi = sl->getDpi(getCurrentFid());
@@ -258,7 +266,7 @@ void RulerTool::updateToolOption() {
//----------------------------------------------------------------------------------------------
/*! 現在のマウス位置がRulerに十分近ければTrueを返す
-*/
+ */
bool RulerTool::isNearRuler() {
double a, b, c;
diff --git a/toonz/sources/tnztools/rulertool.h b/toonz/sources/tnztools/rulertool.h
index c28c9d4a6..dd36c24e9 100644
--- a/toonz/sources/tnztools/rulertool.h
+++ b/toonz/sources/tnztools/rulertool.h
@@ -11,7 +11,7 @@
//----------------------------------------------------------------------------------------------
-class RulerTool final : public TTool {
+class DVAPI RulerTool final : public TTool {
Q_DECLARE_TR_FUNCTIONS(RulerTool)
enum DragMode { MakeNewRuler = 0, MoveFirstPos, MoveSecondPos, MoveRuler };
@@ -29,6 +29,7 @@ public:
RulerTool();
void setToolOptionsBox(RulerToolOptionsBox *toolOptionsBox);
+ void unsetToolOptionsBox(RulerToolOptionsBox *toolOptionsBox);
ToolType getToolType() const override { return TTool::GenericTool; }
diff --git a/toonz/sources/tnztools/selectiontool.cpp b/toonz/sources/tnztools/selectiontool.cpp
index a0b706e59..6168da317 100644
--- a/toonz/sources/tnztools/selectiontool.cpp
+++ b/toonz/sources/tnztools/selectiontool.cpp
@@ -19,6 +19,32 @@ using namespace ToolUtils;
using namespace DragSelectionTool;
TEnv::StringVar SelectionType("SelectionType", "Rectangular");
+TEnv::IntVar SelectionScaleLink("SelectionScaleLink", 0);
+
+bool selectionScaleLinkIsEnabled() { return SelectionScaleLink != 0; }
+
+void setSelectionScaleLinkEnabled(bool linked) {
+ const int v = linked ? 1 : 0;
+ if ((int)SelectionScaleLink == v) return;
+ SelectionScaleLink = v;
+
+ TTool *tool = TTool::getApplication()
+ ? TTool::getApplication()->getCurrentTool()->getTool()
+ : nullptr;
+ if (SelectionTool *st = dynamic_cast<SelectionTool *>(tool))
+ emit st->scaleHVLinkChanged(linked);
+
+ if (TTool::getApplication())
+ TTool::getApplication()->getCurrentTool()->notifyToolChanged();
+}
+
+bool SelectionTool::isScaleHVLinked() const {
+ return selectionScaleLinkIsEnabled();
+}
+
+void SelectionTool::setScaleHVLinked(bool linked) {
+ setSelectionScaleLinkEnabled(linked);
+}
//-----------------------------------------------------------------------------
@@ -707,9 +733,9 @@ TPointD DragSelectionTool::Scale::getScaledPoint(int index,
TPointD v = normalize(center - pc);
double currentD = tdistance(sc, pc);
double startD = (index % 2 == 1)
- ? currentD / m_deformTool->getStartScaleValue().x
- : currentD / m_deformTool->getStartScaleValue().y;
- double factor = (index % 2 == 1) ? scaleValue.x : scaleValue.y;
+ ? currentD / m_deformTool->getStartScaleValue().x
+ : currentD / m_deformTool->getStartScaleValue().y;
+ double factor = (index % 2 == 1) ? scaleValue.x : scaleValue.y;
double d = (currentD - startD * factor) * tdistance(center, pc) / currentD;
return TPointD(pc.x + d * v.x, pc.y + d * v.y);
}
@@ -1218,7 +1244,6 @@ void SelectionTool::drawFreehandSelection() {
//-----------------------------------------------------------------------------
void SelectionTool::drawRectSelection(const TImage *image) {
-
TPixel color = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg
? TPixel32::White
: TPixel32::Black;
@@ -1227,8 +1252,7 @@ void SelectionTool::drawRectSelection(const TImage *image) {
unsigned short stipple = 0x3F33;
FourPoints selectingRect = m_selectingRect;
- if (vi && m_curPos.x >= m_firstPos.x)
- stipple = 0xFF00;
+ if (vi && m_curPos.x >= m_firstPos.x) stipple = 0xFF00;
drawFourPoints(selectingRect, color, stipple, true);
}
diff --git a/toonz/sources/tnztools/selectiontool.h b/toonz/sources/tnztools/selectiontool.h
index 66d458b53..43075168f 100644
--- a/toonz/sources/tnztools/selectiontool.h
+++ b/toonz/sources/tnztools/selectiontool.h
@@ -318,6 +318,9 @@ DragSelectionTool::DragTool *createNewFreeDeformTool(SelectionTool *st);
DragSelectionTool::DragTool *createNewScaleTool(
SelectionTool *st, DragSelectionTool::ScaleType type);
+bool DVAPI selectionScaleLinkIsEnabled();
+void DVAPI setSelectionScaleLinkEnabled(bool linked);
+
//=============================================================================
// SelectionTool
//-----------------------------------------------------------------------------
@@ -468,11 +471,15 @@ public:
virtual bool isSelectionEditable() { return true; }
+ bool isScaleHVLinked() const;
+public slots:
+ void setScaleHVLinked(bool linked);
signals:
void clickFlipHorizontal();
void clickFlipVertical();
void clickRotateLeft();
void clickRotateRight();
+ void scaleHVLinkChanged(bool linked);
};
#endif // SELECTIONTOOL_INCLUDED
diff --git a/toonz/sources/tnztools/shifttracetool.cpp b/toonz/sources/tnztools/shifttracetool.cpp
index e1a7fdcb4..6c2ccf13b 100644
--- a/toonz/sources/tnztools/shifttracetool.cpp
+++ b/toonz/sources/tnztools/shifttracetool.cpp
@@ -611,9 +611,14 @@ void ShiftTraceTool::onLeave() {
}
void ShiftTraceTool::setCurrentGhostIndex(int index) {
+ if (m_ghostIndex == index) return;
m_ghostIndex = index;
updateBox();
invalidate();
+ if (TTool::Application *app = getApplication()) {
+ if (ToolHandle *toolHandle = app->getCurrentTool())
+ toolHandle->notifyToolChanged();
+ }
}
ShiftTraceTool shiftTraceTool;
diff --git a/toonz/sources/tnztools/shifttracetool.h b/toonz/sources/tnztools/shifttracetool.h
index 3fd64120c..dcf0cdbaf 100644
--- a/toonz/sources/tnztools/shifttracetool.h
+++ b/toonz/sources/tnztools/shifttracetool.h
@@ -2,7 +2,7 @@
#include "tools/tool.h"
-class ShiftTraceTool final : public TTool {
+class DVAPI ShiftTraceTool final : public TTool {
public:
enum CurveStatus {
NoCurve,
diff --git a/toonz/sources/tnztools/toolhandle.cpp b/toonz/sources/tnztools/toolhandle.cpp
index 6ca2fcf9b..fcb4ee585 100644
--- a/toonz/sources/tnztools/toolhandle.cpp
+++ b/toonz/sources/tnztools/toolhandle.cpp
@@ -35,11 +35,17 @@ TTool *ToolHandle::getTool() const { return m_tool; }
//-----------------------------------------------------------------------------
void ToolHandle::setTool(QString name) {
+ const bool toolNameChanged = m_toolName != name;
m_oldToolName = m_toolName = name;
TTool *tool = TTool::getTool(m_toolName.toStdString(),
(TTool::ToolTargetType)m_toolTargetType);
- if (tool == m_tool) return;
+ if (tool == m_tool) {
+ // Different requested tools can share the same placeholder instance.
+ // Refresh the UI without reactivating an already active tool.
+ if (m_tool && toolNameChanged) emit toolSwitched();
+ return;
+ }
if (m_tool) m_tool->onDeactivate();
diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp
index c98ea3cec..4741b5dc4 100644
--- a/toonz/sources/tnztools/tooloptions.cpp
+++ b/toonz/sources/tnztools/tooloptions.cpp
@@ -55,6 +55,9 @@
#include <QToolBar>
#include <QDockWidget>
#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QLayoutItem>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
@@ -274,7 +277,8 @@ void ToolOptionControlBuilder::visit(TStringProperty *p) {
QLabel *label = addLabel(p);
m_panel->addLabel(p->getName(), label);
- ToolOptionTextField *control = new ToolOptionTextField(m_tool, p);
+ ToolOptionTextField *control =
+ new ToolOptionTextField(m_tool, p, m_toolHandle);
m_panel->addControl(control);
hLayout()->addWidget(control);
@@ -1136,6 +1140,7 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool,
m_scaleYLabel = new ClickableLabel(tr("V:"), this);
m_scaleYField = new SelectionScaleField(selectionTool, 1, "Scale Y");
m_scaleLink = new DVGui::CheckBox(tr("Link"), this);
+ m_scaleLink->setChecked(selectionTool->isScaleHVLinked());
SimpleIconViewField *rotIconView =
new SimpleIconViewField("edit_rotation", tr("Rotation"));
@@ -1309,6 +1314,16 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool,
connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft()));
connect(m_rightRotateButton, SIGNAL(clicked()), SLOT(onRotateRight()));
+ connect(m_scaleLink, &QCheckBox::toggled, selectionTool,
+ &SelectionTool::setScaleHVLinked);
+ connect(selectionTool, &SelectionTool::scaleHVLinkChanged, this,
+ [this](bool linked) {
+ if (!m_scaleLink || m_scaleLink->isChecked() == linked) return;
+ m_scaleLink->blockSignals(true);
+ m_scaleLink->setChecked(linked);
+ m_scaleLink->blockSignals(false);
+ });
+
connect(selectionTool, SIGNAL(clickFlipHorizontal()),
SLOT(onFlipHorizontal()));
connect(selectionTool, SIGNAL(clickFlipVertical()), SLOT(onFlipVertical()));
@@ -2304,10 +2319,19 @@ public:
}
};
-RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool)
- : ToolOptionsBox(parent), m_tool(tool) {
+RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool,
+ bool verticalLayout)
+ : ToolOptionsBox(parent, !verticalLayout)
+ , m_tool(tool)
+ , m_verticalLayout(verticalLayout) {
setFrameStyle(QFrame::StyledPanel);
- setFixedHeight(26);
+ if (verticalLayout) {
+ setMinimumHeight(0);
+ setMaximumHeight(QWIDGETSIZE_MAX);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ } else {
+ setFixedHeight(26);
+ }
m_Xfld = new MeasuredValueField(this);
m_Yfld = new MeasuredValueField(this);
@@ -2337,15 +2361,25 @@ RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool)
m_Hfld->setObjectName("RulerToolOptionValues");
m_Afld->setObjectName("RulerToolOptionValues");
m_Lfld->setObjectName("RulerToolOptionValues");
- setStyleSheet(
- "#RulerToolOptionValues {border:0px; background: rgb(196,196,196);}");
-
- m_Xfld->setMaximumWidth(70);
- m_Yfld->setMaximumWidth(70);
- m_Wfld->setMaximumWidth(70);
- m_Hfld->setMaximumWidth(70);
- m_Afld->setMaximumWidth(70);
- m_Lfld->setMaximumWidth(70);
+ if (!verticalLayout)
+ setStyleSheet(
+ "#RulerToolOptionValues {border:0px; background: rgb(196,196,196);}");
+
+ if (verticalLayout) {
+ m_Xfld->setMaximumWidth(QWIDGETSIZE_MAX);
+ m_Yfld->setMaximumWidth(QWIDGETSIZE_MAX);
+ m_Wfld->setMaximumWidth(QWIDGETSIZE_MAX);
+ m_Hfld->setMaximumWidth(QWIDGETSIZE_MAX);
+ m_Afld->setMaximumWidth(QWIDGETSIZE_MAX);
+ m_Lfld->setMaximumWidth(QWIDGETSIZE_MAX);
+ } else {
+ m_Xfld->setMaximumWidth(70);
+ m_Yfld->setMaximumWidth(70);
+ m_Wfld->setMaximumWidth(70);
+ m_Hfld->setMaximumWidth(70);
+ m_Afld->setMaximumWidth(70);
+ m_Lfld->setMaximumWidth(70);
+ }
m_Xfld->setReadOnly(true);
m_Yfld->setReadOnly(true);
@@ -2354,49 +2388,106 @@ RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool)
m_Afld->setReadOnly(true);
m_Lfld->setReadOnly(true);
- // layout
- QHBoxLayout *lay = new QHBoxLayout();
- lay->setContentsMargins(0, 0, 0, 0);
- lay->setSpacing(3);
- {
- lay->addWidget(new QLabel(tr("X:", "ruler tool option"), this), 0);
- lay->addWidget(m_Xfld, 0);
- lay->addWidget(m_XpixelFld, 0);
+ if (verticalLayout) {
+ const int labelW = 22;
+ const int fieldMinW = 52;
+ const int colGutter = 4;
+ const int labelGap = 2;
+ const int rowVSpace = 11;
+ QGridLayout *grid = new QGridLayout();
+ grid->setContentsMargins(0, 4, 0, 4);
+ grid->setHorizontalSpacing(labelGap);
+ grid->setVerticalSpacing(rowVSpace);
+ for (int col = 0; col < 5; ++col) grid->setColumnStretch(col, 0);
+ grid->setColumnStretch(1, 1);
+ grid->setColumnStretch(4, 1);
+ grid->setColumnMinimumWidth(0, labelW);
+ grid->setColumnMinimumWidth(1, fieldMinW);
+ grid->setColumnMinimumWidth(2, colGutter);
+ grid->setColumnMinimumWidth(3, labelW);
+ grid->setColumnMinimumWidth(4, fieldMinW);
+
+ auto addGridLabel = [&](int row, int col, const QString &text) {
+ auto *label = new QLabel(text, this);
+ label->setFixedSize(labelW, 20);
+ label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+ grid->addWidget(label, row, col, Qt::AlignRight | Qt::AlignVCenter);
+ };
+ auto addGridField = [&](int row, int col, MeasuredValueField *field) {
+ field->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ field->setMinimumWidth(fieldMinW);
+ field->setMaximumWidth(QWIDGETSIZE_MAX);
+ grid->addWidget(field, row, col);
+ };
+
+ addGridLabel(0, 0, tr("X:", "ruler tool option"));
+ addGridField(0, 1, m_Xfld);
+ addGridLabel(0, 3, tr("Y:", "ruler tool option"));
+ addGridField(0, 4, m_Yfld);
+ addGridLabel(1, 0, tr("W:", "ruler tool option"));
+ addGridField(1, 1, m_Wfld);
+ addGridLabel(1, 3, tr("H:", "ruler tool option"));
+ addGridField(1, 4, m_Hfld);
+ addGridLabel(2, 0, tr("A:", "ruler tool option"));
+ addGridField(2, 1, m_Afld);
+ addGridLabel(2, 3, tr("L:", "ruler tool option"));
+ addGridField(2, 4, m_Lfld);
+ m_XpixelFld->hide();
+ m_YpixelFld->hide();
+ m_WpixelFld->hide();
+ m_HpixelFld->hide();
+ m_layout->setContentsMargins(0, 0, 0, 0);
+ m_layout->setSpacing(0);
+ while (m_layout->count() > 0) {
+ QLayoutItem *item = m_layout->takeAt(0);
+ delete item;
+ }
+ m_layout->addLayout(grid, 1);
+ } else {
+ // Horizontal toolbar layout (original)
+ QHBoxLayout *lay = new QHBoxLayout();
+ lay->setContentsMargins(0, 0, 0, 0);
+ lay->setSpacing(3);
+ {
+ lay->addWidget(new QLabel(tr("X:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Xfld, 0);
+ lay->addWidget(m_XpixelFld, 0);
- lay->addSpacing(3);
+ lay->addSpacing(3);
- lay->addWidget(new QLabel(tr("Y:", "ruler tool option"), this), 0);
- lay->addWidget(m_Yfld, 0);
- lay->addWidget(m_YpixelFld, 0);
+ lay->addWidget(new QLabel(tr("Y:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Yfld, 0);
+ lay->addWidget(m_YpixelFld, 0);
- lay->addSpacing(3);
- lay->addWidget(new ToolOptionsBarSeparator(this), 0);
- lay->addSpacing(3);
+ lay->addSpacing(3);
+ lay->addWidget(new ToolOptionsBarSeparator(this), 0);
+ lay->addSpacing(3);
- lay->addWidget(new QLabel(tr("W:", "ruler tool option"), this), 0);
- lay->addWidget(m_Wfld, 0);
- lay->addWidget(m_WpixelFld, 0);
+ lay->addWidget(new QLabel(tr("W:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Wfld, 0);
+ lay->addWidget(m_WpixelFld, 0);
- lay->addSpacing(3);
+ lay->addSpacing(3);
- lay->addWidget(new QLabel(tr("H:", "ruler tool option"), this), 0);
- lay->addWidget(m_Hfld, 0);
- lay->addWidget(m_HpixelFld, 0);
+ lay->addWidget(new QLabel(tr("H:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Hfld, 0);
+ lay->addWidget(m_HpixelFld, 0);
- lay->addSpacing(3);
- lay->addWidget(new ToolOptionsBarSeparator(this), 0);
- lay->addSpacing(3);
+ lay->addSpacing(3);
+ lay->addWidget(new ToolOptionsBarSeparator(this), 0);
+ lay->addSpacing(3);
- lay->addWidget(new QLabel(tr("A:", "ruler tool option"), this), 0);
- lay->addWidget(m_Afld, 0);
+ lay->addWidget(new QLabel(tr("A:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Afld, 0);
- lay->addSpacing(3);
+ lay->addSpacing(3);
- lay->addWidget(new QLabel(tr("L:", "ruler tool option"), this), 0);
- lay->addWidget(m_Lfld, 0);
+ lay->addWidget(new QLabel(tr("L:", "ruler tool option"), this), 0);
+ lay->addWidget(m_Lfld, 0);
+ }
+ m_layout->addLayout(lay, 0);
+ m_layout->addStretch(1);
}
- m_layout->addLayout(lay, 0);
- m_layout->addStretch(1);
}
void RulerToolOptionsBox::updateValues(bool isRasterLevelEditing, double X,
@@ -2410,10 +2501,12 @@ void RulerToolOptionsBox::updateValues(bool isRasterLevelEditing, double X,
m_Afld->setValue(A);
m_Lfld->setValue(L);
- m_XpixelFld->setVisible(isRasterLevelEditing);
- m_YpixelFld->setVisible(isRasterLevelEditing);
- m_WpixelFld->setVisible(isRasterLevelEditing);
- m_HpixelFld->setVisible(isRasterLevelEditing);
+ if (!m_verticalLayout) {
+ m_XpixelFld->setVisible(isRasterLevelEditing);
+ m_YpixelFld->setVisible(isRasterLevelEditing);
+ m_WpixelFld->setVisible(isRasterLevelEditing);
+ m_HpixelFld->setVisible(isRasterLevelEditing);
+ }
if (isRasterLevelEditing) {
m_XpixelFld->setText(QString("(%1)").arg(Xpix));
diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp
index 3b6f21e2e..061ca8724 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.cpp
+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp
@@ -107,6 +107,12 @@ ToolOptionCheckbox::ToolOptionCheckbox(TTool *tool, TBoolProperty *property,
//-----------------------------------------------------------------------------
+ToolOptionCheckbox::~ToolOptionCheckbox() {
+ if (m_property) m_property->removeListener(this);
+}
+
+//-----------------------------------------------------------------------------
+
void ToolOptionCheckbox::updateStatus() {
bool check = m_property->getValue();
@@ -120,7 +126,9 @@ void ToolOptionCheckbox::updateStatus() {
void ToolOptionCheckbox::nextCheckState() {
QAbstractButton::nextCheckState();
m_property->setValue(checkState() == Qt::Checked);
+ m_property->notifyListeners();
notifyTool();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
//=============================================================================
@@ -170,7 +178,9 @@ void ToolOptionSlider::updateStatus() {
void ToolOptionSlider::onValueChanged(bool isDragging) {
m_property->setValue(getValue());
+ m_property->notifyListeners();
notifyTool(!isDragging);
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
//=============================================================================
@@ -224,8 +234,8 @@ void ToolOptionPairSlider::updateStatus() {
void ToolOptionPairSlider::onValuesChanged(bool isDragging) {
m_property->setValue(getValues());
+ m_property->notifyListeners();
notifyTool(!isDragging);
- // synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
@@ -263,8 +273,8 @@ void ToolOptionIntPairSlider::updateStatus() {
void ToolOptionIntPairSlider::onValuesChanged(bool isDragging) {
m_property->setValue(getValues());
+ m_property->notifyListeners();
notifyTool(!isDragging);
- // synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
@@ -309,7 +319,9 @@ void ToolOptionIntSlider::updateStatus() {
void ToolOptionIntSlider::onValueChanged(bool isDragging) {
m_property->setValue(getValue());
+ m_property->notifyListeners();
notifyTool(!isDragging);
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
//=============================================================================
@@ -332,6 +344,12 @@ ToolOptionCombo::ToolOptionCombo(TTool *tool, TEnumProperty *property,
//-----------------------------------------------------------------------------
+ToolOptionCombo::~ToolOptionCombo() {
+ if (m_property) m_property->removeListener(this);
+}
+
+//-----------------------------------------------------------------------------
+
void ToolOptionCombo::reloadComboBoxList(std::string id) {
if (id == "" || m_property->getName() != id) return;
loadEntries();
@@ -417,6 +435,12 @@ ToolOptionFontCombo::ToolOptionFontCombo(TTool *tool, TEnumProperty *property,
//-----------------------------------------------------------------------------
+ToolOptionFontCombo::~ToolOptionFontCombo() {
+ if (m_property) m_property->removeListener(this);
+}
+
+//-----------------------------------------------------------------------------
+
void ToolOptionFontCombo::updateStatus() {
QString value = QString::fromStdWString(m_property->getValue());
int index = findText(value);
@@ -483,14 +507,17 @@ void ToolOptionPopupButton::doSetCurrentIndex(int index) {
//=============================================================================
-ToolOptionTextField::ToolOptionTextField(TTool *tool, TStringProperty *property)
+ToolOptionTextField::ToolOptionTextField(TTool *tool, TStringProperty *property,
+ ToolHandle *toolHandle)
: LineEdit()
- , ToolOptionControl(tool, property->getName())
+ , ToolOptionControl(tool, property->getName(), toolHandle)
, m_property(property) {
setFixedSize(100, 23);
m_property->addListener(this);
updateStatus();
+ connect(this, SIGNAL(textChanged(const QString &)),
+ SLOT(onLiveTextChanged(const QString &)));
connect(this, SIGNAL(editingFinished()), SLOT(onValueChanged()));
}
@@ -500,15 +527,31 @@ void ToolOptionTextField::updateStatus() {
QString newText = QString::fromStdWString(m_property->getValue());
if (newText == text()) return;
+ blockSignals(true);
setText(newText);
+ blockSignals(false);
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolOptionTextField::onLiveTextChanged(const QString &) {
+ if (!hasFocus()) return;
+
+ const std::wstring w = text().toStdWString();
+ if (m_property->getValue() == w) return;
+
+ m_property->setValue(w);
+ m_property->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
//-----------------------------------------------------------------------------
void ToolOptionTextField::onValueChanged() {
- m_property->setValue(text().toStdWString());
+ const std::wstring w = text().toStdWString();
+ if (m_property->getValue() != w) m_property->setValue(w);
+ m_property->notifyListeners();
notifyTool();
- // synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
@@ -1157,6 +1200,10 @@ void NoScaleField::onChange(TMeasuredValue *fld, bool addToUndo) {
double v = fld->getValue(TMeasuredValue::MainUnit);
obj->setNoScaleZ(v);
m_tool->invalidate();
+ if (TApplication *app = TTool::getApplication()) {
+ if (TObjectHandle *objHandle = app->getCurrentObject())
+ objHandle->notifyObjectIdChanged(false);
+ }
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/tooloptionscontrols.h b/toonz/sources/tnztools/tooloptionscontrols.h
index 814fb3753..c6bbbcb03 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.h
+++ b/toonz/sources/tnztools/tooloptionscontrols.h
@@ -87,8 +87,8 @@ public:
// ToolOptionControl derivative declarations
//***********************************************************************************
-class ToolOptionCheckbox final : public DVGui::CheckBox,
- public ToolOptionControl {
+class DVAPI ToolOptionCheckbox final : public DVGui::CheckBox,
+ public ToolOptionControl {
Q_OBJECT
protected:
@@ -97,6 +97,7 @@ protected:
public:
ToolOptionCheckbox(TTool *tool, TBoolProperty *property,
ToolHandle *toolHandle = 0, QWidget *parent = 0);
+ ~ToolOptionCheckbox() override;
void updateStatus() override;
protected:
@@ -179,7 +180,7 @@ protected slots:
//-----------------------------------------------------------------------------
-class ToolOptionCombo final : public QComboBox, public ToolOptionControl {
+class DVAPI ToolOptionCombo final : public QComboBox, public ToolOptionControl {
Q_OBJECT
protected:
@@ -188,6 +189,7 @@ protected:
public:
ToolOptionCombo(TTool *tool, TEnumProperty *property,
ToolHandle *toolHandle = 0);
+ ~ToolOptionCombo();
void updateStatus() override;
TEnumProperty *getProperty() const { return m_property; }
@@ -200,8 +202,8 @@ public slots:
//-----------------------------------------------------------------------------
-class ToolOptionFontCombo final : public QFontComboBox,
- public ToolOptionControl {
+class DVAPI ToolOptionFontCombo final : public QFontComboBox,
+ public ToolOptionControl {
Q_OBJECT
protected:
@@ -210,6 +212,7 @@ protected:
public:
ToolOptionFontCombo(TTool *tool, TEnumProperty *property,
ToolHandle *toolHandle = 0);
+ ~ToolOptionFontCombo();
void updateStatus() override;
TEnumProperty *getProperty() const { return m_property; }
@@ -239,19 +242,21 @@ public slots:
//-----------------------------------------------------------------------------
-class ToolOptionTextField final : public DVGui::LineEdit,
- public ToolOptionControl {
+class DVAPI ToolOptionTextField final : public DVGui::LineEdit,
+ public ToolOptionControl {
Q_OBJECT
protected:
TStringProperty *m_property;
public:
- ToolOptionTextField(TTool *tool, TStringProperty *property);
+ ToolOptionTextField(TTool *tool, TStringProperty *property,
+ ToolHandle *toolHandle = 0);
void updateStatus() override;
public slots:
+ void onLiveTextChanged(const QString &);
void onValueChanged();
};
@@ -290,8 +295,9 @@ public slots:
the edited one)
\li Undo/Redo of user interactions.
*/
-class ToolOptionParamRelayField final : public DVGui::MeasuredDoubleLineEdit,
- public ToolOptionControl {
+class DVAPI ToolOptionParamRelayField final
+ : public DVGui::MeasuredDoubleLineEdit,
+ public ToolOptionControl {
Q_OBJECT
TDoubleParamP m_param; //!< Cached property param
@@ -360,9 +366,9 @@ public:
void setValue(double v);
double getValue() const;
-
+
bool isLabelClicked() const { return m_labelClicked; }
-
+
void setPrecision(int precision);
int getPrecision() { return m_precision; }
@@ -384,8 +390,8 @@ signals:
};
//-----------------------------------------------------------------------------
-class PegbarChannelField final : public MeasuredValueField,
- public ToolOptionControl {
+class DVAPI PegbarChannelField final : public MeasuredValueField,
+ public ToolOptionControl {
Q_OBJECT
const enum TStageObject::Channel m_actionId;
@@ -445,7 +451,8 @@ protected slots:
//-----------------------------------------------------------------------------
-class NoScaleField final : public MeasuredValueField, public ToolOptionControl {
+class DVAPI NoScaleField final : public MeasuredValueField,
+ public ToolOptionControl {
Q_OBJECT
public:
@@ -487,7 +494,7 @@ signals:
//-----------------------------------------------------------------------------
-class SelectionScaleField final : public MeasuredValueField {
+class DVAPI SelectionScaleField final : public MeasuredValueField {
Q_OBJECT
int m_id;
@@ -513,7 +520,7 @@ signals:
//-----------------------------------------------------------------------------
-class SelectionRotationField final : public MeasuredValueField {
+class DVAPI SelectionRotationField final : public MeasuredValueField {
Q_OBJECT
SelectionTool *m_tool;
@@ -534,7 +541,7 @@ protected slots:
//-----------------------------------------------------------------------------
-class SelectionMoveField final : public MeasuredValueField {
+class DVAPI SelectionMoveField final : public MeasuredValueField {
Q_OBJECT
int m_id;
@@ -555,7 +562,7 @@ protected slots:
//-----------------------------------------------------------------------------
-class ThickChangeField final : public MeasuredValueField {
+class DVAPI ThickChangeField final : public MeasuredValueField {
Q_OBJECT
SelectionTool *m_tool;
@@ -577,7 +584,7 @@ protected slots:
// The ClickableLabel class is used to allow click and dragging
// on a label to change the value of a linked field
-class ClickableLabel : public QLabel {
+class DVAPI ClickableLabel : public QLabel {
Q_OBJECT
protected:
diff --git a/toonz/sources/toonz/CMakeLists.txt b/toonz/sources/toonz/CMakeLists.txt
index c0b1e16d7..3a7ce05d2 100644
--- a/toonz/sources/toonz/CMakeLists.txt
+++ b/toonz/sources/toonz/CMakeLists.txt
@@ -494,6 +494,7 @@ include_directories(
../../sources/toonzfarm/include
../../sources/toonzqt
../../sources/stopmotion
+ ../../sources/tnztools # Required for SelectionScaleField, SelectionRotationField, etc.
)
if (WITH_CANON)
diff --git a/toonz/sources/toonz/toolpropertiespanel.cpp b/toonz/sources/toonz/toolpropertiespanel.cpp
index dd5de07e6..7b348fbfc 100644
--- a/toonz/sources/toonz/toolpropertiespanel.cpp
+++ b/toonz/sources/toonz/toolpropertiespanel.cpp
@@ -1,10 +1,27 @@
#include "toolpropertiespanel.h"
+#include <cmath>
+
+#include <QPointer>
+
+#include <array>
+#include <limits>
+#include <memory>
+
// ToonzQt includes
#include "tapp.h"
-#include "menubarcommandids.h"
#include "toonzqt/doublepairfield.h"
#include "toonzqt/intpairfield.h"
+#include "toonzqt/gutil.h"
+#include "toonzqt/menubarcommand.h"
+#include "toonz/tframehandle.h"
+#include "toonz/tobjecthandle.h"
+#include "toonz/tcolumnhandle.h"
+#include "toonz/txsheethandle.h"
+#include "toonz/txshlevelhandle.h"
+#include "toonz/txshleveltypes.h"
+#include "toonz/txsheet.h"
+#include "toonz/tstageobjecttree.h"
// ToonzLib includes
#include "toonz/preferences.h"
@@ -12,6 +29,13 @@
// TnzCore includes
#include "tenv.h"
+#include "tundo.h"
+
+// TnzBase includes
+#include "tdoubleparamrelayproperty.h"
+
+// ToonzLib includes
+#include "toonz/doubleparamcmd.h"
// Tools includes
#include "tools/tool.h"
@@ -19,6 +43,22 @@
#include "tools/toolcommandids.h"
#include "tproperty.h"
+// tnztools — Selection tool specialized fields (requires tnztools in include
+// path)
+#include "selectiontool.h"
+#include "vectorselectiontool.h"
+#include "rasterselectiontool.h"
+#include "tooloptionscontrols.h"
+#include "rulertool.h"
+#include "plastictool.h"
+#include "ext/plasticskeleton.h"
+#include "tools/tooloptions.h"
+#include "shifttracetool.h"
+
+#include "menubarcommandids.h"
+#include "toonz/onionskinmask.h"
+#include "toonz/tonionskinmaskhandle.h"
+
// Qt includes
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -28,6 +68,9 @@
#include <QCheckBox>
#include <QComboBox>
#include <QPushButton>
+#include <QAction>
+#include <QList>
+#include <QGridLayout>
#include <QLineEdit>
#include <QIntValidator>
#include <QDoubleValidator>
@@ -40,9 +83,13 @@
// Standard library
#include <algorithm> // For std::min
#include <map>
+#include <set>
+#include <functional>
+#include <QAction>
#include <QMenu>
#include <QContextMenuEvent>
#include <QIcon>
+#include <QObject>
#include <QPixmap>
#include <QPainter>
#include <QStyleOptionToolButton>
@@ -51,8 +98,8 @@
namespace {
// Tool Properties Panel UI preferences (stored in user .env via TEnv).
-TEnv::IntVar ToolPropertiesUseSingleMaxSlider("ToolPropertiesUseSingleMaxSlider",
- 0);
+TEnv::IntVar ToolPropertiesUseSingleMaxSlider(
+ "ToolPropertiesUseSingleMaxSlider", 0);
TEnv::IntVar ToolPropertiesShowLabels("ToolPropertiesShowLabels", 1);
TEnv::IntVar ToolPropertiesShowNumericFields("ToolPropertiesShowNumericFields",
1);
@@ -67,8 +114,7 @@ std::map<std::string, bool> parseCollapsedStates() {
std::map<std::string, bool> result;
const QString stored =
QString::fromStdString((std::string)ToolPropertiesCollapsedStates);
- const QStringList entries =
- stored.split(';', Qt::SkipEmptyParts);
+ const QStringList entries = stored.split(';', Qt::SkipEmptyParts);
for (const QString &entry : entries) {
const int eq = entry.indexOf('=');
if (eq <= 0) continue;
@@ -82,7 +128,7 @@ void writeCollapsedStates(const std::map<std::string, bool> &states) {
QStringList entries;
for (const auto &it : states) {
entries << QString::fromStdString(it.first) + "=" +
- QString::number(it.second ? 1 : 0);
+ QString::number(it.second ? 1 : 0);
}
ToolPropertiesCollapsedStates = entries.join(";").toStdString();
}
@@ -102,59 +148,184 @@ void setCollapsedStateInEnv(const std::string &propName, bool expanded) {
} // namespace
+namespace {
+
+// Same cell fill as ToolPropertyButton in collapsible enum menus.
+QColor tppCollapsibleCellBackground(const QColor &panelBg) {
+ if (!panelBg.isValid()) return panelBg;
+ if (panelBg.lightness() > 128) return panelBg.darker(105);
+ return panelBg.lighter(108);
+}
+
+QColor tppCollapsibleCellPanelBackground(const QWidget *widget) {
+ if (!widget) return QColor();
+ // Use the same panel surface as collapsible pickers (toolOptionsPanel), not a
+ // styled QFrame parent whose palette can read too dark under stylesheets.
+ for (const QWidget *w = widget; w; w = w->parentWidget()) {
+ if (w->objectName() == QLatin1String("toolOptionsPanel"))
+ return w->palette().color(QPalette::Window);
+ }
+ QColor panelBg = widget->palette().color(QPalette::Window);
+ if (widget->parentWidget())
+ panelBg = widget->parentWidget()->palette().color(QPalette::Window);
+ return panelBg;
+}
+
+} // namespace
+
+class AnimateAxisStackWidget final : public QStackedWidget {
+public:
+ explicit AnimateAxisStackWidget(QWidget *parent = nullptr)
+ : QStackedWidget(parent) {
+ connect(this, &QStackedWidget::currentChanged, this, [this](int) {
+ updateGeometry();
+ if (QWidget *host = parentWidget()) host->updateGeometry();
+ });
+ }
+
+ QSize sizeHint() const override {
+ return axisAwareSizeHint(&QWidget::sizeHint);
+ }
+ QSize minimumSizeHint() const override {
+ return axisAwareSizeHint(&QWidget::minimumSizeHint);
+ }
+
+private:
+ using HintFn = QSize (QWidget::*)() const;
+
+ QSize axisAwareSizeHint(HintFn hint) const {
+ int maxW = 0;
+ for (int i = 0; i < count(); ++i) {
+ if (QWidget *page = widget(i)) maxW = qMax(maxW, (page->*hint)().width());
+ }
+ QWidget *cur = currentWidget();
+ if (!cur) return QStackedWidget::sizeHint();
+ QSize sh = (cur->*hint)();
+ sh.setWidth(qMax(sh.width(), maxW));
+ return sh;
+ }
+};
+
//=============================================================================
// ToolPropertyButton - Custom button with theme-aware painting
//=============================================================================
ToolPropertyButton::ToolPropertyButton(const QString &text, QWidget *parent)
- : QToolButton(parent)
- , m_showBorders(true)
- , m_showBackgrounds(true) {
+ : QToolButton(parent), m_showBorders(true), m_showBackgrounds(true) {
setText(text);
- setMouseTracking(true); // To detect hover
+ setMouseTracking(true);
+ setStyleSheet(QStringLiteral("QToolButton { margin: 0; padding: 0; }"));
}
-void ToolPropertyButton::paintEvent(QPaintEvent *event) {
+void ToolPropertyButton::paintEvent(QPaintEvent *) {
QStyleOptionToolButton opt;
initStyleOption(&opt);
- const bool isHovered = opt.state.testFlag(QStyle::State_MouseOver);
- const bool isChecked = opt.state.testFlag(QStyle::State_On);
- const bool isPressed = opt.state.testFlag(QStyle::State_Sunken);
- const bool useThemeState = isHovered || isChecked || isPressed;
+ const bool enabled = isEnabled();
+ if (!enabled) {
+ opt.state &= ~QStyle::State_MouseOver;
+ opt.state &= ~QStyle::State_Sunken;
+ opt.palette.setCurrentColorGroup(QPalette::Disabled);
+ }
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- if (useThemeState) {
- // Hover/checked/pressed: let QSS draw full button to match theme colors
- style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &painter, this);
+ // Disabled: identical cells for checked and unchecked — flat label, no
+ // selected chrome and no CE_ToolButtonLabel emboss (Windows).
+ if (!enabled) {
+ opt.state &= ~QStyle::State_On;
+ opt.state &= ~QStyle::State_Raised;
+
+ if (m_showBackgrounds) {
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(tppCollapsibleCellBackground(
+ tppCollapsibleCellPanelBackground(this)));
+ painter.drawRect(rect());
+ }
+
+ painter.setPen(palette().color(QPalette::Disabled, QPalette::WindowText));
+ painter.setFont(font());
+ painter.drawText(rect(), Qt::AlignCenter, text());
+
+ if (m_showBorders) {
+ QColor borderColor = palette().color(QPalette::Mid);
+ QPen borderPen(borderColor);
+ borderPen.setWidthF(0.5);
+ painter.setPen(borderPen);
+ painter.setBrush(Qt::NoBrush);
+ painter.drawRect(rect().adjusted(0, 0, -1, -1));
+ }
return;
}
- // Normal state: draw background based on Cells Backgrounds option
- if (m_showBackgrounds) {
- QColor panelBg = palette().color(QPalette::Window);
- if (QWidget *parent = parentWidget()) {
- panelBg = parent->palette().color(QPalette::Window);
+ const bool isHovered =
+ m_hoverEnabled && opt.state.testFlag(QStyle::State_MouseOver);
+ const bool isChecked = opt.state.testFlag(QStyle::State_On);
+ const bool isPressed = opt.state.testFlag(QStyle::State_Sunken);
+ const bool useThemeState = isHovered || isChecked || isPressed;
+
+ // Compact highlight: theme colors on a small centered pill, icon size
+ // unchanged.
+ if (m_compactIconSize > 0) {
+ constexpr int kCompactHighlightPad = 4;
+ const int hlSize = m_compactIconSize + kCompactHighlightPad * 2;
+ const QRect hlRect((width() - hlSize) / 2, (height() - hlSize) / 2, hlSize,
+ hlSize);
+
+ // Full cell fill first — same layer as collapsible enum rows (Column,
+ // etc.).
+ if (m_showBackgrounds) {
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(tppCollapsibleCellBackground(
+ tppCollapsibleCellPanelBackground(this)));
+ painter.drawRect(rect());
}
- QColor bgColor = panelBg;
- if (panelBg.lightness() > 128) {
- bgColor = panelBg.darker(105);
- } else {
- bgColor = panelBg.lighter(108);
+ if (useThemeState) {
+ QStyleOptionToolButton hlOpt = opt;
+ hlOpt.rect = QRect(0, 0, hlRect.width(), hlRect.height());
+ painter.save();
+ painter.translate(hlRect.topLeft());
+ style()->drawComplexControl(QStyle::CC_ToolButton, &hlOpt, &painter,
+ this);
+ painter.restore();
+ }
+
+ style()->drawControl(QStyle::CE_ToolButtonLabel, &opt, &painter, this);
+
+ if (m_showBorders) {
+ QColor borderColor = palette().color(QPalette::Mid);
+ QPen borderPen(borderColor);
+ borderPen.setWidthF(0.5);
+ painter.setPen(borderPen);
+ painter.setBrush(Qt::NoBrush);
+ painter.drawRect(rect().adjusted(0, 0, -1, -1));
}
+ return;
+ }
+ if (m_showBackgrounds) {
painter.setPen(Qt::NoPen);
- painter.setBrush(bgColor);
+ painter.setBrush(
+ tppCollapsibleCellBackground(tppCollapsibleCellPanelBackground(this)));
painter.drawRect(rect());
}
- // Draw label (text/icon)
- style()->drawControl(QStyle::CE_ToolButtonLabel, &opt, &painter, this);
+ if (useThemeState) {
+ QStyleOptionToolButton frameOpt = opt;
+ frameOpt.text = QString();
+ frameOpt.icon = QIcon();
+ style()->drawComplexControl(QStyle::CC_ToolButton, &frameOpt, &painter,
+ this);
+ }
+
+ // Literal UIName text (e.g. "Lines & Areas"): same glyphs as disabled flat
+ // paint; CE_ToolButtonLabel would strip "&" shortcut markers.
+ painter.setPen(palette().color(QPalette::WindowText));
+ painter.setFont(font());
+ painter.drawText(rect(), Qt::AlignCenter, text());
- // Draw thin border if enabled (Brush Preset style)
if (m_showBorders) {
QColor borderColor = palette().color(QPalette::Mid);
QPen borderPen(borderColor);
@@ -165,6 +336,16 @@ void ToolPropertyButton::paintEvent(QPaintEvent *event) {
}
}
+void ToolPropertyButton::enterEvent(QEvent *event) {
+ if (!isEnabled() || !m_hoverEnabled) return;
+ QToolButton::enterEvent(event);
+}
+
+void ToolPropertyButton::mouseMoveEvent(QMouseEvent *event) {
+ if (!isEnabled() || !m_hoverEnabled) return;
+ QToolButton::mouseMoveEvent(event);
+}
+
//=============================================================================
// ToolPropertiesPanel implementation
//=============================================================================
@@ -178,13 +359,14 @@ ToolPropertiesPanel::ToolPropertiesPanel(QWidget *parent)
, m_toolHandle(nullptr)
, m_currentToolId("")
, m_currentToolType("")
- , m_useSingleMaxSlider(false) // DoublePairField by default (native double cursor)
- , m_showLabels(true) // Show labels by default
- , m_showNumericFields(true) // Show numeric fields by default
- , m_showBorders(true) // Show option borders by default
- , m_showBackgrounds(true) // Show option backgrounds by default
- , m_showIcons(true) { // Show Cap/Join icons by default
-
+ , m_useSingleMaxSlider(
+ false) // DoublePairField by default (native double cursor)
+ , m_showLabels(true) // Show labels by default
+ , m_showNumericFields(true) // Show numeric fields by default
+ , m_showBorders(true) // Show option borders by default
+ , m_showBackgrounds(true) // Show option backgrounds by default
+ , m_showIcons(true) { // Icon grid replaces collapsible enums when possible
+
// Load preferences from TEnv
m_useSingleMaxSlider = ToolPropertiesUseSingleMaxSlider != 0;
m_showLabels = ToolPropertiesShowLabels != 0;
@@ -198,6 +380,14 @@ ToolPropertiesPanel::ToolPropertiesPanel(QWidget *parent)
}
ToolPropertiesPanel::~ToolPropertiesPanel() {
+ if (m_rulerOptionsBox && m_rulerOptionsBoxRegistered) {
+ if (auto *ruler = dynamic_cast<RulerTool *>(getCurrentTool()))
+ ruler->unsetToolOptionsBox(m_rulerOptionsBox);
+ else if (auto *ruler = dynamic_cast<RulerTool *>(
+ TTool::getTool("T_Ruler", TTool::ToonzImage)))
+ ruler->unsetToolOptionsBox(m_rulerOptionsBox);
+ m_rulerOptionsBoxRegistered = false;
+ }
disconnectSignals();
}
@@ -222,49 +412,51 @@ void ToolPropertiesPanel::hideEvent(QHideEvent *e) {
//-----------------------------------------------------------------------------
void ToolPropertiesPanel::initializeUI() {
- QWidget *mainWidget = new QWidget(this);
+ QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setMargin(5);
mainLayout->setSpacing(5);
-
+
// Tool name label (header) - Normal style like "Size" property
m_toolNameLabel = new QLabel(tr("Tool Properties"), this);
m_toolNameLabel->setAlignment(Qt::AlignCenter);
mainLayout->addWidget(m_toolNameLabel);
-
+
// Separator
QFrame *separator = new QFrame(this);
separator->setFrameShape(QFrame::HLine);
separator->setFrameShadow(QFrame::Sunken);
mainLayout->addWidget(separator);
-
+
// Scroll area for properties
m_scrollArea = new QScrollArea(this);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
-
+
m_propertiesContainer = new QWidget();
- // CRITICAL: Set objectName to "toolOptionsPanel" to inherit theme styles from .qss
- // All themes define #toolOptionsPanel QPushButton:checked, :hover, etc.
+ m_propertiesContainer->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+ // CRITICAL: Set objectName to "toolOptionsPanel" to inherit theme styles from
+ // .qss All themes define #toolOptionsPanel QPushButton:checked, :hover, etc.
m_propertiesContainer->setObjectName("toolOptionsPanel");
-
+
m_propertiesLayout = new QVBoxLayout(m_propertiesContainer);
m_propertiesLayout->setMargin(8);
m_propertiesLayout->setSpacing(20); // Significant spacing between properties
m_propertiesLayout->setAlignment(Qt::AlignTop);
-
+
m_propertiesContainer->setLayout(m_propertiesLayout);
m_scrollArea->setWidget(m_propertiesContainer);
-
+
// Apply initial container stylesheet for Cells Borders/Backgrounds control
updateContainerStylesheet();
-
+
mainLayout->addWidget(m_scrollArea, 1);
-
+
setWidget(mainWidget);
setWindowTitle(tr("Tool Properties"));
-
+
// Enable context menu
setContextMenuPolicy(Qt::DefaultContextMenu);
}
@@ -272,19 +464,67 @@ void ToolPropertiesPanel::initializeUI() {
void ToolPropertiesPanel::connectSignals() {
if (!m_toolHandle) {
TApplication *app = TApp::instance();
- m_toolHandle = app->getCurrentTool();
+ m_toolHandle = app->getCurrentTool();
}
-
+
if (m_toolHandle) {
- connect(m_toolHandle, SIGNAL(toolSwitched()), this, SLOT(onToolSwitched()));
- connect(m_toolHandle, SIGNAL(toolChanged()), this, SLOT(onToolChanged()));
+ connect(m_toolHandle, SIGNAL(toolSwitched()), this, SLOT(onToolSwitched()),
+ Qt::UniqueConnection);
+ connect(m_toolHandle, SIGNAL(toolChanged()), this, SLOT(onToolChanged()),
+ Qt::UniqueConnection);
+ connect(m_toolHandle, SIGNAL(toolComboBoxListChanged(std::string)), this,
+ SLOT(onToolComboBoxListChanged(std::string)), Qt::UniqueConnection);
+ connect(m_toolHandle, SIGNAL(toolOptionsBoxChanged()), this,
+ SLOT(onSceneContextChanged()), Qt::UniqueConnection);
+ }
+
+ TApplication *app = TApp::instance();
+ if (app) {
+ connect(app->getCurrentColumn(), SIGNAL(columnIndexSwitched()), this,
+ SLOT(onSceneContextChanged()), Qt::UniqueConnection);
+ connect(app->getCurrentLevel(), SIGNAL(xshLevelSwitched(TXshLevel *)), this,
+ SLOT(onSceneContextChanged()), Qt::UniqueConnection);
+ connect(app->getCurrentFrame(), SIGNAL(frameSwitched()), this,
+ SLOT(onSceneContextChanged()), Qt::UniqueConnection);
+ connect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
+ SLOT(onSceneContextChanged()), Qt::UniqueConnection);
+ if (TObjectHandle *objHandle = app->getCurrentObject()) {
+ connect(objHandle, SIGNAL(objectChanged(bool)), this,
+ SLOT(onToolChanged()), Qt::UniqueConnection);
+ connect(objHandle, SIGNAL(objectSwitched()), this, SLOT(onToolChanged()),
+ Qt::UniqueConnection);
+ }
}
}
void ToolPropertiesPanel::disconnectSignals() {
if (m_toolHandle) {
- disconnect(m_toolHandle, SIGNAL(toolSwitched()), this, SLOT(onToolSwitched()));
- disconnect(m_toolHandle, SIGNAL(toolChanged()), this, SLOT(onToolChanged()));
+ disconnect(m_toolHandle, SIGNAL(toolSwitched()), this,
+ SLOT(onToolSwitched()));
+ disconnect(m_toolHandle, SIGNAL(toolChanged()), this,
+ SLOT(onToolChanged()));
+ disconnect(m_toolHandle, SIGNAL(toolComboBoxListChanged(std::string)), this,
+ SLOT(onToolComboBoxListChanged(std::string)));
+ disconnect(m_toolHandle, SIGNAL(toolOptionsBoxChanged()), this,
+ SLOT(onSceneContextChanged()));
+ }
+
+ TApplication *app = TApp::instance();
+ if (app) {
+ disconnect(app->getCurrentColumn(), SIGNAL(columnIndexSwitched()), this,
+ SLOT(onSceneContextChanged()));
+ disconnect(app->getCurrentLevel(), SIGNAL(xshLevelSwitched(TXshLevel *)),
+ this, SLOT(onSceneContextChanged()));
+ disconnect(app->getCurrentFrame(), SIGNAL(frameSwitched()), this,
+ SLOT(onSceneContextChanged()));
+ disconnect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
+ SLOT(onSceneContextChanged()));
+ if (TObjectHandle *objHandle = app->getCurrentObject()) {
+ disconnect(objHandle, SIGNAL(objectChanged(bool)), this,
+ SLOT(onToolChanged()));
+ disconnect(objHandle, SIGNAL(objectSwitched()), this,
+ SLOT(onToolChanged()));
+ }
}
}
@@ -299,7 +539,9 @@ QString ToolPropertiesPanel::detectCurrentToolId() {
QString ToolPropertiesPanel::detectCurrentToolType() {
QString toolId = detectCurrentToolId();
-
+
+ if (toolId == T_ShiftTrace) return QStringLiteral("shifttrace");
+
// Identify tool types
if (toolId == T_Brush) {
// Check if it's a MyPaint brush (similar to BrushPresetPanel logic)
@@ -311,7 +553,7 @@ QString ToolPropertiesPanel::detectCurrentToolType() {
TApplication *app = TApp::instance();
if (app) {
TColorStyle *style = app->getCurrentLevelStyle();
- if (dynamic_cast<TMyPaintBrushStyle*>(style)) {
+ if (dynamic_cast<TMyPaintBrushStyle *>(style)) {
return "mypainttnz";
}
}
@@ -320,7 +562,7 @@ QString ToolPropertiesPanel::detectCurrentToolType() {
TApplication *app = TApp::instance();
if (app) {
TColorStyle *style = app->getCurrentLevelStyle();
- if (dynamic_cast<TMyPaintBrushStyle*>(style)) {
+ if (dynamic_cast<TMyPaintBrushStyle *>(style)) {
return "mypaint";
}
}
@@ -329,6 +571,10 @@ QString ToolPropertiesPanel::detectCurrentToolType() {
return "brush";
}
if (toolId == T_Fill) return "fill";
+ if (toolId == T_PaintBrush) return "paintbrush";
+ if (toolId == T_Finger) return "finger";
+ if (toolId == T_Type) return "type";
+ if (toolId == T_EditAssistants) return "assistant";
if (toolId == T_Eraser) return "eraser";
if (toolId == T_Geometric) return "geometric";
if (toolId == T_Selection) return "selection";
@@ -352,67 +598,332 @@ QString ToolPropertiesPanel::detectCurrentToolType() {
if (toolId == T_Zoom) return "zoom";
if (toolId == T_Rotate) return "rotate";
if (toolId == T_Hand) return "hand";
-
+
return "unknown";
}
-TTool* ToolPropertiesPanel::getCurrentTool() {
+TTool *ToolPropertiesPanel::getCurrentTool() {
if (!m_toolHandle) return nullptr;
return m_toolHandle->getTool();
}
+QString ToolPropertiesPanel::displayNameForToolId(const QString &toolId) const {
+ if (toolId == T_Brush) return tr("Brush tool");
+ if (toolId == T_Fill) return tr("Fill tool");
+ if (toolId == T_PaintBrush) return tr("Paint Brush tool");
+ if (toolId == T_Finger) return tr("Finger tool");
+ if (toolId == T_Type) return tr("Type tool");
+ if (toolId == T_EditAssistants) return tr("Edit Assistants tool");
+ if (toolId == T_Eraser) return tr("Eraser tool");
+ if (toolId == T_Selection) return tr("Selection tool");
+ if (toolId == T_Geometric) return tr("Geometric tool");
+ if (toolId == T_Edit) return tr("Animate tool");
+ if (toolId == T_Tape) return tr("Tape tool");
+ if (toolId == T_Cutter) return tr("Cutter tool");
+ if (toolId == T_StylePicker) return tr("Style Picker tool");
+ if (toolId == T_RGBPicker) return tr("RGB Picker tool");
+ if (toolId == T_ControlPointEditor) return tr("Control Point Editor tool");
+ if (toolId == T_Pinch) return tr("Pinch tool");
+ if (toolId == T_Pump) return tr("Pump tool");
+ if (toolId == T_Magnet) return tr("Magnet tool");
+ if (toolId == T_Bender) return tr("Bender tool");
+ if (toolId == T_Iron) return tr("Iron tool");
+ if (toolId == T_Skeleton) return tr("Skeleton tool");
+ if (toolId == T_Tracker) return tr("Tracker tool");
+ if (toolId == T_Hook) return tr("Hook tool");
+ if (toolId == T_Plastic) return tr("Plastic tool");
+ if (toolId == T_Zoom) return tr("Zoom tool");
+ if (toolId == T_Rotate) return tr("Rotate tool");
+ if (toolId == T_Hand) return tr("Hand tool");
+ if (toolId == T_Ruler) return tr("Ruler tool");
+ if (toolId == T_ShiftTrace) return tr("Shift and Trace");
+ return toolId;
+}
+
//-----------------------------------------------------------------------------
// Properties Display
//-----------------------------------------------------------------------------
+namespace {
+
+struct LevelTypeDesc {
+ int levelType;
+ TTool::ToolTargetType targetType;
+ const char *name;
+};
+
+const LevelTypeDesc kLevelTypes[] = {
+ {PLI_XSHLEVEL, TTool::VectorImage, QT_TR_NOOP("Toonz Vector Level")},
+ {TZP_XSHLEVEL, TTool::ToonzImage, QT_TR_NOOP("Toonz Raster Level")},
+ {OVL_XSHLEVEL, TTool::RasterImage, QT_TR_NOOP("Raster Level")},
+ {MESH_XSHLEVEL, TTool::MeshImage, QT_TR_NOOP("Mesh Level")},
+ {META_XSHLEVEL, TTool::MetaImage, QT_TR_NOOP("Assistants Level")},
+};
+
+bool isPlaceholderTool(TTool *tool) {
+ return tool && tool->getName() == "T_Dummy";
+}
+
+bool propertyGroupHasAdjustableProps(TPropertyGroup *props) {
+ if (!props || props->getPropertyCount() == 0) return false;
+
+ std::set<std::string> seenNames;
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop) continue;
+
+ const std::string name = prop->getName();
+ if (seenNames.count(name)) continue;
+ seenNames.insert(name);
+
+ if (auto *ep = dynamic_cast<TEnumProperty *>(prop)) {
+ if (!ep->getItems().empty()) return true;
+ } else if (dynamic_cast<TBoolProperty *>(prop) ||
+ dynamic_cast<TIntProperty *>(prop) ||
+ dynamic_cast<TDoubleProperty *>(prop) ||
+ dynamic_cast<TStringProperty *>(prop) ||
+ dynamic_cast<TDoublePairProperty *>(prop) ||
+ dynamic_cast<TIntPairProperty *>(prop)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool toolInstanceHasAdjustableProperties(TTool *tool) {
+ if (!tool || isPlaceholderTool(tool)) return false;
+ return propertyGroupHasAdjustableProps(tool->getProperties(0)) ||
+ propertyGroupHasAdjustableProps(tool->getProperties(1));
+}
+
+int detectCurrentLevelType(TApplication *app) {
+ if (!app) return NO_XSHLEVEL;
+
+ TXsheet *xsh = app->getCurrentXsheet()->getXsheet();
+ const int columnIndex = app->getCurrentColumn()->getColumnIndex();
+ const int rowIndex = app->getCurrentFrame()->getFrame();
+
+ TXshColumn *column =
+ (columnIndex >= 0) ? xsh->getColumn(columnIndex) : nullptr;
+
+ TXshLevel *xl = app->getCurrentLevel()->getLevel();
+ TXshSimpleLevel *sl = xl ? xl->getSimpleLevel() : nullptr;
+ int levelType = sl ? sl->getType() : NO_XSHLEVEL;
+
+ if (levelType == NO_XSHLEVEL && !app->getCurrentFrame()->isEditingLevel()) {
+ if (!column || !column->getSoundColumn()) {
+ TXshCell cell = xsh->getCell(rowIndex, columnIndex);
+ sl = cell.isEmpty() ? nullptr : cell.getSimpleLevel();
+ levelType = cell.isEmpty() ? NO_XSHLEVEL : cell.m_level->getType();
+ }
+ }
+
+ return levelType;
+}
+
+bool isToolSupportedOnLevelType(const std::string &toolName, int levelType) {
+ for (const LevelTypeDesc &desc : kLevelTypes) {
+ if (levelType != desc.levelType) continue;
+ TTool *tool = TTool::getTool(toolName, desc.targetType);
+ return tool && !isPlaceholderTool(tool) &&
+ (tool->getTargetType() & desc.targetType);
+ }
+ return false;
+}
+
+QStringList compatibleLevelNamesWithProperties(const std::string &toolName) {
+ QStringList names;
+ for (const LevelTypeDesc &desc : kLevelTypes) {
+ TTool *tool = TTool::getTool(toolName, desc.targetType);
+ if (!tool || isPlaceholderTool(tool)) continue;
+ if (!(tool->getTargetType() & desc.targetType)) continue;
+ if (!toolInstanceHasAdjustableProperties(tool)) continue;
+ names << QObject::tr(desc.name);
+ }
+ return names;
+}
+
+QStringList compatibleLevelNamesForToolUse(const std::string &toolName) {
+ QStringList names;
+ for (const LevelTypeDesc &desc : kLevelTypes) {
+ TTool *tool = TTool::getTool(toolName, desc.targetType);
+ if (!tool || isPlaceholderTool(tool)) continue;
+ if (!(tool->getTargetType() & desc.targetType)) continue;
+ names << QObject::tr(desc.name);
+ }
+ return names;
+}
+
+QString formatLevelHintMessage(const QString &singleLineTemplate,
+ const QString &listTemplate,
+ const QStringList &levels) {
+ if (levels.isEmpty()) return QString();
+ if (levels.size() == 1) return singleLineTemplate.arg(levels.first());
+ return listTemplate.arg(levels.join(QObject::tr(", ")));
+}
+
+bool hasNoActiveLevelContext(TApplication *app) {
+ if (!app) return true;
+ if (app->getCurrentFrame()->isEditingLevel()) return false;
+ return detectCurrentLevelType(app) == NO_XSHLEVEL;
+}
+
+constexpr const char *kTppPropPtrKey = "tppPropPtr";
+
+void storeTppPropertyPtr(QWidget *w, TProperty *prop) {
+ if (w && prop) {
+ w->setProperty(kTppPropPtrKey, QVariant::fromValue<quintptr>(
+ reinterpret_cast<quintptr>(prop)));
+ }
+}
+
+TProperty *tppPropertyFromWidget(const QWidget *w) {
+ if (!w) return nullptr;
+ const QVariant v = w->property(kTppPropPtrKey);
+ if (!v.isValid()) return nullptr;
+ return reinterpret_cast<TProperty *>(v.value<quintptr>());
+}
+
+TProperty *resolveTppProperty(TTool *tool, const QWidget *w, int propGroup,
+ const std::string &propName) {
+ if (TProperty *direct = tppPropertyFromWidget(w)) return direct;
+ if (!tool) return nullptr;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return nullptr;
+ return props->getProperty(propName);
+}
+
+} // namespace
+
+int ToolPropertiesPanel::propertyWidgetCount() const {
+ if (!m_propertiesLayout) return 0;
+
+ int count = 0;
+ for (int i = 0; i < m_propertiesLayout->count(); ++i) {
+ QLayoutItem *item = m_propertiesLayout->itemAt(i);
+ if (item && item->widget()) ++count;
+ }
+ return count;
+}
+
+void ToolPropertiesPanel::showEmptyPropertiesHint(
+ const QString &requestedToolId) {
+ const std::string toolName = requestedToolId.toStdString();
+ if (toolName.empty()) return;
+
+ TApplication *app = TApp::instance();
+ if (hasNoActiveLevelContext(app)) return;
+
+ const QStringList propertyLevels =
+ compatibleLevelNamesWithProperties(toolName);
+ const QStringList usableLevels = compatibleLevelNamesForToolUse(toolName);
+ const int levelType = detectCurrentLevelType(app);
+ const bool supportedOnCurrent =
+ isToolSupportedOnLevelType(toolName, levelType);
+
+ QString message;
+ if (!usableLevels.isEmpty() && !supportedOnCurrent) {
+ if (!propertyLevels.isEmpty()) {
+ message = formatLevelHintMessage(
+ tr("This tool's properties are only available on %1."),
+ tr("This tool's properties are only available on: %1"),
+ propertyLevels);
+ } else {
+ message = formatLevelHintMessage(tr("This tool can only be used on %1."),
+ tr("This tool can only be used on: %1"),
+ usableLevels);
+ }
+ } else {
+ message = tr("No adjustable properties for this tool.");
+ }
+
+ QLabel *hint = new QLabel(message, m_propertiesContainer);
+ hint->setAlignment(Qt::AlignCenter);
+ hint->setWordWrap(true);
+ QPalette pal = hint->palette();
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
+ hint->setPalette(pal);
+ hint->setStyleSheet("padding: 20px;");
+ m_propertiesLayout->addWidget(hint);
+}
+
void ToolPropertiesPanel::refreshProperties() {
QString toolId = detectCurrentToolId();
- QString toolType = detectCurrentToolType();
-
- // Clear existing properties
- clearProperties();
-
- m_currentToolId = toolId;
- m_currentToolType = toolType;
-
- // Update header
- TTool *tool = getCurrentTool();
- if (tool) {
- QString toolName = QString::fromStdString(tool->getName());
- m_toolNameLabel->setText(tr("Tool Properties - %1").arg(toolName));
- } else {
+ if (toolId.isEmpty()) {
+ clearProperties();
+ m_currentToolId = QString();
+ m_currentToolType = QString();
m_toolNameLabel->setText(tr("Tool Properties"));
- // No active tool, display nothing
m_propertiesLayout->addStretch(1);
return;
}
-
+
+ QString toolType = detectCurrentToolType();
+
+ clearProperties();
+
+ m_currentToolId = toolId;
+ m_currentToolType = toolType;
+
+ m_toolNameLabel->setText(displayNameForToolId(toolId));
+
// Create properties based on tool type
if (toolType == "brush") {
createBrushProperties();
} else if (toolType == "mypaint" || toolType == "mypainttnz") {
createMyPaintBrushProperties();
} else if (toolType == "fill") {
- // TODO: Implement later
- QLabel *comingSoon = new QLabel(tr("Properties for Fill tool - Coming soon!"), this);
- comingSoon->setAlignment(Qt::AlignCenter);
- comingSoon->setStyleSheet("color: gray; padding: 20px;");
- m_propertiesLayout->addWidget(comingSoon);
+ createFillProperties();
} else if (toolType == "eraser") {
- // TODO: Implement later
- QLabel *comingSoon = new QLabel(tr("Properties for Eraser tool - Coming soon!"), this);
- comingSoon->setAlignment(Qt::AlignCenter);
- comingSoon->setStyleSheet("color: gray; padding: 20px;");
- m_propertiesLayout->addWidget(comingSoon);
+ createEraserProperties();
+ } else if (toolType == "geometric") {
+ createGeometricProperties();
+ } else if (toolType == "selection") {
+ createSelectionProperties();
+
+ } else if (toolType == "type") {
+ createTypeProperties();
+
+ } else if (toolType == "ruler") {
+ createRulerProperties();
+
+ } else if (toolType == "plastic") {
+ createPlasticProperties();
+
+ } else if (toolType == "edit") {
+ createAnimateProperties();
+
+ } else if (toolType == "assistant") {
+ createEditAssistantsProperties();
+
+ } else if (toolType == "shifttrace") {
+ createShiftTraceProperties();
+
} else {
- // Other tools or unrecognized tool
- QLabel *comingSoon = new QLabel(tr("Properties for this tool - Coming soon!"), this);
- comingSoon->setAlignment(Qt::AlignCenter);
- comingSoon->setStyleSheet("color: gray; padding: 20px;");
- m_propertiesLayout->addWidget(comingSoon);
- }
-
- // Add stretch at the end
+ TTool *t = getCurrentTool();
+ TPropertyGroup *g0 = t ? t->getProperties(0) : nullptr;
+ TPropertyGroup *g1 = t ? t->getProperties(1) : nullptr;
+ const bool sameGroup = (g0 && g1 && g0 == g1);
+
+ createGenericProperties(0);
+
+ if (!sameGroup && g1 && g1->getPropertyCount() > 0) {
+ QFrame *sep = new QFrame(this);
+ sep->setFrameShape(QFrame::HLine);
+ sep->setFrameShadow(QFrame::Sunken);
+ sep->setStyleSheet("color: #555; margin: 4px 0;");
+ m_propertiesLayout->addWidget(sep);
+ createGenericProperties(1);
+ }
+ }
+
+ if (propertyWidgetCount() == 0) showEmptyPropertiesHint(toolId);
+
+ attachAllPropertySyncListeners();
+
+ if (toolType == QStringLiteral("shifttrace")) updateShiftTraceWidgets();
+
m_propertiesLayout->addStretch(1);
}
@@ -421,10 +932,70 @@ void ToolPropertiesPanel::clearProperties() {
QLayoutItem *item;
while ((item = m_propertiesLayout->takeAt(0)) != nullptr) {
if (item->widget()) {
- delete item->widget();
+ QWidget *w = item->widget();
+ // Ruler measurements are owned by the panel, not rebuilt each refresh.
+ if (w == m_rulerOptionsBox) {
+ if (m_rulerOptionsBoxRegistered) {
+ if (auto *ruler = dynamic_cast<RulerTool *>(
+ TTool::getTool("T_Ruler", TTool::ToonzImage)))
+ ruler->unsetToolOptionsBox(m_rulerOptionsBox);
+ m_rulerOptionsBoxRegistered = false;
+ }
+ m_rulerOptionsBox->hide();
+ m_rulerOptionsBox->setParent(this);
+ delete item;
+ continue;
+ }
+ delete w;
}
delete item;
}
+
+ m_plasticModeContainer = nullptr;
+ m_plasticModeLayout = nullptr;
+ m_plasticSkelPicker = nullptr;
+ m_plasticVertexWidget = nullptr;
+ m_plasticVisibleMode = -1;
+
+ m_animateColumnWidget = nullptr;
+ m_animateSplineRowWidgets.clear();
+ m_animateXYRowWidgets.clear();
+ m_animateMeasuredFields.clear();
+ m_animateAxisFieldsHost = nullptr;
+ m_animateAxisStack = nullptr;
+ m_animateAxisStackPages.clear();
+ m_animateAllModeHost = nullptr;
+ m_animateAllModeLayout = nullptr;
+ m_animateSectionsInAllLayout = false;
+ m_animateAxisSectionHeaders.clear();
+ m_animateAxisSections.clear();
+ m_animateVisibleAxis = -1;
+ m_animateScaleHField = nullptr;
+ m_animateScaleVField = nullptr;
+
+ m_selScaleX = m_selScaleY = nullptr;
+ m_selRotation = nullptr;
+ m_selMoveX = m_selMoveY = nullptr;
+ m_selThick = nullptr;
+ m_selScaleLink = nullptr;
+ m_selFlipH = m_selFlipV = nullptr;
+ m_selRotL = m_selRotR = nullptr;
+ m_selHLabel = m_selVLabel = nullptr;
+ m_selXLabel = m_selYLabel = nullptr;
+ m_selScaleLinkIcon = nullptr;
+ m_typeStyleWidget = nullptr;
+
+ m_shiftTraceGhostPicker = nullptr;
+ m_shiftTraceNoShiftChk = nullptr;
+ m_shiftTraceNoShiftIconBtn = nullptr;
+ m_shiftTraceResetShiftIconBtn = nullptr;
+ m_shiftTraceResetPrevBtn = nullptr;
+ m_shiftTraceResetFollowingBtn = nullptr;
+
+ if (TTool *tool = getCurrentTool()) {
+ if (auto *plastic = dynamic_cast<PlasticTool *>(tool))
+ disconnect(plastic, nullptr, this, nullptr);
+ }
}
//-----------------------------------------------------------------------------
@@ -434,55 +1005,64 @@ void ToolPropertiesPanel::clearProperties() {
void ToolPropertiesPanel::createBrushProperties() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Create brush properties in STRICT order per level type:
- // Vector: Size/Accuracy/Smooth/DrawOrder/BreakAngles/Pressure/Range/Snap/Assistants/Cap/Join/Miter
- // Toonz Raster: Size/Hardness/Smooth/DrawOrder/LockAlpha/PencilMode/Assistants/Pressure
+ // Vector:
+ // Size/Accuracy/Smooth/DrawOrder/BreakAngles/Pressure/Range/Snap/Assistants/Cap/Join/Miter
+ // Toonz Raster:
+ // Size/Hardness/Smooth/DrawOrder/LockAlpha/PencilMode/Assistants/Pressure
// Raster: Size/Hardness/Opacity/LockAlpha/Pressure/Assistants
-
+
// === SIZE (all levels) ===
createSizeProperty();
-
+
// === VECTOR: Accuracy ===
createAccuracyProperty();
-
+
// === RASTER/TOONZ RASTER: Hardness ===
createHardnessProperty();
-
+
// === RASTER ONLY: Opacity (double slider) ===
createOpacityProperty();
-
+
// === VECTOR & TOONZ RASTER: Smooth ===
createSmoothProperty();
-
+
// === VECTOR & TOONZ RASTER: Draw Order ===
createDrawOrderProperty();
-
+
// === RASTER & TOONZ RASTER: Lock Alpha ===
createLockAlphaProperty();
-
+
// === TOONZ RASTER: Pencil Mode ===
createPencilModeProperty();
-
+
// === VECTOR: Break Angles ===
createBreakAnglesProperty();
-
- // === PRESSURE (all levels, but different positions) ===
- createPressureProperty();
-
+
+ // Toonz Raster (normal brush): Assistants then Pressure — matches TOB.
+ const bool toonzRasterNormalBrush =
+ m_currentToolType == QStringLiteral("brush") &&
+ (tool->getTargetType() & TTool::ToonzImage);
+
+ if (toonzRasterNormalBrush) {
+ createAssistantsProperty();
+ createPressureProperty();
+ } else {
+ createPressureProperty();
+ createAssistantsProperty();
+ }
+
// === VECTOR: Frame Range (Off/Linear/In/Out/In&Out) ===
createFrameRangeProperty();
-
+
// === VECTOR: Snap ===
createSnapProperty();
createSnapSensitivityProperty();
-
- // === ASSISTANTS (all levels) ===
- createAssistantsProperty();
-
+
// === VECTOR: Cap/Join/Miter ===
createCapProperty();
createJoinProperty();
@@ -496,36 +1076,36 @@ void ToolPropertiesPanel::createBrushProperties() {
void ToolPropertiesPanel::createMyPaintBrushProperties() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// MyPaint brushes use Modifier* properties to control the brush
// These are single-value properties (not min/max pairs)
//
// Raster MyPaint (mypaint):
- // Size (ModifierSize) / Opacity (ModifierOpacity) / Eraser (ModifierEraser) /
- // Lock Alpha (ModifierLockAlpha) / Pressure / Assistants
+ // Size (ModifierSize) / Opacity (ModifierOpacity) / Eraser (ModifierEraser)
+ // / Lock Alpha (ModifierLockAlpha) / Pressure / Assistants
//
// Toonz Raster MyPaint (mypainttnz):
- // Size (ModifierSize) / Smooth / Lock Alpha (ModifierLockAlpha) /
+ // Size (ModifierSize) / Smooth / Lock Alpha (ModifierLockAlpha) /
// Assistants / Pressure
-
+
QString toolType = m_currentToolType;
-
+
if (toolType == "mypaint") {
// === RASTER MYPAINT (in order as specified) ===
- createMyPaintSizeProperty(); // ModifierSize slider
- createMyPaintOpacityProperty(); // ModifierOpacity slider
- createModifierEraserProperty(); // Eraser checkbox
- createModifierLockAlphaProperty(); // Lock Alpha checkbox
- createPressureProperty(); // Pressure checkbox
- createAssistantsProperty(); // Assistants checkbox
+ createMyPaintSizeProperty(); // ModifierSize slider
+ createMyPaintOpacityProperty(); // ModifierOpacity slider
+ createModifierEraserProperty(); // Eraser checkbox
+ createModifierLockAlphaProperty(); // Lock Alpha checkbox
+ createPressureProperty(); // Pressure checkbox
+ createAssistantsProperty(); // Assistants checkbox
// Note: Preset is excluded as per requirements
} else if (toolType == "mypainttnz") {
// === TOONZ RASTER MYPAINT (in order as specified) ===
- createMyPaintSizeProperty(); // ModifierSize slider
- createSmoothProperty(); // Smooth slider
+ createMyPaintSizeProperty(); // ModifierSize slider
+ createSmoothProperty(); // Smooth slider
createModifierEraserProperty();
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
@@ -539,9 +1119,9 @@ void ToolPropertiesPanel::createMyPaintBrushProperties() {
}
break;
}
- createModifierLockAlphaProperty(); // Lock Alpha checkbox
- createAssistantsProperty(); // Assistants checkbox
- createPressureProperty(); // Pressure checkbox
+ createModifierLockAlphaProperty(); // Lock Alpha checkbox
+ createAssistantsProperty(); // Assistants checkbox
+ createPressureProperty(); // Pressure checkbox
// Note: Preset is excluded as per requirements
// Note: NO Draw Order, NO Pencil Mode for MyPaint
}
@@ -550,102 +1130,105 @@ void ToolPropertiesPanel::createMyPaintBrushProperties() {
void ToolPropertiesPanel::createSizeProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Size property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Size:" || propName == "Size" || propName == "Thickness:" || propName == "Thickness") {
+
+ if (propName == "Size:" || propName == "Size" || propName == "Thickness:" ||
+ propName == "Thickness") {
// Try TDoublePairProperty first (min/max)
- TDoublePairProperty *pairProp = dynamic_cast<TDoublePairProperty*>(prop);
+ TDoublePairProperty *pairProp = dynamic_cast<TDoublePairProperty *>(prop);
if (pairProp) {
createDoublePairSlider(tr("Size"), pairProp, propName);
return;
}
-
+
// Try TIntPairProperty (min/max)
- TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty*>(prop);
+ TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty *>(prop);
if (intPairProp) {
createIntPairSlider(tr("Size"), intPairProp, propName);
return;
}
-
+
// Try TDoubleProperty
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
+
// Create widget
- QWidget *container = new QWidget(this);
+ QWidget *container = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label + value display
QHBoxLayout *headerLayout = new QHBoxLayout();
- QLabel *nameLabel = new QLabel(tr("Size"), container);
- QLabel *valueLabel = new QLabel(QString::number(value, 'f', 1), container);
+ QLabel *nameLabel = new QLabel(tr("Size"), container);
+ QLabel *valueLabel =
+ new QLabel(QString::number(value, 'f', 1), container);
valueLabel->setAlignment(Qt::AlignRight);
valueLabel->setMinimumWidth(50);
headerLayout->addWidget(nameLabel);
headerLayout->addStretch();
headerLayout->addWidget(valueLabel);
layout->addLayout(headerLayout);
-
+
// Slider
QSlider *slider = new QSlider(Qt::Horizontal, container);
slider->setMinimum(static_cast<int>(min * 10));
slider->setMaximum(static_cast<int>(max * 10));
slider->setValue(static_cast<int>(value * 10));
layout->addWidget(slider);
-
+
// Connect slider to value label
connect(slider, &QSlider::valueChanged, [valueLabel](int val) {
valueLabel->setText(QString::number(val / 10.0, 'f', 1));
});
-
+
// Connect slider to tool property
- connect(slider, &QSlider::valueChanged, [this, doubleProp, propName](int val) {
- double newValue = val / 10.0;
- doubleProp->setValue(newValue);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [this, doubleProp, propName](int val) {
+ double newValue = val / 10.0;
+ doubleProp->setValue(newValue);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
m_propertiesLayout->addWidget(container);
return;
}
-
+
// Try TIntProperty
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
+
// Create widget
- QWidget *container = new QWidget(this);
+ QWidget *container = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label + value display
QHBoxLayout *headerLayout = new QHBoxLayout();
- QLabel *nameLabel = new QLabel(tr("Size"), container);
+ QLabel *nameLabel = new QLabel(tr("Size"), container);
QLabel *valueLabel = new QLabel(QString::number(value), container);
valueLabel->setAlignment(Qt::AlignRight);
valueLabel->setMinimumWidth(50);
@@ -653,32 +1236,33 @@ void ToolPropertiesPanel::createSizeProperty() {
headerLayout->addStretch();
headerLayout->addWidget(valueLabel);
layout->addLayout(headerLayout);
-
+
// Slider
QSlider *slider = new QSlider(Qt::Horizontal, container);
slider->setMinimum(min);
slider->setMaximum(max);
slider->setValue(value);
layout->addWidget(slider);
-
+
// Connect slider to value label
connect(slider, &QSlider::valueChanged, [valueLabel](int val) {
valueLabel->setText(QString::number(val));
});
-
+
// Connect slider to tool property
- connect(slider, &QSlider::valueChanged, [this, intProp, propName](int val) {
- intProp->setValue(val);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [this, intProp, propName](int val) {
+ intProp->setValue(val);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
m_propertiesLayout->addWidget(container);
return;
}
@@ -689,36 +1273,38 @@ void ToolPropertiesPanel::createSizeProperty() {
void ToolPropertiesPanel::createHardnessProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Hardness property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Hardness:" || propName == "Hardness") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Hardness"), min, max, value, propName);
+
+ QWidget *widget =
+ createSliderWithLabel(tr("Hardness"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
-
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
- QWidget *widget = createDoubleSliderWithLabel(tr("Hardness"), min, max, value, propName);
+
+ QWidget *widget = createDoubleSliderWithLabel(tr("Hardness"), min, max,
+ value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -729,54 +1315,58 @@ void ToolPropertiesPanel::createHardnessProperty() {
void ToolPropertiesPanel::createOpacityProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Opacity property (Raster brush uses TDoublePairProperty)
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Opacity:" || propName == "Opacity") {
- // Try TDoublePairProperty first (Raster brush uses this for min/max opacity)
- TDoublePairProperty *doublePairProp = dynamic_cast<TDoublePairProperty*>(prop);
+ // Try TDoublePairProperty first (Raster brush uses this for min/max
+ // opacity)
+ TDoublePairProperty *doublePairProp =
+ dynamic_cast<TDoublePairProperty *>(prop);
if (doublePairProp) {
createDoublePairSlider(tr("Opacity"), doublePairProp, propName);
// Note: createDoublePairSlider already adds spacing
return;
}
-
+
// Try IntPairProperty (min/max)
- TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty*>(prop);
+ TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty *>(prop);
if (intPairProp) {
createIntPairSlider(tr("Opacity"), intPairProp, propName);
return;
}
-
+
// Try single IntProperty
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Opacity"), min, max, value, propName);
+
+ QWidget *widget =
+ createSliderWithLabel(tr("Opacity"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
m_propertiesLayout->addSpacing(10);
return;
}
-
+
// Try single DoubleProperty
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
- QWidget *widget = createDoubleSliderWithLabel(tr("Opacity"), min, max, value, propName);
+
+ QWidget *widget = createDoubleSliderWithLabel(tr("Opacity"), min, max,
+ value, propName);
m_propertiesLayout->addWidget(widget);
m_propertiesLayout->addSpacing(10);
return;
@@ -788,21 +1378,21 @@ void ToolPropertiesPanel::createOpacityProperty() {
void ToolPropertiesPanel::createLockAlphaProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Lock Alpha property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Lock Alpha" || propName == "LockAlpha") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Lock Alpha"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -814,21 +1404,22 @@ void ToolPropertiesPanel::createLockAlphaProperty() {
void ToolPropertiesPanel::createPencilModeProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Pencil Mode property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Pencil" || propName == "PencilMode" || propName == "Pencil Mode") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+
+ if (propName == "Pencil" || propName == "PencilMode" ||
+ propName == "Pencil Mode") {
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Pencil Mode"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -840,19 +1431,20 @@ void ToolPropertiesPanel::createPencilModeProperty() {
void ToolPropertiesPanel::createDrawOrderProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Draw Order property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Draw Order:" || propName == "DrawOrder" || propName == "Draw Order") {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
+
+ if (propName == "Draw Order:" || propName == "DrawOrder" ||
+ propName == "Draw Order") {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
if (enumProp) {
QStringList items;
const TEnumProperty::Items &enumItems = enumProp->getItems();
@@ -860,8 +1452,9 @@ void ToolPropertiesPanel::createDrawOrderProperty() {
items << enumItems[j].UIName;
}
int currentIndex = enumProp->getIndex();
-
- QWidget *widget = createCollapsibleEnum(tr("Draw Order"), items, currentIndex, propName);
+
+ QWidget *widget = createCollapsibleEnum(tr("Draw Order"), items,
+ currentIndex, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -872,42 +1465,29 @@ void ToolPropertiesPanel::createDrawOrderProperty() {
void ToolPropertiesPanel::createCapProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(1); // prop[1] for Cap/Join
if (!props) {
// Try getProperties(0) if group 1 doesn't exist
props = tool->getProperties(0);
if (!props) return;
}
-
- // Cap icon names corresponding to the enum items
- QStringList capIcons;
- capIcons << "butt_cap" << "round_cap" << "projecting_cap";
-
+
+ // Cap icon names are stored on TEnumProperty items (or resolved from values).
// Search for Cap Style property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Cap:" || propName == "Cap" || propName == "CapStyle" || propName == "Cap Style:" || propName == "Cap Style") {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- QStringList items;
- const TEnumProperty::Items &enumItems = enumProp->getItems();
- for (int j = 0; j < enumItems.size(); ++j) {
- items << enumItems[j].UIName;
- }
- int currentIndex = enumProp->getIndex();
-
- // Only create widget if we have items
- if (items.size() > 0) {
- // Use standard collapsible enum but add icons if m_showIcons is true
- QWidget *widget = createCollapsibleEnumWithIcons(tr("Cap"), items, currentIndex, propName, capIcons);
- widget->setProperty("propGroup", 1); // Cap is in group 1
- m_propertiesLayout->addWidget(widget);
- }
+
+ if (propName == "Cap:" || propName == "Cap" || propName == "CapStyle" ||
+ propName == "Cap Style:" || propName == "Cap Style") {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (enumProp && enumProp->getItems().size() > 0) {
+ QWidget *widget =
+ createCollapsibleEnumForProperty(tr("Cap"), enumProp, propName, 1);
+ if (widget) m_propertiesLayout->addWidget(widget);
return;
}
}
@@ -917,42 +1497,29 @@ void ToolPropertiesPanel::createCapProperty() {
void ToolPropertiesPanel::createJoinProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(1); // prop[1] for Cap/Join
if (!props) {
// Try getProperties(0) if group 1 doesn't exist
props = tool->getProperties(0);
if (!props) return;
}
-
- // Join icon names corresponding to the enum items
- QStringList joinIcons;
- joinIcons << "miter_join" << "round_join" << "bevel_join";
-
- // Search for Join Style property
+
+ // Join icon names are stored on TEnumProperty items (or resolved from
+ // values). Search for Join Style property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Join:" || propName == "Join" || propName == "JoinStyle" || propName == "Join Style:" || propName == "Join Style") {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- QStringList items;
- const TEnumProperty::Items &enumItems = enumProp->getItems();
- for (int j = 0; j < enumItems.size(); ++j) {
- items << enumItems[j].UIName;
- }
- int currentIndex = enumProp->getIndex();
-
- // Only create widget if we have items
- if (items.size() > 0) {
- // Use collapsible enum with icons if m_showIcons is true
- QWidget *widget = createCollapsibleEnumWithIcons(tr("Join"), items, currentIndex, propName, joinIcons);
- widget->setProperty("propGroup", 1); // Join is in group 1
- m_propertiesLayout->addWidget(widget);
- }
+
+ if (propName == "Join:" || propName == "Join" || propName == "JoinStyle" ||
+ propName == "Join Style:" || propName == "Join Style") {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (enumProp && enumProp->getItems().size() > 0) {
+ QWidget *widget =
+ createCollapsibleEnumForProperty(tr("Join"), enumProp, propName, 1);
+ if (widget) m_propertiesLayout->addWidget(widget);
return;
}
}
@@ -962,36 +1529,38 @@ void ToolPropertiesPanel::createJoinProperty() {
void ToolPropertiesPanel::createSmoothProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Smooth property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Smooth:" || propName == "Smooth") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Smooth"), min, max, value, propName);
+
+ QWidget *widget =
+ createSliderWithLabel(tr("Smooth"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
-
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
- QWidget *widget = createDoubleSliderWithLabel(tr("Smooth"), min, max, value, propName);
+
+ QWidget *widget = createDoubleSliderWithLabel(tr("Smooth"), min, max,
+ value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1002,21 +1571,21 @@ void ToolPropertiesPanel::createSmoothProperty() {
void ToolPropertiesPanel::createAssistantsProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Assistants property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Assistants" || propName == "Assistant") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Assistants"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1028,21 +1597,22 @@ void ToolPropertiesPanel::createAssistantsProperty() {
void ToolPropertiesPanel::createPressureProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Search for Pressure property
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Pressure" || propName == "PressureSensitivity" || propName == "Pressure Sensitivity") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+
+ if (propName == "Pressure" || propName == "PressureSensitivity" ||
+ propName == "Pressure Sensitivity") {
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Pressure"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1054,35 +1624,37 @@ void ToolPropertiesPanel::createPressureProperty() {
void ToolPropertiesPanel::createAccuracyProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Accuracy:" || propName == "Accuracy") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Accuracy"), min, max, value, propName);
+
+ QWidget *widget =
+ createSliderWithLabel(tr("Accuracy"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
-
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
- QWidget *widget = createDoubleSliderWithLabel(tr("Accuracy"), min, max, value, propName);
+
+ QWidget *widget = createDoubleSliderWithLabel(tr("Accuracy"), min, max,
+ value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1093,20 +1665,21 @@ void ToolPropertiesPanel::createAccuracyProperty() {
void ToolPropertiesPanel::createBreakAnglesProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Break" || propName == "Break Angles" || propName == "Break:" || propName == "BreakAngles") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+
+ if (propName == "Break" || propName == "Break Angles" ||
+ propName == "Break:" || propName == "BreakAngles") {
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Break Angles"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1118,19 +1691,20 @@ void ToolPropertiesPanel::createBreakAnglesProperty() {
void ToolPropertiesPanel::createFrameRangeProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Frame Range:" || propName == "Frame Range" || propName == "FrameRange" ||
- propName == "Range:" || propName == "Range") {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
+
+ if (propName == "Frame Range:" || propName == "Frame Range" ||
+ propName == "FrameRange" || propName == "Range:" ||
+ propName == "Range") {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
if (enumProp) {
QStringList items;
const TEnumProperty::Items &enumItems = enumProp->getItems();
@@ -1138,8 +1712,9 @@ void ToolPropertiesPanel::createFrameRangeProperty() {
items << enumItems[j].UIName;
}
int currentIndex = enumProp->getIndex();
-
- QWidget *widget = createCollapsibleEnum(tr("Frame Range"), items, currentIndex, propName);
+
+ QWidget *widget = createCollapsibleEnum(tr("Frame Range"), items,
+ currentIndex, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1150,20 +1725,20 @@ void ToolPropertiesPanel::createFrameRangeProperty() {
void ToolPropertiesPanel::createSnapProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "Snap" || propName == "Snap:" || propName == "AutoFill") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Snap"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1175,19 +1750,20 @@ void ToolPropertiesPanel::createSnapProperty() {
void ToolPropertiesPanel::createSnapSensitivityProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
// Property name is "Sensitivity:" (not "Snap Sensitivity")
- if (propName == "Sensitivity:" || propName == "Sensitivity" || propName == "SnapSensitivity") {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
+ if (propName == "Sensitivity:" || propName == "Sensitivity" ||
+ propName == "SnapSensitivity") {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
if (enumProp) {
// Use collapsible enum like Cap/Join for reliable synchronization
QStringList items;
@@ -1196,9 +1772,10 @@ void ToolPropertiesPanel::createSnapSensitivityProperty() {
items << enumItems[j].UIName;
}
int currentIndex = enumProp->getIndex();
-
+
if (items.size() > 0) {
- QWidget *widget = createCollapsibleEnum(tr("Sensitivity"), items, currentIndex, propName);
+ QWidget *widget = createCollapsibleEnum(tr("Sensitivity"), items,
+ currentIndex, propName);
widget->setProperty("propGroup", 0);
m_propertiesLayout->addWidget(widget);
}
@@ -1211,35 +1788,38 @@ void ToolPropertiesPanel::createSnapSensitivityProperty() {
void ToolPropertiesPanel::createMiterProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(1); // prop[1] for Cap/Join/Miter
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
- if (propName == "Miter:" || propName == "Miter" || propName == "MiterJoinLimit") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+
+ if (propName == "Miter:" || propName == "Miter" ||
+ propName == "MiterJoinLimit") {
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Miter"), min, max, value, propName);
+
+ QWidget *widget =
+ createSliderWithLabel(tr("Miter"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
-
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first;
- double max = doubleProp->getRange().second;
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
double value = doubleProp->getValue();
-
- QWidget *widget = createDoubleSliderWithLabel(tr("Miter"), min, max, value, propName);
+
+ QWidget *widget =
+ createDoubleSliderWithLabel(tr("Miter"), min, max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1250,24 +1830,25 @@ void ToolPropertiesPanel::createMiterProperty() {
void ToolPropertiesPanel::createModifierSizeProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierSize" || propName == "Modifier Size") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Modifier Size"), min, max, value, propName);
+
+ QWidget *widget = createSliderWithLabel(tr("Modifier Size"), min, max,
+ value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1278,24 +1859,25 @@ void ToolPropertiesPanel::createModifierSizeProperty() {
void ToolPropertiesPanel::createModifierOpacityProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierOpacity" || propName == "Modifier Opacity") {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
if (intProp) {
- int min = intProp->getRange().first;
- int max = intProp->getRange().second;
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
int value = intProp->getValue();
-
- QWidget *widget = createSliderWithLabel(tr("Modifier Opacity"), min, max, value, propName);
+
+ QWidget *widget = createSliderWithLabel(tr("Modifier Opacity"), min,
+ max, value, propName);
m_propertiesLayout->addWidget(widget);
return;
}
@@ -1306,20 +1888,20 @@ void ToolPropertiesPanel::createModifierOpacityProperty() {
void ToolPropertiesPanel::createModifierEraserProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierEraser") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Eraser"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1331,20 +1913,20 @@ void ToolPropertiesPanel::createModifierEraserProperty() {
void ToolPropertiesPanel::createModifierLockAlphaProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierLockAlpha" || propName == "Lock Alpha") {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
if (boolProp) {
- bool value = boolProp->getValue();
+ bool value = boolProp->getValue();
QWidget *widget = createCheckBox(tr("Lock Alpha"), value, propName);
m_propertiesLayout->addWidget(widget);
return;
@@ -1360,40 +1942,42 @@ void ToolPropertiesPanel::createModifierLockAlphaProperty() {
void ToolPropertiesPanel::createMyPaintSizeProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Find ModifierSize property (MyPaint uses this for size)
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierSize") {
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first; // -3.0
- double max = doubleProp->getRange().second; // 3.0
+ double min = doubleProp->getRange().first; // -3.0
+ double max = doubleProp->getRange().second; // 3.0
double value = doubleProp->getValue();
-
+
// Create widget
QWidget *container = new QWidget(this);
container->setProperty("propName", QString::fromStdString(propName));
container->setProperty("propGroup", 0);
- container->setProperty("valueFactor", 100); // MyPaint Size uses factor 100
+ container->setProperty("valueFactor",
+ 100); // MyPaint Size uses factor 100
container->setProperty("valueDecimals", 2); // Display 2 decimal places
-
+
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label (respect m_showLabels) + value display
QHBoxLayout *headerLayout = new QHBoxLayout();
- QLabel *nameLabel = new QLabel(tr("Size"), container);
+ QLabel *nameLabel = new QLabel(tr("Size"), container);
nameLabel->setVisible(m_showLabels);
- QLabel *valueLabel = new QLabel(QString::number(value, 'f', 2), container);
+ QLabel *valueLabel =
+ new QLabel(QString::number(value, 'f', 2), container);
valueLabel->setAlignment(Qt::AlignRight);
valueLabel->setMinimumWidth(50);
valueLabel->setVisible(m_showLabels);
@@ -1401,12 +1985,12 @@ void ToolPropertiesPanel::createMyPaintSizeProperty() {
headerLayout->addStretch();
headerLayout->addWidget(valueLabel);
layout->addLayout(headerLayout);
-
+
// Slider + numeric field layout
QHBoxLayout *sliderLayout = new QHBoxLayout();
sliderLayout->setMargin(0);
sliderLayout->setSpacing(5);
-
+
// Numeric field (respect m_showNumericFields)
QLineEdit *lineEdit = new QLineEdit(container);
lineEdit->setText(QString::number(value, 'f', 2));
@@ -1414,26 +1998,27 @@ void ToolPropertiesPanel::createMyPaintSizeProperty() {
lineEdit->setMaximumWidth(60);
lineEdit->setValidator(new QDoubleValidator(min, max, 2, lineEdit));
lineEdit->setVisible(m_showNumericFields);
-
+
// Slider (range -3.0 to 3.0, multiply by 100 for integer slider)
QSlider *slider = new QSlider(Qt::Horizontal, container);
slider->setMinimum(static_cast<int>(min * 100));
slider->setMaximum(static_cast<int>(max * 100));
slider->setValue(static_cast<int>(value * 100));
-
+
sliderLayout->addWidget(lineEdit);
sliderLayout->addWidget(slider);
layout->addLayout(sliderLayout);
-
+
// Connect slider to value label and line edit
- connect(slider, &QSlider::valueChanged, [valueLabel, lineEdit](int val) {
- double dVal = val / 100.0;
- valueLabel->setText(QString::number(dVal, 'f', 2));
- lineEdit->blockSignals(true);
- lineEdit->setText(QString::number(dVal, 'f', 2));
- lineEdit->blockSignals(false);
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [valueLabel, lineEdit](int val) {
+ double dVal = val / 100.0;
+ valueLabel->setText(QString::number(dVal, 'f', 2));
+ lineEdit->blockSignals(true);
+ lineEdit->setText(QString::number(dVal, 'f', 2));
+ lineEdit->blockSignals(false);
+ });
+
// Connect line edit to slider
connect(lineEdit, &QLineEdit::editingFinished, [slider, lineEdit]() {
double val = lineEdit->text().toDouble();
@@ -1441,35 +2026,37 @@ void ToolPropertiesPanel::createMyPaintSizeProperty() {
slider->setValue(static_cast<int>(val * 100));
slider->blockSignals(false);
});
-
+
// Connect slider to tool property
- connect(slider, &QSlider::valueChanged, [this, doubleProp, propName](int val) {
- double newValue = val / 100.0;
- doubleProp->setValue(newValue);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [this, doubleProp, propName](int val) {
+ double newValue = val / 100.0;
+ doubleProp->setValue(newValue);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
// Connect line edit to tool property
- connect(lineEdit, &QLineEdit::editingFinished, [this, doubleProp, lineEdit, propName]() {
- double newValue = lineEdit->text().toDouble();
- doubleProp->setValue(newValue);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(lineEdit, &QLineEdit::editingFinished,
+ [this, doubleProp, lineEdit, propName]() {
+ double newValue = lineEdit->text().toDouble();
+ doubleProp->setValue(newValue);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
m_propertiesLayout->addWidget(container);
return;
}
@@ -1480,40 +2067,42 @@ void ToolPropertiesPanel::createMyPaintSizeProperty() {
void ToolPropertiesPanel::createMyPaintOpacityProperty() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
+
TPropertyGroup *props = tool->getProperties(0);
if (!props) return;
-
+
// Find ModifierOpacity property (MyPaint uses this for opacity)
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *prop = props->getProperty(i);
if (!prop) continue;
-
+
std::string propName = prop->getName();
-
+
if (propName == "ModifierOpacity") {
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
if (doubleProp) {
- double min = doubleProp->getRange().first; // 0
- double max = doubleProp->getRange().second; // 100
+ double min = doubleProp->getRange().first; // 0
+ double max = doubleProp->getRange().second; // 100
double value = doubleProp->getValue();
-
+
// Create widget
QWidget *container = new QWidget(this);
container->setProperty("propName", QString::fromStdString(propName));
container->setProperty("propGroup", 0);
- container->setProperty("valueFactor", 1); // MyPaint Opacity uses factor 1 (direct value)
+ container->setProperty(
+ "valueFactor", 1); // MyPaint Opacity uses factor 1 (direct value)
container->setProperty("valueDecimals", 0); // Display as integer
-
+
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label (respect m_showLabels) + value display
QHBoxLayout *headerLayout = new QHBoxLayout();
- QLabel *nameLabel = new QLabel(tr("Opacity"), container);
+ QLabel *nameLabel = new QLabel(tr("Opacity"), container);
nameLabel->setVisible(m_showLabels);
- QLabel *valueLabel = new QLabel(QString::number(static_cast<int>(value)), container);
+ QLabel *valueLabel =
+ new QLabel(QString::number(static_cast<int>(value)), container);
valueLabel->setAlignment(Qt::AlignRight);
valueLabel->setMinimumWidth(50);
valueLabel->setVisible(m_showLabels);
@@ -1521,38 +2110,40 @@ void ToolPropertiesPanel::createMyPaintOpacityProperty() {
headerLayout->addStretch();
headerLayout->addWidget(valueLabel);
layout->addLayout(headerLayout);
-
+
// Slider + numeric field layout
QHBoxLayout *sliderLayout = new QHBoxLayout();
sliderLayout->setMargin(0);
sliderLayout->setSpacing(5);
-
+
// Numeric field (respect m_showNumericFields)
QLineEdit *lineEdit = new QLineEdit(container);
lineEdit->setText(QString::number(static_cast<int>(value)));
lineEdit->setAlignment(Qt::AlignRight);
lineEdit->setMaximumWidth(60);
- lineEdit->setValidator(new QIntValidator(static_cast<int>(min), static_cast<int>(max), lineEdit));
+ lineEdit->setValidator(new QIntValidator(
+ static_cast<int>(min), static_cast<int>(max), lineEdit));
lineEdit->setVisible(m_showNumericFields);
-
+
// Slider (range 0 to 100)
QSlider *slider = new QSlider(Qt::Horizontal, container);
slider->setMinimum(static_cast<int>(min));
slider->setMaximum(static_cast<int>(max));
slider->setValue(static_cast<int>(value));
-
+
sliderLayout->addWidget(lineEdit);
sliderLayout->addWidget(slider);
layout->addLayout(sliderLayout);
-
+
// Connect slider to value label and line edit
- connect(slider, &QSlider::valueChanged, [valueLabel, lineEdit](int val) {
- valueLabel->setText(QString::number(val));
- lineEdit->blockSignals(true);
- lineEdit->setText(QString::number(val));
- lineEdit->blockSignals(false);
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [valueLabel, lineEdit](int val) {
+ valueLabel->setText(QString::number(val));
+ lineEdit->blockSignals(true);
+ lineEdit->setText(QString::number(val));
+ lineEdit->blockSignals(false);
+ });
+
// Connect line edit to slider
connect(lineEdit, &QLineEdit::editingFinished, [slider, lineEdit]() {
int val = lineEdit->text().toInt();
@@ -1560,35 +2151,38 @@ void ToolPropertiesPanel::createMyPaintOpacityProperty() {
slider->setValue(val);
slider->blockSignals(false);
});
-
+
// Connect slider to tool property
- connect(slider, &QSlider::valueChanged, [this, doubleProp, propName](int val) {
- double newValue = static_cast<double>(val);
- doubleProp->setValue(newValue);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(slider, &QSlider::valueChanged,
+ [this, doubleProp, propName](int val) {
+ double newValue = static_cast<double>(val);
+ doubleProp->setValue(newValue);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
// Connect line edit to tool property
- connect(lineEdit, &QLineEdit::editingFinished, [this, doubleProp, lineEdit, propName]() {
- double newValue = static_cast<double>(lineEdit->text().toInt());
- doubleProp->setValue(newValue);
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(lineEdit, &QLineEdit::editingFinished,
+ [this, doubleProp, lineEdit, propName]() {
+ double newValue =
+ static_cast<double>(lineEdit->text().toInt());
+ doubleProp->setValue(newValue);
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
m_propertiesLayout->addWidget(container);
return;
}
@@ -1597,227 +2191,683 @@ void ToolPropertiesPanel::createMyPaintOpacityProperty() {
}
//-----------------------------------------------------------------------------
-// Helper Methods for UI Creation
+// Collapsible field metrics — shared by Plastic TPP capsules and mode options.
//-----------------------------------------------------------------------------
-QWidget* ToolPropertiesPanel::createSliderWithLabel(const QString &label, int min, int max,
- int value, const std::string &propName) {
- QWidget *container = new QWidget(this);
- container->setProperty("propName", QString::fromStdString(propName));
- container->setProperty("propGroup", 0);
-
- QVBoxLayout *layout = new QVBoxLayout(container);
- layout->setMargin(0);
- layout->setSpacing(3);
-
- // Label (respect m_showLabels)
- QLabel *nameLabel = new QLabel(label, container);
- nameLabel->setVisible(m_showLabels);
- layout->addWidget(nameLabel);
-
- // Slider with numeric fields
- QHBoxLayout *sliderLayout = new QHBoxLayout();
- sliderLayout->setMargin(0);
- sliderLayout->setSpacing(5);
-
- // Numeric field (QLineEdit to avoid arrows, respect m_showNumericFields)
- QLineEdit *lineEdit = new QLineEdit(container);
- lineEdit->setText(QString::number(value));
- lineEdit->setFixedWidth(45); // Reduce size
- lineEdit->setAlignment(Qt::AlignRight);
- lineEdit->setVisible(m_showNumericFields);
- QIntValidator *validator = new QIntValidator(min, max, lineEdit);
- lineEdit->setValidator(validator);
- sliderLayout->addWidget(lineEdit);
-
- // Slider
- QSlider *slider = new QSlider(Qt::Horizontal, container);
- slider->setMinimum(min);
- slider->setMaximum(max);
- slider->setValue(value);
- sliderLayout->addWidget(slider, 1); // Stretch to take available space
-
- layout->addLayout(sliderLayout);
-
- // Connect slider and lineEdit together
- connect(slider, &QSlider::valueChanged, [lineEdit](int val) {
- lineEdit->setText(QString::number(val));
- });
- connect(lineEdit, &QLineEdit::editingFinished, [slider, lineEdit]() {
- slider->setValue(lineEdit->text().toInt());
- });
-
- // Connect to tool property
- connect(slider, &QSlider::valueChanged, [this, propName](int val) {
- TTool *tool = getCurrentTool();
- if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(0);
- if (!props) return;
-
- for (int i = 0; i < props->getPropertyCount(); ++i) {
- TProperty *prop = props->getProperty(i);
- if (prop && prop->getName() == propName) {
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
- if (intProp) {
- intProp->setValue(val);
- tool->onPropertyChanged(propName);
- if (m_toolHandle) m_toolHandle->notifyToolChanged();
- }
- break;
- }
- }
- });
-
- return container;
+namespace CollapsibleStyle {
+constexpr int kToggleSize = 16;
+constexpr int kHeaderMarginH = 4;
+constexpr int kHeaderMarginV = 2;
+constexpr int kHeaderSpacing = 3;
+constexpr int kHeaderRowHeight = 24;
+constexpr int kContentLeftIndent = 25;
+constexpr int kContentRightMargin = 44; // aligns with skeleton [-][+] column
+constexpr int kHeaderRightSlot = 44;
+constexpr int kFieldHeight = 23;
+constexpr int kItemSpacing = 2;
+constexpr int kBlockGap = 6; // vertical gap between collapsible capsules
+constexpr int kSectionGap = 20; // gap between major plastic mode blocks
+constexpr int kAnimateRelayLabelW = 56; // compact aligned relay labels
+constexpr int kAnimateRelayFieldW = 58; // compact aligned relay fields
+} // namespace CollapsibleStyle
+
+namespace {
+
+// Match ToolOptionSlider / DoubleLineEdit slider scale and TOB field layout.
+constexpr int kTppDoubleSliderDecimals = 2;
+constexpr int kTppDoubleSliderFactor = 100000;
+
+int tppNumericLineEditWidth(const QFont &font, int minIntDigits,
+ int maxIntDigits, int decimalPlaces) {
+ const int textMaxLength =
+ std::max(minIntDigits, maxIntDigits) + decimalPlaces + 1;
+ return QFontMetrics(font).horizontalAdvance(
+ QString(textMaxLength, QChar('0'))) +
+ 5;
}
-QWidget* ToolPropertiesPanel::createDoubleSliderWithLabel(const QString &label, double min,
- double max, double value,
- const std::string &propName) {
- QWidget *container = new QWidget(this);
- container->setProperty("propName", QString::fromStdString(propName));
- container->setProperty("propGroup", 0);
-
- QVBoxLayout *layout = new QVBoxLayout(container);
- layout->setMargin(0);
- layout->setSpacing(3);
-
- // Label (respect m_showLabels)
- QLabel *nameLabel = new QLabel(label, container);
- nameLabel->setVisible(m_showLabels);
- layout->addWidget(nameLabel);
-
- // Slider with numeric field
- QHBoxLayout *sliderLayout = new QHBoxLayout();
- sliderLayout->setMargin(0);
- sliderLayout->setSpacing(5);
-
- // Numeric field (QLineEdit to avoid arrows, respect m_showNumericFields)
- QLineEdit *lineEdit = new QLineEdit(container);
- lineEdit->setText(QString::number(value, 'f', 1));
- lineEdit->setFixedWidth(50); // Reduce size
- lineEdit->setAlignment(Qt::AlignRight);
- lineEdit->setVisible(m_showNumericFields);
- QDoubleValidator *validator = new QDoubleValidator(min, max, 1, lineEdit);
- lineEdit->setValidator(validator);
- sliderLayout->addWidget(lineEdit);
-
- // Slider (scale to int)
- QSlider *slider = new QSlider(Qt::Horizontal, container);
- slider->setMinimum(static_cast<int>(min * 10));
- slider->setMaximum(static_cast<int>(max * 10));
- slider->setValue(static_cast<int>(value * 10));
- sliderLayout->addWidget(slider, 1); // Stretch to take available space
-
- layout->addLayout(sliderLayout);
-
- // Connect slider and lineEdit together
+void styleTppIntLineEdit(QLineEdit *lineEdit, int minValue, int maxValue) {
+ lineEdit->setFixedWidth(tppNumericLineEditWidth(
+ lineEdit->font(), QString::number(minValue).length(),
+ QString::number(maxValue).length(), 0));
+ lineEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+}
+
+void styleTppDoubleLineEdit(QLineEdit *lineEdit, double minValue,
+ double maxValue,
+ int decimals = kTppDoubleSliderDecimals) {
+ lineEdit->setFixedWidth(tppNumericLineEditWidth(
+ lineEdit->font(), QString::number(static_cast<int>(minValue)).length(),
+ QString::number(static_cast<int>(maxValue)).length(), decimals));
+ lineEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+}
+
+int tppDoubleValueToSliderPos(double value, int sliderMin, int sliderMax,
+ int factor, bool isLinear) {
+ const int sliderValue = static_cast<int>(std::lround(value * factor));
+ if (isLinear) return sliderValue;
+
+ const double rangeSize = static_cast<double>(sliderMax - sliderMin);
+ if (std::abs(rangeSize) < std::numeric_limits<double>::epsilon())
+ return sliderValue;
+
+ const double valueRatio =
+ (static_cast<double>(sliderValue) - static_cast<double>(sliderMin)) /
+ rangeSize;
+ double t = 0.0;
+ if (valueRatio <= 0.02)
+ t = valueRatio / 0.04;
+ else if (valueRatio <= 0.04)
+ t = (valueRatio + 0.02) / 0.08;
+ else if (valueRatio <= 0.1)
+ t = (valueRatio + 0.26) / 0.4;
+ else
+ t = (valueRatio + 8.0) / 9.0;
+ return sliderMin + static_cast<int>(t * rangeSize);
+}
+
+double tppSliderPosToDoubleValue(int pos, int sliderMin, int sliderMax,
+ int factor, bool isLinear) {
+ if (isLinear) return static_cast<double>(pos) / factor;
+
+ static constexpr std::array<double, 4> thresholds{0.5, 0.75, 0.9, 1.0};
+ const double rangeSize = static_cast<double>(sliderMax - sliderMin);
+ if (std::abs(rangeSize) < std::numeric_limits<double>::epsilon())
+ return static_cast<double>(pos) / factor;
+
+ const double posRatio = static_cast<double>(pos - sliderMin) / rangeSize;
+ double t = 0.0;
+ if (posRatio <= thresholds[0])
+ t = 0.04 * posRatio;
+ else if (posRatio <= thresholds[1])
+ t = -0.02 + 0.08 * posRatio;
+ else if (posRatio <= thresholds[2])
+ t = -0.26 + 0.4 * posRatio;
+ else
+ t = -8.0 + 9.0 * posRatio;
+
+ const double sliderValue =
+ std::round(static_cast<double>(sliderMin) + rangeSize * t);
+ return sliderValue / factor;
+}
+
+constexpr int kTppPairSliderTrackMin = 72;
+constexpr int kTppPairFieldGutter = 8;
+
+class TppCompactDoublePairField final : public DVGui::DoublePairField {
+public:
+ using DoublePairField::DoublePairField;
+
+ int configureTppLayout(double rangeMin, double rangeMax, bool isLinear,
+ bool showNumericFields) {
+ setLinearSlider(isLinear);
+ setLabelsEnabled(false);
+
+ const int widgetWidth = tppNumericLineEditWidth(
+ font(), QString::number(static_cast<int>(rangeMin)).length(),
+ QString::number(static_cast<int>(rangeMax)).length(),
+ kTppDoubleSliderDecimals);
+
+ if (showNumericFields) {
+ m_leftLineEdit->setFixedWidth(widgetWidth);
+ m_rightLineEdit->setFixedWidth(widgetWidth);
+ m_leftLineEdit->show();
+ m_rightLineEdit->show();
+ m_leftMargin = widgetWidth + kTppPairFieldGutter;
+ m_rightMargin = widgetWidth + kTppPairFieldGutter;
+ } else {
+ m_leftLineEdit->hide();
+ m_rightLineEdit->hide();
+ m_leftMargin = kTppPairFieldGutter + 2;
+ m_rightMargin = kTppPairFieldGutter + 2;
+ }
+
+ setMinimumWidth(kTppPairSliderTrackMin + m_leftMargin + m_rightMargin);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ update();
+ return widgetWidth;
+ }
+};
+
+void configureTppIntPairField(DVGui::IntPairField *pairField, int rangeMin,
+ int rangeMax, bool showNumericFields) {
+ if (!pairField) return;
+
+ pairField->setLabelsEnabled(false);
+
+ const int widgetWidth = tppNumericLineEditWidth(
+ pairField->font(), QString::number(rangeMin).length(),
+ QString::number(rangeMax).length(), 0);
+
+ for (DVGui::IntLineEdit *edit :
+ pairField->findChildren<DVGui::IntLineEdit *>()) {
+ edit->setFixedWidth(widgetWidth);
+ edit->setVisible(showNumericFields);
+ }
+
+ const int sideReserve = showNumericFields ? widgetWidth + kTppPairFieldGutter
+ : kTppPairFieldGutter + 2;
+ pairField->setMinimumWidth(kTppPairSliderTrackMin + 2 * sideReserve);
+ pairField->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+}
+
+} // namespace
+
+class ToolPropertiesPanel::PropertyWidgetSync final
+ : public QObject,
+ public TProperty::Listener {
+ ToolPropertiesPanel *m_panel;
+ QPointer<QWidget> m_widget;
+ TProperty *m_property;
+
+public:
+ PropertyWidgetSync(ToolPropertiesPanel *panel, QWidget *widget,
+ TProperty *property, QObject *parent = nullptr)
+ : QObject(parent)
+ , m_panel(panel)
+ , m_widget(widget)
+ , m_property(property) {
+ m_property->addListener(this);
+ }
+
+ ~PropertyWidgetSync() override {
+ if (m_property) m_property->removeListener(this);
+ }
+
+ void onPropertyChanged() override {
+ if (m_panel && m_widget) m_panel->updateWidgetFromProperty(m_widget);
+ }
+};
+
+namespace {
+
+void applyCollapsibleContentLayout(QVBoxLayout *contentLayout) {
+ contentLayout->setMargin(0);
+ contentLayout->setContentsMargins(
+ CollapsibleStyle::kContentLeftIndent, CollapsibleStyle::kHeaderMarginV,
+ CollapsibleStyle::kContentRightMargin, CollapsibleStyle::kHeaderMarginV);
+ contentLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+}
+
+void addCollapsibleHeaderRightReserve(QHBoxLayout *headerLayout,
+ QWidget *header) {
+ QWidget *reserve = new QWidget(header);
+ reserve->setFixedWidth(CollapsibleStyle::kHeaderRightSlot);
+ reserve->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+ headerLayout->addWidget(reserve);
+}
+
+void styleCollapsibleField(QWidget *field) {
+ field->setFixedHeight(CollapsibleStyle::kFieldHeight);
+ field->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+}
+
+QWidget *replacePlasticSkeletonEmptyLineEdit(QWidget *picker, bool showBorders,
+ bool showBackgrounds) {
+ if (!picker) return nullptr;
+ QLineEdit *emptyField = picker->findChild<QLineEdit *>("pickerEmptyField");
+ if (!emptyField) return nullptr;
+
+ QWidget *content = emptyField->parentWidget();
+ if (!content) return nullptr;
+ auto *contentLayout = qobject_cast<QVBoxLayout *>(content->layout());
+ if (!contentLayout) return nullptr;
+
+ contentLayout->removeWidget(emptyField);
+ delete emptyField;
+
+ ToolPropertyButton *emptySlot = new ToolPropertyButton(QString(), content);
+ emptySlot->setObjectName("plasticSkelEmptySlot");
+ emptySlot->setCursor(Qt::ArrowCursor);
+ emptySlot->setCheckable(false);
+ emptySlot->setHoverEnabled(false);
+ emptySlot->setFocusPolicy(Qt::NoFocus);
+ styleCollapsibleField(emptySlot);
+ emptySlot->setShowBorders(showBorders);
+ emptySlot->setShowBackgrounds(showBackgrounds);
+ contentLayout->insertWidget(0, emptySlot);
+ return emptySlot;
+}
+
+void uniformPlasticFieldWidget(QWidget *widget) {
+ if (!widget) return;
+ for (QLineEdit *lineEdit : widget->findChildren<QLineEdit *>())
+ styleCollapsibleField(lineEdit);
+ for (ToolPropertyButton *button :
+ widget->findChildren<ToolPropertyButton *>())
+ styleCollapsibleField(button);
+ for (QSlider *slider : widget->findChildren<QSlider *>())
+ slider->setFixedHeight(CollapsibleStyle::kFieldHeight);
+ for (QCheckBox *checkBox : widget->findChildren<QCheckBox *>())
+ checkBox->setMinimumHeight(CollapsibleStyle::kFieldHeight);
+}
+
+void syncPlasticRelayField(MeasuredValueField *field,
+ TDoubleParamRelayProperty *relay);
+
+class PlasticRelayFieldSync final : public QObject, public TProperty::Listener {
+ QPointer<MeasuredValueField> m_field;
+ TDoubleParamRelayProperty *m_relay;
+
+public:
+ PlasticRelayFieldSync(MeasuredValueField *field,
+ TDoubleParamRelayProperty *relay, QObject *parent)
+ : QObject(parent), m_field(field), m_relay(relay) {
+ if (m_relay) m_relay->addListener(this);
+ }
+
+ ~PlasticRelayFieldSync() override {
+ if (m_relay) m_relay->removeListener(this);
+ }
+
+ void onPropertyChanged() override {
+ if (m_field && m_relay) syncPlasticRelayField(m_field, m_relay);
+ }
+};
+
+void syncPlasticRelayField(MeasuredValueField *field,
+ TDoubleParamRelayProperty *relay) {
+ if (!field || !relay) return;
+
+ TDoubleParamP param = relay->getParam();
+ if (!param) {
+ field->setEnabled(false);
+ field->blockSignals(true);
+ field->setText("");
+ field->blockSignals(false);
+ return;
+ }
+
+ field->setEnabled(true);
+ if (TMeasure *measure = param->getMeasure())
+ field->setMeasure(measure->getName());
+
+ field->blockSignals(true);
+ field->setValue(relay->getValue());
+ field->blockSignals(false);
+}
+
+class PlasticRelayFieldEditor final : public QObject {
+ PlasticTool *m_plastic;
+ TDoubleParamRelayProperty *m_relay;
+ TDoubleParamP m_param;
+ double m_frame = 0.0;
+ std::unique_ptr<KeyframeSetter> m_setter;
+
+public:
+ PlasticRelayFieldEditor(MeasuredValueField *field, PlasticTool *plastic,
+ TDoubleParamRelayProperty *relay)
+ : QObject(field), m_plastic(plastic), m_relay(relay) {
+ connect(field, &MeasuredValueField::measuredValueChanged, this,
+ [this, field](TMeasuredValue *, bool addToUndo) {
+ // Keyframe notifications can replace the field's displayed value.
+ const double value = field->getValue();
+ setValue(value, addToUndo);
+ });
+ }
+
+private:
+ void setValue(double value, bool addToUndo) {
+ TDoubleParamP param = m_relay->getParam();
+ const double frame = m_relay->frame();
+ if (m_setter && (param != m_param || frame != m_frame)) m_setter.reset();
+ if (!param || (!m_setter && m_relay->getValue() == value)) return;
+
+ TUndoManager *manager = TUndoManager::manager();
+ if (addToUndo) manager->beginBlock();
+
+ // Retain the original keyframe state throughout a drag. This also lets
+ // undo remove a keyframe first created by a live preview.
+ if (!m_setter) {
+ m_param = param;
+ m_frame = frame;
+ m_setter.reset(new KeyframeSetter(param.getPointer(), -1, true));
+ m_setter->createKeyframe(frame);
+ }
+ if (addToUndo) m_plastic->keyframePlasticRelays(m_relay);
+
+ m_setter->setValue(value);
+ m_plastic->onPropertyChanged(m_relay->getName());
+
+ if (addToUndo) {
+ // Add one undo entry for the whole gesture, grouped with Global Key.
+ m_setter.reset();
+ manager->endBlock();
+ }
+ }
+};
+
+MeasuredValueField *createPlasticRelayField(QWidget *parent,
+ PlasticTool *plastic,
+ TDoubleParamRelayProperty *relay,
+ const QString &objectName) {
+ auto *field = new MeasuredValueField(parent);
+ field->setObjectName(objectName);
+ field->setProperty("plasticRelay", true);
+ syncPlasticRelayField(field, relay);
+ new PlasticRelayFieldEditor(field, plastic, relay);
+ return field;
+}
+
+QLineEdit *createPlasticStringField(QWidget *parent, TTool *tool,
+ TStringProperty *prop, int propGroup) {
+ auto *lineEdit = new QLineEdit(parent);
+ lineEdit->setText(QString::fromStdWString(prop->getValue()));
+ lineEdit->setProperty("propName", QString::fromStdString(prop->getName()));
+ lineEdit->setProperty("propGroup", propGroup);
+ styleCollapsibleField(lineEdit);
+
+ QObject::connect(lineEdit, &QLineEdit::editingFinished, [tool, lineEdit]() {
+ if (!tool) return;
+ const std::string name =
+ lineEdit->property("propName").toString().toStdString();
+ const int group = lineEdit->property("propGroup").toInt();
+ TPropertyGroup *props = tool->getProperties(group);
+ if (!props) return;
+ if (auto *sp = dynamic_cast<TStringProperty *>(props->getProperty(name))) {
+ sp->setValue(lineEdit->text().toStdWString());
+ tool->onPropertyChanged(name);
+ sp->notifyListeners();
+ }
+ });
+ return lineEdit;
+}
+
+void initCollapsibleHeader(QHBoxLayout *headerLayout) {
+ headerLayout->setContentsMargins(
+ CollapsibleStyle::kHeaderMarginH, CollapsibleStyle::kHeaderMarginV,
+ CollapsibleStyle::kHeaderMarginH, CollapsibleStyle::kHeaderMarginV);
+ headerLayout->setSpacing(CollapsibleStyle::kHeaderSpacing);
+}
+
+void connectClickableLabel(ClickableLabel *label, MeasuredValueField *field) {
+ QObject::connect(label, SIGNAL(onMousePress(QMouseEvent *)), field,
+ SLOT(receiveMousePress(QMouseEvent *)));
+ QObject::connect(label, SIGNAL(onMouseMove(QMouseEvent *)), field,
+ SLOT(receiveMouseMove(QMouseEvent *)));
+ QObject::connect(label, SIGNAL(onMouseRelease(QMouseEvent *)), field,
+ SLOT(receiveMouseRelease(QMouseEvent *)));
+}
+
+} // namespace
+
+//-----------------------------------------------------------------------------
+// Helper Methods for UI Creation
+//-----------------------------------------------------------------------------
+
+QWidget *ToolPropertiesPanel::createSliderWithLabel(
+ const QString &label, int min, int max, int value,
+ const std::string &propName) {
+ QWidget *container = new QWidget(this);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", 0);
+
+ QVBoxLayout *layout = new QVBoxLayout(container);
+ layout->setMargin(0);
+ layout->setSpacing(3);
+
+ // Label (respect m_showLabels)
+ QLabel *nameLabel = new QLabel(label, container);
+ nameLabel->setVisible(m_showLabels);
+ layout->addWidget(nameLabel);
+
+ // Slider with numeric fields
+ QHBoxLayout *sliderLayout = new QHBoxLayout();
+ sliderLayout->setMargin(0);
+ sliderLayout->setSpacing(5);
+
+ // Numeric field (QLineEdit to avoid arrows, respect m_showNumericFields)
+ QLineEdit *lineEdit = new QLineEdit(container);
+ lineEdit->setText(QString::number(value));
+ styleTppIntLineEdit(lineEdit, min, max);
+ lineEdit->setVisible(m_showNumericFields);
+ QIntValidator *validator = new QIntValidator(min, max, lineEdit);
+ lineEdit->setValidator(validator);
+ sliderLayout->addWidget(lineEdit);
+
+ // Slider
+ QSlider *slider = new QSlider(Qt::Horizontal, container);
+ slider->setMinimum(min);
+ slider->setMaximum(max);
+ slider->setValue(value);
+ sliderLayout->addWidget(slider, 1); // Stretch to take available space
+
+ layout->addLayout(sliderLayout);
+
+ // Connect slider and lineEdit together
+ connect(slider, &QSlider::valueChanged,
+ [lineEdit](int val) { lineEdit->setText(QString::number(val)); });
+ connect(lineEdit, &QLineEdit::editingFinished,
+ [slider, lineEdit]() { slider->setValue(lineEdit->text().toInt()); });
+
+ // Connect to tool property
+ connect(slider, &QSlider::valueChanged, [this, container](int val) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ const std::string propName =
+ container->property("propName").toString().toStdString();
+ const int propGroup = container->property("propGroup").toInt();
+
+ TProperty *prop = resolveTppProperty(tool, container, propGroup, propName);
+ if (auto *intProp = dynamic_cast<TIntProperty *>(prop)) {
+ intProp->setValue(val);
+ tool->onPropertyChanged(propName, true);
+ intProp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createDoubleSliderWithLabel(
+ const QString &label, double min, double max, double value,
+ const std::string &propName) {
+ QWidget *container = new QWidget(this);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", 0);
+ container->setProperty("valueFactor", kTppDoubleSliderFactor);
+ container->setProperty("valueDecimals", kTppDoubleSliderDecimals);
+
+ QVBoxLayout *layout = new QVBoxLayout(container);
+ layout->setMargin(0);
+ layout->setSpacing(3);
+
+ // Label (respect m_showLabels)
+ QLabel *nameLabel = new QLabel(label, container);
+ nameLabel->setVisible(m_showLabels);
+ layout->addWidget(nameLabel);
+
+ // Slider with numeric field
+ QHBoxLayout *sliderLayout = new QHBoxLayout();
+ sliderLayout->setMargin(0);
+ sliderLayout->setSpacing(5);
+
+ const int sliderMin =
+ static_cast<int>(std::lround(min * kTppDoubleSliderFactor));
+ const int sliderMax =
+ static_cast<int>(std::lround(max * kTppDoubleSliderFactor));
+ const int sliderVal =
+ static_cast<int>(std::lround(value * kTppDoubleSliderFactor));
+
+ // Numeric field (QLineEdit to avoid arrows, respect m_showNumericFields)
+ QLineEdit *lineEdit = new QLineEdit(container);
+ lineEdit->setText(QString::number(value, 'f', kTppDoubleSliderDecimals));
+ styleTppDoubleLineEdit(lineEdit, min, max);
+ lineEdit->setVisible(m_showNumericFields);
+ QDoubleValidator *validator =
+ new QDoubleValidator(min, max, kTppDoubleSliderDecimals, lineEdit);
+ lineEdit->setValidator(validator);
+ sliderLayout->addWidget(lineEdit);
+
+ // Slider (scale matches ToolOptionSlider / DoubleLineEdit)
+ QSlider *slider = new QSlider(Qt::Horizontal, container);
+ slider->setMinimum(sliderMin);
+ slider->setMaximum(sliderMax);
+ slider->setValue(sliderVal);
+ sliderLayout->addWidget(slider, 1); // Stretch to take available space
+
+ layout->addLayout(sliderLayout);
+
+ // Connect slider and lineEdit together
connect(slider, &QSlider::valueChanged, [lineEdit](int val) {
- lineEdit->setText(QString::number(val / 10.0, 'f', 1));
+ lineEdit->setText(
+ QString::number(static_cast<double>(val) / kTppDoubleSliderFactor, 'f',
+ kTppDoubleSliderDecimals));
});
connect(lineEdit, &QLineEdit::editingFinished, [slider, lineEdit]() {
- slider->setValue(static_cast<int>(lineEdit->text().toDouble() * 10));
+ slider->setValue(static_cast<int>(
+ std::lround(lineEdit->text().toDouble() * kTppDoubleSliderFactor)));
});
-
+
// Connect to tool property
- connect(slider, &QSlider::valueChanged, [this, propName](int val) {
- double newValue = val / 10.0;
-
+ connect(slider, &QSlider::valueChanged, [this, container](int val) {
+ const double newValue = static_cast<double>(val) / kTppDoubleSliderFactor;
+
TTool *tool = getCurrentTool();
if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(0);
- if (!props) return;
-
- for (int i = 0; i < props->getPropertyCount(); ++i) {
- TProperty *prop = props->getProperty(i);
- if (prop && prop->getName() == propName) {
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
- if (doubleProp) {
- doubleProp->setValue(newValue);
- tool->onPropertyChanged(propName);
- if (m_toolHandle) m_toolHandle->notifyToolChanged();
- }
- break;
- }
+
+ const std::string propName =
+ container->property("propName").toString().toStdString();
+ const int propGroup = container->property("propGroup").toInt();
+
+ TProperty *prop = resolveTppProperty(tool, container, propGroup, propName);
+ if (auto *doubleProp = dynamic_cast<TDoubleProperty *>(prop)) {
+ doubleProp->setValue(newValue);
+ tool->onPropertyChanged(propName, true);
+ doubleProp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
});
-
+
return container;
}
-QWidget* ToolPropertiesPanel::createCheckBox(const QString &label, bool checked,
+QWidget *ToolPropertiesPanel::createCheckBox(const QString &label, bool checked,
const std::string &propName) {
QCheckBox *checkBox = new QCheckBox(label, this);
checkBox->setProperty("propName", QString::fromStdString(propName));
checkBox->setProperty("propGroup", 0);
checkBox->setChecked(checked);
-
+
// Connect checkbox to tool property
- connect(checkBox, &QCheckBox::toggled, [this, propName](bool checked) {
+ connect(checkBox, &QCheckBox::toggled, [this, checkBox](bool checked) {
TTool *tool = getCurrentTool();
if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(0);
- if (!props) return;
-
- for (int i = 0; i < props->getPropertyCount(); ++i) {
- TProperty *prop = props->getProperty(i);
- if (prop && prop->getName() == propName) {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
- if (boolProp) {
- boolProp->setValue(checked);
- tool->onPropertyChanged(propName);
- if (m_toolHandle) m_toolHandle->notifyToolChanged();
- }
- break;
- }
+
+ const std::string propName =
+ checkBox->property("propName").toString().toStdString();
+ const int propGroup = checkBox->property("propGroup").toInt();
+
+ TProperty *prop = resolveTppProperty(tool, checkBox, propGroup, propName);
+ if (auto *boolProp = dynamic_cast<TBoolProperty *>(prop)) {
+ boolProp->setValue(checked);
+ tool->onPropertyChanged(propName, true);
+ boolProp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
});
-
+
return checkBox;
}
-QWidget* ToolPropertiesPanel::createCollapsibleEnum(const QString &label,
- const QStringList &items,
- int currentIndex,
- const std::string &propName,
- const QString &iconName) {
+QWidget *ToolPropertiesPanel::createTextProperty(const QString &label,
+ TStringProperty *prop,
+ const std::string &propName,
+ int propGroup) {
QWidget *container = new QWidget(this);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", propGroup);
+ QVBoxLayout *layout = new QVBoxLayout(container);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ QLabel *nameLabel = new QLabel(label, container);
+ layout->addWidget(nameLabel);
+
+ QLineEdit *lineEdit = new QLineEdit(container);
+ lineEdit->setText(QString::fromStdWString(prop->getValue()));
+ storeTppPropertyPtr(container, prop);
+ layout->addWidget(lineEdit);
+
+ connect(lineEdit, &QLineEdit::editingFinished,
+ [this, container, lineEdit, propName, propGroup]() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TProperty *p =
+ resolveTppProperty(tool, container, propGroup, propName);
+ if (auto *sp = dynamic_cast<TStringProperty *>(p)) {
+ sp->setValue(lineEdit->text().toStdWString());
+ tool->onPropertyChanged(propName, true);
+ sp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ });
+
+ connect(lineEdit, &QLineEdit::textChanged,
+ [this, container, lineEdit, propName, propGroup]() {
+ if (!lineEdit->hasFocus()) return;
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TProperty *p =
+ resolveTppProperty(tool, container, propGroup, propName);
+ if (auto *sp = dynamic_cast<TStringProperty *>(p)) {
+ const std::wstring w = lineEdit->text().toStdWString();
+ if (sp->getValue() == w) return;
+ sp->setValue(w);
+ sp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsibleEnum(
+ const QString &label, const QStringList &items, int currentIndex,
+ const std::string &propName, const QString &iconName,
+ const std::function<void(int)> &onChanged, bool reserveHeaderRightSlot,
+ QWidget *parentWidget) {
+ QWidget *container =
+ new QWidget(parentWidget ? parentWidget : static_cast<QWidget *>(this));
QVBoxLayout *mainLayout = new QVBoxLayout(container);
mainLayout->setMargin(0);
- mainLayout->setSpacing(2);
-
+ mainLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
// Header with toggle button
QWidget *header = new QWidget(container);
+ header->setFixedHeight(CollapsibleStyle::kHeaderRowHeight);
QHBoxLayout *headerLayout = new QHBoxLayout(header);
- headerLayout->setMargin(2);
- headerLayout->setSpacing(5);
-
+ initCollapsibleHeader(headerLayout);
+
// Toggle button (triangle)
QToolButton *toggleButton = new QToolButton(header);
toggleButton->setArrowType(Qt::RightArrow);
toggleButton->setCheckable(true);
toggleButton->setStyleSheet("QToolButton { border: none; }");
- toggleButton->setFixedSize(16, 16);
+ toggleButton->setFixedSize(CollapsibleStyle::kToggleSize,
+ CollapsibleStyle::kToggleSize);
headerLayout->addWidget(toggleButton);
-
+
// Icon (if provided)
if (!iconName.isEmpty()) {
QLabel *iconLabel = new QLabel(header);
- QPixmap icon = QIcon(":Resources/" + iconName + ".svg").pixmap(16, 16);
+ QPixmap icon = QIcon(":Resources/" + iconName + ".svg").pixmap(16, 16);
if (!icon.isNull()) {
iconLabel->setPixmap(icon);
headerLayout->addWidget(iconLabel);
}
}
-
+
// Label (respect m_showLabels)
QLabel *nameLabel = new QLabel(label, header);
nameLabel->setVisible(m_showLabels);
headerLayout->addWidget(nameLabel);
-
+
// Current value indicator (attenuated: italic + disabled color from palette)
QLabel *valueLabel = new QLabel(items.value(currentIndex, ""), header);
valueLabel->setObjectName("valueLabel");
@@ -1826,147 +2876,589 @@ QWidget* ToolPropertiesPanel::createCollapsibleEnum(const QString &label,
valueLabel->setFont(italicFont);
// Use palette disabled text color for attenuation (theme-aware)
QPalette pal = valueLabel->palette();
- pal.setColor(QPalette::WindowText, palette().color(QPalette::Disabled, QPalette::WindowText));
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
valueLabel->setPalette(pal);
headerLayout->addStretch();
headerLayout->addWidget(valueLabel);
-
+ if (reserveHeaderRightSlot)
+ addCollapsibleHeaderRightReserve(headerLayout, header);
+
mainLayout->addWidget(header);
-
+
// Content (checkable buttons in a group)
QWidget *content = new QWidget(container);
-
+
// Load saved collapse state from TEnv (persists between sessions)
bool isExpanded =
collapsedStateFromEnv(propName, false); // Default: collapsed
content->setVisible(isExpanded);
toggleButton->setChecked(isExpanded);
toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
-
+
QVBoxLayout *contentLayout = new QVBoxLayout(content);
- contentLayout->setMargin(0);
- contentLayout->setContentsMargins(25, 2, 0, 2); // Indent
- contentLayout->setSpacing(2);
-
+ applyCollapsibleContentLayout(contentLayout);
+
// Create button group for exclusive selection
QButtonGroup *buttonGroup = new QButtonGroup(content);
buttonGroup->setExclusive(true);
-
+
// Create checkable buttons using custom ToolPropertyButton class
- // This class has custom paintEvent that respects theme colors AND Cells options
+ // This class has custom paintEvent that respects theme colors AND Cells
+ // options
for (int i = 0; i < items.size(); ++i) {
- ToolPropertyButton *optionButton = new ToolPropertyButton(items[i], content);
+ ToolPropertyButton *optionButton =
+ new ToolPropertyButton(items[i], content);
optionButton->setCursor(Qt::PointingHandCursor);
optionButton->setCheckable(true);
optionButton->setAutoExclusive(true);
- optionButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- optionButton->setMinimumHeight(24);
- optionButton->setMinimumWidth(100);
-
+ styleCollapsibleField(optionButton);
+
// Set Cells Borders/Backgrounds state
optionButton->setShowBorders(m_showBorders);
optionButton->setShowBackgrounds(m_showBackgrounds);
-
+
// Set initial checked state
if (i == currentIndex) {
optionButton->setChecked(true);
}
-
+
buttonGroup->addButton(optionButton, i);
contentLayout->addWidget(optionButton);
}
-
+
mainLayout->addWidget(content);
-
+
// Toggle behavior - Save state on change
- connect(toggleButton, &QToolButton::toggled, [content, toggleButton, propName](bool checked) {
- content->setVisible(checked);
- toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
-
- // Save collapsed state to TEnv for persistence
- setCollapsedStateInEnv(propName, checked);
- });
-
+ connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, propName](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+
+ // Save collapsed state to TEnv for persistence
+ setCollapsedStateInEnv(propName, checked);
+ });
+
// Store propName in container for later use
container->setProperty("propName", QString::fromStdString(propName));
container->setProperty("propGroup", 0); // Default to group 0
-
+
// Connect button group to property update
- connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
- [this, valueLabel, items, container](int id) {
- // Update value label
- valueLabel->setText(items.value(id, ""));
-
- // Update tool property
- std::string propName = container->property("propName").toString().toStdString();
- int propGroup = container->property("propGroup").toInt();
-
- TTool *tool = getCurrentTool();
- if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(propGroup);
- if (!props) return;
-
- for (int k = 0; k < props->getPropertyCount(); ++k) {
- TProperty *prop = props->getProperty(k);
- if (prop && prop->getName() == propName) {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- enumProp->setIndex(id);
- tool->onPropertyChanged(propName);
- if (m_toolHandle) m_toolHandle->notifyToolChanged();
- }
- break;
- }
- }
+ connect(buttonGroup, &QButtonGroup::idClicked,
+ [this, valueLabel, items, container, onChanged](int id) {
+ // Update value label
+ valueLabel->setText(items.value(id, ""));
+
+ // Update tool property
+ std::string propName =
+ container->property("propName").toString().toStdString();
+ int propGroup = container->property("propGroup").toInt();
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TProperty *prop =
+ resolveTppProperty(tool, container, propGroup, propName);
+ if (auto *enumProp = dynamic_cast<TEnumProperty *>(prop)) {
+ enumProp->setIndex(id);
+ tool->onPropertyChanged(propName, true);
+ enumProp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ if (tool->getName() == T_EditAssistants &&
+ propName == "AssistantType")
+ refreshProperties();
+ }
+
+ if (onChanged) onChanged(id);
+ });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsibleIntSlider(
+ const QString &label, int min, int max, int value,
+ const std::string &propName, int propGroup, const std::string &storageKey,
+ bool reserveHeaderRightSlot) {
+ QWidget *container = new QWidget(m_propertiesContainer);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", propGroup);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(container);
+ mainLayout->setMargin(0);
+ mainLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ QWidget *header = new QWidget(container);
+ header->setFixedHeight(CollapsibleStyle::kHeaderRowHeight);
+ QHBoxLayout *headerLayout = new QHBoxLayout(header);
+ initCollapsibleHeader(headerLayout);
+
+ QToolButton *toggleButton = new QToolButton(header);
+ toggleButton->setArrowType(Qt::RightArrow);
+ toggleButton->setCheckable(true);
+ toggleButton->setStyleSheet("QToolButton { border: none; }");
+ toggleButton->setFixedSize(CollapsibleStyle::kToggleSize,
+ CollapsibleStyle::kToggleSize);
+ headerLayout->addWidget(toggleButton);
+
+ QLabel *nameLabel = new QLabel(label, header);
+ nameLabel->setVisible(m_showLabels);
+ headerLayout->addWidget(nameLabel);
+
+ QLabel *valueLabel = new QLabel(QString::number(value), header);
+ valueLabel->setObjectName("intSliderValueLabel");
+ QFont italicFont = valueLabel->font();
+ italicFont.setItalic(true);
+ valueLabel->setFont(italicFont);
+ QPalette pal = valueLabel->palette();
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
+ valueLabel->setPalette(pal);
+ headerLayout->addStretch();
+ headerLayout->addWidget(valueLabel);
+ if (reserveHeaderRightSlot)
+ addCollapsibleHeaderRightReserve(headerLayout, header);
+ mainLayout->addWidget(header);
+
+ QWidget *content = new QWidget(container);
+ const bool isExpanded = collapsedStateFromEnv(storageKey, false);
+ content->setVisible(isExpanded);
+ toggleButton->setChecked(isExpanded);
+ toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
+
+ QVBoxLayout *contentLayout = new QVBoxLayout(content);
+ applyCollapsibleContentLayout(contentLayout);
+
+ QHBoxLayout *sliderLayout = new QHBoxLayout();
+ sliderLayout->setMargin(0);
+ sliderLayout->setSpacing(CollapsibleStyle::kHeaderSpacing);
+
+ QLineEdit *lineEdit = new QLineEdit(content);
+ lineEdit->setText(QString::number(value));
+ styleTppIntLineEdit(lineEdit, min, max);
+ lineEdit->setVisible(m_showNumericFields);
+ lineEdit->setValidator(new QIntValidator(min, max, lineEdit));
+ styleCollapsibleField(lineEdit);
+
+ QSlider *slider = new QSlider(Qt::Horizontal, content);
+ slider->setMinimum(min);
+ slider->setMaximum(max);
+ slider->setValue(value);
+ slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ slider->setFixedHeight(CollapsibleStyle::kFieldHeight);
+
+ sliderLayout->addWidget(lineEdit);
+ sliderLayout->addWidget(slider, 1);
+ contentLayout->addLayout(sliderLayout);
+ mainLayout->addWidget(content);
+
+ QObject::connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, storageKey](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+ setCollapsedStateInEnv(storageKey, checked);
+ });
+
+ QObject::connect(slider, &QSlider::valueChanged, [lineEdit](int val) {
+ lineEdit->setText(QString::number(val));
+ });
+ QObject::connect(lineEdit, &QLineEdit::editingFinished, [slider, lineEdit]() {
+ slider->setValue(lineEdit->text().toInt());
});
-
+
+ auto applyValue = [this, container, valueLabel](int val) {
+ valueLabel->setText(QString::number(val));
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ const std::string name =
+ container->property("propName").toString().toStdString();
+ const int group = container->property("propGroup").toInt();
+ TProperty *prop = resolveTppProperty(tool, container, group, name);
+ if (auto *intProp = dynamic_cast<TIntProperty *>(prop)) {
+ intProp->setValue(val);
+ tool->onPropertyChanged(name, true);
+ intProp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ };
+
+ QObject::connect(slider, &QSlider::valueChanged, applyValue);
+ QObject::connect(
+ lineEdit, &QLineEdit::editingFinished,
+ [slider, lineEdit, applyValue]() { applyValue(slider->value()); });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsiblePicker(
+ const QString &label, const QStringList &items, int currentIndex,
+ const QString &storageKey, const std::function<void(int)> &onChanged) {
+ QWidget *container = new QWidget(this);
+ container->setProperty("pickerStorageKey", storageKey);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(container);
+ mainLayout->setMargin(0);
+ mainLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ QWidget *header = new QWidget(container);
+ header->setFixedHeight(CollapsibleStyle::kHeaderRowHeight);
+ QHBoxLayout *headerLayout = new QHBoxLayout(header);
+ initCollapsibleHeader(headerLayout);
+
+ QToolButton *toggleButton = new QToolButton(header);
+ toggleButton->setArrowType(Qt::RightArrow);
+ toggleButton->setCheckable(true);
+ toggleButton->setStyleSheet("QToolButton { border: none; }");
+ toggleButton->setFixedSize(CollapsibleStyle::kToggleSize,
+ CollapsibleStyle::kToggleSize);
+ headerLayout->addWidget(toggleButton);
+
+ QLabel *nameLabel = new QLabel(label, header);
+ nameLabel->setVisible(m_showLabels);
+ headerLayout->addWidget(nameLabel);
+
+ QLabel *valueLabel = new QLabel(items.value(currentIndex, ""), header);
+ valueLabel->setObjectName("pickerValueLabel");
+ QFont italicFont = valueLabel->font();
+ italicFont.setItalic(true);
+ valueLabel->setFont(italicFont);
+ QPalette pal = valueLabel->palette();
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
+ valueLabel->setPalette(pal);
+ headerLayout->addStretch();
+ headerLayout->addWidget(valueLabel);
+ mainLayout->addWidget(header);
+
+ QWidget *content = new QWidget(container);
+ const bool isExpanded =
+ collapsedStateFromEnv(storageKey.toStdString(), false);
+ content->setVisible(isExpanded);
+ toggleButton->setChecked(isExpanded);
+ toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
+
+ QVBoxLayout *contentLayout = new QVBoxLayout(content);
+ applyCollapsibleContentLayout(contentLayout);
+
+ QButtonGroup *buttonGroup = new QButtonGroup(content);
+ buttonGroup->setExclusive(true);
+ buttonGroup->setObjectName("pickerButtonGroup");
+
+ if (items.isEmpty()) {
+ QLineEdit *emptyField = new QLineEdit(content);
+ emptyField->setObjectName("pickerEmptyField");
+ emptyField->setReadOnly(true);
+ styleCollapsibleField(emptyField);
+ contentLayout->addWidget(emptyField);
+ } else {
+ for (int i = 0; i < items.size(); ++i) {
+ ToolPropertyButton *optionButton =
+ new ToolPropertyButton(items[i], content);
+ optionButton->setCursor(Qt::PointingHandCursor);
+ optionButton->setCheckable(true);
+ optionButton->setAutoExclusive(true);
+ styleCollapsibleField(optionButton);
+ optionButton->setShowBorders(m_showBorders);
+ optionButton->setShowBackgrounds(m_showBackgrounds);
+ if (i == currentIndex) optionButton->setChecked(true);
+ buttonGroup->addButton(optionButton, i);
+ contentLayout->addWidget(optionButton);
+ }
+ }
+
+ mainLayout->addWidget(content);
+
+ QObject::connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, storageKey](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+ setCollapsedStateInEnv(storageKey.toStdString(), checked);
+ });
+
+ QObject::connect(buttonGroup, &QButtonGroup::idClicked,
+ [valueLabel, items, onChanged](int id) {
+ valueLabel->setText(items.value(id, ""));
+ if (onChanged) onChanged(id);
+ });
+
+ container->setProperty("pickerCurrentIndex", currentIndex);
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsibleTextField(
+ const QString &label, const QString &textValue,
+ const std::string &storageKey, const std::string &propName, int propGroup,
+ const std::function<void(const QString &)> &onChanged,
+ bool reserveHeaderRightSlot) {
+ QWidget *container = new QWidget(m_propertiesContainer);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", propGroup);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(container);
+ mainLayout->setMargin(0);
+ mainLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ QWidget *header = new QWidget(container);
+ header->setFixedHeight(CollapsibleStyle::kHeaderRowHeight);
+ QHBoxLayout *headerLayout = new QHBoxLayout(header);
+ initCollapsibleHeader(headerLayout);
+
+ QToolButton *toggleButton = new QToolButton(header);
+ toggleButton->setArrowType(Qt::RightArrow);
+ toggleButton->setCheckable(true);
+ toggleButton->setStyleSheet("QToolButton { border: none; }");
+ toggleButton->setFixedSize(CollapsibleStyle::kToggleSize,
+ CollapsibleStyle::kToggleSize);
+ headerLayout->addWidget(toggleButton);
+
+ QLabel *nameLabel = new QLabel(label, header);
+ nameLabel->setVisible(m_showLabels);
+ headerLayout->addWidget(nameLabel);
+
+ QLabel *valueLabel = new QLabel(textValue, header);
+ valueLabel->setObjectName("textValueLabel");
+ QFont italicFont = valueLabel->font();
+ italicFont.setItalic(true);
+ valueLabel->setFont(italicFont);
+ QPalette pal = valueLabel->palette();
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
+ valueLabel->setPalette(pal);
+ headerLayout->addStretch();
+ headerLayout->addWidget(valueLabel);
+ if (reserveHeaderRightSlot)
+ addCollapsibleHeaderRightReserve(headerLayout, header);
+ mainLayout->addWidget(header);
+
+ QWidget *content = new QWidget(container);
+ const bool isExpanded = collapsedStateFromEnv(storageKey, false);
+ content->setVisible(isExpanded);
+ toggleButton->setChecked(isExpanded);
+ toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
+
+ QVBoxLayout *contentLayout = new QVBoxLayout(content);
+ applyCollapsibleContentLayout(contentLayout);
+
+ QLineEdit *lineEdit = new QLineEdit(content);
+ lineEdit->setObjectName("collapsibleTextEdit");
+ lineEdit->setText(textValue);
+ styleCollapsibleField(lineEdit);
+ contentLayout->addWidget(lineEdit);
+ mainLayout->addWidget(content);
+
+ QObject::connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, storageKey](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+ setCollapsedStateInEnv(storageKey, checked);
+ });
+
+ QObject::connect(lineEdit, &QLineEdit::editingFinished,
+ [lineEdit, valueLabel, onChanged]() {
+ valueLabel->setText(lineEdit->text());
+ if (onChanged) onChanged(lineEdit->text());
+ });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsibleSection(
+ const QString &label, const std::string &storageKey, QWidget *contentWidget,
+ const QString &headerValue, const QString &iconName) {
+ QWidget *container = new QWidget(m_propertiesContainer);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(container);
+ mainLayout->setMargin(0);
+ mainLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ QWidget *header = new QWidget(container);
+ header->setFixedHeight(CollapsibleStyle::kHeaderRowHeight);
+ QHBoxLayout *headerLayout = new QHBoxLayout(header);
+ initCollapsibleHeader(headerLayout);
+
+ QToolButton *toggleButton = new QToolButton(header);
+ toggleButton->setArrowType(Qt::RightArrow);
+ toggleButton->setCheckable(true);
+ toggleButton->setStyleSheet("QToolButton { border: none; }");
+ toggleButton->setFixedSize(CollapsibleStyle::kToggleSize,
+ CollapsibleStyle::kToggleSize);
+ headerLayout->addWidget(toggleButton);
+
+ if (!iconName.isEmpty()) {
+ QLabel *iconLabel = new QLabel(header);
+ QIcon qi = createQIcon(iconName);
+ if (!qi.isNull()) iconLabel->setPixmap(qi.pixmap(16, 16));
+ headerLayout->addWidget(iconLabel);
+ }
+
+ QLabel *nameLabel = new QLabel(label, header);
+ nameLabel->setVisible(m_showLabels);
+ headerLayout->addWidget(nameLabel);
+
+ if (!headerValue.isEmpty()) {
+ QLabel *valueLabel = new QLabel(headerValue, header);
+ QFont italicFont = valueLabel->font();
+ italicFont.setItalic(true);
+ valueLabel->setFont(italicFont);
+ QPalette pal = valueLabel->palette();
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
+ valueLabel->setPalette(pal);
+ headerLayout->addStretch();
+ headerLayout->addWidget(valueLabel);
+ } else {
+ headerLayout->addStretch();
+ }
+
+ mainLayout->addWidget(header);
+
+ QWidget *content = new QWidget(container);
+ const bool isExpanded = collapsedStateFromEnv(storageKey, false);
+ content->setVisible(isExpanded);
+ toggleButton->setChecked(isExpanded);
+ toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
+
+ QVBoxLayout *contentLayout = new QVBoxLayout(content);
+ applyCollapsibleContentLayout(contentLayout);
+ if (contentWidget) {
+ contentWidget->setParent(content);
+ const QSizePolicy::Policy hPolicy =
+ contentWidget->sizePolicy().horizontalPolicy();
+ if (hPolicy == QSizePolicy::Expanding ||
+ hPolicy == QSizePolicy::MinimumExpanding)
+ contentLayout->addWidget(contentWidget, 1);
+ else
+ contentLayout->addWidget(contentWidget, 0, Qt::AlignLeft);
+ }
+ mainLayout->addWidget(content);
+
+ QObject::connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, storageKey](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+ setCollapsedStateInEnv(storageKey, checked);
+ });
+
return container;
}
+void ToolPropertiesPanel::syncCollapsiblePicker(QWidget *container, int index) {
+ if (!container || index < 0) return;
+
+ if (QLabel *valueLabel = container->findChild<QLabel *>("pickerValueLabel")) {
+ if (auto *group =
+ container->findChild<QButtonGroup *>("pickerButtonGroup")) {
+ if (QAbstractButton *btn = group->button(index)) {
+ valueLabel->setText(btn->text());
+ btn->setChecked(true);
+ container->setProperty("pickerCurrentIndex", index);
+ }
+ }
+ }
+}
+
+QWidget *ToolPropertiesPanel::createAnimateColumnPicker(
+ TXsheetHandle *xshHandle, TObjectHandle *objHandle) {
+ TXsheet *xsh = xshHandle->getXsheet();
+ QStringList items;
+ QVariantList codes;
+
+ for (int i = 0; i < xsh->getStageObjectTree()->getStageObjectCount(); ++i) {
+ TStageObjectId id = xsh->getStageObjectTree()->getStageObject(i)->getId();
+ if (id.isColumn()) {
+ int columnIndex = id.getIndex();
+ if (xsh->isColumnEmpty(columnIndex)) continue;
+ }
+
+ TStageObject *pegbar = xsh->getStageObject(id);
+ QString itemName =
+ id.isTable() ? tr("Table") : QString::fromStdString(pegbar->getName());
+ items << itemName;
+ codes << QVariant((int)id.getCode());
+ }
+
+ TStageObjectId curObjId = objHandle->getObjectId();
+ int currentIndex = -1;
+ for (int i = 0; i < codes.size(); ++i) {
+ if (codes[i].toInt() == (int)curObjId.getCode()) {
+ currentIndex = i;
+ break;
+ }
+ }
+ if (currentIndex < 0) {
+ TStageObject *pegbar = xsh->getStageObject(curObjId);
+ items << QString::fromStdString(pegbar->getName());
+ codes << QVariant((int)curObjId.getCode());
+ currentIndex = items.size() - 1;
+ }
+
+ QWidget *picker = createCollapsiblePicker(
+ tr("Column"), items, currentIndex, "animate_column",
+ [objHandle, xshHandle, codes](int index) {
+ if (index < 0 || index >= codes.size()) return;
+ TStageObjectId id;
+ id.setCode(codes[index].toInt());
+ if (id == TStageObjectId::NoneId) return;
+ if (id.isCamera()) {
+ TXsheet *xsh = xshHandle->getXsheet();
+ if (xsh->getCameraColumnIndex() != id.getIndex())
+ xshHandle->changeXsheetCamera(id.getIndex());
+ }
+ objHandle->setObjectId(id);
+ });
+ picker->setProperty("pickerCodes", codes);
+ return picker;
+}
+
//-----------------------------------------------------------------------------
// createCollapsibleEnumWithIcons - Collapsible enum with icons for each option
//-----------------------------------------------------------------------------
-QWidget* ToolPropertiesPanel::createCollapsibleEnumWithIcons(
- const QString &label, const QStringList &items,
- int currentIndex, const std::string &propName,
- const QStringList &iconNames) {
-
+QWidget *ToolPropertiesPanel::createCollapsibleEnumWithIcons(
+ const QString &label, const QStringList &items, int currentIndex,
+ const std::string &propName, const QStringList &iconNames) {
QWidget *container = new QWidget(this);
container->setProperty("propName", QString::fromStdString(propName));
container->setProperty("propGroup", 0);
-
+
QVBoxLayout *mainLayout = new QVBoxLayout(container);
mainLayout->setMargin(0);
mainLayout->setSpacing(2);
-
+
// Header row with toggle button, label, and current value
QHBoxLayout *headerLayout = new QHBoxLayout();
headerLayout->setMargin(0);
headerLayout->setSpacing(5);
-
+
// Collapsible toggle button (triangle)
QToolButton *toggleButton = new QToolButton(container);
toggleButton->setArrowType(Qt::DownArrow);
toggleButton->setCheckable(true);
toggleButton->setAutoRaise(true);
toggleButton->setFixedSize(16, 16);
-
+
// Load collapsed state from TEnv
bool isExpanded = collapsedStateFromEnv(propName, true);
toggleButton->setChecked(isExpanded);
toggleButton->setArrowType(isExpanded ? Qt::DownArrow : Qt::RightArrow);
-
+
headerLayout->addWidget(toggleButton);
-
+
// Label
QLabel *nameLabel = new QLabel(label, container);
nameLabel->setVisible(m_showLabels);
headerLayout->addWidget(nameLabel);
-
+
headerLayout->addStretch();
-
+
// Value label showing current selection (attenuated: italic + disabled color)
QLabel *valueLabel = new QLabel(items.value(currentIndex, ""), container);
valueLabel->setObjectName("valueLabel");
@@ -1975,12 +3467,13 @@ QWidget* ToolPropertiesPanel::createCollapsibleEnumWithIcons(
valueLabel->setFont(italicFont);
// Use palette disabled text color for attenuation (theme-aware)
QPalette pal = valueLabel->palette();
- pal.setColor(QPalette::WindowText, palette().color(QPalette::Disabled, QPalette::WindowText));
+ pal.setColor(QPalette::WindowText,
+ palette().color(QPalette::Disabled, QPalette::WindowText));
valueLabel->setPalette(pal);
headerLayout->addWidget(valueLabel);
-
+
mainLayout->addLayout(headerLayout);
-
+
// Content widget (collapsible options)
QWidget *content = new QWidget(container);
content->setVisible(isExpanded);
@@ -1988,323 +3481,3513 @@ QWidget* ToolPropertiesPanel::createCollapsibleEnumWithIcons(
contentLayout->setMargin(0);
contentLayout->setContentsMargins(20, 0, 0, 0); // Indent content
contentLayout->setSpacing(2);
-
+
// Create button group for exclusive selection
QButtonGroup *buttonGroup = new QButtonGroup(content);
buttonGroup->setExclusive(true);
-
+
bool showIcons = m_showIcons;
-
+
// Create checkable buttons with icons using custom ToolPropertyButton
for (int i = 0; i < items.size(); ++i) {
- ToolPropertyButton *optionButton = new ToolPropertyButton("", container); // Empty text, we'll add via layout
+ ToolPropertyButton *optionButton = new ToolPropertyButton(
+ "", container); // Empty text, we'll add via layout
optionButton->setCursor(Qt::PointingHandCursor);
optionButton->setCheckable(true);
optionButton->setAutoExclusive(true);
optionButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
optionButton->setMinimumHeight(24);
optionButton->setMinimumWidth(100);
-
+
// Set Cells Borders/Backgrounds state
optionButton->setShowBorders(m_showBorders);
optionButton->setShowBackgrounds(m_showBackgrounds);
-
- // For buttons with custom layout, we need to override the paintEvent text drawing
- // Create layout for button content: text on left, icon on right
+
+ // For buttons with custom layout, we need to override the paintEvent text
+ // drawing Create layout for button content: text on left, icon on right
QHBoxLayout *btnLayout = new QHBoxLayout(optionButton);
btnLayout->setMargin(4);
btnLayout->setSpacing(5);
-
+
QLabel *textLabel = new QLabel(items[i], optionButton);
textLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
btnLayout->addWidget(textLabel);
-
+
btnLayout->addStretch();
-
+
// Add icon on the right if showIcons is true and icon exists
- // Use QToolButton with setIcon() so it redraws on theme change via SvgIconEngine
+ // Use QToolButton with setIcon() so it redraws on theme change via
+ // SvgIconEngine
if (showIcons && i < iconNames.size() && !iconNames[i].isEmpty()) {
QToolButton *iconBtn = new QToolButton(optionButton);
iconBtn->setIcon(createQIcon(iconNames[i].toStdString().c_str()));
iconBtn->setIconSize(QSize(16, 16));
- iconBtn->setAutoRaise(true); // Transparent background
+ iconBtn->setAutoRaise(true); // Transparent background
iconBtn->setFocusPolicy(Qt::NoFocus); // Non-focusable
- iconBtn->setAttribute(Qt::WA_TransparentForMouseEvents); // Non-interactive
+ iconBtn->setAttribute(
+ Qt::WA_TransparentForMouseEvents); // Non-interactive
btnLayout->addWidget(iconBtn);
}
-
+
// Set initial checked state
if (i == currentIndex) {
optionButton->setChecked(true);
}
-
+
buttonGroup->addButton(optionButton, i);
contentLayout->addWidget(optionButton);
}
-
+
mainLayout->addWidget(content);
-
+
// Toggle behavior - Save state on change
- connect(toggleButton, &QToolButton::toggled, [content, toggleButton, propName](bool checked) {
- content->setVisible(checked);
- toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
-
- setCollapsedStateInEnv(propName, checked);
- });
-
+ connect(
+ toggleButton, &QToolButton::toggled,
+ [content, toggleButton, propName](bool checked) {
+ content->setVisible(checked);
+ toggleButton->setArrowType(checked ? Qt::DownArrow : Qt::RightArrow);
+
+ setCollapsedStateInEnv(propName, checked);
+ });
+
// Connect button group to property update
- connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked),
+ connect(buttonGroup, &QButtonGroup::idClicked,
[this, valueLabel, items, container](int id) {
- valueLabel->setText(items.value(id, ""));
-
- std::string propName = container->property("propName").toString().toStdString();
- int propGroup = container->property("propGroup").toInt();
-
- TTool *tool = getCurrentTool();
- if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(propGroup);
- if (!props) return;
-
- for (int k = 0; k < props->getPropertyCount(); ++k) {
- TProperty *prop = props->getProperty(k);
- if (prop && prop->getName() == propName) {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- enumProp->setIndex(id);
- tool->onPropertyChanged(propName);
- if (m_toolHandle) m_toolHandle->notifyToolChanged();
- }
- break;
- }
- }
- });
-
- return container;
+ valueLabel->setText(items.value(id, ""));
+
+ std::string propName =
+ container->property("propName").toString().toStdString();
+ int propGroup = container->property("propGroup").toInt();
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int k = 0; k < props->getPropertyCount(); ++k) {
+ TProperty *prop = props->getProperty(k);
+ if (prop && prop->getName() == propName) {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (enumProp) {
+ enumProp->setIndex(id);
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ break;
+ }
+ }
+ });
+
+ return container;
+}
+
+namespace {
+
+// Enum icon grid — 3-column framed panel (replaces collapsible enum when Show
+// Icons is on).
+constexpr int kEnumIconGridCols = 3;
+constexpr int kEnumIconGridBtnSize = 40;
+constexpr int kEnumIconGridIconSize = 20;
+constexpr int kEnumIconGridFrameRadius = 6;
+constexpr int kEnumIconGridFramePad = 8;
+constexpr int kEnumIconGridSpacingH = 10;
+constexpr int kEnumIconGridSpacingV = 8;
+constexpr int kEnumIconGridLabelGap =
+ 3; // air below label descenders (g, p, q)
+
+void applyEnumIconGridFrameStyle(QFrame *frame, bool showBorder,
+ bool showBackground, const QPalette &pal) {
+ Q_UNUSED(showBackground);
+ frame->setFrameShape(QFrame::NoFrame);
+ QStringList rules;
+ // Cell backgrounds are drawn per icon button (same as collapsible enum
+ // cells).
+ rules << QStringLiteral("background-color: transparent");
+ if (showBorder) {
+ rules << QStringLiteral("border: 1px solid %1")
+ .arg(pal.color(QPalette::Mid).name());
+ } else {
+ rules << QStringLiteral("border: none");
+ }
+ rules << QStringLiteral("border-radius: %1px").arg(kEnumIconGridFrameRadius);
+ frame->setStyleSheet(QStringLiteral("QFrame#tppEnumIconGridFrame { %1 }")
+ .arg(rules.join("; ")));
+}
+
+// Resolve SVG icon name for enum items that do not carry iconName in the tool
+// source.
+QString resolveEnumItemIcon(TTool *tool, const std::string &propName,
+ const std::wstring &value) {
+ const QString v = QString::fromStdWString(value);
+ const QString pn = QString::fromStdString(propName);
+
+ if (v.endsWith(QStringLiteral("_cap"), Qt::CaseInsensitive) ||
+ v.endsWith(QStringLiteral("_join"), Qt::CaseInsensitive))
+ return v;
+
+ if (!tool) return QString();
+ const QString tid = QString::fromStdString(tool->getName());
+
+ if (pn == QLatin1String("Shape:") || pn == QLatin1String("Shape")) {
+ if (v == QLatin1String("Rectangle"))
+ return QStringLiteral("geometric_rectangle");
+ if (v == QLatin1String("Circle")) return QStringLiteral("geometric_circle");
+ if (v == QLatin1String("Ellipse"))
+ return QStringLiteral("geometric_ellipse");
+ if (v == QLatin1String("Line")) return QStringLiteral("geometric_line");
+ if (v == QLatin1String("Polyline"))
+ return QStringLiteral("geometric_polyline");
+ if (v == QLatin1String("Arc")) return QStringLiteral("geometric_arc");
+ if (v == QLatin1String("MultiArc"))
+ return QStringLiteral("geometric_multiarc");
+ if (v == QLatin1String("Polygon"))
+ return QStringLiteral("geometric_polygon");
+ return QString();
+ }
+
+ if (pn == QLatin1String("Type:") || pn == QLatin1String("Type")) {
+ QString prefix;
+ if (tid == QLatin1String(T_Fill))
+ prefix = QStringLiteral("fill_");
+ else if (tid == QLatin1String(T_Eraser))
+ prefix = QStringLiteral("eraser_");
+ else if (tid == QLatin1String(T_Tape))
+ prefix = QStringLiteral("tape_");
+ else if (tid == QLatin1String(T_Selection))
+ prefix = QStringLiteral("selection_");
+
+ if (prefix.isEmpty()) return QString();
+
+ if (v == QLatin1String("Normal")) return prefix + QStringLiteral("normal");
+ if (v == QLatin1String("Rectangular"))
+ return prefix + QStringLiteral("rectangular");
+ if (v == QLatin1String("Freehand"))
+ return prefix + QStringLiteral("freehand");
+ if (v == QLatin1String("Polyline"))
+ return prefix + QStringLiteral("polyline");
+ if (v == QLatin1String("Freepick"))
+ return prefix + QStringLiteral("freepick");
+ if (v == QLatin1String("Segment"))
+ return prefix + QStringLiteral("segment");
+ return QString();
+ }
+
+ if (pn == QLatin1String("Mode:") || pn == QLatin1String("Mode")) {
+ if (tid == QLatin1String(T_Fill) || tid == QLatin1String(T_Eraser) ||
+ tid == QLatin1String(T_PaintBrush) || tid == QLatin1String(T_Finger) ||
+ tid == QLatin1String(T_StylePicker)) {
+ if (v == QLatin1String("Lines")) return QStringLiteral("fill_mode_lines");
+ if (v == QLatin1String("Areas")) return QStringLiteral("fill_mode_areas");
+ if (v == QLatin1String("Lines & Areas"))
+ return QStringLiteral("fill_mode_lines_areas");
+ }
+ if (tid == QLatin1String(T_Tape)) {
+ if (v == QLatin1String("Endpoint to Endpoint"))
+ return QStringLiteral("tape_end_to_end");
+ if (v == QLatin1String("Endpoint to Line"))
+ return QStringLiteral("tape_end_to_line");
+ if (v == QLatin1String("Line to Line"))
+ return QStringLiteral("tape_line_to_line");
+ }
+ if (tid == QLatin1String(T_Selection) && v == QLatin1String("Standard"))
+ return QStringLiteral("selection_normal");
+ }
+
+ return QString();
+}
+
+QStringList collectEnumItemIcons(TTool *tool, TEnumProperty *enumProp) {
+ QStringList icons;
+ if (!enumProp) return icons;
+
+ const TEnumProperty::Items &items = enumProp->getItems();
+ const TEnumProperty::Range &range = enumProp->getRange();
+ const int count = std::min((int)items.size(), (int)range.size());
+ icons.reserve(count);
+ for (int i = 0; i < count; ++i) {
+ if (!items[i].iconName.isEmpty())
+ icons << items[i].iconName;
+ else
+ icons << resolveEnumItemIcon(tool, enumProp->getName(), range[i]);
+ }
+ return icons;
+}
+
+bool enumIconsComplete(const QStringList &icons, int itemCount) {
+ if ((int)icons.size() < itemCount || itemCount <= 0) return false;
+ for (int i = 0; i < itemCount; ++i) {
+ if (icons[i].isEmpty()) return false;
+ }
+ return true;
+}
+
+} // namespace
+
+QWidget *ToolPropertiesPanel::createEnumIconGridPanel(
+ const QString &label, TEnumProperty *enumProp, const std::string &propName,
+ int propGroup, QWidget *parentWidget,
+ const std::function<void(int)> &onChanged) {
+ if (!enumProp) return nullptr;
+
+ TTool *tool = getCurrentTool();
+ const QStringList iconNames = collectEnumItemIcons(tool, enumProp);
+ const TEnumProperty::Items &items = enumProp->getItems();
+ if (!enumIconsComplete(iconNames, (int)items.size())) return nullptr;
+
+ QWidget *host = parentWidget ? parentWidget : m_propertiesContainer;
+ QWidget *container = new QWidget(host);
+ container->setProperty("propName", QString::fromStdString(propName));
+ container->setProperty("propGroup", propGroup);
+ storeTppPropertyPtr(container, enumProp);
+ container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ QVBoxLayout *outerLayout = new QVBoxLayout(container);
+ outerLayout->setContentsMargins(0, 0, 0, 0);
+ outerLayout->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ const QString sectionLabel =
+ label.isEmpty() ? enumProp->getQStringName() : label;
+ if (m_showLabels && !sectionLabel.isEmpty()) {
+ auto *nameLabel = new QLabel(sectionLabel, container);
+ nameLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ outerLayout->addWidget(nameLabel);
+ outerLayout->addSpacing(kEnumIconGridLabelGap);
+ }
+
+ QFrame *frame = new QFrame(container);
+ frame->setObjectName(QStringLiteral("tppEnumIconGridFrame"));
+ applyEnumIconGridFrameStyle(frame, m_showBorders, m_showBackgrounds,
+ palette());
+
+ // Host grid on a plain widget so icon cells inherit toolOptionsPanel palette
+ // (styled QFrame parents can make cell backgrounds read too dark).
+ QWidget *gridHost = new QWidget(frame);
+ gridHost->setAttribute(Qt::WA_TranslucentBackground);
+ gridHost->setAutoFillBackground(false);
+
+ QVBoxLayout *frameLayout = new QVBoxLayout(frame);
+ frameLayout->setContentsMargins(0, 0, 0, 0);
+ frameLayout->setSpacing(0);
+ frameLayout->addWidget(gridHost);
+
+ QGridLayout *gridLayout = new QGridLayout(gridHost);
+ gridLayout->setContentsMargins(kEnumIconGridFramePad, kEnumIconGridFramePad,
+ kEnumIconGridFramePad, kEnumIconGridFramePad);
+ gridLayout->setHorizontalSpacing(kEnumIconGridSpacingH);
+ gridLayout->setVerticalSpacing(kEnumIconGridSpacingV);
+ for (int col = 0; col < kEnumIconGridCols; ++col)
+ gridLayout->setColumnStretch(col, 1);
+
+ QButtonGroup *buttonGroup = new QButtonGroup(container);
+ buttonGroup->setExclusive(true);
+
+ const int currentIndex = enumProp->getIndex();
+
+ for (int i = 0; i < (int)items.size(); ++i) {
+ const int row = i / kEnumIconGridCols;
+ const int col = i % kEnumIconGridCols;
+
+ ToolPropertyButton *btn = new ToolPropertyButton(QString(), gridHost);
+ btn->setCheckable(true);
+ btn->setCursor(Qt::PointingHandCursor);
+ btn->setAutoFillBackground(false);
+ btn->setFixedSize(kEnumIconGridBtnSize, kEnumIconGridBtnSize);
+ btn->setIconSize(QSize(kEnumIconGridIconSize, kEnumIconGridIconSize));
+ btn->setIcon(createQIcon(iconNames[i].toStdString().c_str()));
+ btn->setToolTip(items[i].UIName);
+ btn->setCompactIconHighlight(kEnumIconGridIconSize);
+ btn->setShowBorders(m_showBorders);
+ btn->setShowBackgrounds(m_showBackgrounds);
+ if (i == currentIndex) btn->setChecked(true);
+
+ buttonGroup->addButton(btn, i);
+ gridLayout->addWidget(btn, row, col, Qt::AlignCenter);
+ }
+
+ outerLayout->addWidget(frame);
+
+ connect(buttonGroup, &QButtonGroup::idClicked,
+ [this, container, propName, onChanged](int id) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ const int group = container->property("propGroup").toInt();
+ TProperty *prop =
+ resolveTppProperty(tool, container, group, propName);
+ if (auto *ep = dynamic_cast<TEnumProperty *>(prop)) {
+ ep->setIndex(id);
+ tool->onPropertyChanged(propName, true);
+ ep->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ if (tool->getName() == T_EditAssistants &&
+ propName == "AssistantType")
+ refreshProperties();
+ }
+
+ if (onChanged) onChanged(id);
+ });
+
+ return container;
+}
+
+QWidget *ToolPropertiesPanel::createCollapsibleEnumForProperty(
+ const QString &label, TEnumProperty *enumProp, const std::string &propName,
+ int propGroup, const QString &headerIconName,
+ const std::function<void(int)> &onChanged, bool reserveHeaderRightSlot,
+ QWidget *parentWidget) {
+ if (!enumProp) return nullptr;
+
+ QStringList items;
+ for (const auto &item : enumProp->getItems()) items << item.UIName;
+ if (items.isEmpty()) return nullptr;
+
+ const int index = enumProp->getIndex();
+ QWidget *widget = nullptr;
+
+ if (m_showIcons) {
+ widget = createEnumIconGridPanel(label, enumProp, propName, propGroup,
+ parentWidget, onChanged);
+ }
+
+ if (!widget) {
+ widget =
+ createCollapsibleEnum(label, items, index, propName, headerIconName,
+ onChanged, reserveHeaderRightSlot, parentWidget);
+ }
+
+ if (widget) {
+ widget->setProperty("propGroup", propGroup);
+ storeTppPropertyPtr(widget, enumProp);
+ }
+ return widget;
+}
+
+//=============================================================================
+// Generic Property Helpers
+// Name-based property lookup: each helper is a no-op when the property is
+// absent from the current tool's group — identical to the brush pattern.
+//=============================================================================
+
+void ToolPropertiesPanel::createEnumProperty(const QString &label,
+ const std::string &propName,
+ int propGroup,
+ const QString &iconName) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop || prop->getName() != propName) continue;
+
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (!enumProp) return;
+
+ if (enumProp->getItems().empty()) return;
+
+ QWidget *w = createCollapsibleEnumForProperty(label, enumProp, propName,
+ propGroup, iconName);
+ if (!w) return;
+ m_propertiesLayout->addWidget(w);
+ return;
+ }
+}
+
+void ToolPropertiesPanel::createBoolProperty(const QString &label,
+ const std::string &propName,
+ int propGroup) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop || prop->getName() != propName) continue;
+
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
+ if (!boolProp) return;
+
+ QWidget *w = createCheckBox(label, boolProp->getValue(), propName);
+ w->setProperty("propGroup", propGroup);
+ m_propertiesLayout->addWidget(w);
+ return;
+ }
+}
+
+void ToolPropertiesPanel::createDoublePairByName(const QString &label,
+ const std::string &propName,
+ int propGroup) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop || prop->getName() != propName) continue;
+
+ TDoublePairProperty *dp = dynamic_cast<TDoublePairProperty *>(prop);
+ if (dp) {
+ createDoublePairSlider(label, dp, propName, propGroup);
+ return;
+ }
+ TIntPairProperty *ip = dynamic_cast<TIntPairProperty *>(prop);
+ if (ip) {
+ createIntPairSlider(label, ip, propName, propGroup);
+ return;
+ }
+ return;
+ }
+}
+
+void ToolPropertiesPanel::createIntSliderByName(const QString &label,
+ const std::string &propName,
+ int propGroup) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop || prop->getName() != propName) continue;
+
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
+ if (!intProp) return;
+
+ int min = intProp->getRange().first;
+ int max = intProp->getRange().second;
+ int val = intProp->getValue();
+
+ QWidget *w = createSliderWithLabel(label, min, max, val, propName);
+ w->setProperty("propGroup", propGroup);
+ m_propertiesLayout->addWidget(w);
+ return;
+ }
+}
+
+void ToolPropertiesPanel::createDoubleSliderByName(const QString &label,
+ const std::string &propName,
+ int propGroup) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop || prop->getName() != propName) continue;
+
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
+ if (!doubleProp) return;
+
+ double min = doubleProp->getRange().first;
+ double max = doubleProp->getRange().second;
+ double val = doubleProp->getValue();
+
+ QWidget *w = createDoubleSliderWithLabel(label, min, max, val, propName);
+ w->setProperty("propGroup", propGroup);
+ m_propertiesLayout->addWidget(w);
+ return;
+ }
+}
+
+//=============================================================================
+// Eraser Properties Creation
+//
+// Exact Tool Options Bar order (left→right = top→bottom):
+//
+// Vector: Size | Type | Selective | Invert | Frame Range |
+// Toonz Raster: Size | Hardness | Type | Mode | Selective |
+// Invert | Frame Range | Pencil Mode | Savebox
+// FullColor: Size | Hardness | Opacity | Type | Invert | Frame Range
+//
+// Calls that do not match the current tool type are no-ops.
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+// Generic property builder — works for any tool without hardcoding prop names.
+// Iterates all TProperty in the given group and creates appropriate widgets.
+//-----------------------------------------------------------------------------
+
+bool ToolPropertiesPanel::createGenericProperties(int propGroup,
+ QVBoxLayout *targetLayout,
+ bool plasticAlignedFields) {
+ TTool *tool = getCurrentTool();
+ if (!tool) return false;
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props || props->getPropertyCount() == 0) return false;
+
+ QVBoxLayout *layout = targetLayout ? targetLayout : m_propertiesLayout;
+ bool addedAny = false;
+ // Guard against tools that bind the same property twice in one group.
+ std::set<std::string> seenNames;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop) continue;
+
+ const std::string name = prop->getName();
+ if (seenNames.count(name)) continue; // skip duplicate property
+ seenNames.insert(name);
+
+ // Use translated UI name; fall back to internal name
+ QString label = prop->getQStringName();
+ if (label.isEmpty()) label = QString::fromStdString(name);
+ QWidget *w = nullptr;
+
+ if (auto *ep = dynamic_cast<TEnumProperty *>(prop)) {
+ if (ep->getItems().empty()) continue;
+ w = createCollapsibleEnumForProperty(
+ label, ep, name, propGroup, QString(), nullptr, plasticAlignedFields);
+
+ } else if (auto *bp = dynamic_cast<TBoolProperty *>(prop)) {
+ w = createCheckBox(label, bp->getValue(), name);
+
+ } else if (auto *ip = dynamic_cast<TIntProperty *>(prop)) {
+ auto range = ip->getRange();
+ w = createSliderWithLabel(label, static_cast<int>(range.first),
+ static_cast<int>(range.second), ip->getValue(),
+ name);
+
+ } else if (auto *dp = dynamic_cast<TDoubleProperty *>(prop)) {
+ auto range = dp->getRange();
+ w = createDoubleSliderWithLabel(label, range.first, range.second,
+ dp->getValue(), name);
+
+ } else if (auto *sp = dynamic_cast<TStringProperty *>(prop)) {
+ w = createTextProperty(label, sp, name, propGroup);
+
+ } else if (dynamic_cast<TDoublePairProperty *>(prop)) {
+ // Reuse existing helper (does its own lookup, no widget returned)
+ createDoublePairByName(label, name, propGroup);
+ addedAny = true;
+ continue;
+
+ } else if (dynamic_cast<TIntPairProperty *>(prop)) {
+ createIntPairSlider(label, prop, name, propGroup);
+ addedAny = true;
+ continue;
+ }
+ // TPointerProperty, etc. — skip silently
+
+ if (w) {
+ w->setProperty("propGroup", propGroup);
+ storeTppPropertyPtr(w, prop);
+ layout->addWidget(w);
+ if (plasticAlignedFields) uniformPlasticFieldWidget(w);
+ addedAny = true;
+ }
+ }
+
+ return addedAny;
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::createRulerProperties() {
+ TTool *tool = getCurrentTool();
+ auto *ruler = dynamic_cast<RulerTool *>(tool);
+ if (!ruler)
+ ruler =
+ dynamic_cast<RulerTool *>(TTool::getTool("T_Ruler", TTool::ToonzImage));
+ if (!ruler) return;
+ if (!tool) tool = ruler;
+
+ if (!m_rulerOptionsBox) {
+ m_rulerOptionsBox =
+ new RulerToolOptionsBox(m_propertiesContainer, tool, true);
+ m_rulerOptionsBox->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+ } else {
+ m_rulerOptionsBox->setParent(m_propertiesContainer);
+ }
+
+ if (!m_rulerOptionsBoxRegistered) {
+ ruler->setToolOptionsBox(m_rulerOptionsBox);
+ m_rulerOptionsBoxRegistered = true;
+ }
+
+ m_rulerOptionsBox->resetValues();
+ m_rulerOptionsBox->show();
+ m_propertiesLayout->addWidget(m_rulerOptionsBox);
+}
+
+void ToolPropertiesPanel::createEditAssistantsProperties() {
+ // EditAssistantsTool::getProperties() rebuilds its group on every call and
+ // must not be invoked from change handlers — store direct TProperty* on
+ // widgets.
+ createGenericProperties(0);
+}
+
+namespace {
+
+void resetShiftTraceGhost(int index) {
+ TApplication *app = TApp::instance();
+ if (!app) return;
+ OnionSkinMask osm = app->getCurrentOnionSkin()->getOnionSkinMask();
+ osm.setShiftTraceGhostCenter(index, TPointD());
+ osm.setShiftTraceGhostAff(index, TAffine());
+ app->getCurrentOnionSkin()->setOnionSkinMask(osm);
+ app->getCurrentOnionSkin()->notifyOnionSkinMaskChanged();
+ if (TTool *tool = app->getCurrentTool()->getTool()) tool->reset();
+}
+
+bool shiftTraceGhostHasShift(int index) {
+ TApplication *app = TApp::instance();
+ if (!app) return false;
+ const OnionSkinMask osm = app->getCurrentOnionSkin()->getOnionSkinMask();
+ return !(osm.getShiftTraceGhostAff(index).isIdentity() &&
+ osm.getShiftTraceGhostCenter(index) == TPointD());
+}
+
+ShiftTraceTool *activeShiftTraceTool() {
+ if (TTool *tool = TApp::instance()->getCurrentTool()->getTool())
+ return dynamic_cast<ShiftTraceTool *>(tool);
+ return dynamic_cast<ShiftTraceTool *>(
+ TTool::getTool(T_ShiftTrace, TTool::ToonzImage));
+}
+
+void setShiftTraceGhostIndex(int index) {
+ if (ShiftTraceTool *st = activeShiftTraceTool())
+ st->setCurrentGhostIndex(index);
+}
+
+QCheckBox *addShiftTraceToggleRow(QVBoxLayout *layout, QWidget *parent,
+ QAction *action, QCheckBox **storedPtr) {
+ if (!layout || !parent || !action) return nullptr;
+ QCheckBox *checkBox = new QCheckBox(action->text(), parent);
+ checkBox->setChecked(action->isChecked());
+ checkBox->setEnabled(action->isEnabled());
+ layout->addWidget(checkBox);
+ QObject::connect(checkBox, &QCheckBox::clicked, action, &QAction::trigger);
+ QObject::connect(action, &QAction::toggled, checkBox, &QCheckBox::setChecked);
+ QObject::connect(action, &QAction::changed, checkBox, [checkBox, action]() {
+ checkBox->setEnabled(action->isEnabled());
+ });
+ if (storedPtr) *storedPtr = checkBox;
+ return checkBox;
+}
+
+} // namespace
+
+void ToolPropertiesPanel::createShiftTraceProperties() {
+ CommandManager *cm = CommandManager::instance();
+ if (!cm) return;
+
+ QAction *noShiftAct = cm->getAction(MI_NoShift);
+ QAction *resetShiftAct = cm->getAction(MI_ResetShift);
+ if (!noShiftAct || !resetShiftAct) return;
+
+ ShiftTraceTool *stTool = activeShiftTraceTool();
+ const int ghostIndex = stTool ? stTool->getCurrentGhostIndex() : 0;
+
+ const QStringList ghostItems{tr("Previous Drawing"), tr("Following Drawing")};
+ m_shiftTraceGhostPicker = createCollapsibleEnum(
+ tr("Drawing"), ghostItems, ghostIndex, "shift_trace_ghost", QString(),
+ [](int index) { setShiftTraceGhostIndex(index); });
+ if (m_shiftTraceGhostPicker) {
+ m_shiftTraceGhostPicker->setObjectName("shiftTraceGhostPicker");
+ m_propertiesLayout->addWidget(m_shiftTraceGhostPicker);
+ }
+
+ QWidget *resetRow = new QWidget(m_propertiesContainer);
+ QHBoxLayout *resetLayout = new QHBoxLayout(resetRow);
+ resetLayout->setContentsMargins(0, 0, 0, 0);
+ resetLayout->setSpacing(CollapsibleStyle::kHeaderSpacing);
+
+ m_shiftTraceResetPrevBtn = new QPushButton(tr("Reset Previous"), resetRow);
+ m_shiftTraceResetFollowingBtn =
+ new QPushButton(tr("Reset Following"), resetRow);
+ m_shiftTraceResetPrevBtn->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Fixed);
+ m_shiftTraceResetFollowingBtn->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Fixed);
+ resetLayout->addWidget(m_shiftTraceResetPrevBtn);
+ resetLayout->addWidget(m_shiftTraceResetFollowingBtn);
+ m_propertiesLayout->addWidget(resetRow);
+
+ QObject::connect(m_shiftTraceResetPrevBtn, &QPushButton::clicked,
+ []() { resetShiftTraceGhost(0); });
+ QObject::connect(m_shiftTraceResetFollowingBtn, &QPushButton::clicked,
+ []() { resetShiftTraceGhost(1); });
+
+ m_propertiesLayout->addSpacing(CollapsibleStyle::kBlockGap);
+
+ if (m_showIcons) {
+ QWidget *iconRow = new QWidget(m_propertiesContainer);
+ QHBoxLayout *iconLayout = new QHBoxLayout(iconRow);
+ iconLayout->setContentsMargins(0, 0, 0, 0);
+ iconLayout->setSpacing(CollapsibleStyle::kHeaderSpacing);
+
+ m_shiftTraceNoShiftIconBtn = new ToolPropertyButton(QString(), iconRow);
+ m_shiftTraceNoShiftIconBtn->setCheckable(true);
+ m_shiftTraceNoShiftIconBtn->setCursor(Qt::PointingHandCursor);
+ m_shiftTraceNoShiftIconBtn->setToolTip(noShiftAct->text());
+ m_shiftTraceNoShiftIconBtn->setIcon(
+ createQIcon("shift_and_trace_no_shift"));
+ m_shiftTraceNoShiftIconBtn->setIconSize(QSize(20, 20));
+ m_shiftTraceNoShiftIconBtn->setFixedSize(32, 32);
+ m_shiftTraceNoShiftIconBtn->setShowBorders(m_showBorders);
+ m_shiftTraceNoShiftIconBtn->setShowBackgrounds(m_showBackgrounds);
+ m_shiftTraceNoShiftIconBtn->setChecked(noShiftAct->isChecked());
+ m_shiftTraceNoShiftIconBtn->setEnabled(noShiftAct->isEnabled());
+ iconLayout->addWidget(m_shiftTraceNoShiftIconBtn);
+
+ m_shiftTraceResetShiftIconBtn = new ToolPropertyButton(QString(), iconRow);
+ m_shiftTraceResetShiftIconBtn->setCursor(Qt::PointingHandCursor);
+ m_shiftTraceResetShiftIconBtn->setToolTip(resetShiftAct->text());
+ m_shiftTraceResetShiftIconBtn->setIcon(
+ createQIcon("shift_and_trace_reset"));
+ m_shiftTraceResetShiftIconBtn->setIconSize(QSize(20, 20));
+ m_shiftTraceResetShiftIconBtn->setFixedSize(32, 32);
+ m_shiftTraceResetShiftIconBtn->setShowBorders(m_showBorders);
+ m_shiftTraceResetShiftIconBtn->setShowBackgrounds(m_showBackgrounds);
+ m_shiftTraceResetShiftIconBtn->setEnabled(resetShiftAct->isEnabled());
+ iconLayout->addWidget(m_shiftTraceResetShiftIconBtn);
+ iconLayout->addStretch(1);
+ m_propertiesLayout->addWidget(iconRow);
+
+ QObject::connect(m_shiftTraceNoShiftIconBtn, &QToolButton::clicked,
+ noShiftAct, &QAction::trigger);
+ QObject::connect(noShiftAct, &QAction::toggled, m_shiftTraceNoShiftIconBtn,
+ &QToolButton::setChecked);
+ QObject::connect(m_shiftTraceResetShiftIconBtn, &QToolButton::clicked,
+ resetShiftAct, &QAction::trigger);
+ } else {
+ m_shiftTraceNoShiftChk =
+ addShiftTraceToggleRow(m_propertiesLayout, m_propertiesContainer,
+ noShiftAct, &m_shiftTraceNoShiftChk);
+
+ QPushButton *resetShiftBtn =
+ new QPushButton(resetShiftAct->text(), m_propertiesContainer);
+ resetShiftBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ resetShiftBtn->setEnabled(resetShiftAct->isEnabled());
+ QObject::connect(resetShiftBtn, &QPushButton::clicked, resetShiftAct,
+ &QAction::trigger);
+ QObject::connect(resetShiftAct, &QAction::changed, resetShiftBtn,
+ [resetShiftBtn, resetShiftAct]() {
+ resetShiftBtn->setEnabled(resetShiftAct->isEnabled());
+ });
+ m_propertiesLayout->addWidget(resetShiftBtn);
+ }
+
+ connect(noShiftAct, &QAction::toggled, this,
+ &ToolPropertiesPanel::onShiftTraceCommandChanged);
+ connect(noShiftAct, &QAction::changed, this,
+ &ToolPropertiesPanel::onShiftTraceCommandChanged);
+ connect(resetShiftAct, &QAction::toggled, this,
+ &ToolPropertiesPanel::onShiftTraceCommandChanged);
+ connect(resetShiftAct, &QAction::changed, this,
+ &ToolPropertiesPanel::onShiftTraceCommandChanged);
+
+ updateShiftTraceWidgets();
+}
+
+void ToolPropertiesPanel::updateShiftTraceWidgets() {
+ if (m_currentToolType != QStringLiteral("shifttrace")) return;
+
+ CommandManager *cm = CommandManager::instance();
+ if (!cm) return;
+
+ auto syncCheckableAction = [](QAction *act, QCheckBox *chk,
+ ToolPropertyButton *iconBtn) {
+ if (!act) return;
+ if (chk) {
+ if (chk->isChecked() != act->isChecked()) {
+ chk->blockSignals(true);
+ chk->setChecked(act->isChecked());
+ chk->blockSignals(false);
+ }
+ chk->setEnabled(act->isEnabled());
+ }
+ if (iconBtn) {
+ if (iconBtn->isChecked() != act->isChecked()) {
+ iconBtn->blockSignals(true);
+ iconBtn->setChecked(act->isChecked());
+ iconBtn->blockSignals(false);
+ }
+ iconBtn->setEnabled(act->isEnabled());
+ }
+ };
+
+ syncCheckableAction(cm->getAction(MI_NoShift), m_shiftTraceNoShiftChk,
+ m_shiftTraceNoShiftIconBtn);
+
+ auto syncCollapsibleEnum = [](QWidget *container, int index,
+ const QStringList &items) {
+ if (!container || index < 0 || index >= items.size()) return;
+ if (QLabel *valueLabel = container->findChild<QLabel *>("valueLabel"))
+ valueLabel->setText(items.value(index));
+ if (auto *group = container->findChild<QButtonGroup *>()) {
+ if (QAbstractButton *btn = group->button(index)) {
+ group->blockSignals(true);
+ btn->setChecked(true);
+ group->blockSignals(false);
+ }
+ }
+ };
+
+ ShiftTraceTool *stTool = activeShiftTraceTool();
+ const int ghostIndex = stTool ? stTool->getCurrentGhostIndex() : 0;
+
+ if (m_shiftTraceGhostPicker) {
+ syncCollapsibleEnum(m_shiftTraceGhostPicker, ghostIndex,
+ {tr("Previous Drawing"), tr("Following Drawing")});
+ }
+
+ if (m_shiftTraceResetPrevBtn)
+ m_shiftTraceResetPrevBtn->setEnabled(shiftTraceGhostHasShift(0));
+ if (m_shiftTraceResetFollowingBtn)
+ m_shiftTraceResetFollowingBtn->setEnabled(shiftTraceGhostHasShift(1));
+
+ if (QAction *act = cm->getAction(MI_ResetShift)) {
+ if (m_shiftTraceResetShiftIconBtn)
+ m_shiftTraceResetShiftIconBtn->setEnabled(act->isEnabled());
+ }
+}
+
+void ToolPropertiesPanel::onShiftTraceCommandChanged() {
+ updateShiftTraceWidgets();
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::updatePlasticSkeletonPicker() {
+ if (!m_plasticSkelPicker) return;
+
+ auto *plastic = dynamic_cast<PlasticTool *>(getCurrentTool());
+ if (!plastic) return;
+
+ QStringList items;
+ int currentIndex = -1;
+ const SkDP &sd = plastic->deformation();
+ if (sd) {
+ const int curId = plastic->currentSkeletonId();
+ SkD::skelId_iterator st, sEnd;
+ sd->skeletonIds(st, sEnd);
+ for (int i = 0; st != sEnd; ++st, ++i) {
+ items << QString::number(*st);
+ if (*st == curId) currentIndex = i;
+ }
+ }
+
+ // After removal the skelIds curve can still reference a deleted id — realign.
+ if (currentIndex < 0 && !items.isEmpty()) {
+ plastic->editSkelId_undo(items[0].toInt());
+ return;
+ }
+
+ const int storedCount =
+ m_plasticSkelPicker->property("pickerItemCount").toInt();
+ if (storedCount != items.size()) {
+ rebuildPlasticSkeletonPicker();
+ return;
+ }
+
+ if (items.isEmpty()) {
+ if (QLabel *valueLabel =
+ m_plasticSkelPicker->findChild<QLabel *>("pickerValueLabel"))
+ valueLabel->clear();
+ if (auto *group = m_plasticSkelPicker->findChild<QButtonGroup *>(
+ "pickerButtonGroup")) {
+ if (QAbstractButton *checked = group->checkedButton()) {
+ group->setExclusive(false);
+ checked->setChecked(false);
+ group->setExclusive(true);
+ }
+ }
+ m_plasticSkelPicker->setProperty("pickerCurrentIndex", -1);
+ m_plasticSkelPicker->setProperty("pickerCurrentSkelId", -1);
+ return;
+ }
+
+ if (m_plasticSkelPicker->property("pickerCurrentSkelId").toInt() ==
+ plastic->currentSkeletonId() &&
+ m_plasticSkelPicker->property("pickerCurrentIndex").toInt() ==
+ currentIndex)
+ return;
+
+ syncCollapsiblePicker(m_plasticSkelPicker, currentIndex);
+ m_plasticSkelPicker->setProperty("pickerCurrentSkelId",
+ plastic->currentSkeletonId());
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::updatePlasticVertexField() {
+ if (!m_plasticVertexWidget) return;
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TPropertyGroup *pg = tool->getProperties(PlasticTool::MODES_COUNT);
+ if (!pg) return;
+
+ auto *sp = dynamic_cast<TStringProperty *>(pg->getProperty("vertexName"));
+ if (!sp) return;
+
+ const QString newText = QString::fromStdWString(sp->getValue());
+ if (QLineEdit *textEdit = m_plasticVertexWidget->findChild<QLineEdit *>(
+ "collapsibleTextEdit")) {
+ if (textEdit->text() != newText) {
+ textEdit->blockSignals(true);
+ textEdit->setText(newText);
+ textEdit->blockSignals(false);
+ }
+ }
+ if (QLabel *valueLabel =
+ m_plasticVertexWidget->findChild<QLabel *>("textValueLabel")) {
+ valueLabel->setText(newText);
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::rebuildPlasticSkeletonPicker() {
+ auto *plastic = dynamic_cast<PlasticTool *>(getCurrentTool());
+ if (!plastic || !m_propertiesLayout) return;
+
+ if (const SkDP &sd = plastic->deformation()) {
+ QStringList items;
+ int currentIndex = -1;
+ const int curId = plastic->currentSkeletonId();
+ SkD::skelId_iterator st, sEnd;
+ sd->skeletonIds(st, sEnd);
+ for (int i = 0; st != sEnd; ++st, ++i) {
+ items << QString::number(*st);
+ if (*st == curId) currentIndex = i;
+ }
+ if (currentIndex < 0 && !items.isEmpty()) {
+ plastic->editSkelId_undo(items[0].toInt());
+ return;
+ }
+ }
+
+ if (m_plasticSkelPicker) {
+ m_propertiesLayout->removeWidget(m_plasticSkelPicker);
+ delete m_plasticSkelPicker;
+ m_plasticSkelPicker = nullptr;
+ }
+
+ m_plasticSkelPicker = buildPlasticSkeletonPicker(plastic);
+ if (!m_plasticSkelPicker) return;
+
+ int insertAt = 1;
+ for (int i = 0; i < m_propertiesLayout->count(); ++i) {
+ QLayoutItem *item = m_propertiesLayout->itemAt(i);
+ if (!item || !item->widget()) continue;
+ if (auto *btn = qobject_cast<QPushButton *>(item->widget())) {
+ if (btn->text() == tr("Create Mesh")) {
+ insertAt = i + 1;
+ break;
+ }
+ }
+ }
+ m_propertiesLayout->insertWidget(insertAt, m_plasticSkelPicker);
+}
+
+//-----------------------------------------------------------------------------
+
+QWidget *ToolPropertiesPanel::buildPlasticSkeletonPicker(PlasticTool *plastic) {
+ QStringList items;
+ int currentIndex = -1;
+
+ const SkDP &sd = plastic->deformation();
+ if (sd) {
+ const int curId = plastic->currentSkeletonId();
+ SkD::skelId_iterator st, sEnd;
+ sd->skeletonIds(st, sEnd);
+ for (int i = 0; st != sEnd; ++st, ++i) {
+ items << QString::number(*st);
+ if (*st == curId) currentIndex = i;
+ }
+ }
+
+ const int pickerIndex = currentIndex >= 0 ? currentIndex : 0;
+ const QString headerValue =
+ currentIndex >= 0 ? items.value(currentIndex) : QString();
+
+ QWidget *picker =
+ createCollapsiblePicker(tr("Skeleton:"), items, pickerIndex,
+ "plastic_skeleton", [plastic](int index) {
+ if (!plastic->deformation()) return;
+ QStringList skelItems;
+ SkD::skelId_iterator st, sEnd;
+ plastic->deformation()->skeletonIds(st, sEnd);
+ for (; st != sEnd; ++st)
+ skelItems << QString::number(*st);
+ if (index < 0 || index >= skelItems.size())
+ return;
+ const int skelId = skelItems[index].toInt();
+ if (skelId == plastic->currentSkeletonId())
+ return;
+ plastic->editSkelId_undo(skelId);
+ });
+ picker->setObjectName("plasticSkelPicker");
+ picker->setProperty("pickerItemCount", items.size());
+ picker->setProperty("pickerCurrentSkelId",
+ currentIndex >= 0 ? plastic->currentSkeletonId() : -1);
+ picker->setProperty("pickerCurrentIndex", currentIndex);
+
+ if (QLabel *valueLabel = picker->findChild<QLabel *>("pickerValueLabel"))
+ valueLabel->setText(headerValue);
+
+ if (items.isEmpty())
+ replacePlasticSkeletonEmptyLineEdit(picker, m_showBorders,
+ m_showBackgrounds);
+
+ // Keep [-][+] on the header row (outside expanded list), fixed on the right.
+ if (auto *mainLayout = qobject_cast<QVBoxLayout *>(picker->layout())) {
+ if (QLayoutItem *headerItem = mainLayout->itemAt(0)) {
+ if (auto *header = headerItem->widget()) {
+ if (auto *headerLayout =
+ qobject_cast<QHBoxLayout *>(header->layout())) {
+ QWidget *btnHost = new QWidget(header);
+ QHBoxLayout *btnLayout = new QHBoxLayout(btnHost);
+ btnLayout->setContentsMargins(0, 0, 0, 0);
+ btnLayout->setSpacing(4);
+
+ QPushButton *removeSkelBtn = new QPushButton("-", btnHost);
+ QPushButton *addSkelBtn = new QPushButton("+", btnHost);
+ removeSkelBtn->setFixedSize(20, 20);
+ addSkelBtn->setFixedSize(20, 20);
+
+ // TPP header order [-][+] (reversed vs TOB [+][-]).
+ btnLayout->addWidget(removeSkelBtn);
+ btnLayout->addWidget(addSkelBtn);
+ btnHost->setFixedWidth(CollapsibleStyle::kHeaderRightSlot);
+ headerLayout->addWidget(btnHost);
+
+ QObject::connect(removeSkelBtn, &QPushButton::released, [plastic]() {
+ if (plastic->isEnabled() && plastic->deformation())
+ plastic->removeSkeleton_withKeyframes_undo(
+ plastic->currentSkeletonId());
+ });
+ QObject::connect(addSkelBtn, &QPushButton::released, [plastic]() {
+ if (plastic->isEnabled())
+ plastic->addSkeleton_undo(PlasticSkeletonP(new PlasticSkeleton));
+ });
+ }
+ }
+ }
+ }
+
+ return picker;
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::syncPlasticModeFromTool() {
+ TTool *tool = getCurrentTool();
+ auto *plastic = dynamic_cast<PlasticTool *>(tool);
+ if (!plastic || !m_plasticModeLayout) return;
+
+ TPropertyGroup *modeGroup = tool->getProperties(PlasticTool::MODES_COUNT);
+ if (!modeGroup) return;
+
+ TEnumProperty *modeProp =
+ dynamic_cast<TEnumProperty *>(modeGroup->getProperty("mode"));
+ if (!modeProp) return;
+
+ const int mode = modeProp->getIndex();
+ if (mode == m_plasticVisibleMode) return;
+
+ m_plasticVisibleMode = mode;
+ rebuildPlasticModeSection();
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::rebuildPlasticModeSection() {
+ if (!m_plasticModeLayout) return;
+
+ TTool *tool = getCurrentTool();
+ auto *plastic = dynamic_cast<PlasticTool *>(tool);
+ if (!plastic) return;
+
+ QLayoutItem *item;
+ while ((item = m_plasticModeLayout->takeAt(0)) != nullptr) {
+ if (item->widget()) delete item->widget();
+ delete item;
+ }
+
+ TPropertyGroup *modeGroup = tool->getProperties(PlasticTool::MODES_COUNT);
+ if (!modeGroup) return;
+
+ TEnumProperty *modeProp =
+ dynamic_cast<TEnumProperty *>(modeGroup->getProperty("mode"));
+ if (!modeProp) return;
+
+ const int mode = modeProp->getIndex();
+ m_plasticVisibleMode = mode;
+
+ // Match toolbar: only the active mode sub-toolbar is visible.
+ if (mode == PlasticTool::MESH_IDX) return;
+
+ if (mode == PlasticTool::RIGIDITY_IDX) {
+ m_plasticModeLayout->setContentsMargins(0, 0, 0, 0);
+ createPlasticRigidityModeProperties(plastic);
+ return;
+ }
+
+ m_plasticModeLayout->setContentsMargins(
+ CollapsibleStyle::kContentLeftIndent, 0,
+ CollapsibleStyle::kContentRightMargin, 0);
+
+ if (mode == PlasticTool::ANIMATE_IDX) {
+ createPlasticAnimateModeProperties(plastic);
+ return;
+ }
+
+ createGenericProperties(mode, m_plasticModeLayout, true);
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::createPlasticRigidityModeProperties(
+ PlasticTool *plastic) {
+ if (!plastic || !m_plasticModeLayout) return;
+
+ TTool *tool = getCurrentTool();
+ TPropertyGroup *rigidityGroup =
+ tool->getProperties(PlasticTool::RIGIDITY_IDX);
+ if (!rigidityGroup) return;
+
+ for (int i = 0; i < rigidityGroup->getPropertyCount(); ++i) {
+ TProperty *prop = rigidityGroup->getProperty(i);
+ if (!prop) continue;
+
+ const std::string name = prop->getName();
+ QString label = prop->getQStringName();
+ if (label.isEmpty()) label = QString::fromStdString(name);
+
+ if (auto *thickness = dynamic_cast<TIntProperty *>(prop)) {
+ auto range = thickness->getRange();
+ QWidget *thicknessWidget = createCollapsibleIntSlider(
+ label, static_cast<int>(range.first), static_cast<int>(range.second),
+ thickness->getValue(), name, PlasticTool::RIGIDITY_IDX, name, true);
+ m_plasticModeLayout->addWidget(thicknessWidget);
+ continue;
+ }
+
+ if (i > 0) m_plasticModeLayout->addSpacing(CollapsibleStyle::kSectionGap);
+
+ if (auto *rigidValue = dynamic_cast<TEnumProperty *>(prop)) {
+ QStringList items;
+ for (const auto &item : rigidValue->getItems()) items << item.UIName;
+ if (items.isEmpty()) continue;
+
+ const QString rigidLabel = rigidValue->getQStringName();
+ QWidget *rigidWidget = createCollapsibleEnumForProperty(
+ rigidLabel, rigidValue, name, PlasticTool::RIGIDITY_IDX, QString(),
+ nullptr, true, m_propertiesContainer);
+ if (!rigidWidget) continue;
+ rigidWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_plasticModeLayout->addWidget(rigidWidget);
+ }
+ }
+
+ m_plasticModeLayout->addSpacing(CollapsibleStyle::kSectionGap);
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::createPlasticAnimateModeProperties(
+ PlasticTool *plastic) {
+ if (!plastic || !m_plasticModeLayout) return;
+
+ QWidget *relayBlock = new QWidget(m_plasticModeContainer);
+ relayBlock->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
+
+ QGridLayout *relayGrid = new QGridLayout(relayBlock);
+ relayGrid->setContentsMargins(0, 0, 0, 0);
+ relayGrid->setHorizontalSpacing(CollapsibleStyle::kHeaderSpacing);
+ relayGrid->setVerticalSpacing(CollapsibleStyle::kBlockGap);
+ relayGrid->setColumnMinimumWidth(0, CollapsibleStyle::kAnimateRelayLabelW);
+ relayGrid->setColumnMinimumWidth(1, CollapsibleStyle::kAnimateRelayFieldW);
+ relayGrid->setColumnStretch(0, 0);
+ relayGrid->setColumnStretch(1, 0);
+
+ auto addRelayRow = [&](int row, const QString &labelText,
+ TDoubleParamRelayProperty *relay,
+ const QString &objectName) {
+ auto *label = new ClickableLabel(labelText, relayBlock);
+ label->setFixedSize(CollapsibleStyle::kAnimateRelayLabelW,
+ CollapsibleStyle::kFieldHeight);
+
+ MeasuredValueField *field =
+ createPlasticRelayField(relayBlock, plastic, relay, objectName);
+ field->setFixedSize(CollapsibleStyle::kAnimateRelayFieldW,
+ CollapsibleStyle::kFieldHeight);
+
+ relayGrid->addWidget(label, row, 0, Qt::AlignRight | Qt::AlignVCenter);
+ relayGrid->addWidget(field, row, 1, Qt::AlignLeft | Qt::AlignVCenter);
+ connectClickableLabel(label, field);
+
+ new PlasticRelayFieldSync(field, relay, field);
+ };
+
+ addRelayRow(0, tr("Distance"), &plastic->distanceRelayProperty(),
+ "plasticDistanceRelay");
+ addRelayRow(1, tr("Angle"), &plastic->angleRelayProperty(),
+ "plasticAngleRelay");
+ addRelayRow(2, tr("SO"), &plastic->soRelayProperty(), "plasticSORelay");
+
+ m_plasticModeLayout->addWidget(relayBlock, 0, Qt::AlignLeft);
+
+ createGenericProperties(PlasticTool::ANIMATE_IDX, m_plasticModeLayout, true);
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::updatePlasticRelayFields() {
+ if (!m_plasticModeContainer) return;
+
+ auto *plastic = dynamic_cast<PlasticTool *>(getCurrentTool());
+ if (!plastic) return;
+
+ if (MeasuredValueField *distanceField =
+ m_plasticModeContainer->findChild<MeasuredValueField *>(
+ "plasticDistanceRelay"))
+ syncPlasticRelayField(distanceField, &plastic->distanceRelayProperty());
+ if (MeasuredValueField *angleField =
+ m_plasticModeContainer->findChild<MeasuredValueField *>(
+ "plasticAngleRelay"))
+ syncPlasticRelayField(angleField, &plastic->angleRelayProperty());
+ if (MeasuredValueField *soField =
+ m_plasticModeContainer->findChild<MeasuredValueField *>(
+ "plasticSORelay"))
+ syncPlasticRelayField(soField, &plastic->soRelayProperty());
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::createPlasticProperties() {
+ TTool *tool = getCurrentTool();
+ auto *plastic = dynamic_cast<PlasticTool *>(tool);
+ if (!plastic) return;
+
+ tool->updateTranslation();
+ m_plasticVisibleMode = -1;
+
+ // 1. Create Mesh — CommandManager only (no shared QAction with toolbar).
+ QPushButton *meshBtn =
+ new QPushButton(tr("Create Mesh"), m_propertiesContainer);
+ meshBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QObject::connect(meshBtn, &QPushButton::clicked, []() {
+ CommandManager::instance()->execute("A_ToolOption_Meshify");
+ });
+ m_propertiesLayout->addWidget(meshBtn);
+
+ TPropertyGroup *modeGroup = tool->getProperties(PlasticTool::MODES_COUNT);
+ if (!modeGroup) return;
+
+ // 2. Skeleton — collapsible picker (TPP layout, button list).
+ m_plasticSkelPicker = buildPlasticSkeletonPicker(plastic);
+ m_propertiesLayout->addWidget(m_plasticSkelPicker);
+
+ QObject::connect(plastic, SIGNAL(skelIdsListChanged()), this,
+ SLOT(rebuildPlasticSkeletonPicker()));
+ QObject::connect(plastic, SIGNAL(skelIdChanged()), this,
+ SLOT(updatePlasticSkeletonPicker()));
+
+ m_propertiesLayout->addSpacing(CollapsibleStyle::kBlockGap);
+
+ // 3. Mode selector — matches toolbar order (before Vertex Name).
+ TEnumProperty *modeProp =
+ dynamic_cast<TEnumProperty *>(modeGroup->getProperty("mode"));
+ if (!modeProp) return;
+
+ QWidget *modeWidget = createCollapsibleEnumForProperty(
+ modeProp->getQStringName(), modeProp, "mode", PlasticTool::MODES_COUNT,
+ QString(), [this](int) { rebuildPlasticModeSection(); }, true);
+ if (modeWidget) m_propertiesLayout->addWidget(modeWidget);
+
+ m_propertiesLayout->addSpacing(CollapsibleStyle::kBlockGap);
+
+ // 4. Vertex name — after Mode, as in the tool options bar.
+ if (TProperty *vn = modeGroup->getProperty("vertexName")) {
+ if (auto *sp = dynamic_cast<TStringProperty *>(vn)) {
+ const QString vertexLabel = sp->getQStringName().isEmpty()
+ ? tr("Vertex Name")
+ : sp->getQStringName();
+ auto commitVertexName = [this](const QString &text) {
+ TTool *t = getCurrentTool();
+ if (!t) return;
+ TPropertyGroup *pg = t->getProperties(PlasticTool::MODES_COUNT);
+ if (!pg) return;
+ if (auto *vp = dynamic_cast<TStringProperty *>(
+ pg->getProperty("vertexName"))) {
+ if (QString::fromStdWString(vp->getValue()) == text) return;
+ vp->setValue(text.toStdWString());
+ t->onPropertyChanged("vertexName");
+ vp->notifyListeners();
+ if (m_toolHandle) m_toolHandle->notifyToolChanged();
+ }
+ };
+ m_plasticVertexWidget = createCollapsibleTextField(
+ vertexLabel, QString::fromStdWString(sp->getValue()),
+ "plastic_vertex", "vertexName", PlasticTool::MODES_COUNT,
+ commitVertexName, true);
+ m_plasticVertexWidget->setProperty("propName",
+ QStringLiteral("vertexName"));
+ m_plasticVertexWidget->setProperty("propGroup", PlasticTool::MODES_COUNT);
+ storeTppPropertyPtr(m_plasticVertexWidget, sp);
+ if (QLineEdit *vertexEdit = m_plasticVertexWidget->findChild<QLineEdit *>(
+ "collapsibleTextEdit")) {
+ QObject::connect(vertexEdit, &QLineEdit::textChanged, this,
+ [commitVertexName, this](const QString &text) {
+ commitVertexName(text);
+ if (QLabel *valueLabel =
+ m_plasticVertexWidget->findChild<QLabel *>(
+ "textValueLabel"))
+ valueLabel->setText(text);
+ });
+ }
+ m_propertiesLayout->addWidget(m_plasticVertexWidget);
+ }
+ }
+
+ // 5. Active mode options only (rebuilt when mode changes).
+ m_plasticModeContainer = new QWidget(m_propertiesContainer);
+ m_plasticModeLayout = new QVBoxLayout(m_plasticModeContainer);
+ m_plasticModeLayout->setContentsMargins(
+ CollapsibleStyle::kContentLeftIndent, 0,
+ CollapsibleStyle::kContentRightMargin, 0);
+ m_plasticModeLayout->setSpacing(CollapsibleStyle::kBlockGap);
+ m_plasticModeLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ m_propertiesLayout->addWidget(m_plasticModeContainer);
+
+ rebuildPlasticModeSection();
+}
+
+//-----------------------------------------------------------------------------
+
+namespace {
+
+void updateToolOptionControlsIn(QWidget *root) {
+ if (!root) return;
+
+ for (PegbarChannelField *field : root->findChildren<PegbarChannelField *>())
+ field->updateStatus();
+ for (PegbarCenterField *field : root->findChildren<PegbarCenterField *>())
+ field->updateStatus();
+ for (NoScaleField *field : root->findChildren<NoScaleField *>())
+ field->updateStatus();
+
+ const QList<QWidget *> widgets = root->findChildren<QWidget *>();
+ for (QWidget *w : widgets) {
+ if (qobject_cast<PegbarChannelField *>(w) ||
+ qobject_cast<PegbarCenterField *>(w) || qobject_cast<NoScaleField *>(w))
+ continue;
+ if (auto *c = dynamic_cast<ToolOptionControl *>(w)) c->updateStatus();
+ }
+}
+
+QWidget *addMeasuredFieldRow(QWidget *parent, QVBoxLayout *layout,
+ const QString &labelText,
+ MeasuredValueField *field) {
+ QWidget *row = new QWidget(parent);
+ QHBoxLayout *rowLayout = new QHBoxLayout(row);
+ rowLayout->setContentsMargins(0, 0, 0, 0);
+ rowLayout->setSpacing(3);
+
+ auto *label = new ClickableLabel(labelText, row);
+ label->setFixedHeight(20);
+ field->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+
+ rowLayout->addWidget(label);
+ rowLayout->addWidget(field, 1);
+ layout->addWidget(row);
+ connectClickableLabel(label, field);
+ return row;
+}
+
+constexpr int kGridLabelWidth = 22;
+constexpr int kGridFieldWidth = 68;
+constexpr int kGridColGutter = 16;
+constexpr int kGridLabelGap = 2;
+constexpr int kGridRowVSpacing = 11;
+
+QWidget *createCenteredFieldGrid(QWidget *parent, QGridLayout *&outGrid,
+ int columnCount) {
+ QWidget *block = new QWidget(parent);
+ QHBoxLayout *outer = new QHBoxLayout(block);
+ outer->setContentsMargins(0, 0, 0, 0);
+ outer->addStretch();
+
+ QWidget *gridHost = new QWidget(block);
+ outGrid = new QGridLayout(gridHost);
+ outGrid->setContentsMargins(0, 4, 0, 4);
+ outGrid->setHorizontalSpacing(kGridLabelGap);
+ outGrid->setVerticalSpacing(kGridRowVSpacing);
+
+ outer->addWidget(gridHost);
+ outer->addStretch();
+ return block;
+}
+
+// Selection transform grid — shared column widths across all rows.
+constexpr int kSelIconWidth = 16;
+constexpr int kSelLabelWidth = kGridLabelWidth;
+constexpr int kSelFieldWidth = kGridFieldWidth;
+constexpr int kSelAuxWidth = 20;
+
+constexpr int kSelUniformFieldW = 52;
+
+// Animate field grid — same compact base as Selection.
+constexpr int kAnimateUniformFieldW = kSelUniformFieldW;
+constexpr int kAnimateColGutter = 4;
+
+constexpr int kSelCaptionHeight = 16;
+// Optical bias: shift caption block slightly left (~2–3 px on 52 px field).
+constexpr int kSelCaptionCenterBiasL = 3;
+constexpr int kSelCaptionCenterBiasR = 4;
+
+void applyTppExpandingMeasuredField(MeasuredValueField *field, int minWidth) {
+ if (!field) return;
+ // Override TOB constructor caps (getMaximumWidthFor*ToolField) for TPP grids.
+ field->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ field->setMinimumWidth(minWidth);
+ field->setMaximumWidth(QWIDGETSIZE_MAX);
+ field->setFixedHeight(CollapsibleStyle::kFieldHeight);
+}
+
+void styleSelectionTransformField(MeasuredValueField *field) {
+ applyTppExpandingMeasuredField(field, kSelUniformFieldW);
+}
+
+QWidget *selectionTransformAuxSpacer(QWidget *parent) {
+ QWidget *sp = new QWidget(parent);
+ sp->setFixedWidth(kSelAuxWidth);
+ sp->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ return sp;
+}
+
+QWidget *selectionTransformCaptionCell(QWidget *parent, QWidget *caption) {
+ QWidget *cell = new QWidget(parent);
+ cell->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ cell->setFixedHeight(kSelCaptionHeight);
+ QHBoxLayout *layout = new QHBoxLayout(cell);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addStretch(kSelCaptionCenterBiasL);
+ layout->addWidget(caption, 0, Qt::AlignVCenter);
+ layout->addStretch(kSelCaptionCenterBiasR);
+ return cell;
+}
+
+QWidget *selectionTransformCenteredAuxCell(QWidget *parent, QWidget *content,
+ int height, int stretchLeft = 1,
+ int stretchRight = 1) {
+ QWidget *cell = new QWidget(parent);
+ cell->setFixedSize(kSelAuxWidth, height);
+ QHBoxLayout *layout = new QHBoxLayout(cell);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addStretch(stretchLeft);
+ layout->addWidget(content, 0, Qt::AlignCenter);
+ layout->addStretch(stretchRight);
+ return cell;
+}
+
+QWidget *selectionTransformLockIconCell(QWidget *parent, QWidget *icon) {
+ QWidget *cell = new QWidget(parent);
+ cell->setFixedSize(kSelAuxWidth, kSelCaptionHeight);
+ QHBoxLayout *layout = new QHBoxLayout(cell);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ // Toward Scale H: left-align in the link column (symmetric margins had no
+ // effect).
+ layout->addWidget(icon, 0, Qt::AlignLeft | Qt::AlignVCenter);
+ layout->addStretch(1);
+ return cell;
+}
+
+// Scale row: flip H | link | V field | flip V (5-column grid)
+
+void initSelectionTransformGrid(QGridLayout *grid) {
+ grid->setContentsMargins(0, 0, 0, 0);
+ grid->setHorizontalSpacing(kGridLabelGap);
+ grid->setVerticalSpacing(2);
+ for (int col = 0; col < 5; ++col) grid->setColumnStretch(col, 0);
+ grid->setColumnStretch(0, 1);
+ grid->setColumnStretch(3, 1);
+ grid->setColumnMinimumWidth(0, kSelUniformFieldW);
+ grid->setColumnMinimumWidth(1, kSelAuxWidth);
+ grid->setColumnMinimumWidth(2, kSelAuxWidth);
+ grid->setColumnMinimumWidth(3, kSelUniformFieldW);
+ grid->setColumnMinimumWidth(4, kSelAuxWidth);
+}
+
+QWidget *selectionTransformSectionGap(QWidget *parent) {
+ QWidget *gap = new QWidget(parent);
+ gap->setFixedHeight(kGridRowVSpacing);
+ gap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ return gap;
+}
+
+void selectionTransformAddSectionGap(QGridLayout *grid, int row,
+ QWidget *parent) {
+ QWidget *gap = selectionTransformSectionGap(parent);
+ grid->addWidget(gap, row, 0, 1, 5);
+}
+
+ClickableLabel *selectionStackedAddCaption(const QString &text,
+ QWidget *parent) {
+ auto *label = new ClickableLabel(text, parent);
+ label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+ label->setFixedHeight(kSelCaptionHeight);
+ const int textW = label->fontMetrics().horizontalAdvance(text) + 2;
+ label->setFixedWidth(textW);
+ label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ return label;
+}
+
+QWidget *selectionStackedAddCaptionGroup(
+ QWidget *parent, const QString &iconName, ClickableLabel *&outLabel,
+ const QString &text, const QString &iconToolTip = QString()) {
+ QWidget *group = new QWidget(parent);
+ group->setFixedHeight(kSelCaptionHeight);
+ group->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ QHBoxLayout *layout = new QHBoxLayout(group);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ if (!iconName.isEmpty()) {
+ auto *icon = new QLabel(group);
+ QIcon qi = createQIcon(iconName);
+ if (!qi.isNull()) icon->setPixmap(qi.pixmap(16, 16));
+ icon->setFixedSize(16, 16);
+ icon->setAlignment(Qt::AlignCenter);
+ if (!iconToolTip.isEmpty()) {
+ icon->setToolTip(iconToolTip);
+ group->setToolTip(iconToolTip);
+ }
+ layout->addWidget(icon, 0, Qt::AlignVCenter);
+ }
+
+ outLabel = selectionStackedAddCaption(text, group);
+ layout->addWidget(outLabel, 0, Qt::AlignVCenter);
+ return group;
+}
+
+QLabel *selectionStackedAddSectionIcon(QWidget *parent, const QString &iconName,
+ const QString &toolTip = QString()) {
+ auto *icon = new QLabel(parent);
+ QIcon qi = createQIcon(iconName);
+ if (!qi.isNull()) icon->setPixmap(qi.pixmap(16, 16));
+ icon->setFixedSize(16, 16);
+ icon->setAlignment(Qt::AlignCenter);
+ if (!toolTip.isEmpty()) icon->setToolTip(toolTip);
+ return icon;
+}
+
+void updateSelectionScaleLinkLockIcon(QLabel *icon, bool linked) {
+ if (!icon) return;
+ const QString iconName =
+ linked ? QStringLiteral("lock_on") : QStringLiteral("lock");
+ QIcon qi = createQIcon(iconName);
+ if (qi.isNull()) return;
+
+ QPixmap pm = qi.pixmap(16, 16);
+ if (linked) {
+ // lock_on glyph reads right of lock; redraw 2 px left inside the label
+ // (toward H).
+ QPixmap shifted(16, 16);
+ shifted.fill(Qt::transparent);
+ QPainter painter(&shifted);
+ painter.drawPixmap(-2, 0, pm);
+ icon->setPixmap(shifted);
+ } else {
+ icon->setPixmap(pm);
+ }
+
+ icon->setStyleSheet(QString());
+ if (QWidget *cell = icon->parentWidget()) {
+ if (QHBoxLayout *layout = qobject_cast<QHBoxLayout *>(cell->layout())) {
+ layout->setContentsMargins(0, 0, 0, 0);
+ }
+ }
+}
+
+void selectionStackAddBlank(QGridLayout *grid, int row, int col,
+ QWidget *parent, int width,
+ int height = CollapsibleStyle::kFieldHeight) {
+ auto *blank = new QWidget(parent);
+ blank->setFixedSize(width, height);
+ grid->addWidget(blank, row, col);
+}
+
+void initSelectionFieldGrid(QGridLayout *grid) {
+ grid->setColumnMinimumWidth(0, kSelIconWidth);
+ grid->setColumnMinimumWidth(1, kSelLabelWidth);
+ grid->setColumnMinimumWidth(2, kSelFieldWidth);
+ grid->setColumnMinimumWidth(3, kSelAuxWidth);
+ grid->setColumnMinimumWidth(4, kSelAuxWidth);
+ grid->setColumnMinimumWidth(5, kGridColGutter);
+ grid->setColumnMinimumWidth(6, kSelLabelWidth);
+ grid->setColumnMinimumWidth(7, kSelFieldWidth);
+ grid->setColumnMinimumWidth(8, kSelAuxWidth);
+ grid->setColumnMinimumWidth(9, 40);
+ for (int col = 0; col < 10; ++col) grid->setColumnStretch(col, 0);
+}
+
+void selectionGridAddSeparator(QGridLayout *grid, int row, QWidget *parent) {
+ auto *sep = new QFrame(parent);
+ sep->setFrameShape(QFrame::HLine);
+ sep->setFrameShadow(QFrame::Sunken);
+ sep->setFixedHeight(2);
+ grid->addWidget(sep, row, 0, 1, 10);
+}
+
+void selectionGridAddIcon(QGridLayout *grid, int row, QWidget *parent,
+ const QString &iconName) {
+ auto *icon = new QLabel(parent);
+ QIcon qi = createQIcon(iconName);
+ if (!qi.isNull()) icon->setPixmap(qi.pixmap(16, 16));
+ icon->setFixedSize(kSelIconWidth, 16);
+ grid->addWidget(icon, row, 0, Qt::AlignHCenter | Qt::AlignVCenter);
+}
+
+void selectionGridAddBlank(QGridLayout *grid, int row, int col, QWidget *parent,
+ int width, int height = 20) {
+ auto *blank = new QWidget(parent);
+ blank->setFixedSize(width, height);
+ grid->addWidget(blank, row, col);
+}
+
+void selectionGridAddLabel(QGridLayout *grid, int row, int col, QWidget *parent,
+ ClickableLabel *label) {
+ label->setFixedSize(kSelLabelWidth, CollapsibleStyle::kFieldHeight);
+ grid->addWidget(label, row, col, Qt::AlignRight | Qt::AlignVCenter);
+}
+
+void selectionGridAddField(QGridLayout *grid, int row, int col,
+ MeasuredValueField *field) {
+ styleSelectionTransformField(field);
+ grid->addWidget(field, row, col);
+}
+
+QPushButton *selectionGridAddAuxButton(QWidget *parent, const QString &iconName,
+ const QString &fallback,
+ const QString &tip) {
+ auto *btn = new QPushButton(parent);
+ QIcon qi = createQIcon(iconName);
+ if (!qi.isNull()) {
+ btn->setIcon(qi);
+ btn->setIconSize(QSize(16, 16));
+ } else {
+ btn->setText(fallback);
+ }
+ btn->setFixedSize(kSelAuxWidth, CollapsibleStyle::kFieldHeight);
+ btn->setToolTip(tip);
+ return btn;
+}
+
+QPushButton *selectionGridAddAuxButton(QGridLayout *grid, int row, int col,
+ QWidget *parent, const QString &iconName,
+ const QString &fallback,
+ const QString &tip) {
+ QPushButton *btn = selectionGridAddAuxButton(parent, iconName, fallback, tip);
+ grid->addWidget(btn, row, col, Qt::AlignLeft | Qt::AlignVCenter);
+ return btn;
+}
+
+void styleAnimateGridField(MeasuredValueField *field) {
+ applyTppExpandingMeasuredField(field, kAnimateUniformFieldW);
+}
+
+void reapplySelectionTransformFieldSizing(SelectionScaleField *scaleX,
+ SelectionScaleField *scaleY,
+ SelectionRotationField *rotation,
+ SelectionMoveField *moveX,
+ SelectionMoveField *moveY,
+ ThickChangeField *thick) {
+ styleSelectionTransformField(scaleX);
+ styleSelectionTransformField(scaleY);
+ styleSelectionTransformField(rotation);
+ styleSelectionTransformField(moveX);
+ styleSelectionTransformField(moveY);
+ styleSelectionTransformField(thick);
+}
+
+void gridAddLabeledField(QGridLayout *grid, int row, int labelCol, int fieldCol,
+ QWidget *parent, const QString &labelText,
+ MeasuredValueField *field,
+ QList<QWidget *> *rowWidgets = nullptr) {
+ if (!labelText.isEmpty()) {
+ auto *label = new ClickableLabel(labelText, parent);
+ label->setFixedSize(kGridLabelWidth, 20);
+ grid->addWidget(label, row, labelCol, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(label, field);
+ if (rowWidgets) rowWidgets->append(label);
+ } else {
+ auto *spacer = new QWidget(parent);
+ spacer->setFixedSize(kGridLabelWidth, 20);
+ grid->addWidget(spacer, row, labelCol);
+ if (rowWidgets) rowWidgets->append(spacer);
+ }
+
+ styleAnimateGridField(field);
+ grid->addWidget(field, row, fieldCol);
+ if (rowWidgets) rowWidgets->append(field);
+}
+
+void gridAddColumnSpacer(QGridLayout *grid, int row, QWidget *parent,
+ int rightLabelCol, int rightFieldCol,
+ QList<QWidget *> *rowWidgets = nullptr) {
+ auto *spacer = new QWidget(parent);
+ spacer->setMinimumWidth(kGridLabelWidth);
+ spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ grid->addWidget(spacer, row, rightLabelCol);
+ auto *fieldSpacer = new QWidget(parent);
+ fieldSpacer->setMinimumWidth(kAnimateUniformFieldW);
+ fieldSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ grid->addWidget(fieldSpacer, row, rightFieldCol);
+ if (rowWidgets) {
+ rowWidgets->append(spacer);
+ rowWidgets->append(fieldSpacer);
+ }
+}
+
+void setGridRowVisible(const QList<QWidget *> &rowWidgets, bool visible) {
+ for (QWidget *w : rowWidgets)
+ if (w) w->setVisible(visible);
+}
+
+void initAnimateFieldGrid(QGridLayout *grid) {
+ grid->setContentsMargins(0, 0, 0, 4);
+ grid->setHorizontalSpacing(kGridLabelGap);
+ grid->setVerticalSpacing(kGridRowVSpacing);
+ for (int col = 0; col < 5; ++col) grid->setColumnStretch(col, 0);
+ grid->setColumnStretch(1, 1);
+ grid->setColumnStretch(4, 1);
+ grid->setColumnMinimumWidth(0, kGridLabelWidth);
+ grid->setColumnMinimumWidth(1, kAnimateUniformFieldW);
+ grid->setColumnMinimumWidth(2, kAnimateColGutter);
+ grid->setColumnMinimumWidth(3, kGridLabelWidth);
+ grid->setColumnMinimumWidth(4, kAnimateUniformFieldW);
+}
+
+void styleTypeToolCombo(QWidget *combo) {
+ combo->setMinimumWidth(kSelUniformFieldW);
+ combo->setMaximumWidth(QWIDGETSIZE_MAX);
+ combo->setFixedHeight(CollapsibleStyle::kFieldHeight);
+ combo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+}
+
+constexpr int kTypeLabelWidth = 32;
+
+void addTypeToolComboRow(QWidget *parent, QVBoxLayout *layout,
+ const QString &labelText, QWidget *combo,
+ bool showLabel) {
+ QWidget *row = new QWidget(parent);
+ row->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QHBoxLayout *h = new QHBoxLayout(row);
+ h->setContentsMargins(CollapsibleStyle::kHeaderMarginH, 0, 0, 0);
+ h->setSpacing(kGridLabelGap);
+ if (showLabel && !labelText.isEmpty()) {
+ auto *label = new QLabel(labelText, row);
+ label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ label->setFixedWidth(kTypeLabelWidth);
+ h->addWidget(label);
+ }
+ styleTypeToolCombo(combo);
+ h->addWidget(combo, 1);
+ layout->addWidget(row);
+}
+
+} // namespace
+
+namespace {
+
+constexpr int kAnimateAxisSectionCount = 5;
+constexpr int kAnimateAllAxisIndex = 5;
+constexpr int kAnimateLockButtonW = 22;
+constexpr int kAnimateAllSectionHeaderH = 18;
+constexpr int kAnimateAllModeSectionGap = 3;
+constexpr int kAnimateActiveAxisToFieldsGap = 2;
+
+void styleAnimateLockCheckbox(ToolOptionCheckbox *lock) {
+ if (!lock) return;
+ lock->setObjectName("EditToolLockButton");
+ lock->setText("");
+ lock->setFixedSize(kAnimateLockButtonW, CollapsibleStyle::kFieldHeight);
+ lock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+}
+
+QWidget *makeAnimateLockSlotPlaceholder(QWidget *parent) {
+ QWidget *slot = new QWidget(parent);
+ slot->setFixedSize(kAnimateLockButtonW, CollapsibleStyle::kFieldHeight);
+ slot->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ slot->setAttribute(Qt::WA_TransparentForMouseEvents);
+ return slot;
+}
+
+QWidget *makeAnimateFieldHBoxCell(QWidget *parent, MeasuredValueField *field,
+ QWidget *trailing,
+ bool reserveLockSlot = false) {
+ QWidget *cell = new QWidget(parent);
+ cell->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QHBoxLayout *lay = new QHBoxLayout(cell);
+ lay->setContentsMargins(0, 0, 1, 0);
+ lay->setSpacing(2);
+ styleAnimateGridField(field);
+ lay->addWidget(field, 1);
+ if (trailing)
+ lay->addWidget(trailing, 0);
+ else if (reserveLockSlot)
+ lay->addWidget(makeAnimateLockSlotPlaceholder(cell), 0);
+ return cell;
+}
+
+QLabel *makeAnimateAllModeSectionHeader(QWidget *parent, const QString &text,
+ int topMargin = 0) {
+ auto *label = new QLabel(text, parent);
+ label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ QFont f = label->font();
+ f.setBold(true);
+ label->setFont(f);
+ label->setContentsMargins(CollapsibleStyle::kContentLeftIndent, topMargin, 0,
+ 0);
+ label->setFixedHeight(kAnimateAllSectionHeaderH + topMargin);
+ label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ label->setVisible(false);
+ return label;
+}
+
+void applyAnimateAllModeSectionHeaderLabel(QLabel *header, bool showLabels) {
+ if (!header) return;
+ const QString title =
+ header->property("animateAllModeSectionTitle").toString();
+ header->setText(showLabels ? title : QString());
+}
+
+QWidget *makeAnimateAxisStackPage(QWidget *parent, QWidget *section) {
+ QWidget *page = new QWidget(parent);
+ QVBoxLayout *lay = new QVBoxLayout(page);
+ lay->setContentsMargins(0, 0, 0, 0);
+ lay->setSpacing(0);
+ QWidget *topPad = new QWidget(page);
+ topPad->setFixedHeight(kAnimateAllSectionHeaderH);
+ topPad->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ lay->addWidget(topPad);
+ lay->addWidget(section);
+ return page;
+}
+
+QPushButton *animateAuxIconButton(QWidget *parent, const char *iconName,
+ const QString &tip) {
+ auto *btn = new QPushButton(parent);
+ btn->setFixedSize(20, CollapsibleStyle::kFieldHeight);
+ btn->setIcon(createQIcon(iconName));
+ btn->setIconSize(QSize(20, 20));
+ btn->setToolTip(tip);
+ btn->setFlat(true);
+ return btn;
+}
+
+void animateGridAddFieldWithAux(QGridLayout *grid, int row, int fieldCol,
+ QWidget *parent, MeasuredValueField *field,
+ QWidget *aux) {
+ styleAnimateGridField(field);
+ if (!aux) {
+ grid->addWidget(field, row, fieldCol);
+ return;
+ }
+ QWidget *cell = new QWidget(parent);
+ cell->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QHBoxLayout *hl = new QHBoxLayout(cell);
+ hl->setContentsMargins(0, 0, 1, 0);
+ hl->setSpacing(4);
+ hl->addWidget(field, 1);
+ hl->addWidget(aux, 0);
+ grid->addWidget(cell, row, fieldCol);
+}
+
+} // namespace
+
+void ToolPropertiesPanel::createAnimateProperties() {
+ TTool *tool = getCurrentTool();
+ if (!tool || detectCurrentToolId() != T_Edit) return;
+
+ TPropertyGroup *pg = tool->getProperties(0);
+ if (!pg) return;
+
+ TApplication *app = TApp::instance();
+ if (!app) return;
+
+ TFrameHandle *frameHandle = app->getCurrentFrame();
+ TObjectHandle *objHandle = app->getCurrentObject();
+ TXsheetHandle *xshHandle = app->getCurrentXsheet();
+
+ tool->updateTranslation();
+
+ m_animateColumnWidget = createAnimateColumnPicker(xshHandle, objHandle);
+ m_animateColumnWidget->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Fixed);
+ m_propertiesLayout->addWidget(m_animateColumnWidget);
+
+ QWidget *activeAxisBlock = new QWidget(m_propertiesContainer);
+ activeAxisBlock->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+ QVBoxLayout *activeAxisBlockLayout = new QVBoxLayout(activeAxisBlock);
+ activeAxisBlockLayout->setContentsMargins(0, 0, 0, 0);
+ activeAxisBlockLayout->setSpacing(kAnimateActiveAxisToFieldsGap);
+
+ if (TEnumProperty *activeAxisProp =
+ dynamic_cast<TEnumProperty *>(pg->getProperty("Active Axis"))) {
+ QWidget *axisWidget = createCollapsibleEnumForProperty(
+ activeAxisProp->getQStringName(), activeAxisProp,
+ activeAxisProp->getName(), 0, QString(),
+ [this](int) { syncAnimateAxisFromTool(); });
+ if (axisWidget) {
+ axisWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ activeAxisBlockLayout->addWidget(axisWidget);
+ }
+ }
+
+ m_animateAxisFieldsHost = new QWidget(activeAxisBlock);
+ m_animateAxisFieldsHost->setMinimumWidth(0);
+ m_animateAxisFieldsHost->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+ QVBoxLayout *axisHostLayout = new QVBoxLayout(m_animateAxisFieldsHost);
+ axisHostLayout->setContentsMargins(0, 0, 0, 0);
+ axisHostLayout->setSpacing(0);
+
+ m_animateAxisStack = new AnimateAxisStackWidget(m_animateAxisFieldsHost);
+ m_animateAxisStack->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+
+ m_animateAllModeHost = new QWidget(m_animateAxisFieldsHost);
+ m_animateAllModeLayout = new QVBoxLayout(m_animateAllModeHost);
+ m_animateAllModeLayout->setContentsMargins(0, 0, 0, 0);
+ m_animateAllModeLayout->setSpacing(0);
+ m_animateAllModeHost->hide();
+
+ axisHostLayout->addWidget(m_animateAxisStack);
+ axisHostLayout->addWidget(m_animateAllModeHost);
+
+ m_animateSectionsInAllLayout = false;
+ m_animateAxisStackPages.clear();
+ m_animateAxisSectionHeaders.clear();
+ m_animateAxisSections.clear();
+ m_animateSplineRowWidgets.clear();
+ m_animateXYRowWidgets.clear();
+ m_animateScaleHField = nullptr;
+ m_animateScaleVField = nullptr;
+
+ auto appendAnimateAxisSection = [&](const QString &allModeTitle,
+ QWidget *section) {
+ const int headerTopGap =
+ m_animateAxisSectionHeaders.isEmpty() ? 0 : kAnimateAllModeSectionGap;
+ QLabel *header = makeAnimateAllModeSectionHeader(
+ m_animateAllModeHost, allModeTitle, headerTopGap);
+ header->setProperty("animateAllModeSectionTitle", allModeTitle);
+ applyAnimateAllModeSectionHeaderLabel(header, m_showLabels);
+ QWidget *page = makeAnimateAxisStackPage(m_animateAxisStack, section);
+ m_animateAxisStack->addWidget(page);
+ m_animateAxisStackPages.append(page);
+ m_animateAxisSectionHeaders.append(header);
+ m_animateAxisSections.append(section);
+ };
+
+ // --- Position ---
+ {
+ QWidget *section = new QWidget(m_animateAxisFieldsHost);
+ section->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ QVBoxLayout *sectionLay = new QVBoxLayout(section);
+ sectionLay->setContentsMargins(0, 0, 0, 0);
+ sectionLay->setSpacing(0);
+
+ QWidget *fieldBlock = new QWidget(section);
+ QGridLayout *fieldGrid = new QGridLayout(fieldBlock);
+ initAnimateFieldGrid(fieldGrid);
+
+ QList<QWidget *> splineRowWidgets;
+ QList<QWidget *> xyRowWidgets;
+ int row = 0;
+
+ auto *motionPathField =
+ new PegbarChannelField(tool, TStageObject::T_Path, "field", frameHandle,
+ objHandle, xshHandle, fieldBlock);
+ gridAddLabeledField(fieldGrid, row, 0, 1, fieldBlock, tr("Position:"),
+ motionPathField, &splineRowWidgets);
+ gridAddColumnSpacer(fieldGrid, row, fieldBlock, 3, 4, &splineRowWidgets);
+
+ ++row;
+ auto *ewPosField =
+ new PegbarChannelField(tool, TStageObject::T_X, "field", frameHandle,
+ objHandle, xshHandle, fieldBlock);
+ auto *nsPosField =
+ new PegbarChannelField(tool, TStageObject::T_Y, "field", frameHandle,
+ objHandle, xshHandle, fieldBlock);
+
+ ToolOptionCheckbox *lockPosX = nullptr;
+ ToolOptionCheckbox *lockPosY = nullptr;
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Position X")))
+ lockPosX =
+ new ToolOptionCheckbox(tool, lockProp, m_toolHandle, fieldBlock);
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Position Y")))
+ lockPosY =
+ new ToolOptionCheckbox(tool, lockProp, m_toolHandle, fieldBlock);
+ styleAnimateLockCheckbox(lockPosX);
+ styleAnimateLockCheckbox(lockPosY);
+
+ QWidget *posXCell =
+ makeAnimateFieldHBoxCell(fieldBlock, ewPosField, lockPosX);
+ QWidget *posYCell =
+ makeAnimateFieldHBoxCell(fieldBlock, nsPosField, lockPosY);
+
+ auto *xLabel = new ClickableLabel(tr("X:"), fieldBlock);
+ xLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(xLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(xLabel, ewPosField);
+ fieldGrid->addWidget(posXCell, row, 1);
+
+ auto *yLabel = new ClickableLabel(tr("Y:"), fieldBlock);
+ yLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(yLabel, row, 3, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(yLabel, nsPosField);
+ fieldGrid->addWidget(posYCell, row, 4);
+
+ xyRowWidgets.append(xLabel);
+ xyRowWidgets.append(posXCell);
+ xyRowWidgets.append(yLabel);
+ xyRowWidgets.append(posYCell);
+
+ ++row;
+ auto *zField =
+ new PegbarChannelField(tool, TStageObject::T_Z, "field", frameHandle,
+ objHandle, xshHandle, fieldBlock);
+ zField->setPrecision(4);
+ auto *noScaleZField = new NoScaleField(tool, "field");
+ noScaleZField->setParent(fieldBlock);
+ noScaleZField->setPrecision(4);
+
+ QWidget *zCell =
+ makeAnimateFieldHBoxCell(fieldBlock, zField, nullptr, true);
+ QWidget *noScaleZCell =
+ makeAnimateFieldHBoxCell(fieldBlock, noScaleZField, nullptr, true);
+
+ auto *zLabel = new ClickableLabel(tr("Z:"), fieldBlock);
+ zLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(zLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(zLabel, zField);
+ fieldGrid->addWidget(zCell, row, 1);
+
+ auto *zRightLabelSpacer = new QWidget(fieldBlock);
+ zRightLabelSpacer->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(zRightLabelSpacer, row, 3);
+ fieldGrid->addWidget(noScaleZCell, row, 4);
+
+ ++row;
+ auto *soField =
+ new PegbarChannelField(tool, TStageObject::T_SO, "field", frameHandle,
+ objHandle, xshHandle, fieldBlock);
+ QWidget *soCell =
+ makeAnimateFieldHBoxCell(fieldBlock, soField, nullptr, true);
+ auto *soLabel = new ClickableLabel(tr("SO:"), fieldBlock);
+ soLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(soLabel, row, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(soLabel, soField);
+ fieldGrid->addWidget(soCell, row, 1);
+ gridAddColumnSpacer(fieldGrid, row, fieldBlock, 3, 4);
+
+ sectionLay->addWidget(fieldBlock);
+ m_animateSplineRowWidgets = splineRowWidgets;
+ m_animateXYRowWidgets = xyRowWidgets;
+ appendAnimateAxisSection(tr("Position"), section);
+ }
+
+ // --- Rotation ---
+ {
+ QWidget *section = new QWidget(m_animateAxisFieldsHost);
+ QGridLayout *fieldGrid = new QGridLayout(section);
+ initAnimateFieldGrid(fieldGrid);
+
+ auto *rotField =
+ new PegbarChannelField(tool, TStageObject::T_Angle, "field",
+ frameHandle, objHandle, xshHandle, section);
+
+ QPushButton *rotL =
+ animateAuxIconButton(section, "rotateleft", tr("Rotate Object Left"));
+ QPushButton *rotR =
+ animateAuxIconButton(section, "rotateright", tr("Rotate Object Right"));
+ QWidget *rotBtnCell = new QWidget(section);
+ QHBoxLayout *rotBtnLay = new QHBoxLayout(rotBtnCell);
+ rotBtnLay->setContentsMargins(0, 0, 0, 0);
+ rotBtnLay->setSpacing(2);
+ rotBtnLay->addWidget(rotL);
+ rotBtnLay->addWidget(rotR);
+
+ auto *rotLabel = new ClickableLabel(tr("Rot:"), section);
+ rotLabel->setToolTip(tr("Rotation"));
+ rotLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(rotLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(rotLabel, rotField);
+
+ QWidget *rotCell = new QWidget(section);
+ rotCell->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ QHBoxLayout *rotCellLay = new QHBoxLayout(rotCell);
+ rotCellLay->setContentsMargins(0, 0, 1, 0);
+ rotCellLay->setSpacing(2);
+ styleAnimateGridField(rotField);
+ rotCellLay->addWidget(rotField, 1);
+ rotCellLay->addWidget(rotBtnCell, 0);
+ fieldGrid->addWidget(rotCell, 0, 1);
+
+ auto *rotMidSpacer = new QWidget(section);
+ rotMidSpacer->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(rotMidSpacer, 0, 3);
+ auto *rotFieldSpacer = new QWidget(section);
+ rotFieldSpacer->setMinimumWidth(kAnimateUniformFieldW);
+ rotFieldSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ fieldGrid->addWidget(rotFieldSpacer, 0, 4);
+
+ QObject::connect(rotL, &QPushButton::clicked, [rotField]() {
+ rotField->setValue(rotField->getValue() + 90);
+ emit rotField->measuredValueChanged(rotField->getMeasuredValue());
+ });
+ QObject::connect(rotR, &QPushButton::clicked, [rotField]() {
+ rotField->setValue(rotField->getValue() - 90);
+ emit rotField->measuredValueChanged(rotField->getMeasuredValue());
+ });
+
+ appendAnimateAxisSection(tr("Rotation"), section);
+ }
+
+ // --- Scale ---
+ {
+ QWidget *section = new QWidget(m_animateAxisFieldsHost);
+ QVBoxLayout *sectionLay = new QVBoxLayout(section);
+ sectionLay->setContentsMargins(0, 0, 0, 0);
+ sectionLay->setSpacing(CollapsibleStyle::kItemSpacing);
+
+ QWidget *fieldBlock = new QWidget(section);
+ QGridLayout *fieldGrid = new QGridLayout(fieldBlock);
+ initAnimateFieldGrid(fieldGrid);
+
+ auto *globalField =
+ new PegbarChannelField(tool, TStageObject::T_Scale, "field",
+ frameHandle, objHandle, xshHandle, fieldBlock);
+ m_animateScaleHField =
+ new PegbarChannelField(tool, TStageObject::T_ScaleX, "field",
+ frameHandle, objHandle, xshHandle, fieldBlock);
+ m_animateScaleVField =
+ new PegbarChannelField(tool, TStageObject::T_ScaleY, "field",
+ frameHandle, objHandle, xshHandle, fieldBlock);
+
+ QPushButton *flipH = animateAuxIconButton(fieldBlock, "fliphoriz",
+ tr("Flip Object Horizontally"));
+ QPushButton *flipV = animateAuxIconButton(fieldBlock, "flipvert",
+ tr("Flip Object Vertically"));
+
+ ToolOptionCheckbox *lockH = nullptr;
+ ToolOptionCheckbox *lockV = nullptr;
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Scale H")))
+ lockH = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, fieldBlock);
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Scale V")))
+ lockV = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, fieldBlock);
+ styleAnimateLockCheckbox(lockH);
+ styleAnimateLockCheckbox(lockV);
+
+ auto addScaleRowLabel = [&](ClickableLabel *label,
+ MeasuredValueField *field, int row) {
+ label->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(label, row, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(label, field);
+ };
+
+ auto addScaleAuxPlaceholder = [&](int row) {
+ auto *flipSlot = new QWidget(fieldBlock);
+ flipSlot->setFixedSize(flipH->width(), CollapsibleStyle::kFieldHeight);
+ flipSlot->setAttribute(Qt::WA_TransparentForMouseEvents);
+ fieldGrid->addWidget(flipSlot, row, 3);
+ fieldGrid->addWidget(makeAnimateLockSlotPlaceholder(fieldBlock), row, 4);
+ };
+
+ auto *globLabel = new ClickableLabel(tr("Glo:"), fieldBlock);
+ globLabel->setToolTip(tr("Global scale"));
+ addScaleRowLabel(globLabel, globalField, 0);
+ styleAnimateGridField(globalField);
+ fieldGrid->addWidget(globalField, 0, 1);
+ addScaleAuxPlaceholder(0);
+
+ addScaleRowLabel(new ClickableLabel(tr("H:"), fieldBlock),
+ m_animateScaleHField, 1);
+ styleAnimateGridField(m_animateScaleHField);
+ fieldGrid->addWidget(m_animateScaleHField, 1, 1);
+ fieldGrid->addWidget(flipH, 1, 3, Qt::AlignLeft | Qt::AlignVCenter);
+ if (lockH)
+ fieldGrid->addWidget(lockH, 1, 4, Qt::AlignLeft | Qt::AlignVCenter);
+
+ addScaleRowLabel(new ClickableLabel(tr("V:"), fieldBlock),
+ m_animateScaleVField, 2);
+ styleAnimateGridField(m_animateScaleVField);
+ fieldGrid->addWidget(m_animateScaleVField, 2, 1);
+ fieldGrid->addWidget(flipV, 2, 3, Qt::AlignLeft | Qt::AlignVCenter);
+ if (lockV)
+ fieldGrid->addWidget(lockV, 2, 4, Qt::AlignLeft | Qt::AlignVCenter);
+
+ QObject::connect(flipH, &QPushButton::clicked, [this]() {
+ if (!m_animateScaleHField) return;
+ m_animateScaleHField->setValue(m_animateScaleHField->getValue() * -1);
+ emit m_animateScaleHField->measuredValueChanged(
+ m_animateScaleHField->getMeasuredValue());
+ });
+ QObject::connect(flipV, &QPushButton::clicked, [this]() {
+ if (!m_animateScaleVField) return;
+ m_animateScaleVField->setValue(m_animateScaleVField->getValue() * -1);
+ emit m_animateScaleVField->measuredValueChanged(
+ m_animateScaleVField->getMeasuredValue());
+ });
+
+ sectionLay->addWidget(fieldBlock);
+
+ if (TEnumProperty *scaleConstraintProp = dynamic_cast<TEnumProperty *>(
+ pg->getProperty("Scale Constraint:"))) {
+ const int maintainIdx = scaleConstraintProp->getIndex();
+ m_animateScaleHField->onScaleTypeChanged(maintainIdx);
+ m_animateScaleVField->onScaleTypeChanged(maintainIdx);
+ QWidget *maintainWidget = createCollapsibleEnumForProperty(
+ scaleConstraintProp->getQStringName(), scaleConstraintProp,
+ scaleConstraintProp->getName(), 0, QString(), [this](int idx) {
+ if (m_animateScaleHField)
+ m_animateScaleHField->onScaleTypeChanged(idx);
+ if (m_animateScaleVField)
+ m_animateScaleVField->onScaleTypeChanged(idx);
+ });
+ if (maintainWidget) sectionLay->addWidget(maintainWidget);
+ }
+
+ appendAnimateAxisSection(tr("Scale"), section);
+ }
+
+ // --- Shear ---
+ {
+ QWidget *section = new QWidget(m_animateAxisFieldsHost);
+ QGridLayout *fieldGrid = new QGridLayout(section);
+ initAnimateFieldGrid(fieldGrid);
+
+ auto *shearH =
+ new PegbarChannelField(tool, TStageObject::T_ShearX, "field",
+ frameHandle, objHandle, xshHandle, section);
+ auto *shearV =
+ new PegbarChannelField(tool, TStageObject::T_ShearY, "field",
+ frameHandle, objHandle, xshHandle, section);
+
+ ToolOptionCheckbox *lockH = nullptr;
+ ToolOptionCheckbox *lockV = nullptr;
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Shear H")))
+ lockH = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, section);
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Shear V")))
+ lockV = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, section);
+ styleAnimateLockCheckbox(lockH);
+ styleAnimateLockCheckbox(lockV);
+
+ QWidget *shearHCell = makeAnimateFieldHBoxCell(section, shearH, lockH);
+ QWidget *shearVCell = makeAnimateFieldHBoxCell(section, shearV, lockV);
+
+ auto *shearHLabel = new ClickableLabel(tr("H:"), section);
+ shearHLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(shearHLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(shearHLabel, shearH);
+ fieldGrid->addWidget(shearHCell, 0, 1);
+
+ auto *shearVLabel = new ClickableLabel(tr("V:"), section);
+ shearVLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(shearVLabel, 0, 3, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(shearVLabel, shearV);
+ fieldGrid->addWidget(shearVCell, 0, 4);
+
+ appendAnimateAxisSection(tr("Shear"), section);
+ }
+
+ // --- Center position ---
+ {
+ QWidget *section = new QWidget(m_animateAxisFieldsHost);
+ QGridLayout *fieldGrid = new QGridLayout(section);
+ initAnimateFieldGrid(fieldGrid);
+
+ auto *centerX =
+ new PegbarCenterField(tool, 0, "field", objHandle, xshHandle, section);
+ auto *centerY =
+ new PegbarCenterField(tool, 1, "field", objHandle, xshHandle, section);
+
+ ToolOptionCheckbox *lockX = nullptr;
+ ToolOptionCheckbox *lockY = nullptr;
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Center X")))
+ lockX = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, section);
+ if (auto *lockProp =
+ dynamic_cast<TBoolProperty *>(pg->getProperty("Lock Center Y")))
+ lockY = new ToolOptionCheckbox(tool, lockProp, m_toolHandle, section);
+ styleAnimateLockCheckbox(lockX);
+ styleAnimateLockCheckbox(lockY);
+
+ QWidget *centerXCell = makeAnimateFieldHBoxCell(section, centerX, lockX);
+ QWidget *centerYCell = makeAnimateFieldHBoxCell(section, centerY, lockY);
+
+ auto *centerXLabel = new ClickableLabel(tr("X:"), section);
+ centerXLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(centerXLabel, 0, 0, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(centerXLabel, centerX);
+ fieldGrid->addWidget(centerXCell, 0, 1);
+
+ auto *centerYLabel = new ClickableLabel(tr("Y:"), section);
+ centerYLabel->setFixedSize(kGridLabelWidth, 20);
+ fieldGrid->addWidget(centerYLabel, 0, 3, Qt::AlignRight | Qt::AlignVCenter);
+ connectClickableLabel(centerYLabel, centerY);
+ fieldGrid->addWidget(centerYCell, 0, 4);
+
+ appendAnimateAxisSection(tr("Center"), section);
+ }
+
+ activeAxisBlockLayout->addWidget(m_animateAxisFieldsHost);
+ m_propertiesLayout->addWidget(activeAxisBlock);
+
+ createBoolProperty(tr("Global Key"), "Global Key");
+
+ m_animateMeasuredFields =
+ m_animateAxisFieldsHost->findChildren<MeasuredValueField *>();
+ for (MeasuredValueField *field : m_animateMeasuredFields)
+ styleAnimateGridField(field);
+
+ m_animateVisibleAxis = -1;
+ syncAnimateAxisFromTool();
+
+ TStageObjectId objId = objHandle->getObjectId();
+ bool splined =
+ xshHandle->getXsheet()->getStageObject(objId)->getSpline() != 0;
+ setGridRowVisible(m_animateSplineRowWidgets, splined);
+ setGridRowVisible(m_animateXYRowWidgets, !splined);
+}
+
+void ToolPropertiesPanel::syncAnimateAxisFromTool() {
+ if (m_currentToolType != "edit" ||
+ m_animateAxisSections.size() != kAnimateAxisSectionCount)
+ return;
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ TPropertyGroup *pg = tool->getProperties(0);
+ if (!pg) return;
+
+ TEnumProperty *axisProp =
+ dynamic_cast<TEnumProperty *>(pg->getProperty("Active Axis"));
+ if (!axisProp) return;
+
+ const int axisId = axisProp->getIndex();
+ if (axisId == m_animateVisibleAxis) return;
+
+ m_animateVisibleAxis = axisId;
+ updateAnimateActiveAxisVisibility();
+}
+
+void ToolPropertiesPanel::reparentAnimateSectionsToAllMode() {
+ if (!m_animateAxisStack || !m_animateAllModeLayout ||
+ m_animateAxisSections.size() != kAnimateAxisSectionCount)
+ return;
+
+ while (m_animateAxisStack->count() > 0) {
+ QWidget *page = m_animateAxisStack->widget(0);
+ m_animateAxisStack->removeWidget(page);
+ }
+
+ for (int a = 0; a < kAnimateAxisSectionCount; ++a) {
+ QLabel *header =
+ qobject_cast<QLabel *>(m_animateAxisSectionHeaders.value(a));
+ QWidget *section = m_animateAxisSections.value(a);
+ QWidget *page = m_animateAxisStackPages.value(a);
+ if (page && section && section->parentWidget() == page) {
+ if (auto *pageLay = qobject_cast<QVBoxLayout *>(page->layout()))
+ pageLay->removeWidget(section);
+ }
+ if (header) {
+ header->setVisible(true);
+ applyAnimateAllModeSectionHeaderLabel(header, m_showLabels);
+ m_animateAllModeLayout->addWidget(header);
+ }
+ if (section) {
+ section->setVisible(true);
+ m_animateAllModeLayout->addWidget(section);
+ }
+ }
+ m_animateSectionsInAllLayout = true;
+}
+
+void ToolPropertiesPanel::reparentAnimateSectionsToAxisStack() {
+ if (!m_animateAxisStack || !m_animateAllModeLayout ||
+ m_animateAxisSections.size() != kAnimateAxisSectionCount)
+ return;
+
+ for (int a = 0; a < kAnimateAxisSectionCount; ++a) {
+ QWidget *section = m_animateAxisSections.value(a);
+ QWidget *header = m_animateAxisSectionHeaders.value(a);
+ QWidget *page = m_animateAxisStackPages.value(a);
+ if (section) m_animateAllModeLayout->removeWidget(section);
+ if (header) {
+ m_animateAllModeLayout->removeWidget(header);
+ header->setVisible(false);
+ }
+ if (page && section) {
+ if (auto *pageLay = qobject_cast<QVBoxLayout *>(page->layout()))
+ pageLay->insertWidget(1, section);
+ m_animateAxisStack->insertWidget(a, page);
+ }
+ }
+ m_animateSectionsInAllLayout = false;
+}
+
+void ToolPropertiesPanel::updateAnimateActiveAxisVisibility() {
+ if (m_animateAxisSections.size() != kAnimateAxisSectionCount ||
+ !m_animateAxisStack || !m_animateAllModeHost)
+ return;
+
+ const int axisId =
+ m_animateVisibleAxis >= 0 ? m_animateVisibleAxis : kAnimateAllAxisIndex;
+ const bool showAll = axisId == kAnimateAllAxisIndex;
+
+ if (showAll) {
+ if (!m_animateSectionsInAllLayout) reparentAnimateSectionsToAllMode();
+ m_animateAxisStack->hide();
+ m_animateAllModeHost->show();
+ m_animateAllModeHost->updateGeometry();
+ m_animateAxisFieldsHost->updateGeometry();
+ return;
+ }
+
+ if (m_animateSectionsInAllLayout) reparentAnimateSectionsToAxisStack();
+
+ m_animateAllModeHost->hide();
+ m_animateAxisStack->show();
+ if (axisId >= 0 && axisId < m_animateAxisStack->count()) {
+ m_animateAxisStack->setCurrentIndex(axisId);
+ m_animateAxisStack->updateGeometry();
+ m_animateAxisFieldsHost->updateGeometry();
+ }
+}
+
+void ToolPropertiesPanel::updateAnimateColumnPicker() {
+ if (!m_animateColumnWidget) return;
+
+ TApplication *app = TApp::instance();
+ if (!app) return;
+
+ const int code = (int)app->getCurrentObject()->getObjectId().getCode();
+ const QVariantList codes =
+ m_animateColumnWidget->property("pickerCodes").toList();
+ for (int i = 0; i < codes.size(); ++i) {
+ if (codes[i].toInt() == code) {
+ syncCollapsiblePicker(m_animateColumnWidget, i);
+ return;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void ToolPropertiesPanel::createEraserProperties() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ if (!tool->getProperties(0)) return;
+
+ // 1. Size — all variants
+ createSizeProperty();
+
+ // 2. Hardness — Toonz Raster + FullColor
+ createHardnessProperty();
+
+ // 3. Opacity — FullColor only
+ createOpacityProperty();
+
+ // 4. Type: Normal / Rectangular / Freehand / Polyline [/ Segment for vector]
+ createEnumProperty(tr("Type"), "Type:");
+
+ // 5. Mode: Lines / Areas / Lines & Areas — Toonz Raster only
+ createEnumProperty(tr("Mode"), "Mode:");
+
+ // 6. Selective — Vector (propName "Selective")
+ // Current Style — Toonz Raster (same UI label, different propName)
+ createBoolProperty(tr("Selective"), "Selective");
+ createBoolProperty(tr("Selective"), "Current Style");
+
+ // 7. Invert — Vector + FullColor
+ createBoolProperty(tr("Invert"), "Invert");
+
+ // 8. Frame Range — all variants (TBoolProperty, not the brush enum)
+ createBoolProperty(tr("Frame Range"), "Frame Range");
+
+ // 9. Pencil Mode — Toonz Raster only
+ createPencilModeProperty();
+
+ // 10. Savebox — Toonz Raster only (enabled in Segment type; mirrors TOB)
+ createBoolProperty(tr("Savebox"), "Savebox");
+
+ // 11. Interpolation — Vector only (enabled when Frame Range is checked)
+ createEnumProperty(tr("Interpolation"), "interpolation:");
+
+ updateEraserOptionStates();
+}
+
+namespace {
+
+QWidget *findPropertyWidget(QWidget *root, const QString &propName) {
+ if (!root) return nullptr;
+ const QList<QWidget *> widgets = root->findChildren<QWidget *>();
+ for (QWidget *w : widgets) {
+ if (w->property("propName").toString() == propName) return w;
+ }
+ return nullptr;
+}
+
+void setPropertyWidgetTreeEnabled(QWidget *w, bool enabled) {
+ if (!w) return;
+ w->setEnabled(enabled);
+ for (ToolPropertyButton *btn : w->findChildren<ToolPropertyButton *>()) {
+ btn->setHoverEnabled(enabled);
+ btn->setEnabled(enabled);
+ }
+ for (QWidget *child : w->findChildren<QWidget *>()) {
+ if (qobject_cast<ToolPropertyButton *>(child)) continue;
+ child->setEnabled(enabled);
+ }
+}
+
+} // namespace
+
+void ToolPropertiesPanel::updateEraserOptionStates() {
+ if (m_currentToolType != QStringLiteral("eraser")) return;
+
+ TTool *tool = getCurrentTool();
+ if (!tool || !(tool->getTargetType() & TTool::ToonzImage)) return;
+
+ TPropertyGroup *props = tool->getProperties(0);
+ if (!props) return;
+
+ TEnumProperty *typeProp =
+ dynamic_cast<TEnumProperty *>(props->getProperty("Type:"));
+ TEnumProperty *modeProp =
+ dynamic_cast<TEnumProperty *>(props->getProperty("Mode:"));
+ TBoolProperty *pencilProp =
+ dynamic_cast<TBoolProperty *>(props->getProperty("Pencil Mode"));
+ if (!typeProp) return;
+
+ const std::wstring typeVal = typeProp->getValue();
+ const bool isNormal = typeVal == L"Normal";
+ const bool isSegment = typeVal == L"Segment";
+ const bool modeIsAreas = modeProp && modeProp->getValue() == L"Areas";
+ const bool pencilOn = pencilProp && pencilProp->getValue();
+
+ if (QWidget *modeW = findPropertyWidget(m_propertiesContainer, "Mode:"))
+ setPropertyWidgetTreeEnabled(modeW, !isSegment);
+
+ if (QWidget *saveboxW = findPropertyWidget(m_propertiesContainer, "Savebox"))
+ setPropertyWidgetTreeEnabled(saveboxW, isSegment);
+
+ if (QWidget *invertW = findPropertyWidget(m_propertiesContainer, "Invert"))
+ setPropertyWidgetTreeEnabled(invertW, !isNormal && !isSegment);
+
+ if (QWidget *frameW =
+ findPropertyWidget(m_propertiesContainer, "Frame Range"))
+ setPropertyWidgetTreeEnabled(frameW, !isNormal);
+
+ if (QWidget *pencilW =
+ findPropertyWidget(m_propertiesContainer, "Pencil Mode"))
+ setPropertyWidgetTreeEnabled(pencilW, !modeIsAreas);
+
+ if (QWidget *hardnessW =
+ findPropertyWidget(m_propertiesContainer, "Hardness:"))
+ setPropertyWidgetTreeEnabled(hardnessW, !modeIsAreas && !pencilOn);
+}
+
+//=============================================================================
+// Fill Properties Creation
+//
+// Exact Tool Options Bar order (left→right = top→bottom):
+//
+// Vector: Type | Mode | Empty Only | Onion Skin | Frame Range |
+// Maximum Gap
+// Toonz Raster: Type | Mode | Empty Only | Fill Depth | Segment |
+// Close Gap | Refer Fill | Onion Skin | Frame Range |
+// Autopaint Lines | Extend Fill | Gap Close Distance
+// FullColor: Fill Depth
+//
+// Calls that do not match the current tool type are no-ops.
+//=============================================================================
+
+void ToolPropertiesPanel::createFillProperties() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ if (!tool->getProperties(0)) return;
+
+ // 1. Type: Normal / Rectangular / Freehand / Polyline / FreePick
+ // (absent for FullColor → no-op)
+ createEnumProperty(tr("Type"), "Type:");
+
+ // 2. Mode: Lines / Areas / Lines & Areas
+ // (absent for FullColor → no-op)
+ createEnumProperty(tr("Mode"), "Mode:");
+
+ // 3. Empty Only
+ createBoolProperty(tr("Empty Only"), "Empty Only");
+
+ // 4. Fill Depth (DoublePair) — Toonz Raster + FullColor
+ createDoublePairByName(tr("Fill Depth"), "Fill Depth");
+
+ // 5–7. Toonz Raster properties only
+ createBoolProperty(tr("Segment"), "Segment");
+ createBoolProperty(tr("Close Gap"), "Close Gap");
+ createBoolProperty(tr("Refer Fill"), "Refer Fill");
+
+ // 8. Onion Skin — Vector + Toonz Raster
+ createBoolProperty(tr("Onion Skin"), "Onion Skin");
+
+ // 9. Frame Range — Vector + Toonz Raster (TBoolProperty)
+ createBoolProperty(tr("Frame Range"), "Frame Range");
+
+ // 10. Maximum Gap — Vector only
+ createDoubleSliderByName(tr("Maximum Gap"), "Maximum Gap");
+
+ // 11–13. Toonz Raster only
+ createBoolProperty(tr("Autopaint Lines"), "Autopaint Lines");
+ createBoolProperty(tr("Extend Fill"), "Extend Fill");
+ createIntSliderByName(tr("Gap Close Distance"), "Gap Close Distance:");
+}
+
+//=============================================================================
+// Geometric Properties Creation
+//
+// Exact Tool Options Bar order (left→right = top→bottom):
+//
+// Vector: Size | Shape | Polygon Sides | Rotate | Auto Group |
+// Auto Fill | Snap | Sensitivity | Smooth |
+// Cap | Join | Miter
+// Toonz Raster: Size | Hardness | Shape | Polygon Sides | Rotate |
+// Empty Only | Pencil Mode | Smooth |
+// Cap | Join | Miter
+// FullColor: Size | Hardness | Opacity | Shape | Polygon Sides |
+// Rotate | Smooth | Cap | Join | Miter
+//
+// Calls that do not match the current tool type are no-ops.
+//=============================================================================
+
+void ToolPropertiesPanel::createGeometricProperties() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ if (!tool->getProperties(0)) return;
+
+ // 1. Size — all variants
+ createSizeProperty();
+
+ // 2. Hardness — Toonz Raster + FullColor
+ createHardnessProperty();
+
+ // 3. Opacity — FullColor only
+ createOpacityProperty();
+
+ // 4. Shape — all variants
+ createEnumProperty(tr("Shape"), "Shape:");
+
+ // 5. Polygon Sides — all variants (enabled when Shape == Polygon)
+ createIntSliderByName(tr("Polygon Sides"), "Polygon Sides:");
+
+ // 6. Rotate — all variants (lowercase propName in source code)
+ createBoolProperty(tr("Rotate"), "rotate");
+
+ // 7–8. Auto Group / Auto Fill — Vector only
+ createBoolProperty(tr("Auto Group"), "Auto Group");
+ createBoolProperty(tr("Auto Fill"), "Auto Fill");
+
+ // 9–10. Snap + Sensitivity — Vector only
+ createSnapProperty();
+ createSnapSensitivityProperty();
+
+ // 11. Empty Only — Toonz Raster only
+ createBoolProperty(tr("Empty Only"), "Empty Only");
+
+ // 12. Pencil Mode — Toonz Raster only
+ createPencilModeProperty();
+
+ // 13. Smooth — all variants (TBoolProperty for Geometric,
+ // so use createBoolProperty instead of createSmoothProperty)
+ createBoolProperty(tr("Smooth"), "Smooth");
+
+ // 14–16. Cap / Join / Miter — group 1, Vector only
+ createCapProperty();
+ createJoinProperty();
+ createMiterProperty();
+}
+
+//=============================================================================
+// Selection Properties Creation
+//
+// Exact Tool Options Bar order (left→right = top→bottom):
+//
+// All variants: Type (Rect / Freehand / Polyline)
+// Vector: + Mode | Include Intersection | Preserve Thickness |
+// Cap | Join | Miter (group outlineProps)
+// Raster: + No Antialiasing
+// Toonz Raster: + Modify Savebox
+//=============================================================================
+
+void ToolPropertiesPanel::createSelectionProperties() {
+ // Reset all selection field pointers (they'll be set below or remain nullptr)
+ m_selScaleX = m_selScaleY = nullptr;
+ m_selRotation = nullptr;
+ m_selMoveX = m_selMoveY = nullptr;
+ m_selThick = nullptr;
+ m_selScaleLink = nullptr;
+ m_selFlipH = m_selFlipV = nullptr;
+ m_selRotL = m_selRotR = nullptr;
+ m_selHLabel = m_selVLabel = nullptr;
+ m_selXLabel = m_selYLabel = nullptr;
+ m_selScaleLinkIcon = nullptr;
+
+ TTool *tool = getCurrentTool();
+ if (!tool || !tool->getProperties(0)) return;
+
+ SelectionTool *selTool = dynamic_cast<SelectionTool *>(tool);
+ VectorSelectionTool *vecTool = dynamic_cast<VectorSelectionTool *>(tool);
+ RasterSelectionTool *rasTool = dynamic_cast<RasterSelectionTool *>(tool);
+ if (!selTool) return;
+
+ // ── 1. Type: Rect / Freehand / Polyline (all variants) ──────────────────
+ createEnumProperty(tr("Type"), "Type:");
+
+ // ── 2. Mode (vector only — no-op for raster via missing prop) ───────────
+ createEnumProperty(tr("Mode"), "Mode:");
+
+ // ── 3–4. Vector only ────────────────────────────────────────────────────
+ createBoolProperty(tr("Include Intersection"), "Include Intersection");
+ createBoolProperty(tr("Preserve Thickness"), "Preserve Thickness");
+
+ // ── 5. No Antialiasing (raster only) ────────────────────────────────────
+ createBoolProperty(tr("No Antialiasing"), "No Antialiasing");
+
+ // ── Transform — single 5-column grid (mockup: aligned fields)
+ {
+ QWidget *transformBlock = new QWidget(m_propertiesContainer);
+ transformBlock->setMinimumWidth(0);
+ transformBlock->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred);
+ QGridLayout *grid = new QGridLayout(transformBlock);
+ initSelectionTransformGrid(grid);
+
+ int row = 0;
+
+ m_selScaleX = new SelectionScaleField(selTool, 0, "Scale X");
+ m_selFlipH = selectionGridAddAuxButton(transformBlock, "fliphoriz", "H",
+ tr("Flip Selection Horizontally"));
+ m_selScaleY = new SelectionScaleField(selTool, 1, "Scale Y");
+ m_selFlipV = selectionGridAddAuxButton(transformBlock, "flipvert", "V",
+ tr("Flip Selection Vertically"));
+ m_selScaleLink = new DVGui::CheckBox(QString(), transformBlock);
+ m_selScaleLink->setToolTip(tr("Link Scale H and V"));
+ m_selScaleLink->setFixedSize(kSelAuxWidth, CollapsibleStyle::kFieldHeight);
+ m_selScaleLink->setChecked(selectionScaleLinkIsEnabled());
+ styleSelectionTransformField(m_selScaleX);
+ styleSelectionTransformField(m_selScaleY);
+
+ m_selScaleLinkIcon = selectionStackedAddSectionIcon(
+ transformBlock, QStringLiteral("lock"), tr("Link Scale H and V"));
+ updateSelectionScaleLinkLockIcon(m_selScaleLinkIcon,
+ selectionScaleLinkIsEnabled());
+ QWidget *linkIconCell =
+ selectionTransformLockIconCell(transformBlock, m_selScaleLinkIcon);
+ QWidget *linkCheckCell = selectionTransformCenteredAuxCell(
+ transformBlock, m_selScaleLink, CollapsibleStyle::kFieldHeight, 0, 1);
+
+ grid->setRowMinimumHeight(row, kSelCaptionHeight);
+ grid->addWidget(selectionTransformCaptionCell(
+ transformBlock, selectionStackedAddCaptionGroup(
+ transformBlock, "edit_scale",
+ m_selHLabel, tr("H"), tr("Scale"))),
+ row, 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(linkIconCell, row, 2, Qt::AlignLeft | Qt::AlignVCenter);
+ grid->addWidget(selectionTransformCaptionCell(
+ transformBlock,
+ selectionStackedAddCaptionGroup(
+ transformBlock, QString(), m_selVLabel, tr("V"))),
+ row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ grid->addWidget(m_selScaleX, row, 0);
+ grid->addWidget(m_selFlipH, row, 1, Qt::AlignCenter);
+ grid->addWidget(linkCheckCell, row, 2, Qt::AlignLeft | Qt::AlignVCenter);
+ grid->addWidget(m_selScaleY, row, 3);
+ grid->addWidget(m_selFlipV, row, 4, Qt::AlignCenter);
+ ++row;
+
+ selectionTransformAddSectionGap(grid, row++, transformBlock);
+
+ m_selRotation = new SelectionRotationField(selTool, tr("Rotation"));
+ styleSelectionTransformField(m_selRotation);
+ m_selRotL = selectionGridAddAuxButton(transformBlock, "rotateleft", "L",
+ tr("Rotate Selection Left 90°"));
+ m_selRotR = selectionGridAddAuxButton(transformBlock, "rotateright", "R",
+ tr("Rotate Selection Right 90°"));
+ QWidget *rotIcon = selectionStackedAddSectionIcon(
+ transformBlock, "edit_rotation", tr("Rotation"));
+
+ grid->setRowMinimumHeight(row, kSelCaptionHeight);
+ grid->addWidget(selectionTransformCaptionCell(transformBlock, rotIcon), row,
+ 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 2);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ grid->addWidget(m_selRotation, row, 0);
+ grid->addWidget(m_selRotL, row, 1, Qt::AlignCenter);
+ grid->addWidget(m_selRotR, row, 2, Qt::AlignCenter);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ selectionTransformAddSectionGap(grid, row++, transformBlock);
+
+ m_selMoveX = new SelectionMoveField(selTool, 0, "Move X");
+ m_selMoveY = new SelectionMoveField(selTool, 1, "Move Y");
+ styleSelectionTransformField(m_selMoveX);
+ styleSelectionTransformField(m_selMoveY);
+
+ grid->setRowMinimumHeight(row, kSelCaptionHeight);
+ grid->addWidget(
+ selectionTransformCaptionCell(
+ transformBlock, selectionStackedAddCaptionGroup(
+ transformBlock, "edit_position", m_selXLabel,
+ tr("X"), tr("Position"))),
+ row, 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 2);
+ grid->addWidget(selectionTransformCaptionCell(
+ transformBlock,
+ selectionStackedAddCaptionGroup(
+ transformBlock, QString(), m_selYLabel, tr("Y"))),
+ row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ grid->addWidget(m_selMoveX, row, 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 2);
+ grid->addWidget(m_selMoveY, row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ if (vecTool) {
+ selectionTransformAddSectionGap(grid, row++, transformBlock);
+
+ m_selThick = new ThickChangeField(selTool, tr("Thickness"));
+ styleSelectionTransformField(m_selThick);
+ QWidget *thickIcon = selectionStackedAddSectionIcon(
+ transformBlock, "thickness", tr("Thickness"));
+
+ grid->setRowMinimumHeight(row, kSelCaptionHeight);
+ grid->addWidget(selectionTransformCaptionCell(transformBlock, thickIcon),
+ row, 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 2);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ ++row;
+
+ grid->addWidget(m_selThick, row, 0);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 1);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 2);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 3);
+ grid->addWidget(selectionTransformAuxSpacer(transformBlock), row, 4);
+ }
+
+ m_propertiesLayout->addWidget(transformBlock);
+ reapplySelectionTransformFieldSizing(m_selScaleX, m_selScaleY,
+ m_selRotation, m_selMoveX, m_selMoveY,
+ m_selThick);
+ }
+
+ connect(m_selScaleX, &SelectionScaleField::valueChange,
+ [this](bool addToUndo) {
+ if (!m_selScaleLink || !m_selScaleLink->isChecked()) return;
+ if (!m_selScaleY) return;
+ if (m_selScaleX->getValue() == m_selScaleY->getValue()) return;
+ m_selScaleY->setValue(m_selScaleX->getValue());
+ m_selScaleY->applyChange(addToUndo);
+ });
+ connect(m_selScaleY, &SelectionScaleField::valueChange,
+ [this](bool addToUndo) {
+ if (!m_selScaleLink || !m_selScaleLink->isChecked()) return;
+ if (!m_selScaleX) return;
+ if (m_selScaleX->getValue() == m_selScaleY->getValue()) return;
+ m_selScaleX->setValue(m_selScaleY->getValue());
+ m_selScaleX->applyChange(addToUndo);
+ });
+
+ connect(m_selScaleLink, &QCheckBox::toggled, [this](bool linked) {
+ updateSelectionScaleLinkLockIcon(m_selScaleLinkIcon, linked);
+ setSelectionScaleLinkEnabled(linked);
+ });
+
+ connect(m_selFlipH, &QPushButton::clicked, [this]() {
+ if (!m_selScaleX) return;
+ m_selScaleX->setValue(m_selScaleX->getValue() * -1.0);
+ m_selScaleX->applyChange(true);
+ if (m_selScaleLink && m_selScaleLink->isChecked() && m_selScaleY) {
+ m_selScaleY->setValue(m_selScaleX->getValue());
+ m_selScaleY->applyChange(true);
+ }
+ });
+ connect(m_selFlipV, &QPushButton::clicked, [this]() {
+ if (!m_selScaleY) return;
+ m_selScaleY->setValue(m_selScaleY->getValue() * -1.0);
+ m_selScaleY->applyChange(true);
+ if (m_selScaleLink && m_selScaleLink->isChecked() && m_selScaleX) {
+ m_selScaleX->setValue(m_selScaleY->getValue());
+ m_selScaleX->applyChange(true);
+ }
+ });
+
+ connectClickableLabel(m_selHLabel, m_selScaleX);
+ connectClickableLabel(m_selVLabel, m_selScaleY);
+
+ connect(m_selRotL, &QPushButton::clicked, [this]() {
+ if (!m_selRotation) return;
+ m_selRotation->setValue(m_selRotation->getValue() + 90.0);
+ m_selRotation->applyChange(true);
+ });
+ connect(m_selRotR, &QPushButton::clicked, [this]() {
+ if (!m_selRotation) return;
+ m_selRotation->setValue(m_selRotation->getValue() - 90.0);
+ m_selRotation->applyChange(true);
+ });
+
+ connectClickableLabel(m_selXLabel, m_selMoveX);
+ connectClickableLabel(m_selYLabel, m_selMoveY);
+
+ // ── Modify Savebox (ToonzRaster only) ───────────────────────────────────
+ if (rasTool) {
+ TBoolProperty *modSaveProp = rasTool->getModifySaveboxProperty();
+ if (modSaveProp) {
+ QWidget *w = createCheckBox(tr("Modify Savebox"), modSaveProp->getValue(),
+ "ModifySavebox");
+ storeTppPropertyPtr(w, modSaveProp);
+ m_propertiesLayout->addWidget(w);
+ }
+ }
+
+ // ── Vector-only: Cap / Join / Miter ─────────────────────────────────────
+ if (vecTool) {
+ createCapProperty();
+ createJoinProperty();
+ createMiterProperty();
+ }
+
+ // Reopening or rebuilding the panel must reflect an existing selection too.
+ updatePropertyValues();
+}
+
+//=============================================================================
+// Type (Text) Properties — Font / Size as dropdown menus (same as TOB)
+//=============================================================================
+
+void ToolPropertiesPanel::createTypeProperties() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+ tool->updateTranslation();
+
+ auto processGroup = [&](int propGroup) {
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props) return;
+
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *prop = props->getProperty(i);
+ if (!prop) continue;
+
+ const std::string name = prop->getName();
+ QString label = prop->getQStringName();
+ if (label.isEmpty()) label = QString::fromStdString(name);
+
+ if (name == "Font:") {
+ auto *ep = dynamic_cast<TEnumProperty *>(prop);
+ if (!ep) continue;
+ auto *fontCombo = new ToolOptionFontCombo(tool, ep, m_toolHandle);
+ addTypeToolComboRow(m_propertiesContainer, m_propertiesLayout, label,
+ fontCombo, m_showLabels);
+ continue;
+ }
+
+ if (name == "Size:") {
+ auto *ep = dynamic_cast<TEnumProperty *>(prop);
+ if (!ep) continue;
+ auto *sizeCombo = new ToolOptionCombo(tool, ep, m_toolHandle);
+ addTypeToolComboRow(m_propertiesContainer, m_propertiesLayout, label,
+ sizeCombo, m_showLabels);
+ continue;
+ }
+
+ if (name == "Style:") {
+ auto *ep = dynamic_cast<TEnumProperty *>(prop);
+ if (!ep || ep->getItems().empty()) continue;
+ m_typeStyleWidget =
+ createCollapsibleEnumForProperty(label, ep, name, propGroup);
+ if (!m_typeStyleWidget) continue;
+ m_typeStyleWidget->setSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Fixed);
+ m_propertiesLayout->addWidget(m_typeStyleWidget);
+ continue;
+ }
+
+ if (auto *ep = dynamic_cast<TEnumProperty *>(prop)) {
+ if (ep->getItems().empty()) continue;
+ QWidget *w =
+ createCollapsibleEnumForProperty(label, ep, name, propGroup);
+ if (!w) continue;
+ w->setProperty("propGroup", propGroup);
+ w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_propertiesLayout->addWidget(w);
+ continue;
+ }
+
+ if (auto *bp = dynamic_cast<TBoolProperty *>(prop)) {
+ QWidget *w = createCheckBox(label, bp->getValue(), name);
+ if (!w) continue;
+ w->setProperty("propGroup", propGroup);
+ m_propertiesLayout->addWidget(w);
+ continue;
+ }
+ }
+ };
+
+ processGroup(0);
+ processGroup(1);
+}
+
+void ToolPropertiesPanel::refreshTypeStyleWidget() {
+ if (!m_typeStyleWidget || m_currentToolType != "type") return;
+
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ TPropertyGroup *props = tool->getProperties(1);
+ if (!props) return;
+
+ auto *ep = dynamic_cast<TEnumProperty *>(props->getProperty("Style:"));
+ if (!ep) return;
+
+ const int index = m_propertiesLayout->indexOf(m_typeStyleWidget);
+ m_propertiesLayout->removeWidget(m_typeStyleWidget);
+ m_typeStyleWidget->deleteLater();
+ m_typeStyleWidget = nullptr;
+
+ m_typeStyleWidget =
+ createCollapsibleEnumForProperty(ep->getQStringName(), ep, "Style:", 1);
+ if (!m_typeStyleWidget) return;
+ m_typeStyleWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ if (index >= 0)
+ m_propertiesLayout->insertWidget(index, m_typeStyleWidget);
+ else
+ m_propertiesLayout->addWidget(m_typeStyleWidget);
}
//-----------------------------------------------------------------------------
// Slots
//-----------------------------------------------------------------------------
-void ToolPropertiesPanel::onToolSwitched() {
+void ToolPropertiesPanel::onToolSwitched() { refreshProperties(); }
+
+void ToolPropertiesPanel::onSceneContextChanged() {
+ TApplication *app = TApp::instance();
+ if (app && app->getCurrentFrame()->isPlaying()) {
+ updatePropertyValues();
+ return;
+ }
refreshProperties();
}
void ToolPropertiesPanel::onToolChanged() {
- // Check if tool type has changed (e.g., from "brush" to "mypaint")
- // This can happen when user changes brush style from standard to MyPaint
- QString currentType = detectCurrentToolType();
- if (currentType != m_currentToolType) {
- // Tool type changed, need to refresh entire properties display
+ const QString currentId = detectCurrentToolId();
+ const QString currentType = detectCurrentToolType();
+ if (currentId != m_currentToolId || currentType != m_currentToolType) {
refreshProperties();
} else {
- // Same tool type, just update property values (synchronization from ToolOptionsBar)
updatePropertyValues();
}
}
+void ToolPropertiesPanel::onToolComboBoxListChanged(const std::string &id) {
+ if (m_currentToolType != "type") return;
+ if (id != "Style:") return;
+ refreshTypeStyleWidget();
+ updateToolOptionControlsIn(m_propertiesContainer);
+}
+
void ToolPropertiesPanel::updatePropertyValues() {
TTool *tool = getCurrentTool();
if (!tool) return;
-
- // Update all widgets in the properties layout
- for (int i = 0; i < m_propertiesLayout->count(); ++i) {
- QLayoutItem *item = m_propertiesLayout->itemAt(i);
- if (!item || !item->widget()) continue;
-
- QWidget *widget = item->widget();
- updateWidgetFromProperty(widget);
+
+ // Update all TProperty-backed widgets (including nested mode sections).
+ updatePropertyWidgetsIn(m_propertiesContainer);
+
+ // Update Selection tool live transform fields (updateStatus reads
+ // DeformValues)
+ if (m_currentToolType == "selection") {
+ if (m_selScaleX) {
+ m_selScaleX->updateStatus();
+ bool scaleEnabled = m_selScaleX->isEnabled();
+ if (m_selHLabel) m_selHLabel->setEnabled(scaleEnabled);
+ if (m_selFlipH) m_selFlipH->setEnabled(scaleEnabled);
+ }
+ if (m_selScaleY) {
+ m_selScaleY->updateStatus();
+ bool scaleEnabled = m_selScaleY->isEnabled();
+ if (m_selVLabel) m_selVLabel->setEnabled(scaleEnabled);
+ if (m_selFlipV) m_selFlipV->setEnabled(scaleEnabled);
+ }
+ if (m_selRotation) {
+ m_selRotation->updateStatus();
+ bool rotEnabled = m_selRotation->isEnabled();
+ if (m_selRotL) m_selRotL->setEnabled(rotEnabled);
+ if (m_selRotR) m_selRotR->setEnabled(rotEnabled);
+ }
+ if (m_selMoveX) {
+ m_selMoveX->updateStatus();
+ if (m_selXLabel) m_selXLabel->setEnabled(m_selMoveX->isEnabled());
+ }
+ if (m_selMoveY) {
+ m_selMoveY->updateStatus();
+ if (m_selYLabel) m_selYLabel->setEnabled(m_selMoveY->isEnabled());
+ }
+ if (m_selThick) m_selThick->updateStatus();
+ reapplySelectionTransformFieldSizing(m_selScaleX, m_selScaleY,
+ m_selRotation, m_selMoveX, m_selMoveY,
+ m_selThick);
+ if (m_selScaleLink) {
+ const bool linked = selectionScaleLinkIsEnabled();
+ if (m_selScaleLink->isChecked() != linked) {
+ m_selScaleLink->blockSignals(true);
+ m_selScaleLink->setChecked(linked);
+ m_selScaleLink->blockSignals(false);
+ }
+ updateSelectionScaleLinkLockIcon(m_selScaleLinkIcon, linked);
+ }
+ }
+
+ if (m_currentToolType == "plastic") {
+ syncPlasticModeFromTool();
+ updatePlasticSkeletonPicker();
+ updatePlasticVertexField();
+ updatePlasticRelayFields();
+ }
+
+ if (m_currentToolType == "shifttrace") updateShiftTraceWidgets();
+
+ if (m_currentToolType == QStringLiteral("eraser")) updateEraserOptionStates();
+
+ if (m_currentToolType == "type") {
+ updateToolOptionControlsIn(m_propertiesContainer);
+ }
+
+ if (m_currentToolType == "edit") {
+ syncAnimateAxisFromTool();
+ updateAnimateColumnPicker();
+ updateToolOptionControlsIn(m_propertiesContainer);
+ for (MeasuredValueField *field : m_animateMeasuredFields)
+ styleAnimateGridField(field);
+
+ TApplication *app = TApp::instance();
+ if (app && !m_animateSplineRowWidgets.isEmpty()) {
+ TStageObjectId objId = app->getCurrentObject()->getObjectId();
+ bool splined = app->getCurrentXsheet()
+ ->getXsheet()
+ ->getStageObject(objId)
+ ->getSpline() != 0;
+ setGridRowVisible(m_animateSplineRowWidgets, splined);
+ setGridRowVisible(m_animateXYRowWidgets, !splined);
+ }
+ }
+}
+
+void ToolPropertiesPanel::updatePropertyWidgetsIn(QWidget *root) {
+ if (!root) return;
+
+ if (root->property("propName").isValid()) updateWidgetFromProperty(root);
+
+ const QList<QWidget *> widgets = root->findChildren<QWidget *>();
+ for (QWidget *widget : widgets) {
+ if (widget->property("propName").isValid())
+ updateWidgetFromProperty(widget);
+ }
+}
+
+void ToolPropertiesPanel::attachAllPropertySyncListeners() {
+ TTool *tool = getCurrentTool();
+ if (!tool) return;
+
+ const QList<QWidget *> widgets =
+ m_propertiesContainer->findChildren<QWidget *>();
+ for (QWidget *widget : widgets) {
+ if (!widget->property("propName").isValid()) continue;
+ if (widget->property("propSyncAttached").toBool()) continue;
+
+ const std::string propName =
+ widget->property("propName").toString().toStdString();
+ const int propGroup = widget->property("propGroup").toInt();
+
+ TProperty *prop = tppPropertyFromWidget(widget);
+ if (!prop) {
+ TPropertyGroup *props = tool->getProperties(propGroup);
+ if (!props && propGroup > 0) props = tool->getProperties(0);
+ if (props) prop = props->getProperty(propName);
+ }
+ if (!prop) continue;
+
+ new PropertyWidgetSync(this, widget, prop, widget);
+ widget->setProperty("propSyncAttached", true);
}
}
void ToolPropertiesPanel::updateWidgetFromProperty(QWidget *widget) {
if (!widget) return;
-
+
// Check if widget has a property name stored
QVariant propNameVariant = widget->property("propName");
if (!propNameVariant.isValid()) return;
-
+
std::string propName = propNameVariant.toString().toStdString();
- int propGroup = widget->property("propGroup").toInt();
-
+ int propGroup = widget->property("propGroup").toInt();
+
TTool *tool = getCurrentTool();
if (!tool) return;
-
- TPropertyGroup *props = tool->getProperties(propGroup);
- if (!props && propGroup > 0) {
- // Fallback to group 0 if specified group doesn't exist
- props = tool->getProperties(0);
- }
- if (!props) return;
-
- // Find the property
- for (int i = 0; i < props->getPropertyCount(); ++i) {
- TProperty *prop = props->getProperty(i);
- if (!prop || prop->getName() != propName) continue;
-
- // Update widget based on property type
-
- // Check for DoublePairField (Size with min/max)
- DVGui::DoublePairField *doublePairField = widget->findChild<DVGui::DoublePairField*>();
- if (doublePairField) {
- TDoublePairProperty *doublePairProp = dynamic_cast<TDoublePairProperty*>(prop);
- if (doublePairProp) {
- std::pair<double, double> values = doublePairProp->getValue();
- doublePairField->blockSignals(true);
- doublePairField->setValues(values);
- doublePairField->blockSignals(false);
- return;
- }
+
+ TProperty *prop = resolveTppProperty(tool, widget, propGroup, propName);
+ if (!prop) return;
+
+ // Collapsible text field (Plastic vertex name) — before generic line edits.
+ if (auto *strProp = dynamic_cast<TStringProperty *>(prop)) {
+ if (QLineEdit *directEdit = qobject_cast<QLineEdit *>(widget)) {
+ const QString newText = QString::fromStdWString(strProp->getValue());
+ directEdit->blockSignals(true);
+ directEdit->setText(newText);
+ directEdit->blockSignals(false);
+ return;
}
-
- // Check for IntPairField (Size with min/max)
- DVGui::IntPairField *intPairField = widget->findChild<DVGui::IntPairField*>();
- if (intPairField) {
- TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty*>(prop);
- if (intPairProp) {
- std::pair<int, int> values = intPairProp->getValue();
- intPairField->blockSignals(true);
- intPairField->setValues(values);
- intPairField->blockSignals(false);
- return;
+ if (QLineEdit *textEdit =
+ widget->findChild<QLineEdit *>("collapsibleTextEdit")) {
+ const QString newText = QString::fromStdWString(strProp->getValue());
+ textEdit->blockSignals(true);
+ textEdit->setText(newText);
+ textEdit->blockSignals(false);
+ if (QLabel *valueLabel = widget->findChild<QLabel *>("textValueLabel")) {
+ valueLabel->setText(newText);
}
+ return;
}
-
- // Check for slider + line edit combo
- QList<QLineEdit*> lineEdits = widget->findChildren<QLineEdit*>();
- QList<QSlider*> sliders = widget->findChildren<QSlider*>();
-
- if (!lineEdits.isEmpty() && !sliders.isEmpty()) {
- QLineEdit *lineEdit = lineEdits.first();
- QSlider *slider = sliders.first();
-
- // CRITICAL FIX: Check for TIntPairProperty first (Single Slider Max Only mode)
- // When m_useSingleMaxSlider is enabled, we create a simple slider for pair properties
- // that only displays/controls the MAX value
- TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty*>(prop);
- if (intPairProp) {
- std::pair<int, int> values = intPairProp->getValue();
- int maxValue = values.second; // Use MAX value for single slider
- slider->blockSignals(true);
- lineEdit->blockSignals(true);
- slider->setValue(maxValue);
- lineEdit->setText(QString::number(maxValue));
- slider->blockSignals(false);
- lineEdit->blockSignals(false);
- return;
- }
-
- // CRITICAL FIX: Check for TDoublePairProperty (Single Slider Max Only mode)
- TDoublePairProperty *doublePairProp = dynamic_cast<TDoublePairProperty*>(prop);
- if (doublePairProp) {
- std::pair<double, double> values = doublePairProp->getValue();
- double maxValue = values.second; // Use MAX value for single slider
- slider->blockSignals(true);
+ if (QLineEdit *lineEdit = widget->findChild<QLineEdit *>()) {
+ const QString newText = QString::fromStdWString(strProp->getValue());
+ if (lineEdit->text() != newText) {
lineEdit->blockSignals(true);
- slider->setValue(static_cast<int>(maxValue * 10));
- lineEdit->setText(QString::number(maxValue, 'f', 1));
- slider->blockSignals(false);
+ lineEdit->setText(newText);
lineEdit->blockSignals(false);
- return;
}
-
- // Update int property (simple, not pair)
- TIntProperty *intProp = dynamic_cast<TIntProperty*>(prop);
- if (intProp) {
- int value = intProp->getValue();
- slider->blockSignals(true);
- lineEdit->blockSignals(true);
- slider->setValue(value);
- lineEdit->setText(QString::number(value));
- slider->blockSignals(false);
- lineEdit->blockSignals(false);
- return;
+ return;
+ }
+ }
+
+ // Update widget based on property type
+
+ // Check for DoublePairField (Size with min/max)
+ DVGui::DoublePairField *doublePairField =
+ widget->findChild<DVGui::DoublePairField *>();
+ if (doublePairField) {
+ TDoublePairProperty *doublePairProp =
+ dynamic_cast<TDoublePairProperty *>(prop);
+ if (doublePairProp) {
+ std::pair<double, double> values = doublePairProp->getValue();
+ doublePairField->blockSignals(true);
+ doublePairField->setValues(values);
+ doublePairField->blockSignals(false);
+ return;
+ }
+ }
+
+ // Check for IntPairField (Size with min/max)
+ DVGui::IntPairField *intPairField =
+ widget->findChild<DVGui::IntPairField *>();
+ if (intPairField) {
+ TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty *>(prop);
+ if (intPairProp) {
+ std::pair<int, int> values = intPairProp->getValue();
+ intPairField->blockSignals(true);
+ intPairField->setValues(values);
+ intPairField->blockSignals(false);
+ return;
+ }
+ }
+
+ // Check for slider + line edit combo
+ QList<QLineEdit *> lineEdits = widget->findChildren<QLineEdit *>();
+ QList<QSlider *> sliders = widget->findChildren<QSlider *>();
+
+ if (!lineEdits.isEmpty() && !sliders.isEmpty()) {
+ QLineEdit *lineEdit = lineEdits.first();
+ QSlider *slider = sliders.first();
+
+ // CRITICAL FIX: Check for TIntPairProperty first (Single Slider Max Only
+ // mode) When m_useSingleMaxSlider is enabled, we create a simple slider for
+ // pair properties that only displays/controls the MAX value
+ TIntPairProperty *intPairProp = dynamic_cast<TIntPairProperty *>(prop);
+ if (intPairProp) {
+ std::pair<int, int> values = intPairProp->getValue();
+ int maxValue = values.second; // Use MAX value for single slider
+ slider->blockSignals(true);
+ lineEdit->blockSignals(true);
+ slider->setValue(maxValue);
+ lineEdit->setText(QString::number(maxValue));
+ slider->blockSignals(false);
+ lineEdit->blockSignals(false);
+ return;
+ }
+
+ // CRITICAL FIX: Check for TDoublePairProperty (Single Slider Max Only mode)
+ TDoublePairProperty *doublePairProp =
+ dynamic_cast<TDoublePairProperty *>(prop);
+ if (doublePairProp) {
+ std::pair<double, double> values = doublePairProp->getValue();
+ double maxValue = values.second;
+ const int valueFactor = widget->property("valueFactor").isValid()
+ ? widget->property("valueFactor").toInt()
+ : kTppDoubleSliderFactor;
+ const int valueDecimals = widget->property("valueDecimals").isValid()
+ ? widget->property("valueDecimals").toInt()
+ : kTppDoubleSliderDecimals;
+ const bool isLinear = widget->property("isLinearSlider").isValid()
+ ? widget->property("isLinearSlider").toBool()
+ : doublePairProp->isLinearSlider();
+ const int sliderPos =
+ tppDoubleValueToSliderPos(maxValue, slider->minimum(),
+ slider->maximum(), valueFactor, isLinear);
+ slider->blockSignals(true);
+ lineEdit->blockSignals(true);
+ slider->setValue(sliderPos);
+ lineEdit->setText(QString::number(maxValue, 'f', valueDecimals));
+ slider->blockSignals(false);
+ lineEdit->blockSignals(false);
+ return;
+ }
+
+ // Update int property (simple, not pair)
+ TIntProperty *intProp = dynamic_cast<TIntProperty *>(prop);
+ if (intProp) {
+ int value = intProp->getValue();
+ slider->blockSignals(true);
+ lineEdit->blockSignals(true);
+ slider->setValue(value);
+ lineEdit->setText(QString::number(value));
+ slider->blockSignals(false);
+ lineEdit->blockSignals(false);
+ if (QLabel *valueLabel =
+ widget->findChild<QLabel *>("intSliderValueLabel")) {
+ valueLabel->setText(QString::number(value));
}
-
- // Update double property (simple, not pair)
- TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty*>(prop);
- if (doubleProp) {
- double value = doubleProp->getValue();
-
- // Check if widget has custom value factor (for MyPaint sliders)
- int valueFactor = widget->property("valueFactor").isValid() ?
- widget->property("valueFactor").toInt() : 10;
- int valueDecimals = widget->property("valueDecimals").isValid() ?
- widget->property("valueDecimals").toInt() : 1;
-
- // Also update the value label if present
- QList<QLabel*> labels = widget->findChildren<QLabel*>();
- for (QLabel *label : labels) {
- if (label->alignment() & Qt::AlignRight) {
- label->setText(QString::number(value, 'f', valueDecimals));
- break;
- }
+ return;
+ }
+
+ // Update double property (simple, not pair)
+ TDoubleProperty *doubleProp = dynamic_cast<TDoubleProperty *>(prop);
+ if (doubleProp) {
+ double value = doubleProp->getValue();
+
+ // Check if widget has custom value factor (for MyPaint sliders)
+ int valueFactor = widget->property("valueFactor").isValid()
+ ? widget->property("valueFactor").toInt()
+ : kTppDoubleSliderFactor;
+ int valueDecimals = widget->property("valueDecimals").isValid()
+ ? widget->property("valueDecimals").toInt()
+ : kTppDoubleSliderDecimals;
+
+ // Also update the value label if present
+ QList<QLabel *> labels = widget->findChildren<QLabel *>();
+ for (QLabel *label : labels) {
+ if (label->alignment() & Qt::AlignRight) {
+ label->setText(QString::number(value, 'f', valueDecimals));
+ break;
}
-
- slider->blockSignals(true);
- lineEdit->blockSignals(true);
- slider->setValue(static_cast<int>(value * valueFactor));
- lineEdit->setText(QString::number(value, 'f', valueDecimals));
- slider->blockSignals(false);
- lineEdit->blockSignals(false);
- return;
}
+
+ slider->blockSignals(true);
+ lineEdit->blockSignals(true);
+ slider->setValue(static_cast<int>(value * valueFactor));
+ lineEdit->setText(QString::number(value, 'f', valueDecimals));
+ slider->blockSignals(false);
+ lineEdit->blockSignals(false);
+ return;
}
-
- // Check if widget itself is a checkbox
- QCheckBox *checkBox = qobject_cast<QCheckBox*>(widget);
- if (checkBox) {
- TBoolProperty *boolProp = dynamic_cast<TBoolProperty*>(prop);
- if (boolProp) {
- checkBox->blockSignals(true);
- checkBox->setChecked(boolProp->getValue());
- checkBox->blockSignals(false);
- return;
- }
+ }
+
+ // Check if widget itself is a checkbox
+ QCheckBox *checkBox = qobject_cast<QCheckBox *>(widget);
+ if (checkBox) {
+ TBoolProperty *boolProp = dynamic_cast<TBoolProperty *>(prop);
+ if (boolProp) {
+ checkBox->blockSignals(true);
+ checkBox->setChecked(boolProp->getValue());
+ checkBox->blockSignals(false);
+ return;
}
-
- // Check for QComboBox (Snap Sensitivity, etc.)
- QComboBox *comboBox = widget->findChild<QComboBox*>();
- if (comboBox) {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- int index = enumProp->getIndex();
- comboBox->blockSignals(true);
- comboBox->setCurrentIndex(index);
- comboBox->blockSignals(false);
- return;
- }
+ }
+
+ // Check for QComboBox (Snap Sensitivity, etc.)
+ QComboBox *comboBox = widget->findChild<QComboBox *>();
+ if (comboBox) {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (enumProp) {
+ int index = enumProp->getIndex();
+ comboBox->blockSignals(true);
+ comboBox->setCurrentIndex(index);
+ comboBox->blockSignals(false);
+ return;
}
-
- // Check for collapsible enum with QButtonGroup
- QButtonGroup *buttonGroup = widget->findChild<QButtonGroup*>();
- if (buttonGroup) {
- TEnumProperty *enumProp = dynamic_cast<TEnumProperty*>(prop);
- if (enumProp) {
- int newIndex = enumProp->getIndex();
-
- // Update button checked state via button group
- QAbstractButton *button = buttonGroup->button(newIndex);
- if (button) {
- button->blockSignals(true);
- button->setChecked(true);
- button->blockSignals(false);
- }
-
- // Update value label
- QList<QLabel*> labels = widget->findChildren<QLabel*>();
- for (QLabel *label : labels) {
- if (label->objectName() == "valueLabel" && enumProp->getItems().size() > newIndex) {
- label->setText(enumProp->getItems()[newIndex].UIName);
- break;
- }
+ }
+
+ // Check for collapsible enum with QButtonGroup
+ QButtonGroup *buttonGroup = widget->findChild<QButtonGroup *>();
+ if (buttonGroup) {
+ TEnumProperty *enumProp = dynamic_cast<TEnumProperty *>(prop);
+ if (enumProp) {
+ int newIndex = enumProp->getIndex();
+
+ // Update button checked state via button group
+ QAbstractButton *button = buttonGroup->button(newIndex);
+ if (button) {
+ button->blockSignals(true);
+ button->setChecked(true);
+ button->blockSignals(false);
+ }
+
+ // Update value label
+ QList<QLabel *> labels = widget->findChildren<QLabel *>();
+ for (QLabel *label : labels) {
+ if (label->objectName() == "valueLabel" &&
+ enumProp->getItems().size() > newIndex) {
+ label->setText(enumProp->getItems()[newIndex].UIName);
+ break;
}
- return;
}
+ return;
}
-
- break;
}
}
@@ -2356,263 +7039,270 @@ void ToolPropertiesPanel::onPressureChanged(bool checked) {
// Double/Single Slider Creation
//-----------------------------------------------------------------------------
-void ToolPropertiesPanel::createDoublePairSlider(const QString &label,
- void *propPtr,
- const std::string &propName) {
- TDoublePairProperty *prop = static_cast<TDoublePairProperty*>(propPtr);
- double rangeMin = prop->getRange().first;
- double rangeMax = prop->getRange().second;
- double valueMin = prop->getValue().first;
- double valueMax = prop->getValue().second;
-
+void ToolPropertiesPanel::createDoublePairSlider(const QString &label,
+ void *propPtr,
+ const std::string &propName,
+ int propGroup) {
+ TDoublePairProperty *prop = static_cast<TDoublePairProperty *>(propPtr);
+ double rangeMin = prop->getRange().first;
+ double rangeMax = prop->getRange().second;
+ double valueMin = prop->getValue().first;
+ double valueMax = prop->getValue().second;
+
QWidget *container = new QWidget(this);
container->setProperty("propName", QString::fromStdString(propName));
- container->setProperty("propGroup", 0);
-
+ container->setProperty("propGroup", propGroup);
+ storeTppPropertyPtr(container, prop);
+
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label (respect m_showLabels)
QLabel *nameLabel = new QLabel(label, container);
nameLabel->setVisible(m_showLabels);
layout->addWidget(nameLabel);
-
+
if (!m_useSingleMaxSlider) {
- // === NATIVE DOUBLE SLIDER (DoublePairField) - Simple original layout ===
- DVGui::DoublePairField *pairField = new DVGui::DoublePairField(container);
+ // === NATIVE DOUBLE SLIDER (DoublePairField) — compact, no Min/Max labels
+ // ===
+ auto *pairField =
+ new TppCompactDoublePairField(container, prop->isMaxRangeLimited());
pairField->setRange(rangeMin, rangeMax);
pairField->setValues(std::make_pair(valueMin, valueMax));
- pairField->setLeftText(tr("Min"));
- pairField->setRightText(tr("Max"));
- pairField->setMinimumWidth(200);
-
- // Hide numeric fields if m_showNumericFields is false
- if (!m_showNumericFields) {
- pairField->setLabelsEnabled(false);
- QList<QLineEdit*> lineEdits = pairField->findChildren<QLineEdit*>();
- for (QLineEdit *le : lineEdits) {
- le->hide();
- }
- }
-
+ pairField->configureTppLayout(rangeMin, rangeMax, prop->isLinearSlider(),
+ m_showNumericFields);
+
layout->addWidget(pairField);
-
+
// Connect to property - update property value when slider changes
- connect(pairField, &DVGui::DoublePairField::valuesChanged,
+ connect(pairField, &DVGui::DoublePairField::valuesChanged,
[this, prop, pairField, propName](bool isDragging) {
- // Get new values from the field and update property
- std::pair<double, double> newValues = pairField->getValues();
- prop->setValue(TDoublePairProperty::Value(newValues.first, newValues.second));
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ // Get new values from the field and update property
+ std::pair<double, double> newValues = pairField->getValues();
+ prop->setValue(TDoublePairProperty::Value(newValues.first,
+ newValues.second));
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
} else {
// === SINGLE SLIDER (single value) - With numeric field ===
+ const int valueFactor = kTppDoubleSliderFactor;
+ const int valueDecimals = kTppDoubleSliderDecimals;
+ const bool isLinear = prop->isLinearSlider();
+ container->setProperty("valueFactor", valueFactor);
+ container->setProperty("valueDecimals", valueDecimals);
+ container->setProperty("isLinearSlider", isLinear);
+
QHBoxLayout *sliderLayout = new QHBoxLayout();
sliderLayout->setMargin(0);
sliderLayout->setSpacing(5);
-
- // Numeric field (respect m_showNumericFields)
+
QLineEdit *lineEdit = new QLineEdit(container);
- lineEdit->setText(QString::number(valueMax, 'f', 1));
- lineEdit->setFixedWidth(45);
- lineEdit->setAlignment(Qt::AlignRight);
+ styleTppDoubleLineEdit(lineEdit, rangeMin, rangeMax, valueDecimals);
+ lineEdit->setText(QString::number(valueMax, 'f', valueDecimals));
lineEdit->setVisible(m_showNumericFields);
- QDoubleValidator *validator = new QDoubleValidator(rangeMin, rangeMax, 1, lineEdit);
+ QDoubleValidator *validator =
+ new QDoubleValidator(rangeMin, rangeMax, valueDecimals, lineEdit);
lineEdit->setValidator(validator);
sliderLayout->addWidget(lineEdit);
-
- // Single Slider for Max
- QSlider *maxSlider = new QSlider(Qt::Horizontal, container);
- maxSlider->setMinimum(static_cast<int>(rangeMin * 10));
- maxSlider->setMaximum(static_cast<int>(rangeMax * 10));
- maxSlider->setValue(static_cast<int>(valueMax * 10));
+
+ const int sliderMin = static_cast<int>(std::lround(rangeMin * valueFactor));
+ const int sliderMax = static_cast<int>(std::lround(rangeMax * valueFactor));
+ QSlider *maxSlider = new QSlider(Qt::Horizontal, container);
+ maxSlider->setMinimum(sliderMin);
+ maxSlider->setMaximum(sliderMax);
+ maxSlider->setValue(tppDoubleValueToSliderPos(
+ valueMax, sliderMin, sliderMax, valueFactor, isLinear));
sliderLayout->addWidget(maxSlider, 1);
-
+
layout->addLayout(sliderLayout);
-
- // Connect slider to lineEdit
- connect(maxSlider, &QSlider::valueChanged, [lineEdit](int val) {
- lineEdit->setText(QString::number(val / 10.0, 'f', 1));
- });
-
- // Connect lineEdit to slider
- connect(lineEdit, &QLineEdit::editingFinished, [maxSlider, lineEdit]() {
- maxSlider->setValue(static_cast<int>(lineEdit->text().toDouble() * 10));
- });
-
- // Connect slider to property
- connect(maxSlider, &QSlider::valueChanged, [this, prop, propName](int val) {
- double newMaxValue = val / 10.0;
-
- // Use native Pressure property to determine behavior
- // Pressure OFF → Fixed size (set both min and max)
- // Pressure ON → Dynamic range (update max only, preserve min)
- TTool *tool = getCurrentTool();
- bool pressureDisabled = true; // Default to fixed size
-
- if (tool) {
- TPropertyGroup *props = tool->getProperties(0);
- if (props) {
- for (int i = 0; i < props->getPropertyCount(); ++i) {
- TProperty *p = props->getProperty(i);
- if (p && (p->getName() == "Pressure" || p->getName() == "PressureSensitivity")) {
- TBoolProperty *pressureProp = dynamic_cast<TBoolProperty*>(p);
- if (pressureProp) {
- pressureDisabled = !pressureProp->getValue();
- break;
+
+ connect(
+ maxSlider, &QSlider::valueChanged,
+ [lineEdit, maxSlider, valueFactor, valueDecimals, isLinear](int val) {
+ const double v = tppSliderPosToDoubleValue(val, maxSlider->minimum(),
+ maxSlider->maximum(),
+ valueFactor, isLinear);
+ lineEdit->setText(QString::number(v, 'f', valueDecimals));
+ });
+
+ connect(lineEdit, &QLineEdit::editingFinished,
+ [maxSlider, lineEdit, valueFactor, isLinear]() {
+ const double v = lineEdit->text().toDouble();
+ maxSlider->setValue(tppDoubleValueToSliderPos(
+ v, maxSlider->minimum(), maxSlider->maximum(), valueFactor,
+ isLinear));
+ });
+
+ connect(maxSlider, &QSlider::valueChanged,
+ [this, prop, propName, maxSlider, valueFactor, isLinear](int val) {
+ const double newMaxValue = tppSliderPosToDoubleValue(
+ val, maxSlider->minimum(), maxSlider->maximum(), valueFactor,
+ isLinear);
+
+ // Only collapse pressure-controlled ranges when pressure is off.
+ // Other ranges, such as Fill Depth, keep their minimum value.
+ TTool *tool = getCurrentTool();
+ bool pressureDisabled = false;
+
+ if (tool) {
+ TPropertyGroup *props = tool->getProperties(0);
+ if (props) {
+ for (int i = 0; i < props->getPropertyCount(); ++i) {
+ TProperty *p = props->getProperty(i);
+ if (p && (p->getName() == "Pressure" ||
+ p->getName() == "PressureSensitivity")) {
+ TBoolProperty *pressureProp =
+ dynamic_cast<TBoolProperty *>(p);
+ if (pressureProp) {
+ pressureDisabled = !pressureProp->getValue();
+ break;
+ }
+ }
+ }
+ }
}
- }
- }
- }
- }
-
- if (pressureDisabled) {
- // Fixed Size Mode: Set both Min and Max to the same value
- prop->setValue(TDoublePairProperty::Value(newMaxValue, newMaxValue));
- } else {
- // Dynamic Range Mode: Only update Max, preserve Min
- // Guard: if new Max < current Min, push Min down (same logic as DoublePairField)
- double currentMin = prop->getValue().first;
- double newMin = currentMin;
- if (newMaxValue < currentMin) {
- newMin = newMaxValue; // Push Min down to match Max
- }
- prop->setValue(TDoublePairProperty::Value(newMin, newMaxValue));
- }
-
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
+
+ if (pressureDisabled) {
+ // Fixed Size Mode: Set both Min and Max to the same value
+ prop->setValue(
+ TDoublePairProperty::Value(newMaxValue, newMaxValue));
+ } else {
+ // Dynamic Range Mode: Only update Max, preserve Min
+ // Guard: if new Max < current Min, push Min down (same logic as
+ // DoublePairField)
+ double currentMin = prop->getValue().first;
+ double newMin = currentMin;
+ if (newMaxValue < currentMin) {
+ newMin = newMaxValue; // Push Min down to match Max
+ }
+ prop->setValue(TDoublePairProperty::Value(newMin, newMaxValue));
+ }
+
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
}
-
+
m_propertiesLayout->addWidget(container);
m_propertiesLayout->addSpacing(10);
}
-void ToolPropertiesPanel::createIntPairSlider(const QString &label,
- void *propPtr,
- const std::string &propName) {
- TIntPairProperty *prop = static_cast<TIntPairProperty*>(propPtr);
- int rangeMin = prop->getRange().first;
- int rangeMax = prop->getRange().second;
- int valueMin = prop->getValue().first;
- int valueMax = prop->getValue().second;
-
+void ToolPropertiesPanel::createIntPairSlider(const QString &label,
+ void *propPtr,
+ const std::string &propName,
+ int propGroup) {
+ TIntPairProperty *prop = static_cast<TIntPairProperty *>(propPtr);
+ int rangeMin = prop->getRange().first;
+ int rangeMax = prop->getRange().second;
+ int valueMin = prop->getValue().first;
+ int valueMax = prop->getValue().second;
+
QWidget *container = new QWidget(this);
container->setProperty("propName", QString::fromStdString(propName));
- container->setProperty("propGroup", 0);
-
+ container->setProperty("propGroup", propGroup);
+ storeTppPropertyPtr(container, prop);
+
QVBoxLayout *layout = new QVBoxLayout(container);
layout->setMargin(0);
layout->setSpacing(3);
-
+
// Label (respect m_showLabels)
QLabel *nameLabel = new QLabel(label, container);
nameLabel->setVisible(m_showLabels);
layout->addWidget(nameLabel);
-
+
if (!m_useSingleMaxSlider) {
- // === DOUBLE CURSEUR NATIF (IntPairField) ===
- DVGui::IntPairField *pairField = new DVGui::IntPairField(container);
+ // === NATIVE DOUBLE SLIDER (IntPairField) — compact, no Min/Max labels ===
+ DVGui::IntPairField *pairField =
+ new DVGui::IntPairField(container, prop->isMaxRangeLimited());
pairField->setRange(rangeMin, rangeMax);
pairField->setValues(std::make_pair(valueMin, valueMax));
- pairField->setLeftText(tr("Min:"));
- pairField->setRightText(tr("Max:"));
- pairField->setMinimumWidth(200); // Minimum width to avoid cramping
-
- // Hide numeric fields if m_showNumericFields is false
- if (!m_showNumericFields) {
- pairField->setLabelsEnabled(false); // Hide labels (Min:/Max:)
- // Also hide the line edit fields (find children and hide)
- QList<QLineEdit*> lineEdits = pairField->findChildren<QLineEdit*>();
- for (QLineEdit *le : lineEdits) {
- le->hide();
- }
- }
-
+ configureTppIntPairField(pairField, rangeMin, rangeMax,
+ m_showNumericFields);
+
layout->addWidget(pairField);
-
+
// Connect to property
- connect(pairField, &DVGui::IntPairField::valuesChanged, [this, pairField, prop, propName](bool isDragging) {
- std::pair<int, int> values = pairField->getValues();
- prop->setValue(TIntPairProperty::Value(values.first, values.second));
-
- TTool *tool = getCurrentTool();
- if (tool) {
- tool->onPropertyChanged(propName);
- if (m_toolHandle) {
- m_toolHandle->notifyToolChanged();
- }
- }
- });
-
+ connect(
+ pairField, &DVGui::IntPairField::valuesChanged,
+ [this, pairField, prop, propName](bool isDragging) {
+ std::pair<int, int> values = pairField->getValues();
+ prop->setValue(TIntPairProperty::Value(values.first, values.second));
+
+ TTool *tool = getCurrentTool();
+ if (tool) {
+ tool->onPropertyChanged(propName);
+ if (m_toolHandle) {
+ m_toolHandle->notifyToolChanged();
+ }
+ }
+ });
+
} else {
// === SINGLE SLIDER (single value) - With numeric field ===
-
+
// Slider layout with numeric field on the left
QHBoxLayout *sliderLayout = new QHBoxLayout();
sliderLayout->setMargin(0);
sliderLayout->setSpacing(5);
-
+
// Numeric field (QLineEdit to avoid arrows, respect m_showNumericFields)
QLineEdit *lineEdit = new QLineEdit(container);
+ styleTppIntLineEdit(lineEdit, rangeMin, rangeMax);
lineEdit->setText(QString::number(valueMax));
- lineEdit->setFixedWidth(45); // Match Hardness field size
- lineEdit->setAlignment(Qt::AlignRight);
lineEdit->setVisible(m_showNumericFields);
QIntValidator *validator = new QIntValidator(rangeMin, rangeMax, lineEdit);
lineEdit->setValidator(validator);
sliderLayout->addWidget(lineEdit);
-
+
// Single Slider for Max (set both min and max to same value)
QSlider *maxSlider = new QSlider(Qt::Horizontal, container);
maxSlider->setMinimum(rangeMin);
maxSlider->setMaximum(rangeMax);
maxSlider->setValue(valueMax);
sliderLayout->addWidget(maxSlider, 1); // Stretch to take available space
-
+
layout->addLayout(sliderLayout);
-
+
// Connect slider to lineEdit
- connect(maxSlider, &QSlider::valueChanged, [lineEdit](int val) {
- lineEdit->setText(QString::number(val));
- });
-
+ connect(maxSlider, &QSlider::valueChanged,
+ [lineEdit](int val) { lineEdit->setText(QString::number(val)); });
+
// Connect lineEdit to slider
connect(lineEdit, &QLineEdit::editingFinished, [maxSlider, lineEdit]() {
maxSlider->setValue(lineEdit->text().toInt());
});
-
+
// Connect slider to property
connect(maxSlider, &QSlider::valueChanged, [this, prop, propName](int val) {
int newMaxValue = val;
-
- // Use native Pressure property to determine behavior
- // Pressure OFF → Fixed size (set both min and max)
- // Pressure ON → Dynamic range (update max only, preserve min)
- TTool *tool = getCurrentTool();
- bool pressureDisabled = true; // Default to fixed size
-
+
+ // Only collapse pressure-controlled ranges when pressure is off.
+ // Other ranges, such as Fill Depth, keep their minimum value.
+ TTool *tool = getCurrentTool();
+ bool pressureDisabled = false;
+
if (tool) {
TPropertyGroup *props = tool->getProperties(0);
if (props) {
for (int i = 0; i < props->getPropertyCount(); ++i) {
TProperty *p = props->getProperty(i);
- if (p && (p->getName() == "Pressure" || p->getName() == "PressureSensitivity")) {
- TBoolProperty *pressureProp = dynamic_cast<TBoolProperty*>(p);
+ if (p && (p->getName() == "Pressure" ||
+ p->getName() == "PressureSensitivity")) {
+ TBoolProperty *pressureProp = dynamic_cast<TBoolProperty *>(p);
if (pressureProp) {
pressureDisabled = !pressureProp->getValue();
break;
@@ -2621,21 +7311,22 @@ void ToolPropertiesPanel::createIntPairSlider(const QString &label,
}
}
}
-
+
if (pressureDisabled) {
// Fixed Size Mode: Set both Min and Max to the same value
prop->setValue(TIntPairProperty::Value(newMaxValue, newMaxValue));
} else {
// Dynamic Range Mode: Only update Max, preserve Min
- // Guard: if new Max < current Min, push Min down (same logic as IntPairField)
+ // Guard: if new Max < current Min, push Min down (same logic as
+ // IntPairField)
int currentMin = prop->getValue().first;
- int newMin = currentMin;
+ int newMin = currentMin;
if (newMaxValue < currentMin) {
newMin = newMaxValue; // Push Min down to match Max
}
prop->setValue(TIntPairProperty::Value(newMin, newMaxValue));
}
-
+
if (tool) {
tool->onPropertyChanged(propName);
if (m_toolHandle) {
@@ -2644,9 +7335,9 @@ void ToolPropertiesPanel::createIntPairSlider(const QString &label,
}
});
}
-
+
m_propertiesLayout->addWidget(container);
-
+
// Additional spacing after Size block
m_propertiesLayout->addSpacing(10);
}
@@ -2657,64 +7348,75 @@ void ToolPropertiesPanel::createIntPairSlider(const QString &label,
void ToolPropertiesPanel::contextMenuEvent(QContextMenuEvent *event) {
QMenu *menu = new QMenu(this);
-
+
// Add "GUI Show / Hide" menu specific to this panel
addShowHideContextMenu(menu);
-
- // NOTE: The "Bind to Room" menu is handled by the parent DockWidget, not by the panel itself.
- // It appears when right-clicking on the panel title bar, not on its content.
-
+
+ // NOTE: The "Bind to Room" menu is handled by the parent DockWidget, not by
+ // the panel itself. It appears when right-clicking on the panel title bar,
+ // not on its content.
+
menu->exec(event->globalPos());
delete menu;
}
void ToolPropertiesPanel::addShowHideContextMenu(QMenu *menu) {
QMenu *showHideMenu = menu->addMenu(tr("GUI Show / Hide"));
-
+
// Action to toggle to single slider (Max only)
- QAction *singleMaxSliderAction = showHideMenu->addAction(tr("Single Slider (Max Only)"));
+ QAction *singleMaxSliderAction =
+ showHideMenu->addAction(tr("Single Slider (Max Only)"));
singleMaxSliderAction->setCheckable(true);
singleMaxSliderAction->setChecked(m_useSingleMaxSlider);
singleMaxSliderAction->setObjectName("singleSlider");
-
+
// Action to show/hide labels
QAction *showLabelsAction = showHideMenu->addAction(tr("Show Labels"));
showLabelsAction->setCheckable(true);
showLabelsAction->setChecked(m_showLabels);
showLabelsAction->setObjectName("showLabels");
-
+
// Action to show/hide numeric fields
- QAction *showNumericAction = showHideMenu->addAction(tr("Show Numeric Fields"));
+ QAction *showNumericAction =
+ showHideMenu->addAction(tr("Show Numeric Fields"));
showNumericAction->setCheckable(true);
showNumericAction->setChecked(m_showNumericFields);
showNumericAction->setObjectName("showNumeric");
-
+
showHideMenu->addSeparator();
-
+
// Action to show/hide cell borders (for collapsible menu options)
QAction *showBordersAction = showHideMenu->addAction(tr("Cell Borders"));
showBordersAction->setCheckable(true);
showBordersAction->setChecked(m_showBorders);
showBordersAction->setObjectName("showBorders");
-
+
// Action to show/hide cell backgrounds (for collapsible menu options)
- QAction *showBackgroundsAction = showHideMenu->addAction(tr("Cell Backgrounds"));
+ QAction *showBackgroundsAction =
+ showHideMenu->addAction(tr("Cell Backgrounds"));
showBackgroundsAction->setCheckable(true);
showBackgroundsAction->setChecked(m_showBackgrounds);
showBackgroundsAction->setObjectName("showBackgrounds");
-
- // Action to show/hide Cap/Join icons
+
+ // Show Icons: icon grid replaces collapsible enum menus (when every option
+ // has an icon)
QAction *showIconsAction = showHideMenu->addAction(tr("Show Icons"));
showIconsAction->setCheckable(true);
showIconsAction->setChecked(m_showIcons);
showIconsAction->setObjectName("showIcons");
-
- connect(singleMaxSliderAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
- connect(showLabelsAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
- connect(showNumericAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
- connect(showBordersAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
- connect(showBackgroundsAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
- connect(showIconsAction, SIGNAL(triggered()), this, SLOT(onShowHideActionTriggered()));
+
+ connect(singleMaxSliderAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
+ connect(showLabelsAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
+ connect(showNumericAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
+ connect(showBordersAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
+ connect(showBackgroundsAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
+ connect(showIconsAction, SIGNAL(triggered()), this,
+ SLOT(onShowHideActionTriggered()));
}
//-----------------------------------------------------------------------------
@@ -2723,10 +7425,11 @@ void ToolPropertiesPanel::addShowHideContextMenu(QMenu *menu) {
void ToolPropertiesPanel::updateContainerStylesheet() {
if (!m_propertiesContainer) return;
-
+
// No stylesheet needed - we use custom ToolPropertyButton with paintEvent
// Instead, update all existing ToolPropertyButton instances
- QList<ToolPropertyButton*> buttons = m_propertiesContainer->findChildren<ToolPropertyButton*>();
+ QList<ToolPropertyButton *> buttons =
+ m_propertiesContainer->findChildren<ToolPropertyButton *>();
for (ToolPropertyButton *btn : buttons) {
btn->setShowBorders(m_showBorders);
btn->setShowBackgrounds(m_showBackgrounds);
@@ -2738,55 +7441,50 @@ QString ToolPropertiesPanel::getButtonStyleChecked() const {
return QString();
}
-QString ToolPropertiesPanel::getButtonStyleNormal(bool showBorders, bool showBackgrounds) const {
+QString ToolPropertiesPanel::getButtonStyleNormal(bool showBorders,
+ bool showBackgrounds) const {
// Not used anymore - kept for API compatibility
return QString();
}
void ToolPropertiesPanel::onShowHideActionTriggered() {
- QAction *action = qobject_cast<QAction*>(sender());
+ QAction *action = qobject_cast<QAction *>(sender());
if (!action) return;
-
+
QString actionName = action->objectName();
- bool needsRefresh = false;
-
+ bool needsRefresh = false;
+
// Save preferences according to the action (TEnv)
if (actionName == "singleSlider") {
- m_useSingleMaxSlider = action->isChecked();
+ m_useSingleMaxSlider = action->isChecked();
ToolPropertiesUseSingleMaxSlider = m_useSingleMaxSlider ? 1 : 0;
- needsRefresh = true;
- }
- else if (actionName == "showLabels") {
- m_showLabels = action->isChecked();
+ needsRefresh = true;
+ } else if (actionName == "showLabels") {
+ m_showLabels = action->isChecked();
ToolPropertiesShowLabels = m_showLabels ? 1 : 0;
- needsRefresh = true;
- }
- else if (actionName == "showNumeric") {
- m_showNumericFields = action->isChecked();
+ needsRefresh = true;
+ } else if (actionName == "showNumeric") {
+ m_showNumericFields = action->isChecked();
ToolPropertiesShowNumericFields = m_showNumericFields ? 1 : 0;
- needsRefresh = true;
- }
- else if (actionName == "showBorders") {
- m_showBorders = action->isChecked();
+ needsRefresh = true;
+ } else if (actionName == "showBorders") {
+ m_showBorders = action->isChecked();
ToolPropertiesShowBorders = m_showBorders ? 1 : 0;
updateContainerStylesheet(); // Update container stylesheet immediately
needsRefresh = true;
- }
- else if (actionName == "showBackgrounds") {
- m_showBackgrounds = action->isChecked();
+ } else if (actionName == "showBackgrounds") {
+ m_showBackgrounds = action->isChecked();
ToolPropertiesShowBackgrounds = m_showBackgrounds ? 1 : 0;
updateContainerStylesheet(); // Update container stylesheet immediately
needsRefresh = true;
- }
- else if (actionName == "showIcons") {
- m_showIcons = action->isChecked();
+ } else if (actionName == "showIcons") {
+ m_showIcons = action->isChecked();
ToolPropertiesShowIcons = m_showIcons ? 1 : 0;
- needsRefresh = true;
+ needsRefresh = true;
}
-
+
// Refresh properties to apply changes
if (needsRefresh) {
refreshProperties();
}
}
-
diff --git a/toonz/sources/toonz/toolpropertiespanel.h b/toonz/sources/toonz/toolpropertiespanel.h
index 4651aacf5..ab66a6f32 100644
--- a/toonz/sources/toonz/toolpropertiespanel.h
+++ b/toonz/sources/toonz/toolpropertiespanel.h
@@ -12,36 +12,82 @@
#include <QCheckBox>
#include <QComboBox>
#include <QToolButton>
+#include <QMouseEvent>
+#include <QPushButton>
+#include <QList>
#include <QMap>
+#include <QStackedWidget>
#include <QString>
+#include <functional>
//=============================================================================
-// Custom button that respects Cells Borders/Backgrounds while preserving theme colors
+// Custom button that respects Cells Borders/Backgrounds while preserving theme
+// colors
//=============================================================================
class ToolPropertyButton : public QToolButton {
Q_OBJECT
-
+
bool m_showBorders;
bool m_showBackgrounds;
-
+ bool m_hoverEnabled = true;
+ int m_compactIconSize = 0; // >0: highlight/hover only around icon (px)
+
public:
ToolPropertyButton(const QString &text, QWidget *parent = nullptr);
-
- void setShowBorders(bool show) { m_showBorders = show; update(); }
- void setShowBackgrounds(bool show) { m_showBackgrounds = show; update(); }
-
+
+ void setShowBorders(bool show) {
+ m_showBorders = show;
+ update();
+ }
+ void setShowBackgrounds(bool show) {
+ m_showBackgrounds = show;
+ update();
+ }
+ void setHoverEnabled(bool enabled) {
+ m_hoverEnabled = enabled;
+ update();
+ }
+ // Compact highlight: keeps hit area, draws theme state on a smaller centered
+ // rect.
+ void setCompactIconHighlight(int iconSize) {
+ m_compactIconSize = iconSize;
+ update();
+ }
+
protected:
void paintEvent(QPaintEvent *event) override;
+ void enterEvent(QEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
};
// Forward declarations
class TTool;
class ToolHandle;
class TApplication;
+class TStringProperty;
+class TEnumProperty;
+class TXsheetHandle;
+class TObjectHandle;
class QSpinBox;
class QDoubleSpinBox;
+// tnztools – Selection tool specialized fields (forward declarations only)
+class SelectionScaleField;
+class SelectionRotationField;
+class SelectionMoveField;
+class ThickChangeField;
+class MeasuredValueField;
+class PegbarChannelField;
+class ClickableLabel;
+class SelectionTool;
+class PlasticTool;
+class RulerToolOptionsBox;
+class ToolOptionTextField;
+namespace DVGui {
+class CheckBox;
+}
+
//=============================================================================
// Tool Properties Panel - Tool properties panel
// Generic architecture, brushes implementation only for now
@@ -50,50 +96,118 @@ class QDoubleSpinBox;
class ToolPropertiesPanel : public TPanel {
Q_OBJECT
+ class PropertyWidgetSync;
+ friend class PropertyWidgetSync;
+
// UI Components
QScrollArea *m_scrollArea;
QWidget *m_propertiesContainer;
QVBoxLayout *m_propertiesLayout;
QLabel *m_toolNameLabel;
-
+
// Tool management
ToolHandle *m_toolHandle;
QString m_currentToolId;
QString m_currentToolType; // "brush", "fill", "eraser", etc.
- bool m_useSingleMaxSlider; // false = DoublePairField (double curseur natif), true = single slider (max uniquement)
- bool m_showLabels; // Show/hide property labels
- bool m_showNumericFields; // Show/hide numeric fields
- bool m_showBorders; // Show/hide option borders in collapsible menus
- bool m_showBackgrounds; // Show/hide option backgrounds in collapsible menus
- bool m_showIcons; // Show/hide icons in Cap/Join options
-
+
+ // Selection tool transform fields (valid only while selection tool is active)
+ SelectionScaleField *m_selScaleX = nullptr;
+ SelectionScaleField *m_selScaleY = nullptr;
+ SelectionRotationField *m_selRotation = nullptr;
+ SelectionMoveField *m_selMoveX = nullptr;
+ SelectionMoveField *m_selMoveY = nullptr;
+ ThickChangeField *m_selThick = nullptr;
+ DVGui::CheckBox *m_selScaleLink = nullptr;
+ QPushButton *m_selFlipH = nullptr;
+ QPushButton *m_selFlipV = nullptr;
+ QPushButton *m_selRotL = nullptr;
+ QPushButton *m_selRotR = nullptr;
+ ClickableLabel *m_selHLabel = nullptr;
+ ClickableLabel *m_selVLabel = nullptr;
+ ClickableLabel *m_selXLabel = nullptr;
+ ClickableLabel *m_selYLabel = nullptr;
+ QLabel *m_selScaleLinkIcon = nullptr;
+
+ // Type tool — Style capsule rebuilt when font changes
+ // (toolComboBoxListChanged).
+ QWidget *m_typeStyleWidget = nullptr;
+
+ // Ruler tool: persistent read-only measurement strip (no TPropertyGroup).
+ RulerToolOptionsBox *m_rulerOptionsBox = nullptr;
+ bool m_rulerOptionsBoxRegistered = false;
+
+ // Plastic tool persistent widgets (synced with tool options bar).
+ QWidget *m_plasticModeContainer = nullptr;
+ QVBoxLayout *m_plasticModeLayout = nullptr;
+ QWidget *m_plasticSkelPicker = nullptr;
+ QWidget *m_plasticVertexWidget = nullptr;
+ int m_plasticVisibleMode = -1;
+
+ // Animate (Edit) tool persistent widgets.
+ QWidget *m_animateColumnWidget = nullptr;
+ QList<QWidget *> m_animateSplineRowWidgets;
+ QList<QWidget *> m_animateXYRowWidgets;
+ QList<MeasuredValueField *> m_animateMeasuredFields;
+ QWidget *m_animateAxisFieldsHost = nullptr;
+ QStackedWidget *m_animateAxisStack = nullptr;
+ QList<QWidget *> m_animateAxisStackPages;
+ QWidget *m_animateAllModeHost = nullptr;
+ QVBoxLayout *m_animateAllModeLayout = nullptr;
+ bool m_animateSectionsInAllLayout = false;
+ QList<QWidget *> m_animateAxisSectionHeaders;
+ QList<QWidget *> m_animateAxisSections;
+ int m_animateVisibleAxis = -1;
+ PegbarChannelField *m_animateScaleHField = nullptr;
+ PegbarChannelField *m_animateScaleVField = nullptr;
+
+ // Shift && Trace (Edit Shift pseudo-tool only).
+ QWidget *m_shiftTraceGhostPicker = nullptr;
+ QCheckBox *m_shiftTraceNoShiftChk = nullptr;
+ ToolPropertyButton *m_shiftTraceNoShiftIconBtn = nullptr;
+ ToolPropertyButton *m_shiftTraceResetShiftIconBtn = nullptr;
+ QPushButton *m_shiftTraceResetPrevBtn = nullptr;
+ QPushButton *m_shiftTraceResetFollowingBtn = nullptr;
+
+ bool m_useSingleMaxSlider; // false = DoublePairField (native double cursor),
+ // true = single slider (max only)
+ bool m_showLabels; // Show/hide property labels
+ bool m_showNumericFields; // Show/hide numeric fields
+ bool m_showBorders; // Show/hide option borders in collapsible menus
+ bool m_showBackgrounds; // Show/hide option backgrounds in collapsible menus
+ bool m_showIcons; // Icon grid replaces collapsible enums when possible
+
public:
ToolPropertiesPanel(QWidget *parent = nullptr);
~ToolPropertiesPanel();
-
+
void reset() override;
-
+
protected:
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;
void contextMenuEvent(QContextMenuEvent *event) override;
-
+
private:
void initializeUI();
void connectSignals();
void disconnectSignals();
-
+
// Tool detection
QString detectCurrentToolId();
QString detectCurrentToolType();
- TTool* getCurrentTool();
-
+ TTool *getCurrentTool();
+ QString displayNameForToolId(const QString &toolId) const;
+
// Properties display
void refreshProperties();
void clearProperties();
+ void showEmptyPropertiesHint(const QString &requestedToolId);
+ int propertyWidgetCount() const;
void updatePropertyValues();
void updateWidgetFromProperty(QWidget *widget);
-
+ void updatePropertyWidgetsIn(QWidget *root);
+ void attachAllPropertySyncListeners();
+
// Brush-specific properties (current implementation)
void createBrushProperties();
void createMyPaintBrushProperties();
@@ -118,40 +232,139 @@ private:
void createModifierLockAlphaProperty();
void createAssistantsProperty();
void createPressureProperty();
-
+
// MyPaint-specific properties (special sliders)
void createMyPaintSizeProperty();
void createMyPaintOpacityProperty();
-
+
+ // Generic property helpers (name-based lookup, no-op if property absent)
+ void createEnumProperty(const QString &label, const std::string &propName,
+ int propGroup = 0,
+ const QString &iconName = QString());
+ void createBoolProperty(const QString &label, const std::string &propName,
+ int propGroup = 0);
+ void createDoublePairByName(const QString &label, const std::string &propName,
+ int propGroup = 0);
+ void createIntSliderByName(const QString &label, const std::string &propName,
+ int propGroup = 0);
+ void createDoubleSliderByName(const QString &label,
+ const std::string &propName, int propGroup = 0);
+
+ // Generic property builder — iterates all TProperty in a group dynamically.
+ bool createGenericProperties(int propGroup = 0,
+ QVBoxLayout *targetLayout = nullptr,
+ bool plasticAlignedFields = false);
+
+ void createEditAssistantsProperties();
+ void createShiftTraceProperties();
+ void updateShiftTraceWidgets();
+
+ // Ruler / Plastic need bespoke layouts (no or multi-mode property groups).
+ void createRulerProperties();
+ void createPlasticProperties();
+ void rebuildPlasticModeSection();
+ void syncPlasticModeFromTool();
+ void createPlasticAnimateModeProperties(PlasticTool *plastic);
+ void createPlasticRigidityModeProperties(PlasticTool *plastic);
+ void updatePlasticRelayFields();
+ void createAnimateProperties();
+ void updateAnimateColumnPicker();
+ void syncAnimateAxisFromTool();
+ void updateAnimateActiveAxisVisibility();
+ void reparentAnimateSectionsToAllMode();
+ void reparentAnimateSectionsToAxisStack();
+ QWidget *createEnumIconGridPanel(
+ const QString &label, TEnumProperty *enumProp,
+ const std::string &propName, int propGroup = 0,
+ QWidget *parentWidget = nullptr,
+ const std::function<void(int)> &onChanged = nullptr);
+
+ // Eraser properties (3 variants: vector / toonz-raster / fullcolor-raster)
+ void createEraserProperties();
+ void updateEraserOptionStates();
+
+ // Fill properties (3 variants: vector / toonz-raster / fullcolor-raster)
+ void createFillProperties();
+
+ // Geometric properties (vector / toonz-raster / fullcolor-raster)
+ void createGeometricProperties();
+
+ // Selection properties
+ void createSelectionProperties();
+
+ // Type (text) tool — Font/Size as dropdown menus (same as TOB)
+ void createTypeProperties();
+ void refreshTypeStyleWidget();
+
// Helper methods
- void createDoublePairSlider(const QString &label, void *prop,
- const std::string &propName);
- void createIntPairSlider(const QString &label, void *prop,
- const std::string &propName);
- QWidget* createSliderWithLabel(const QString &label, int min, int max, int value,
- const std::string &propName);
- QWidget* createDoubleSliderWithLabel(const QString &label, double min, double max,
- double value, const std::string &propName);
- QWidget* createCheckBox(const QString &label, bool checked, const std::string &propName);
- QWidget* createCollapsibleEnum(const QString &label, const QStringList &items,
- int currentIndex, const std::string &propName,
- const QString &iconName = QString());
- QWidget* createCollapsibleEnumWithIcons(const QString &label, const QStringList &items,
- int currentIndex, const std::string &propName,
+ void createDoublePairSlider(const QString &label, void *prop,
+ const std::string &propName, int propGroup = 0);
+ void createIntPairSlider(const QString &label, void *prop,
+ const std::string &propName, int propGroup = 0);
+ QWidget *createSliderWithLabel(const QString &label, int min, int max,
+ int value, const std::string &propName);
+ QWidget *createDoubleSliderWithLabel(const QString &label, double min,
+ double max, double value,
+ const std::string &propName);
+ QWidget *createCheckBox(const QString &label, bool checked,
+ const std::string &propName);
+ QWidget *createTextProperty(const QString &label, TStringProperty *prop,
+ const std::string &propName, int propGroup = 0);
+ QWidget *createCollapsibleEnum(
+ const QString &label, const QStringList &items, int currentIndex,
+ const std::string &propName, const QString &iconName = QString(),
+ const std::function<void(int)> &onChanged = nullptr,
+ bool reserveHeaderRightSlot = false, QWidget *parentWidget = nullptr);
+ QWidget *createCollapsiblePicker(const QString &label,
+ const QStringList &items, int currentIndex,
+ const QString &storageKey,
+ const std::function<void(int)> &onChanged);
+ QWidget *createAnimateColumnPicker(TXsheetHandle *xshHandle,
+ TObjectHandle *objHandle);
+ void syncCollapsiblePicker(QWidget *container, int index);
+ QWidget *createCollapsibleTextField(
+ const QString &label, const QString &textValue,
+ const std::string &storageKey, const std::string &propName, int propGroup,
+ const std::function<void(const QString &)> &onChanged,
+ bool reserveHeaderRightSlot = false);
+ QWidget *createCollapsibleSection(const QString &label,
+ const std::string &storageKey,
+ QWidget *contentWidget,
+ const QString &headerValue = QString(),
+ const QString &iconName = QString());
+ QWidget *createCollapsibleIntSlider(const QString &label, int min, int max,
+ int value, const std::string &propName,
+ int propGroup,
+ const std::string &storageKey,
+ bool reserveHeaderRightSlot = false);
+ QWidget *buildPlasticSkeletonPicker(PlasticTool *plastic);
+ void updatePlasticVertexField();
+ QWidget *createCollapsibleEnumWithIcons(const QString &label,
+ const QStringList &items,
+ int currentIndex,
+ const std::string &propName,
const QStringList &iconNames);
+ QWidget *createCollapsibleEnumForProperty(
+ const QString &label, TEnumProperty *enumProp,
+ const std::string &propName, int propGroup = 0,
+ const QString &headerIconName = QString(),
+ const std::function<void(int)> &onChanged = nullptr,
+ bool reserveHeaderRightSlot = false, QWidget *parentWidget = nullptr);
void addShowHideContextMenu(QMenu *menu);
-
+
// Container stylesheet management for Cells Borders/Backgrounds
void updateContainerStylesheet();
-
+
// Theme-aware style helpers (no hardcoded colors)
QString getButtonStyleChecked() const;
QString getButtonStyleNormal(bool showBorders, bool showBackgrounds) const;
-
+
private slots:
void onToolSwitched();
+ void onSceneContextChanged();
void onToolChanged();
-
+ void onToolComboBoxListChanged(const std::string &id);
+
// Brush property slots
void onSizeChanged(int value);
void onHardnessChanged(int value);
@@ -165,7 +378,9 @@ private slots:
void onAssistantsChanged(bool checked);
void onPressureChanged(bool checked);
void onShowHideActionTriggered();
+ void rebuildPlasticSkeletonPicker();
+ void updatePlasticSkeletonPicker();
+ void onShiftTraceCommandChanged();
};
-#endif // TOOLPROPERTIESPANEL_H
-
+#endif // TOOLPROPERTIESPANEL_H