-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.h
More file actions
74 lines (58 loc) · 1.82 KB
/
link.h
File metadata and controls
74 lines (58 loc) · 1.82 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef LINK_H
#define LINK_H
#include <QtGui>
#include <maxmodel/model.h>
#include "entry.h"
class Link
{
public:
Link(const model_link_t *link, Entry::Handle *out, Entry::Handle *in) :
link(link), out(out), in(in)
{
}
const model_link_t *getLink() const { return link; }
Entry::Handle *getOutput() const { return out; }
Entry::Handle *getInput() const { return in; }
class Handle : public QGraphicsItem
{
public:
Handle(Link *link) :
QGraphicsItem(), link(link)
{
setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable);
}
Link *getLink() const { return link; }
QRectF boundingRect() const { return QRectF(-7, 0, 14, 20); }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
Q_UNUSED(option);
Q_UNUSED(widget);
QPainterPath bg;
bg.addRect(boundingRect());
painter->save();
{
painter->setRenderHints(QPainter::Antialiasing);
painter->fillPath(bg, QBrush(hasFocus()? Qt::black : QColor(0x8370FA)));
//painter->setPen(QPen(Qt::black));
//painter->setFont(QFont("sans-serif", 10, QFont::Normal));
//painter->drawText(boundingRect(), Qt::AlignCenter, QString(entry->getSig()));
}
painter->restore();
}
private:
Link *link;
};
Handle *makeHandle() { return new Handle(this); }
bool operator ==(const Link &other) const
{
return getLink() == other.getLink();
}
bool operator !=(const Link &other) const
{
return !(*this == other);
}
private:
const model_link_t *link;
Entry::Handle *out, *in;
};
#endif // LINK_H