-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now Controls Can Be Moved from the Blackboard as well
- Loading branch information
Showing
10 changed files
with
312 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "connector.h" | ||
|
||
Connector::Connector() | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef CONNECTOR_H | ||
#define CONNECTOR_H | ||
|
||
#include<QPoint> | ||
#include<QColor> | ||
|
||
class Connector | ||
{ | ||
public: | ||
Connector(); | ||
QPoint from; | ||
QPoint to; | ||
QColor lineColor; | ||
float lineWidth=2.5f; | ||
}; | ||
|
||
#endif // CONNECTOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
#include "nodecore.h" | ||
|
||
NodeCore::NodeCore() | ||
{ | ||
setAcceptedMouseButtons(Qt::AllButtons); | ||
} | ||
|
||
void NodeCore::setBackgroundColor(const QColor color) | ||
{ | ||
if(color==m_backgroundColor) | ||
return; | ||
else | ||
{ | ||
m_backgroundColor=color; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setHighlightColor(const QColor color) | ||
{ | ||
if(color==m_highlightColor) | ||
return; | ||
else | ||
{ | ||
m_highlightColor=color; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setPanelColor(const QColor color) | ||
{ | ||
if(color==m_panelColor) | ||
return; | ||
else | ||
{ | ||
m_panelColor=color; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setPanelGradColor(const QColor color) | ||
{ | ||
if(color==m_panelGradColor) | ||
return; | ||
else | ||
{ | ||
m_panelGradColor=color; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setTitleFont(const QFont f) | ||
{ | ||
if(f==m_titleFont) | ||
return; | ||
else | ||
{ | ||
m_titleFont=f; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setPanelHeight(const int h) | ||
{ | ||
if(h==m_panelHeight) | ||
return; | ||
else | ||
{ | ||
m_panelHeight=h; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setTitleColor(const QColor c) | ||
{ | ||
if(c==m_titleColor) | ||
return; | ||
else | ||
{ | ||
m_titleColor=c; | ||
update(); | ||
} | ||
} | ||
void NodeCore::setTitle(const QString c) | ||
{ | ||
if(c==m_title) | ||
return; | ||
else | ||
{ | ||
m_title=c; | ||
update(); | ||
} | ||
} | ||
|
||
|
||
QColor NodeCore::backgroundColor() const | ||
{ | ||
return m_backgroundColor; | ||
} | ||
QColor NodeCore::highlightColor() const | ||
{ | ||
return m_highlightColor; | ||
} | ||
QColor NodeCore::panelColor() const | ||
{ | ||
return m_panelColor; | ||
} | ||
QColor NodeCore::panelGradColor() const | ||
{ | ||
return m_panelGradColor; | ||
} | ||
QColor NodeCore::titleColor() const | ||
{ | ||
return m_titleColor; | ||
} | ||
QString NodeCore::title() const | ||
{ | ||
return m_title; | ||
} | ||
QFont NodeCore::titleFont() const | ||
{ | ||
return m_titleFont; | ||
} | ||
int NodeCore::panelHeight() const | ||
{ | ||
return m_panelHeight; | ||
} | ||
|
||
|
||
|
||
|
||
void NodeCore::paint(QPainter *painter) | ||
{ | ||
DrawBody(painter); | ||
DrawTitle(painter); | ||
} | ||
void NodeCore::DrawBody(QPainter *painter) | ||
{ | ||
int w=static_cast<int>(width()); | ||
int h=static_cast<int>(height()); | ||
|
||
painter->fillRect(0,0,w,h,QBrush(m_backgroundColor)); | ||
|
||
QLinearGradient g(QPoint(0,0),QPoint(w,m_panelHeight)); | ||
g.setColorAt(0,m_panelColor); | ||
g.setColorAt(1,m_panelGradColor); | ||
painter->fillRect(0,0,w,m_panelHeight,QBrush(g)); | ||
|
||
|
||
painter->setPen(m_highlightColor); | ||
painter->drawRect(1,1,w-2,h-2); | ||
painter->drawRect(1,1,w,m_panelHeight-2); | ||
|
||
|
||
} | ||
void NodeCore::DrawTitle(QPainter *e) | ||
{ | ||
e->setPen(m_titleColor); | ||
e->setFont(m_titleFont); | ||
QFontMetrics f(m_titleFont); | ||
int x=f.width(m_title); | ||
int y=f.height(); | ||
e->drawText(x/2,y,m_title); | ||
} | ||
|
||
void NodeCore::mouseMoveEvent(QMouseEvent *e) | ||
{ | ||
if(isMouseDown) | ||
{ | ||
QPoint curr=QPoint(static_cast<int>(position().x()),static_cast<int>(position().y())); | ||
QPoint l=curr-lastMousePosition+e->pos(); | ||
setPosition(l); | ||
} | ||
} | ||
|
||
|
||
void NodeCore::mousePressEvent(QMouseEvent *e) | ||
{ | ||
isMouseDown=true; | ||
lastMousePosition=e->pos(); | ||
} | ||
void NodeCore::mouseReleaseEvent(QMouseEvent *) | ||
{ | ||
isMouseDown=false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef NODECORE_H | ||
#define NODECORE_H | ||
|
||
#include <QtQuick/QQuickPaintedItem> | ||
#include<QPainter> | ||
class NodeCore : public QQuickPaintedItem | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor) | ||
Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) | ||
Q_PROPERTY(QColor panelColor READ panelColor WRITE setPanelColor) | ||
Q_PROPERTY(QColor panelGradColor READ panelGradColor WRITE setPanelGradColor) | ||
Q_PROPERTY(QColor titleColor READ titleColor WRITE setTitleColor) | ||
Q_PROPERTY(int panelHeight READ panelHeight WRITE setPanelHeight) | ||
Q_PROPERTY(QString title READ title WRITE setTitle) | ||
Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont) | ||
|
||
public: | ||
NodeCore(); | ||
QColor backgroundColor() const; | ||
QColor highlightColor()const; | ||
QColor panelColor()const; | ||
QColor panelGradColor()const; | ||
QString title()const; | ||
QColor titleColor()const; | ||
int panelHeight()const; | ||
QFont titleFont()const; | ||
protected: | ||
void paint(QPainter*) override; | ||
void mouseMoveEvent(QMouseEvent*)override; | ||
void mousePressEvent(QMouseEvent*) override; | ||
void mouseReleaseEvent(QMouseEvent*) override; | ||
|
||
signals: | ||
|
||
public slots: | ||
void setBackgroundColor(const QColor); | ||
void setHighlightColor(const QColor); | ||
void setPanelColor(const QColor); | ||
void setPanelGradColor(const QColor); | ||
void setTitleColor(const QColor); | ||
void setPanelHeight(const int); | ||
void setTitle(const QString); | ||
void setTitleFont(const QFont); | ||
|
||
private: | ||
QColor m_backgroundColor=QColor(40,40,40); | ||
QColor m_highlightColor=QColor(Qt::yellow); | ||
QColor m_panelColor=QColor(Qt::blue); | ||
QColor m_panelGradColor=QColor(Qt::green); | ||
QColor m_titleColor=QColor(Qt::white); | ||
QString m_title="Node"; | ||
QFont m_titleFont=QFont("Segoe UI",12,-1,true); | ||
|
||
int m_panelHeight=40; | ||
|
||
bool isMouseDown; | ||
QPoint lastMousePosition; | ||
|
||
void DrawBody(QPainter*); | ||
void DrawTitle(QPainter*); | ||
}; | ||
|
||
#endif // NODECORE_H |