summaryrefslogtreecommitdiffstats
path: root/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz
koffice-698569f8428ca088f764d704034a1330517b98c0.zip
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc')
-rw-r--r--chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc147
1 files changed, 147 insertions, 0 deletions
diff --git a/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc b/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc
new file mode 100644
index 000000000..12005e05d
--- /dev/null
+++ b/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2004 Boudewijn Rempt
+ * (c) 2005 Bart Coppens <kde@bartcoppens.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <tqpainter.h>
+#include <tqpixmap.h>
+#include <tqlabel.h>
+#include <tqcombobox.h>
+#include <tqbuttongroup.h>
+#include <tqpushbutton.h>
+#include <tqscrollbar.h>
+#include <tqtooltip.h>
+
+#include <kdebug.h>
+
+#include "kis_channelinfo.h"
+#include "kis_histogram_view.h"
+#include "kis_histogram_widget.h"
+#include "kis_histogram.h"
+#include "kis_global.h"
+#include "kis_types.h"
+#include "kis_layer.h"
+#include "kis_paint_device.h"
+#include "kis_colorspace.h"
+
+
+KisHistogramWidget::KisHistogramWidget(TQWidget *tqparent, const char *name)
+ : super(tqparent, name)
+{
+ m_from = 0.0;
+ m_width = 0.0;
+}
+
+KisHistogramWidget::~KisHistogramWidget()
+{
+}
+
+void KisHistogramWidget::setPaintDevice(KisPaintDeviceSP dev)
+{
+ grpType->disconnect(this);
+ cmbChannel->disconnect(this);
+
+ m_histogramView->setPaintDevice(dev);
+ setActiveChannel(0); // So we have the colored one if there are colors
+
+ // The channels
+ cmbChannel->clear();
+ cmbChannel->insertStringList(m_histogramView->channelStrings());
+ cmbChannel->setCurrentItem(0);
+
+ // View display
+ currentView->setMinValue(0);
+ currentView->setMaxValue(100);
+
+ updateEnabled();
+
+ m_from = m_histogramView->currentProducer()->viewFrom();
+ m_width = m_histogramView->currentProducer()->viewWidth();
+
+ connect(grpType, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotTypeSwitched(int)));
+ connect(cmbChannel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setActiveChannel(int)));
+ connect(zoomIn, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomIn()));
+ connect(zoomOut, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomOut()));
+ connect(currentView, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slide(int)));
+}
+
+void KisHistogramWidget::setActiveChannel(int channel)
+{
+ m_histogramView->setActiveChannel(channel);
+ updateEnabled();
+}
+
+void KisHistogramWidget::slotTypeSwitched(int id)
+{
+ if (id == LINEAR)
+ m_histogramView->setHistogramType(LINEAR);
+ else if (id == LOGARITHMIC)
+ m_histogramView->setHistogramType(LOGARITHMIC);
+}
+
+void KisHistogramWidget::setView(double from, double size)
+{
+ m_from = from;
+ m_width = size;
+ if (m_from + m_width > 1.0)
+ m_from = 1.0 - m_width;
+ m_histogramView->setView(m_from, m_width);
+ updateEnabled();
+}
+
+void KisHistogramWidget::slotZoomIn() {
+ if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) {
+ setView(m_from, m_width / 2);
+ }
+}
+
+void KisHistogramWidget::slotZoomOut() {
+ if (m_width * 2 <= 1.0) {
+ setView(m_from, m_width * 2);
+ }
+}
+
+void KisHistogramWidget::slide(int val) {
+ // Beware: at the END (e.g. 100), we want to still view m_width:
+ setView((static_cast<double>(val) / 100.0) * (1.0 - m_width), m_width);
+}
+
+void KisHistogramWidget::updateEnabled() {
+ if (m_histogramView->currentProducer()->maximalZoom() < 1.0) {
+ if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) {
+ zoomIn->setEnabled(true);
+ } else {
+ zoomIn->setEnabled(false);
+ }
+ if (m_width * 2 <= 1.0) {
+ zoomOut->setEnabled(true);
+ } else {
+ zoomOut->setEnabled(false);
+ }
+ if (m_width < 1.0)
+ currentView->setEnabled(true);
+ else
+ currentView->setEnabled(false);
+ } else {
+ zoomIn->setEnabled(false);
+ zoomOut->setEnabled(false);
+ currentView->setEnabled(false);
+ }
+}
+
+#include "kis_histogram_widget.moc"
+