Commit fa81254f authored by Halla Rempt's avatar Halla Rempt
Browse files

BUG:335670 Don't break the lightstrip when floating

Only the left position of the light strip really works, and we tried
to use the top position when the docker was made floating. Just remove
this bit of adaptive smartness -- it doesn't make sense to move the strip
around all the time.
parent 39056162
......@@ -94,8 +94,6 @@ ArtisticColorSelectorDock::ArtisticColorSelectorDock():
connect(m_preferencesUI->bnDefault , SIGNAL(clicked(bool)) , SLOT(slotResetDefaultSettings()));
connect(m_selectorUI->bnAbsLight , SIGNAL(toggled(bool)) , SLOT(slotLightModeChanged(bool)));
connect(m_resetMenu , SIGNAL(triggered(QAction*)) , SLOT(slotMenuActionTriggered(QAction*)));
connect(this , SIGNAL(topLevelChanged(bool)) , SLOT(slotTopLevelChanged(bool)));
connect(this , SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), SLOT(slotDockLocationChanged(Qt::DockWidgetArea)));
setWidget(m_selectorUI);
}
......@@ -201,22 +199,3 @@ void ArtisticColorSelectorDock::slotLightModeChanged(bool setToAbsolute)
m_selectorUI->colorSelector->setLight(m_selectorUI->colorSelector->getLight(), !setToAbsolute);
}
void ArtisticColorSelectorDock::slotDockLocationChanged(Qt::DockWidgetArea area)
{
if(area == Qt::AllDockWidgetAreas) {
m_selectorUI->colorSelector->setLightStripPosition(KisColorSelector::LSP_TOP);
}
else {
if(area & Qt::LeftDockWidgetArea)
m_selectorUI->colorSelector->setLightStripPosition(KisColorSelector::LSP_RIGHT);
if(area & Qt::RightDockWidgetArea)
m_selectorUI->colorSelector->setLightStripPosition(KisColorSelector::LSP_LEFT);
}
}
void ArtisticColorSelectorDock::slotTopLevelChanged(bool topLevel)
{
if(topLevel)
m_selectorUI->colorSelector->setLightStripPosition(KisColorSelector::LSP_TOP);
}
......@@ -47,8 +47,6 @@ private slots:
void slotMenuActionTriggered(QAction* action);
void slotResetDefaultSettings();
void slotLightModeChanged(bool setToAbsolute);
void slotDockLocationChanged(Qt::DockWidgetArea area);
void slotTopLevelChanged(bool topLevel);
private:
KoCanvasBase* m_canvas;
......
......@@ -46,7 +46,6 @@ KisColorSelector::KisColorSelector(QWidget* parent, KisColor::Type type):
m_inverseSaturation(false),
m_relativeLight(false),
m_light(0.5f),
m_lightStripPos(LSP_RIGHT),
m_selectedColorIsFgColor(true),
m_clickedRing(-1)
{
......@@ -62,13 +61,6 @@ void KisColorSelector::setColorSpace(KisColor::Type type)
update();
}
void KisColorSelector::setLightStripPosition(KisColorSelector::LightStripPos pos)
{
m_lightStripPos = pos;
recalculateAreas(quint8(getNumLightPieces()));
update();
}
void KisColorSelector::setNumLightPieces(int num)
{
num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES);
......@@ -182,10 +174,8 @@ qint8 KisColorSelector::getLightIndex(const QPointF& pt) const
{
if (m_lightStripArea.contains(pt.toPoint(), true)) {
qreal t = (pt.x() - m_lightStripArea.x()) / qreal(m_lightStripArea.width());
if (m_lightStripPos == LSP_LEFT || m_lightStripPos == LSP_RIGHT)
t = (pt.y() - m_lightStripArea.y()) / qreal(m_lightStripArea.height());
t = (pt.y() - m_lightStripArea.y()) / qreal(m_lightStripArea.height());
return qint8(t * getNumLightPieces());
}
......@@ -215,13 +205,10 @@ qreal KisColorSelector::getLight(const QPointF& pt) const
qint8 clickedLightPiece = getLightIndex(pt);
if (clickedLightPiece >= 0) {
if (getNumLightPieces() > 1)
if (getNumLightPieces() > 1) {
return 1.0 - (qreal(clickedLightPiece) / qreal(getNumLightPieces()-1));
if (m_lightStripPos == LSP_LEFT || m_lightStripPos == LSP_RIGHT)
return 1.0 - (qreal(pt.y()) / qreal(m_lightStripArea.height()));
return 1.0 - (qreal(pt.x()) / qreal(m_lightStripArea.width()));
}
return 1.0 - (qreal(pt.y()) / qreal(m_lightStripArea.height()));
}
return qreal(0);
......@@ -275,39 +262,16 @@ void KisColorSelector::recalculateAreas(quint8 numLightPieces)
int size = qMin(width, height);
int stripThick = int(size * LIGHT_STRIP_RATIO);
if (m_lightStripPos == LSP_LEFT || m_lightStripPos == LSP_RIGHT)
width -= stripThick;
else
height -= stripThick;
width -= stripThick;
size = qMin(width, height);
int x = (width - size) / 2;
int y = (height - size) / 2;
switch(m_lightStripPos)
{
case LSP_LEFT:
m_renderArea = QRect(x+stripThick, y, size, size);
m_lightStripArea = QRect(0, 0, stripThick, QWidget::height());
break;
case LSP_RIGHT:
m_renderArea = QRect(x, y, size, size);
m_lightStripArea = QRect(QWidget::width()-stripThick, 0, stripThick, QWidget::height());
break;
case LSP_TOP:
m_renderArea = QRect(x, y+stripThick, size, size);
m_lightStripArea = QRect(0, 0, QWidget::width(), stripThick);
break;
case LSP_BOTTOM:
m_renderArea = QRect(x, y, size, size);
m_lightStripArea = QRect(0, QWidget::height()-stripThick, QWidget::width(), stripThick);
break;
}
m_renderArea = QRect(x+stripThick, y, size, size);
m_lightStripArea = QRect(0, 0, stripThick, QWidget::height());
m_renderBuffer = QImage(size, size, QImage::Format_ARGB32);
m_numLightPieces = numLightPieces;
}
......@@ -474,7 +438,7 @@ void KisColorSelector::drawOutline(QPainter& painter, const QRect& rect)
void KisColorSelector::drawLightStrip(QPainter& painter, const QRect& rect)
{
bool isVertical = (m_lightStripPos == LSP_LEFT || m_lightStripPos == LSP_RIGHT);
bool isVertical = true;
qreal penSize = qreal(qMin(QWidget::width(), QWidget::height())) / 200.0;
KisColor color(m_selectedColor);
......
......@@ -60,12 +60,9 @@ class KisColorSelector: public QWidget
};
public:
enum LightStripPos { LSP_LEFT, LSP_RIGHT, LSP_TOP, LSP_BOTTOM };
KisColorSelector(QWidget* parent, KisColor::Type type=KisColor::HSL);
void setColorSpace(KisColor::Type type);
void setLightStripPosition(LightStripPos pos);
void setNumPieces(int num);
void setNumLightPieces(int num);
void setNumRings(int num);
......@@ -137,7 +134,6 @@ private:
QImage m_renderBuffer;
QRect m_renderArea;
QRect m_lightStripArea;
LightStripPos m_lightStripPos;
bool m_mouseMoved;
bool m_selectedColorIsFgColor;
QPointF m_clickPos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment