Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2f375d46 authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Add qcolor based basic convolution method to the base color model (this color model

  really should use float-based lab for its calculations... It'd be slow but wouldn't
  remove precision from any colorstrategy without optimized implementations.
* Fix the add-many-options-to-palette-menu-on-tool-change bug
* Fix a crash with tablet use, but its doesn't work yet.

svn path=/trunk/koffice/; revision=443350
parent 16af0dbd
......@@ -106,7 +106,8 @@ User Interface
* Create brush-shape outline cursor
* Implement the following dialogs / widgets:
- Variations (#Boudewijn)
- Gradient (nick from Scribus?)
- Gradient: remove the autogradient dialog and make into a proper
gradient dialog, and allow saving gradients.
* Improve the preview widget - see "doc/the preview widget"
* Show which tool is associated with which pointer (mouse, stylus, eraser, other stylusses) In the statusbar.
* Allow guides to be disabled. Allow diagonal guides (useful
......
......@@ -158,7 +158,7 @@ bool KisStrategyColorSpace::convertPixelsTo(const Q_UINT8 * src, KisProfileSP sr
return true;
}
KisColorAdjustment *KisStrategyColorSpace::createBrightnessContrastAdjustment(Q_UINT16 *transferValues)
KisColorAdjustment *KisStrategyColorSpace::createBrightnessContrastAdjustment(Q_UINT16 */*transferValues*/)
{
return NULL;
}
......@@ -232,6 +232,42 @@ void KisStrategyColorSpace::mixColors(const Q_UINT8 **colors, const Q_UINT8 *wei
void KisStrategyColorSpace::convolveColors(Q_UINT8** colors, Q_INT32 * kernelValues, enumChannelFlags channelFlags, Q_UINT8 *dst, Q_INT32 factor, Q_INT32 offset, Q_INT32 nColors) const
{
Q_INT32 totalRed = 0, totalGreen = 0, totalBlue = 0, totalAlpha = 0;
QColor dstColor;
Q_UINT8 dstOpacity;
const_cast<KisStrategyColorSpace *>(this)->toQColor(dst, &dstColor, &dstOpacity);
while (nColors--)
{
Q_INT32 weight = *kernelValues;
if (weight != 0) {
QColor c;
Q_UINT8 opacity;
const_cast<KisStrategyColorSpace *>(this)->toQColor( *colors, &c, &opacity );
totalRed += c.red() * weight;
totalGreen += c.green() * weight;
totalBlue += c.blue() * weight;
totalAlpha += opacity * weight;
}
colors++;
kernelValues++;
}
if (channelFlags & FLAG_COLOR) {
const_cast<KisStrategyColorSpace *>(this)->nativeColor(QColor(CLAMP((totalRed / factor) + offset, 0, QUANTUM_MAX),
CLAMP((totalGreen / factor) + offset, 0, QUANTUM_MAX),
CLAMP((totalBlue / factor) + offset, 0, QUANTUM_MAX)),
dstOpacity,
dst);
}
if (channelFlags & FLAG_ALPHA) {
const_cast<KisStrategyColorSpace *>(this)->nativeColor(dstColor, CLAMP((totalAlpha/ factor) + offset, 0, QUANTUM_MAX), dst);
}
}
void KisStrategyColorSpace::darken(const Q_UINT8 * src, Q_UINT8 * dst, Q_INT32 shade, bool compensate, double compensation, Q_INT32 nPixels) const
......
......@@ -118,19 +118,23 @@ void KisToolManager::setCurrentTool(KisTool *tool)
KisTool *oldTool = currentTool();
KisCanvas * canvas = (KisCanvas*)m_controller->canvas();
if (!tool->optionWidget()) {
tool->createOptionWidget(0);
}
m_paletteManager->addWidget(tool->optionWidget(), krita::TOOL_OPTION_WIDGET, krita::CONTROL_PALETTE );
if (oldTool)
{
oldTool -> clear();
oldTool -> action() -> setChecked( false );
m_paletteManager->removeWidget(krita::TOOL_OPTION_WIDGET);
}
if (tool) {
if (!tool->optionWidget()) {
tool->createOptionWidget(0);
}
m_paletteManager->addWidget(tool->optionWidget(), krita::TOOL_OPTION_WIDGET, krita::CONTROL_PALETTE );
m_inputDeviceToolMap[m_controller->currentInputDevice()] = tool;
m_controller->setCanvasCursor(tool->cursor());
......@@ -200,7 +204,10 @@ void KisToolManager::setToolForInputDevice(enumInputDevice oldDevice, enumInputD
void KisToolManager::activateCurrentTool()
{
currentTool() -> action() -> activate();
KisTool * t = currentTool();
if (t && t->action()) {
t->action()->activate();
}
}
KisTool * KisToolManager::findTool(const QString &toolName, enumInputDevice inputDevice) const
......
......@@ -96,6 +96,8 @@ void KoPaletteManager::addWidget(QWidget * widget,
enumKoPaletteStyle style)
{
kdDebug() << "Adding widget " << name << "\n";
Q_ASSERT(widget);
if (!widget) return;
......@@ -196,6 +198,8 @@ void KoPaletteManager::showWidget(const QString & name)
void KoPaletteManager::removeWidget(const QString & name)
{
kdDebug() << "Removing widget: " << name << "\n";
QString palette = *(m_currentMapping->find(name));
if (palette.isNull()) return;
......@@ -209,6 +213,11 @@ void KoPaletteManager::removeWidget(const QString & name)
m_widgets->remove(name);
m_currentMapping->remove(name);
KAction * a = m_actions->take(name);
m_viewActionMenu->remove(a);
m_actionCollection->remove(a);
kdDebug() << "Done removing widget " << name << "\n";
}
......
......@@ -56,98 +56,111 @@ KisWetPaletteWidget::KisWetPaletteWidget(QWidget *parent, const char *name) : su
int WIDTH = 24;
int HEIGHT = 24;
b = new KisColorCup(QColor(240, 32, 160), this);
b = new KisColorCup(this);
b->setColor( QColor(240, 32, 160) );
l -> addWidget(b, 0, 0);
QToolTip::add(b, i18n("Quinacridone Rose"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(159, 88, 43), this);
b = new KisColorCup(this);
b->setColor(QColor(159, 88, 43));
l -> addWidget(b, 0, 1);
QToolTip::add(b,i18n("Indian Red"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(254, 220, 64), this);
b = new KisColorCup(this);
b->setColor( QColor(254, 220, 64) );
l -> addWidget(b, 0, 2);
QToolTip::add(b,i18n("Cadmium Yellow"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(36, 180, 32), this);
b = new KisColorCup(this);
b->setColor(QColor(254, 220, 64));
l -> addWidget(b, 0, 3);
QToolTip::add(b,i18n("Hookers Green"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(16, 185, 215), this);
b = new KisColorCup(this);
b->setColor(QColor(16, 185, 215));
l -> addWidget(b, 0, 4);
QToolTip::add(b,i18n("Cerulean Blue"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(96, 32, 8), this);
b = new KisColorCup(this);
b->setColor(QColor(96, 32, 8));
l -> addWidget(b, 0, 5);
QToolTip::add(b,i18n("Burnt Umber"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(254, 96, 8), this);
b = new KisColorCup(this);
b->setColor(QColor(254, 96, 8));
l -> addWidget(b, 0, 6);
QToolTip::add(b,i18n("Cadmium Red"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(255, 136, 8), this);
b = new KisColorCup(this);
b->setColor(QColor(255, 136, 8));
l -> addWidget(b, 0, 7);
QToolTip::add(b,i18n("Brilliant Orange"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(240, 199, 8), this);
b = new KisColorCup(this);
b->setColor(QColor(240, 199, 8));
l -> addWidget(b, 1, 0);
QToolTip::add(b,i18n("Hansa Yellow"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(96, 170, 130), this);
b = new KisColorCup(this);
b->setColor(QColor(96, 170, 130));
l -> addWidget(b, 1, 1);
QToolTip::add(b,i18n("Phthalo Green"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(48, 32, 170), this);
b = new KisColorCup(this);
b->setColor(QColor(48, 32, 170));
l -> addWidget(b, 1, 2);
QToolTip::add(b,i18n("French Ultramarine"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(118, 16, 135), this);
b = new KisColorCup(this);
b->setColor(QColor(118, 16, 135));
l -> addWidget(b, 1, 3);
QToolTip::add(b,i18n("Interference Lilac"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(254, 254, 254), this);
b = new KisColorCup(this);
b->setColor(QColor(254, 254, 254));
l -> addWidget(b, 1, 4);
QToolTip::add(b,i18n("Titanium White"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(64, 64, 74), this);
b = new KisColorCup(this);
b->setColor(QColor(64, 64, 74));
l -> addWidget(b, 1, 5);
QToolTip::add(b,i18n("Ivory Black"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
b = new KisColorCup(QColor(255, 255, 255), this);
b = new KisColorCup(this);
b->setColor(QColor(255, 255, 255));
l -> addWidget(b, 1, 6);
QToolTip::add(b,i18n("Pure Water"));
b -> setFixedSize(WIDTH, HEIGHT);
connect(b, SIGNAL(changed(const QColor &)), SLOT(slotFGColorSelected(const QColor &)));
QHBoxLayout * h1 = new QHBoxLayout(vl, 0, "strength layout");
QLabel * label = new QLabel(i18n("Paint strength:"), this);
h1 -> addWidget(label);
......
......@@ -31,7 +31,10 @@
#include <qspinbox.h>
#include <qstyle.h>
#include <qtooltip.h>
#include <qwidget.h>
#include <qframe.h>
#include <kcolordialog.h>
#include <klocale.h>
#include <knuminput.h>
#include <koFrameButton.h>
......@@ -41,25 +44,42 @@
#include <kis_color.h>
#include <kis_color_cup.h>
KisColorPopup::KisColorPopup(QColor c, QWidget * parent, const char * name)
: QFrame(parent, name, WType_Popup | WStyle_Customize | WStyle_NoBorder)
{
m_color = c;
setMargin(4);
kdDebug() << "Constructing the color popup\n";
setFocusPolicy(StrongFocus);
QHBoxLayout * l = new QHBoxLayout(this);
l->add(m_khsSelector = new KHSSelector(this));
m_khsSelector->setMinimumSize(140, 7);
l->add(m_valueSelector = new KValueSelector(this));
m_valueSelector->setMinimumSize(26, 70);
m_khsSelector->show();
m_valueSelector->show();
};
KisColorCup::KisColorCup(QWidget * parent, const char * name)
: QPushButton(parent, name)
{
m_color = Qt::black;
m_popup = new KisColorPopup(m_color, this, "colorpopup");
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
connect(m_popup, SIGNAL(changed( const QColor &)), this, SLOT(setColor(const QColor &)));
}
KisColorCup::KisColorCup(const QColor & c, QWidget * parent, const char * name)
: QPushButton(parent, name)
void KisColorCup::setColor(const QColor & c)
{
m_color = c;
connect(this, SIGNAL(clicked()), this, SLOT(slotClicked()));
emit changed(c);
}
void KisColorCup::slotClicked()
{
emit changed(m_color);
{
m_popup->move(this->mapToGlobal( this->rect().topRight() ) );
m_popup->show();
}
QSize KisColorCup::sizeHint() const
......
......@@ -19,13 +19,38 @@
#ifndef KIS_COLOR_CUP_H
#define KIS_COLOR_CUP_H
#include "qpushbutton.h"
#include "qcolor.h"
#include <qpushbutton.h>
#include <qcolor.h>
#include <qframe.h>
#include <koffice_export.h>
class QSize;
class QPainter;
class QWidget;
class KHSSelector;
class KValueSelector;
class KisColorPopup : public QFrame {
Q_OBJECT;
public:
KisColorPopup(QColor color, QWidget * w, const char * name);
virtual ~KisColorPopup() {};
signals:
void changed(const QColor &);
private:
KHSSelector * m_khsSelector;
KValueSelector * m_valueSelector;
QColor m_color;
};
class KisColorCup : public QPushButton {
......@@ -34,11 +59,11 @@ class KisColorCup : public QPushButton {
public:
KisColorCup(QWidget * parent, const char * name = 0);
KisColorCup(const QColor & c, QWidget * parent, const char * name = 0);
virtual ~KisColorCup() {};
void setColor(const QColor & c) {m_color = c; };
QColor color() { return m_color; };
signals:
void changed(const QColor &);
......@@ -47,8 +72,13 @@ public:
QSize sizeHint() const;
private slots:
public slots:
void setColor(const QColor & c);
private slots:
void slotClicked();
protected:
......@@ -57,6 +87,7 @@ protected:
private:
KisColorPopup * m_popup;
QColor m_color;
};
......
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