|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/styleeditor.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/colorfield.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/menubarcommand.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/cleanupcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
shun-iwasawa |
ad7711 |
#include "toonzqt/lutcalibrator.h"
|
|
shun-iwasawa |
6ed8c3 |
#include "styledata.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6ed8c3 |
// Qt includes
|
|
shun-iwasawa |
6ed8c3 |
#include <qapplication></qapplication>
|
|
shun-iwasawa |
6ed8c3 |
#include <qclipboard></qclipboard>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlayout></qlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6ed8c3 |
namespace {
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
void drawChessBoard(QPainter &p) {
|
|
shun-iwasawa |
6ed8c3 |
for (int x = 0; x < 4; x++) {
|
|
shun-iwasawa |
6ed8c3 |
for (int y = 0; y < 4; y++) {
|
|
shun-iwasawa |
6ed8c3 |
QColor col((x + y) % 2 == 0 ? Qt::black : Qt::white);
|
|
shun-iwasawa |
6ed8c3 |
p.fillRect(x * 4, y * 4, 4, 4, col);
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
QPixmap getIconPm(const QColor &color) {
|
|
shun-iwasawa |
6ed8c3 |
QPixmap retPm(16, 16);
|
|
shun-iwasawa |
6ed8c3 |
if (color.alpha() == 255) {
|
|
shun-iwasawa |
6ed8c3 |
retPm.fill(color);
|
|
shun-iwasawa |
6ed8c3 |
return retPm;
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
QPainter p(&retPm);
|
|
shun-iwasawa |
6ed8c3 |
drawChessBoard(p);
|
|
shun-iwasawa |
6ed8c3 |
p.fillRect(0, 0, 16, 16, color);
|
|
shun-iwasawa |
6ed8c3 |
return retPm;
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
} // namespace
|
|
shun-iwasawa |
6ed8c3 |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class DVGui::StyleSample
|
|
Shinya Kitaoka |
120a6e |
\brief The StyleSample class provides to view a square color.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
By default square color is set to \b TPixel32(235,235,235,255),
|
|
Shinya Kitaoka |
120a6e |
you
|
|
Shinya Kitaoka |
120a6e |
can set other color using setColor(); you can also define
|
|
Shinya Kitaoka |
120a6e |
current color
|
|
Shinya Kitaoka |
120a6e |
with a style \b TColorStyle, \b getStyle(), using setStyle().
|
|
Shinya Kitaoka |
120a6e |
You can pass to constructor square size.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
StyleSample permit to manage click event, it's possile to enable
|
|
Shinya Kitaoka |
120a6e |
this
|
|
Shinya Kitaoka |
120a6e |
feature setting enableClick(bool on) to true.
|
|
Shinya Kitaoka |
120a6e |
If it is enable when click in square class emit the signal
|
|
Shinya Kitaoka |
120a6e |
clicked(const TColorStyle &style).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void DVGui::StyleSample::clicked(const TColorStyle &style)
|
|
Shinya Kitaoka |
120a6e |
This signal is emitted when click event is enable and a style is
|
|
Shinya Kitaoka |
120a6e |
set.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void DVGui::StyleSample::enableClick(bool on)
|
|
Shinya Kitaoka |
120a6e |
Set click event enable if \b is true, disable otherwise.
|
|
Shinya Kitaoka |
120a6e |
If true setStyle store current style and buttonPress emit signal
|
|
Shinya Kitaoka |
120a6e |
clicked(const TColorStyle &style).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
StyleSample::StyleSample(QWidget *parent, int sizeX, int sizeY)
|
|
Shinya Kitaoka |
120a6e |
: m_samplePixmap(sizeX, sizeY, QImage::Format_ARGB32)
|
|
Shinya Kitaoka |
120a6e |
, m_bgRas(sizeX, sizeY)
|
|
Shinya Kitaoka |
120a6e |
, m_style(0)
|
|
Shinya Kitaoka |
120a6e |
, m_clickEnabled(false)
|
|
Shinya Kitaoka |
120a6e |
, m_chessColor1(0, 0, 0)
|
|
Shinya Kitaoka |
120a6e |
, m_chessColor2(255, 255, 255)
|
|
Shinya Kitaoka |
120a6e |
, m_isEditing(false) {
|
|
Shinya Kitaoka |
120a6e |
setMinimumSize(sizeX, sizeY);
|
|
Shinya Kitaoka |
120a6e |
setColor(TPixel32::Transparent);
|
|
Shinya Kitaoka |
120a6e |
TRop::checkBoard(m_bgRas, m_chessColor1, m_chessColor2,
|
|
Shinya Kitaoka |
120a6e |
TDimensionD(sizeX / 8, sizeX / 8), TPointD(0, 0));
|
|
Shinya Kitaoka |
120a6e |
setEnable(true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StyleSample::~StyleSample() {
|
|
Shinya Kitaoka |
120a6e |
if (m_style) delete m_style;
|
|
Shinya Kitaoka |
120a6e |
m_style = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Return current StyleSample \b TColorStyle style.
|
|
shun-iwasawa |
a64bad |
*/
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *StyleSample::getStyle() const { return m_style; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Update current square colore and, if click event is enable set current
|
|
Shinya Kitaoka |
120a6e |
StyleSample \b TColorStyle style to \b style.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::setStyle(TColorStyle &style) {
|
|
Shinya Kitaoka |
120a6e |
/*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/
|
|
Shinya Kitaoka |
120a6e |
if (style.getTagId() == 3)
|
|
Shinya Kitaoka |
120a6e |
setColor(style.getMainColor());
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
TRaster32P icon =
|
|
Shinya Kitaoka |
120a6e |
style.getIcon(qsize2Dimension(m_samplePixmap.rect().size()));
|
|
Shinya Kitaoka |
120a6e |
m_samplePixmap = rasterToQImage(icon, false); // modified in 6.2
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_clickEnabled) m_style = style.clone();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Update current square colore to \b TPixel32 \b color.
|
|
Shinya Kitaoka |
120a6e |
Useful for efficiency if click event is disable.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::setColor(const TPixel32 &pixel) {
|
|
Shinya Kitaoka |
120a6e |
QColor color(pixel.r, pixel.g, pixel.b, pixel.m);
|
|
shun-iwasawa |
388550 |
if (LutManager::instance()->isValid()) LutManager::instance()->convert(color);
|
|
shun-iwasawa |
ad7711 |
|
|
Shinya Kitaoka |
120a6e |
m_samplePixmap.fill(color.rgba());
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::setChessboardColors(const TPixel32 &col1,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &col2) {
|
|
Shinya Kitaoka |
120a6e |
m_chessColor1 = col1;
|
|
Shinya Kitaoka |
120a6e |
m_chessColor2 = col2;
|
|
Shinya Kitaoka |
120a6e |
TRop::checkBoard(m_bgRas, m_chessColor1, m_chessColor2,
|
|
Shinya Kitaoka |
120a6e |
TDimensionD(m_bgRas->getLx() / 8, m_bgRas->getLy() / 8),
|
|
Shinya Kitaoka |
120a6e |
TPointD(0, 0));
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Paint square color.
|
|
shun-iwasawa |
a64bad |
*/
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::paintEvent(QPaintEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (!isEnable()) return;
|
|
Shinya Kitaoka |
120a6e |
QPainter painter(this);
|
|
Shinya Kitaoka |
120a6e |
QImage img(m_bgRas->getRawData(), m_bgRas->getLx(), m_bgRas->getLy(),
|
|
Shinya Kitaoka |
120a6e |
QImage::Format_ARGB32);
|
|
Shinya Kitaoka |
120a6e |
painter.drawImage(0, 0, img.scaled(size()));
|
|
Shinya Kitaoka |
120a6e |
painter.drawImage(0, 0, m_samplePixmap.scaled(size()));
|
|
Shinya Kitaoka |
120a6e |
if (m_isEditing) {
|
|
Shinya Kitaoka |
120a6e |
// QRect rect(0,0,m_bgRas->getLx(),m_bgRas->getLy());
|
|
Shinya Kitaoka |
120a6e |
painter.setPen(Qt::white);
|
|
Shinya Kitaoka |
120a6e |
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
|
Shinya Kitaoka |
120a6e |
painter.drawRect(rect().adjusted(2, 2, -3, -3));
|
|
Shinya Kitaoka |
120a6e |
painter.setPen(QColor(180, 210, 255));
|
|
Shinya Kitaoka |
120a6e |
painter.drawRect(rect().adjusted(1, 1, -2, -2));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If exist current style and event click is enable emit signal
|
|
Shinya Kitaoka |
120a6e |
clicked(const TColorStyle &style).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_style && m_clickEnabled)
|
|
Shinya Kitaoka |
120a6e |
emit clicked(*m_style);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
event->ignore();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleSample::mouseDoubleClickEvent(QMouseEvent *event) { event->ignore(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class DVGui::ChannelField
|
|
Shinya Kitaoka |
120a6e |
\brief The ChannelField class is used to view an object to
|
|
Shinya Kitaoka |
120a6e |
manage a color
|
|
Shinya Kitaoka |
120a6e |
value, red, green, blue or transparency
|
|
Shinya Kitaoka |
120a6e |
channel.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
The object is composed of grid layout \b QGridLayout which
|
|
Shinya Kitaoka |
120a6e |
contains a label
|
|
Shinya Kitaoka |
120a6e |
in first row, first column, to identify channel, a text field \b
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit
|
|
Shinya Kitaoka |
120a6e |
in first row, second column, and a slider in second row, second
|
|
Shinya Kitaoka |
120a6e |
column.
|
|
Shinya Kitaoka |
120a6e |
Texf field and slider are connected, so if you change one the
|
|
Shinya Kitaoka |
120a6e |
other automatically
|
|
Shinya Kitaoka |
120a6e |
change. You can set current value getChannel(), using
|
|
Shinya Kitaoka |
120a6e |
setChannel().
|
|
Shinya Kitaoka |
120a6e |
This two object is used to manage channel value, them range is
|
|
Shinya Kitaoka |
120a6e |
fixed to [0,255].
|
|
Shinya Kitaoka |
120a6e |
This object size is fixed, [50, 2*DVGui::WidgetHeight].
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
To know when channel parameter value change class provides a
|
|
Shinya Kitaoka |
120a6e |
signal, valueChanged(int value);
|
|
Shinya Kitaoka |
120a6e |
class emit signal when slider value change or when text field is
|
|
Shinya Kitaoka |
120a6e |
editing,
|
|
Shinya Kitaoka |
120a6e |
see SLOT: onSliderChanged(int value) and onEditChanged(const
|
|
Shinya Kitaoka |
120a6e |
QString &str)
|
|
Shinya Kitaoka |
120a6e |
to know when signal is emitted.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void DVGui::ChannelField::valueChanged(int value)
|
|
Shinya Kitaoka |
120a6e |
This signal is emitted when ChannelField, slider or text field,
|
|
Shinya Kitaoka |
120a6e |
value change;
|
|
Shinya Kitaoka |
120a6e |
if slider position change or text field is editing.
|
|
Shinya Kitaoka |
120a6e |
\sa onEditChanged(const QString &str) and onSliderChanged(int
|
|
Shinya Kitaoka |
120a6e |
value).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
ChannelField::ChannelField(QWidget *parent, const QString &string, int value,
|
|
Shinya Kitaoka |
120a6e |
int maxValue, bool horizontal, int labelWidth,
|
|
Shinya Kitaoka |
120a6e |
int sliderWidth)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent), m_maxValue(maxValue) {
|
|
Shinya Kitaoka |
120a6e |
assert(maxValue > 0);
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= value && value <= m_maxValue);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QLabel *channelName = new QLabel(string, this);
|
|
Shinya Kitaoka |
120a6e |
m_channelEdit = new DVGui::IntLineEdit(this, value, 0, maxValue);
|
|
Shinya Kitaoka |
120a6e |
m_channelSlider = new QSlider(Qt::Horizontal, this);
|
|
Jeremy Bullock |
372fca |
m_channelSlider->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
channelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
Shinya Kitaoka |
120a6e |
channelName->setFixedWidth(labelWidth);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_channelSlider->setRange(0, maxValue);
|
|
Shinya Kitaoka |
120a6e |
m_channelSlider->setValue(value);
|
|
shun-iwasawa |
cd4694 |
if (sliderWidth > 0) m_channelSlider->setFixedWidth(sliderWidth);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----layout
|
|
Shinya Kitaoka |
120a6e |
QGridLayout *mainLayout = new QGridLayout(this);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(3);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(channelName, 0, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_channelEdit, 0, 1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_channelSlider, horizontal ? 0 : 1,
|
|
Shinya Kitaoka |
120a6e |
horizontal ? 2 : 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setColumnStretch(0, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setColumnStretch(1, 1);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setRowStretch(2, 1);
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//----singnal-slot connections
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(m_channelEdit, SIGNAL(textChanged(const QString &)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onEditChanged(const QString &)));
|
|
shun-iwasawa |
a64bad |
ret = ret && connect(m_channelEdit, SIGNAL(editingFinished()),
|
|
shun-iwasawa |
a64bad |
SLOT(onEditFinished()));
|
|
shun-iwasawa |
a64bad |
ret = ret && connect(m_channelSlider, SIGNAL(valueChanged(int)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSliderChanged(int)));
|
|
shun-iwasawa |
a64bad |
ret = ret && connect(m_channelSlider, SIGNAL(sliderReleased()),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSliderReleased()));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set current value to \b value.
|
|
Shinya Kitaoka |
120a6e |
\sa getChannel()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ChannelField::setChannel(int value) {
|
|
Shinya Kitaoka |
120a6e |
if (getChannel() == value) return;
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= value && value <= m_maxValue);
|
|
Shinya Kitaoka |
120a6e |
m_channelSlider->setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_channelEdit->setValue(value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Return current channel value.
|
|
Shinya Kitaoka |
120a6e |
\sa setChannel()
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
int ChannelField::getChannel() {
|
|
Shinya Kitaoka |
120a6e |
int value = m_channelEdit->getValue();
|
|
Shinya Kitaoka |
120a6e |
assert(m_channelSlider->value() == value);
|
|
Shinya Kitaoka |
120a6e |
return value;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set slider value to new string \b str value.
|
|
Shinya Kitaoka |
120a6e |
Verify if value is lower than 255 or greater than 0, range,
|
|
Shinya Kitaoka |
120a6e |
otherwise set
|
|
Shinya Kitaoka |
120a6e |
current value to 255 or 0. If slider value is different from
|
|
Shinya Kitaoka |
120a6e |
value in \b str
|
|
Shinya Kitaoka |
120a6e |
emit signal valueChanged(int value).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ChannelField::onEditChanged(const QString &str) {
|
|
shun-iwasawa |
a64bad |
int value = str.toInt();
|
|
shun-iwasawa |
a64bad |
if (value < 0) value = 0;
|
|
Shinya Kitaoka |
120a6e |
if (value > m_maxValue) value = m_maxValue;
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= value && value <= m_maxValue);
|
|
Shinya Kitaoka |
120a6e |
if (str.toInt() != value) m_channelEdit->setValue(value);
|
|
Shinya Kitaoka |
120a6e |
if (m_channelSlider->value() == value) return;
|
|
Shinya Kitaoka |
120a6e |
m_channelSlider->setValue(value);
|
|
shun-iwasawa |
a64bad |
emit valueChanged(value, true);
|
|
shun-iwasawa |
a64bad |
}
|
|
shun-iwasawa |
a64bad |
|
|
shun-iwasawa |
a64bad |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
a64bad |
|
|
shun-iwasawa |
a64bad |
void ChannelField::onEditFinished() {
|
|
shun-iwasawa |
a64bad |
emit valueChanged(m_channelEdit->getValue(), false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! Set text field value to \b value. If text field value is different from \b
|
|
Shinya Kitaoka |
120a6e |
value
|
|
Shinya Kitaoka |
120a6e |
emit signal valueChanged(int value).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ChannelField::onSliderChanged(int value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= value && value <= m_maxValue);
|
|
Shinya Kitaoka |
120a6e |
if (m_channelEdit->getValue() == value) return;
|
|
Shinya Kitaoka |
120a6e |
m_channelEdit->setText(QString(std::to_string(value).c_str()));
|
|
Shinya Kitaoka |
120a6e |
emit valueChanged(value, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ChannelField::onSliderReleased() {
|
|
Shinya Kitaoka |
120a6e |
emit valueChanged(m_channelSlider->value(), false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ColorField::ColorFieldEditorController *ColorField::m_editorController = 0;
|
|
Shinya Kitaoka |
120a6e |
// new
|
|
Shinya Kitaoka |
38fd86 |
// ColorField::ColorFieldEditorController();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class DVGui::ColorField
|
|
Shinya Kitaoka |
120a6e |
\brief The ColorField class is used to view an object to manage
|
|
Shinya Kitaoka |
120a6e |
a color.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
The object is composed of a horizontal layout \b QHBoxLayout
|
|
Shinya Kitaoka |
120a6e |
which contains
|
|
Shinya Kitaoka |
120a6e |
a StyleSample, and three or four ChannelField, it depend if
|
|
Shinya Kitaoka |
120a6e |
transparency is
|
|
Shinya Kitaoka |
120a6e |
count, to manage color channel.
|
|
Shinya Kitaoka |
120a6e |
You can pass to constructor current color value, getColor(), or
|
|
Shinya Kitaoka |
120a6e |
set it
|
|
Shinya Kitaoka |
120a6e |
calling setColor(). You can also pass to constructor a boolean
|
|
Shinya Kitaoka |
120a6e |
to know if
|
|
Shinya Kitaoka |
120a6e |
manage transparency channel or not, and an integer for
|
|
Shinya Kitaoka |
120a6e |
StyleSample size.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
To know when color value change class provides a signal,
|
|
Shinya Kitaoka |
120a6e |
colorChanged(const TPixel32 &);
|
|
Shinya Kitaoka |
120a6e |
class emit signal when one ChannelField value change.
|
|
Shinya Kitaoka |
120a6e |
See SLOT: onRedChannelChanged(int value),
|
|
Shinya Kitaoka |
120a6e |
onGreenChannelChanged(int value),
|
|
Shinya Kitaoka |
120a6e |
onBlueChannelChanged(int value) and onAlphaChannelChanged(int
|
|
Shinya Kitaoka |
120a6e |
value) to know
|
|
Shinya Kitaoka |
120a6e |
when signal is emitted.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\b Example: initialize a ColorField with transparency channel.
|
|
Shinya Kitaoka |
120a6e |
\code
|
|
Shinya Kitaoka |
120a6e |
ColorField* colorFld = new
|
|
Shinya Kitaoka |
120a6e |
ColorField(0,true,TPixel32(0,0,255,255),50);
|
|
Shinya Kitaoka |
120a6e |
\endcode
|
|
Shinya Kitaoka |
120a6e |
\b Result:
|
|
Shinya Kitaoka |
120a6e |
\image html ColorField.jpg
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn void DVGui::ColorField::colorChanged(const TPixel32 &)
|
|
Shinya Kitaoka |
120a6e |
This signal is emitted when a channel value of current color
|
|
Shinya Kitaoka |
120a6e |
change.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
/*! \fn TPixel32 DVGui::ColorField::getColor() const
|
|
Shinya Kitaoka |
120a6e |
Return ColorField current color.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
ColorField::ColorField(QWidget *parent, bool isAlphaActive, TPixel32 color,
|
|
shun-iwasawa |
cd4694 |
int squareSize, bool useStyleEditor, int sliderWidth)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_color(color)
|
|
Shinya Kitaoka |
120a6e |
, m_notifyEditingChange(true)
|
|
Shinya Kitaoka |
120a6e |
, m_useStyleEditor(useStyleEditor) {
|
|
Shinya Kitaoka |
120a6e |
setMaximumHeight(squareSize);
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *layout = new QHBoxLayout(this);
|
|
Shinya Kitaoka |
120a6e |
layout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
layout->setSpacing(5);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int h = WidgetHeight;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_colorSample = new StyleSample(this, squareSize, squareSize);
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
shun-iwasawa |
cd4694 |
m_redChannel =
|
|
shun-iwasawa |
cd4694 |
new ChannelField(this, tr("R:"), m_color.r, 255, false, 13, sliderWidth);
|
|
Shinya Kitaoka |
120a6e |
connect(m_redChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onRedChannelChanged(int, bool)));
|
|
shun-iwasawa |
cd4694 |
m_greenChannel =
|
|
shun-iwasawa |
cd4694 |
new ChannelField(this, tr("G:"), m_color.g, 255, false, 13, sliderWidth);
|
|
Shinya Kitaoka |
120a6e |
connect(m_greenChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onGreenChannelChanged(int, bool)));
|
|
shun-iwasawa |
cd4694 |
m_blueChannel =
|
|
shun-iwasawa |
cd4694 |
new ChannelField(this, tr("B:"), m_color.b, 255, false, 13, sliderWidth);
|
|
Shinya Kitaoka |
120a6e |
connect(m_blueChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onBlueChannelChanged(int, bool)));
|
|
shun-iwasawa |
cd4694 |
m_alphaChannel =
|
|
shun-iwasawa |
cd4694 |
new ChannelField(this, tr("A:"), m_color.m, 255, false, 13, sliderWidth);
|
|
Shinya Kitaoka |
120a6e |
connect(m_alphaChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onAlphaChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_colorSample);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_redChannel);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_greenChannel);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_blueChannel);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_alphaChannel);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!isAlphaActive) m_alphaChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
setLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set ColorField current color to \b color. Update channel value of
|
|
Shinya Kitaoka |
120a6e |
\b ChannelField and \b StyleSample color.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::setAlphaActive(bool active) {
|
|
Shinya Kitaoka |
120a6e |
if (active && !m_alphaChannel->isVisible()) {
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->show();
|
|
Shinya Kitaoka |
120a6e |
connect(m_alphaChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onAlphaChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
assert(m_color.m == 255);
|
|
turtletooth |
21dab2 |
m_alphaChannel->setChannel(0);
|
|
turtletooth |
21dab2 |
m_color.m = 0;
|
|
turtletooth |
21dab2 |
m_colorSample->setColor(m_color);
|
|
turtletooth |
21dab2 |
emit colorChanged(m_color, false);
|
|
Shinya Kitaoka |
120a6e |
} else if (!active && m_alphaChannel->isVisible()) {
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_alphaChannel, SIGNAL(valueChanged(int, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onAlphaChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
if (m_color.m != 255) {
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->setChannel(255);
|
|
Shinya Kitaoka |
120a6e |
m_color.m = 255;
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::setColor(const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (m_color == color) return;
|
|
Shinya Kitaoka |
120a6e |
m_color = color;
|
|
Shinya Kitaoka |
120a6e |
updateChannels();
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set all \b ChannelField channel value to ColorField current color.
|
|
shun-iwasawa |
a64bad |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::hideChannelsFields(bool hide) {
|
|
Shinya Kitaoka |
120a6e |
if (hide) {
|
|
Shinya Kitaoka |
120a6e |
m_redChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_greenChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_blueChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->hide();
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_redChannel, SIGNAL(valueChanged(int, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onRedChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_greenChannel, SIGNAL(valueChanged(int, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onGreenChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_blueChannel, SIGNAL(valueChanged(int, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onBlueChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
disconnect(m_alphaChannel, SIGNAL(valueChanged(int, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onAlphaChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
m_redChannel->show();
|
|
Shinya Kitaoka |
120a6e |
m_greenChannel->show();
|
|
Shinya Kitaoka |
120a6e |
m_blueChannel->show();
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->show();
|
|
Shinya Kitaoka |
120a6e |
;
|
|
Shinya Kitaoka |
120a6e |
connect(m_redChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onRedChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_greenChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onGreenChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_blueChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onBlueChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_alphaChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onAlphaChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set all \b ChannelField channel value to ColorField current color.
|
|
shun-iwasawa |
a64bad |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::updateChannels() {
|
|
Shinya Kitaoka |
120a6e |
m_redChannel->setChannel(m_color.r);
|
|
Shinya Kitaoka |
120a6e |
m_greenChannel->setChannel(m_color.g);
|
|
Shinya Kitaoka |
120a6e |
m_blueChannel->setChannel(m_color.b);
|
|
Shinya Kitaoka |
120a6e |
m_alphaChannel->setChannel(m_color.m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (event->button() != Qt::LeftButton) return;
|
|
Shinya Kitaoka |
120a6e |
QPoint p = event->pos();
|
|
Shinya Kitaoka |
120a6e |
if (!m_colorSample->visibleRegion().contains(p)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_useStyleEditor || !getEditorController()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->edit(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QPoint p = event->pos();
|
|
Shinya Kitaoka |
120a6e |
if (!m_colorSample->visibleRegion().contains(p)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_useStyleEditor || !getEditorController()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->execute("MI_OpenStyleControl");
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->edit(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::hideEvent(QHideEvent *) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_useStyleEditor || !getEditorController()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->hide();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
void ColorField::contextMenuEvent(QContextMenuEvent *event) {
|
|
shun-iwasawa |
6ed8c3 |
bool hasColor = QApplication::clipboard()->mimeData()->hasColor();
|
|
shun-iwasawa |
6ed8c3 |
const StyleData *data =
|
|
shun-iwasawa |
6ed8c3 |
dynamic_cast<const *="" styledata="">(QApplication::clipboard()->mimeData());</const>
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
QMenu menu(this);
|
|
shun-iwasawa |
6ed8c3 |
if (hasColor) { // pasting QColor
|
|
shun-iwasawa |
6ed8c3 |
QColor color = qvariant_cast<qcolor>(</qcolor>
|
|
shun-iwasawa |
6ed8c3 |
QApplication::clipboard()->mimeData()->colorData());
|
|
shun-iwasawa |
6ed8c3 |
QAction *action = new QAction(tr("Paste Color"), this);
|
|
shun-iwasawa |
6ed8c3 |
action->setIcon(QIcon(getIconPm(color)));
|
|
shun-iwasawa |
6ed8c3 |
action->setData(color);
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
connect(action, SIGNAL(triggered()), this, SLOT(onPasteColor()));
|
|
shun-iwasawa |
6ed8c3 |
menu.addAction(action);
|
|
shun-iwasawa |
6ed8c3 |
menu.addSeparator();
|
|
shun-iwasawa |
6ed8c3 |
} else if (data && data->getStyleCount() > 0) { // pasting styles colors
|
|
shun-iwasawa |
6ed8c3 |
// show 10 styles in maximum
|
|
shun-iwasawa |
6ed8c3 |
int styleCount = std::min(10, data->getStyleCount());
|
|
shun-iwasawa |
6ed8c3 |
for (int i = 0; i < styleCount; i++) {
|
|
shun-iwasawa |
6ed8c3 |
QString styleName = QString::fromStdWString(data->getStyle(i)->getName());
|
|
shun-iwasawa |
6ed8c3 |
TPixel32 color = data->getStyle(i)->getMainColor();
|
|
shun-iwasawa |
6ed8c3 |
QColor _color(color.r, color.g, color.b, color.m);
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
QAction *action =
|
|
shun-iwasawa |
6ed8c3 |
new QAction(tr("Paste Color of %1").arg(styleName), this);
|
|
shun-iwasawa |
6ed8c3 |
action->setIcon(QIcon(getIconPm(_color)));
|
|
shun-iwasawa |
6ed8c3 |
action->setData(_color);
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
connect(action, SIGNAL(triggered()), this, SLOT(onPasteColor()));
|
|
shun-iwasawa |
6ed8c3 |
menu.addAction(action);
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
menu.addSeparator();
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
QAction *copyAction = new QAction(tr("Copy Color"), this);
|
|
shun-iwasawa |
6ed8c3 |
connect(copyAction, SIGNAL(triggered()), this, SLOT(onCopyColor()));
|
|
shun-iwasawa |
6ed8c3 |
menu.addAction(copyAction);
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
menu.exec(event->globalPos());
|
|
shun-iwasawa |
6ed8c3 |
event->accept();
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current red channel value of color is different from \b value set it,
|
|
Shinya Kitaoka |
120a6e |
change \b StyleSample color and emit signal \b
|
|
Shinya Kitaoka |
120a6e |
colorChanged(const TPixel32 &).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::onRedChannelChanged(int value, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (m_color.r == value) {
|
|
Shinya Kitaoka |
120a6e |
if (!isDragging) emit colorChanged(m_color, isDragging);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_color = TPixel32(value, m_color.g, m_color.b, m_color.m);
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current green channel value of color is different from \b value set it,
|
|
Shinya Kitaoka |
120a6e |
change \b StyleSample color and emit signal \b
|
|
Shinya Kitaoka |
120a6e |
colorChanged(const TPixel32 &).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::onGreenChannelChanged(int value, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (m_color.g == value) {
|
|
Shinya Kitaoka |
120a6e |
if (!isDragging) emit colorChanged(m_color, isDragging);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_color = TPixel32(m_color.r, value, m_color.b, m_color.m);
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current blue channel value of color is different from \b value set it,
|
|
Shinya Kitaoka |
120a6e |
change \b StyleSample color and emit signal \b
|
|
Shinya Kitaoka |
120a6e |
colorChanged(const TPixel32 &).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::onBlueChannelChanged(int value, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (m_color.b == value) {
|
|
Shinya Kitaoka |
120a6e |
if (!isDragging) emit colorChanged(m_color, isDragging);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_color = TPixel32(m_color.r, m_color.g, value, m_color.m);
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! If current alpha channel value of color is different from \b value set it,
|
|
Shinya Kitaoka |
120a6e |
change \b StyleSample color and emit signal \b
|
|
Shinya Kitaoka |
120a6e |
colorChanged(const TPixel32 &).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void ColorField::onAlphaChannelChanged(int value, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (m_color.m == value) {
|
|
Shinya Kitaoka |
120a6e |
if (!isDragging) emit colorChanged(m_color, isDragging);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_color = TPixel32(m_color.r, m_color.g, m_color.b, value);
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6ed8c3 |
void ColorField::onPasteColor() {
|
|
shun-iwasawa |
6ed8c3 |
QColor color = qobject_cast<qaction *="">(sender())->data().value<qcolor>();</qcolor></qaction>
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
m_color = TPixel32(color.red(), color.green(), color.blue(), color.alpha());
|
|
shun-iwasawa |
6ed8c3 |
if (!m_alphaChannel->isVisible()) m_color.m = 255;
|
|
shun-iwasawa |
6ed8c3 |
m_colorSample->setColor(m_color);
|
|
shun-iwasawa |
6ed8c3 |
updateChannels();
|
|
shun-iwasawa |
6ed8c3 |
emit colorChanged(m_color, false);
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
void ColorField::onCopyColor() {
|
|
shun-iwasawa |
6ed8c3 |
QColor color(m_color.r, m_color.g, m_color.b, m_color.m);
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
QMimeData *data = new QMimeData();
|
|
shun-iwasawa |
6ed8c3 |
data->setColorData(color);
|
|
shun-iwasawa |
6ed8c3 |
QApplication::clipboard()->setMimeData(data);
|
|
shun-iwasawa |
6ed8c3 |
}
|
|
shun-iwasawa |
6ed8c3 |
|
|
shun-iwasawa |
6ed8c3 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
6ed8c3 |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::setChessboardColors(const TPixel32 &col1,
|
|
Shinya Kitaoka |
120a6e |
const TPixel32 &col2) {
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setChessboardColors(col1, col2);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorField::setEditorController(
|
|
Shinya Kitaoka |
120a6e |
ColorFieldEditorController *editorController) {
|
|
Shinya Kitaoka |
120a6e |
m_editorController = editorController;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ColorField::ColorFieldEditorController *ColorField::getEditorController() {
|
|
Shinya Kitaoka |
120a6e |
return m_editorController;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#define SQUARESIZE 50
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onBrightnessChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setBrightness(value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onContrastChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setContrast(value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onCThresholdChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
((TBlackCleanupStyle *)m_cleanupStyle)->setColorThreshold((double)value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onWThresholdChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
((TBlackCleanupStyle *)m_cleanupStyle)->setWhiteThreshold((double)value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onHRangeChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
((TColorCleanupStyle *)m_cleanupStyle)->setHRange(value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::onLineWidthChannelChanged(int value, bool dragging) {
|
|
Shinya Kitaoka |
120a6e |
((TColorCleanupStyle *)m_cleanupStyle)->setLineWidth(value);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(dragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (event->button() != Qt::LeftButton) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
emit StyleSelected(m_cleanupStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (getEditorController()) getEditorController()->edit(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
CleanupColorField::CleanupColorField(QWidget *parent,
|
|
Shinya Kitaoka |
120a6e |
TCleanupStyle *cleanupStyle,
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *ph, bool greyMode)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_style(cleanupStyle)
|
|
Shinya Kitaoka |
120a6e |
, m_cleanupStyle(cleanupStyle)
|
|
Shinya Kitaoka |
120a6e |
, m_ph(ph)
|
|
Shinya Kitaoka |
120a6e |
, m_greyMode(greyMode)
|
|
Shinya Kitaoka |
120a6e |
, m_notifyEditingChange(true) {
|
|
Shinya Kitaoka |
120a6e |
TBlackCleanupStyle *bs = dynamic_cast<tblackcleanupstyle *="">(cleanupStyle);</tblackcleanupstyle>
|
|
Shinya Kitaoka |
120a6e |
TColorCleanupStyle *cs = dynamic_cast<tcolorcleanupstyle *="">(cleanupStyle);</tcolorcleanupstyle>
|
|
Shinya Kitaoka |
120a6e |
assert(bs || cs);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_colorSample = new StyleSample(this, SQUARESIZE / 2, SQUARESIZE);
|
|
Shinya Kitaoka |
120a6e |
m_brightnessChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("Brightness:"),
|
|
Shinya Kitaoka |
120a6e |
cleanupStyle->getBrightness(), 100, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
m_contrastChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("Contrast:"),
|
|
Shinya Kitaoka |
120a6e |
cleanupStyle->getContrast(), 100, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
if (!greyMode) {
|
|
Shinya Kitaoka |
120a6e |
if (bs) {
|
|
Shinya Kitaoka |
120a6e |
m_cThresholdChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("Color Thres"),
|
|
Shinya Kitaoka |
120a6e |
bs->getColorThreshold(), 100, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
m_wThresholdChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("White Thres"),
|
|
Shinya Kitaoka |
120a6e |
bs->getWhiteThreshold(), 100, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
} else // cs
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
m_hRangeChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("H Range"),
|
|
Shinya Kitaoka |
120a6e |
cs->getHRange(), 120, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
m_lineWidthChannel =
|
|
Shinya Kitaoka |
120a6e |
new ChannelField(this, DVGui::CleanupColorField::tr("Line Width"),
|
|
Shinya Kitaoka |
120a6e |
cs->getLineWidth(), 100, true, 75, -1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setStyle(*cleanupStyle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//---- layout
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *mainLay = new QHBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
mainLay->setMargin(8);
|
|
Shinya Kitaoka |
120a6e |
mainLay->setSpacing(5);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
mainLay->addWidget(m_colorSample, 0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *paramLay = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
paramLay->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
paramLay->setSpacing(3);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_brightnessChannel);
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_contrastChannel);
|
|
Shinya Kitaoka |
120a6e |
if (!greyMode) {
|
|
Shinya Kitaoka |
120a6e |
if (bs) {
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_cThresholdChannel);
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_wThresholdChannel);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_hRangeChannel);
|
|
Shinya Kitaoka |
120a6e |
paramLay->addWidget(m_lineWidthChannel);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
mainLay->addLayout(paramLay, 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLay);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//---- signal-slot connections
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_brightnessChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onBrightnessChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_contrastChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onContrastChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
if (!greyMode) {
|
|
Shinya Kitaoka |
120a6e |
if (bs) {
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_cThresholdChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onCThresholdChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_wThresholdChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onWThresholdChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_hRangeChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onHRangeChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_lineWidthChannel, SIGNAL(valueChanged(int, bool)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onLineWidthChannelChanged(int, bool)));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::updateColor() {
|
|
Shinya Kitaoka |
120a6e |
if (m_cleanupStyle->canUpdate()) {
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->invalidateIcon();
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setStyle(*m_cleanupStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_brightnessChannel->setChannel(m_cleanupStyle->getBrightness());
|
|
Shinya Kitaoka |
120a6e |
if (m_cleanupStyle->isContrastEnabled())
|
|
Shinya Kitaoka |
120a6e |
m_contrastChannel->setChannel(m_cleanupStyle->getContrast());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TBlackCleanupStyle *bs;
|
|
Shinya Kitaoka |
120a6e |
TColorCleanupStyle *cs;
|
|
Shinya Kitaoka |
120a6e |
if ((bs = dynamic_cast<tblackcleanupstyle *="">(m_cleanupStyle)) &&</tblackcleanupstyle>
|
|
Shinya Kitaoka |
120a6e |
!m_greyMode) {
|
|
Shinya Kitaoka |
120a6e |
m_cThresholdChannel->setChannel(bs->getColorThreshold());
|
|
Shinya Kitaoka |
120a6e |
m_wThresholdChannel->setChannel(bs->getWhiteThreshold());
|
|
Shinya Kitaoka |
120a6e |
} else if ((cs = dynamic_cast<tcolorcleanupstyle *="">(m_cleanupStyle))) {</tcolorcleanupstyle>
|
|
Shinya Kitaoka |
120a6e |
m_hRangeChannel->setChannel(cs->getHRange());
|
|
Shinya Kitaoka |
120a6e |
m_lineWidthChannel->setChannel(cs->getLineWidth());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 CleanupColorField::getColor() const {
|
|
Shinya Kitaoka |
120a6e |
return m_cleanupStyle->getMainColor();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::setColor(const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (m_cleanupStyle->getMainColor() == color) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setMainColor(color);
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->invalidateIcon();
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setStyle(*m_cleanupStyle);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 CleanupColorField::getOutputColor() const {
|
|
Shinya Kitaoka |
120a6e |
return m_cleanupStyle->getColorParamValue(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::setOutputColor(const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
if (getOutputColor() == color) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setColorParamValue(1, color);
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->invalidateIcon();
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setStyle(*m_cleanupStyle);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::setStyle(TColorStyle *style) {
|
|
Shinya Kitaoka |
120a6e |
if (getColor() == style->getMainColor() &&
|
|
Shinya Kitaoka |
120a6e |
getOutputColor() == style->getColorParamValue(1))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setMainColor(style->getMainColor());
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->setColorParamValue(1, style->getColorParamValue(1));
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->invalidateIcon();
|
|
Shinya Kitaoka |
120a6e |
m_colorSample->setStyle(*m_cleanupStyle);
|
|
Shinya Kitaoka |
120a6e |
m_ph->notifyColorStyleChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CleanupColorField::CleanupColorFieldEditorController
|
|
Shinya Kitaoka |
120a6e |
*CleanupColorField::m_editorController = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CleanupColorField::CleanupColorFieldEditorController *
|
|
Shinya Kitaoka |
120a6e |
CleanupColorField::getEditorController() {
|
|
Shinya Kitaoka |
120a6e |
return m_editorController;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::setEditorController(
|
|
Shinya Kitaoka |
120a6e |
CleanupColorFieldEditorController *editorController) {
|
|
Shinya Kitaoka |
120a6e |
m_editorController = editorController;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::mouseDoubleClickEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QPoint p = event->pos();
|
|
Shinya Kitaoka |
120a6e |
if (!m_colorSample->visibleRegion().contains(p)) return;
|
|
Shinya Kitaoka |
120a6e |
emit StyleSelected(m_cleanupStyle);
|
|
Shinya Kitaoka |
120a6e |
if (!getEditorController()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
CommandManager::instance()->execute("MI_OpenStyleControl");
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->edit(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::hideEvent(QHideEvent *) {
|
|
Shinya Kitaoka |
120a6e |
if (!getEditorController()) return;
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->edit(0);
|
|
Shinya Kitaoka |
120a6e |
getEditorController()->hide();
|
|
Shinya Kitaoka |
120a6e |
// setEditorController(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void CleanupColorField::setContrastEnabled(bool enable) {
|
|
Shinya Kitaoka |
120a6e |
m_contrastChannel->setEnabled(enable);
|
|
Shinya Kitaoka |
120a6e |
m_cleanupStyle->enableContrast(enable);
|
|
Toshihiro Shimizu |
890ddd |
}
|