OpenToonz - An open-source full-featured 2D animation creation software
C
fix viewer gadgets
shun_iwasawa1fbdc97128a3
diff --git a/toonz/sources/include/tools/toolutils.h b/toonz/sources/include/tools/toolutils.hindex d196f86ae..c17fad7fc 100644--- a/toonz/sources/include/tools/toolutils.h+++ b/toonz/sources/include/tools/toolutils.h@@ -128,7 +128,7 @@ void drawBalloon(std::string text, // balloon textconst TPixel32 &color, // ballon background color (text is black)TPoint delta, // text position (pixels; pos is the origin; y grows upward)- bool isPicking = false,+ double pixelSize, bool isPicking = false,std::vector<TRectD> *otherBalloons =0); // avoid other balloons positions; add the new ballons positionsdiff --git a/toonz/sources/tnztools/edittool.cpp b/toonz/sources/tnztools/edittool.cppindex 1f5749cab..38dd0cb97 100644--- a/toonz/sources/tnztools/edittool.cpp+++ b/toonz/sources/tnztools/edittool.cpp@@ -30,6 +30,8 @@#include <QCoreApplication>#include <QDebug>+#include <QApplication>+#include <QDesktopWidget>//=============================================================================// Scale Constraints@@ -290,12 +292,13 @@ class DragSplinePositionTool final : public DragChannelTool {double m_tolerance;public:- DragSplinePositionTool(const TStroke *spline, bool globalKeyframesEnabled)+ DragSplinePositionTool(const TStroke *spline, bool globalKeyframesEnabled,+ double pixelSize): DragChannelTool(TStageObject::T_Path, globalKeyframesEnabled), m_spline(spline), m_offset(0.0), m_splineLength(0)- , m_tolerance(0) {}+ , m_tolerance(pixelSize * 10.0) {}double getLengthAtPos(const TPointD &pos) const {assert(m_spline);@@ -322,7 +325,6 @@ else return 0.0;m_firstPos = pos;start();assert(m_spline);- m_tolerance = sqrt(tglGetPixelSize2()) * 10;m_splineLength = m_spline->getLength();m_lengthAtCPs.clear();int n = m_spline->getControlPointCount();@@ -929,8 +931,8 @@ void EditTool::leftButtonDown(const TPointD &ppos, const TMouseEvent &e) {case Translation:if (const TStroke *spline = getSpline())- m_dragTool =- new DragSplinePositionTool(spline, m_globalKeyframes.getValue());+ m_dragTool = new DragSplinePositionTool(+ spline, m_globalKeyframes.getValue(), getPixelSize());elsem_dragTool = new DragPositionTool(m_lockPositionX.getValue(),m_lockPositionY.getValue(),@@ -1157,7 +1159,7 @@ void EditTool::draw() {return;}- double unit = sqrt(tglGetPixelSize2());+ double unit = getPixelSize();/*-- ObjectのCenter位置を取得 --*/glPushMatrix();diff --git a/toonz/sources/tnztools/edittoolgadgets.cpp b/toonz/sources/tnztools/edittoolgadgets.cppindex b3a545c7b..1effcb599 100644--- a/toonz/sources/tnztools/edittoolgadgets.cpp+++ b/toonz/sources/tnztools/edittoolgadgets.cpp@@ -19,10 +19,20 @@#include "historytypes.h"+#include <QApplication>+#include <QDesktopWidget>+using namespace EditToolGadgets;GLdouble FxGadget::m_selectedColor[3] = {0.2, 0.8, 0.1};+namespace {+int getDevPixRatio() {+ static int devPixRatio = QApplication::desktop()->devicePixelRatio();+ return devPixRatio;+}+}+//*************************************************************************************// FxGadgetUndo definition//*************************************************************************************@@ -172,13 +182,15 @@ void FxGadget::setValue(const TPointParamP ¶m, const TPointD &pos) {//----------------------------------------------------------------------------void FxGadget::setPixelSize() { setPixelSize(sqrt(tglGetPixelSize2())); }+void FxGadget::setPixelSize() {+ setPixelSize(sqrt(tglGetPixelSize2()) * getDevPixRatio());+}//---------------------------------------------------------------------------void FxGadget::drawTooltip(const TPointD &tooltipPos,std::string tooltipPosText) {- double unit = sqrt(tglGetPixelSize2());+ double unit = sqrt(tglGetPixelSize2()) * getDevPixRatio();glPushMatrix();glTranslated(tooltipPos.x, tooltipPos.y, 0.0);double sc = unit * 1.6;@@ -482,7 +494,7 @@ void AngleFxGadget::draw(bool picking) {elseglColor3d(0, 0, 1);glPushName(getId());- double pixelSize = sqrt(tglGetPixelSize2());+ double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();double r = pixelSize * 40;double a = pixelSize * 10, b = pixelSize * 5;tglDrawCircle(m_pos, r);diff --git a/toonz/sources/tnztools/skeletontool.cpp b/toonz/sources/tnztools/skeletontool.cppindex 3f425c9a3..43949a76d 100644--- a/toonz/sources/tnztools/skeletontool.cpp+++ b/toonz/sources/tnztools/skeletontool.cpp@@ -1096,8 +1096,8 @@ qDebug("color = TPixel32(200, 200, 10, 200);else if (code == m_device)color = TPixel32(185, 255, 255);- ToolUtils::drawBalloon(pos, hook.m_name, color, TPoint(20, 20), isPicking(),- &balloons);+ ToolUtils::drawBalloon(pos, hook.m_name, color, TPoint(20, 20),+ getPixelSize(), isPicking(), &balloons);glPopName();}@@ -1202,7 +1202,8 @@ glPopMatrix();255 * (191 - ialfa) / alfa, alfa);ToolUtils::drawBalloon(otherColumnsHooks[j].m_pos,otherColumnsHooks[j].m_name, // getHandle(),- color, TPoint(20, 20), false, &balloons);+ color, TPoint(20, 20), getPixelSize(), false,+ &balloons);HookData baseHook = currentColumnHooks[0];baseHook.m_pos = otherColumnsHooks[j].m_pos;@@ -1228,7 +1229,7 @@ glPopMatrix();TPixel32 color(100, 255, 100, 100);if (code == m_device) color = TPixel32(185, 255, 255);ToolUtils::drawBalloon(magicLink.m_h0.m_pos, name, color, TPoint(20, -20),- isPicking(), &balloons);+ getPixelSize(), isPicking(), &balloons);glPopName();}}@@ -1416,7 +1417,7 @@ void SkeletonTool::draw() {if (m_label != "")ToolUtils::drawBalloon(m_labelPos, m_label, TPixel32::Red, TPoint(20, -20),- false);+ getPixelSize(), false);bool ikEnabled = m_mode.getValue() == INVERSE_KINEMATICS;assert(glGetError() == GL_NO_ERROR);diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cppindex 3717d9677..f77ed0d2c 100644--- a/toonz/sources/tnztools/toolutils.cpp+++ b/toonz/sources/tnztools/toolutils.cpp@@ -1479,10 +1479,12 @@ const double ToolUtils::ConeSubVolume::m_values[] = {//---------------------------------------------------------------------------------------------void ToolUtils::drawBalloon(const TPointD &pos, std::string text,- const TPixel32 &color, TPoint delta, bool isPicking,+ const TPixel32 &color, TPoint delta,+ double pixelSize, bool isPicking,std::vector<TRectD> *otherBalloons) {QString qText = QString::fromStdString(text);- QFont font("Arial", 10); // ,QFont::Bold);+ QFont font("Arial"); // ,QFont::Bold);+ font.setPixelSize(13);QFontMetrics fm(font);QRect textRect = fm.boundingRect(qText);@@ -1491,7 +1493,6 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,// avoid other balloonsif (otherBalloons) {- double pixelSize = sqrt(tglGetPixelSize2());std::vector<TRectD> &balloons = *otherBalloons;int n = (int)balloons.size();TDimensionD balloonSize(pixelSize * (textRect.width() + mrg * 2),@@ -1517,7 +1518,6 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,int y0 = textRect.top() - mrg;int y1 = textRect.bottom() + mrg;- double pixelSize = sqrt(tglGetPixelSize2());if (isPicking) {TTool::Viewer *viewer =TTool::getApplication()->getCurrentTool()->getTool()->getViewer();diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cppindex 714d804eb..9016ac680 100644--- a/toonz/sources/toonz/sceneviewer.cpp+++ b/toonz/sources/toonz/sceneviewer.cpp@@ -1254,7 +1254,7 @@ void SceneViewer::drawOverlay() {else {glPushMatrix();tglMultMatrix(m_drawCameraAff);- m_pixelSize = sqrt(tglGetPixelSize2());+ m_pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();ViewerDraw::drawCamera(f, m_pixelSize);glPopMatrix();}@@ -1352,7 +1352,7 @@ void SceneViewer::drawOverlay() {if (tool->getToolType() & TTool::LevelTool &&!app->getCurrentObject()->isSpline())glScaled(m_dpiScale.x, m_dpiScale.y, 1);- m_pixelSize = sqrt(tglGetPixelSize2());+ m_pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();tool->draw();glPopMatrix();// Used (only in the T_RGBPicker tool) to notify and set the currentColor