revised UI color system when showing nodes

Olive now has a set of colors that categories can be "assigned" to. The timeline also shares the same colors as the NodeView. Colors can be configured per node (aka per clip).
This commit is contained in:
itsmattkc
2021-01-15 18:44:34 +11:00
parent 91740dd823
commit b4dd976e90
22 changed files with 443 additions and 72 deletions
+44 -1
View File
@@ -27,15 +27,18 @@
#include "common/timecodefunctions.h"
#include "common/xmlutils.h"
#include "config/config.h"
#include "project/project.h"
#include "project/item/footage/footage.h"
#include "project/item/footage/videostream.h"
#include "ui/colorcoding.h"
#include "widget/nodeview/nodeviewundo.h"
namespace olive {
Node::Node() :
can_be_deleted_(true)
can_be_deleted_(true),
override_color_(-1)
{
}
@@ -99,6 +102,8 @@ void Node::Load(QXmlStreamReader *reader, XMLNodeData& xml_node_data, const QAto
SetPosition(p);
} else if (reader->name() == QStringLiteral("label")) {
SetLabel(reader->readElementText());
} else if (reader->name() == QStringLiteral("color")) {
override_color_ = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("custom")) {
LoadInternal(reader, xml_node_data);
} else {
@@ -117,6 +122,7 @@ void Node::Save(QXmlStreamWriter *writer) const
writer->writeEndElement(); // pos
writer->writeTextElement(QStringLiteral("label"), GetLabel());
writer->writeTextElement(QStringLiteral("color"), QString::number(override_color_));
foreach (NodeInput* input, inputs_) {
writer->writeStartElement(QStringLiteral("input"));
@@ -146,6 +152,43 @@ void Node::Retranslate()
{
}
Color Node::color() const
{
int c;
if (override_color_ >= 0) {
c = override_color_;
} else {
c = Config::Current()[QStringLiteral("CatColor%1").arg(this->Category().first())].toInt();
}
return ColorCoding::GetColor(c);
}
QLinearGradient Node::gradient_color(qreal top, qreal bottom) const
{
QLinearGradient grad;
grad.setStart(0, top);
grad.setFinalStop(0, bottom);
QColor c = color().toQColor();
grad.setColorAt(0.0, c.lighter());
grad.setColorAt(1.0, c);
return grad;
}
QBrush Node::brush(qreal top, qreal bottom) const
{
if (Config::Current()[QStringLiteral("UseGradients")].toBool()) {
return gradient_color(top, bottom);
} else {
return color().toQColor();
}
}
void Node::RemoveNodesAndExclusiveDependencies(Node *node, QUndoCommand *command)
{
// Remove main node
+28
View File
@@ -154,6 +154,29 @@ public:
*/
virtual void Retranslate();
/**
* @brief Retrieve the color of this node
*/
Color color() const;
/**
* @brief Same as color() but return a pretty gradient version
*/
QLinearGradient gradient_color(qreal top, qreal bottom) const;
/**
* @brief Uses config and returns either color() for flat shading or gradient for gradient
*/
QBrush brush(qreal top, qreal bottom) const;
/**
* @brief Sets the override color. Set to -1 for no override color.
*/
void SetOverrideColor(int index)
{
override_color_ = index;
}
/**
* @brief Return a list of NodeParams
*/
@@ -485,6 +508,11 @@ private:
*/
QString label_;
/**
* @brief -1 if the color should be based on the category, >=0 if the user has set a custom color
*/
int override_color_;
};
template<class T>