forked from PeterS242/YARRH
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathheadcontrolline.cpp
47 lines (40 loc) · 1.21 KB
/
headcontrolline.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "headcontrolline.h"
HeadControlLine::HeadControlLine(QPoint p1)
{
this->p1=p1;
this->hovered=false;
this->showPoint = true;
this->setAcceptHoverEvents(true);
}
QRectF HeadControlLine::boundingRect() const{
return QRectF(p1.x()-2,p1.y()-2,8,8);
}
void HeadControlLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
if(this->showPoint){
if(this->hovered){
painter->setPen(QColor(200,100,100));
painter->setBrush(QColor(200,100,100));
}
else{
painter->setPen(QColor(179,179,179));
painter->setBrush(QColor(179,179,179));
}
painter->drawRoundedRect(QRectF(p1,QSize(4,4)),2,2);
}
}
void HeadControlLine::mousePressEvent(QGraphicsSceneMouseEvent *event){
emit clicked(p1);
}
void HeadControlLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event){
hovered=true;
emit isHovered(p1);
this->update(this->boundingRect());
}
void HeadControlLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
hovered=false;
this->update(this->boundingRect());
}
void HeadControlLine::setShow(bool show){
this->showPoint=show;
this->update(this->boundingRect());
}