Commit 3aa25e8b authored by Casper Boemann's avatar Casper Boemann

Further work on the UniColorChooser:

Let the number inputs work too.
Introduce the concept of current color - you can now paint with it!
Make sure the slider and xy are updated when you select another 
channel or enter values.


svn path=/trunk/koffice/; revision=551352
parent 8247325e
......@@ -17,6 +17,7 @@ set(kopainter_LIB_SRCS
ko_gray_widget.cc
ko_hsv_widget.cc
KoUniColorChooser.cpp
KoColorPatch.cpp
ko_rgb_widget.cc )
kde4_automoc(${kopainter_LIB_SRCS})
......
/**
* Copyright (c) 2006 Casper Boemann (cbr@boemann.dk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <QPainter>
#include "KoColorPatch.h"
KoColorPatch::KoColorPatch( QWidget *parent ) : QFrame( parent )
{
setFrameStyle( QFrame::Panel | QFrame::Sunken );
}
KoColorPatch::~KoColorPatch()
{
}
void KoColorPatch::setColor(const KoColor c)
{
m_color = c;
update();
}
void KoColorPatch::paintEvent ( QPaintEvent* pe )
{
QColor qc;
m_color.toQColor(&qc);
QFrame::paintEvent(pe);
QPainter painter( this );
painter.setPen(qc);
painter.setBrush(QBrush(qc));
painter.drawRect(contentsRect());
}
#include "KoColorPatch.moc"
/**
* Copyright (c) 2006 Casper Boemann (cbr@boemann.dk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCOLORPATCH_H
#define KOCOLORPATCH_H
#include <QFrame>
#include <KoColor.h>
/**
* The small widget showing the selected color
*/
class KOPAINTER_EXPORT KoColorPatch : public QFrame
{
Q_OBJECT
public:
KoColorPatch( QWidget *parent );
virtual ~KoColorPatch();
void setColor( const KoColor c );
protected:
virtual void paintEvent ( QPaintEvent * pe );
private:
KoColor m_color;
};
#endif
This diff is collapsed.
......@@ -22,13 +22,14 @@
#include "qwidget.h"
#include <QLabel>
#include <koColor.h>
#include <KoColor.h>
#include <koffice_export.h>
class KValueSelector;
class KoXYColorSelector;
class KoColorSlider;
class KoColorPatch;
class QFrame;
class QLabel;
class QSpinBox;
......@@ -45,10 +46,6 @@ public:
virtual ~KoUniColorChooser() {}
public slots:
/**
* Set the current color to c. Do not emit the color changed signals
*/
virtual void setColor(const QColor & c);
signals:
......@@ -62,27 +59,29 @@ protected slots:
virtual void slotHChanged(int h);
virtual void slotSChanged(int s);
virtual void slotVChanged(int v);
virtual void slotWheelChanged(const KoOldColor& c);
virtual void slotRGBChanged();
virtual void slotRSelected(bool s);
virtual void slotGSelected(bool s);
virtual void slotBSelected(bool s);
virtual void slotSliderChanged(int v);
virtual void slotXYChanged(int u, int v);
void slotSetColor(const QColor& c);
private:
enum ChannelType {CHANNEL_H, CHANNEL_S, CHANNEL_V, CHANNEL_R, CHANNEL_G, CHANNEL_B,CHANNEL_L,CHANNEL_a,CHANNEL_b};
ChannelType m_activeChannel;
KoColor m_currentColor;
void changedFgColor();
void update(const KoOldColor & color);
void announceColor();
void updateValues();
void updateSelectorsR();
void updateSelectorsG();
void updateSelectorsB();
void updateSelectorsCurrent();
KoXYColorSelector *m_xycolorselector;
KoColorSlider *m_colorSlider;
QFrame *m_colorpatch;
KoColorPatch *m_colorpatch;
QLabel *m_HLabel;
QLabel *m_SLabel;
QLabel *m_VLabel;
......@@ -111,9 +110,6 @@ private:
QRadioButton *m_aRB;
QRadioButton *m_bRB;
KoOldColor m_fgColor;
bool m_autovalue;
KoColorSpaceFactoryRegistry* m_csFactoryRegistry;
};
......
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