ui: color schemes

Put all colors into single xml file. Accessing colors is handled via the singleton class ColorScheme. The default scheme
"bright.xml" holds the original colors. The scheme "dark.xml" is a start, but still a poor alternative. Color schemes
can be switched via the View menu.
This commit is contained in:
Eberhard Graether
2015-07-17 19:50:39 +02:00
parent fb170cbd5d
commit 5722b4dc23
42 changed files with 979 additions and 309 deletions
+5
View File
@@ -60,6 +60,11 @@ void ComponentManager::refreshViews()
view->refreshView();
}
}
for (std::shared_ptr<CompositeView> view : m_compositeViews)
{
view->refreshView();
}
}
ComponentManager::ComponentManager()
@@ -88,6 +88,15 @@ void FeatureController::handleMessage(MessageSearch* message)
m.dispatchImmediately();
}
void FeatureController::handleMessage(MessageSwitchColorScheme* message)
{
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
settings->setColorSchemePath(message->colorSchemeFilePath);
settings->save();
MessageRefresh(true).dispatch();
}
void FeatureController::handleMessage(MessageZoom* message)
{
ApplicationSettings* settings = ApplicationSettings::getInstance().get();
@@ -7,6 +7,7 @@
#include "utility/messaging/type/MessageActivateNode.h"
#include "utility/messaging/type/MessageActivateTokenLocation.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageSwitchColorScheme.h"
#include "utility/messaging/type/MessageZoom.h"
#include "component/controller/Controller.h"
@@ -20,6 +21,7 @@ class FeatureController
, public MessageListener<MessageActivateNode>
, public MessageListener<MessageActivateTokenLocation>
, public MessageListener<MessageSearch>
, public MessageListener<MessageSwitchColorScheme>
, public MessageListener<MessageZoom>
{
public:
@@ -32,6 +34,7 @@ private:
virtual void handleMessage(MessageActivateNode* message);
virtual void handleMessage(MessageActivateTokenLocation* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageSwitchColorScheme* message);
virtual void handleMessage(MessageZoom* message);
StorageAccess* m_storageAccess;
@@ -213,10 +213,13 @@ void UndoRedoController::processNormalCommand(const Command& command)
void UndoRedoController::processRedoCommand(const Command& command)
{
m_undo.push_back(m_lastCommand);
m_lastCommand = command;
if (m_lastCommand.message)
{
m_undo.push_back(m_lastCommand);
getView()->setUndoButtonEnabled(true);
}
getView()->setUndoButtonEnabled(true);
m_lastCommand = command;
if (m_redo.empty())
{
@@ -226,10 +229,13 @@ void UndoRedoController::processRedoCommand(const Command& command)
void UndoRedoController::processUndoCommand(const Command& command)
{
m_redo.push_back(m_lastCommand);
m_lastCommand = command;
if (m_lastCommand.message)
{
m_redo.push_back(m_lastCommand);
getView()->setRedoButtonEnabled(true);
}
getView()->setRedoButtonEnabled(true);
m_lastCommand = command;
if (m_undo.empty())
{
+35 -36
View File
@@ -4,6 +4,7 @@
#include "component/view/GraphViewStyleImpl.h"
#include "settings/ApplicationSettings.h"
#include "settings/ColorScheme.h"
GraphViewStyle::NodeMargins::NodeMargins()
: left(0)
@@ -248,33 +249,31 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
){
NodeStyle style;
style.color = "#D3D3D3";
style.borderColor = "#00000000";
style.fontName = getFontNameForNodeType(type);
style.fontSize = getFontSizeForNodeType(type);
if (isActive)
{
style.borderColor = "#3c3c3c";
}
ColorScheme* scheme = ColorScheme::getInstance().get();
if (isActive || isFocused)
{
style.color = ApplicationSettings::getInstance()->getNodeTypeColor(type, "hover");
style.color = scheme->getNodeTypeColor(type, "hover");
}
else
{
style.color = ApplicationSettings::getInstance()->getNodeTypeColor(type);
style.color = scheme->getNodeTypeColor(type);
}
style.textColor = scheme->getColor("graph/text");
style.borderColor = isActive ? scheme->getColor("graph/border") : "#00000000";
style.fontName = getFontNameForNodeType(type);
style.fontSize = getFontSizeForNodeType(type);
switch (type)
{
case Node::NODE_UNDEFINED:
style.borderDashed = true;
case Node::NODE_NAMESPACE:
style.borderColor = "#cc8d91";
style.borderColor = style.color;
style.color = "#00000000";
style.borderWidth = 1;
style.cornerRadius = 20;
@@ -296,13 +295,14 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
style.fontBold = true;
}
style.shadowColor = scheme->getColor("graph/border");
if (isFocused)
{
style.shadowColor = "#FF000000";
style.shadowColor.insert(1, "FF");
}
else
{
style.shadowColor = "#80000000";
style.shadowColor.insert(1, "80");
}
style.shadowBlurRadius = 5;
@@ -363,7 +363,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfAccessNode()
{
NodeStyle style;
style.color = "#FFFFFF";
ColorScheme* scheme = ColorScheme::getInstance().get();
style.color = scheme->getColor("graph/background");
style.textColor = scheme->getColor("graph/text");
style.borderColor = "#00000000";
style.cornerRadius = 12;
@@ -382,7 +385,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
{
NodeStyle style;
style.color = "#FFFFFF";
ColorScheme* scheme = ColorScheme::getInstance().get();
style.color = scheme->getColor("graph/background");
style.textColor = scheme->getColor("graph/text");
style.borderColor = "#00000000";
style.cornerRadius = 100;
@@ -397,8 +403,10 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
{
NodeStyle style = getStyleForNodeType(Node::NODE_CLASS, false, isFocused, false);
ColorScheme* scheme = ColorScheme::getInstance().get();
style.shadowColor = "";
style.borderColor = "#3c3c3c";
style.borderColor = scheme->getColor("graph/border");
style.borderWidth = isFocused ? 2 : 1;
return style;
@@ -423,23 +431,28 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ
style.originOffset.y = -1;
style.targetOffset.y = 1;
if (isActive)
{
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type, "hover");
}
else
{
style.color = ColorScheme::getInstance()->getEdgeTypeColor(type);
}
switch (type)
{
case Edge::EDGE_AGGREGATION:
style.isStraight = true;
style.color = isActive ? "#DDD" : "#EEE";
style.width = 1;
style.zValue = isActive ? -2 : -5;
break;
case Edge::EDGE_CALL:
style.color = "#F4BC3D";
style.originOffset.y = 1;
style.targetOffset.y = -1;
style.verticalOffset = 4;
break;
case Edge::EDGE_USAGE:
style.color = "#3190BA";
style.originOffset.y = 3;
style.targetOffset.y = -3;
style.verticalOffset = 6;
@@ -449,22 +462,8 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(Edge::EdgeType typ
style.arrowWidth = 14;
style.arrowClosed = true;
style.targetOffset.x = 34;
style.color = "#878787";
break;
case Edge::EDGE_OVERRIDE:
style.color = "#CC5E89";
break;
case Edge::EDGE_INCLUDE:
style.color = "#5DA399";
break;
case Edge::EDGE_TEMPLATE_PARAMETER_OF:
case Edge::EDGE_TEMPLATE_ARGUMENT_OF:
case Edge::EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF:
case Edge::EDGE_TEMPLATE_SPECIALIZATION_OF:
style.color = "#C1305D";
break;
default:
style.color = "#878787";
break;
}
+1
View File
@@ -39,6 +39,7 @@ public:
NodeStyle();
std::string color;
std::string textColor;
std::string shadowColor;
int shadowBlurRadius;