Commit e3ff6f5d authored by Ivan Yossi's avatar Ivan Yossi 👌

Krita: add Background Color preview to PopupPalette

parent 5002f9eb
......@@ -364,5 +364,15 @@ const KoColor& KisFavoriteResourceManager::recentColorAt(int pos)
return m_colorList->guiColor(pos);
}
void KisFavoriteResourceManager::slotSetBGColor(const KoColor c)
{
m_bgColor = c.toQColor();
}
QColor KisFavoriteResourceManager::bgColor()
{
return m_bgColor;
}
#include "kis_favorite_resource_manager.moc"
......@@ -81,6 +81,9 @@ public:
virtual void syncTagAddition(const QString& tag);
virtual void syncTagRemoval(const QString& tag);
//BgColor;
QColor bgColor();
/**
* Set palette to block updates, paintops won't be deleted when they are deleted from server
* Used when overwriting a resource
......@@ -90,6 +93,7 @@ public:
signals:
void sigSetFGColor(const KoColor& c);
void sigSetBGColor(const KoColor& c);
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
......@@ -118,6 +122,8 @@ public slots:
void slotChangeFGColorSelector(KoColor c);
void slotSetBGColor(const KoColor c);
private:
KisPaletteManager *m_favoriteBrushManager;
......@@ -132,6 +138,7 @@ private:
void saveFavoritePresets();
QColor m_bgColor;
};
#endif
......@@ -295,7 +295,9 @@ KisPaintopBox::KisPaintopBox(KisView2 *view, QWidget *parent, const char *name)
m_favoriteResourceManager = new KisFavoriteResourceManager(this);
connect(m_resourceProvider, SIGNAL(sigFGColorUsed(KoColor)), m_favoriteResourceManager, SLOT(slotAddRecentColor(KoColor)));
connect(m_resourceProvider, SIGNAL(sigFGColorChanged(KoColor)), m_favoriteResourceManager, SLOT(slotChangeFGColorSelector(KoColor)));
connect(m_resourceProvider, SIGNAL(sigBGColorChanged(KoColor)), m_favoriteResourceManager, SLOT(slotSetBGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigSetFGColor(KoColor)), m_resourceProvider, SLOT(slotSetFGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigSetBGColor(KoColor)), m_resourceProvider, SLOT(slotSetBGColor(KoColor)));
connect(m_favoriteResourceManager, SIGNAL(sigEnableChangeColor(bool)), m_resourceProvider, SLOT(slotResetEnableFGChange(bool)));
m_view->canvasBase()->setFavoriteResourceManager(m_favoriteResourceManager);
......
......@@ -30,10 +30,10 @@
#include <math.h>
#define maxPresetCount 10
#define brushInnerRadius 100.0
#define brushOuterRadius 140.0
#define colorInnerRadius 75.0
#define colorOuterRadius 95.0
#define brushInnerRadius 94.0
#define brushOuterRadius 145.0
#define colorInnerRadius 72.0
#define colorOuterRadius 92.0
#define brushRadius (brushInnerRadius+brushOuterRadius)/2
class PopupColorTriangle : public KoTriangleColorSelector
......@@ -85,14 +85,14 @@ KisPopupPalette::KisPopupPalette(KisFavoriteResourceManager* manager, QWidget *p
, m_triangleColorSelector(0)
, m_timer(0)
{
m_triangleColorSelector = new PopupColorTriangle(this);
m_triangleColorSelector->move(70, 70);
m_triangleColorSelector->resize(140, 140);
m_triangleColorSelector = new PopupColorTriangle(this);
m_triangleColorSelector->move(77, 77);
m_triangleColorSelector->resize(136, 136);
m_triangleColorSelector->setVisible(true);
setAutoFillBackground(true);
setAttribute(Qt::WA_ContentsPropagated, true);
// setAttribute(Qt::WA_TranslucentBackground, true);
//setAttribute(Qt::WA_TranslucentBackground, true);
connect(m_triangleColorSelector, SIGNAL(colorChanged(QColor)), SLOT(slotChangefGColor(QColor)));
connect(this, SIGNAL(sigChangeActivePaintop(int)), m_resourceManager, SLOT(slotChangeActivePaintop(int)));
......@@ -225,32 +225,41 @@ void KisPopupPalette::setVisible(bool b)
QSize KisPopupPalette::sizeHint() const
{
return QSize(280, 280);
return QSize(290, 290);
}
void KisPopupPalette::resizeEvent(QResizeEvent*)
{
int side = qMin(width(), height());
int side2 = 66;
int fgball = 66;
QRegion maskedRegion(width() / 2 - side / 2, height() / 2 - side / 2, side, side, QRegion::Ellipse);
QRegion maskedRegion2(33 - side2 / 2, 33 - side2 / 2 , side2, side2, QRegion::Ellipse);
setMask(maskedRegion + maskedRegion2);
maskedRegion = maskedRegion.united( QRegion(50 - fgball / 2, 32 - fgball / 2 , fgball, fgball, QRegion::Ellipse) );
maskedRegion = maskedRegion.united( QRegion(24 - (fgball - 20 ) / 2, 60 - (fgball - 20 ) / 2 , (fgball - 20 ), (fgball - 20 ), QRegion::Ellipse) );
setMask(maskedRegion);
}
void KisPopupPalette::paintEvent(QPaintEvent* e)
{
float rotationAngle = 0.0;
QColor bg_color = m_resourceManager->bgColor();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(e->rect(), palette().brush(QPalette::Window));
painter.translate(width() / 2, height() / 2);
//painting background color
QPainterPath bgColor;
bgColor.addEllipse(QPoint(-width() / 2 + 24, -height() / 2 + 60), 20, 20);
painter.fillPath(bgColor, (bg_color.isValid()) ? (bg_color) : (QColor("white")) );
painter.drawPath(bgColor);
//painting foreground color
QPainterPath path2;
path2.addEllipse(QPoint(-width() / 2 + 33, -height() / 2 + 33), 30, 30);
painter.fillPath(path2, m_triangleColorSelector->color());
painter.drawPath(path2);
QPainterPath fgColor;
fgColor.addEllipse(QPoint(-width() / 2 + 50, -height() / 2 + 32), 30, 30);
painter.fillPath(fgColor, m_triangleColorSelector->color());
painter.drawPath(fgColor);
//painting favorite brushes
QList<QImage> images(m_resourceManager->favoritePresetImages());
......@@ -468,7 +477,7 @@ QPainterPath KisPopupPalette::pathFromPresetIndex(int index)
{
QRect outerRect(-width() / 2, -height() / 2, width(), height());
outerRect.adjust(3, 3, -3, -3);
int ringSize = brushOuterRadius - colorOuterRadius - 8;
int ringSize = brushOuterRadius - colorOuterRadius - 6;
QRect innerRect = outerRect.adjusted(ringSize, ringSize, -ringSize, -ringSize);
qreal angleLength = 360 / 10;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment