-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework styling #172
base: master
Are you sure you want to change the base?
Rework styling #172
Changes from 10 commits
818b56a
2bb3ff0
8ad2d3a
da1f6c0
77c4724
397d98a
a5c2430
f88d00b
008eea5
9f09fad
8cb84ce
468101e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,37 +2,28 @@ | |
|
||
#include <QtGui/QColor> | ||
|
||
#include <QByteArray> | ||
#include <QObject> | ||
#include <QString> | ||
|
||
#include "Export.hpp" | ||
#include "Style.hpp" | ||
|
||
namespace QtNodes | ||
{ | ||
|
||
class NODE_EDITOR_PUBLIC ConnectionStyle : public Style | ||
class NODE_EDITOR_PUBLIC ConnectionStyle | ||
{ | ||
public: | ||
|
||
ConnectionStyle(); | ||
|
||
ConnectionStyle(QString jsonText); | ||
|
||
public: | ||
|
||
static void setConnectionStyle(QString jsonText); | ||
|
||
private: | ||
|
||
void loadJsonText(QString jsonText) override; | ||
static ConnectionStyle const& | ||
defaultStyle(); | ||
|
||
void loadJsonFile(QString fileName) override; | ||
|
||
void loadJsonFromByteArray(QByteArray const &byteArray) override; | ||
|
||
public: | ||
static ConnectionStyle | ||
fromJson(QString const& jsonText); | ||
|
||
QColor constructionColor() const; | ||
QColor normalColor() const; | ||
QColor normalColor(QString typeId) const; | ||
QColor selectedColor() const; | ||
QColor selectedHaloColor() const; | ||
QColor hoveredColor() const; | ||
|
@@ -43,18 +34,35 @@ class NODE_EDITOR_PUBLIC ConnectionStyle : public Style | |
|
||
bool useDataDefinedColors() const; | ||
|
||
void setConstructionColor(QColor); | ||
void setNormalColor(QColor); | ||
void setSelectedColor(QColor); | ||
void setSelectedHaloColor(QColor); | ||
void setHoveredColor(QColor); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we go further with the Qt-kung-fu and describe all the members in the class with As I understand, something like this
would define a private member and generate setters and getters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a bad idea. E.g. when we implement a QML frontend, that could come in handy. IIUC,
|
||
|
||
void setLineWidth(float); | ||
void setConstructionLineWidth(float); | ||
void setPointDiameter(float); | ||
|
||
void useDataDefinedColors(bool); | ||
|
||
static QColor | ||
computeNormalColor(QString const& typeId); | ||
|
||
private: | ||
ConnectionStyle(QByteArray const& jsonBytes); | ||
void loadJson(QByteArray const& jsonBytes); | ||
|
||
QColor ConstructionColor; | ||
QColor NormalColor; | ||
QColor SelectedColor; | ||
QColor SelectedHaloColor; | ||
QColor HoveredColor; | ||
QColor _constructionColor; | ||
QColor _normalColor; | ||
QColor _selectedColor; | ||
QColor _selectedHaloColor; | ||
QColor _hoveredColor; | ||
|
||
float LineWidth; | ||
float ConstructionLineWidth; | ||
float PointDiameter; | ||
float _lineWidth; | ||
float _constructionLineWidth; | ||
float _pointDiameter; | ||
|
||
bool UseDataDefinedColors; | ||
bool _useDataDefinedColors; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, maybe a stupid question -- why pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other options were you thinking of?
ConnectionStyle _connectionStyle;
This is expensive. We don't need a copy of theConnectionStyle
object for eachConnection
, especially when they're all going to be the samestd::shared_ptr<ConnectionStyle const> _connectionStyle;
This is unnecessary. TheConnectionStyle
outlives the connections anyway (correction: they can, but currently don't; that's something I will fix).ConnectionStyle const &_connectionStyle;
I don't use references as class members, as references can't be rebound (they are effectively const). It doesn't matter here, asConnection
can't be copied anyway, but I used a pointer instead for consistency.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here
ConnectionStyle const & connectionStyle() const
we convert this pointer back to a reference.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. The member is stored as a pointer, but is semantically a reference (that's the style I use anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection
is deleted.Therefore I suggested that this member shouldn't be rebound.
I'd simply use a const ref.
BTW, we should explicitly delete move constructor and move assignment operator for this class