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
+10 -25
View File
@@ -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 -11
View File
@@ -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&);
+49
View File
@@ -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()
{
}
+31
View File
@@ -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