18 #include "OOPDHeaders.h"
20 #include <QGraphicsView>
35 class UIProperty :
public UIBox {
42 QString _abstractionPath;
47 std::string _propertyName;
50 explicit UIProperty();
53 static UIObject* createObject(QString asQString,
t_canvas* pdCanvas, QGraphicsView* parent = 0);
58 virtual void paint(QPainter* p,
const QStyleOptionGraphicsItem*, QWidget*)
60 QBrush brush(bgColor());
62 p->drawRect(boundingRect());
63 p->setBrush(QBrush());
65 p->setRenderHint(QPainter::HighQualityAntialiasing,
true);
66 p->scale(scale(), scale());
69 if (subpatchController()) {
70 p->setPen(QPen(QColor(192, 192, 192), 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
71 p->drawRect(0, 2, width(), height() - 4);
74 QColor rectColor = (errorBox()) ? QColor(255, 0, 0) : properties()->get(
"BorderColor")->asQColor();
75 p->setPen(QPen(rectColor, 1 + _isAbstraction, (errorBox()) ? Qt::DashLine : Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
76 p->drawRect(0, 0, width(), height());
77 QTextOption* op =
new QTextOption;
78 op->setAlignment(Qt::AlignLeft);
79 p->setPen(QPen(QColor(0, 0, 0), 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
81 p->setFont(QFont(
PREF_QSTRING(
"Font"), properties()->
get(
"FontSize")->asFontSize(), 0,
false));
82 p->drawText(2, 3, width() - 2, height() - 3, 0, objectData()->toQString(), 0);
85 p->setPen(QPen(QColor(0, 192, 255), 1, (errorBox()) ? Qt::DashLine : Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin));
86 p->drawRect(0, 0, width(), height());
94 void mousePressEvent(QGraphicsSceneMouseEvent* ev)
97 if (ev->button() == Qt::RightButton) {
100 && !scene()->views().isEmpty()
101 && scene()->views().first()
102 && scene()->views().first()->viewport()) {
104 QGraphicsView* v = scene()->views().first();
105 QPoint pos = v->viewport()->mapToGlobal(ev->pos().toPoint());
108 showPopupMenu(pos + this->pos().toPoint());
117 if (subpatchController()) {
118 subpatchController()->mainWindow()->show();
122 if ((getEditMode() ==
em_Unlocked) && isSelected()) {
124 emit signalEditObject(
this);
128 emit selectBox(
this, ev);
129 dragOffset = ev->pos().toPoint();
135 void mouseReleaseEvent(QGraphicsSceneMouseEvent*) {}
141 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
143 if (event->buttons() & Qt::LeftButton) {
144 emit moveBox(
this, event);
148 if ((getEditMode() !=
em_Unlocked) && (subpatchController())) {
149 setCursor(QCursor(Qt::PointingHandCursor));
151 setCursor(QCursor(Qt::ArrowCursor));
155 void setPdMessage(QString message)
175 static void updateUI(
void* uiobj, PdArguments msg)
223 void updateUISignal();
#define t_canvas
Definition: m_pd.h:205
Definition: CommonTypes.h:14
#define PREF_QSTRING(x)
Definition: Preferences.h:17
Definition: oop_common.h:352
Definition: oop_common.h:81