Vuo  2.4.0
VuoRendererComment.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include "VuoBaseDetail.hh"
13#include "VuoHeap.h"
14#include "VuoRendererColors.hh"
15#include "VuoRendererItem.hh"
16
18class VuoComment;
19
23class VuoRendererComment : public VuoRendererItem, public VuoBaseDetail<VuoComment>
24{
25public:
27
28 QRectF boundingRect(void) const;
29 QPainterPath shape(void) const;
30 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
31
32 QVariant itemChange(GraphicsItemChange change, const QVariant &value);
33 void updateGeometry(void);
34 void updateColor(void);
35
36 void setContent(string content);
37 void setBodySelectable(bool bodySelectable);
38
39protected:
40 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) VuoWarnUnusedResult;
41 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
42 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
43 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
44 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
45 void mousePressEvent(QGraphicsSceneMouseEvent *event);
46 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
47 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
48
50
51private:
52 // Drawing configuration
53 static const qreal cornerRadius;
54 static const qreal borderWidth;
55 static const qreal textMargin;
56
57 QRectF frameRect;
58 QPainterPath commentFrame;
59 QGraphicsTextItem *textItem;
60
61 bool resizeDragInProgress;
62 QPointF resizeDeltaIgnored;
63 bool dragHandleHovered;
64 bool titleHandleHovered;
65 bool bodySelectable;
66
67 // Internal methods
68 void updateFrameRect(void);
69 QPainterPath getCommentFrame(QRectF frameRect) const;
70 QPainterPath getTitleHandlePath(QRectF frameRect) const;
71 QPainterPath getDragHandlePath(QRectF frameRect) const;
72 QRectF extendedTitleHandleBoundingRect(void) const;
73 QRectF extendedDragHandleBoundingRect(void) const;
74
75 bool titleHandleActiveForEventPos(QPointF pos);
76 bool titleHandleHoveredForEventPos(QPointF pos);
77 bool dragHandleHoveredForEventPos(QPointF pos);
78
79 void updateFormattedCommentText();
80 QString generateTextStyleString();
81
82 void drawCommentFrame(QPainter *painter, VuoRendererColors *colors) const;
83 void drawTextContent(QPainter *painter) const;
84 void drawTitleHandle(QPainter *painter, VuoRendererColors *colors) const;
85 void drawDragHandle(QPainter *painter, VuoRendererColors *colors) const;
86};
87