Commit 3a3010ca authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add an invert button to the level filter widget

Differential Revision: https://phabricator.kde.org/D9052
BUG:375842
CCMAIL:vincentl13x@gmail.com

Patch by Wu Weilin -- thanks!
parent 5077699b
This diff is collapsed.
......@@ -76,6 +76,8 @@ public:
void enableWhite(bool b);
void setInverted(bool b);
private:
int m_leftmost;
int m_rightmost;
......@@ -93,6 +95,7 @@ private:
bool m_gammaEnabled;
bool m_whiteEnabled;
bool m_feedback;
bool m_inverted;
};
#endif /* KIS_GRADIENT_SLIDER_H */
......@@ -134,6 +134,7 @@ KisLevelConfigWidget::KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP de
connect(m_page.outgradient, SIGNAL(sigModifiedWhite(int)), m_page.outwhitespin, SLOT(setValue(int)));
connect(m_page.butauto, SIGNAL(clicked(bool)), this, SLOT(slotAutoLevel(void)));
connect(m_page.butinvert, SIGNAL(clicked(bool)), this, SLOT(slotInvert(void)));
connect((QObject*)(m_page.chkLogarithmic), SIGNAL(toggled(bool)), this, SLOT(slotDrawHistogram(bool)));
......@@ -141,6 +142,7 @@ KisLevelConfigWidget::KisLevelConfigWidget(QWidget * parent, KisPaintDeviceSP de
m_histogram.reset( new KisHistogram(dev, dev->exactBounds(), producer, LINEAR) );
m_histlog = false;
m_page.histview->resize(288,100);
m_inverted = false;
slotDrawHistogram();
}
......@@ -207,12 +209,20 @@ void KisLevelConfigWidget::slotModifyInWhiteLimit(int limit)
void KisLevelConfigWidget::slotModifyOutBlackLimit(int limit)
{
if (m_inverted) {
m_page.outblackspin->setMinimum(limit + 1);
} else {
m_page.outblackspin->setMaximum(limit - 1);
}
}
void KisLevelConfigWidget::slotModifyOutWhiteLimit(int limit)
{
if (m_inverted) {
m_page.outwhitespin->setMaximum(limit - 1);
} else {
m_page.outwhitespin->setMinimum(limit + 1);
}
}
void KisLevelConfigWidget::slotAutoLevel(void)
......@@ -273,6 +283,18 @@ void KisLevelConfigWidget::slotAutoLevel(void)
}
}
void KisLevelConfigWidget::slotInvert(void)
{
m_inverted = !m_inverted;
int white = m_page.outwhitespin->value();
int black = m_page.outblackspin->value();
resetOutSpinLimit();
m_page.outgradient->setInverted(m_inverted);
m_page.outwhitespin->setValue(black);
m_page.outblackspin->setValue(white);
}
KisPropertiesConfigurationSP KisLevelConfigWidget::configuration() const
{
KisColorTransformationConfiguration * config = new KisColorTransformationConfiguration(KisLevelFilter::id().id(), 1);
......@@ -310,3 +332,13 @@ void KisLevelConfigWidget::setConfiguration(const KisPropertiesConfigurationSP
m_page.outgradient->slotModifyWhite(value.toUInt());
}
}
void KisLevelConfigWidget::resetOutSpinLimit() {
if (m_inverted) {
m_page.outblackspin->setMaximum(255);
m_page.outwhitespin->setMinimum(0);
} else {
m_page.outblackspin->setMinimum(0);
m_page.outwhitespin->setMaximum(255);
}
}
......@@ -75,10 +75,14 @@ protected Q_SLOTS:
void slotModifyOutWhiteLimit(int);
void slotAutoLevel(void);
void slotInvert(void);
void resetOutSpinLimit();
protected:
QScopedPointer<KisHistogram> m_histogram;
bool m_histlog;
bool m_inverted;
};
#endif
......@@ -288,6 +288,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="butinvert">
<property name="text">
<string>&amp;Invert</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
......
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