Skui 0.0.1
Build fast and easy to use control software with Skui.
 
Loading...
Searching...
No Matches
pad.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <QCursor>
4#include <QGraphicsObject>
5#include <QGraphicsSceneMouseEvent>
6#include <QPainter>
7
9
10static const int LINE_WIDTH = 3;
11static const int PAD_SIZE = 10;
12static const int PAD_EXPANDED = 12;
13static const int LINE_LENGTH = 10;
14
15enum class PadSide { Left, Right };
16
17class Pad : public QGraphicsObject
18{
19 Q_OBJECT
20
21public:
22 static const int Type = QGraphicsItem::UserType + 1;
23
24 explicit Pad(QGraphicsItem *parent = nullptr,
25 Interface *interface = nullptr,
26 const PadSide pad_side = PadSide::Left);
27
35 QPoint getSceneDockPoint() const;
36
48 void setHover(bool hover);
49
50 inline PadSide getSide() const { return m_pad_side; }
51 inline Interface *getInterface() const { return m_represented_interface; }
52 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
53 QRectF boundingRect() const override;
54 int type() const override { return Type; }
55
56signals:
58
59protected:
60 QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
61 void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
62 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
63
64private:
65 bool m_hover = false;
66 const PadSide m_pad_side;
67 Interface *m_represented_interface;
68};
Definition interface.hpp:9
void setHover(bool hover)
Sets the hover state.
Definition pad.cpp:33
QPoint getSceneDockPoint() const
Get position for the cable to dock to.
Definition pad.cpp:16
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
Definition pad.cpp:43
PadSide getSide() const
Definition pad.hpp:50
void positionChanged()
static const int Type
Definition pad.hpp:22
int type() const override
Definition pad.hpp:54
QRectF boundingRect() const override
Definition pad.cpp:76
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override
Definition pad.cpp:89
Interface * getInterface() const
Definition pad.hpp:51
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Definition pad.cpp:94
Pad(QGraphicsItem *parent=nullptr, Interface *interface=nullptr, const PadSide pad_side=PadSide::Left)
Definition pad.cpp:3
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override
Definition pad.cpp:84
PadSide
Definition pad.hpp:15
@ Right
Definition pad.hpp:15
@ Left
Definition pad.hpp:15