Skip to content

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

C

#assistants: fix hovering in editor

Ivan Mahoninbae79a7b822a
diff --git a/toonz/sources/tnztools/editassistantstool.cpp b/toonz/sources/tnztools/editassistantstool.cpp
index a6a0b47f6..25299d937 100644
--- a/toonz/sources/tnztools/editassistantstool.cpp
+++ b/toonz/sources/tnztools/editassistantstool.cpp
@@ -11,6 +11,8 @@
#include <toonz/tapplication.h>
#include <toonz/txshlevelhandle.h>
#include <toonz/txsheethandle.h>
+#include <toonz/tframehandle.h>
+#include <toonz/dpiscale.h>
// TnzCore includes
#include <tgl.h>
@@ -579,9 +581,16 @@ public:
m_dragging = false;
}
+ void mouseMove(const TPointD &position, const TMouseEvent&) override {
+ m_currentPosition = position;
+ m_currentPointOffset = TPointD();
+ getViewer()->GLInvalidateAll();
+ }
+
void draw() override {
m_currentGuidelines.clear();
-
+ TPointD position = m_currentPosition + m_currentPointOffset;
+
// draw assistants
if (Closer closer = read(ModeImage))
for(TMetaObjectListCW::iterator i = (*m_reader)->begin(); i != (*m_reader)->end(); ++i)
@@ -594,6 +603,48 @@ public:
TAffine(),
m_currentGuidelines );
}
+
+ // draw assistans from other layers
+ TImage *currentImage = getImage(false);
+ if (TToolViewer *viewer = getViewer())
+ if (TApplication *application = getApplication())
+ if (TXshLevelHandle *levelHandle = application->getCurrentLevel())
+ if (TXshLevel *level = levelHandle->getLevel())
+ if (TXshSimpleLevel *simpleLevel = level->getSimpleLevel())
+ if (TFrameHandle *frameHandle = application->getCurrentFrame())
+ if (TXsheetHandle *XsheetHandle = application->getCurrentXsheet())
+ if (TXsheet *Xsheet = XsheetHandle->getXsheet())
+ {
+ TPointD dpiScale = getCurrentDpiScale(simpleLevel, getCurrentFid());
+ int frame = frameHandle->getFrame();
+ int count = Xsheet->getColumnCount();
+ TAffine worldToTrack;
+ worldToTrack.a11 /= dpiScale.x;
+ worldToTrack.a22 /= dpiScale.y;
+
+ for(int i = 0; i < count; ++i)
+ if (TXshColumn *column = Xsheet->getColumn(i))
+ if (column->isCamstandVisible())
+ if (column->isPreviewVisible())
+ if (TImageP image = Xsheet->getCell(frame, i).getImage(false))
+ if (image->getType() == TImage::META)
+ if (image != currentImage)
+ if (TMetaImage *metaImage = dynamic_cast<TMetaImage*>(image.getPointer()))
+ {
+ TAffine imageToTrack = worldToTrack * getColumnMatrix(i);
+ glPushMatrix(); tglMultMatrix(imageToTrack);
+
+ TMetaImage::Reader reader(*metaImage);
+ for(TMetaObjectListCW::iterator i = reader->begin(); i != reader->end(); ++i)
+ if (*i)
+ if (const TAssistant *assistant = (*i)->getHandler<TAssistant>()) {
+ assistant->getGuidelines(position, imageToTrack, m_currentGuidelines);
+ assistant->draw(viewer, false);
+ }
+
+ glPopMatrix();
+ }
+ }
// draw guidelines
for(TGuidelineList::const_iterator i = m_currentGuidelines.begin(); i != m_currentGuidelines.end(); ++i)