forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionState.hpp
More file actions
66 lines (45 loc) · 1.36 KB
/
ConnectionState.hpp
File metadata and controls
66 lines (45 loc) · 1.36 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
#pragma once
#include <QtCore/QUuid>
#include "Export.hpp"
#include "Definitions.hpp"
class QPointF;
namespace QtNodes {
class ConnectionGraphicsObject;
/// Stores currently draggind end.
/// Remembers last hovered Node.
class NODE_EDITOR_PUBLIC ConnectionState
{
public:
/// Defines whether we construct a new connection
/// or it is already binding two nodes.
enum LooseEnd { Pending = 0, Connected = 1 };
public:
ConnectionState(ConnectionGraphicsObject &cgo)
: _cgo(cgo)
, _hovered(false)
, _frozen(false)
{}
ConnectionState(ConnectionState const &) = delete;
ConnectionState(ConnectionState &&) = delete;
ConnectionState &operator=(ConnectionState const &) = delete;
ConnectionState &operator=(ConnectionState &&) = delete;
~ConnectionState();
public:
PortType requiredPort() const;
bool requiresPort() const;
bool hovered() const;
void setHovered(bool hovered);
bool frozen() const { return _frozen; }
void setFrozen(bool frozen) { _frozen = frozen; }
public:
/// Caches NodeId for further interaction.
void setLastHoveredNode(NodeId const nodeId);
NodeId lastHoveredNode() const;
void resetLastHoveredNode();
private:
ConnectionGraphicsObject &_cgo;
bool _hovered;
NodeId _lastHoveredNode{InvalidNodeId};
bool _frozen;
};
} // namespace QtNodes