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:
@@ -11,6 +11,7 @@
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "data/StorageCache.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
{
|
||||
@@ -32,6 +33,8 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
void Application::loadSettings()
|
||||
{
|
||||
ApplicationSettings::getInstance()->load("data/ApplicationSettings.xml");
|
||||
ColorScheme::getInstance()->load(ApplicationSettings::getInstance()->getColorSchemePath());
|
||||
|
||||
GraphViewStyle::loadStyleSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -211,6 +211,8 @@ add_files(
|
||||
|
||||
settings/ApplicationSettings.cpp
|
||||
settings/ApplicationSettings.h
|
||||
settings/ColorScheme.cpp
|
||||
settings/ColorScheme.h
|
||||
settings/CommonSettings.cpp
|
||||
settings/CommonSettings.h
|
||||
settings/ProjectSettings.cpp
|
||||
@@ -274,6 +276,7 @@ add_files(
|
||||
utility/messaging/type/MessageSearchAutocomplete.h
|
||||
utility/messaging/type/MessageShowFile.h
|
||||
utility/messaging/type/MessageStatus.h
|
||||
utility/messaging/type/MessageSwitchColorScheme.h
|
||||
utility/messaging/type/MessageUndo.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
NodeStyle();
|
||||
|
||||
std::string color;
|
||||
std::string textColor;
|
||||
|
||||
std::string shadowColor;
|
||||
int shadowBlurRadius;
|
||||
|
||||
@@ -154,13 +154,13 @@ std::string Edge::getTypeString(EdgeType type)
|
||||
case EDGE_TYPEDEF_OF:
|
||||
return "typedef";
|
||||
case EDGE_TEMPLATE_PARAMETER_OF:
|
||||
return "template parameter";
|
||||
return "template_parameter";
|
||||
case EDGE_TEMPLATE_ARGUMENT_OF:
|
||||
return "template argument";
|
||||
return "template_argument";
|
||||
case EDGE_TEMPLATE_DEFAULT_ARGUMENT_OF:
|
||||
return "template default argument";
|
||||
return "template_default_argument";
|
||||
case EDGE_TEMPLATE_SPECIALIZATION_OF:
|
||||
return "template specialization";
|
||||
return "template_specialization";
|
||||
case EDGE_INCLUDE:
|
||||
return "include";
|
||||
case EDGE_AGGREGATION:
|
||||
|
||||
@@ -46,6 +46,16 @@ void ApplicationSettings::setFontSize(int fontSize)
|
||||
setValue<int>("application/font_size", fontSize);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
return getValue<std::string>("application/color_scheme", "./data/color_schemes/bright.xml");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setColorSchemePath(const std::string& colorSchemePath)
|
||||
{
|
||||
setValue<std::string>("application/color_scheme", colorSchemePath);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getCodeTabWidth() const
|
||||
{
|
||||
return getValue<int>("code/TabWidth", 4);
|
||||
@@ -76,31 +86,6 @@ void ApplicationSettings::setCodeSnippetExpandRange(int range)
|
||||
setValue<int>("code/snippet/expand_range", range);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getNodeTypeColor(Node::NodeType type, const std::string& state) const
|
||||
{
|
||||
std::string path = "colors/" + Node::getTypeString(type) + "/" + state;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state)
|
||||
{
|
||||
std::string path = "colors/" + Node::getTypeString(type) + "/" + state;
|
||||
setValue<std::string>(path, color);
|
||||
}
|
||||
|
||||
std::string ApplicationSettings::getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state) const
|
||||
{
|
||||
std::string path = "colors/" + QueryNode::queryNodeTypeToString(type) + "/" + state;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
}
|
||||
|
||||
void ApplicationSettings::setQueryNodeTypeColor(QueryNode::QueryNodeType type,
|
||||
const std::string& color, const std::string& state)
|
||||
{
|
||||
std::string path = "colors/" + QueryNode::queryNodeTypeToString(type) + "/" + state;
|
||||
setValue<std::string>(path, color);
|
||||
}
|
||||
|
||||
ApplicationSettings::ApplicationSettings()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "utility/math/Color.h"
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/query/QueryNode.h"
|
||||
#include "settings/CommonSettings.h"
|
||||
|
||||
class ApplicationSettings
|
||||
@@ -26,6 +22,9 @@ public:
|
||||
int getFontSize() const;
|
||||
void setFontSize(int fontSize);
|
||||
|
||||
std::string getColorSchemePath() const;
|
||||
void setColorSchemePath(const std::string& colorSchemePath);
|
||||
|
||||
// code
|
||||
int getCodeTabWidth() const;
|
||||
void setCodeTabWidth(int codeTabWidth);
|
||||
@@ -36,13 +35,6 @@ public:
|
||||
int getCodeSnippetExpandRange() const;
|
||||
void setCodeSnippetExpandRange(int range);
|
||||
|
||||
// colors
|
||||
std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const;
|
||||
void setNodeTypeColor(Node::NodeType type, const std::string& color, const std::string& state = "normal");
|
||||
|
||||
std::string getQueryNodeTypeColor(QueryNode::QueryNodeType type , const std::string& state = "normal") const;
|
||||
void setQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& color, const std::string& state = "normal");
|
||||
|
||||
private:
|
||||
ApplicationSettings();
|
||||
ApplicationSettings(const ApplicationSettings&);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
std::shared_ptr<ColorScheme> ColorScheme::s_instance;
|
||||
|
||||
std::shared_ptr<ColorScheme> ColorScheme::getInstance()
|
||||
{
|
||||
if (!s_instance)
|
||||
{
|
||||
s_instance = std::shared_ptr<ColorScheme>(new ColorScheme());
|
||||
}
|
||||
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
ColorScheme::~ColorScheme()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ColorScheme::getColor(const std::string& key) const
|
||||
{
|
||||
return getValue<std::string>(key, "#FFFFFF");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getNodeTypeColor(Node::NodeType type, const std::string& state) const
|
||||
{
|
||||
std::string path = "graph/node/" + Node::getTypeString(type) + "/" + state;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getEdgeTypeColor(Edge::EdgeType type, const std::string& state) const
|
||||
{
|
||||
std::string path = "graph/edge/" + Edge::getTypeString(type) + "/" + state;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state) const
|
||||
{
|
||||
std::string path = "search/query/" + QueryNode::queryNodeTypeToString(type) + "/" + state;
|
||||
return getValue<std::string>(path, "#FFFFFF");
|
||||
}
|
||||
|
||||
std::string ColorScheme::getSyntaxColor(const std::string& key) const
|
||||
{
|
||||
return getValue<std::string>("code/snippet/syntax/" + key, "#FFFFFF");
|
||||
}
|
||||
|
||||
ColorScheme::ColorScheme()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef COLOR_SCHEME_H
|
||||
#define COLOR_SCHEME_H
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/query/QueryNode.h"
|
||||
#include "settings/Settings.h"
|
||||
|
||||
class ColorScheme
|
||||
: public Settings
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ColorScheme> getInstance();
|
||||
virtual ~ColorScheme();
|
||||
|
||||
std::string getColor(const std::string& key) const;
|
||||
|
||||
std::string getNodeTypeColor(Node::NodeType type, const std::string& state = "normal") const;
|
||||
std::string getEdgeTypeColor(Edge::EdgeType type, const std::string& state = "normal") const;
|
||||
std::string getQueryNodeTypeColor(QueryNode::QueryNodeType type, const std::string& state = "normal") const;
|
||||
std::string getSyntaxColor(const std::string& key) const;
|
||||
|
||||
protected:
|
||||
ColorScheme();
|
||||
ColorScheme(const ColorScheme&);
|
||||
void operator=(const ColorScheme&);
|
||||
|
||||
static std::shared_ptr<ColorScheme> s_instance;
|
||||
};
|
||||
|
||||
#endif // COLOR_SCHEME_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_SWITCH_COLOR_SCHEME_H
|
||||
#define MESSAGE_SWITCH_COLOR_SCHEME_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageSwitchColorScheme
|
||||
: public Message<MessageSwitchColorScheme>
|
||||
{
|
||||
public:
|
||||
MessageSwitchColorScheme(const std::string& filePath)
|
||||
: colorSchemeFilePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageSwitchColorScheme";
|
||||
}
|
||||
|
||||
const std::string colorSchemeFilePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SWITCH_COLOR_SCHEME_H
|
||||
Reference in New Issue
Block a user