OpenToonz - An open-source full-featured 2D animation creation software
C
Relax animate tool handle size minimum
Rodney7a6391d1960b
diff --git a/toonz/sources/include/toonzqt/intfield.h b/toonz/sources/include/toonzqt/intfield.hindex f18125f70..1329d7dae 100644--- a/toonz/sources/include/toonzqt/intfield.h+++ b/toonz/sources/include/toonzqt/intfield.h@@ -184,6 +184,9 @@ public:\sa getRange() */void setRange(int minValue, int maxValue);+ // Set the numeric entry range independently of the slider range.+ void setInputRange(int minValue, int maxValue);+/*! Set \b minValue and \b maxValue to IntField range.\sa setRange() */void getRange(int &minValue, int &maxValue);diff --git a/toonz/sources/tnztools/edittool.cpp b/toonz/sources/tnztools/edittool.cppindex 47f47580e..5354f0529 100644--- a/toonz/sources/tnztools/edittool.cpp+++ b/toonz/sources/tnztools/edittool.cpp@@ -28,6 +28,8 @@#include "edittoolgadgets.h"+#include <algorithm>+// For Qt translation support#include <QCoreApplication>@@ -70,6 +72,9 @@ namespace {using EditToolGadgets::DragTool;+// Keep fixed-size labels visible until the handle drops below 5%.+constexpr double MinTextVisibilityScale = 0.05;+//=============================================================================// DragCenterTool//-----------------------------------------------------------------------------@@ -1172,6 +1177,7 @@ void EditTool::drawMainHandle() {const TPixel32 normalColor = Preferences::instance()->getAnimateToolColor();const TPixel32 highlightedColor = TPixel32(150, 255, 140);const double prefScale = Preferences::instance()->getAnimateToolHandleSize();+ const bool showText = prefScale >= MinTextVisibilityScale;// collect informationTXsheet *xsh = getXsheet();@@ -1190,9 +1196,11 @@ void EditTool::drawMainHandle() {// so in the system of ref. of the gadget the center is always in the origincenter = TPointD();- // SINGLE DEFINITION OF UNIT (including prefScale)- double unit = sqrt(tglGetPixelSize2()) * devPixRatio * prefScale;- bool dragging = m_dragTool != 0;+ // Keep text at a DPI-aware screen size while the handle scales.+ const double textUnit = sqrt(tglGetPixelSize2()) * devPixRatio;+ const double unit = textUnit * prefScale;+ const double labelUnit = std::max(unit, textUnit);+ bool dragging = m_dragTool != 0;// draw centertglColor(m_highlightedDevice == Center ? highlightedColor : normalColor);@@ -1202,26 +1210,28 @@ void EditTool::drawMainHandle() {else {tglDrawCircle(center, unit * 10);tglDrawCircle(center, unit * 8);- if (m_highlightedDevice == Center && !dragging)- drawText(center + TPointD(4 * unit, 0), unit, "Move center");+ if (showText && m_highlightedDevice == Center && !dragging)+ drawText(center + TPointD(4 * labelUnit, 0), textUnit, "Move center");}glPopName();// draw label (column/pegbar name; possibly camera icon)tglColor(normalColor);- glPushMatrix();- glTranslated(center.x + unit * 10, center.y - unit * 20, 0);-- if (objId.isColumn() || objId.isPegbar()) {+ if (showText && (objId.isColumn() || objId.isPegbar())) {+ glPushMatrix();+ glTranslated(center.x + labelUnit * 10, center.y - labelUnit * 20, 0);TStageObject *pegbar = xsh->getStageObject(objId);std::string name = pegbar->getFullName();- glScaled(unit * 2, unit * 1.5, 1);+ glScaled(textUnit * 2, textUnit * 1.5, 1);tglDrawText(TPointD(0, 0), name);+ glPopMatrix();} else if (objId.isCamera()) {+ glPushMatrix();+ glTranslated(center.x + unit * 10, center.y - unit * 20, 0);glScaled(unit, unit, 1);drawCameraIcon();+ glPopMatrix();}- glPopMatrix();// draw rotation handleconst double delta = 30;@@ -1233,8 +1243,8 @@ void EditTool::drawMainHandle() {elsetglDrawDisk(p, unit * 5);glPopName();- if (m_highlightedDevice == Rotation && !dragging && !isPicking())- drawText(p, unit, "Rotate");+ if (showText && m_highlightedDevice == Rotation && !dragging && !isPicking())+ drawText(p, textUnit, "Rotate");tglColor(normalColor);tglDrawSegment(p, center);@@ -1254,9 +1264,9 @@ void EditTool::drawMainHandle() {elsetglDrawRect(p.x - r, p.y - r, p.x + r, p.y + r);glPopName();- TPointD scaleTooltipPos = p + unit * TPointD(-16, -16);- if (m_highlightedDevice == Scale && !dragging && !isPicking())- drawText(scaleTooltipPos, unit, "Scale");+ TPointD scaleTooltipPos = p + labelUnit * TPointD(-16, -16);+ if (showText && m_highlightedDevice == Scale && !dragging && !isPicking())+ drawText(scaleTooltipPos, textUnit, "Scale");tglColor(normalColor);tglDrawSegment(p, center);@@ -1274,8 +1284,8 @@ void EditTool::drawMainHandle() {elsetglDrawRect(q.x - r, q.y - r, q.x + r, q.y + r);glPopName();- if (m_highlightedDevice == ScaleXY && !dragging && !isPicking())- drawText(scaleTooltipPos, unit, "Horizontal/Vertical scale");+ if (showText && m_highlightedDevice == ScaleXY && !dragging && !isPicking())+ drawText(scaleTooltipPos, textUnit, "Horizontal/Vertical scale");// draw shear handlep = center + m_currentScaleFactor * unit * delta * TPointD(1, -1);@@ -1299,8 +1309,8 @@ void EditTool::drawMainHandle() {glEnd();}glPopName();- if (m_highlightedDevice == Shear && !dragging)- drawText(p + TPointD(0, -unit * 10), unit, "Shear");+ if (showText && m_highlightedDevice == Shear && !dragging)+ drawText(p + TPointD(0, -labelUnit * 10), textUnit, "Shear");tglColor(normalColor);tglDrawSegment(p, center);@@ -1340,6 +1350,7 @@ void EditTool::draw() {const TPixel32 normalColor = Preferences::instance()->getAnimateToolColor();const TPixel32 highlightedColor = TPixel32(150, 255, 140);const double prefScale = Preferences::instance()->getAnimateToolHandleSize();+ const bool showText = prefScale >= MinTextVisibilityScale;TXsheet *xsh = getXsheet();/*-- Obtain ID of the current editing stage object --*/@@ -1373,8 +1384,10 @@ void EditTool::draw() {return;}- // SINGLE DEFINITION OF UNIT- double unit = getPixelSize() * prefScale;+ // Keep text at a DPI-aware screen size while the handle scales.+ const double textUnit = getPixelSize();+ const double unit = textUnit * prefScale;+ const double labelUnit = std::max(unit, textUnit);/*-- Obtain object's center position --*/glPushMatrix();@@ -1403,11 +1416,12 @@ void EditTool::draw() {tglMultMatrix(parentAff.inv() * aff * TTranslation(center));glScaled(unit, unit, 1);tglColor(normalColor);+ const int crossHairRadius = 100;glBegin(GL_LINES); // GL_LINE_STRIP to GL_LINES for continuous axes- glVertex2i(-800, 0);- glVertex2i(800, 0);- glVertex2i(0, -100);- glVertex2i(0, 100);+ glVertex2i(-crossHairRadius, 0);+ glVertex2i(crossHairRadius, 0);+ glVertex2i(0, -crossHairRadius);+ glVertex2i(0, crossHairRadius);glEnd();glPopMatrix();}@@ -1433,24 +1447,30 @@ void EditTool::draw() {// draw label (column/pegbar name; possibly camera icon)tglColor(normalColor);- glPushMatrix();- glTranslated(center.x + unit * 10, center.y - unit * 20, 0);/*-- Object name --*/TStageObject *pegbar = xsh->getStageObject(objId);std::string name = pegbar->getFullName();- if (objId.isColumn() || objId.isPegbar() || objId.isTable()) {- glScaled(unit * 2, unit * 1.5, 1);+ if (showText && (objId.isColumn() || objId.isPegbar() || objId.isTable())) {+ glPushMatrix();+ glTranslated(center.x + labelUnit * 10, center.y - labelUnit * 20, 0);+ glScaled(textUnit * 2, textUnit * 1.5, 1);tglDrawText(TPointD(0, 0), name);+ glPopMatrix();} else if (objId.isCamera()) {+ if (showText) {+ glPushMatrix();+ glTranslated(center.x + labelUnit * 10, center.y - labelUnit * 20, 0);+ glScaled(textUnit * 2, textUnit * 1.5, 1);+ tglDrawText(TPointD(12 * labelUnit / textUnit, 0), name);+ glPopMatrix();+ }glPushMatrix();- glScaled(unit * 2, unit * 1.5, 1);- tglDrawText(TPointD(12, 0), name);- glPopMatrix();+ glTranslated(center.x + unit * 10, center.y - unit * 20, 0);glScaled(unit, unit, 1);drawCameraIcon();+ glPopMatrix();}- glPopMatrix();/*--- When editing non-active camera, draw its camera frame ---*/if (objId.isCamera()) {diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex c3ea3aa46..3815ec251 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -2275,6 +2275,7 @@ QWidget* PreferencesPopup::createToolsPage() {// Use IntField to display 100% instead of 1.0IntField* handleSizeSlider = new IntField(this);handleSizeSlider->setRange(100, 600); // scale range: 100% to 600%+ handleSizeSlider->setInputRange(1, 600);// Get the decimal value (e.g., 1.0) and multiply by 100 for the sliderdouble currentVal = Preferences::instance()->getAnimateToolHandleSize();diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cppindex 46a6fe719..8d4d2e2cf 100644--- a/toonz/sources/toonzlib/preferences.cpp+++ b/toonz/sources/toonzlib/preferences.cpp@@ -574,7 +574,7 @@ void Preferences::definePreferenceItems() {define(tempToolSwitchTimer, "tempToolSwitchTimer", QMetaType::Int, 500, 1,std::numeric_limits<int>::max());define(animateToolHandleSize, "animateToolHandleSize", QMetaType::Double, 1.0,- 1.0, 5.0);+ 0.01, 6.0);define(animateToolColor, "animateToolColor", QMetaType::QColor,QColor(250, 127, 240));// The Preferences dialog updates both keys together. Advanced users may setdiff --git a/toonz/sources/toonzqt/intfield.cpp b/toonz/sources/toonzqt/intfield.cppindex 467193996..21994c46b 100644--- a/toonz/sources/toonzqt/intfield.cpp+++ b/toonz/sources/toonzqt/intfield.cpp@@ -11,6 +11,7 @@#include <QFocusEvent>#include <QPainter>#include <QPushButton>+#include <QSignalBlocker>namespace {const int NonLinearSliderPrecision = 2;@@ -360,9 +361,17 @@ void IntField::setRange(int minValue, int maxValue) {//-----------------------------------------------------------------------------+void IntField::setInputRange(int minValue, int maxValue) {+ m_lineEdit->setRange(minValue, maxValue);+ m_roller->setRange(minValue, maxValue);+}++//-----------------------------------------------------------------------------+void IntField::setValue(int value) {if (m_lineEdit->getValue() == value) return;m_lineEdit->setValue(value);+ const QSignalBlocker blocker(m_slider);m_slider->setSliderPosition(value2pos(value));m_roller->setValue((double)value);}@@ -521,6 +530,7 @@ void IntField::onEditingFinished() {if ((pos2value(m_slider->value()) == value && m_slider->isVisible()) ||((int)m_roller->getValue() == value && m_roller->isVisible()))return;+ const QSignalBlocker blocker(m_slider);m_slider->setValue(value2pos(value));m_roller->setValue((double)value);emit valueChanged(false);