Commit 43059bce authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Make composite ops appear in a fixed, sensible order in the gui

* Rename the method to get the composite ops from the colorspace: it returns all comp ops, not just the user-visible
  ones.
* rename the grayscale-without-alpha-channel colorspace plugin directories to avoid confusion (my confusion, mostly)

svn path=/trunk/koffice/; revision=750701
parent c92b7826
#add_subdirectory( rgb_f32 )
#add_subdirectory( lms_f32 )
#add_subdirectory( wet )
add_subdirectory( rgb_float_hdr )
add_subdirectory( gray_u8 )
add_subdirectory( gray_u16 )
add_subdirectory( gray_u8_no_alpha )
add_subdirectory( gray_u16_no_alpa )
add_subdirectory( xyz_u16 )
add_subdirectory( xyz_float_hdr )
add_subdirectory( ycbcr )
......
......@@ -372,7 +372,7 @@ void KisLmsF32ColorSpace::bitBlt(quint8 *dst,
}
}
KoCompositeOpList KisLmsF32ColorSpace::userVisiblecompositeOps() const
KoCompositeOpList KisLmsF32ColorSpace::compositeOps() const
{
KoCompositeOpList list;
......
......@@ -69,7 +69,7 @@ public:
qint32 renderingIntent,
float exposure = 0.0f);
virtual KoCompositeOpList userVisiblecompositeOps() const;
virtual KoCompositeOpList compositeOps() const;
protected:
......
......@@ -680,7 +680,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
}
// XXX: Move this averaging code into the colorspace
if (maxDistance > 3. * antiAliasThreshold*antiAliasThreshold) {
if (maxDistance > 3. * antiAliasThreshold * antiAliasThreshold) {
const int numSamples = 4;
QVector<quint32> channelTotals(colorSpace->channelCount());
......
......@@ -367,7 +367,7 @@ QWidget* KisToolGradient::createOptionWidget()
m_slAntiAliasThreshold = new KDoubleNumInput(widget);
m_slAntiAliasThreshold->setObjectName("threshold_slider");
m_slAntiAliasThreshold->setRange( 0, 1);
m_slAntiAliasThreshold->setRange( 0, 1, 0.01);
m_slAntiAliasThreshold->setValue(m_antiAliasThreshold);
connect(m_slAntiAliasThreshold, SIGNAL(valueChanged(double)), this, SLOT(slotSetAntiAliasThreshold(double)));
......
......@@ -25,6 +25,8 @@
#include <KoCompositeOp.h>
#include "kis_cmb_composite.h"
static QStringList opsInOrder;
KisCmbComposite::KisCmbComposite(QWidget * parent, const char * name)
: QComboBox(parent)
{
......@@ -32,6 +34,46 @@ KisCmbComposite::KisCmbComposite(QWidget * parent, const char * name)
setEditable(false);
connect(this, SIGNAL(activated(int)), this, SLOT(slotOpActivated(int)));
connect(this, SIGNAL(highlighted(int)), this, SLOT(slotOpHighlighted(int)));
if (opsInOrder.isEmpty()) {
opsInOrder <<
COMPOSITE_OVER <<
COMPOSITE_ERASE <<
COMPOSITE_COPY <<
COMPOSITE_ALPHA_DARKEN <<
COMPOSITE_IN <<
COMPOSITE_OUT <<
COMPOSITE_ATOP <<
COMPOSITE_XOR <<
COMPOSITE_PLUS <<
COMPOSITE_MINUS <<
COMPOSITE_ADD <<
COMPOSITE_SUBTRACT <<
COMPOSITE_DIFF <<
COMPOSITE_MULT <<
COMPOSITE_DIVIDE <<
COMPOSITE_DODGE <<
COMPOSITE_BURN <<
COMPOSITE_BUMPMAP <<
COMPOSITE_CLEAR <<
COMPOSITE_DISSOLVE <<
COMPOSITE_DISPLACE <<
COMPOSITE_NO <<
COMPOSITE_DARKEN <<
COMPOSITE_LIGHTEN <<
COMPOSITE_HUE <<
COMPOSITE_SATURATION <<
COMPOSITE_VALUE <<
COMPOSITE_COLOR <<
COMPOSITE_COLORIZE <<
COMPOSITE_LUMINIZE <<
COMPOSITE_SCREEN <<
COMPOSITE_OVERLAY <<
COMPOSITE_UNDEF <<
COMPOSITE_COPY_RED <<
COMPOSITE_COPY_GREEN <<
COMPOSITE_COPY_BLUE <<
COMPOSITE_COPY_OPACITY;
}
}
KisCmbComposite::~KisCmbComposite()
......@@ -41,10 +83,30 @@ KisCmbComposite::~KisCmbComposite()
void KisCmbComposite::setCompositeOpList(const QList<KoCompositeOp*> & list)
{
QComboBox::clear();
m_list = list;
for(int i = 0; i < m_list.count(); ++i)
addItem(m_list.at(i)->description());
m_list.clear();
// First, insert all composite ops that we know about, in a nice order.
foreach (QString id, opsInOrder) {
foreach (KoCompositeOp* op, list) {
if ( op->id() == id ) {
m_list.append(op);
addItem(op->description());
}
}
}
// Then check for all given composite ops whether they are already inserted, and if not, add them at the end.
foreach(KoCompositeOp* op1, list) {
bool found = false;
foreach(KoCompositeOp* op2, m_list) {
if (op1->id() == op2->id()) {
found = true;
}
}
if (!found && op1->userVisible()) {
m_list.append(op1);
addItem(op1->description());
}
}
}
KoCompositeOp * KisCmbComposite::currentItem() const
......@@ -57,9 +119,13 @@ KoCompositeOp * KisCmbComposite::currentItem() const
void KisCmbComposite::setCurrent(const KoCompositeOp* op)
{
qint32 index = m_list.indexOf(const_cast<KoCompositeOp*>( op ));
if (index >= 0) {
int index = 0;
foreach( KoCompositeOp * op2, m_list) {
if (op->id() == op2->id())
break;
++index;
}
if (index >= 0 && index < m_list.size() ) {
QComboBox::setCurrentIndex(index);
}
}
......
......@@ -26,14 +26,8 @@
#include "KoCompositeOp.h"
/**
* A combobox filled with the various composition strategies defined in kis_global.
*
* XXX: devise some kind of capabilities database for the various color strategies
*
* enum constant Description CMYK RGBA GRAYA
* 1 COMPOSITE_OVER Over X - X
*
* But that's for later...
* A combobox filled with the various composition strategies
* associated with a certain colorspace.
*/
class KRITAUI_EXPORT KisCmbComposite : public QComboBox
......
......@@ -81,7 +81,7 @@ KisDlgLayerProperties::KisDlgLayerProperties(const QString& deviceName,
m_page->intOpacity->setRange(0, 100, 13);
m_page->intOpacity->setValue(opacity);
m_page->cmbComposite->setCompositeOpList(colorSpace->userVisiblecompositeOps());
m_page->cmbComposite->setCompositeOpList(colorSpace->compositeOps());
m_page->cmbComposite->setCurrent(compositeOp);
slotNameChanged( m_page->editName->text() );
......
......@@ -114,7 +114,7 @@ void NewLayerDialog::fillCmbComposite(const KoID & s)
const KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace(s,"");
if (cs) {
m_page->cmbComposite->setCompositeOpList(cs->userVisiblecompositeOps());
m_page->cmbComposite->setCompositeOpList(cs->compositeOps());
}
}
......
......@@ -222,6 +222,7 @@ void KisLayerBox::updateUI()
if (active->inherits("KisLayer")) {
KisLayerSP l = qobject_cast<KisLayer*>(active.data());
slotSetOpacity(l->opacity() * 100.0 / 255);
kDebug() << "############## compositeOp: " << l->compositeOp()->id();
slotSetCompositeOp(l->compositeOp());
}
}
......@@ -237,6 +238,7 @@ void KisLayerBox::setCurrentNode( KisNodeSP node )
void KisLayerBox::slotSetCompositeOp(const KoCompositeOp* compositeOp)
{
kDebug() << "slotSetCompositeOp: " << compositeOp->id();
cmbComposite->blockSignals(true);
cmbComposite->setCurrent(compositeOp);
cmbComposite->blockSignals(false);
......@@ -245,7 +247,7 @@ void KisLayerBox::slotSetCompositeOp(const KoCompositeOp* compositeOp)
void KisLayerBox::slotSetColorSpace(const KoColorSpace * colorSpace)
{
cmbComposite->blockSignals(true);
cmbComposite->setCompositeOpList(colorSpace->userVisiblecompositeOps());
cmbComposite->setCompositeOpList(colorSpace->compositeOps());
cmbComposite->blockSignals(false);
}
......
......@@ -194,7 +194,7 @@ void KisToolPaint::updateCompositeOpComboBox()
KisPaintDeviceSP device = currentLayer()->paintDevice();
if (device) {
QList<KoCompositeOp*> compositeOps = device->colorSpace()->userVisiblecompositeOps();
QList<KoCompositeOp*> compositeOps = device->colorSpace()->compositeOps();
m_cmbComposite->setCompositeOpList(compositeOps);
if (m_compositeOp == 0 || compositeOps.indexOf(const_cast<KoCompositeOp*>(m_compositeOp)) < 0) {
......
......@@ -145,7 +145,7 @@ quint8 *KoColorSpace::allocPixelBuffer(quint32 numPixels) const
return new quint8[pixelSize()*numPixels];
}
QList<KoCompositeOp*> KoColorSpace::userVisiblecompositeOps() const
QList<KoCompositeOp*> KoColorSpace::compositeOps() const
{
return d->compositeOps.values();
}
......@@ -183,6 +183,7 @@ const KoColorConversionTransformation* KoColorSpace::toLabA16Converter() const
}
return d->transfoToLABA16;
}
const KoColorConversionTransformation* KoColorSpace::fromLabA16Converter() const
{
if(not d->transfoFromLABA16)
......
......@@ -280,7 +280,7 @@ public:
/**
* Returns the list of user-visible composite ops supported by this colorspace.
*/
virtual QList<KoCompositeOp*> userVisiblecompositeOps() const;
virtual QList<KoCompositeOp*> compositeOps() const;
/**
* Retrieve a single composite op from the ones this colorspace offers.
......@@ -521,9 +521,10 @@ public:
*/
virtual KoColorTransformation *createInvertTransformation() const = 0;
// XXX: What with alpha channels? YYY: Add an overloaded function that takes alpha into account?
/**
* Get the difference between 2 colors, normalized in the range (0,255)
* Get the difference between 2 colors, normalized in the range (0,255). Only completely
* opaque and completely transparent are taken into account when computing the different;
* other transparency levels are not regarded when finding the difference.
*/
virtual quint8 difference(const quint8* src1, const quint8* src2) const = 0;
......@@ -653,7 +654,7 @@ public:
/**
* The backgroundfilters will be run periodically on the newly
* created paint device. XXX: Currently this uses times and not
* created paint device. XXX: Currently this uses timers and not
* threads.
*/
virtual QList<KisFilter*> createBackgroundFilters() const
......
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