ui: added icon colors to ColorScheme
This change introduces the qt utility function colorizePixmap() for colloring icons in different colors for different color schemes.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<hover>#B2B2B2</hover>
|
||||
<press>#626262</press>
|
||||
<disabled>#F4F4F4</disabled>
|
||||
<icon>white</icon>
|
||||
</button>
|
||||
|
||||
<field>
|
||||
@@ -100,6 +101,8 @@
|
||||
<text>black</text>
|
||||
<background>white</background>
|
||||
<border>#3C3C3C</border>
|
||||
<icon>black</icon>
|
||||
<hatching>white</hatching>
|
||||
|
||||
<node>
|
||||
<class>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<hover>#555555</hover>
|
||||
<press>#444444</press>
|
||||
<disabled>#333333</disabled>
|
||||
<icon>white</icon>
|
||||
</button>
|
||||
|
||||
<field>
|
||||
@@ -100,6 +101,8 @@
|
||||
<text>#F7F7F7</text>
|
||||
<border>#C3C3C3</border>
|
||||
<background>#272728</background>
|
||||
<icon>#F7F7F7</icon>
|
||||
<hatching>#272728</hatching>
|
||||
|
||||
<node>
|
||||
<class>
|
||||
|
||||
@@ -45,6 +45,7 @@ add_files(
|
||||
qt/graphics/QtStraightLineItem.cpp
|
||||
qt/graphics/QtStraightLineItem.h
|
||||
|
||||
qt/utility/QtDeviceScaledPixmap.cpp
|
||||
qt/utility/QtDeviceScaledPixmap.h
|
||||
qt/utility/QtHighlighter.cpp
|
||||
qt/utility/QtHighlighter.h
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "utility/messaging/type/MessageAutoRefreshChanged.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtRefreshBar::QtRefreshBar()
|
||||
{
|
||||
@@ -22,7 +24,6 @@ QtRefreshBar::QtRefreshBar()
|
||||
m_refreshButton->setObjectName("refresh_button");
|
||||
m_refreshButton->setToolTip("refresh");
|
||||
m_refreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_refreshButton->setIcon(QIcon("data/gui/refresh_view/images/refresh.png"));
|
||||
layout->addWidget(m_refreshButton);
|
||||
|
||||
m_autoRefreshButton = new QPushButton(this);
|
||||
@@ -30,11 +31,12 @@ QtRefreshBar::QtRefreshBar()
|
||||
m_autoRefreshButton->setCheckable(true);
|
||||
m_autoRefreshButton->setToolTip("automatic refresh on window focus");
|
||||
m_autoRefreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_autoRefreshButton->setIcon(QIcon("data/gui/refresh_view/images/auto_refresh.png"));
|
||||
layout->addWidget(m_autoRefreshButton);
|
||||
|
||||
connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(refreshClicked()));
|
||||
connect(m_autoRefreshButton, SIGNAL(clicked()), this, SLOT(autoRefreshClicked()));
|
||||
|
||||
refreshStyle();
|
||||
}
|
||||
|
||||
QtRefreshBar::~QtRefreshBar()
|
||||
@@ -57,4 +59,14 @@ void QtRefreshBar::refreshStyle()
|
||||
|
||||
m_refreshButton->setFixedHeight(height);
|
||||
m_autoRefreshButton->setFixedHeight(height);
|
||||
|
||||
m_refreshButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/refresh_view/images/refresh.png"),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
|
||||
m_autoRefreshButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/refresh_view/images/auto_refresh.png"),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#include "qt/element/QtSmartSearchBox.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtSearchBar::QtSearchBar()
|
||||
{
|
||||
@@ -39,7 +41,6 @@ QtSearchBar::QtSearchBar()
|
||||
m_searchButton->setObjectName("search_button");
|
||||
m_searchButton->setToolTip("search");
|
||||
m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_searchButton->setIcon(QIcon("data/gui/search_view/images/search.png"));
|
||||
layout->addWidget(m_searchButton);
|
||||
|
||||
connect(m_searchButton, SIGNAL(clicked()), m_searchBox, SLOT(search()));
|
||||
@@ -84,4 +85,9 @@ void QtSearchBar::refreshStyle()
|
||||
{
|
||||
m_searchBox->setFixedHeight(std::max(ApplicationSettings::getInstance()->getFontSize() + 11, 25));
|
||||
m_searchButton->setFixedHeight(m_searchBox->height() + 5);
|
||||
|
||||
m_searchButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/search_view/images/search.png"),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageRedo.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtUndoRedo::QtUndoRedo()
|
||||
{
|
||||
@@ -16,14 +18,12 @@ QtUndoRedo::QtUndoRedo()
|
||||
m_undoButton->setObjectName("undo_button");
|
||||
m_undoButton->setToolTip("undo");
|
||||
m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_undoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_left.png"));
|
||||
m_undoButton->setEnabled(false);
|
||||
|
||||
m_redoButton = new QPushButton(this);
|
||||
m_redoButton->setObjectName("redo_button");
|
||||
m_redoButton->setToolTip("redo");
|
||||
m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_redoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_right.png"));
|
||||
m_redoButton->setEnabled(false);
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
@@ -70,4 +70,14 @@ void QtUndoRedo::refreshStyle()
|
||||
|
||||
m_undoButton->setFixedHeight(height);
|
||||
m_redoButton->setFixedHeight(height);
|
||||
|
||||
m_undoButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/undoredo_view/images/arrow_left.png"),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
|
||||
m_redoButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap("data/gui/undoredo_view/images/arrow_right.png"),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
qreal QtDeviceScaledPixmap::devicePixelRatio()
|
||||
{
|
||||
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
|
||||
return app->devicePixelRatio();
|
||||
}
|
||||
|
||||
QtDeviceScaledPixmap::QtDeviceScaledPixmap(QString filePath)
|
||||
: m_pixmap(filePath)
|
||||
{
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
|
||||
QtDeviceScaledPixmap::~QtDeviceScaledPixmap() {}
|
||||
|
||||
const QPixmap& QtDeviceScaledPixmap::pixmap() const
|
||||
{
|
||||
return m_pixmap;
|
||||
}
|
||||
|
||||
qreal QtDeviceScaledPixmap::width() const
|
||||
{
|
||||
return m_pixmap.width() / devicePixelRatio();
|
||||
}
|
||||
|
||||
qreal QtDeviceScaledPixmap::height() const
|
||||
{
|
||||
return m_pixmap.height() / devicePixelRatio();
|
||||
}
|
||||
|
||||
void QtDeviceScaledPixmap::scaleToWidth(int width)
|
||||
{
|
||||
m_pixmap = m_pixmap.scaledToWidth(width * devicePixelRatio(), Qt::SmoothTransformation);
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
|
||||
void QtDeviceScaledPixmap::scaleToHeight(int height)
|
||||
{
|
||||
m_pixmap = m_pixmap.scaledToHeight(height * devicePixelRatio(), Qt::SmoothTransformation);
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
|
||||
void QtDeviceScaledPixmap::mirror(bool horizontal, bool vertical)
|
||||
{
|
||||
m_pixmap = QPixmap::fromImage(m_pixmap.toImage().mirrored(horizontal, vertical));
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
@@ -1,58 +1,25 @@
|
||||
#ifndef QT_DEVICE_SCALED_PIXMAP_H
|
||||
#define QT_DEVICE_SCALED_PIXMAP_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPixmap>
|
||||
|
||||
class QtDeviceScaledPixmap
|
||||
{
|
||||
public:
|
||||
static qreal devicePixelRatio()
|
||||
{
|
||||
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
|
||||
return app->devicePixelRatio();
|
||||
}
|
||||
static qreal devicePixelRatio();
|
||||
|
||||
explicit QtDeviceScaledPixmap(QString filePath)
|
||||
: m_pixmap(filePath)
|
||||
{
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
explicit QtDeviceScaledPixmap(QString filePath);
|
||||
virtual ~QtDeviceScaledPixmap();
|
||||
|
||||
virtual ~QtDeviceScaledPixmap() {}
|
||||
const QPixmap& pixmap() const;
|
||||
|
||||
const QPixmap& pixmap() const
|
||||
{
|
||||
return m_pixmap;
|
||||
}
|
||||
qreal width() const;
|
||||
qreal height() const;
|
||||
|
||||
qreal width() const
|
||||
{
|
||||
return m_pixmap.width() / devicePixelRatio();
|
||||
}
|
||||
void scaleToWidth(int width);
|
||||
void scaleToHeight(int height);
|
||||
|
||||
qreal height() const
|
||||
{
|
||||
return m_pixmap.height() / devicePixelRatio();
|
||||
}
|
||||
|
||||
void scaleToWidth(int width)
|
||||
{
|
||||
m_pixmap = m_pixmap.scaledToWidth(width * devicePixelRatio(), Qt::SmoothTransformation);
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
|
||||
void scaleToHeight(int height)
|
||||
{
|
||||
m_pixmap = m_pixmap.scaledToHeight(height * devicePixelRatio(), Qt::SmoothTransformation);
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
|
||||
void mirror(bool horizontal = false, bool vertical = true)
|
||||
{
|
||||
m_pixmap = QPixmap::fromImage(m_pixmap.toImage().mirrored(horizontal, vertical));
|
||||
m_pixmap.setDevicePixelRatio(devicePixelRatio());
|
||||
}
|
||||
void mirror(bool horizontal = false, bool vertical = true);
|
||||
|
||||
private:
|
||||
QPixmap m_pixmap;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "utilityQt.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QPainter>
|
||||
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
@@ -115,4 +116,17 @@ namespace utility
|
||||
|
||||
return css;
|
||||
}
|
||||
|
||||
QPixmap colorizePixmap(const QPixmap& pixmap, QColor color)
|
||||
{
|
||||
QImage image = pixmap.toImage();
|
||||
QImage colorImage(image.size(), image.format());
|
||||
QPainter colorPainter(&colorImage);
|
||||
colorPainter.fillRect(image.rect(), color);
|
||||
|
||||
QPainter painter(&image);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
||||
painter.drawImage(0, 0, colorImage);
|
||||
return QPixmap::fromImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace utility
|
||||
void loadFontsFromDirectory(const std::string& path, const std::string& extension = ".otf");
|
||||
|
||||
std::string getStyleSheet(const std::string& path);
|
||||
|
||||
QPixmap colorizePixmap(const QPixmap& pixmap, QColor color);
|
||||
}
|
||||
|
||||
# endif // UTILITY_QT_H
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "qt/graphics/QtRoundedRectItem.h"
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h"
|
||||
#include "qt/view/graphElements/QtGraphEdge.h"
|
||||
|
||||
@@ -372,10 +373,11 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
m_rect->setBrush(QBrush(color));
|
||||
m_rect->setRadius(radius);
|
||||
|
||||
if (style.undefinedPattern)
|
||||
if (style.hatchingColor.size())
|
||||
{
|
||||
QtDeviceScaledPixmap pixmap("data/gui/graph_view/images/pattern.png");
|
||||
pixmap.scaleToHeight(10);
|
||||
QtDeviceScaledPixmap pattern("data/gui/graph_view/images/pattern.png");
|
||||
pattern.scaleToHeight(10);
|
||||
QPixmap pixmap = utility::colorizePixmap(pattern.pixmap(), style.hatchingColor.c_str());
|
||||
|
||||
if (!m_undefinedRect)
|
||||
{
|
||||
@@ -387,7 +389,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
|
||||
p.setColor(Qt::transparent);
|
||||
|
||||
m_undefinedRect->setPen(p);
|
||||
m_undefinedRect->setBrush(QBrush(pixmap.pixmap()));
|
||||
m_undefinedRect->setBrush(pixmap);
|
||||
m_undefinedRect->setRadius(radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/graphics/QtRoundedRectItem.h"
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtGraphNodeAccess::QtGraphNodeAccess(TokenComponentAccess::AccessType accessType)
|
||||
: QtGraphNode()
|
||||
@@ -54,6 +55,8 @@ void QtGraphNodeAccess::updateStyle()
|
||||
|
||||
m_text->setPos(style.textOffset.x + m_accessIconSize + 3, style.textOffset.x + m_accessIconSize + 2 - style.fontSize);
|
||||
m_accessIcon->setPos(style.textOffset.x, style.textOffset.y);
|
||||
|
||||
m_accessIcon->setPixmap(utility::colorizePixmap(m_accessIcon->pixmap(), style.iconColor.c_str()));
|
||||
}
|
||||
|
||||
void QtGraphNodeAccess::hideLabel()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "qt/graphics/QtRoundedRectItem.h"
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
|
||||
QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount)
|
||||
@@ -71,4 +72,6 @@ void QtGraphNodeExpandToggle::updateStyle()
|
||||
(m_rect->rect().width() - m_icon->pixmap().width() / QtDeviceScaledPixmap::devicePixelRatio()) / 2,
|
||||
(m_invisibleSubNodeCount == 0 ? m_rect->rect().height() / 2 - 2 : m_rect->rect().height() - 8)
|
||||
);
|
||||
|
||||
m_icon->setPixmap(utility::colorizePixmap(m_icon->pixmap(), style.iconColor.c_str()));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ GraphViewStyle::NodeStyle::NodeStyle()
|
||||
, borderDashed(false)
|
||||
, fontSize(0)
|
||||
, fontBold(false)
|
||||
, undefinedPattern(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -283,7 +282,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
break;
|
||||
|
||||
case Node::NODE_UNDEFINED_TYPE:
|
||||
style.undefinedPattern = true;
|
||||
style.hatchingColor = scheme->getColor("graph/hatching");
|
||||
|
||||
case Node::NODE_STRUCT:
|
||||
case Node::NODE_CLASS:
|
||||
@@ -333,7 +332,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleForNodeType(
|
||||
|
||||
case Node::NODE_UNDEFINED_FUNCTION:
|
||||
case Node::NODE_UNDEFINED_VARIABLE:
|
||||
style.undefinedPattern = true;
|
||||
style.hatchingColor = scheme->getColor("graph/hatching");
|
||||
|
||||
case Node::NODE_FUNCTION:
|
||||
case Node::NODE_METHOD:
|
||||
@@ -367,6 +366,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfAccessNode()
|
||||
|
||||
style.color = scheme->getColor("graph/background");
|
||||
style.textColor = scheme->getColor("graph/text");
|
||||
style.iconColor = scheme->getColor("graph/icon");
|
||||
style.borderColor = "#00000000";
|
||||
|
||||
style.cornerRadius = 12;
|
||||
@@ -389,6 +389,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfExpandToggleNode()
|
||||
|
||||
style.color = scheme->getColor("graph/background");
|
||||
style.textColor = scheme->getColor("graph/text");
|
||||
style.iconColor = scheme->getColor("graph/icon");
|
||||
style.borderColor = "#00000000";
|
||||
|
||||
style.cornerRadius = 100;
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
|
||||
std::string color;
|
||||
std::string textColor;
|
||||
std::string iconColor;
|
||||
std::string hatchingColor;
|
||||
|
||||
std::string shadowColor;
|
||||
int shadowBlurRadius;
|
||||
@@ -55,8 +57,6 @@ public:
|
||||
bool fontBold;
|
||||
|
||||
Vec2i textOffset;
|
||||
|
||||
bool undefinedPattern;
|
||||
};
|
||||
|
||||
struct EdgeStyle
|
||||
|
||||
Reference in New Issue
Block a user