|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/styleeditor.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/filefield.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "historytypes.h"
|
|
shun-iwasawa |
ad7711 |
#include "toonzqt/lutcalibrator.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzfolders.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/cleanupcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/imagestyles.h"
|
|
Shinya Kitaoka |
120a6e |
#include "toonz/txshsimplelevel.h" //iwsw
|
|
Shinya Kitaoka |
120a6e |
#include "toonz/levelproperties.h" //iwsw
|
|
Ivan Mahonin |
bf1d82 |
#include "toonz/mypaintbrushstyle.h"
|
|
shun-iwasawa |
388550 |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tconvert.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfiletype.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trasterimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tlevel_io.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tofflinegl.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tropcm.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorrenderdata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tsimplecolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorbrushstyle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <QHBoxLayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <QVBoxLayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <QGridLayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <QPainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <QButtonGroup>
|
|
Toshihiro Shimizu |
890ddd |
#include <QMouseEvent>
|
|
Toshihiro Shimizu |
890ddd |
#include <QLabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <QCheckBox>
|
|
Toshihiro Shimizu |
890ddd |
#include <QPushButton>
|
|
Toshihiro Shimizu |
890ddd |
#include <QRadioButton>
|
|
Toshihiro Shimizu |
890ddd |
#include <QComboBox>
|
|
Toshihiro Shimizu |
890ddd |
#include <QScrollArea>
|
|
Toshihiro Shimizu |
890ddd |
#include <QStackedWidget>
|
|
Toshihiro Shimizu |
890ddd |
#include <QStyleOptionSlider>
|
|
Toshihiro Shimizu |
890ddd |
#include <QToolTip>
|
|
Toshihiro Shimizu |
890ddd |
#include <QSplitter>
|
|
Jeremy Bullock |
0a2e55 |
#include <QMenu>
|
|
shun-iwasawa |
ad7711 |
#include <QOpenGLFramebufferObject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c18bfa |
namespace {
|
|
shun-iwasawa |
c18bfa |
enum ColorSliderAppearance {
|
|
shun-iwasawa |
c18bfa |
RelativeColoredTriangleHandle,
|
|
shun-iwasawa |
c18bfa |
AbsoluteColoredLineHandle
|
|
shun-iwasawa |
c18bfa |
};
|
|
shun-iwasawa |
c18bfa |
}
|
|
shun-iwasawa |
c18bfa |
TEnv::IntVar StyleEditorColorSliderAppearance(
|
|
shun-iwasawa |
c18bfa |
"StyleEditorColorSliderAppearance", RelativeColoredTriangleHandle);
|
|
shun-iwasawa |
c18bfa |
|
|
Toshihiro Shimizu |
890ddd |
using namespace StyleEditorGUI;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// UndoPaletteChange definition
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class UndoPaletteChange final : public TUndo {
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *m_paletteHandle;
|
|
Shinya Kitaoka |
120a6e |
TPaletteP m_palette;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_styleId;
|
|
Shinya Kitaoka |
120a6e |
const TColorStyleP m_oldColor, m_newColor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring m_oldName, m_newName;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_oldEditedFlag, m_newEditedFlag;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
UndoPaletteChange(TPaletteHandle *paletteHandle, int styleId,
|
|
Shinya Kitaoka |
120a6e |
const TColorStyle &oldColor, const TColorStyle &newColor)
|
|
Shinya Kitaoka |
120a6e |
: m_paletteHandle(paletteHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_palette(paletteHandle->getPalette())
|
|
Shinya Kitaoka |
120a6e |
, m_styleId(styleId)
|
|
Shinya Kitaoka |
120a6e |
, m_oldColor(oldColor.clone())
|
|
Shinya Kitaoka |
120a6e |
, m_newColor(newColor.clone())
|
|
Shinya Kitaoka |
120a6e |
, m_oldName(oldColor.getName())
|
|
Shinya Kitaoka |
120a6e |
, m_newName(newColor.getName())
|
|
Shinya Kitaoka |
120a6e |
, m_frame(m_palette->getFrame())
|
|
Shinya Kitaoka |
120a6e |
, m_oldEditedFlag(oldColor.getIsEditedFlag())
|
|
Shinya Kitaoka |
120a6e |
, m_newEditedFlag(newColor.getIsEditedFlag()) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override {
|
|
Shinya Kitaoka |
120a6e |
m_palette->setStyle(m_styleId, m_oldColor->clone());
|
|
Shinya Kitaoka |
120a6e |
m_palette->getStyle(m_styleId)->setIsEditedFlag(m_oldEditedFlag);
|
|
Shinya Kitaoka |
120a6e |
m_palette->getStyle(m_styleId)->setName(m_oldName);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_palette->isKeyframe(m_styleId, m_frame))
|
|
Shinya Kitaoka |
120a6e |
m_palette->setKeyframe(m_styleId, m_frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// don't change the dirty flag. because m_palette may not the current
|
|
Shinya Kitaoka |
120a6e |
// palette when undo executed
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyColorStyleChanged(false, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void redo() const override {
|
|
Shinya Kitaoka |
120a6e |
m_palette->setStyle(m_styleId, m_newColor->clone());
|
|
Shinya Kitaoka |
120a6e |
m_palette->getStyle(m_styleId)->setIsEditedFlag(m_newEditedFlag);
|
|
Shinya Kitaoka |
120a6e |
m_palette->getStyle(m_styleId)->setName(m_newName);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_palette->isKeyframe(m_styleId, m_frame))
|
|
Shinya Kitaoka |
120a6e |
m_palette->setKeyframe(m_styleId, m_frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// don't change the dirty flag. because m_palette may not the current
|
|
Shinya Kitaoka |
120a6e |
// palette when undo executed
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyColorStyleChanged(false, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// imprecise - depends on the style
|
|
Shinya Kitaoka |
38fd86 |
int getSize() const override {
|
|
Shinya Kitaoka |
38fd86 |
return sizeof(*this) + 2 * sizeof(TColorStyle *);
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
QString getHistoryString() override {
|
|
Shinya Kitaoka |
120a6e |
return QObject::tr(
|
|
Shinya Kitaoka |
120a6e |
"Change Style Palette : %1 Style#%2 [R%3 G%4 B%5] -> [R%6 "
|
|
Shinya Kitaoka |
120a6e |
"G%7 B%8]")
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::fromStdWString(m_palette->getPaletteName()))
|
|
Shinya Kitaoka |
120a6e |
.arg(QString::number(m_styleId))
|
|
Shinya Kitaoka |
120a6e |
.arg(m_oldColor->getMainColor().r)
|
|
Shinya Kitaoka |
120a6e |
.arg(m_oldColor->getMainColor().g)
|
|
Shinya Kitaoka |
120a6e |
.arg(m_oldColor->getMainColor().b)
|
|
Shinya Kitaoka |
120a6e |
.arg(m_newColor->getMainColor().r)
|
|
Shinya Kitaoka |
120a6e |
.arg(m_newColor->getMainColor().g)
|
|
Shinya Kitaoka |
120a6e |
.arg(m_newColor->getMainColor().b);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getHistoryType() override { return HistoryType::Palette; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ColorModel implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
const int ChannelMaxValues[] = {255, 255, 255, 255, 359, 100, 100};
|
|
Shinya Kitaoka |
120a6e |
const int ChannelPairMaxValues[][2] = {{255, 255}, {255, 255}, {255, 255},
|
|
Shinya Kitaoka |
120a6e |
{255, 255}, {100, 100}, {359, 100},
|
|
Shinya Kitaoka |
120a6e |
{359, 100}};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ColorModel::ColorModel() { memset(m_channels, 0, sizeof m_channels); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::rgb2hsv() {
|
|
Shinya Kitaoka |
120a6e |
QColor converter(m_channels[0], m_channels[1], m_channels[2]);
|
|
Shinya Kitaoka |
120a6e |
m_channels[4] =
|
|
Shinya Kitaoka |
120a6e |
std::max(converter.hue(), 0); // hue() ritorna -1 per colori acromatici
|
|
shun-iwasawa |
9dbaa2 |
m_channels[5] = (int)std::round(converter.saturationF() * 100.);
|
|
shun-iwasawa |
9dbaa2 |
m_channels[6] = (int)std::round(converter.valueF() * 100.);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::hsv2rgb() {
|
|
shun-iwasawa |
9dbaa2 |
QColor converter =
|
|
shun-iwasawa |
9dbaa2 |
QColor::fromHsvF((qreal)m_channels[4] / 360., (qreal)m_channels[5] / 100.,
|
|
shun-iwasawa |
9dbaa2 |
(qreal)m_channels[6] / 100.);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_channels[0] = converter.red();
|
|
Shinya Kitaoka |
120a6e |
m_channels[1] = converter.green();
|
|
Shinya Kitaoka |
120a6e |
m_channels[2] = converter.blue();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::setTPixel(const TPixel32 &pix) {
|
|
Shinya Kitaoka |
120a6e |
QColor color(pix.r, pix.g, pix.b, pix.m);
|
|
Shinya Kitaoka |
120a6e |
m_channels[0] = color.red();
|
|
Shinya Kitaoka |
120a6e |
m_channels[1] = color.green();
|
|
Shinya Kitaoka |
120a6e |
m_channels[2] = color.blue();
|
|
Shinya Kitaoka |
120a6e |
m_channels[3] = color.alpha();
|
|
Shinya Kitaoka |
120a6e |
m_channels[4] =
|
|
Shinya Kitaoka |
120a6e |
std::max(color.hue(), 0); // hue() ritorna -1 per colori acromatici
|
|
shun-iwasawa |
9dbaa2 |
m_channels[5] = (int)std::round(color.saturationF() * 100.);
|
|
shun-iwasawa |
9dbaa2 |
m_channels[6] = (int)std::round(color.valueF() * 100.);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 ColorModel::getTPixel() const {
|
|
Shinya Kitaoka |
120a6e |
return TPixel32(m_channels[0], m_channels[1], m_channels[2], m_channels[3]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::setValue(ColorChannel channel, int value) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int)channel && (int)channel < 7);
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= value && value <= ChannelMaxValues[channel]);
|
|
Shinya Kitaoka |
120a6e |
m_channels[(int)channel] = value;
|
|
Shinya Kitaoka |
120a6e |
if (channel >= eHue)
|
|
Shinya Kitaoka |
120a6e |
hsv2rgb();
|
|
Shinya Kitaoka |
120a6e |
else if (channel <= eBlue)
|
|
Shinya Kitaoka |
120a6e |
rgb2hsv();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::setValues(ColorChannel channel, int v, int u) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int)channel && (int)channel < 7);
|
|
Shinya Kitaoka |
120a6e |
switch (channel) {
|
|
Shinya Kitaoka |
120a6e |
case eRed:
|
|
Shinya Kitaoka |
120a6e |
setValue(eGreen, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eBlue, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eGreen:
|
|
Shinya Kitaoka |
120a6e |
setValue(eRed, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eBlue, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eBlue:
|
|
Shinya Kitaoka |
120a6e |
setValue(eRed, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eGreen, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eHue:
|
|
Shinya Kitaoka |
120a6e |
setValue(eSaturation, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eValue, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eSaturation:
|
|
Shinya Kitaoka |
120a6e |
setValue(eHue, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eValue, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eValue:
|
|
Shinya Kitaoka |
120a6e |
setValue(eHue, v);
|
|
Shinya Kitaoka |
120a6e |
setValue(eSaturation, u);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int ColorModel::getValue(ColorChannel channel) const {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int)channel && (int)channel < 7);
|
|
Shinya Kitaoka |
120a6e |
return m_channels[(int)channel];
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ColorModel::getValues(ColorChannel channel, int &u, int &v) {
|
|
Shinya Kitaoka |
120a6e |
switch (channel) {
|
|
Shinya Kitaoka |
120a6e |
case eRed:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eGreen);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eBlue);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eGreen:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eRed);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eBlue);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eBlue:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eRed);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eGreen);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eHue:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eSaturation);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eValue);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eSaturation:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eHue);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eValue);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case eValue:
|
|
Shinya Kitaoka |
120a6e |
u = getValue(eHue);
|
|
Shinya Kitaoka |
120a6e |
v = getValue(eSaturation);
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Rozhuk Ivan |
823a31 |
default:
|
|
Rozhuk Ivan |
823a31 |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class RedShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RedShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(value, m_color.g(), m_color.b()).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class GreenShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
GreenShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(m_color.r(), value, m_color.b()).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class BlueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
BlueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(m_color.r(), m_color.g(), value).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class AlphaShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
AlphaShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(m_color.r(), m_color.g(), m_color.b(), value).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class HueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(359 * value / 255, m_color.s() * 255 / 100,
|
|
Shinya Kitaoka |
120a6e |
m_color.v() * 255 / 100)
|
|
Shinya Kitaoka |
120a6e |
.rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class SaturationShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SaturationShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(m_color.h(), value, m_color.v() * 255 / 100).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class ValueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ValueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int value) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(m_color.h(), m_color.s() * 255 / 100, value).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class RedGreenShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RedGreenShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(u, v, m_color.b()).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class RedBlueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
RedBlueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(u, m_color.g(), v).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class GreenBlueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
GreenBlueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor(m_color.r(), u, v).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class SaturationValueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SaturationValueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(m_color.h(), u, v).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class HueValueShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HueValueShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(359 * u / 255, m_color.s() * 255 / 100, v).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class HueSaturationShadeMaker {
|
|
Shinya Kitaoka |
120a6e |
const ColorModel &m_color;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HueSaturationShadeMaker(const ColorModel &color) : m_color(color) {}
|
|
Shinya Kitaoka |
120a6e |
inline QRgb shade(int u, int v) const {
|
|
Shinya Kitaoka |
120a6e |
return QColor::fromHsv(359 * u / 255, v, m_color.v() * 255 / 100).rgba();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class ShadeMaker>
|
|
Shinya Kitaoka |
120a6e |
QPixmap makeLinearShading(const ShadeMaker &shadeMaker, int size,
|
|
Shinya Kitaoka |
120a6e |
bool isVertical) {
|
|
Shinya Kitaoka |
120a6e |
assert(size > 0);
|
|
Shinya Kitaoka |
120a6e |
QPixmap bgPixmap;
|
|
Shinya Kitaoka |
120a6e |
int i, dx, dy, w = 1, h = 1;
|
|
Shinya Kitaoka |
120a6e |
int x = 0, y = 0;
|
|
Shinya Kitaoka |
120a6e |
if (isVertical) {
|
|
Shinya Kitaoka |
120a6e |
dx = 0;
|
|
Shinya Kitaoka |
120a6e |
dy = -1;
|
|
Shinya Kitaoka |
120a6e |
h = size;
|
|
Shinya Kitaoka |
120a6e |
y = size - 1;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
dx = 1;
|
|
Shinya Kitaoka |
120a6e |
dy = 0;
|
|
Shinya Kitaoka |
120a6e |
w = size;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
QImage image(w, h, QImage::Format_ARGB32);
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
int v = 255 * i / (size - 1);
|
|
Shinya Kitaoka |
120a6e |
image.setPixel(x, y, shadeMaker.shade(v));
|
|
Shinya Kitaoka |
120a6e |
x += dx;
|
|
Shinya Kitaoka |
120a6e |
y += dy;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return QPixmap::fromImage(image);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPixmap makeLinearShading(const ColorModel &color, ColorChannel channel,
|
|
Shinya Kitaoka |
120a6e |
int size, bool isVertical) {
|
|
shun-iwasawa |
c18bfa |
bool relative =
|
|
shun-iwasawa |
c18bfa |
ColorSlider::s_slider_appearance == RelativeColoredTriangleHandle;
|
|
Shinya Kitaoka |
120a6e |
switch (channel) {
|
|
Shinya Kitaoka |
120a6e |
case eRed:
|
|
shun-iwasawa |
c18bfa |
if (isVertical || relative)
|
|
shun-iwasawa |
c18bfa |
return makeLinearShading(RedShadeMaker(color), size, isVertical);
|
|
shun-iwasawa |
c18bfa |
else
|
|
shun-iwasawa |
c18bfa |
return QPixmap(":Resources/grad_r.png").scaled(size, 1);
|
|
Shinya Kitaoka |
120a6e |
case eGreen:
|
|
shun-iwasawa |
c18bfa |
if (isVertical || relative)
|
|
shun-iwasawa |
c18bfa |
return makeLinearShading(GreenShadeMaker(color), size, isVertical);
|
|
shun-iwasawa |
c18bfa |
else
|
|
shun-iwasawa |
c18bfa |
return QPixmap(":Resources/grad_g.png").scaled(size, 1);
|
|
Shinya Kitaoka |
120a6e |
case eBlue:
|
|
shun-iwasawa |
c18bfa |
if (isVertical || relative)
|
|
shun-iwasawa |
c18bfa |
return makeLinearShading(BlueShadeMaker(color), size, isVertical);
|
|
shun-iwasawa |
c18bfa |
else
|
|
shun-iwasawa |
c18bfa |
return QPixmap(":Resources/grad_b.png").scaled(size, 1);
|
|
Shinya Kitaoka |
120a6e |
case eAlpha:
|
|
shun-iwasawa |
c18bfa |
if (isVertical || relative)
|
|
shun-iwasawa |
c18bfa |
return makeLinearShading(AlphaShadeMaker(color), size, isVertical);
|
|
shun-iwasawa |
c18bfa |
else
|
|
shun-iwasawa |
c18bfa |
return QPixmap(":Resources/grad_m.png").scaled(size, 1);
|
|
Shinya Kitaoka |
120a6e |
case eHue:
|
|
Shinya Kitaoka |
120a6e |
return makeLinearShading(HueShadeMaker(color), size, isVertical);
|
|
Shinya Kitaoka |
120a6e |
case eSaturation:
|
|
Shinya Kitaoka |
120a6e |
return makeLinearShading(SaturationShadeMaker(color), size, isVertical);
|
|
Shinya Kitaoka |
120a6e |
case eValue:
|
|
Shinya Kitaoka |
120a6e |
return makeLinearShading(ValueShadeMaker(color), size, isVertical);
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return QPixmap();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <class ShadeMaker>
|
|
Shinya Kitaoka |
120a6e |
QPixmap makeSquareShading(const ShadeMaker &shadeMaker, int size) {
|
|
Shinya Kitaoka |
120a6e |
assert(size > 0);
|
|
Shinya Kitaoka |
120a6e |
QPixmap bgPixmap;
|
|
Shinya Kitaoka |
120a6e |
QImage image(size, size, QImage::Format_RGB32);
|
|
Shinya Kitaoka |
120a6e |
int i, j;
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < size; j++) {
|
|
Shinya Kitaoka |
120a6e |
int u = 255 - (255 * j / (size - 1));
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < size; i++) {
|
|
Shinya Kitaoka |
120a6e |
int v = 255 * i / (size - 1);
|
|
Shinya Kitaoka |
120a6e |
image.setPixel(i, j, shadeMaker.shade(v, u));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return QPixmap::fromImage(image);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPixmap makeSquareShading(const ColorModel &color, ColorChannel channel,
|
|
Shinya Kitaoka |
120a6e |
int size) {
|
|
Shinya Kitaoka |
120a6e |
switch (channel) {
|
|
Shinya Kitaoka |
120a6e |
case eRed:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(GreenBlueShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
case eGreen:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(RedBlueShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
case eBlue:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(RedGreenShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
case eHue:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(SaturationValueShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
case eSaturation:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(HueValueShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
case eValue:
|
|
Shinya Kitaoka |
120a6e |
return makeSquareShading(HueSaturationShadeMaker(color), size);
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
assert(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
return QPixmap();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// HexagonalColorWheel implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
HexagonalColorWheel::HexagonalColorWheel(QWidget *parent)
|
|
shun_iwasawa |
7c988d |
: GLWidgetForHighDpi(parent)
|
|
luz paz |
6454c4 |
, m_bgColor(128, 128, 128) // default value in case this value does not set
|
|
Shinya Kitaoka |
120a6e |
// in the style sheet
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
setObjectName("HexagonalColorWheel");
|
|
Shinya Kitaoka |
120a6e |
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
m_currentWheel = none;
|
|
shun-iwasawa |
388550 |
if (Preferences::instance()->isColorCalibrationEnabled())
|
|
shun-iwasawa |
388550 |
m_lutCalibrator = new LutCalibrator();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
HexagonalColorWheel::~HexagonalColorWheel() {
|
|
shun-iwasawa |
ad7711 |
if (m_fbo) delete m_fbo;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
a8f111 |
void HexagonalColorWheel::updateColorCalibration() {
|
|
shun-iwasawa |
a8f111 |
if (Preferences::instance()->isColorCalibrationEnabled()) {
|
|
shun-iwasawa |
c18bfa |
// prevent to initialize LutCalibrator before this instance is initialized
|
|
shun-iwasawa |
c18bfa |
// or OT may crash due to missing OpenGL context
|
|
shun-iwasawa |
c18bfa |
if (m_firstInitialized) {
|
|
shun-iwasawa |
c18bfa |
cueCalibrationUpdate();
|
|
shun-iwasawa |
c18bfa |
return;
|
|
shun-iwasawa |
c18bfa |
}
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
a8f111 |
makeCurrent();
|
|
shun-iwasawa |
a8f111 |
if (!m_lutCalibrator)
|
|
shun-iwasawa |
a8f111 |
m_lutCalibrator = new LutCalibrator();
|
|
shun-iwasawa |
a8f111 |
else
|
|
shun-iwasawa |
a8f111 |
m_lutCalibrator->cleanup();
|
|
shun-iwasawa |
a8f111 |
m_lutCalibrator->initialize();
|
|
shun-iwasawa |
a8f111 |
connect(context(), SIGNAL(aboutToBeDestroyed()), this,
|
|
shun-iwasawa |
a8f111 |
SLOT(onContextAboutToBeDestroyed()));
|
|
shun-iwasawa |
a8f111 |
if (m_lutCalibrator->isValid() && !m_fbo)
|
|
shun-iwasawa |
a8f111 |
m_fbo = new QOpenGLFramebufferObject(width(), height());
|
|
shun-iwasawa |
a8f111 |
doneCurrent();
|
|
shun-iwasawa |
a8f111 |
}
|
|
shun-iwasawa |
a8f111 |
update();
|
|
shun-iwasawa |
a8f111 |
}
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
a8f111 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
567f65 |
void HexagonalColorWheel::showEvent(QShowEvent *) {
|
|
shun-iwasawa |
567f65 |
if (m_cuedCalibrationUpdate) {
|
|
shun-iwasawa |
567f65 |
updateColorCalibration();
|
|
shun-iwasawa |
567f65 |
m_cuedCalibrationUpdate = false;
|
|
shun-iwasawa |
567f65 |
}
|
|
shun-iwasawa |
567f65 |
}
|
|
shun-iwasawa |
567f65 |
|
|
shun-iwasawa |
567f65 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
567f65 |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::initializeGL() {
|
|
shun_iwasawa |
5e0d4f |
initializeOpenGLFunctions();
|
|
shun-iwasawa |
ad7711 |
|
|
shun-iwasawa |
ad7711 |
// to be computed once through the software
|
|
shun-iwasawa |
e40777 |
if (m_lutCalibrator && !m_lutCalibrator->isInitialized()) {
|
|
shun-iwasawa |
388550 |
m_lutCalibrator->initialize();
|
|
shun-iwasawa |
388550 |
connect(context(), SIGNAL(aboutToBeDestroyed()), this,
|
|
shun-iwasawa |
388550 |
SLOT(onContextAboutToBeDestroyed()));
|
|
shun-iwasawa |
388550 |
}
|
|
shun-iwasawa |
ad7711 |
|
|
Shinya Kitaoka |
120a6e |
QColor const color = getBGColor();
|
|
Shinya Kitaoka |
120a6e |
glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
|
|
shun-iwasawa |
e40777 |
|
|
shun-iwasawa |
e40777 |
// Without the following lines, the wheel in a floating style editor
|
|
luz paz |
6454c4 |
// disappears on switching the room due to context switching.
|
|
shun-iwasawa |
e40777 |
if (m_firstInitialized)
|
|
shun-iwasawa |
e40777 |
m_firstInitialized = false;
|
|
shun-iwasawa |
e40777 |
else {
|
|
shun-iwasawa |
e40777 |
resizeGL(width(), height());
|
|
shun-iwasawa |
e40777 |
update();
|
|
shun-iwasawa |
e40777 |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
7c988d |
void HexagonalColorWheel::resizeGL(int w, int h) {
|
|
shun_iwasawa |
1c961d |
w *= getDevPixRatio();
|
|
shun_iwasawa |
1c961d |
h *= getDevPixRatio();
|
|
shun_iwasawa |
7c988d |
float d = (w - 5.0f) / 2.5f;
|
|
shun_iwasawa |
7c988d |
bool isHorizontallyLong = ((d * 1.732f) < h) ? false : true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (isHorizontallyLong) {
|
|
shun_iwasawa |
7c988d |
m_triEdgeLen = (float)h / 1.732f;
|
|
shun_iwasawa |
7c988d |
m_triHeight = (float)h / 2.0f;
|
|
shun_iwasawa |
7c988d |
m_wheelPosition.setX(((float)w - (m_triEdgeLen * 2.5f + 5.0f)) / 2.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wheelPosition.setY(0.0f);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
m_triEdgeLen = d;
|
|
Shinya Kitaoka |
120a6e |
m_triHeight = m_triEdgeLen * 0.866f;
|
|
Shinya Kitaoka |
120a6e |
m_wheelPosition.setX(0.0f);
|
|
shun_iwasawa |
7c988d |
m_wheelPosition.setY(((float)h - (m_triHeight * 2.0f)) / 2.0f);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// set all vertices positions
|
|
Shinya Kitaoka |
120a6e |
m_wp[0].setX(m_triEdgeLen);
|
|
Shinya Kitaoka |
120a6e |
m_wp[0].setY(m_triHeight);
|
|
Shinya Kitaoka |
120a6e |
m_wp[1].setX(m_triEdgeLen * 0.5f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[1].setY(0.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[2].setX(0.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[2].setY(m_triHeight);
|
|
Shinya Kitaoka |
120a6e |
m_wp[3].setX(m_triEdgeLen * 0.5f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[3].setY(m_triHeight * 2.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[4].setX(m_triEdgeLen * 1.5f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[4].setY(m_triHeight * 2.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[5].setX(m_triEdgeLen * 2.0f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[5].setY(m_triHeight);
|
|
Shinya Kitaoka |
120a6e |
m_wp[6].setX(m_triEdgeLen * 1.5f);
|
|
Shinya Kitaoka |
120a6e |
m_wp[6].setY(0.0f);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_leftp[0].setX(m_wp[6].x() + 5.0f);
|
|
Shinya Kitaoka |
120a6e |
m_leftp[0].setY(0.0f);
|
|
Shinya Kitaoka |
120a6e |
m_leftp[1].setX(m_leftp[0].x() + m_triEdgeLen);
|
|
Shinya Kitaoka |
120a6e |
m_leftp[1].setY(m_triHeight * 2.0f);
|
|
Shinya Kitaoka |
120a6e |
m_leftp[2].setX(m_leftp[1].x());
|
|
Shinya Kitaoka |
120a6e |
m_leftp[2].setY(0.0f);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// GL settings
|
|
shun_iwasawa |
7c988d |
glViewport(0, 0, w, h);
|
|
Shinya Kitaoka |
120a6e |
glMatrixMode(GL_PROJECTION);
|
|
Shinya Kitaoka |
120a6e |
glLoadIdentity();
|
|
shun_iwasawa |
7c988d |
glOrtho(0.0, (GLdouble)w, (GLdouble)h, 0.0, 1.0, -1.0);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
ad7711 |
// remake fbo with new size
|
|
shun-iwasawa |
388550 |
if (m_lutCalibrator && m_lutCalibrator->isValid()) {
|
|
shun-iwasawa |
ad7711 |
if (m_fbo) delete m_fbo;
|
|
shun-iwasawa |
ad7711 |
m_fbo = new QOpenGLFramebufferObject(w, h);
|
|
shun-iwasawa |
ad7711 |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::paintGL() {
|
|
Shinya Kitaoka |
120a6e |
// call ClearColor() here in order to update bg color when the stylesheet is
|
|
Shinya Kitaoka |
120a6e |
// switched
|
|
Shinya Kitaoka |
120a6e |
QColor const color = getBGColor();
|
|
Shinya Kitaoka |
120a6e |
glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
glMatrixMode(GL_MODELVIEW);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
388550 |
if (m_lutCalibrator && m_lutCalibrator->isValid()) m_fbo->bind();
|
|
Keisuke Ogaki |
0c8292 |
|
|
Shinya Kitaoka |
120a6e |
glClear(GL_COLOR_BUFFER_BIT);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
float v = (float)m_color.getValue(eValue) / 100.0f;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw hexagonal color wheel
|
|
Shinya Kitaoka |
120a6e |
glTranslatef(m_wheelPosition.rx(), m_wheelPosition.ry(), 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_TRIANGLE_FAN);
|
|
Shinya Kitaoka |
120a6e |
glColor3f(v, v, v);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[0].x(), m_wp[0].y());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, v, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[1].x(), m_wp[1].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, v, v);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[2].x(), m_wp[2].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, 0.0f, v);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[3].x(), m_wp[3].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(v, 0.0f, v);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[4].x(), m_wp[4].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(v, 0.0f, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[5].x(), m_wp[5].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(v, v, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[6].x(), m_wp[6].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, v, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_wp[1].x(), m_wp[1].y());
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QColor leftCol = QColor().fromHsv(m_color.getValue(eHue), 255, 255);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw triangle color picker
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_TRIANGLES);
|
|
Shinya Kitaoka |
120a6e |
glColor3f(leftCol.redF(), leftCol.greenF(), leftCol.blueF());
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_leftp[0].x(), m_leftp[0].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, 0.0f, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_leftp[1].x(), m_leftp[1].y());
|
|
Shinya Kitaoka |
120a6e |
glColor3f(1.0f, 1.0f, 1.0f);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(m_leftp[2].x(), m_leftp[2].y());
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw small quad at current color position
|
|
Shinya Kitaoka |
120a6e |
drawCurrentColorMark();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
388550 |
if (m_lutCalibrator && m_lutCalibrator->isValid())
|
|
shun-iwasawa |
388550 |
m_lutCalibrator->onEndDraw(m_fbo);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::drawCurrentColorMark() {
|
|
Shinya Kitaoka |
120a6e |
int h;
|
|
Shinya Kitaoka |
120a6e |
float s, v;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// show hue in a counterclockwise fashion
|
|
Shinya Kitaoka |
120a6e |
h = 360 - m_color.getValue(eHue);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
s = (float)m_color.getValue(eSaturation) / 100.0f;
|
|
Shinya Kitaoka |
120a6e |
v = (float)m_color.getValue(eValue) / 100.0f;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// d is a distance from a center of the wheel
|
|
Shinya Kitaoka |
120a6e |
float d, phi;
|
|
Shinya Kitaoka |
120a6e |
phi = (float)(h % 60 - 30) / 180.0f * 3.1415f;
|
|
Shinya Kitaoka |
120a6e |
d = s * m_triHeight / cosf(phi);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// set marker color
|
|
Shinya Kitaoka |
120a6e |
if (v > 0.4f)
|
|
Shinya Kitaoka |
120a6e |
glColor3f(0.0f, 0.0f, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
glColor3f(1.0f, 1.0f, 1.0f);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw marker (in the wheel)
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslatef(m_wp[0].x(), m_wp[0].y(), 0.1f);
|
|
Shinya Kitaoka |
120a6e |
glRotatef(h, 0.0, 0.0, 1.0);
|
|
Shinya Kitaoka |
120a6e |
glTranslatef(d, 0.0f, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glRotatef(-h, 0.0, 0.0, 1.0);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_LOOP);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(-3, -3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(3, -3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(3, 3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(-3, 3);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// draw marker (in the triangle)
|
|
Shinya Kitaoka |
120a6e |
glPushMatrix();
|
|
Shinya Kitaoka |
120a6e |
glTranslatef(m_leftp[1].x(), m_leftp[1].y(), 0.1f);
|
|
Shinya Kitaoka |
120a6e |
glTranslatef(-m_triEdgeLen * v * s, -m_triHeight * v * 2.0f, 0.0f);
|
|
Shinya Kitaoka |
120a6e |
glBegin(GL_LINE_LOOP);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(-3, -3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(3, -3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(3, 3);
|
|
Shinya Kitaoka |
120a6e |
glVertex2f(-3, 3);
|
|
Shinya Kitaoka |
120a6e |
glEnd();
|
|
Shinya Kitaoka |
120a6e |
glPopMatrix();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (~event->buttons() & Qt::LeftButton) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// check whether the mouse cursor is in the wheel or in the triangle (or
|
|
Shinya Kitaoka |
120a6e |
// nothing).
|
|
shun_iwasawa |
7c988d |
QPoint curPos = event->pos() * getDevPixRatio();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPolygonF wheelPolygon;
|
|
Shinya Kitaoka |
120a6e |
// in the case of the wheel
|
|
Shinya Kitaoka |
120a6e |
wheelPolygon << m_wp[1] << m_wp[2] << m_wp[3] << m_wp[4] << m_wp[5]
|
|
Shinya Kitaoka |
120a6e |
<< m_wp[6];
|
|
Shinya Kitaoka |
120a6e |
wheelPolygon.translate(m_wheelPosition);
|
|
shun_iwasawa |
7c988d |
if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) {
|
|
Shinya Kitaoka |
120a6e |
m_currentWheel = leftWheel;
|
|
shun_iwasawa |
7c988d |
clickLeftWheel(curPos);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
wheelPolygon.clear();
|
|
Shinya Kitaoka |
120a6e |
// in the case of the triangle
|
|
Shinya Kitaoka |
120a6e |
wheelPolygon << m_leftp[0] << m_leftp[1] << m_leftp[2];
|
|
Shinya Kitaoka |
120a6e |
wheelPolygon.translate(m_wheelPosition);
|
|
shun_iwasawa |
7c988d |
if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) {
|
|
Shinya Kitaoka |
120a6e |
m_currentWheel = rightTriangle;
|
|
shun_iwasawa |
7c988d |
clickRightTriangle(curPos);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//... or, in the case of nothing
|
|
Shinya Kitaoka |
120a6e |
m_currentWheel = none;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::mouseMoveEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
// change the behavior according to the current touching wheel
|
|
Shinya Kitaoka |
120a6e |
switch (m_currentWheel) {
|
|
Shinya Kitaoka |
120a6e |
case none:
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case leftWheel:
|
|
shun_iwasawa |
7c988d |
clickLeftWheel(event->pos() * getDevPixRatio());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case rightTriangle:
|
|
shun_iwasawa |
7c988d |
clickRightTriangle(event->pos() * getDevPixRatio());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::mouseReleaseEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
m_currentWheel = none;
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! compute hue and saturation position. saturation value must be clamped
|
|
shun-iwasawa |
e40777 |
*/
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::clickLeftWheel(const QPoint &pos) {
|
|
Shinya Kitaoka |
120a6e |
QLineF p(m_wp[0] + m_wheelPosition, QPointF(pos));
|
|
Shinya Kitaoka |
120a6e |
QLineF horizontal(0, 0, 1, 0);
|
|
Shinya Kitaoka |
120a6e |
float theta = (p.dy() < 0) ? p.angle(horizontal) : 360 - p.angle(horizontal);
|
|
Shinya Kitaoka |
120a6e |
float phi = theta;
|
|
Shinya Kitaoka |
120a6e |
while (phi >= 60.0f) phi -= 60.0f;
|
|
Shinya Kitaoka |
120a6e |
phi -= 30.0f;
|
|
Shinya Kitaoka |
120a6e |
// d is a length from center to edge of the wheel when saturation = 100
|
|
Shinya Kitaoka |
120a6e |
float d = m_triHeight / cosf(phi / 180.0f * 3.1415f);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
a8f111 |
int h = (int)theta;
|
|
Shinya Kitaoka |
120a6e |
if (h > 359) h = 359;
|
|
Shinya Kitaoka |
120a6e |
// clamping
|
|
Shinya Kitaoka |
120a6e |
int s = (int)(std::min(p.length() / d, 1.0) * 100.0f);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_color.setValues(eValue, h, s);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void HexagonalColorWheel::clickRightTriangle(const QPoint &pos) {
|
|
Shinya Kitaoka |
120a6e |
int s, v;
|
|
Shinya Kitaoka |
120a6e |
QPointF p = m_leftp[1] + m_wheelPosition - QPointF(pos);
|
|
Shinya Kitaoka |
120a6e |
if (p.ry() <= 0.0f) {
|
|
Shinya Kitaoka |
120a6e |
s = 0;
|
|
Shinya Kitaoka |
120a6e |
v = 0;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
float v_ratio = std::min((float)(p.ry() / (m_triHeight * 2.0f)), 1.0f);
|
|
Shinya Kitaoka |
120a6e |
float s_f = p.rx() / (m_triEdgeLen * v_ratio);
|
|
Shinya Kitaoka |
120a6e |
v = (int)(v_ratio * 100.0f);
|
|
Shinya Kitaoka |
120a6e |
s = (int)(std::min(std::max(s_f, 0.0f), 1.0f) * 100.0f);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_color.setValues(eHue, s, v);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
388550 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
388550 |
|
|
shun-iwasawa |
388550 |
void HexagonalColorWheel::onContextAboutToBeDestroyed() {
|
|
shun-iwasawa |
388550 |
if (!m_lutCalibrator) return;
|
|
shun-iwasawa |
388550 |
makeCurrent();
|
|
shun-iwasawa |
388550 |
m_lutCalibrator->cleanup();
|
|
shun-iwasawa |
388550 |
doneCurrent();
|
|
shun-iwasawa |
034d17 |
disconnect(context(), SIGNAL(aboutToBeDestroyed()), this,
|
|
shun-iwasawa |
034d17 |
SLOT(onContextAboutToBeDestroyed()));
|
|
shun-iwasawa |
388550 |
}
|
|
shun-iwasawa |
388550 |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SquaredColorWheel implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SquaredColorWheel::SquaredColorWheel(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent), m_channel(eRed), m_color() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::paintEvent(QPaintEvent *) {
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
// calcolo lo sfondo
|
|
Shinya Kitaoka |
120a6e |
int size = width();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QPixmap bgPixmap = makeSquareShading(m_color, m_channel, size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!bgPixmap.isNull()) p.drawTiledPixmap(0, 0, size, size, bgPixmap);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int u = 0, v = 0;
|
|
Shinya Kitaoka |
120a6e |
m_color.getValues(m_channel, u, v);
|
|
Shinya Kitaoka |
120a6e |
int x = u * width() / ChannelPairMaxValues[m_channel][0];
|
|
Shinya Kitaoka |
120a6e |
int y = (ChannelPairMaxValues[m_channel][1] - v) * height() /
|
|
Shinya Kitaoka |
120a6e |
ChannelPairMaxValues[m_channel][1];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_color.v() > 127)
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::black);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::white);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(x - 1, y - 1, 3, 3);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::click(const QPoint &pos) {
|
|
Shinya Kitaoka |
120a6e |
int u = ChannelPairMaxValues[m_channel][0] * pos.x() / width();
|
|
Shinya Kitaoka |
120a6e |
int v = ChannelPairMaxValues[m_channel][1] * (height() - pos.y()) / height();
|
|
Shinya Kitaoka |
120a6e |
u = tcrop(u, 0, ChannelPairMaxValues[m_channel][0]);
|
|
Shinya Kitaoka |
120a6e |
v = tcrop(v, 0, ChannelPairMaxValues[m_channel][1]);
|
|
Shinya Kitaoka |
120a6e |
m_color.setValues(m_channel, u, v);
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (event->buttons() & Qt::LeftButton) click(event->pos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::mouseMoveEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (event->buttons() & Qt::LeftButton) click(event->pos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::mouseReleaseEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::setColor(const ColorModel &color) { m_color = color; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SquaredColorWheel::setChannel(int channel) {
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= channel && channel < 7);
|
|
Shinya Kitaoka |
120a6e |
m_channel = (ColorChannel)channel;
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ColorSlider implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
luz paz |
657132 |
// Acquire size later...
|
|
shun-iwasawa |
c18bfa |
int ColorSlider::s_chandle_size = -1;
|
|
shun-iwasawa |
c18bfa |
int ColorSlider::s_chandle_tall = -1;
|
|
shun-iwasawa |
c18bfa |
int ColorSlider::s_slider_appearance = -1;
|
|
justburner |
a13da2 |
|
|
Toshihiro Shimizu |
890ddd |
ColorSlider::ColorSlider(Qt::Orientation orientation, QWidget *parent)
|
|
justburner |
a13da2 |
: QAbstractSlider(parent), m_channel(eRed), m_color() {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setOrientation(orientation);
|
|
Shinya Kitaoka |
120a6e |
setMinimum(0);
|
|
Shinya Kitaoka |
120a6e |
setMaximum(ChannelMaxValues[m_channel]);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setMinimumHeight(7);
|
|
Shinya Kitaoka |
120a6e |
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
a13da2 |
// Get color handle size once
|
|
justburner |
a13da2 |
if (s_chandle_size == -1) {
|
|
shun-iwasawa |
c18bfa |
QImage chandle = QImage(":Resources/h_chandle_arrow.svg");
|
|
shun-iwasawa |
c18bfa |
s_chandle_size = chandle.width();
|
|
shun-iwasawa |
c18bfa |
s_chandle_tall = chandle.height();
|
|
shun-iwasawa |
c18bfa |
s_slider_appearance = StyleEditorColorSliderAppearance;
|
|
justburner |
a13da2 |
}
|
|
justburner |
a13da2 |
|
|
Shinya Kitaoka |
120a6e |
// Attenzione: necessario per poter individuare l'oggetto nel file di
|
|
Shinya Kitaoka |
120a6e |
// definizione dello stile
|
|
Shinya Kitaoka |
120a6e |
setObjectName("colorSlider");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSlider::setChannel(ColorChannel channel) {
|
|
Shinya Kitaoka |
120a6e |
if (m_channel == channel) return;
|
|
Shinya Kitaoka |
120a6e |
m_channel = channel;
|
|
Shinya Kitaoka |
120a6e |
setMaximum(ChannelMaxValues[m_channel]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSlider::setColor(const ColorModel &color) { m_color = color; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSlider::paintEvent(QPaintEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int x = rect().x();
|
|
Shinya Kitaoka |
120a6e |
int y = rect().y();
|
|
Shinya Kitaoka |
120a6e |
int w = width();
|
|
Shinya Kitaoka |
120a6e |
int h = height();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isVertical = orientation() == Qt::Vertical;
|
|
shun-iwasawa |
c18bfa |
bool isLineHandle =
|
|
shun-iwasawa |
c18bfa |
ColorSlider::s_slider_appearance == AbsoluteColoredLineHandle;
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
a13da2 |
if (isVertical) {
|
|
justburner |
a13da2 |
y += s_chandle_size / 2;
|
|
justburner |
a13da2 |
h -= s_chandle_size;
|
|
justburner |
a13da2 |
w -= 3;
|
|
justburner |
a13da2 |
} else {
|
|
justburner |
a13da2 |
x += s_chandle_size / 2;
|
|
justburner |
a13da2 |
w -= s_chandle_size;
|
|
justburner |
a13da2 |
h -= 3;
|
|
shun-iwasawa |
c18bfa |
if (isLineHandle) {
|
|
shun-iwasawa |
c18bfa |
y += 1;
|
|
shun-iwasawa |
c18bfa |
h -= 2;
|
|
shun-iwasawa |
c18bfa |
}
|
|
justburner |
a13da2 |
}
|
|
shun-iwasawa |
16effc |
if (w < 2 || h < 2) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPixmap bgPixmap =
|
|
Shinya Kitaoka |
120a6e |
makeLinearShading(m_color, m_channel, isVertical ? h : w, isVertical);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (m_channel == eAlpha) {
|
|
shun-iwasawa |
c18bfa |
p.drawTiledPixmap(x, y, w, h,
|
|
shun-iwasawa |
c18bfa |
DVGui::CommonChessboard::instance()->getPixmap());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!bgPixmap.isNull()) {
|
|
justburner |
a13da2 |
p.drawTiledPixmap(x, y, w, h, bgPixmap);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Bug in Qt 4.3: The vertical Slider cannot be styled due to a bug.
|
|
Shinya Kitaoka |
120a6e |
In this case we draw "manually" the slider handle at correct position
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
if (isVertical) {
|
|
shun-iwasawa |
c18bfa |
static QPixmap vHandlePixmap =
|
|
shun-iwasawa |
c18bfa |
svgToPixmap(":Resources/v_chandle_arrow.svg");
|
|
justburner |
a13da2 |
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), h, true);
|
|
justburner |
a13da2 |
p.drawPixmap(width() - s_chandle_tall, pos, vHandlePixmap);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
justburner |
a13da2 |
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), w, false);
|
|
shun-iwasawa |
c18bfa |
if (isLineHandle) {
|
|
shun-iwasawa |
c18bfa |
static QPixmap hHandleUpPm(":Resources/h_chandleUp.png");
|
|
shun-iwasawa |
c18bfa |
static QPixmap hHandleDownPm(":Resources/h_chandleDown.png");
|
|
shun-iwasawa |
c18bfa |
static QPixmap hHandleCenterPm(":Resources/h_chandleCenter.png");
|
|
shun-iwasawa |
c18bfa |
int linePos = pos + (s_chandle_size - hHandleCenterPm.width()) / 2;
|
|
shun-iwasawa |
c18bfa |
p.drawPixmap(linePos, 0, hHandleUpPm);
|
|
shun-iwasawa |
c18bfa |
p.drawPixmap(linePos, height() - hHandleDownPm.height(), hHandleDownPm);
|
|
shun-iwasawa |
c18bfa |
p.drawPixmap(linePos, hHandleUpPm.height(), hHandleCenterPm.width(),
|
|
shun-iwasawa |
c18bfa |
height() - hHandleUpPm.height() - hHandleDownPm.height(),
|
|
shun-iwasawa |
c18bfa |
hHandleCenterPm);
|
|
shun-iwasawa |
c18bfa |
} else {
|
|
shun-iwasawa |
c18bfa |
static QPixmap hHandlePixmap =
|
|
shun-iwasawa |
c18bfa |
svgToPixmap(":Resources/h_chandle_arrow.svg");
|
|
shun-iwasawa |
c18bfa |
p.drawPixmap(pos, height() - s_chandle_tall, hHandlePixmap);
|
|
shun-iwasawa |
c18bfa |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSlider::mousePressEvent(QMouseEvent *event) {
|
|
justburner |
a13da2 |
chandleMouse(event->pos().x(), event->pos().y());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ColorSlider::mouseReleaseEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
emit sliderReleased();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
a13da2 |
//-----------------------------------------------------------------------------
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
void ColorSlider::mouseMoveEvent(QMouseEvent *event) {
|
|
justburner |
a13da2 |
chandleMouse(event->pos().x(), event->pos().y());
|
|
justburner |
a13da2 |
}
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
//-----------------------------------------------------------------------------
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
void ColorSlider::chandleMouse(int mouse_x, int mouse_y) {
|
|
justburner |
a13da2 |
if (orientation() == Qt::Vertical) {
|
|
justburner |
a13da2 |
int pos = mouse_y - s_chandle_size / 2;
|
|
justburner |
a13da2 |
int span = height() - s_chandle_size;
|
|
justburner |
a13da2 |
setValue(QStyle::sliderValueFromPosition(0, maximum(), pos, span, true));
|
|
justburner |
a13da2 |
} else {
|
|
justburner |
a13da2 |
int pos = mouse_x - s_chandle_size / 2;
|
|
justburner |
a13da2 |
int span = width() - s_chandle_size;
|
|
justburner |
a13da2 |
setValue(QStyle::sliderValueFromPosition(0, maximum(), pos, span, false));
|
|
justburner |
a13da2 |
}
|
|
justburner |
a13da2 |
}
|
|
justburner |
a13da2 |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ArrowButton implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ArrowButton::ArrowButton(QWidget *parent, Qt::Orientation orientation,
|
|
Shinya Kitaoka |
120a6e |
bool isFirstArrow)
|
|
Shinya Kitaoka |
120a6e |
: QToolButton(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_orientaion(orientation)
|
|
Shinya Kitaoka |
120a6e |
, m_isFirstArrow(isFirstArrow)
|
|
Shinya Kitaoka |
120a6e |
, m_timerId(0)
|
|
Shinya Kitaoka |
120a6e |
, m_firstTimerId(0) {
|
|
Shinya Kitaoka |
120a6e |
setFixedSize(10, 10);
|
|
Shinya Kitaoka |
120a6e |
setObjectName("StyleEditorArrowButton");
|
|
Shinya Kitaoka |
120a6e |
bool isVertical = orientation == Qt::Vertical;
|
|
Shinya Kitaoka |
120a6e |
if (m_isFirstArrow) {
|
|
Shinya Kitaoka |
120a6e |
if (isVertical)
|
|
Shinya Kitaoka |
120a6e |
setIcon(createQIconPNG("arrow_up"));
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setIcon(createQIconPNG("arrow_left"));
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (isVertical)
|
|
Shinya Kitaoka |
120a6e |
setIcon(createQIconPNG("arrow_down"));
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setIcon(createQIconPNG("arrow_right"));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(pressed()), this, SLOT(onPressed()));
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(released()), this, SLOT(onRelease()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArrowButton::timerEvent(QTimerEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_firstTimerId != 0) {
|
|
Shinya Kitaoka |
120a6e |
killTimer(m_firstTimerId);
|
|
Shinya Kitaoka |
120a6e |
m_firstTimerId = 0;
|
|
Shinya Kitaoka |
120a6e |
m_timerId = startTimer(10);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
notifyChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArrowButton::notifyChanged() {
|
|
Shinya Kitaoka |
120a6e |
bool isVertical = m_orientaion == Qt::Vertical;
|
|
Shinya Kitaoka |
120a6e |
if ((m_isFirstArrow && !isVertical) || (!m_isFirstArrow && isVertical))
|
|
Shinya Kitaoka |
120a6e |
emit remove();
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
emit add();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ArrowButton::onPressed() {
|
|
Shinya Kitaoka |
120a6e |
notifyChanged();
|
|
Shinya Kitaoka |
120a6e |
assert(m_timerId == 0 && m_firstTimerId == 0);
|
|
Shinya Kitaoka |
120a6e |
m_firstTimerId = startTimer(500);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ArrowButton::onRelease() {
|
|
Shinya Kitaoka |
120a6e |
if (m_firstTimerId != 0) {
|
|
Shinya Kitaoka |
120a6e |
killTimer(m_firstTimerId);
|
|
Shinya Kitaoka |
120a6e |
m_firstTimerId = 0;
|
|
Shinya Kitaoka |
120a6e |
} else if (m_timerId != 0) {
|
|
Shinya Kitaoka |
120a6e |
killTimer(m_timerId);
|
|
Shinya Kitaoka |
120a6e |
m_timerId = 0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ColorSliderBar implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ColorSliderBar::ColorSliderBar(QWidget *parent, Qt::Orientation orientation)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent) {
|
|
Shinya Kitaoka |
120a6e |
bool isVertical = orientation == Qt::Vertical;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ArrowButton *first = new ArrowButton(this, orientation, true);
|
|
Shinya Kitaoka |
120a6e |
connect(first, SIGNAL(remove()), this, SLOT(onRemove()));
|
|
Shinya Kitaoka |
120a6e |
connect(first, SIGNAL(add()), this, SLOT(onAdd()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_colorSlider = new ColorSlider(orientation, this);
|
|
Shinya Kitaoka |
120a6e |
if (isVertical) m_colorSlider->setMaximumWidth(22);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ArrowButton *last = new ArrowButton(this, orientation, false);
|
|
Shinya Kitaoka |
120a6e |
connect(last, SIGNAL(add()), this, SLOT(onAdd()));
|
|
Shinya Kitaoka |
120a6e |
connect(last, SIGNAL(remove()), this, SLOT(onRemove()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
connect(m_colorSlider, SIGNAL(valueChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(valueChanged(int)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_colorSlider, SIGNAL(sliderReleased()), this,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(valueChanged()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QBoxLayout *layout;
|
|
Shinya Kitaoka |
120a6e |
if (!isVertical)
|
|
Shinya Kitaoka |
120a6e |
layout = new QHBoxLayout(this);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
layout = new QVBoxLayout(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
layout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
layout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(first, 0, Qt::AlignCenter);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(m_colorSlider, 1);
|
|
Shinya Kitaoka |
120a6e |
layout->addWidget(last, 0, Qt::AlignCenter);
|
|
Shinya Kitaoka |
120a6e |
setLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSliderBar::onRemove() {
|
|
Shinya Kitaoka |
120a6e |
int value = m_colorSlider->value();
|
|
Shinya Kitaoka |
120a6e |
if (value <= m_colorSlider->minimum()) return;
|
|
Shinya Kitaoka |
120a6e |
m_colorSlider->setValue(value - 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorSliderBar::onAdd() {
|
|
Shinya Kitaoka |
120a6e |
int value = m_colorSlider->value();
|
|
Shinya Kitaoka |
120a6e |
if (value >= m_colorSlider->maximum()) return;
|
|
Shinya Kitaoka |
120a6e |
m_colorSlider->setValue(value + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ChannelLineEdit implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ChannelLineEdit::mousePressEvent(QMouseEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit::mousePressEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_isEditing) {
|
|
Shinya Kitaoka |
120a6e |
selectAll();
|
|
Shinya Kitaoka |
120a6e |
m_isEditing = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ChannelLineEdit::focusOutEvent(QFocusEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit::focusOutEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_isEditing = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ChannelLineEdit::paintEvent(QPaintEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit::paintEvent(e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Kite |
521c84 |
/* Now that stylesheets added lineEdit focus this is likely redundant,
|
|
Kite |
521c84 |
* commenting out in-case it is still required.
|
|
Shinya Kitaoka |
120a6e |
if (m_isEditing) {
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::yellow);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(rect().adjusted(0, 0, -1, -1));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Kite |
521c84 |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ColorChannelControl implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ColorChannelControl::ColorChannelControl(ColorChannel channel, QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent), m_channel(channel), m_value(0), m_signalEnabled(true) {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
7ae920 |
QStringList channelList;
|
|
Jeremy Bullock |
7ae920 |
channelList << tr("R") << tr("G") << tr("B") << tr("A") << tr("H") << tr("S")
|
|
Jeremy Bullock |
7ae920 |
<< tr("V");
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= (int)m_channel && (int)m_channel < 7);
|
|
Jeremy Bullock |
7ae920 |
QString text = channelList.at(m_channel);
|
|
Shinya Kitaoka |
120a6e |
m_label = new QLabel(text, this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int minValue = 0;
|
|
Shinya Kitaoka |
120a6e |
int maxValue = 0;
|
|
Shinya Kitaoka |
120a6e |
if (m_channel < 4) // RGBA
|
|
Shinya Kitaoka |
120a6e |
maxValue = 255;
|
|
Shinya Kitaoka |
120a6e |
else if (m_channel == 4) // H
|
|
Shinya Kitaoka |
120a6e |
maxValue = 359;
|
|
Shinya Kitaoka |
120a6e |
else // SV
|
|
Shinya Kitaoka |
120a6e |
maxValue = 100;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_field = new ChannelLineEdit(this, 0, minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
m_slider = new ColorSlider(Qt::Horizontal, this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// buttons to increment/decrement the values by 1
|
|
Shinya Kitaoka |
120a6e |
QPushButton *addButton = new QPushButton(this);
|
|
Shinya Kitaoka |
120a6e |
QPushButton *subButton = new QPushButton(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_slider->setValue(0);
|
|
Shinya Kitaoka |
120a6e |
m_slider->setChannel(m_channel);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_label->setObjectName("colorSliderLabel");
|
|
Shinya Kitaoka |
120a6e |
m_label->setFixedWidth(11);
|
|
Shinya Kitaoka |
120a6e |
m_label->setMinimumHeight(7);
|
|
Shinya Kitaoka |
120a6e |
m_label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_field->setObjectName("colorSliderField");
|
|
Kite |
521c84 |
m_field->setFixedWidth(fontMetrics().width('0') * 4);
|
|
Shinya Kitaoka |
120a6e |
m_field->setMinimumHeight(7);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
addButton->setObjectName("colorSliderAddButton");
|
|
Shinya Kitaoka |
120a6e |
subButton->setObjectName("colorSliderSubButton");
|
|
Shinya Kitaoka |
120a6e |
addButton->setFixedWidth(18);
|
|
Shinya Kitaoka |
120a6e |
subButton->setFixedWidth(18);
|
|
Shinya Kitaoka |
120a6e |
addButton->setMinimumHeight(7);
|
|
Shinya Kitaoka |
120a6e |
subButton->setMinimumHeight(7);
|
|
Shinya Kitaoka |
120a6e |
addButton->setFlat(true);
|
|
Shinya Kitaoka |
120a6e |
subButton->setFlat(true);
|
|
Shinya Kitaoka |
120a6e |
addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
|
Shinya Kitaoka |
120a6e |
subButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
|
Shinya Kitaoka |
120a6e |
addButton->setAutoRepeat(true);
|
|
Shinya Kitaoka |
120a6e |
subButton->setAutoRepeat(true);
|
|
Shinya Kitaoka |
120a6e |
addButton->setAutoRepeatInterval(25);
|
|
Shinya Kitaoka |
120a6e |
subButton->setAutoRepeatInterval(25);
|
|
Shinya Kitaoka |
120a6e |
addButton->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
subButton->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(1);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_label, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addSpacing(2);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_field, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addSpacing(2);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(subButton, 0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(m_slider, 1);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->addWidget(addButton, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret =
|
|
Shinya Kitaoka |
120a6e |
connect(m_field, SIGNAL(editingFinished()), this, SLOT(onFieldChanged()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_slider, SIGNAL(valueChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSliderChanged(int)));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_slider, SIGNAL(sliderReleased()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onSliderReleased()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret &&
|
|
Shinya Kitaoka |
120a6e |
connect(addButton, SIGNAL(clicked()), this, SLOT(onAddButtonClicked()));
|
|
Shinya Kitaoka |
120a6e |
ret = ret &&
|
|
Shinya Kitaoka |
120a6e |
connect(subButton, SIGNAL(clicked()), this, SLOT(onSubButtonClicked()));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::onAddButtonClicked() {
|
|
Shinya Kitaoka |
120a6e |
m_slider->setValue(m_slider->value() + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::onSubButtonClicked() {
|
|
Shinya Kitaoka |
120a6e |
m_slider->setValue(m_slider->value() - 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::setColor(const ColorModel &color) {
|
|
Shinya Kitaoka |
120a6e |
m_color = color;
|
|
Shinya Kitaoka |
120a6e |
m_slider->setColor(color);
|
|
Shinya Kitaoka |
120a6e |
int value = color.getValue(m_channel);
|
|
Shinya Kitaoka |
120a6e |
if (m_value != value) {
|
|
Shinya Kitaoka |
120a6e |
bool signalEnabled = m_signalEnabled;
|
|
Shinya Kitaoka |
120a6e |
m_signalEnabled = false;
|
|
Shinya Kitaoka |
120a6e |
m_value = value;
|
|
Shinya Kitaoka |
120a6e |
m_field->setText(QString::number(value));
|
|
Shinya Kitaoka |
120a6e |
m_slider->setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_signalEnabled = signalEnabled;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::onFieldChanged() {
|
|
Shinya Kitaoka |
120a6e |
int value = m_field->text().toInt();
|
|
Shinya Kitaoka |
120a6e |
if (m_value == value) return;
|
|
Shinya Kitaoka |
120a6e |
m_value = value;
|
|
Shinya Kitaoka |
120a6e |
m_slider->setValue(value);
|
|
Shinya Kitaoka |
120a6e |
if (m_signalEnabled) {
|
|
Shinya Kitaoka |
120a6e |
m_color.setValue(m_channel, value);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::onSliderChanged(int value) {
|
|
Shinya Kitaoka |
120a6e |
if (m_value == value) return;
|
|
Shinya Kitaoka |
120a6e |
m_value = value;
|
|
Shinya Kitaoka |
120a6e |
m_field->setText(QString::number(value));
|
|
Shinya Kitaoka |
120a6e |
if (m_signalEnabled) {
|
|
Shinya Kitaoka |
120a6e |
m_color.setValue(m_channel, value);
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ColorChannelControl::onSliderReleased() {
|
|
Shinya Kitaoka |
120a6e |
emit colorChanged(m_color, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// StyleEditorPage implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StyleEditorPage::StyleEditorPage(QWidget *parent) : QFrame(parent) {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// It is necessary for the style sheets
|
|
Shinya Kitaoka |
120a6e |
setObjectName("styleEditorPage");
|
|
Shinya Kitaoka |
120a6e |
setFrameStyle(QFrame::StyledPanel);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ColorParameterSelector implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ColorParameterSelector::ColorParameterSelector(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent)
|
|
justburner |
a13da2 |
, m_index(0)
|
|
Shinya Kitaoka |
120a6e |
, m_chipSize(21, 21)
|
|
Shinya Kitaoka |
120a6e |
, m_chipOrigin(0, 1)
|
|
shun-iwasawa |
6ef4d0 |
, m_chipDelta(21, 0) {
|
|
shun-iwasawa |
6ef4d0 |
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
|
shun-iwasawa |
6ef4d0 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ColorParameterSelector::paintEvent(QPaintEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
if (m_colors.empty()) return;
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
QRect currentChipRect = QRect();
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < (int)m_colors.size(); i++) {
|
|
Shinya Kitaoka |
120a6e |
QRect chipRect(m_chipOrigin + i * m_chipDelta, m_chipSize);
|
|
Shinya Kitaoka |
120a6e |
p.fillRect(chipRect, m_colors[i]);
|
|
Shinya Kitaoka |
120a6e |
if (i == m_index) currentChipRect = chipRect;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
// Current index border
|
|
Shinya Kitaoka |
120a6e |
if (!currentChipRect.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
p.setPen(QColor(199, 202, 50));
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentChipRect.adjusted(0, 0, -1, -1));
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::white);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentChipRect.adjusted(1, 1, -2, -2));
|
|
Shinya Kitaoka |
120a6e |
p.setPen(Qt::black);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentChipRect.adjusted(2, 2, -3, -3));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorParameterSelector::setStyle(const TColorStyle &style) {
|
|
Shinya Kitaoka |
120a6e |
int count = style.getColorParamCount();
|
|
Shinya Kitaoka |
120a6e |
if (count <= 1) {
|
|
Shinya Kitaoka |
120a6e |
clear();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
shun-iwasawa |
c18bfa |
show();
|
|
Shinya Kitaoka |
120a6e |
if (m_colors.size() != count) {
|
|
Shinya Kitaoka |
120a6e |
m_index = 0;
|
|
Shinya Kitaoka |
120a6e |
m_colors.resize(count);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < count; i++) {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 color = style.getColorParamValue(i);
|
|
Shinya Kitaoka |
120a6e |
m_colors[i] = QColor(color.r, color.g, color.b, color.m);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ColorParameterSelector::clear() {
|
|
Shinya Kitaoka |
120a6e |
if (m_colors.size() != 0) m_colors.clear();
|
|
justburner |
a13da2 |
m_index = 0;
|
|
shun-iwasawa |
c18bfa |
if (isVisible()) {
|
|
shun-iwasawa |
c18bfa |
hide();
|
|
shun-iwasawa |
c18bfa |
update();
|
|
shun-iwasawa |
c18bfa |
qApp->processEvents();
|
|
shun-iwasawa |
c18bfa |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void ColorParameterSelector::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QPoint pos = event->pos() - m_chipOrigin;
|
|
Shinya Kitaoka |
120a6e |
int index = pos.x() / m_chipDelta.x();
|
|
Shinya Kitaoka |
120a6e |
QRect chipRect(index * m_chipDelta, m_chipSize);
|
|
Shinya Kitaoka |
120a6e |
if (chipRect.contains(pos)) {
|
|
justburner |
a13da2 |
if (index < m_colors.size()) m_index = index;
|
|
Shinya Kitaoka |
120a6e |
emit colorParamChanged();
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
6ef4d0 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
6ef4d0 |
|
|
shun-iwasawa |
6ef4d0 |
QSize ColorParameterSelector::sizeHint() const {
|
|
shun-iwasawa |
6ef4d0 |
return QSize(m_chipOrigin.x() + (m_colors.size() - 1) * m_chipDelta.x() +
|
|
shun-iwasawa |
6ef4d0 |
m_chipSize.width(),
|
|
shun-iwasawa |
6ef4d0 |
m_chipOrigin.y() + m_chipSize.height());
|
|
shun-iwasawa |
6ef4d0 |
}
|
|
shun-iwasawa |
6ef4d0 |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// PlainColorPage implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PlainColorPage::PlainColorPage(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: StyleEditorPage(parent), m_color(), m_signalEnabled(true) {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// m_squaredColorWheel = new SquaredColorWheel(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// m_verticalSlider = new ColorSliderBar(this, Qt::Vertical);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_hexagonalColorWheel = new HexagonalColorWheel(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
QButtonGroup *channelButtonGroup = new QButtonGroup();
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i<7; i++)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
if (i != (int)eAlpha)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QRadioButton *button = new QRadioButton(this);
|
|
Shinya Kitaoka |
120a6e |
m_modeButtons[i] = button;
|
|
Shinya Kitaoka |
120a6e |
if (i == 0) button->setChecked(true);
|
|
Shinya Kitaoka |
120a6e |
channelButtonGroup->addButton(button, i);
|
|
Shinya Kitaoka |
120a6e |
//slidersLayout->addWidget(button,i,0);
|
|
Shinya Kitaoka |
120a6e |
//とりあえず隠す
|
|
Shinya Kitaoka |
120a6e |
m_modeButtons[i]->hide();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_modeButtons[i] = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i] = new ColorChannelControl((ColorChannel)i, this);
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i]->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(m_channelControls[i], SIGNAL(colorChanged(const
|
|
Shinya Kitaoka |
120a6e |
ColorModel &, bool)),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(onControlChanged(const ColorModel &, bool)));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < 7; i++) {
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i] = new ColorChannelControl((ColorChannel)i, this);
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i]->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(m_channelControls[i],
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorChanged(const ColorModel &, bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onControlChanged(const ColorModel &, bool)));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
0a2e55 |
m_wheelFrame = new QFrame(this);
|
|
Jeremy Bullock |
0a2e55 |
m_hsvFrame = new QFrame(this);
|
|
Jeremy Bullock |
0a2e55 |
m_alphaFrame = new QFrame(this);
|
|
Jeremy Bullock |
0a2e55 |
m_rgbFrame = new QFrame(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
4bf672 |
m_slidersContainer = new QFrame(this);
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter = new QSplitter(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
9dbaa2 |
// プロパティの設定
|
|
shun-iwasawa |
9dbaa2 |
// channelButtonGroup->setExclusive(true);
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
m_wheelFrame->setObjectName("PlainColorPageParts");
|
|
Jeremy Bullock |
0a2e55 |
m_hsvFrame->setObjectName("PlainColorPageParts");
|
|
Jeremy Bullock |
0a2e55 |
m_alphaFrame->setObjectName("PlainColorPageParts");
|
|
Jeremy Bullock |
0a2e55 |
m_rgbFrame->setObjectName("PlainColorPageParts");
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setOrientation(Qt::Vertical);
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// m_verticalSlider->hide();
|
|
Shinya Kitaoka |
120a6e |
// m_squaredColorWheel->hide();
|
|
Shinya Kitaoka |
120a6e |
// m_ghibliColorWheel->hide();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// layout
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *mainLayout = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *wheelLayout = new QHBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
wheelLayout->setMargin(5);
|
|
Shinya Kitaoka |
120a6e |
wheelLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{ wheelLayout->addWidget(m_hexagonalColorWheel); }
|
|
Jeremy Bullock |
4bf672 |
m_wheelFrame->setLayout(wheelLayout);
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->addWidget(m_wheelFrame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *slidersLayout = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
slidersLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
slidersLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *hsvLayout = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
hsvLayout->setMargin(4);
|
|
Shinya Kitaoka |
120a6e |
hsvLayout->setSpacing(4);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
hsvLayout->addWidget(m_channelControls[eHue]);
|
|
Shinya Kitaoka |
120a6e |
hsvLayout->addWidget(m_channelControls[eSaturation]);
|
|
Shinya Kitaoka |
120a6e |
hsvLayout->addWidget(m_channelControls[eValue]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Jeremy Bullock |
0a2e55 |
m_hsvFrame->setLayout(hsvLayout);
|
|
Jeremy Bullock |
0a2e55 |
slidersLayout->addWidget(m_hsvFrame, 3);
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
7ae920 |
QVBoxLayout *alphaLayout = new QVBoxLayout();
|
|
Jeremy Bullock |
7ae920 |
alphaLayout->setMargin(4);
|
|
Jeremy Bullock |
7ae920 |
alphaLayout->setSpacing(4);
|
|
Jeremy Bullock |
7ae920 |
{ alphaLayout->addWidget(m_channelControls[eAlpha]); }
|
|
Jeremy Bullock |
0a2e55 |
m_alphaFrame->setLayout(alphaLayout);
|
|
Jeremy Bullock |
0a2e55 |
slidersLayout->addWidget(m_alphaFrame, 1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *rgbLayout = new QVBoxLayout();
|
|
Shinya Kitaoka |
120a6e |
rgbLayout->setMargin(4);
|
|
Shinya Kitaoka |
120a6e |
rgbLayout->setSpacing(4);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
rgbLayout->addWidget(m_channelControls[eRed]);
|
|
Shinya Kitaoka |
120a6e |
rgbLayout->addWidget(m_channelControls[eGreen]);
|
|
Shinya Kitaoka |
120a6e |
rgbLayout->addWidget(m_channelControls[eBlue]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Jeremy Bullock |
0a2e55 |
m_rgbFrame->setLayout(rgbLayout);
|
|
Jeremy Bullock |
0a2e55 |
slidersLayout->addWidget(m_rgbFrame, 3);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Jeremy Bullock |
4bf672 |
m_slidersContainer->setLayout(slidersLayout);
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->addWidget(m_slidersContainer);
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
mainLayout->addWidget(m_vSplitter, 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QList<int> list;
|
|
Shinya Kitaoka |
120a6e |
list << rect().height() / 2 << rect().height() / 2;
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setSizes(list);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// connect(m_squaredColorWheel, SIGNAL(colorChanged(const ColorModel &,
|
|
Shinya Kitaoka |
120a6e |
// bool)),
|
|
Shinya Kitaoka |
120a6e |
// this, SLOT(onWheelChanged(const ColorModel &, bool)));
|
|
Shinya Kitaoka |
120a6e |
connect(m_hexagonalColorWheel, SIGNAL(colorChanged(const ColorModel &, bool)),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(onWheelChanged(const ColorModel &, bool)));
|
|
Shinya Kitaoka |
120a6e |
// m_verticalSlider->setMaximumSize(20,150);
|
|
Shinya Kitaoka |
120a6e |
// connect(m_verticalSlider, SIGNAL(valueChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
// SLOT(onWheelSliderChanged(int)));
|
|
Shinya Kitaoka |
120a6e |
// connect(m_verticalSlider, SIGNAL(valueChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
// SLOT(onWheelSliderReleased()));
|
|
Shinya Kitaoka |
120a6e |
// connect( m_verticalSlider, SIGNAL(sliderReleased()), this,
|
|
Shinya Kitaoka |
120a6e |
// SLOT(onWheelSliderReleased()));
|
|
Shinya Kitaoka |
120a6e |
// connect(channelButtonGroup, SIGNAL(buttonClicked(int)), this,
|
|
Shinya Kitaoka |
120a6e |
// SLOT(setWheelChannel(int)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PlainColorPage::resizeEvent(QResizeEvent *) {
|
|
Shinya Kitaoka |
120a6e |
int w = width();
|
|
Shinya Kitaoka |
120a6e |
int h = height();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int parentW = parentWidget()->width();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PlainColorPage::updateControls() {
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < 7; i++) {
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i]->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
m_channelControls[i]->update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
m_squaredColorWheel->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
m_squaredColorWheel->update();
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_hexagonalColorWheel->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
m_hexagonalColorWheel->update();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
bool signalsBlocked = m_verticalSlider->blockSignals(true);
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->setColor(m_color);
|
|
Shinya Kitaoka |
120a6e |
int value = m_color.getValue(m_verticalSlider->getChannel());
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->update();
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->blockSignals(signalsBlocked);
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PlainColorPage::setColor(const TColorStyle &style,
|
|
Shinya Kitaoka |
120a6e |
int colorParameterIndex) {
|
|
Shinya Kitaoka |
120a6e |
TPixel32 newPixel = style.getColorParamValue(colorParameterIndex);
|
|
Shinya Kitaoka |
120a6e |
if (m_color.getTPixel() == newPixel) return;
|
|
Shinya Kitaoka |
120a6e |
bool oldSignalEnabled = m_signalEnabled;
|
|
Shinya Kitaoka |
120a6e |
m_signalEnabled = false;
|
|
Shinya Kitaoka |
120a6e |
m_color.setTPixel(newPixel);
|
|
Shinya Kitaoka |
120a6e |
updateControls();
|
|
Shinya Kitaoka |
120a6e |
m_signalEnabled = oldSignalEnabled;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void PlainColorPage::setIsVertical(bool isVertical) {
|
|
Jeremy Bullock |
4bf672 |
// if (m_isVertical == isVertical) return;
|
|
Jeremy Bullock |
4bf672 |
// not returning even if it already is the same orientation
|
|
Jeremy Bullock |
4bf672 |
// to take advantage of the resizing here
|
|
Jeremy Bullock |
4bf672 |
// this is useful for the first time the splitter is set
|
|
Jeremy Bullock |
4bf672 |
// afterwards, it will be overridden by the saved state
|
|
Jeremy Bullock |
4bf672 |
// from settings.
|
|
Jeremy Bullock |
4bf672 |
m_isVertical = isVertical;
|
|
Jeremy Bullock |
4bf672 |
if (isVertical) {
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setOrientation(Qt::Vertical);
|
|
Jeremy Bullock |
4bf672 |
QList<int> sectionSizes;
|
|
Jeremy Bullock |
4bf672 |
// maximize color wheel space
|
|
Jeremy Bullock |
4bf672 |
sectionSizes << height() - 1 << 1;
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setSizes(sectionSizes);
|
|
Jeremy Bullock |
4bf672 |
} else {
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setOrientation(Qt::Horizontal);
|
|
Jeremy Bullock |
4bf672 |
QList<int> sectionSizes;
|
|
Jeremy Bullock |
4bf672 |
sectionSizes << width() / 2 << width() / 2;
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->setSizes(sectionSizes);
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void PlainColorPage::toggleOrientation() { setIsVertical(!m_isVertical); }
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
QByteArray PlainColorPage::getSplitterState() {
|
|
Jeremy Bullock |
4bf672 |
return m_vSplitter->saveState();
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void PlainColorPage::setSplitterState(QByteArray state) {
|
|
Jeremy Bullock |
4bf672 |
m_vSplitter->restoreState(state);
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
a8f111 |
void PlainColorPage::updateColorCalibration() {
|
|
shun-iwasawa |
567f65 |
if (m_hexagonalColorWheel->isVisible())
|
|
shun-iwasawa |
567f65 |
m_hexagonalColorWheel->updateColorCalibration();
|
|
shun-iwasawa |
567f65 |
else
|
|
shun-iwasawa |
567f65 |
m_hexagonalColorWheel->cueCalibrationUpdate();
|
|
shun-iwasawa |
a8f111 |
}
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
a8f111 |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void PlainColorPage::setWheelChannel(int channel)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
assert(0<=channel && channel<7);
|
|
Shinya Kitaoka |
120a6e |
m_squaredColorWheel->setChannel(channel);
|
|
Toshihiro Shimizu |
890ddd |
bool signalsBlocked = m_verticalSlider->signalsBlocked();
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->blockSignals(true);
|
|
Shinya Kitaoka |
120a6e |
m_verticalSlider->setChannel((ColorChannel)channel);
|
|
Toshihiro Shimizu |
890ddd |
m_verticalSlider->setRange(0,ChannelMaxValues[channel]);
|
|
Toshihiro Shimizu |
890ddd |
m_verticalSlider->setValue(m_color.getValue((ColorChannel)channel));
|
|
Toshihiro Shimizu |
890ddd |
m_verticalSlider->update();
|
|
Toshihiro Shimizu |
890ddd |
m_verticalSlider->blockSignals(signalsBlocked);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PlainColorPage::onControlChanged(const ColorModel &color,
|
|
Shinya Kitaoka |
120a6e |
bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (!(m_color == color)) {
|
|
Shinya Kitaoka |
120a6e |
m_color = color;
|
|
Shinya Kitaoka |
120a6e |
updateControls();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_signalEnabled) emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PlainColorPage::onWheelChanged(const ColorModel &color, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (!(m_color == color)) {
|
|
Shinya Kitaoka |
120a6e |
m_color = color;
|
|
Shinya Kitaoka |
120a6e |
updateControls();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_signalEnabled) emit colorChanged(m_color, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void PlainColorPage::onWheelSliderChanged(int value)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
if(m_color.getValue(m_verticalSlider->getChannel()) == value) return;
|
|
Shinya Kitaoka |
120a6e |
m_color.setValue(m_verticalSlider->getChannel(), value);
|
|
Toshihiro Shimizu |
890ddd |
updateControls();
|
|
Toshihiro Shimizu |
890ddd |
if(m_signalEnabled)
|
|
Toshihiro Shimizu |
890ddd |
emit colorChanged(m_color, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void PlainColorPage::onWheelSliderReleased()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
emit colorChanged(m_color, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// StyleChooserPage implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFilePath StyleChooserPage::m_rootPath;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
StyleChooserPage::StyleChooserPage(StyleEditor *styleEditor, QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: StyleEditorPage(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_chipOrigin(5, 3)
|
|
Shinya Kitaoka |
120a6e |
, m_chipSize(25, 25)
|
|
Shinya Kitaoka |
120a6e |
, m_chipPerRow(0)
|
|
justburner |
981d46 |
, m_pinsToTopDirty(false)
|
|
justburner |
981d46 |
, m_styleEditor(styleEditor) {
|
|
justburner |
981d46 |
//, m_currentIndex(-1) {
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
setObjectName("StyleChooserPage");
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
m_pinToTopAct = new QAction(tr("Pin To Top"), this);
|
|
justburner |
981d46 |
m_pinToTopAct->setCheckable(true);
|
|
justburner |
981d46 |
m_setPinsToTopAct = new QAction(tr("Set Pins To Top"), this);
|
|
justburner |
981d46 |
m_clrPinsToTopAct = new QAction(tr("Clear Pins To Top"), this);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
FavoritesManager *favorites = FavoritesManager::instance();
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
bool ret = true;
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
ret = ret && connect(m_pinToTopAct, SIGNAL(triggered()), this,
|
|
justburner |
981d46 |
SLOT(togglePinToTop()));
|
|
justburner |
981d46 |
ret = ret && connect(m_setPinsToTopAct, SIGNAL(triggered()), this,
|
|
justburner |
981d46 |
SLOT(doSetPinsToTop()));
|
|
justburner |
981d46 |
ret = ret && connect(m_clrPinsToTopAct, SIGNAL(triggered()), this,
|
|
justburner |
981d46 |
SLOT(doClrPinsToTop()));
|
|
justburner |
981d46 |
ret = ret && connect(favorites, SIGNAL(pinsToTopChanged()), this,
|
|
justburner |
981d46 |
SLOT(doPinsToTopChange()));
|
|
justburner |
981d46 |
assert(ret);
|
|
justburner |
981d46 |
setMouseTracking(true);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleChooserPage::setChipSize(QSize chipSize) {
|
|
justburner |
981d46 |
if (chipSize.width() < 4) chipSize.setWidth(4);
|
|
justburner |
981d46 |
if (chipSize.height() < 4) chipSize.setHeight(4);
|
|
justburner |
981d46 |
m_chipSize = chipSize;
|
|
justburner |
981d46 |
computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleChooserPage::applyFilter() {
|
|
justburner |
981d46 |
assert(m_manager);
|
|
justburner |
981d46 |
m_manager->applyFilter();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleChooserPage::applyFilter(const QString text) {
|
|
justburner |
981d46 |
assert(m_manager);
|
|
justburner |
981d46 |
m_manager->applyFilter(text);
|
|
justburner |
981d46 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void StyleChooserPage::paintEvent(QPaintEvent *) {
|
|
justburner |
981d46 |
if (loadIfNeeded() || m_pinsToTopDirty) {
|
|
justburner |
981d46 |
m_pinsToTopDirty = false;
|
|
justburner |
981d46 |
applyFilter();
|
|
justburner |
981d46 |
computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
// Get current selected style
|
|
justburner |
981d46 |
TColorStyleP selectedStyle = nullptr;
|
|
justburner |
981d46 |
if (m_styleEditor) selectedStyle = m_styleEditor->getEditedStyle();
|
|
justburner |
981d46 |
|
|
Shinya Kitaoka |
120a6e |
QPainter p(this);
|
|
Shinya Kitaoka |
120a6e |
// p.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
int maxCount = getChipCount();
|
|
justburner |
981d46 |
if (m_chipPerRow == 0 || maxCount == 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int w = parentWidget()->width();
|
|
Shinya Kitaoka |
120a6e |
int chipLx = m_chipSize.width(), chipLy = m_chipSize.height();
|
|
Shinya Kitaoka |
120a6e |
int nX = m_chipPerRow;
|
|
justburner |
981d46 |
int nY = (maxCount + m_chipPerRow - 1) / m_chipPerRow;
|
|
Shinya Kitaoka |
120a6e |
int x0 = m_chipOrigin.x();
|
|
Shinya Kitaoka |
120a6e |
int y0 = m_chipOrigin.y();
|
|
Shinya Kitaoka |
120a6e |
int i, j;
|
|
Shinya Kitaoka |
120a6e |
QRect currentIndexRect = QRect();
|
|
Shinya Kitaoka |
120a6e |
int count = 0;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < nY; i++)
|
|
Shinya Kitaoka |
120a6e |
for (j = 0; j < nX; j++) {
|
|
Shinya Kitaoka |
120a6e |
QRect rect(x0 + chipLx * j + 2, y0 + chipLy * i + 2, chipLx, chipLy);
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
int chipType = drawChip(p, rect, count);
|
|
justburner |
981d46 |
if (chipType == COMMONCHIP) {
|
|
justburner |
981d46 |
p.setPen(m_commonChipBoxColor);
|
|
justburner |
981d46 |
p.drawRect(rect);
|
|
justburner |
981d46 |
} else if (chipType == PINNEDCHIP) {
|
|
justburner |
981d46 |
p.setPen(m_pinnedChipBoxColor);
|
|
justburner |
981d46 |
p.drawRect(rect.adjusted(0, 0, -1, -1));
|
|
justburner |
981d46 |
} else { // SOLIDCHIP
|
|
justburner |
981d46 |
p.setPen(m_solidChipBoxColor);
|
|
justburner |
981d46 |
p.drawRect(rect.adjusted(0, 0, -1, -1));
|
|
justburner |
981d46 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
// if (m_currentIndex == count) currentIndexRect = rect;
|
|
justburner |
981d46 |
if (isSameStyle(selectedStyle, count)) currentIndexRect = rect;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
count++;
|
|
justburner |
981d46 |
if (count >= maxCount) break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!currentIndexRect.isEmpty()) {
|
|
Shinya Kitaoka |
120a6e |
// Draw the curentIndex border
|
|
justburner |
981d46 |
p.setPen(m_selectedChipBoxColor);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentIndexRect);
|
|
justburner |
981d46 |
p.setPen(m_selectedChipBox2Color);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentIndexRect.adjusted(1, 1, -1, -1));
|
|
justburner |
981d46 |
p.setPen(m_selectedChipBoxColor);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentIndexRect.adjusted(2, 2, -2, -2));
|
|
justburner |
981d46 |
p.setPen(m_commonChipBoxColor);
|
|
Shinya Kitaoka |
120a6e |
p.drawRect(currentIndexRect.adjusted(3, 3, -3, -3));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void StyleChooserPage::patternAdded() {
|
|
justburner |
981d46 |
applyFilter();
|
|
justburner |
981d46 |
computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
Shinya Kitaoka |
120a6e |
void StyleChooserPage::computeSize() {
|
|
Shinya Kitaoka |
120a6e |
int w = width();
|
|
Shinya Kitaoka |
120a6e |
m_chipPerRow = (w - 15) / m_chipSize.width();
|
|
Shinya Kitaoka |
120a6e |
int rowCount = 0;
|
|
Shinya Kitaoka |
120a6e |
if (m_chipPerRow != 0)
|
|
Shinya Kitaoka |
120a6e |
rowCount = (getChipCount() + m_chipPerRow - 1) / m_chipPerRow;
|
|
Jeremy Bullock |
4bf672 |
setMinimumSize(3 * m_chipSize.width(), rowCount * m_chipSize.height() + 10);
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int StyleChooserPage::posToIndex(const QPoint &pos) const {
|
|
Shinya Kitaoka |
120a6e |
if (m_chipPerRow == 0) return -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int x = (pos.x() - m_chipOrigin.x() - 2) / m_chipSize.width();
|
|
Shinya Kitaoka |
120a6e |
if (x >= m_chipPerRow) return -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int y = (pos.y() - m_chipOrigin.y() - 2) / m_chipSize.height();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int index = x + m_chipPerRow * y;
|
|
Shinya Kitaoka |
120a6e |
if (index < 0 || index >= getChipCount()) return -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return index;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleChooserPage::mousePressEvent(QMouseEvent *event) {
|
|
Shinya Kitaoka |
120a6e |
QPoint pos = event->pos();
|
|
Shinya Kitaoka |
120a6e |
int currentIndex = posToIndex(pos);
|
|
Shinya Kitaoka |
120a6e |
if (currentIndex < 0) return;
|
|
justburner |
981d46 |
// m_currentIndex = currentIndex;
|
|
Shinya Kitaoka |
120a6e |
onSelect(currentIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void StyleChooserPage::mouseMoveEvent(QMouseEvent *event) {
|
|
justburner |
981d46 |
QPoint pos = event->pos();
|
|
justburner |
981d46 |
int currentIndex = posToIndex(pos);
|
|
justburner |
981d46 |
if (currentIndex >= 0 && currentIndex < getChipCount())
|
|
justburner |
981d46 |
setCursor(Qt::PointingHandCursor);
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
setCursor(Qt::ArrowCursor);
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void StyleChooserPage::mouseReleaseEvent(QMouseEvent *event) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
void StyleChooserPage::contextMenuEvent(QContextMenuEvent *event) {
|
|
justburner |
981d46 |
QPoint pos = event->pos();
|
|
justburner |
981d46 |
int currentIndex = posToIndex(pos);
|
|
justburner |
981d46 |
if (currentIndex < 0) return;
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
// Get current selected style
|
|
justburner |
981d46 |
TColorStyleP selectedStyle = nullptr;
|
|
justburner |
981d46 |
if (m_styleEditor) selectedStyle = m_styleEditor->getEditedStyle();
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
if (!selectedStyle) return;
|
|
justburner |
981d46 |
std::string idname = selectedStyle->getBrushIdName();
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
// Blacklist "no brush" since it's always pinned/favorite
|
|
justburner |
981d46 |
if (idname == "SolidColorStyle") return;
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
QMenu menu(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
FavoritesManager *favorites = FavoritesManager::instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
m_pinToTopAct->setChecked(favorites->getPinToTop(idname));
|
|
justburner |
981d46 |
menu.addAction(m_pinToTopAct);
|
|
justburner |
981d46 |
// menu.addSeparator();
|
|
justburner |
981d46 |
// QMenu *menuvis = menu.addMenu("Visible Brushes");
|
|
justburner |
981d46 |
// menuvis->addAction(m_setPinsToTopAct);
|
|
justburner |
981d46 |
// menuvis->addAction(m_clrPinsToTopAct);
|
|
justburner |
981d46 |
menu.exec(event->globalPos());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
bool StyleChooserPage::event(QEvent *e) {
|
|
Shinya Kitaoka |
120a6e |
// Intercept tooltip events
|
|
justburner |
981d46 |
if (e->type() != QEvent::ToolTip) return StyleEditorPage::event(e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// see StyleChooserPage::paintEvent
|
|
justburner |
981d46 |
QHelpEvent *he = static_cast<QHelpEvent *>(e);
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
int chipIdx = posToIndex(he->pos()), chipCount = getChipCount();
|
|
justburner |
981d46 |
if (chipIdx < 0 || chipIdx >= chipCount) {
|
|
justburner |
981d46 |
QToolTip::hideText();
|
|
justburner |
981d46 |
return false;
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
QString toolTip = getChipDescription(chipIdx);
|
|
justburner |
981d46 |
if (toolTip.isEmpty())
|
|
justburner |
981d46 |
QToolTip::hideText();
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
QToolTip::showText(he->globalPos(), toolTip);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void StyleChooserPage::togglePinToTop() {
|
|
justburner |
981d46 |
// Get current selected style
|
|
justburner |
981d46 |
TColorStyleP selectedStyle = nullptr;
|
|
justburner |
981d46 |
if (m_styleEditor) selectedStyle = m_styleEditor->getEditedStyle();
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
if (!selectedStyle) return;
|
|
justburner |
981d46 |
std::string idname = selectedStyle->getBrushIdName();
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
FavoritesManager *favorites = FavoritesManager::instance();
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
favorites->togglePinToTop(idname);
|
|
justburner |
981d46 |
favorites->savePinsToTop();
|
|
justburner |
981d46 |
favorites->emitPinsToTopChange();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void StyleChooserPage::doSetPinsToTop() {
|
|
justburner |
981d46 |
FavoritesManager *favorites = FavoritesManager::instance();
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
int len = m_manager->countData();
|
|
justburner |
981d46 |
for (int i = 0; i < len; i++) {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(i);
|
|
justburner |
981d46 |
favorites->setPinToTop(data.idname, true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
justburner |
981d46 |
favorites->savePinsToTop();
|
|
justburner |
981d46 |
favorites->emitPinsToTopChange();
|
|
justburner |
981d46 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
void StyleChooserPage::doClrPinsToTop() {
|
|
justburner |
981d46 |
FavoritesManager *favorites = FavoritesManager::instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
int len = m_manager->countData();
|
|
justburner |
981d46 |
for (int i = 0; i < len; i++) {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(i);
|
|
justburner |
981d46 |
favorites->setPinToTop(data.idname, false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
justburner |
981d46 |
favorites->savePinsToTop();
|
|
justburner |
981d46 |
favorites->emitPinsToTopChange();
|
|
justburner |
981d46 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
void StyleChooserPage::doPinsToTopChange() {
|
|
justburner |
981d46 |
if (!m_pinsToTopDirty) m_pinsToTopDirty = true;
|
|
justburner |
981d46 |
update();
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
// TOGLIERE
|
|
justburner |
981d46 |
void StyleChooserPage::setRootPath(const TFilePath &rootPath) {
|
|
justburner |
981d46 |
m_rootPath = rootPath;
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
justburner |
981d46 |
// CustomStyleChooser implementation
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
int CustomStyleChooserPage::drawChip(QPainter &p, QRect rect, int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index);
|
|
justburner |
981d46 |
if (!data.image.isNull()) p.drawImage(rect, data.image);
|
|
justburner |
981d46 |
return data.markPinToTop ? PINNEDCHIP : COMMONCHIP;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void CustomStyleChooserPage::onSelect(int index) {
|
|
justburner |
981d46 |
if (index < 0 || index >= getChipCount()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
std::string name = data.name.toStdString();
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
if (data.isVector) {
|
|
justburner |
981d46 |
TVectorImagePatternStrokeStyle cs(name);
|
|
justburner |
981d46 |
emit styleSelected(cs);
|
|
justburner |
981d46 |
} else {
|
|
justburner |
981d46 |
TRasterImagePatternStrokeStyle cs(name);
|
|
justburner |
981d46 |
emit styleSelected(cs);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
bool CustomStyleChooserPage::isSameStyle(const TColorStyleP style, int index) {
|
|
justburner |
981d46 |
return style->getBrushIdHash() == m_manager->getData(index).hash;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
QString CustomStyleChooserPage::getChipDescription(int index) {
|
|
justburner |
981d46 |
return m_manager->getData(index).desc;
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
justburner |
981d46 |
// VectorBrushStyleChooser implementation
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
int VectorBrushStyleChooserPage::drawChip(QPainter &p, QRect rect, int index) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0) {
|
|
Shinya Kitaoka |
120a6e |
static QImage noSpecialStyleImage(":Resources/no_vectorbrush.png");
|
|
Shinya Kitaoka |
120a6e |
p.drawImage(rect, noSpecialStyleImage);
|
|
justburner |
981d46 |
return SOLIDCHIP;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
p.drawImage(rect, data.image);
|
|
justburner |
981d46 |
return data.markPinToTop ? PINNEDCHIP : COMMONCHIP;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void VectorBrushStyleChooserPage::onSelect(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (index < 0 || index >= getChipCount()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (index > 0) {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
std::string name = data.name.toStdString();
|
|
justburner |
981d46 |
assert(data.isVector); // must be Vector
|
|
justburner |
981d46 |
if (!data.isVector) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TVectorBrushStyle cs(name);
|
|
Shinya Kitaoka |
120a6e |
emit styleSelected(cs);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
justburner |
981d46 |
static TSolidColorStyle noStyle(TPixel32::Black);
|
|
justburner |
981d46 |
emit styleSelected(noStyle);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
bool VectorBrushStyleChooserPage::isSameStyle(const TColorStyleP style,
|
|
justburner |
981d46 |
int index) {
|
|
justburner |
981d46 |
if (index > 0) {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
if (!data.isVector) return false; // must be Vector
|
|
justburner |
981d46 |
return style->getBrushIdHash() == data.hash;
|
|
justburner |
981d46 |
} else
|
|
justburner |
981d46 |
return style->getBrushIdHash() == TSolidColorStyle::staticBrushIdHash();
|
|
justburner |
981d46 |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
QString VectorBrushStyleChooserPage::getChipDescription(int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return m_manager->getData(index - 1).desc;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return QObject::tr("Plain color", "VectorBrushStyleChooserPage");
|
|
justburner |
981d46 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
justburner |
981d46 |
// TextureStyleChooser implementation
|
|
justburner |
981d46 |
//*****************************************************************************
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
int TextureStyleChooserPage::drawChip(QPainter &p, QRect rect, int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
if (index == 0) {
|
|
justburner |
981d46 |
static QImage noStyleImage(":Resources/no_texturestyle.png");
|
|
justburner |
981d46 |
p.drawImage(rect, noStyleImage);
|
|
justburner |
981d46 |
return SOLIDCHIP;
|
|
justburner |
981d46 |
} else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
p.drawImage(rect, data.image);
|
|
justburner |
981d46 |
return data.markPinToTop ? PINNEDCHIP : COMMONCHIP;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
void TextureStyleChooserPage::onSelect(int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
if (index == 0) {
|
|
justburner |
981d46 |
static TSolidColorStyle noStyle(TPixel32::Black);
|
|
justburner |
981d46 |
emit styleSelected(noStyle);
|
|
justburner |
981d46 |
} else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
TTextureStyle style(data.raster, TFilePath(data.name.toStdWString()));
|
|
justburner |
981d46 |
emit styleSelected(style);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
bool TextureStyleChooserPage::isSameStyle(const TColorStyleP style, int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return style->getBrushIdHash() == m_manager->getData(index - 1).hash;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return style->getBrushIdHash() == TSolidColorStyle::staticBrushIdHash();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
QString TextureStyleChooserPage::getChipDescription(int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return m_manager->getData(index - 1).desc;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return QObject::tr("Plain color", "TextureStyleChooserPage");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
justburner |
981d46 |
// MyPaintBrushStyleChooserPage implementation
|
|
Ivan Mahonin |
bf1d82 |
//*****************************************************************************
|
|
Ivan Mahonin |
bf1d82 |
|
|
justburner |
981d46 |
int MyPaintBrushStyleChooserPage::drawChip(QPainter &p, QRect rect, int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
justburner |
981d46 |
if (index == 0) {
|
|
Ivan Mahonin |
bf1d82 |
static QImage noStyleImage(":Resources/no_mypaintbrush.png");
|
|
justburner |
981d46 |
p.drawImage(rect, noStyleImage);
|
|
justburner |
981d46 |
return SOLIDCHIP;
|
|
justburner |
981d46 |
} else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
p.drawImage(rect, data.image);
|
|
justburner |
981d46 |
return data.markPinToTop ? PINNEDCHIP : COMMONCHIP;
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
justburner |
981d46 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
Ivan Mahonin |
bf1d82 |
|
|
justburner |
981d46 |
void MyPaintBrushStyleChooserPage::onSelect(int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
justburner |
981d46 |
if (index == 0) {
|
|
Ivan Mahonin |
bf1d82 |
static TSolidColorStyle noStyle(TPixel32::Black);
|
|
justburner |
981d46 |
emit styleSelected(noStyle);
|
|
justburner |
981d46 |
} else {
|
|
justburner |
981d46 |
--index;
|
|
justburner |
981d46 |
emit styleSelected(getBrush(index));
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
justburner |
981d46 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
//-----------------------------------------------------------------------------
|
|
Ivan Mahonin |
bf1d82 |
|
|
justburner |
981d46 |
bool MyPaintBrushStyleChooserPage::isSameStyle(const TColorStyleP style,
|
|
justburner |
981d46 |
int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return style->getBrushIdHash() == getBrush(index - 1).getBrushIdHash();
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return style->getBrushIdHash() == TSolidColorStyle::staticBrushIdHash();
|
|
justburner |
981d46 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
//-----------------------------------------------------------------------------
|
|
Ivan Mahonin |
bf1d82 |
|
|
justburner |
981d46 |
QString MyPaintBrushStyleChooserPage::getChipDescription(int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return m_manager->getData(index - 1).desc;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return QObject::tr("Plain color", "MyPaintBrushStyleChooserPage");
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
//*****************************************************************************
|
|
justburner |
981d46 |
// SpecialStyleChooser implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
981d46 |
int SpecialStyleChooserPage::drawChip(QPainter &p, QRect rect, int index) {
|
|
Shinya Kitaoka |
120a6e |
if (index == 0) {
|
|
Shinya Kitaoka |
120a6e |
static QImage noSpecialStyleImage(":Resources/no_specialstyle.png");
|
|
Shinya Kitaoka |
120a6e |
p.drawImage(rect, noSpecialStyleImage);
|
|
justburner |
981d46 |
return SOLIDCHIP;
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
p.drawImage(rect, data.image);
|
|
justburner |
981d46 |
return data.markPinToTop ? PINNEDCHIP : COMMONCHIP;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SpecialStyleChooserPage::onSelect(int index) {
|
|
justburner |
981d46 |
assert(0 <= index && index < getChipCount());
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *cs = 0;
|
|
justburner |
981d46 |
// if (m_currentIndex < 0) return;
|
|
Shinya Kitaoka |
120a6e |
if (index == 0)
|
|
Shinya Kitaoka |
120a6e |
cs = new TSolidColorStyle(TPixel32::Black);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
justburner |
981d46 |
auto &data = m_manager->getData(index - 1);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
cs = TColorStyle::create(data.tagId);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
justburner |
981d46 |
|
|
Shinya Kitaoka |
120a6e |
emit styleSelected(*cs);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
bool SpecialStyleChooserPage::isSameStyle(const TColorStyleP style, int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return style->getBrushIdHash() == m_manager->getData(index - 1).hash;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return style->getBrushIdHash() == TSolidColorStyle::staticBrushIdHash();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
QString SpecialStyleChooserPage::getChipDescription(int index) {
|
|
justburner |
981d46 |
if (index > 0)
|
|
justburner |
981d46 |
return m_manager->getData(index - 1).desc;
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
return QObject::tr("Plain color", "SpecialStyleChooserPage");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// SettingBox
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
SettingBox::SettingBox(QWidget *parent, int index)
|
|
Toshihiro Shimizu |
890ddd |
: QWidget(parent)
|
|
Toshihiro Shimizu |
890ddd |
, m_index(index)
|
|
Toshihiro Shimizu |
890ddd |
, m_style(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
|
Shinya Kitaoka |
120a6e |
hLayout->setSpacing(5);
|
|
Shinya Kitaoka |
120a6e |
hLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addSpacing(10);
|
|
Shinya Kitaoka |
120a6e |
m_name = new QLabel(this);
|
|
Shinya Kitaoka |
120a6e |
m_name->setFixedSize(82,20);
|
|
Shinya Kitaoka |
120a6e |
m_name->setStyleSheet("border: 0px;");
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_name,0);
|
|
Shinya Kitaoka |
120a6e |
m_doubleField = new DoubleField(this, true);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_doubleField,1);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addSpacing(10);
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(m_doubleField, SIGNAL(valueChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged(bool)));
|
|
Toshihiro Shimizu |
890ddd |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
setLayout(hLayout);
|
|
Shinya Kitaoka |
120a6e |
setFixedHeight(22);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SettingBox::setParameters(TColorStyle* cs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
if(!cs)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
m_style = cs;
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if(cs->getParamCount() == 0 || m_index<0 ||
|
|
Shinya Kitaoka |
120a6e |
cs->getParamCount()<=m_index)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
QString paramName = cs->getParamNames(m_index);
|
|
Shinya Kitaoka |
120a6e |
m_name->setText(paramName);
|
|
Toshihiro Shimizu |
890ddd |
double newValue = cs->getParamValue(TColorStyle::double_tag(), m_index);
|
|
Shinya Kitaoka |
120a6e |
double value = m_doubleField->getValue();
|
|
Shinya Kitaoka |
120a6e |
m_style = cs;
|
|
Shinya Kitaoka |
120a6e |
if(value != newValue)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
double min=0, max=1;
|
|
Shinya Kitaoka |
120a6e |
cs->getParamRange(m_index,min,max);
|
|
Shinya Kitaoka |
120a6e |
m_doubleField->setValues(newValue, min, max);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TCleanupStyle* cleanupStyle = dynamic_cast<TCleanupStyle*>(cs);
|
|
Shinya Kitaoka |
120a6e |
if(paramName == "Contrast" && cleanupStyle)
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
if(!cleanupStyle->isContrastEnabled())
|
|
Shinya Kitaoka |
120a6e |
m_doubleField->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_doubleField->setEnabled(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SettingBox::setColorStyleParam(double value, bool isDragging)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TColorStyle* style = m_style;
|
|
Toshihiro Shimizu |
890ddd |
assert(style && m_index < style->getParamCount());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double min = 0.0, max = 1.0;
|
|
Toshihiro Shimizu |
890ddd |
style->getParamRange(m_index, min, max);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
style->setParamValue(m_index, tcrop(value, min, max));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
emit valueChanged(*style, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SettingBox::onValueChanged(bool isDragging)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
if(!m_style || m_style->getParamCount() == 0)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double value = m_doubleField->getValue();
|
|
Shinya Kitaoka |
120a6e |
if(isDragging && m_style->getParamValue(TColorStyle::double_tag(),
|
|
Shinya Kitaoka |
120a6e |
m_index) == value)
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setColorStyleParam(value, isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SettingsPage implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
SettingsPage::SettingsPage(QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QScrollArea(parent), m_updating(false) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setObjectName("styleEditorPage"); // It is necessary for the styleSheet
|
|
Shinya Kitaoka |
120a6e |
setFrameStyle(QFrame::StyledPanel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
setWidgetResizable(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Build the scrolled widget
|
|
Shinya Kitaoka |
120a6e |
QFrame *paramsContainer = new QFrame(this);
|
|
Shinya Kitaoka |
120a6e |
setWidget(paramsContainer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QVBoxLayout *paramsContainerLayout = new QVBoxLayout(this);
|
|
shun-iwasawa |
2a343c |
paramsContainerLayout->setMargin(10);
|
|
shun-iwasawa |
2a343c |
paramsContainerLayout->setSpacing(10);
|
|
Shinya Kitaoka |
120a6e |
paramsContainer->setLayout(paramsContainerLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Add a vertical layout to store the "autofill" checkbox widgets
|
|
shun-iwasawa |
2a343c |
m_autoFillCheckBox = new QCheckBox(tr("Autopaint for Lines"), this);
|
|
shun-iwasawa |
2a343c |
paramsContainerLayout->addWidget(m_autoFillCheckBox, 0,
|
|
shun-iwasawa |
2a343c |
Qt::AlignLeft | Qt::AlignVCenter);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
2a343c |
ret = connect(m_autoFillCheckBox, SIGNAL(stateChanged(int)), this,
|
|
shun-iwasawa |
2a343c |
SLOT(onAutofillChanged()));
|
|
shun-iwasawa |
2a343c |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Prepare the style parameters layout
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout = new QGridLayout;
|
|
shun-iwasawa |
2a343c |
m_paramsLayout->setMargin(0);
|
|
shun-iwasawa |
2a343c |
m_paramsLayout->setVerticalSpacing(8);
|
|
shun-iwasawa |
2a343c |
m_paramsLayout->setHorizontalSpacing(5);
|
|
Shinya Kitaoka |
120a6e |
paramsContainerLayout->addLayout(m_paramsLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
2a343c |
paramsContainerLayout->addStretch(1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SettingsPage::enableAutopaintToggle(bool enabled) {
|
|
shun-iwasawa |
2a343c |
m_autoFillCheckBox->setVisible(enabled);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SettingsPage::setStyle(const TColorStyleP &editedStyle) {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
inline static void clearLayout(QLayout *layout) {
|
|
Shinya Kitaoka |
120a6e |
QLayoutItem *item;
|
|
Shinya Kitaoka |
120a6e |
while ((item = layout->takeAt(0)) != 0) {
|
|
Shinya Kitaoka |
120a6e |
delete item->layout();
|
|
Shinya Kitaoka |
120a6e |
delete item->spacerItem();
|
|
Shinya Kitaoka |
120a6e |
delete item->widget();
|
|
Shinya Kitaoka |
120a6e |
delete item;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}; // locals
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// NOTE: Layout reubilds must be avoided whenever possible. In particular, be
|
|
Shinya Kitaoka |
120a6e |
// warned that this
|
|
Shinya Kitaoka |
120a6e |
// function may be invoked when signals emitted from this function are still
|
|
Shinya Kitaoka |
120a6e |
// "flying"...
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool clearLayout =
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle &&
|
|
Shinya Kitaoka |
120a6e |
!(editedStyle && typeid(*m_editedStyle) == typeid(*editedStyle));
|
|
Shinya Kitaoka |
120a6e |
bool buildLayout =
|
|
Shinya Kitaoka |
120a6e |
editedStyle &&
|
|
Shinya Kitaoka |
120a6e |
!(m_editedStyle && typeid(*m_editedStyle) == typeid(*editedStyle));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle = editedStyle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (clearLayout) locals::clearLayout(m_paramsLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (buildLayout) {
|
|
Shinya Kitaoka |
120a6e |
assert(m_paramsLayout->count() == 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Assign new settings widgets - one label/editor for each parameter
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int p, pCount = editedStyle->getParamCount();
|
|
Shinya Kitaoka |
120a6e |
for (p = 0; p != pCount; ++p) {
|
|
Shinya Kitaoka |
120a6e |
// Assign label
|
|
Shinya Kitaoka |
120a6e |
QLabel *label = new QLabel(editedStyle->getParamNames(p));
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(label, p, 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Assign parameter
|
|
Shinya Kitaoka |
120a6e |
switch (editedStyle->getParamType(p)) {
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::BOOL: {
|
|
Shinya Kitaoka |
120a6e |
QCheckBox *checkBox = new QCheckBox;
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(checkBox, p, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ret = QObject::connect(checkBox, SIGNAL(toggled(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::INT: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::IntField *intField = new DVGui::IntField;
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(intField, p, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int min, max;
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamRange(p, min, max);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
intField->setRange(min, max);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ret = QObject::connect(intField, SIGNAL(valueChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged(bool))) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::ENUM: {
|
|
Shinya Kitaoka |
120a6e |
QComboBox *comboBox = new QComboBox;
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(comboBox, p, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList items;
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamRange(p, items);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
comboBox->addItems(items);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ret = QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::DOUBLE: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::DoubleField *doubleField = new DVGui::DoubleField;
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(doubleField, p, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double min, max;
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamRange(p, min, max);
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
doubleField->setRange(min, max);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ret = QObject::connect(doubleField, SIGNAL(valueChanged(bool)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged(bool))) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::FILEPATH: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::FileField *fileField = new DVGui::FileField;
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->addWidget(fileField, p, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QStringList extensions;
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamRange(p, extensions);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
fileField->setFileMode(QFileDialog::AnyFile);
|
|
Shinya Kitaoka |
120a6e |
fileField->setFilters(extensions);
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
fileField->setPath(QString::fromStdWString(
|
|
Shinya Kitaoka |
120a6e |
editedStyle->getParamValue(TColorStyle::TFilePath_tag(), p)
|
|
Shinya Kitaoka |
120a6e |
.getWideString()));
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
ret = QObject::connect(fileField, SIGNAL(pathChanged()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Ivan Mahonin |
bf1d82 |
// "reset to default" button
|
|
Ivan Mahonin |
bf1d82 |
if (m_editedStyle->hasParamDefault(p)) {
|
|
Ivan Mahonin |
bf1d82 |
QPushButton *pushButton = new QPushButton;
|
|
Ivan Mahonin |
bf1d82 |
pushButton->setToolTip(tr("Reset to default"));
|
|
shun_iwasawa |
3cc41f |
pushButton->setIcon(createQIcon("delete"));
|
|
Kite |
521c84 |
pushButton->setFixedSize(24, 24);
|
|
Ivan Mahonin |
bf1d82 |
m_paramsLayout->addWidget(pushButton, p, 2);
|
|
Ivan Mahonin |
bf1d82 |
ret = QObject::connect(pushButton, SIGNAL(clicked(bool)), this,
|
|
Ivan Mahonin |
bf1d82 |
SLOT(onValueReset())) &&
|
|
Ivan Mahonin |
bf1d82 |
ret;
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateValues();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SettingsPage::updateValues() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_editedStyle) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
struct Updating {
|
|
Shinya Kitaoka |
120a6e |
SettingsPage *m_this; // Prevent 'param changed' signals from being
|
|
Shinya Kitaoka |
120a6e |
~Updating() {
|
|
Shinya Kitaoka |
120a6e |
m_this->m_updating = false;
|
|
Shinya Kitaoka |
120a6e |
} // sent when updating editor widgets - this is
|
|
Shinya Kitaoka |
120a6e |
} updating = {(m_updating = true, this)}; // just a view REFRESH function.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Deal with the autofill
|
|
Shinya Kitaoka |
120a6e |
m_autoFillCheckBox->setChecked(m_editedStyle->getFlags() & 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int p, pCount = m_editedStyle->getParamCount();
|
|
Shinya Kitaoka |
120a6e |
for (p = 0; p != pCount; ++p) {
|
|
Ivan Mahonin |
bf1d82 |
// Update state of "reset to default" button
|
|
Ivan Mahonin |
bf1d82 |
if (m_editedStyle->hasParamDefault(p)) {
|
|
Ivan Mahonin |
bf1d82 |
QPushButton *pushButton = static_cast<QPushButton *>(
|
|
Ivan Mahonin |
bf1d82 |
m_paramsLayout->itemAtPosition(p, 2)->widget());
|
|
Ivan Mahonin |
bf1d82 |
pushButton->setEnabled(m_editedStyle->isParamDefault(p));
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Shinya Kitaoka |
120a6e |
// Update editor values
|
|
Shinya Kitaoka |
120a6e |
switch (m_editedStyle->getParamType(p)) {
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::BOOL: {
|
|
Shinya Kitaoka |
120a6e |
QCheckBox *checkBox = static_cast<QCheckBox *>(
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->itemAtPosition(p, 1)->widget());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
checkBox->setChecked(
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamValue(TColorStyle::bool_tag(), p));
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::INT: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::IntField *intField = static_cast<DVGui::IntField *>(
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->itemAtPosition(p, 1)->widget());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
intField->setValue(
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamValue(TColorStyle::int_tag(), p));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::ENUM: {
|
|
Shinya Kitaoka |
120a6e |
QComboBox *comboBox = static_cast<QComboBox *>(
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->itemAtPosition(p, 1)->widget());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
comboBox->setCurrentIndex(
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamValue(TColorStyle::int_tag(), p));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::DOUBLE: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::DoubleField *doubleField = static_cast<DVGui::DoubleField *>(
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->itemAtPosition(p, 1)->widget());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
doubleField->setValue(
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamValue(TColorStyle::double_tag(), p));
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::FILEPATH: {
|
|
Shinya Kitaoka |
120a6e |
DVGui::FileField *fileField = static_cast<DVGui::FileField *>(
|
|
Shinya Kitaoka |
120a6e |
m_paramsLayout->itemAtPosition(p, 1)->widget());
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
fileField->setPath(QString::fromStdWString(
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getParamValue(TColorStyle::TFilePath_tag(), p)
|
|
Shinya Kitaoka |
120a6e |
.getWideString()));
|
|
Shinya Kitaoka |
d4642c |
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SettingsPage::onAutofillChanged() {
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setFlags((unsigned int)(m_autoFillCheckBox->isChecked()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_updating)
|
|
Shinya Kitaoka |
120a6e |
emit paramStyleChanged(false); // Forward the signal to the style editor
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Ivan Mahonin |
bf1d82 |
int SettingsPage::getParamIndex(const QWidget *widget) {
|
|
Ivan Mahonin |
bf1d82 |
int p, pCount = m_paramsLayout->rowCount();
|
|
Ivan Mahonin |
bf1d82 |
for (p = 0; p != pCount; ++p)
|
|
shun_iwasawa |
3cc41f |
for (int c = 0; c < 3; ++c)
|
|
Ivan Mahonin |
bf1d82 |
if (QLayoutItem *item = m_paramsLayout->itemAtPosition(p, c))
|
|
shun_iwasawa |
3cc41f |
if (item->widget() == widget) return p;
|
|
Ivan Mahonin |
bf1d82 |
return -1;
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Ivan Mahonin |
bf1d82 |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Ivan Mahonin |
bf1d82 |
void SettingsPage::onValueReset() {
|
|
Ivan Mahonin |
bf1d82 |
assert(m_editedStyle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Ivan Mahonin |
bf1d82 |
// Extract the parameter index
|
|
Ivan Mahonin |
bf1d82 |
QWidget *senderWidget = static_cast<QWidget *>(sender());
|
|
Ivan Mahonin |
bf1d82 |
int p = getParamIndex(senderWidget);
|
|
Shinya Kitaoka |
120a6e |
|
|
Ivan Mahonin |
bf1d82 |
assert(0 <= p && p < m_editedStyle->getParamCount());
|
|
Ivan Mahonin |
bf1d82 |
m_editedStyle->setParamDefault(p);
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
// Forward the signal to the style editor
|
|
Ivan Mahonin |
bf1d82 |
if (!m_updating) emit paramStyleChanged(false);
|
|
Ivan Mahonin |
bf1d82 |
}
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
//-----------------------------------------------------------------------------
|
|
Ivan Mahonin |
bf1d82 |
|
|
Ivan Mahonin |
bf1d82 |
void SettingsPage::onValueChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
assert(m_editedStyle);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Extract the parameter index
|
|
Shinya Kitaoka |
120a6e |
QWidget *senderWidget = static_cast<QWidget *>(sender());
|
|
Ivan Mahonin |
bf1d82 |
int p = getParamIndex(senderWidget);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= p && p < m_editedStyle->getParamCount());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Update the style's parameter value
|
|
Shinya Kitaoka |
120a6e |
switch (m_editedStyle->getParamType(p)) {
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::BOOL:
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setParamValue(
|
|
Shinya Kitaoka |
120a6e |
p, static_cast<QCheckBox *>(senderWidget)->isChecked());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::INT:
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setParamValue(
|
|
Shinya Kitaoka |
120a6e |
p, static_cast<DVGui::IntField *>(senderWidget)->getValue());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::ENUM:
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setParamValue(
|
|
Shinya Kitaoka |
120a6e |
p, static_cast<QComboBox *>(senderWidget)->currentIndex());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::DOUBLE:
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setParamValue(
|
|
Shinya Kitaoka |
120a6e |
p, static_cast<DVGui::DoubleField *>(senderWidget)->getValue());
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TColorStyle::FILEPATH: {
|
|
Shinya Kitaoka |
120a6e |
const QString &string =
|
|
Shinya Kitaoka |
120a6e |
static_cast<DVGui::FileField *>(senderWidget)->getPath();
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setParamValue(p, TFilePath(string.toStdWString()));
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Forward the signal to the style editor
|
|
Shinya Kitaoka |
120a6e |
if (!m_updating) emit paramStyleChanged(isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QScrollArea *makeChooserPage(QWidget *chooser) {
|
|
Shinya Kitaoka |
120a6e |
QScrollArea *scrollArea = new QScrollArea();
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setWidgetResizable(true);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setWidget(chooser);
|
|
Shinya Kitaoka |
120a6e |
return scrollArea;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QScrollArea *makeChooserPageWithoutScrollBar(QWidget *chooser) {
|
|
Shinya Kitaoka |
120a6e |
QScrollArea *scrollArea = new QScrollArea();
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setWidgetResizable(true);
|
|
Shinya Kitaoka |
120a6e |
scrollArea->setWidget(chooser);
|
|
Shinya Kitaoka |
120a6e |
return scrollArea;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// StyleEditor implementation
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: QWidget(parent)
|
|
Shinya Kitaoka |
120a6e |
, m_paletteController(paletteController)
|
|
Shinya Kitaoka |
120a6e |
, m_paletteHandle(paletteController->getCurrentPalette())
|
|
Shinya Kitaoka |
120a6e |
, m_cleanupPaletteHandle(paletteController->getCurrentCleanupPalette())
|
|
Shinya Kitaoka |
120a6e |
, m_toolBar(0)
|
|
Shinya Kitaoka |
120a6e |
, m_enabled(false)
|
|
Shinya Kitaoka |
120a6e |
, m_enabledOnlyFirstTab(false)
|
|
Shinya Kitaoka |
120a6e |
, m_enabledFirstAndLastTab(false)
|
|
Shinya Kitaoka |
120a6e |
, m_oldStyle(0)
|
|
Jeremy Bullock |
0a2e55 |
, m_parent(parent)
|
|
justburner |
a72214 |
, m_hexColorNamesEditor(0)
|
|
Shinya Kitaoka |
120a6e |
, m_editedStyle(0) {
|
|
Shinya Kitaoka |
120a6e |
setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
// TOGLIERE
|
|
Shinya Kitaoka |
120a6e |
TFilePath libraryPath = ToonzFolder::getLibraryFolder();
|
|
Shinya Kitaoka |
120a6e |
setRootPath(libraryPath);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_styleBar = new DVGui::TabBar(this);
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->setDrawBase(false);
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->setObjectName("StyleEditorTabBar");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// This widget is used to set the background color of the tabBar
|
|
Shinya Kitaoka |
120a6e |
// using the styleSheet.
|
|
Shinya Kitaoka |
120a6e |
// It is also used to take 6px on the left before the tabBar
|
|
Shinya Kitaoka |
120a6e |
// and to draw the two lines on the bottom size
|
|
Shinya Kitaoka |
120a6e |
m_tabBarContainer = new TabBarContainter(this);
|
|
Shinya Kitaoka |
120a6e |
m_colorParameterSelector = new ColorParameterSelector(this);
|
|
Shinya Kitaoka |
120a6e |
|
|
Ivan Mahonin |
bf1d82 |
m_plainColorPage = new PlainColorPage(0);
|
|
justburner |
981d46 |
m_textureStylePage = new TextureStyleChooserPage(this, 0);
|
|
justburner |
981d46 |
m_specialStylePage = new SpecialStyleChooserPage(this, 0);
|
|
justburner |
981d46 |
m_customStylePage = new CustomStyleChooserPage(this, 0);
|
|
justburner |
981d46 |
m_vectorBrushesStylePage = new VectorBrushStyleChooserPage(this, 0);
|
|
justburner |
981d46 |
m_mypaintBrushesStylePage = new MyPaintBrushStyleChooserPage(this, 0);
|
|
Ivan Mahonin |
bf1d82 |
m_settingsPage = new SettingsPage(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QWidget *emptyPage = new StyleEditorPage(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// For the plainColorPage and the settingsPage
|
|
Shinya Kitaoka |
120a6e |
// I create a "fake" QScrollArea (without ScrollingBar
|
|
Shinya Kitaoka |
120a6e |
// in order to use the styleSheet to stylish its background
|
|
justburner |
981d46 |
QScrollArea *plainArea = makeChooserPageWithoutScrollBar(m_plainColorPage);
|
|
justburner |
981d46 |
QScrollArea *textureArea =
|
|
justburner |
981d46 |
makeChooserPageWithoutScrollBar(createTexturePage());
|
|
justburner |
981d46 |
QScrollArea *mypaintBrushesArea =
|
|
justburner |
981d46 |
makeChooserPageWithoutScrollBar(createMyPaintPage());
|
|
Shinya Kitaoka |
120a6e |
QScrollArea *settingsArea = makeChooserPageWithoutScrollBar(m_settingsPage);
|
|
Jeremy Bullock |
4bf672 |
QScrollArea *vectorOutsideArea =
|
|
shun-iwasawa |
dfea21 |
makeChooserPageWithoutScrollBar(createVectorPage());
|
|
justburner |
981d46 |
textureArea->setMinimumWidth(50);
|
|
Jeremy Bullock |
4bf672 |
vectorOutsideArea->setMinimumWidth(50);
|
|
justburner |
981d46 |
mypaintBrushesArea->setMinimumWidth(50);
|
|
Jeremy Bullock |
4bf672 |
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser = new QStackedWidget(this);
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->addWidget(plainArea);
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->addWidget(textureArea);
|
|
Jeremy Bullock |
4bf672 |
m_styleChooser->addWidget(vectorOutsideArea);
|
|
Ivan Mahonin |
bf1d82 |
m_styleChooser->addWidget(mypaintBrushesArea);
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->addWidget(settingsArea);
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->addWidget(makeChooserPageWithoutScrollBar(emptyPage));
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QFrame *bottomWidget = createBottomWidget();
|
|
Shinya Kitaoka |
120a6e |
/* ------- layout ------- */
|
|
Jeremy Bullock |
4bf672 |
QGridLayout *mainLayout = new QGridLayout;
|
|
Jeremy Bullock |
915f19 |
mainLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
mainLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
Shinya Kitaoka |
120a6e |
hLayout->setMargin(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Kite |
521c84 |
hLayout->addSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addWidget(m_styleBar);
|
|
Shinya Kitaoka |
120a6e |
hLayout->addStretch();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_tabBarContainer->setLayout(hLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
2a343c |
mainLayout->addWidget(m_tabBarContainer, 0, 0, 1, 2);
|
|
Jeremy Bullock |
4bf672 |
mainLayout->addWidget(m_styleChooser, 1, 0, 1, 2);
|
|
shun-iwasawa |
2a343c |
mainLayout->addWidget(bottomWidget, 2, 0, 1, 2);
|
|
shun-iwasawa |
c18bfa |
// mainLayout->addWidget(m_toolBar, 3, 0);
|
|
shun-iwasawa |
c18bfa |
// mainLayout->addWidget(displayToolbar, 3, 1);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
shun-iwasawa |
2a343c |
mainLayout->setColumnStretch(0, 1);
|
|
shun-iwasawa |
2a343c |
mainLayout->setRowStretch(1, 1);
|
|
Shinya Kitaoka |
120a6e |
setLayout(mainLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ------- signal-slot connections ------- */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_styleBar, SIGNAL(currentChanged(int)), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(setPage(int)));
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_colorParameterSelector, SIGNAL(colorParamChanged()),
|
|
shun_iwasawa |
3cc41f |
this, SLOT(onColorParamChanged()));
|
|
shun_iwasawa |
3cc41f |
ret = ret &&
|
|
shun_iwasawa |
3cc41f |
connect(m_textureStylePage, SIGNAL(styleSelected(const TColorStyle &)),
|
|
shun_iwasawa |
3cc41f |
this, SLOT(selectStyle(const TColorStyle &)));
|
|
shun_iwasawa |
3cc41f |
ret = ret &&
|
|
shun_iwasawa |
3cc41f |
connect(m_specialStylePage, SIGNAL(styleSelected(const TColorStyle &)),
|
|
shun_iwasawa |
3cc41f |
this, SLOT(selectStyle(const TColorStyle &)));
|
|
shun_iwasawa |
3cc41f |
ret = ret &&
|
|
shun_iwasawa |
3cc41f |
connect(m_customStylePage, SIGNAL(styleSelected(const TColorStyle &)),
|
|
shun_iwasawa |
3cc41f |
this, SLOT(selectStyle(const TColorStyle &)));
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_vectorBrushesStylePage,
|
|
shun_iwasawa |
3cc41f |
SIGNAL(styleSelected(const TColorStyle &)), this,
|
|
shun_iwasawa |
3cc41f |
SLOT(selectStyle(const TColorStyle &)));
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_mypaintBrushesStylePage,
|
|
shun_iwasawa |
3cc41f |
SIGNAL(styleSelected(const TColorStyle &)), this,
|
|
shun_iwasawa |
3cc41f |
SLOT(selectStyle(const TColorStyle &)));
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_settingsPage, SIGNAL(paramStyleChanged(bool)), this,
|
|
shun_iwasawa |
3cc41f |
SLOT(onParamStyleChanged(bool)));
|
|
shun_iwasawa |
3cc41f |
ret = ret && connect(m_plainColorPage,
|
|
shun_iwasawa |
3cc41f |
SIGNAL(colorChanged(const ColorModel &, bool)), this,
|
|
shun_iwasawa |
3cc41f |
SLOT(onColorChanged(const ColorModel &, bool)));
|
|
Jeremy Bullock |
0a2e55 |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
/* ------- initial conditions ------- */
|
|
Shinya Kitaoka |
120a6e |
enable(false, false, false);
|
|
Shinya Kitaoka |
120a6e |
// set to the empty page
|
|
Jeremy Bullock |
4bf672 |
m_styleChooser->setCurrentIndex(m_styleChooser->count() - 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
StyleEditor::~StyleEditor() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void StyleEditor::setPaletteHandle(TPaletteHandle* paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
if(m_paletteHandle != paletteHandle)
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle = paletteHandle;
|
|
Shinya Kitaoka |
120a6e |
onStyleSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QFrame *StyleEditor::createBottomWidget() {
|
|
Shinya Kitaoka |
120a6e |
QFrame *bottomWidget = new QFrame(this);
|
|
Jeremy Bullock |
0a2e55 |
m_autoButton = new QPushButton(tr("Auto"));
|
|
justburner |
a13da2 |
m_oldColor = new DVGui::StyleSample(this, 42, 24);
|
|
justburner |
a13da2 |
m_newColor = new DVGui::StyleSample(this, 42, 24);
|
|
Shinya Kitaoka |
120a6e |
m_applyButton = new QPushButton(tr("Apply"));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bottomWidget->setFrameStyle(QFrame::StyledPanel);
|
|
Shinya Kitaoka |
120a6e |
bottomWidget->setObjectName("bottomWidget");
|
|
Shinya Kitaoka |
120a6e |
bottomWidget->setContentsMargins(0, 0, 0, 0);
|
|
shun-iwasawa |
c18bfa |
bottomWidget->setMinimumHeight(60);
|
|
Shinya Kitaoka |
120a6e |
m_applyButton->setToolTip(tr("Apply changes to current style"));
|
|
shun_iwasawa |
fd6c3c |
m_applyButton->setDisabled(m_paletteController->isColorAutoApplyEnabled());
|
|
Shinya Kitaoka |
120a6e |
m_applyButton->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setToolTip(tr("Automatically update style changes"));
|
|
shun_iwasawa |
fd6c3c |
m_autoButton->setChecked(m_paletteController->isColorAutoApplyEnabled());
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setFocusPolicy(Qt::NoFocus);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->setToolTip(tr("Return To Previous Style"));
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->enableClick(true);
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->setEnable(false);
|
|
justburner |
a13da2 |
m_oldColor->setSystemChessboard(true);
|
|
justburner |
a13da2 |
m_oldColor->setCloneStyle(true);
|
|
Shinya Kitaoka |
120a6e |
m_newColor->setToolTip(tr("Current Style"));
|
|
justburner |
a13da2 |
m_newColor->enableClick(true);
|
|
Shinya Kitaoka |
120a6e |
m_newColor->setEnable(false);
|
|
justburner |
a13da2 |
m_newColor->setSystemChessboard(true);
|
|
justburner |
a13da2 |
|
|
justburner |
a72214 |
m_hexLineEdit = new DVGui::HexLineEdit("", this);
|
|
justburner |
a13da2 |
m_hexLineEdit->setObjectName("HexLineEdit");
|
|
justburner |
a13da2 |
m_hexLineEdit->setFixedWidth(75);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
c18bfa |
m_toolBar = new QToolBar(this);
|
|
shun-iwasawa |
c18bfa |
m_toolBar->setMovable(false);
|
|
shun-iwasawa |
c18bfa |
m_toolBar->setMaximumHeight(22);
|
|
justburner |
981d46 |
QMenu *menu = new QMenu();
|
|
justburner |
981d46 |
m_wheelAction = new QAction(tr("Wheel"), this);
|
|
justburner |
981d46 |
m_hsvAction = new QAction(tr("HSV"), this);
|
|
justburner |
981d46 |
m_alphaAction = new QAction(tr("Alpha"), this);
|
|
justburner |
981d46 |
m_rgbAction = new QAction(tr("RGB"), this);
|
|
justburner |
981d46 |
m_hexAction = new QAction(tr("Hex"), this);
|
|
justburner |
981d46 |
m_searchAction = new QAction(tr("Search"), this);
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
m_wheelAction->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
m_hsvAction->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
m_alphaAction->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
m_rgbAction->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
m_hexAction->setCheckable(true);
|
|
justburner |
981d46 |
m_searchAction->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
m_wheelAction->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
m_hsvAction->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
m_alphaAction->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
m_rgbAction->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
m_hexAction->setChecked(false);
|
|
justburner |
981d46 |
m_searchAction->setChecked(false);
|
|
shun-iwasawa |
c18bfa |
menu->addAction(m_wheelAction);
|
|
shun-iwasawa |
c18bfa |
menu->addAction(m_hsvAction);
|
|
shun-iwasawa |
c18bfa |
menu->addAction(m_alphaAction);
|
|
shun-iwasawa |
c18bfa |
menu->addAction(m_rgbAction);
|
|
shun-iwasawa |
c18bfa |
menu->addAction(m_hexAction);
|
|
justburner |
981d46 |
menu->addAction(m_searchAction);
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
m_sliderAppearanceAG = new QActionGroup(this);
|
|
shun-iwasawa |
c18bfa |
QAction *relColorAct =
|
|
shun-iwasawa |
c18bfa |
new QAction(tr("Relative colored + Triangle handle"), this);
|
|
shun-iwasawa |
c18bfa |
QAction *absColorAct =
|
|
shun-iwasawa |
c18bfa |
new QAction(tr("Absolute colored + Line handle"), this);
|
|
shun-iwasawa |
c18bfa |
relColorAct->setData(RelativeColoredTriangleHandle);
|
|
shun-iwasawa |
c18bfa |
absColorAct->setData(AbsoluteColoredLineHandle);
|
|
shun-iwasawa |
c18bfa |
relColorAct->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
absColorAct->setCheckable(true);
|
|
shun-iwasawa |
c18bfa |
if (StyleEditorColorSliderAppearance == RelativeColoredTriangleHandle)
|
|
shun-iwasawa |
c18bfa |
relColorAct->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
else
|
|
shun-iwasawa |
c18bfa |
absColorAct->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
m_sliderAppearanceAG->addAction(relColorAct);
|
|
shun-iwasawa |
c18bfa |
m_sliderAppearanceAG->addAction(absColorAct);
|
|
shun-iwasawa |
c18bfa |
m_sliderAppearanceAG->setExclusive(true);
|
|
shun-iwasawa |
c18bfa |
menu->addSeparator();
|
|
shun-iwasawa |
c18bfa |
QMenu *appearanceSubMenu = menu->addMenu(tr("Slider Appearance"));
|
|
shun-iwasawa |
c18bfa |
appearanceSubMenu->addAction(relColorAct);
|
|
shun-iwasawa |
c18bfa |
appearanceSubMenu->addAction(absColorAct);
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
a5cff8 |
m_toggleOrientationAction =
|
|
shun-iwasawa |
a5cff8 |
new QAction(createQIcon("orientation_h"), tr("Toggle Orientation"), this);
|
|
shun-iwasawa |
a5cff8 |
menu->addAction(m_toggleOrientationAction);
|
|
shun-iwasawa |
a5cff8 |
|
|
justburner |
a72214 |
m_hexEditorAction = new QAction(tr("Hex Color Names..."), this);
|
|
justburner |
a72214 |
menu->addAction(m_hexEditorAction);
|
|
justburner |
a72214 |
|
|
shun-iwasawa |
c18bfa |
QToolButton *toolButton = new QToolButton(this);
|
|
shun-iwasawa |
c18bfa |
toolButton->setIcon(createQIcon("menu"));
|
|
shun-iwasawa |
c18bfa |
toolButton->setFixedSize(22, 22);
|
|
shun-iwasawa |
c18bfa |
toolButton->setMenu(menu);
|
|
shun-iwasawa |
c18bfa |
toolButton->setPopupMode(QToolButton::InstantPopup);
|
|
shun-iwasawa |
c18bfa |
toolButton->setToolTip(tr("Show or hide parts of the Color Page."));
|
|
shun-iwasawa |
c18bfa |
// QToolBar* displayToolbar = new QToolBar(this);
|
|
shun-iwasawa |
c18bfa |
m_toolBar->addWidget(toolButton);
|
|
shun-iwasawa |
c18bfa |
m_toolBar->setMaximumHeight(22);
|
|
shun-iwasawa |
c18bfa |
m_toolBar->setIconSize(QSize(16, 16));
|
|
shun-iwasawa |
a5cff8 |
|
|
Shinya Kitaoka |
120a6e |
/* ------ layout ------ */
|
|
shun-iwasawa |
c18bfa |
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
Jeremy Bullock |
0a2e55 |
mainLayout->setMargin(2);
|
|
shun-iwasawa |
c18bfa |
mainLayout->setSpacing(0);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
shun-iwasawa |
c18bfa |
mainLayout->addWidget(m_autoButton);
|
|
shun-iwasawa |
c18bfa |
mainLayout->addSpacing(4);
|
|
shun-iwasawa |
c18bfa |
mainLayout->addWidget(m_applyButton);
|
|
shun-iwasawa |
c18bfa |
mainLayout->addSpacing(4);
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
QVBoxLayout *colorLay = new QVBoxLayout();
|
|
shun-iwasawa |
c18bfa |
colorLay->setMargin(0);
|
|
shun-iwasawa |
c18bfa |
colorLay->setSpacing(2);
|
|
Shinya Kitaoka |
120a6e |
{
|
|
shun-iwasawa |
c18bfa |
QHBoxLayout *chipLay = new QHBoxLayout();
|
|
shun-iwasawa |
c18bfa |
chipLay->setMargin(0);
|
|
shun-iwasawa |
c18bfa |
chipLay->setSpacing(0);
|
|
shun-iwasawa |
c18bfa |
{
|
|
shun-iwasawa |
c18bfa |
chipLay->addWidget(m_newColor, 1);
|
|
shun-iwasawa |
c18bfa |
chipLay->addWidget(m_oldColor, 1);
|
|
shun-iwasawa |
c18bfa |
}
|
|
shun-iwasawa |
c18bfa |
colorLay->addLayout(chipLay, 1);
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
colorLay->addWidget(m_colorParameterSelector, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
shun-iwasawa |
c18bfa |
mainLayout->addLayout(colorLay, 1);
|
|
shun-iwasawa |
c18bfa |
mainLayout->addSpacing(4);
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
c18bfa |
QVBoxLayout *hexLay = new QVBoxLayout();
|
|
shun-iwasawa |
c18bfa |
hexLay->setMargin(0);
|
|
shun-iwasawa |
c18bfa |
hexLay->setSpacing(2);
|
|
shun-iwasawa |
c18bfa |
{
|
|
shun-iwasawa |
c18bfa |
hexLay->addWidget(m_hexLineEdit);
|
|
shun-iwasawa |
c18bfa |
hexLay->addWidget(m_toolBar, 0, Qt::AlignBottom | Qt::AlignRight);
|
|
shun-iwasawa |
c18bfa |
}
|
|
shun-iwasawa |
c18bfa |
mainLayout->addLayout(hexLay, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bottomWidget->setLayout(mainLayout);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/* ------ signal-slot connections ------ */
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_applyButton, SIGNAL(clicked()), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(applyButtonClicked()));
|
|
shun-iwasawa |
a8f111 |
ret = ret && connect(m_autoButton, SIGNAL(toggled(bool)), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(autoCheckChanged(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret &&
|
|
shun-iwasawa |
c18bfa |
connect(m_oldColor, SIGNAL(clicked()), this, SLOT(onOldStyleClicked()));
|
|
shun-iwasawa |
c18bfa |
ret = ret &&
|
|
shun-iwasawa |
c18bfa |
connect(m_newColor, SIGNAL(clicked()), this, SLOT(onNewStyleClicked()));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_wheelAction, SIGNAL(toggled(bool)),
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage->m_wheelFrame, SLOT(setVisible(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_hsvAction, SIGNAL(toggled(bool)),
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage->m_hsvFrame, SLOT(setVisible(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_alphaAction, SIGNAL(toggled(bool)),
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage->m_alphaFrame, SLOT(setVisible(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_rgbAction, SIGNAL(toggled(bool)),
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage->m_rgbFrame, SLOT(setVisible(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_hexAction, SIGNAL(toggled(bool)), m_hexLineEdit,
|
|
shun-iwasawa |
c18bfa |
SLOT(setVisible(bool)));
|
|
justburner |
981d46 |
ret = ret && connect(m_searchAction, SIGNAL(toggled(bool)), this,
|
|
justburner |
981d46 |
SLOT(onSearchVisible(bool)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_hexLineEdit, SIGNAL(editingFinished()), this,
|
|
shun-iwasawa |
c18bfa |
SLOT(onHexChanged()));
|
|
justburner |
a72214 |
ret = ret && connect(m_hexEditorAction, SIGNAL(triggered()), this,
|
|
justburner |
a72214 |
SLOT(onHexEditor()));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()),
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage, SLOT(toggleOrientation()));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), this,
|
|
shun-iwasawa |
c18bfa |
SLOT(updateOrientationButton()));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(m_sliderAppearanceAG, SIGNAL(triggered(QAction *)), this,
|
|
shun-iwasawa |
c18bfa |
SLOT(onSliderAppearanceSelected(QAction *)));
|
|
shun-iwasawa |
c18bfa |
ret = ret && connect(menu, SIGNAL(aboutToShow()), this,
|
|
shun-iwasawa |
c18bfa |
SLOT(onPopupMenuAboutToShow()));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return bottomWidget;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
justburner |
981d46 |
QFrame *StyleEditor::createTexturePage() {
|
|
justburner |
981d46 |
QFrame *outsideFrame = new QFrame();
|
|
justburner |
981d46 |
outsideFrame->setMinimumWidth(50);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
m_textureSearchFrame = new QFrame();
|
|
justburner |
981d46 |
m_textureSearchText = new QLineEdit();
|
|
justburner |
981d46 |
m_textureSearchClear = new QPushButton(tr("Clear Search"));
|
|
justburner |
981d46 |
m_textureSearchClear->setDisabled(true);
|
|
justburner |
981d46 |
m_textureSearchClear->setSizePolicy(QSizePolicy::Minimum,
|
|
justburner |
981d46 |
QSizePolicy::Preferred);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
/* ------ layout ------ */
|
|
justburner |
981d46 |
QVBoxLayout *outsideLayout = new QVBoxLayout();
|
|
justburner |
981d46 |
outsideLayout->setMargin(0);
|
|
justburner |
981d46 |
outsideLayout->setSpacing(0);
|
|
justburner |
981d46 |
outsideLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{
|
|
justburner |
981d46 |
QVBoxLayout *insideLayout = new QVBoxLayout();
|
|
justburner |
981d46 |
insideLayout->setMargin(0);
|
|
justburner |
981d46 |
insideLayout->setSpacing(0);
|
|
justburner |
981d46 |
insideLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{ insideLayout->addWidget(m_textureStylePage); }
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
QFrame *insideFrame = new QFrame();
|
|
justburner |
981d46 |
insideFrame->setMinimumWidth(50);
|
|
justburner |
981d46 |
insideFrame->setLayout(insideLayout);
|
|
justburner |
981d46 |
m_textureArea = makeChooserPage(insideFrame);
|
|
justburner |
981d46 |
m_textureArea->setMinimumWidth(50);
|
|
justburner |
981d46 |
outsideLayout->addWidget(m_textureArea);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
QHBoxLayout *searchLayout = new QHBoxLayout();
|
|
justburner |
981d46 |
searchLayout->setMargin(2);
|
|
justburner |
981d46 |
searchLayout->setSpacing(0);
|
|
justburner |
981d46 |
searchLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{
|
|
justburner |
981d46 |
searchLayout->addWidget(m_textureSearchText);
|
|
justburner |
981d46 |
searchLayout->addWidget(m_textureSearchClear);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
m_textureSearchFrame->setLayout(searchLayout);
|
|
justburner |
981d46 |
outsideLayout->addWidget(m_textureSearchFrame);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
outsideFrame->setLayout(outsideLayout);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
/* ------ signal-slot connections ------ */
|
|
justburner |
981d46 |
bool ret = true;
|
|
justburner |
981d46 |
ret =
|
|
justburner |
981d46 |
ret && connect(m_textureSearchText, SIGNAL(textChanged(const QString &)),
|
|
justburner |
981d46 |
this, SLOT(onTextureSearch(const QString &)));
|
|
justburner |
981d46 |
ret = ret && connect(m_textureSearchClear, SIGNAL(clicked()), this,
|
|
justburner |
981d46 |
SLOT(onTextureClearSearch()));
|
|
justburner |
981d46 |
return outsideFrame;
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
shun-iwasawa |
dfea21 |
QFrame *StyleEditor::createVectorPage() {
|
|
justburner |
981d46 |
QFrame *vectorOutsideFrame = new QFrame();
|
|
shun-iwasawa |
dfea21 |
vectorOutsideFrame->setMinimumWidth(50);
|
|
shun-iwasawa |
dfea21 |
|
|
justburner |
981d46 |
QPushButton *specialButton = new QPushButton(tr("Generated"));
|
|
justburner |
981d46 |
QPushButton *customButton = new QPushButton(tr("Trail"));
|
|
justburner |
981d46 |
QPushButton *vectorBrushButton = new QPushButton(tr("Vector Brush"));
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
m_vectorsSearchFrame = new QFrame();
|
|
justburner |
981d46 |
m_vectorsSearchText = new QLineEdit();
|
|
justburner |
981d46 |
m_vectorsSearchClear = new QPushButton(tr("Clear Search"));
|
|
justburner |
981d46 |
m_vectorsSearchClear->setDisabled(true);
|
|
justburner |
981d46 |
m_vectorsSearchClear->setSizePolicy(QSizePolicy::Minimum,
|
|
justburner |
981d46 |
QSizePolicy::Preferred);
|
|
shun-iwasawa |
dfea21 |
|
|
shun-iwasawa |
dfea21 |
specialButton->setCheckable(true);
|
|
shun-iwasawa |
dfea21 |
customButton->setCheckable(true);
|
|
shun-iwasawa |
dfea21 |
vectorBrushButton->setCheckable(true);
|
|
shun-iwasawa |
dfea21 |
specialButton->setChecked(true);
|
|
shun-iwasawa |
dfea21 |
customButton->setChecked(true);
|
|
shun-iwasawa |
dfea21 |
vectorBrushButton->setChecked(true);
|
|
shun-iwasawa |
dfea21 |
|
|
shun-iwasawa |
dfea21 |
/* ------ layout ------ */
|
|
shun-iwasawa |
dfea21 |
QVBoxLayout *vectorOutsideLayout = new QVBoxLayout();
|
|
shun-iwasawa |
dfea21 |
vectorOutsideLayout->setMargin(0);
|
|
shun-iwasawa |
dfea21 |
vectorOutsideLayout->setSpacing(0);
|
|
shun-iwasawa |
dfea21 |
vectorOutsideLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
shun-iwasawa |
dfea21 |
{
|
|
shun-iwasawa |
dfea21 |
QHBoxLayout *vectorButtonLayout = new QHBoxLayout();
|
|
shun-iwasawa |
dfea21 |
vectorButtonLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
shun-iwasawa |
dfea21 |
{
|
|
shun-iwasawa |
dfea21 |
vectorButtonLayout->addWidget(specialButton);
|
|
shun-iwasawa |
dfea21 |
vectorButtonLayout->addWidget(customButton);
|
|
shun-iwasawa |
dfea21 |
vectorButtonLayout->addWidget(vectorBrushButton);
|
|
shun-iwasawa |
dfea21 |
}
|
|
shun-iwasawa |
dfea21 |
vectorOutsideLayout->addLayout(vectorButtonLayout);
|
|
shun-iwasawa |
dfea21 |
|
|
shun-iwasawa |
dfea21 |
QVBoxLayout *vectorLayout = new QVBoxLayout();
|
|
shun-iwasawa |
dfea21 |
vectorLayout->setMargin(0);
|
|
shun-iwasawa |
dfea21 |
vectorLayout->setSpacing(0);
|
|
shun-iwasawa |
dfea21 |
vectorLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
shun-iwasawa |
dfea21 |
{
|
|
shun-iwasawa |
dfea21 |
vectorLayout->addWidget(m_specialStylePage);
|
|
shun-iwasawa |
dfea21 |
vectorLayout->addWidget(m_customStylePage);
|
|
shun-iwasawa |
dfea21 |
vectorLayout->addWidget(m_vectorBrushesStylePage);
|
|
shun-iwasawa |
dfea21 |
}
|
|
justburner |
981d46 |
QFrame *vectorFrame = new QFrame();
|
|
shun-iwasawa |
dfea21 |
vectorFrame->setMinimumWidth(50);
|
|
shun-iwasawa |
dfea21 |
vectorFrame->setLayout(vectorLayout);
|
|
justburner |
981d46 |
m_vectorsArea = makeChooserPage(vectorFrame);
|
|
justburner |
981d46 |
m_vectorsArea->setMinimumWidth(50);
|
|
justburner |
981d46 |
vectorOutsideLayout->addWidget(m_vectorsArea);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
QHBoxLayout *searchLayout = new QHBoxLayout();
|
|
justburner |
981d46 |
searchLayout->setMargin(2);
|
|
justburner |
981d46 |
searchLayout->setSpacing(0);
|
|
justburner |
981d46 |
searchLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{
|
|
justburner |
981d46 |
searchLayout->addWidget(m_vectorsSearchText);
|
|
justburner |
981d46 |
searchLayout->addWidget(m_vectorsSearchClear);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
m_vectorsSearchFrame->setLayout(searchLayout);
|
|
justburner |
981d46 |
vectorOutsideLayout->addWidget(m_vectorsSearchFrame);
|
|
shun-iwasawa |
dfea21 |
}
|
|
shun-iwasawa |
dfea21 |
vectorOutsideFrame->setLayout(vectorOutsideLayout);
|
|
shun-iwasawa |
dfea21 |
|
|
shun-iwasawa |
dfea21 |
/* ------ signal-slot connections ------ */
|
|
shun-iwasawa |
dfea21 |
bool ret = true;
|
|
shun-iwasawa |
dfea21 |
ret = ret && connect(specialButton, SIGNAL(toggled(bool)), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onSpecialButtonToggled(bool)));
|
|
shun-iwasawa |
a8f111 |
ret = ret && connect(customButton, SIGNAL(toggled(bool)), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onCustomButtonToggled(bool)));
|
|
shun-iwasawa |
a8f111 |
ret = ret && connect(vectorBrushButton, SIGNAL(toggled(bool)), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onVectorBrushButtonToggled(bool)));
|
|
justburner |
981d46 |
ret =
|
|
justburner |
981d46 |
ret && connect(m_vectorsSearchText, SIGNAL(textChanged(const QString &)),
|
|
justburner |
981d46 |
this, SLOT(onVectorsSearch(const QString &)));
|
|
justburner |
981d46 |
ret = ret && connect(m_vectorsSearchClear, SIGNAL(clicked()), this,
|
|
justburner |
981d46 |
SLOT(onVectorsClearSearch()));
|
|
justburner |
981d46 |
|
|
shun-iwasawa |
dfea21 |
assert(ret);
|
|
shun-iwasawa |
dfea21 |
return vectorOutsideFrame;
|
|
shun-iwasawa |
dfea21 |
}
|
|
shun-iwasawa |
dfea21 |
|
|
shun-iwasawa |
dfea21 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
dfea21 |
|
|
justburner |
981d46 |
QFrame *StyleEditor::createMyPaintPage() {
|
|
justburner |
981d46 |
QFrame *outsideFrame = new QFrame();
|
|
justburner |
981d46 |
outsideFrame->setMinimumWidth(50);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
m_mypaintSearchFrame = new QFrame();
|
|
justburner |
981d46 |
m_mypaintSearchText = new QLineEdit();
|
|
justburner |
981d46 |
m_mypaintSearchClear = new QPushButton(tr("Clear Search"));
|
|
justburner |
981d46 |
m_mypaintSearchClear->setDisabled(true);
|
|
justburner |
981d46 |
m_mypaintSearchClear->setSizePolicy(QSizePolicy::Minimum,
|
|
justburner |
981d46 |
QSizePolicy::Preferred);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
/* ------ layout ------ */
|
|
justburner |
981d46 |
QVBoxLayout *outsideLayout = new QVBoxLayout();
|
|
justburner |
981d46 |
outsideLayout->setMargin(0);
|
|
justburner |
981d46 |
outsideLayout->setSpacing(0);
|
|
justburner |
981d46 |
outsideLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{
|
|
justburner |
981d46 |
QVBoxLayout *insideLayout = new QVBoxLayout();
|
|
justburner |
981d46 |
insideLayout->setMargin(0);
|
|
justburner |
981d46 |
insideLayout->setSpacing(0);
|
|
justburner |
981d46 |
insideLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{ insideLayout->addWidget(m_mypaintBrushesStylePage); }
|
|
justburner |
981d46 |
QFrame *insideFrame = new QFrame();
|
|
justburner |
981d46 |
insideFrame->setMinimumWidth(50);
|
|
justburner |
981d46 |
insideFrame->setLayout(insideLayout);
|
|
justburner |
981d46 |
m_mypaintArea = makeChooserPage(insideFrame);
|
|
justburner |
981d46 |
m_mypaintArea->setMinimumWidth(50);
|
|
justburner |
981d46 |
outsideLayout->addWidget(m_mypaintArea);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
QHBoxLayout *searchLayout = new QHBoxLayout();
|
|
justburner |
981d46 |
searchLayout->setMargin(2);
|
|
justburner |
981d46 |
searchLayout->setSpacing(0);
|
|
justburner |
981d46 |
searchLayout->setSizeConstraint(QLayout::SetNoConstraint);
|
|
justburner |
981d46 |
{
|
|
justburner |
981d46 |
searchLayout->addWidget(m_mypaintSearchText);
|
|
justburner |
981d46 |
searchLayout->addWidget(m_mypaintSearchClear);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
m_mypaintSearchFrame->setLayout(searchLayout);
|
|
justburner |
981d46 |
outsideLayout->addWidget(m_mypaintSearchFrame);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
outsideFrame->setLayout(outsideLayout);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
/* ------ signal-slot connections ------ */
|
|
justburner |
981d46 |
bool ret = true;
|
|
justburner |
981d46 |
ret =
|
|
justburner |
981d46 |
ret && connect(m_mypaintSearchText, SIGNAL(textChanged(const QString &)),
|
|
justburner |
981d46 |
this, SLOT(onMyPaintSearch(const QString &)));
|
|
justburner |
981d46 |
ret = ret && connect(m_mypaintSearchClear, SIGNAL(clicked()), this,
|
|
justburner |
981d46 |
SLOT(onMyPaintClearSearch()));
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
assert(ret);
|
|
justburner |
981d46 |
return outsideFrame;
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onTextureSearch(const QString &search) {
|
|
justburner |
981d46 |
m_textureSearchClear->setDisabled(search.isEmpty());
|
|
justburner |
981d46 |
m_textureStylePage->applyFilter(search);
|
|
justburner |
981d46 |
m_textureStylePage->computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onTextureClearSearch() {
|
|
justburner |
981d46 |
m_textureSearchText->setText("");
|
|
justburner |
981d46 |
m_textureSearchText->setFocus();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onVectorsSearch(const QString &search) {
|
|
justburner |
981d46 |
m_vectorsSearchClear->setDisabled(search.isEmpty());
|
|
justburner |
981d46 |
m_specialStylePage->applyFilter(search);
|
|
justburner |
981d46 |
m_customStylePage->applyFilter(search);
|
|
justburner |
981d46 |
m_vectorBrushesStylePage->applyFilter(search);
|
|
justburner |
981d46 |
m_specialStylePage->computeSize();
|
|
justburner |
981d46 |
m_customStylePage->computeSize();
|
|
justburner |
981d46 |
m_vectorBrushesStylePage->computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onVectorsClearSearch() {
|
|
justburner |
981d46 |
m_vectorsSearchText->setText("");
|
|
justburner |
981d46 |
m_vectorsSearchText->setFocus();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onMyPaintSearch(const QString &search) {
|
|
justburner |
981d46 |
m_mypaintSearchClear->setDisabled(search.isEmpty());
|
|
justburner |
981d46 |
m_mypaintBrushesStylePage->applyFilter(search);
|
|
justburner |
981d46 |
m_mypaintBrushesStylePage->computeSize();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
void StyleEditor::onMyPaintClearSearch() {
|
|
justburner |
981d46 |
m_mypaintSearchText->setText("");
|
|
justburner |
981d46 |
m_mypaintSearchText->setFocus();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::updateTabBar() {
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->clearTabBar();
|
|
Shinya Kitaoka |
120a6e |
if (m_enabled && !m_enabledOnlyFirstTab && !m_enabledFirstAndLastTab) {
|
|
Jeremy Bullock |
4bf672 |
m_styleBar->addSimpleTab(tr("Color"));
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->addSimpleTab(tr("Texture"));
|
|
Jeremy Bullock |
4bf672 |
m_styleBar->addSimpleTab(tr("Vector"));
|
|
Jeremy Bullock |
4bf672 |
m_styleBar->addSimpleTab(tr("Raster"));
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->addSimpleTab(tr("Settings"));
|
|
Shinya Kitaoka |
120a6e |
} else if (m_enabled && m_enabledOnlyFirstTab && !m_enabledFirstAndLastTab)
|
|
Jeremy Bullock |
4bf672 |
m_styleBar->addSimpleTab(tr("Color"));
|
|
Shinya Kitaoka |
120a6e |
else if (m_enabled && !m_enabledOnlyFirstTab && m_enabledFirstAndLastTab) {
|
|
Jeremy Bullock |
4bf672 |
m_styleBar->addSimpleTab(tr("Color"));
|
|
Shinya Kitaoka |
120a6e |
m_styleBar->addSimpleTab(tr("Settings"));
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Jeremy Bullock |
4bf672 |
m_styleChooser->setCurrentIndex(m_styleChooser->count() - 1);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_tabBarContainer->layout()->update();
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->setCurrentIndex(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::showEvent(QShowEvent *) {
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setChecked(m_paletteController->isColorAutoApplyEnabled());
|
|
Shinya Kitaoka |
120a6e |
onStyleSwitched();
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleSwitched()),
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onStyleSwitched()));
|
|
shun-iwasawa |
a8f111 |
ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)),
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onStyleChanged(bool)));
|
|
shun-iwasawa |
a8f111 |
ret = ret && connect(m_paletteHandle, SIGNAL(paletteSwitched()), this,
|
|
shun-iwasawa |
9dbaa2 |
SLOT(onStyleSwitched()));
|
|
shun-iwasawa |
2888cd |
ret = ret && connect(m_paletteController, SIGNAL(checkPaletteLock()), this,
|
|
shun-iwasawa |
2888cd |
SLOT(checkPaletteLock()));
|
|
Shinya Kitaoka |
120a6e |
if (m_cleanupPaletteHandle)
|
|
shun_iwasawa |
e553fc |
ret =
|
|
shun_iwasawa |
e553fc |
ret && connect(m_cleanupPaletteHandle, SIGNAL(colorStyleChanged(bool)),
|
|
shun_iwasawa |
e553fc |
SLOT(onCleanupStyleChanged(bool)));
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteController, SIGNAL(colorAutoApplyEnabled(bool)),
|
|
Shinya Kitaoka |
120a6e |
this, SLOT(enableColorAutoApply(bool)));
|
|
Shinya Kitaoka |
120a6e |
ret = ret && connect(m_paletteController,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorSampleChanged(const TPixel32 &)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(setColorSample(const TPixel32 &)));
|
|
Jeremy Bullock |
0a2e55 |
m_plainColorPage->m_wheelFrame->setVisible(m_wheelAction->isChecked());
|
|
Jeremy Bullock |
0a2e55 |
m_plainColorPage->m_hsvFrame->setVisible(m_hsvAction->isChecked());
|
|
Jeremy Bullock |
0a2e55 |
m_plainColorPage->m_alphaFrame->setVisible(m_alphaAction->isChecked());
|
|
Jeremy Bullock |
0a2e55 |
m_plainColorPage->m_rgbFrame->setVisible(m_rgbAction->isChecked());
|
|
justburner |
a13da2 |
m_hexLineEdit->setVisible(m_hexAction->isChecked());
|
|
justburner |
981d46 |
onSearchVisible(m_searchAction->isChecked());
|
|
Jeremy Bullock |
0a2e55 |
updateOrientationButton();
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::hideEvent(QHideEvent *) {
|
|
shun-iwasawa |
11adda |
disconnect(m_paletteHandle, 0, this, 0);
|
|
shun-iwasawa |
11adda |
if (m_cleanupPaletteHandle) disconnect(m_cleanupPaletteHandle, 0, this, 0);
|
|
shun-iwasawa |
11adda |
disconnect(m_paletteController, 0, this, 0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
0a2e55 |
void StyleEditor::updateOrientationButton() {
|
|
Jeremy Bullock |
0a2e55 |
if (m_plainColorPage->getIsVertical()) {
|
|
Kite |
521c84 |
m_toggleOrientationAction->setIcon(createQIcon("orientation_h"));
|
|
Jeremy Bullock |
0a2e55 |
} else {
|
|
Kite |
521c84 |
m_toggleOrientationAction->setIcon(createQIcon("orientation_v"));
|
|
Jeremy Bullock |
0a2e55 |
}
|
|
Jeremy Bullock |
0a2e55 |
}
|
|
Jeremy Bullock |
0a2e55 |
|
|
Jeremy Bullock |
0a2e55 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
0a2e55 |
|
|
justburner |
981d46 |
void StyleEditor::updateStylePages() {
|
|
justburner |
981d46 |
// Refresh all pages
|
|
justburner |
981d46 |
m_textureStylePage->update();
|
|
justburner |
981d46 |
m_specialStylePage->update();
|
|
justburner |
981d46 |
m_customStylePage->update();
|
|
justburner |
981d46 |
m_vectorBrushesStylePage->update();
|
|
justburner |
981d46 |
m_mypaintBrushesStylePage->update();
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::onStyleSwitched() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (!palette) {
|
|
Shinya Kitaoka |
120a6e |
// set the current page to empty
|
|
Jeremy Bullock |
4bf672 |
m_styleChooser->setCurrentIndex(m_styleChooser->count() - 1);
|
|
Shinya Kitaoka |
120a6e |
enable(false);
|
|
Shinya Kitaoka |
120a6e |
m_colorParameterSelector->clear();
|
|
Shinya Kitaoka |
120a6e |
m_oldStyle = TColorStyleP();
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle = TColorStyleP();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
0a2e55 |
m_parent->setWindowTitle(tr("No Style Selected"));
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(palette->getStyle(styleIndex));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isStyleNull = setStyle(m_editedStyle.getPointer());
|
|
Shinya Kitaoka |
120a6e |
bool isColorInField = palette->getPaletteName() == L"EmptyColorFieldPalette";
|
|
Shinya Kitaoka |
120a6e |
bool isValidIndex = styleIndex > 0 || isColorInField;
|
|
Shinya Kitaoka |
120a6e |
bool isCleanUpPalette = palette->isCleanupPalette();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/* ------ update the status text ------ */
|
|
Shinya Kitaoka |
120a6e |
if (!isStyleNull && isValidIndex) {
|
|
Shinya Kitaoka |
120a6e |
QString statusText;
|
|
Shinya Kitaoka |
120a6e |
// palette type
|
|
Shinya Kitaoka |
120a6e |
if (isCleanUpPalette)
|
|
Kite |
521c84 |
statusText = tr("Cleanup ");
|
|
Shinya Kitaoka |
120a6e |
else if (palette->getGlobalName() != L"")
|
|
Kite |
521c84 |
statusText = tr("Studio ");
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Kite |
521c84 |
statusText = tr("Level ");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// palette name
|
|
shun-iwasawa |
e87e08 |
statusText += tr("Palette") + " : " +
|
|
shun-iwasawa |
e87e08 |
QString::fromStdWString(palette->getPaletteName());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// style name
|
|
shun_iwasawa |
9cbd0e |
statusText += QString::fromStdWString(L" | #");
|
|
Shinya Kitaoka |
120a6e |
statusText += QString::number(styleIndex);
|
|
Shinya Kitaoka |
120a6e |
statusText += QString::fromStdWString(L" : " + m_editedStyle->getName());
|
|
shun-iwasawa |
dd780b |
TPoint pickedPos = m_editedStyle->getPickedPosition().pos;
|
|
shun_iwasawa |
9cbd0e |
if (pickedPos != TPoint())
|
|
shun_iwasawa |
9cbd0e |
statusText +=
|
|
shun_iwasawa |
9cbd0e |
QString(" (Picked from %1,%2)").arg(pickedPos.x).arg(pickedPos.y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
0a2e55 |
m_parent->setWindowTitle(statusText);
|
|
Jeremy Bullock |
0a2e55 |
} else {
|
|
Jeremy Bullock |
0a2e55 |
m_parent->setWindowTitle(tr("Style Editor - No Valid Style Selected"));
|
|
Jeremy Bullock |
0a2e55 |
}
|
|
Shinya Kitaoka |
120a6e |
enable(!isStyleNull && isValidIndex, isColorInField, isCleanUpPalette);
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
updateStylePages();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
e553fc |
void StyleEditor::onStyleChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= styleIndex && styleIndex < palette->getStyleCount());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(palette->getStyle(styleIndex));
|
|
shun_iwasawa |
e553fc |
if (!isDragging) {
|
|
shun_iwasawa |
e553fc |
setOldStyleToStyle(
|
|
shun_iwasawa |
e553fc |
m_editedStyle
|
|
shun_iwasawa |
e553fc |
.getPointer()); // This line is needed for proper undo behavior
|
|
shun_iwasawa |
e553fc |
}
|
|
Shinya Kitaoka |
120a6e |
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_colorParameterSelector->setStyle(*m_editedStyle);
|
|
Shinya Kitaoka |
120a6e |
m_settingsPage->setStyle(m_editedStyle);
|
|
justburner |
a13da2 |
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->setStyle(
|
|
justburner |
a13da2 |
*m_oldStyle,
|
|
justburner |
a13da2 |
getColorParam()); // This line is needed for proper undo behavior
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
updateStylePages();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
e553fc |
void StyleEditor::onCleanupStyleChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_cleanupPaletteHandle) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
e553fc |
onStyleChanged(isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
// TOGLIERE
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::setRootPath(const TFilePath &rootPath) {
|
|
Shinya Kitaoka |
120a6e |
m_textureStylePage->setRootPath(rootPath);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::copyEditedStyleToPalette(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
assert(palette);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
assert(0 <= styleIndex && styleIndex < palette->getStyleCount());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!(*m_oldStyle == *m_editedStyle) &&
|
|
Shinya Kitaoka |
120a6e |
(!isDragging || m_paletteController->isColorAutoApplyEnabled()) &&
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getGlobalName() != L"" &&
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getOriginalName() != L"") {
|
|
Shinya Kitaoka |
120a6e |
// If the adited style is linked to the studio palette, then activate the
|
|
Shinya Kitaoka |
120a6e |
// edited flag
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setIsEditedFlag(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
e40777 |
palette->setStyle(styleIndex,
|
|
shun-iwasawa |
e40777 |
m_editedStyle->clone()); // Must be done *before* setting
|
|
shun-iwasawa |
e40777 |
// the eventual palette keyframe
|
|
Shinya Kitaoka |
120a6e |
if (!isDragging) {
|
|
Shinya Kitaoka |
120a6e |
if (!(*m_oldStyle == *m_editedStyle)) {
|
|
Shinya Kitaoka |
120a6e |
// do not register undo if the edited color is special one (e.g. changing
|
|
Shinya Kitaoka |
120a6e |
// the ColorField in the fx settings)
|
|
Shinya Kitaoka |
120a6e |
if (palette->getPaletteName() != L"EmptyColorFieldPalette")
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(new UndoPaletteChange(
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle, styleIndex, *m_oldStyle, *m_editedStyle));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setOldStyleToStyle(m_editedStyle.getPointer());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// In case the frame is a keyframe, update it
|
|
Shinya Kitaoka |
120a6e |
if (palette->isKeyframe(styleIndex, palette->getFrame())) // here
|
|
Shinya Kitaoka |
120a6e |
palette->setKeyframe(styleIndex, palette->getFrame()); //
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
palette->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyColorStyleChanged(isDragging);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::onColorChanged(const ColorModel &color, bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex < 0 || styleIndex > palette->getStyleCount()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(palette->getStyle(styleIndex)); // CLONES the argument
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_editedStyle) // Should be styleIndex's style at this point
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
TPixel tColor = color.getTPixel();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_editedStyle->hasMainColor()) {
|
|
Shinya Kitaoka |
120a6e |
int index = getColorParam(), count = m_editedStyle->getColorParamCount();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (0 <= index && index < count)
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setColorParamValue(index, tColor);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setMainColor(tColor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->invalidateIcon();
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// The argument has NO (main) COLOR. Since color data is being updated, a
|
|
Shinya Kitaoka |
120a6e |
// 'fake'
|
|
Shinya Kitaoka |
120a6e |
// solid style will be created and operated on.
|
|
Shinya Kitaoka |
120a6e |
TSolidColorStyle *style = new TSolidColorStyle(tColor);
|
|
Shinya Kitaoka |
120a6e |
style->assignNames(m_editedStyle.getPointer());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(style); // CLONES the argument
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
delete style;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
a13da2 |
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_colorParameterSelector->setStyle(*m_editedStyle);
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
shun-iwasawa |
2888cd |
// Auto Button should be disabled with locked palette
|
|
shun-iwasawa |
2888cd |
if (m_autoButton->isEnabled() && m_autoButton->isChecked()) {
|
|
Shinya Kitaoka |
120a6e |
copyEditedStyleToPalette(isDragging);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::enable(bool enabled, bool enabledOnlyFirstTab,
|
|
Shinya Kitaoka |
120a6e |
bool enabledFirstAndLastTab) {
|
|
Shinya Kitaoka |
120a6e |
if (m_enabled != enabled || m_enabledOnlyFirstTab != enabledOnlyFirstTab ||
|
|
Shinya Kitaoka |
120a6e |
m_enabledFirstAndLastTab != enabledFirstAndLastTab) {
|
|
Shinya Kitaoka |
120a6e |
m_enabled = enabled;
|
|
Shinya Kitaoka |
120a6e |
m_enabledOnlyFirstTab = enabledOnlyFirstTab;
|
|
Shinya Kitaoka |
120a6e |
m_enabledFirstAndLastTab = enabledFirstAndLastTab;
|
|
Shinya Kitaoka |
120a6e |
updateTabBar();
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setEnabled(enabled);
|
|
Shinya Kitaoka |
120a6e |
m_applyButton->setDisabled(!enabled || m_autoButton->isChecked());
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->setEnable(enabled);
|
|
Shinya Kitaoka |
120a6e |
m_newColor->setEnable(enabled);
|
|
justburner |
a13da2 |
m_hexLineEdit->setEnabled(enabled);
|
|
Shinya Kitaoka |
120a6e |
if (enabled == false) {
|
|
Shinya Kitaoka |
120a6e |
m_oldColor->setColor(TPixel32::Transparent);
|
|
Shinya Kitaoka |
120a6e |
m_newColor->setColor(TPixel32::Transparent);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// lock button behavior
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (palette && enabled) {
|
|
Shinya Kitaoka |
120a6e |
// when the palette is locked
|
|
Shinya Kitaoka |
120a6e |
if (palette->isLocked()) {
|
|
Shinya Kitaoka |
120a6e |
m_applyButton->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
} else // when the palette is unlocked
|
|
Shinya Kitaoka |
120a6e |
{
|
|
shun_iwasawa |
fd6c3c |
m_applyButton->setDisabled(m_autoButton->isChecked());
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setEnabled(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
shun-iwasawa |
2888cd |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
2888cd |
|
|
shun-iwasawa |
2888cd |
void StyleEditor::checkPaletteLock() {
|
|
shun-iwasawa |
2888cd |
if (getPalette() && getPalette()->isLocked()) {
|
|
shun-iwasawa |
2888cd |
m_applyButton->setEnabled(false);
|
|
shun-iwasawa |
2888cd |
m_autoButton->setEnabled(false);
|
|
shun-iwasawa |
2888cd |
} else {
|
|
shun-iwasawa |
2888cd |
m_applyButton->setDisabled(m_autoButton->isChecked());
|
|
shun-iwasawa |
2888cd |
m_autoButton->setEnabled(true);
|
|
shun-iwasawa |
2888cd |
}
|
|
shun-iwasawa |
2888cd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
justburner |
a13da2 |
void StyleEditor::onOldStyleClicked() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_enabled) return;
|
|
Shinya Kitaoka |
120a6e |
selectStyle(*(m_oldColor->getStyle()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c18bfa |
void StyleEditor::onNewStyleClicked() { applyButtonClicked(); }
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
//-----------------------------------------------------------------------------
|
|
justburner |
a13da2 |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::setPage(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_enabledFirstAndLastTab) {
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->setCurrentIndex(index);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Se sono nel caso first and last page enable e index == 1 la pagina che
|
|
Shinya Kitaoka |
120a6e |
// voglio settare e' l'ultima!
|
|
Shinya Kitaoka |
120a6e |
if (index == 1)
|
|
Shinya Kitaoka |
120a6e |
index = m_styleChooser->count() -
|
|
Shinya Kitaoka |
120a6e |
2; // 2 perche' alla fine c'e' una pagina vuota
|
|
Shinya Kitaoka |
120a6e |
m_styleChooser->setCurrentIndex(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::applyButtonClicked() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
if (!palette || styleIndex < 0 || styleIndex > palette->getStyleCount())
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
copyEditedStyleToPalette(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::autoCheckChanged(bool value) {
|
|
shun_iwasawa |
fd6c3c |
m_paletteController->enableColorAutoApply(value);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_enabled) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
fd6c3c |
m_applyButton->setDisabled(value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::enableColorAutoApply(bool enabled) {
|
|
Shinya Kitaoka |
120a6e |
if (m_autoButton->isChecked() != enabled) {
|
|
Shinya Kitaoka |
120a6e |
m_autoButton->setChecked(enabled);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::setColorSample(const TPixel32 &color) {
|
|
Shinya Kitaoka |
120a6e |
// m_colorParameterSelector->setColor(*style);
|
|
Shinya Kitaoka |
120a6e |
ColorModel cm;
|
|
Shinya Kitaoka |
120a6e |
cm.setTPixel(color);
|
|
Shinya Kitaoka |
120a6e |
onColorChanged(cm, true);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool StyleEditor::setStyle(TColorStyle *currentStyle) {
|
|
Shinya Kitaoka |
120a6e |
assert(currentStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool isStyleNull = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QString gname = QString::fromStdWString(currentStyle->getGlobalName());
|
|
Shinya Kitaoka |
120a6e |
// if(!gname.isEmpty() && gname == "ColorFieldSimpleColor")
|
|
Shinya Kitaoka |
120a6e |
// isStyleNull = true;
|
|
Shinya Kitaoka |
120a6e |
// else
|
|
Shinya Kitaoka |
120a6e |
if (!gname.isEmpty() && gname[0] != L'-') {
|
|
Shinya Kitaoka |
120a6e |
currentStyle = 0;
|
|
Shinya Kitaoka |
120a6e |
isStyleNull = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (currentStyle) {
|
|
Shinya Kitaoka |
120a6e |
m_colorParameterSelector->setStyle(*currentStyle);
|
|
Shinya Kitaoka |
120a6e |
m_plainColorPage->setColor(*currentStyle, getColorParam());
|
|
justburner |
a13da2 |
m_oldColor->setStyle(*currentStyle, getColorParam());
|
|
justburner |
a13da2 |
m_newColor->setStyle(*currentStyle, getColorParam());
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
setOldStyleToStyle(currentStyle);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Va fatto anche se non c'e' lo style perche' svuota la pagina
|
|
Shinya Kitaoka |
120a6e |
m_settingsPage->setStyle(m_editedStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return isStyleNull;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::setEditedStyleToStyle(const TColorStyle *style) {
|
|
Shinya Kitaoka |
120a6e |
if (style == m_editedStyle.getPointer()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle = TColorStyleP(style->clone());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::setOldStyleToStyle(const TColorStyle *style) {
|
|
Shinya Kitaoka |
120a6e |
if (style == m_oldStyle.getPointer()) return;
|
|
Shinya Kitaoka |
120a6e |
m_oldStyle = TColorStyleP(style->clone());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::selectStyle(const TColorStyle &newStyle) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = m_paletteHandle->getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = m_paletteHandle->getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex < 0 || palette->getStyleCount() <= styleIndex) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Register the new previous/edited style pairs
|
|
Shinya Kitaoka |
120a6e |
setOldStyleToStyle(palette->getStyle(styleIndex));
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(&newStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->assignNames(
|
|
Shinya Kitaoka |
120a6e |
m_oldStyle.getPointer()); // Copy original name stored in the palette
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// For convenience's sake, copy the main color from the old color, if both
|
|
Shinya Kitaoka |
120a6e |
// have one
|
|
Shinya Kitaoka |
120a6e |
if (m_oldStyle && m_oldStyle->hasMainColor() && m_editedStyle &&
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->hasMainColor())
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setMainColor(m_oldStyle->getMainColor());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_autoButton->isChecked()) {
|
|
Shinya Kitaoka |
120a6e |
// If the adited style is linked to the studio palette, then activate the
|
|
Shinya Kitaoka |
120a6e |
// edited flag
|
|
Shinya Kitaoka |
120a6e |
if (m_editedStyle->getGlobalName() != L"" &&
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->getOriginalName() != L"")
|
|
Shinya Kitaoka |
120a6e |
m_editedStyle->setIsEditedFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Apply new style, if required
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(new UndoPaletteChange(
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle, styleIndex, *m_oldStyle, *m_editedStyle));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
palette->setStyle(styleIndex, m_editedStyle->clone());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->notifyColorStyleChanged(false);
|
|
Shinya Kitaoka |
120a6e |
palette->setDirtyFlag(true);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Update editor widgets
|
|
shun-iwasawa |
c18bfa |
m_colorParameterSelector->setStyle(*m_editedStyle);
|
|
justburner |
a13da2 |
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_settingsPage->setStyle(m_editedStyle);
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::onColorParamChanged() {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex < 0 || palette->getStyleCount() <= styleIndex) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c18bfa |
if (*m_oldStyle != *m_editedStyle) applyButtonClicked();
|
|
shun-iwasawa |
c18bfa |
|
|
Shinya Kitaoka |
120a6e |
m_paletteHandle->setStyleParamIndex(getColorParam());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (TColorStyle *currentStyle = palette->getStyle(styleIndex)) {
|
|
Shinya Kitaoka |
120a6e |
setEditedStyleToStyle(currentStyle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c18bfa |
m_colorParameterSelector->setStyle(*m_editedStyle);
|
|
justburner |
a13da2 |
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
|
justburner |
a13da2 |
m_oldColor->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
m_settingsPage->setStyle(m_editedStyle);
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleEditor::onParamStyleChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
TPalette *palette = getPalette();
|
|
Shinya Kitaoka |
120a6e |
if (!palette) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int styleIndex = getStyleIndex();
|
|
Shinya Kitaoka |
120a6e |
if (styleIndex < 0 || styleIndex > palette->getStyleCount()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_autoButton->isChecked()) copyEditedStyleToPalette(isDragging);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c18bfa |
m_editedStyle->invalidateIcon(); // Refresh the new color icon
|
|
justburner |
a13da2 |
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
|
justburner |
a13da2 |
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
|
justburner |
a13da2 |
}
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
//-----------------------------------------------------------------------------
|
|
justburner |
a13da2 |
|
|
justburner |
a13da2 |
void StyleEditor::onHexChanged() {
|
|
justburner |
a13da2 |
if (m_hexLineEdit->fromText(m_hexLineEdit->text())) {
|
|
justburner |
a13da2 |
ColorModel cm;
|
|
justburner |
a13da2 |
cm.setTPixel(m_hexLineEdit->getColor());
|
|
justburner |
a13da2 |
onColorChanged(cm, false);
|
|
justburner |
a13da2 |
m_hexLineEdit->selectAll();
|
|
justburner |
a13da2 |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
justburner |
a72214 |
void StyleEditor::onHexEditor() {
|
|
justburner |
a72214 |
if (!m_hexColorNamesEditor) {
|
|
justburner |
a72214 |
m_hexColorNamesEditor = new DVGui::HexColorNamesEditor(this);
|
|
justburner |
a72214 |
}
|
|
justburner |
a72214 |
m_hexColorNamesEditor->show();
|
|
justburner |
a72214 |
}
|
|
justburner |
a72214 |
|
|
justburner |
a72214 |
//-----------------------------------------------------------------------------
|
|
justburner |
a72214 |
|
|
justburner |
981d46 |
void StyleEditor::onSearchVisible(bool on) {
|
|
justburner |
981d46 |
m_textureSearchFrame->setVisible(on);
|
|
justburner |
981d46 |
m_vectorsSearchFrame->setVisible(on);
|
|
justburner |
981d46 |
m_mypaintSearchFrame->setVisible(on);
|
|
justburner |
981d46 |
}
|
|
justburner |
981d46 |
|
|
justburner |
981d46 |
//-----------------------------------------------------------------------------
|
|
justburner |
981d46 |
|
|
Jeremy Bullock |
4bf672 |
void StyleEditor::onSpecialButtonToggled(bool on) {
|
|
Jeremy Bullock |
4bf672 |
m_specialStylePage->setVisible(on);
|
|
justburner |
981d46 |
m_vectorsArea->widget()->resize(m_vectorsArea->widget()->sizeHint());
|
|
Jeremy Bullock |
4bf672 |
qApp->processEvents();
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void StyleEditor::onCustomButtonToggled(bool on) {
|
|
Jeremy Bullock |
4bf672 |
m_customStylePage->setVisible(on);
|
|
justburner |
981d46 |
m_vectorsArea->widget()->resize(m_vectorsArea->widget()->sizeHint());
|
|
Jeremy Bullock |
4bf672 |
qApp->processEvents();
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void StyleEditor::onVectorBrushButtonToggled(bool on) {
|
|
Jeremy Bullock |
4bf672 |
m_vectorBrushesStylePage->setVisible(on);
|
|
justburner |
981d46 |
m_vectorsArea->widget()->resize(m_vectorsArea->widget()->sizeHint());
|
|
Jeremy Bullock |
4bf672 |
qApp->processEvents();
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
4bf672 |
|
|
Jeremy Bullock |
4bf672 |
void StyleEditor::save(QSettings &settings) const {
|
|
Jeremy Bullock |
4bf672 |
settings.setValue("isVertical", m_plainColorPage->getIsVertical());
|
|
Jeremy Bullock |
0a2e55 |
int visibleParts = 0;
|
|
Jeremy Bullock |
0a2e55 |
if (m_wheelAction->isChecked()) visibleParts |= 0x01;
|
|
Jeremy Bullock |
0a2e55 |
if (m_hsvAction->isChecked()) visibleParts |= 0x02;
|
|
Jeremy Bullock |
0a2e55 |
if (m_alphaAction->isChecked()) visibleParts |= 0x04;
|
|
Jeremy Bullock |
0a2e55 |
if (m_rgbAction->isChecked()) visibleParts |= 0x08;
|
|
justburner |
a13da2 |
if (m_hexAction->isChecked()) visibleParts |= 0x10;
|
|
justburner |
981d46 |
if (m_searchAction->isChecked()) visibleParts |= 0x20;
|
|
Jeremy Bullock |
0a2e55 |
settings.setValue("visibleParts", visibleParts);
|
|
Jeremy Bullock |
4bf672 |
settings.setValue("splitterState", m_plainColorPage->getSplitterState());
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
void StyleEditor::load(QSettings &settings) {
|
|
Jeremy Bullock |
4bf672 |
QVariant isVertical = settings.value("isVertical");
|
|
Jeremy Bullock |
4bf672 |
if (isVertical.canConvert(QVariant::Bool)) {
|
|
Jeremy Bullock |
4bf672 |
m_colorPageIsVertical = isVertical.toBool();
|
|
Jeremy Bullock |
4bf672 |
m_plainColorPage->setIsVertical(m_colorPageIsVertical);
|
|
Jeremy Bullock |
4bf672 |
}
|
|
Jeremy Bullock |
4bf672 |
QVariant visibleParts = settings.value("visibleParts");
|
|
Jeremy Bullock |
0a2e55 |
if (visibleParts.canConvert(QVariant::Int)) {
|
|
Jeremy Bullock |
0a2e55 |
int visiblePartsInt = visibleParts.toInt();
|
|
Jeremy Bullock |
0a2e55 |
|
|
Jeremy Bullock |
0a2e55 |
if (visiblePartsInt & 0x01)
|
|
Jeremy Bullock |
0a2e55 |
m_wheelAction->setChecked(true);
|
|
Jeremy Bullock |
0a2e55 |
else
|
|
Jeremy Bullock |
0a2e55 |
m_wheelAction->setChecked(false);
|
|
Jeremy Bullock |
0a2e55 |
if (visiblePartsInt & 0x02)
|
|
Jeremy Bullock |
0a2e55 |
m_hsvAction->setChecked(true);
|
|
Jeremy Bullock |
0a2e55 |
else
|
|
Jeremy Bullock |
0a2e55 |
m_hsvAction->setChecked(false);
|
|
Jeremy Bullock |
0a2e55 |
if (visiblePartsInt & 0x04)
|
|
Jeremy Bullock |
0a2e55 |
m_alphaAction->setChecked(true);
|
|
Jeremy Bullock |
0a2e55 |
else
|
|
Jeremy Bullock |
0a2e55 |
m_alphaAction->setChecked(false);
|
|
Jeremy Bullock |
0a2e55 |
if (visiblePartsInt & 0x08)
|
|
Jeremy Bullock |
0a2e55 |
m_rgbAction->setChecked(true);
|
|
Jeremy Bullock |
0a2e55 |
else
|
|
Jeremy Bullock |
0a2e55 |
m_rgbAction->setChecked(false);
|
|
justburner |
a13da2 |
if (visiblePartsInt & 0x10)
|
|
justburner |
a13da2 |
m_hexAction->setChecked(true);
|
|
justburner |
a13da2 |
else
|
|
justburner |
a13da2 |
m_hexAction->setChecked(false);
|
|
justburner |
981d46 |
if (visiblePartsInt & 0x20)
|
|
justburner |
981d46 |
m_searchAction->setChecked(true);
|
|
justburner |
981d46 |
else
|
|
justburner |
981d46 |
m_searchAction->setChecked(false);
|
|
Jeremy Bullock |
0a2e55 |
}
|
|
Jeremy Bullock |
4bf672 |
QVariant splitterState = settings.value("splitterState");
|
|
Jeremy Bullock |
4bf672 |
if (splitterState.canConvert(QVariant::ByteArray))
|
|
Jeremy Bullock |
4bf672 |
m_plainColorPage->setSplitterState(splitterState.toByteArray());
|
|
shun-iwasawa |
a8f111 |
}
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
a8f111 |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
a8f111 |
|
|
shun-iwasawa |
a8f111 |
void StyleEditor::updateColorCalibration() {
|
|
shun-iwasawa |
a8f111 |
m_plainColorPage->updateColorCalibration();
|
|
justburner |
a13da2 |
}
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
void StyleEditor::onSliderAppearanceSelected(QAction *action) {
|
|
shun-iwasawa |
c18bfa |
bool ok = true;
|
|
shun-iwasawa |
c18bfa |
int appearanceId = action->data().toInt(&ok);
|
|
shun-iwasawa |
c18bfa |
if (!ok) return;
|
|
shun-iwasawa |
c18bfa |
if (appearanceId == StyleEditorColorSliderAppearance) return;
|
|
shun-iwasawa |
c18bfa |
StyleEditorColorSliderAppearance = appearanceId;
|
|
shun-iwasawa |
c18bfa |
ColorSlider::s_slider_appearance = appearanceId;
|
|
shun-iwasawa |
c18bfa |
m_plainColorPage->update();
|
|
shun-iwasawa |
c18bfa |
}
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
c18bfa |
|
|
shun-iwasawa |
c18bfa |
void StyleEditor::onPopupMenuAboutToShow() {
|
|
shun-iwasawa |
c18bfa |
// sync radio button state to the current user env settings
|
|
shun-iwasawa |
c18bfa |
for (auto action : m_sliderAppearanceAG->actions()) {
|
|
shun-iwasawa |
c18bfa |
bool ok = true;
|
|
shun-iwasawa |
c18bfa |
int appearanceId = action->data().toInt(&ok);
|
|
shun-iwasawa |
c18bfa |
if (ok && appearanceId == StyleEditorColorSliderAppearance)
|
|
shun-iwasawa |
c18bfa |
action->setChecked(true);
|
|
shun-iwasawa |
c18bfa |
}
|
|
justburner |
a72214 |
}
|