tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SelectionRect.h
Go to the documentation of this file.
1 // (c) 2017 Alex Nadzharov
2 // License: GPL3
3 
4 #ifndef SELECTIONRECT_H
5 #define SELECTIONRECT_H
6 
7 #include "UIItem.h"
8 
9 #include <QPainter>
10 
11 class QPainter;
12 
13 namespace tilde {
14 
17 class SelectionRect : public UIItem {
18  bool _active;
19  QPoint _start;
20  QPoint _end;
21 
22 public:
23  SelectionRect();
24 
25  void setActive(bool active) { _active = active; }
26  void setStart(QPoint start) { _start = start; }
27  void setEnd(QPoint end) { _end = end; }
28  QPoint end() { return _end; }
29  QPoint start() { return _start; }
30  bool active() { return _active; }
31 
32  void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
33  {
34  if (_active) {
35 
36  painter->setPen(QPen(QColor(128, 128, 128), 1, Qt::DashLine, Qt::SquareCap, Qt::BevelJoin));
37  painter->drawRect(_start.x(), _start.y(), _end.x(), _end.y());
38  }
39  }
40 };
41 }
42 #endif // SELECTIONRECT_H
selection rectangle QGraphicsObject (UIItem)
Definition: SelectionRect.h:17
void setStart(QPoint start)
Definition: SelectionRect.h:26
UIItem QGraphicsObject class.
Definition: UIItem.h:15
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
Definition: SelectionRect.h:32
SelectionRect()
Definition: SelectionRect.cpp:9
QPoint end()
Definition: SelectionRect.h:28
void setActive(bool active)
Definition: SelectionRect.h:25
bool active()
Definition: SelectionRect.h:30
QPoint start()
Definition: SelectionRect.h:29
void setEnd(QPoint end)
Definition: SelectionRect.h:27