make color slider appearance optional hide color param bar when there is no sub colors
This commit is contained in:
parent
7a23b1e29a
commit
caf6d70d60
4 changed files with 205 additions and 152 deletions
|
@ -296,13 +296,12 @@ void TColorStyle::makeIcon(const TDimension &d) {
|
||||||
bbox = bbox.enlarge(TDimensionD(-10, -10));
|
bbox = bbox.enlarge(TDimensionD(-10, -10));
|
||||||
checkErrorsByGL;
|
checkErrorsByGL;
|
||||||
|
|
||||||
double scx = 0.9 * d.lx / bbox.getLx();
|
double scx = 0.9 * d.lx / bbox.getLx();
|
||||||
double scy = 0.9 * d.ly / bbox.getLy();
|
double scy = 0.9 * d.ly / bbox.getLy();
|
||||||
double sc = std::min(scx, scy);
|
double sc = std::min(scx, scy);
|
||||||
double dx = (d.lx - bbox.getLx() * sc) * 0.5;
|
double dx = (d.lx - bbox.getLx() * sc) * 0.5;
|
||||||
double dy = (d.ly - bbox.getLy() * sc) * 0.5;
|
double dy = (d.ly - bbox.getLy() * sc) * 0.5;
|
||||||
TAffine aff =
|
TAffine aff = TScale(sc) * TTranslation(-bbox.getP00() + TPointD(dx, dy));
|
||||||
TScale(scx, scy) * TTranslation(-bbox.getP00() + TPointD(dx, dy));
|
|
||||||
|
|
||||||
checkErrorsByGL;
|
checkErrorsByGL;
|
||||||
if (isRegionStyle() && !isStrokeStyle()) aff = aff * TTranslation(-10, -10);
|
if (isRegionStyle() && !isStrokeStyle()) aff = aff * TTranslation(-10, -10);
|
||||||
|
@ -392,7 +391,7 @@ class ColorStyleList { // singleton
|
||||||
public:
|
public:
|
||||||
static ColorStyleList *instance() {
|
static ColorStyleList *instance() {
|
||||||
static ColorStyleList *_instance = 0;
|
static ColorStyleList *_instance = 0;
|
||||||
if (!_instance) _instance = new ColorStyleList();
|
if (!_instance) _instance = new ColorStyleList();
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,28 +253,43 @@ void TMyPaintBrushStyle::resetBaseValues() {
|
||||||
void TMyPaintBrushStyle::makeIcon(const TDimension &d) {
|
void TMyPaintBrushStyle::makeIcon(const TDimension &d) {
|
||||||
TFilePath path =
|
TFilePath path =
|
||||||
m_fullpath.getParentDir() + (m_fullpath.getWideName() + L"_prev.png");
|
m_fullpath.getParentDir() + (m_fullpath.getWideName() + L"_prev.png");
|
||||||
|
TPointD offset(0, 0);
|
||||||
if (!m_preview) {
|
if (!m_preview) {
|
||||||
m_icon = TRaster32P(d);
|
m_icon = TRaster32P(d);
|
||||||
m_icon->fill(TPixel32::Red);
|
m_icon->fill(TPixel32::Red);
|
||||||
} else if (m_preview->getSize() == d) {
|
} else if (m_preview->getSize() == d) {
|
||||||
m_icon = m_preview;
|
m_icon = m_preview;
|
||||||
} else {
|
} else {
|
||||||
m_icon = TRaster32P(d);
|
m_icon = TRaster32P(d);
|
||||||
double sx = (double)d.lx / (double)m_preview->getLx();
|
if (d.lx != d.ly) {
|
||||||
double sy = (double)d.ly / (double)m_preview->getLy();
|
TPixel32 col = getMainColor();
|
||||||
TRop::resample(m_icon, m_preview, TScale(sx, sy));
|
if (col.m == 255)
|
||||||
|
m_icon->fill(col);
|
||||||
|
else {
|
||||||
|
TRaster32P fg(d);
|
||||||
|
fg->fill(premultiply(col));
|
||||||
|
TRop::checkBoard(m_icon, TPixel32::Black, TPixel32::White,
|
||||||
|
TDimensionD(6, 6), TPointD());
|
||||||
|
TRop::over(m_icon, fg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
double sx = (double)d.lx / (double)m_preview->getLx();
|
||||||
|
double sy = (double)d.ly / (double)m_preview->getLy();
|
||||||
|
double scale = std::min(sx, sy);
|
||||||
|
TRop::quickPut(m_icon, m_preview, TScale(scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint color marker
|
// paint color marker
|
||||||
if (d.lx > 0 && d.ly > 0) {
|
if (d.lx > 0 && d.ly > 0) {
|
||||||
int size = std::min(1 + std::min(d.lx, d.ly) * 2 / 3,
|
int size = std::min(1 + std::min(d.lx, d.ly) * 2 / 3,
|
||||||
1 + std::max(d.lx, d.ly) / 2);
|
1 + std::max(d.lx, d.ly) / 2);
|
||||||
TPixel32 color = getMainColor();
|
TPixel32 color = getMainColor();
|
||||||
|
color.m = 255; // show full opac color
|
||||||
for (int y = 0; y < size; ++y) {
|
for (int y = 0; y < size; ++y) {
|
||||||
TPixel32 *p = m_icon->pixels(d.ly - y - 1);
|
TPixel32 *p = m_icon->pixels(d.ly - y - 1);
|
||||||
TPixel32 *endp = p + size - y - 1;
|
TPixel32 *endp = p + size - y - 1;
|
||||||
for (; p != endp; ++p) *p = color;
|
for (; p != endp; ++p) *p = color;
|
||||||
*p = blend(*p, color, 0.5);
|
*p = blend(*p, color, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ CommonChessboard *CommonChessboard::instance() {
|
||||||
CommonChessboard::CommonChessboard() : m_bgRas(40.0, 40.0) { update(); }
|
CommonChessboard::CommonChessboard() : m_bgRas(40.0, 40.0) { update(); }
|
||||||
|
|
||||||
void CommonChessboard::setChessboardColors(const TPixel32 &col1,
|
void CommonChessboard::setChessboardColors(const TPixel32 &col1,
|
||||||
const TPixel32 &col2) {
|
const TPixel32 &col2) {
|
||||||
TRop::checkBoard(m_bgRas, col1, col2,
|
TRop::checkBoard(m_bgRas, col1, col2,
|
||||||
TDimensionD(m_bgRas->getLx() / 8, m_bgRas->getLy() / 8),
|
TDimensionD(m_bgRas->getLx() / 8, m_bgRas->getLy() / 8),
|
||||||
TPointD(0, 0));
|
TPointD(0, 0));
|
||||||
|
@ -137,18 +137,32 @@ void StyleSample::setStyle(TColorStyle &style, int colorParameterIndex) {
|
||||||
// Store current color
|
// Store current color
|
||||||
TPixel32 color = style.getColorParamValue(colorParameterIndex);
|
TPixel32 color = style.getColorParamValue(colorParameterIndex);
|
||||||
m_currentColor = QColor(color.r, color.g, color.b, color.m);
|
m_currentColor = QColor(color.r, color.g, color.b, color.m);
|
||||||
|
if (LutManager::instance()->isValid())
|
||||||
|
LutManager::instance()->convert(m_currentColor);
|
||||||
|
|
||||||
/*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/
|
/*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/
|
||||||
if (style.getTagId() == 3) {
|
if (style.getTagId() == 3) {
|
||||||
setColor(style.getMainColor());
|
setColor(style.getMainColor());
|
||||||
m_stretch = true;
|
m_stretch = true;
|
||||||
} else {
|
} else {
|
||||||
TRaster32P icon =
|
TDimension iconDim(width(), height());
|
||||||
style.getIcon(qsize2Dimension(m_samplePixmap.rect().size()));
|
|
||||||
|
// obtain square icon for the TMyPaintBrushStyle
|
||||||
|
// so that the checkerboard color will become consistent with solido style
|
||||||
|
// when the main color is semi-transparent.
|
||||||
|
if (style.getTagId() == 4001) {
|
||||||
|
int d = std::min(width(), height());
|
||||||
|
iconDim = TDimension(d, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
TRaster32P icon = style.getIcon(iconDim);
|
||||||
|
// TRaster32P icon =
|
||||||
|
// style.getIcon(qsize2Dimension(m_samplePixmap.rect().size()));
|
||||||
m_samplePixmap = rasterToQImage(icon, false); // modified in 6.2
|
m_samplePixmap = rasterToQImage(icon, false); // modified in 6.2
|
||||||
m_stretch = false;
|
m_stretch = style.getTagId() == 4;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cloneStyle) {
|
if (m_cloneStyle) {
|
||||||
if (m_style) delete m_style; // avoid memory leak
|
if (m_style) delete m_style; // avoid memory leak
|
||||||
m_style = style.clone();
|
m_style = style.clone();
|
||||||
|
@ -196,7 +210,9 @@ void StyleSample::paintEvent(QPaintEvent *event) {
|
||||||
if (m_stretch) {
|
if (m_stretch) {
|
||||||
painter.drawImage(0, 0, m_samplePixmap.scaled(size()));
|
painter.drawImage(0, 0, m_samplePixmap.scaled(size()));
|
||||||
} else {
|
} else {
|
||||||
int x = (width() - m_samplePixmap.width()) / 2;
|
// put the icon on the left
|
||||||
|
int x = 0;
|
||||||
|
// int x = (width() - m_samplePixmap.width()) / 2;
|
||||||
int y = (height() - m_samplePixmap.height()) / 2;
|
int y = (height() - m_samplePixmap.height()) / 2;
|
||||||
painter.fillRect(rect(), m_currentColor);
|
painter.fillRect(rect(), m_currentColor);
|
||||||
painter.drawImage(x, y, m_samplePixmap);
|
painter.drawImage(x, y, m_samplePixmap);
|
||||||
|
|
|
@ -150,7 +150,7 @@ bool HexLineEdit::fromText(QString text) {
|
||||||
text.remove(space);
|
text.remove(space);
|
||||||
if (text.size() == 0) return false;
|
if (text.size() == 0) return false;
|
||||||
if (text[0] == "#") return fromHex(text);
|
if (text[0] == "#") return fromHex(text);
|
||||||
text = text.toLower(); // table names are lowercase
|
text = text.toLower(); // table names are lowercase
|
||||||
|
|
||||||
// Find color from tables, user takes priority
|
// Find color from tables, user takes priority
|
||||||
QMap<QString, QString>::const_iterator it;
|
QMap<QString, QString>::const_iterator it;
|
||||||
|
@ -175,19 +175,19 @@ bool HexLineEdit::fromHex(QString text) {
|
||||||
if (!ok) return false;
|
if (!ok) return false;
|
||||||
|
|
||||||
switch (text.length()) {
|
switch (text.length()) {
|
||||||
case 8: // #RRGGBBAA
|
case 8: // #RRGGBBAA
|
||||||
m_color.r = parsedValue >> 24;
|
m_color.r = parsedValue >> 24;
|
||||||
m_color.g = parsedValue >> 16;
|
m_color.g = parsedValue >> 16;
|
||||||
m_color.b = parsedValue >> 8;
|
m_color.b = parsedValue >> 8;
|
||||||
m_color.m = parsedValue;
|
m_color.m = parsedValue;
|
||||||
break;
|
break;
|
||||||
case 6: // #RRGGBB
|
case 6: // #RRGGBB
|
||||||
m_color.r = parsedValue >> 16;
|
m_color.r = parsedValue >> 16;
|
||||||
m_color.g = parsedValue >> 8;
|
m_color.g = parsedValue >> 8;
|
||||||
m_color.b = parsedValue;
|
m_color.b = parsedValue;
|
||||||
m_color.m = 255;
|
m_color.m = 255;
|
||||||
break;
|
break;
|
||||||
case 4: // #RGBA
|
case 4: // #RGBA
|
||||||
m_color.r = (parsedValue >> 12) & 15;
|
m_color.r = (parsedValue >> 12) & 15;
|
||||||
m_color.r |= m_color.r << 4;
|
m_color.r |= m_color.r << 4;
|
||||||
m_color.g = (parsedValue >> 8) & 15;
|
m_color.g = (parsedValue >> 8) & 15;
|
||||||
|
@ -197,7 +197,7 @@ bool HexLineEdit::fromHex(QString text) {
|
||||||
m_color.m = parsedValue & 15;
|
m_color.m = parsedValue & 15;
|
||||||
m_color.m |= m_color.m << 4;
|
m_color.m |= m_color.m << 4;
|
||||||
break;
|
break;
|
||||||
case 3: // #RGB
|
case 3: // #RGB
|
||||||
m_color.r = (parsedValue >> 8) & 15;
|
m_color.r = (parsedValue >> 8) & 15;
|
||||||
m_color.r |= m_color.r << 4;
|
m_color.r |= m_color.r << 4;
|
||||||
m_color.g = (parsedValue >> 4) & 15;
|
m_color.g = (parsedValue >> 4) & 15;
|
||||||
|
@ -206,13 +206,13 @@ bool HexLineEdit::fromHex(QString text) {
|
||||||
m_color.b |= m_color.b << 4;
|
m_color.b |= m_color.b << 4;
|
||||||
m_color.m = 255;
|
m_color.m = 255;
|
||||||
break;
|
break;
|
||||||
case 2: // #VV (non-standard)
|
case 2: // #VV (non-standard)
|
||||||
m_color.r = parsedValue;
|
m_color.r = parsedValue;
|
||||||
m_color.g = m_color.r;
|
m_color.g = m_color.r;
|
||||||
m_color.b = m_color.r;
|
m_color.b = m_color.r;
|
||||||
m_color.m = 255;
|
m_color.m = 255;
|
||||||
break;
|
break;
|
||||||
case 1: // #V (non-standard)
|
case 1: // #V (non-standard)
|
||||||
m_color.r = parsedValue & 15;
|
m_color.r = parsedValue & 15;
|
||||||
m_color.r |= m_color.r << 4;
|
m_color.r |= m_color.r << 4;
|
||||||
m_color.g = m_color.r;
|
m_color.g = m_color.r;
|
||||||
|
@ -864,6 +864,13 @@ HexagonalColorWheel::~HexagonalColorWheel() {
|
||||||
|
|
||||||
void HexagonalColorWheel::updateColorCalibration() {
|
void HexagonalColorWheel::updateColorCalibration() {
|
||||||
if (Preferences::instance()->isColorCalibrationEnabled()) {
|
if (Preferences::instance()->isColorCalibrationEnabled()) {
|
||||||
|
// prevent to initialize LutCalibrator before this instance is initialized
|
||||||
|
// or OT may crash due to missing OpenGL context
|
||||||
|
if (m_firstInitialized) {
|
||||||
|
cueCalibrationUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
if (!m_lutCalibrator)
|
if (!m_lutCalibrator)
|
||||||
m_lutCalibrator = new LutCalibrator();
|
m_lutCalibrator = new LutCalibrator();
|
||||||
|
@ -1344,11 +1351,13 @@ void ColorSlider::paintEvent(QPaintEvent *event) {
|
||||||
In this case we draw "manually" the slider handle at correct position
|
In this case we draw "manually" the slider handle at correct position
|
||||||
*/
|
*/
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
static QPixmap vHandlePixmap = svgToPixmap(":Resources/v_chandle_arrow.svg");
|
static QPixmap vHandlePixmap =
|
||||||
|
svgToPixmap(":Resources/v_chandle_arrow.svg");
|
||||||
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), h, true);
|
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), h, true);
|
||||||
p.drawPixmap(width() - s_chandle_tall, pos, vHandlePixmap);
|
p.drawPixmap(width() - s_chandle_tall, pos, vHandlePixmap);
|
||||||
} else {
|
} else {
|
||||||
static QPixmap hHandlePixmap = svgToPixmap(":Resources/h_chandle_arrow.svg");
|
static QPixmap hHandlePixmap =
|
||||||
|
svgToPixmap(":Resources/h_chandle_arrow.svg");
|
||||||
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), w, false);
|
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), w, false);
|
||||||
p.drawPixmap(pos, height() - s_chandle_tall, hHandlePixmap);
|
p.drawPixmap(pos, height() - s_chandle_tall, hHandlePixmap);
|
||||||
}
|
}
|
||||||
|
@ -1757,6 +1766,7 @@ void ColorParameterSelector::setStyle(const TColorStyle &style) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
show();
|
||||||
if (m_colors.size() != count) {
|
if (m_colors.size() != count) {
|
||||||
m_index = 0;
|
m_index = 0;
|
||||||
m_colors.resize(count);
|
m_colors.resize(count);
|
||||||
|
@ -1774,7 +1784,11 @@ void ColorParameterSelector::setStyle(const TColorStyle &style) {
|
||||||
void ColorParameterSelector::clear() {
|
void ColorParameterSelector::clear() {
|
||||||
if (m_colors.size() != 0) m_colors.clear();
|
if (m_colors.size() != 0) m_colors.clear();
|
||||||
m_index = 0;
|
m_index = 0;
|
||||||
update();
|
if (isVisible()) {
|
||||||
|
hide();
|
||||||
|
update();
|
||||||
|
qApp->processEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -4300,66 +4314,6 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
||||||
|
|
||||||
QFrame *bottomWidget = createBottomWidget();
|
QFrame *bottomWidget = createBottomWidget();
|
||||||
|
|
||||||
m_toolBar = new QToolBar(this);
|
|
||||||
m_toolBar->setMovable(false);
|
|
||||||
m_toolBar->setMaximumHeight(22);
|
|
||||||
m_toolBar->addWidget(m_colorParameterSelector);
|
|
||||||
|
|
||||||
QMenu *menu = new QMenu();
|
|
||||||
m_wheelAction = new QAction(tr("Wheel"), this);
|
|
||||||
m_hsvAction = new QAction(tr("HSV"), this);
|
|
||||||
m_alphaAction = new QAction(tr("Alpha"), this);
|
|
||||||
m_rgbAction = new QAction(tr("RGB"), this);
|
|
||||||
m_hexAction = new QAction(tr("Hex"), this);
|
|
||||||
|
|
||||||
m_wheelAction->setCheckable(true);
|
|
||||||
m_hsvAction->setCheckable(true);
|
|
||||||
m_alphaAction->setCheckable(true);
|
|
||||||
m_rgbAction->setCheckable(true);
|
|
||||||
m_hexAction->setCheckable(true);
|
|
||||||
m_wheelAction->setChecked(true);
|
|
||||||
m_hsvAction->setChecked(false);
|
|
||||||
m_alphaAction->setChecked(true);
|
|
||||||
m_rgbAction->setChecked(false);
|
|
||||||
m_hexAction->setChecked(false);
|
|
||||||
menu->addAction(m_wheelAction);
|
|
||||||
menu->addAction(m_alphaAction);
|
|
||||||
menu->addAction(m_hsvAction);
|
|
||||||
menu->addAction(m_rgbAction);
|
|
||||||
menu->addAction(m_hexAction);
|
|
||||||
|
|
||||||
QFontMetrics fm(QApplication::font());
|
|
||||||
|
|
||||||
m_plainColorPage->m_hsvFrame->setVisible(false);
|
|
||||||
m_plainColorPage->m_rgbFrame->setVisible(false);
|
|
||||||
|
|
||||||
QToolButton *toolButton = new QToolButton(this);
|
|
||||||
toolButton->setIcon(createQIcon("menu"));
|
|
||||||
toolButton->setFixedSize(22, 22);
|
|
||||||
toolButton->setMenu(menu);
|
|
||||||
toolButton->setPopupMode(QToolButton::InstantPopup);
|
|
||||||
toolButton->setToolTip(tr("Show or hide parts of the Color Page."));
|
|
||||||
|
|
||||||
m_styleSetsButton = new QToolButton(this);
|
|
||||||
m_styleSetsButton->setIcon(createQIcon("stylesets"));
|
|
||||||
m_styleSetsButton->setFixedSize(22, 22);
|
|
||||||
m_styleSetsButton->setPopupMode(QToolButton::InstantPopup);
|
|
||||||
m_styleSetsButton->setToolTip(tr("Show or hide style sets."));
|
|
||||||
|
|
||||||
QToolBar *displayToolbar = new QToolBar(this);
|
|
||||||
displayToolbar->addWidget(m_styleSetsButton);
|
|
||||||
m_toggleOrientationAction =
|
|
||||||
displayToolbar->addAction(createQIcon("orientation_h"), "");
|
|
||||||
m_toggleOrientationAction->setToolTip(
|
|
||||||
tr("Toggle orientation of the Color Page."));
|
|
||||||
QWidget *toggleOrientationButton =
|
|
||||||
displayToolbar->widgetForAction(m_toggleOrientationAction);
|
|
||||||
toggleOrientationButton->setFixedSize(22, 22);
|
|
||||||
toggleOrientationButton->setFocusPolicy(Qt::NoFocus);
|
|
||||||
displayToolbar->addWidget(toolButton);
|
|
||||||
displayToolbar->setMaximumHeight(22);
|
|
||||||
displayToolbar->setIconSize(QSize(16, 16));
|
|
||||||
|
|
||||||
/* ------- layout ------- */
|
/* ------- layout ------- */
|
||||||
QGridLayout *mainLayout = new QGridLayout;
|
QGridLayout *mainLayout = new QGridLayout;
|
||||||
mainLayout->setMargin(0);
|
mainLayout->setMargin(0);
|
||||||
|
@ -4377,8 +4331,8 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
||||||
mainLayout->addWidget(m_tabBarContainer, 0, 0, 1, 2);
|
mainLayout->addWidget(m_tabBarContainer, 0, 0, 1, 2);
|
||||||
mainLayout->addWidget(m_styleChooser, 1, 0, 1, 2);
|
mainLayout->addWidget(m_styleChooser, 1, 0, 1, 2);
|
||||||
mainLayout->addWidget(bottomWidget, 2, 0, 1, 2);
|
mainLayout->addWidget(bottomWidget, 2, 0, 1, 2);
|
||||||
mainLayout->addWidget(m_toolBar, 3, 0);
|
// mainLayout->addWidget(m_toolBar, 3, 0);
|
||||||
mainLayout->addWidget(displayToolbar, 3, 1);
|
// mainLayout->addWidget(displayToolbar, 3, 1);
|
||||||
}
|
}
|
||||||
mainLayout->setColumnStretch(0, 1);
|
mainLayout->setColumnStretch(0, 1);
|
||||||
mainLayout->setRowStretch(1, 1);
|
mainLayout->setRowStretch(1, 1);
|
||||||
|
@ -4396,30 +4350,6 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
||||||
ret = ret && connect(m_plainColorPage,
|
ret = ret && connect(m_plainColorPage,
|
||||||
SIGNAL(colorChanged(const ColorModel &, bool)), this,
|
SIGNAL(colorChanged(const ColorModel &, bool)), this,
|
||||||
SLOT(onColorChanged(const ColorModel &, bool)));
|
SLOT(onColorChanged(const ColorModel &, bool)));
|
||||||
|
|
||||||
ret = ret && connect(m_wheelAction, SIGNAL(toggled(bool)),
|
|
||||||
m_plainColorPage->m_wheelFrame, SLOT(setVisible(bool)));
|
|
||||||
ret = ret && connect(m_hsvAction, SIGNAL(toggled(bool)),
|
|
||||||
m_plainColorPage->m_hsvFrame, SLOT(setVisible(bool)));
|
|
||||||
ret = ret && connect(m_alphaAction, SIGNAL(toggled(bool)),
|
|
||||||
m_plainColorPage->m_alphaFrame, SLOT(setVisible(bool)));
|
|
||||||
ret = ret && connect(m_rgbAction, SIGNAL(toggled(bool)),
|
|
||||||
m_plainColorPage->m_rgbFrame, SLOT(setVisible(bool)));
|
|
||||||
ret = ret && connect(m_hexAction, SIGNAL(toggled(bool)), m_hexLineEdit,
|
|
||||||
SLOT(setVisible(bool)));
|
|
||||||
ret = ret && connect(m_hexLineEdit, SIGNAL(editingFinished()), this,
|
|
||||||
SLOT(onHexChanged()));
|
|
||||||
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()),
|
|
||||||
m_plainColorPage, SLOT(toggleOrientation()));
|
|
||||||
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), this,
|
|
||||||
SLOT(updateOrientationButton()));
|
|
||||||
ret = ret && connect(m_hexLineEdit, SIGNAL(returnPressed()), this,
|
|
||||||
SLOT(onHexChanged()));
|
|
||||||
ret = ret && connect(m_hexLineEdit, SIGNAL(textEdited(const QString &)), this,
|
|
||||||
SLOT(onHexEdited(const QString &)));
|
|
||||||
ret = ret && connect(menu, SIGNAL(aboutToHide()), this, SLOT(onHideMenu()));
|
|
||||||
ret = ret && connect(m_styleChooser, SIGNAL(currentChanged(int)), this,
|
|
||||||
SLOT(onPageChanged(int)));
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
/* ------- initial conditions ------- */
|
/* ------- initial conditions ------- */
|
||||||
enable(false, false, false);
|
enable(false, false, false);
|
||||||
|
@ -4457,6 +4387,7 @@ QFrame *StyleEditor::createBottomWidget() {
|
||||||
bottomWidget->setFrameStyle(QFrame::StyledPanel);
|
bottomWidget->setFrameStyle(QFrame::StyledPanel);
|
||||||
bottomWidget->setObjectName("bottomWidget");
|
bottomWidget->setObjectName("bottomWidget");
|
||||||
bottomWidget->setContentsMargins(0, 0, 0, 0);
|
bottomWidget->setContentsMargins(0, 0, 0, 0);
|
||||||
|
bottomWidget->setFixedHeight(60);
|
||||||
m_applyButton->setToolTip(tr("Apply changes to current style"));
|
m_applyButton->setToolTip(tr("Apply changes to current style"));
|
||||||
m_applyButton->setDisabled(m_paletteController->isColorAutoApplyEnabled());
|
m_applyButton->setDisabled(m_paletteController->isColorAutoApplyEnabled());
|
||||||
m_applyButton->setFocusPolicy(Qt::NoFocus);
|
m_applyButton->setFocusPolicy(Qt::NoFocus);
|
||||||
|
@ -4482,54 +4413,146 @@ QFrame *StyleEditor::createBottomWidget() {
|
||||||
m_hexLineEdit->loadDefaultColorNames(false);
|
m_hexLineEdit->loadDefaultColorNames(false);
|
||||||
m_hexLineEdit->loadUserColorNames(false);
|
m_hexLineEdit->loadUserColorNames(false);
|
||||||
|
|
||||||
m_fillColorWidget->setFixedHeight(32);
|
m_toolBar = new QToolBar(this);
|
||||||
m_fillColorWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
m_toolBar->setMovable(false);
|
||||||
|
m_toolBar->setMaximumHeight(22);
|
||||||
|
m_toolBar->addWidget(m_colorParameterSelector);
|
||||||
|
|
||||||
|
QMenu *menu = new QMenu();
|
||||||
|
m_wheelAction = new QAction(tr("Wheel"), this);
|
||||||
|
m_hsvAction = new QAction(tr("HSV"), this);
|
||||||
|
m_alphaAction = new QAction(tr("Alpha"), this);
|
||||||
|
m_rgbAction = new QAction(tr("RGB"), this);
|
||||||
|
m_hexAction = new QAction(tr("Hex"), this);
|
||||||
|
|
||||||
|
m_wheelAction->setCheckable(true);
|
||||||
|
m_hsvAction->setCheckable(true);
|
||||||
|
m_alphaAction->setCheckable(true);
|
||||||
|
m_rgbAction->setCheckable(true);
|
||||||
|
m_hexAction->setCheckable(true);
|
||||||
|
m_wheelAction->setChecked(true);
|
||||||
|
m_hsvAction->setChecked(false);
|
||||||
|
m_alphaAction->setChecked(true);
|
||||||
|
m_rgbAction->setChecked(false);
|
||||||
|
m_hexAction->setChecked(false);
|
||||||
|
menu->addAction(m_wheelAction);
|
||||||
|
menu->addAction(m_alphaAction);
|
||||||
|
menu->addAction(m_hsvAction);
|
||||||
|
menu->addAction(m_rgbAction);
|
||||||
|
menu->addAction(m_hexAction);
|
||||||
|
|
||||||
|
QFontMetrics fm(QApplication::font());
|
||||||
|
|
||||||
|
m_plainColorPage->m_hsvFrame->setVisible(false);
|
||||||
|
m_plainColorPage->m_rgbFrame->setVisible(false);
|
||||||
|
|
||||||
|
QToolButton *toolButton = new QToolButton(this);
|
||||||
|
toolButton->setIcon(createQIcon("menu"));
|
||||||
|
toolButton->setFixedSize(22, 22);
|
||||||
|
toolButton->setMenu(menu);
|
||||||
|
toolButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
toolButton->setToolTip(tr("Show or hide parts of the Color Page."));
|
||||||
|
|
||||||
|
m_styleSetsButton = new QToolButton(this);
|
||||||
|
m_styleSetsButton->setIcon(createQIcon("stylesets"));
|
||||||
|
m_styleSetsButton->setFixedSize(22, 22);
|
||||||
|
m_styleSetsButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
m_styleSetsButton->setToolTip(tr("Show or hide style sets."));
|
||||||
|
|
||||||
|
// QToolBar *displayToolbar = new QToolBar(this);
|
||||||
|
m_toolBar->addWidget(m_styleSetsButton);
|
||||||
|
m_toggleOrientationAction =
|
||||||
|
m_toolBar->addAction(createQIcon("orientation_h"), "");
|
||||||
|
m_toggleOrientationAction->setToolTip(
|
||||||
|
tr("Toggle orientation of the Color Page."));
|
||||||
|
QWidget *toggleOrientationButton =
|
||||||
|
m_toolBar->widgetForAction(m_toggleOrientationAction);
|
||||||
|
toggleOrientationButton->setFixedSize(22, 22);
|
||||||
|
toggleOrientationButton->setFocusPolicy(Qt::NoFocus);
|
||||||
|
m_toolBar->addWidget(toolButton);
|
||||||
|
m_toolBar->setMaximumHeight(22);
|
||||||
|
m_toolBar->setIconSize(QSize(16, 16));
|
||||||
|
|
||||||
|
m_fillColorWidget->setMinimumHeight(24);
|
||||||
|
m_fillColorWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
QHBoxLayout *fillColorLayout = new QHBoxLayout(this);
|
QHBoxLayout *fillColorLayout = new QHBoxLayout(this);
|
||||||
fillColorLayout->addWidget(new QLabel(" ", this));
|
fillColorLayout->addWidget(new QLabel(" ", this));
|
||||||
m_fillColorWidget->setLayout(fillColorLayout);
|
m_fillColorWidget->setLayout(fillColorLayout);
|
||||||
|
|
||||||
/* ------ layout ------ */
|
/* ------ layout ------ */
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||||
mainLayout->setMargin(2);
|
mainLayout->setMargin(2);
|
||||||
mainLayout->setSpacing(1);
|
mainLayout->setSpacing(0);
|
||||||
{
|
{
|
||||||
QHBoxLayout *hLayout = new QHBoxLayout;
|
mainLayout->addWidget(m_autoButton);
|
||||||
hLayout->setMargin(0);
|
// mainLayout->addSpacing(4);
|
||||||
hLayout->setSpacing(0);
|
mainLayout->addWidget(m_applyButton);
|
||||||
{
|
// mainLayout->addSpacing(4);
|
||||||
hLayout->addWidget(m_autoButton);
|
|
||||||
// hLayout->addSpacing(2);
|
|
||||||
hLayout->addWidget(m_applyButton);
|
|
||||||
// hLayout->addSpacing(2);
|
|
||||||
hLayout->addWidget(m_newColor, 1);
|
|
||||||
hLayout->addWidget(m_oldColor, 0);
|
|
||||||
hLayout->addWidget(m_fillColorWidget, 0);
|
|
||||||
hLayout->addSpacing(2);
|
|
||||||
hLayout->addWidget(m_hexLineEdit);
|
|
||||||
m_oldColor->hide();
|
|
||||||
}
|
|
||||||
mainLayout->addLayout(hLayout);
|
|
||||||
m_autoButton->hide();
|
|
||||||
m_applyButton->hide();
|
|
||||||
|
|
||||||
// QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
QVBoxLayout *colorLay = new QVBoxLayout();
|
||||||
// buttonsLayout->setMargin(0);
|
colorLay->setMargin(0);
|
||||||
// buttonsLayout->setSpacing(5);
|
colorLay->setSpacing(0);
|
||||||
//{ buttonsLayout->addWidget(m_applyButton); }
|
{
|
||||||
// mainLayout->addLayout(buttonsLayout);
|
QHBoxLayout *chipLay = new QHBoxLayout();
|
||||||
|
chipLay->setMargin(0);
|
||||||
|
chipLay->setSpacing(0);
|
||||||
|
{
|
||||||
|
chipLay->addWidget(m_newColor, 1);
|
||||||
|
chipLay->addWidget(m_oldColor, 1);
|
||||||
|
chipLay->addWidget(m_fillColorWidget, 0);
|
||||||
|
}
|
||||||
|
colorLay->addLayout(chipLay, 1);
|
||||||
|
colorLay->addSpacing(2);
|
||||||
|
|
||||||
|
colorLay->addWidget(m_colorParameterSelector, 0);
|
||||||
|
}
|
||||||
|
mainLayout->addLayout(colorLay, 1);
|
||||||
|
|
||||||
|
QVBoxLayout *hexLay = new QVBoxLayout();
|
||||||
|
hexLay->setMargin(0);
|
||||||
|
hexLay->setSpacing(0);
|
||||||
|
{
|
||||||
|
hexLay->addWidget(m_hexLineEdit);
|
||||||
|
hexLay->addWidget(m_toolBar, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||||
|
}
|
||||||
|
mainLayout->addLayout(hexLay, 0);
|
||||||
}
|
}
|
||||||
bottomWidget->setLayout(mainLayout);
|
bottomWidget->setLayout(mainLayout);
|
||||||
|
|
||||||
|
m_oldColor->hide();
|
||||||
|
m_autoButton->hide();
|
||||||
|
m_applyButton->hide();
|
||||||
|
|
||||||
/* ------ signal-slot connections ------ */
|
/* ------ signal-slot connections ------ */
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
// ret = ret && connect(m_applyButton, SIGNAL(clicked()), this,
|
// ret = ret && connect(m_applyButton, SIGNAL(clicked()), this,
|
||||||
// SLOT(applyButtonClicked()));
|
// SLOT(applyButtonClicked()));
|
||||||
ret = ret && connect(m_autoButton, SIGNAL(toggled(bool)), this,
|
ret = ret && connect(m_autoButton, SIGNAL(toggled(bool)), this,
|
||||||
SLOT(autoCheckChanged(bool)));
|
SLOT(autoCheckChanged(bool)));
|
||||||
// ret = ret && connect(m_oldColor, SIGNAL(clicked()), this,
|
// ret = ret &&
|
||||||
// SLOT(onOldStyleClicked()));
|
// connect(m_oldColor, SIGNAL(clicked()), this, SLOT(onOldStyleClicked()));
|
||||||
// ret = ret && connect(m_newColor, SIGNAL(clicked()), this,
|
// ret = ret &&
|
||||||
// SLOT(onNewStyleClicked()));
|
// connect(m_newColor, SIGNAL(clicked()), this, SLOT(onNewStyleClicked()));
|
||||||
|
ret = ret && connect(m_wheelAction, SIGNAL(toggled(bool)),
|
||||||
|
m_plainColorPage->m_wheelFrame, SLOT(setVisible(bool)));
|
||||||
|
ret = ret && connect(m_hsvAction, SIGNAL(toggled(bool)),
|
||||||
|
m_plainColorPage->m_hsvFrame, SLOT(setVisible(bool)));
|
||||||
|
ret = ret && connect(m_alphaAction, SIGNAL(toggled(bool)),
|
||||||
|
m_plainColorPage->m_alphaFrame, SLOT(setVisible(bool)));
|
||||||
|
ret = ret && connect(m_rgbAction, SIGNAL(toggled(bool)),
|
||||||
|
m_plainColorPage->m_rgbFrame, SLOT(setVisible(bool)));
|
||||||
|
ret = ret && connect(m_hexAction, SIGNAL(toggled(bool)), m_hexLineEdit,
|
||||||
|
SLOT(setVisible(bool)));
|
||||||
|
ret = ret && connect(m_hexLineEdit, SIGNAL(editingFinished()), this,
|
||||||
|
SLOT(onHexChanged()));
|
||||||
|
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()),
|
||||||
|
m_plainColorPage, SLOT(toggleOrientation()));
|
||||||
|
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(updateOrientationButton()));
|
||||||
|
ret = ret && connect(menu, SIGNAL(aboutToHide()), this, SLOT(onHideMenu()));
|
||||||
|
ret = ret && connect(m_styleChooser, SIGNAL(currentChanged(int)), this,
|
||||||
|
SLOT(onPageChanged(int)));
|
||||||
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
return bottomWidget;
|
return bottomWidget;
|
||||||
|
@ -5208,9 +5231,7 @@ void StyleEditor::onOldStyleClicked() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void StyleEditor::onNewStyleClicked() {
|
void StyleEditor::onNewStyleClicked() { applyButtonClicked(); }
|
||||||
applyButtonClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -5459,6 +5480,8 @@ void StyleEditor::onColorParamChanged() {
|
||||||
int styleIndex = getStyleIndex();
|
int styleIndex = getStyleIndex();
|
||||||
if (styleIndex < 0 || palette->getStyleCount() <= styleIndex) return;
|
if (styleIndex < 0 || palette->getStyleCount() <= styleIndex) return;
|
||||||
|
|
||||||
|
if (*m_oldStyle != *m_editedStyle) applyButtonClicked();
|
||||||
|
|
||||||
m_paletteHandle->setStyleParamIndex(getColorParam());
|
m_paletteHandle->setStyleParamIndex(getColorParam());
|
||||||
|
|
||||||
if (TColorStyle *currentStyle = palette->getStyle(styleIndex)) {
|
if (TColorStyle *currentStyle = palette->getStyle(styleIndex)) {
|
||||||
|
@ -5503,7 +5526,7 @@ void StyleEditor::onParamStyleChanged(bool isDragging) {
|
||||||
|
|
||||||
if (m_autoButton->isChecked()) copyEditedStyleToPalette(isDragging);
|
if (m_autoButton->isChecked()) copyEditedStyleToPalette(isDragging);
|
||||||
|
|
||||||
m_editedStyle->invalidateIcon(); // Refresh the new color icon
|
m_editedStyle->invalidateIcon(); // Refresh the new color icon
|
||||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||||
|
|
||||||
int tag = m_editedStyle->getTagId();
|
int tag = m_editedStyle->getTagId();
|
||||||
|
|
Loading…
Reference in a new issue