Checkbox class added to simplify event handling. (issue #3739)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
set (BASESOURCEFILES
|
||||
editwindow.cc batchtoolpanelcoord.cc paramsedited.cc cropwindow.cc previewhandler.cc previewwindow.cc navigator.cc indclippedpanel.cc previewmodepanel.cc filterpanel.cc
|
||||
exportpanel.cc cursormanager.cc rtwindow.cc renamedlg.cc recentbrowser.cc placesbrowser.cc filepanel.cc editorpanel.cc batchqueuepanel.cc
|
||||
exportpanel.cc cursormanager.cc rtwindow.cc renamedlg.cc recentbrowser.cc placesbrowser.cc filepanel.cc editorpanel.cc batchqueuepanel.cc checkbox.cc
|
||||
ilabel.cc thumbbrowserbase.cc adjuster.cc filebrowserentry.cc filebrowser.cc filethumbnailbuttonset.cc
|
||||
cachemanager.cc cacheimagedata.cc shcselector.cc perspective.cc thresholdselector.cc thresholdadjuster.cc
|
||||
clipboard.cc thumbimageupdater.cc bqentryupdater.cc lensgeom.cc coloredbar.cc edit.cc coordinateadjuster.cc
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -21,11 +21,12 @@
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "adjuster.h"
|
||||
#include "checkbox.h"
|
||||
#include "guiutils.h"
|
||||
#include "toolpanel.h"
|
||||
|
||||
|
||||
class BayerProcess : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel
|
||||
class BayerProcess : public ToolParamBlock, public AdjusterListener, public CheckBoxListener, public FoldableToolPanel
|
||||
{
|
||||
|
||||
protected:
|
||||
@@ -36,21 +37,21 @@ protected:
|
||||
Adjuster* ccSteps;
|
||||
Gtk::VBox *dcbOptions;
|
||||
Adjuster* dcbIterations;
|
||||
MyCheckButton* dcbEnhance;
|
||||
CheckBox* dcbEnhance;
|
||||
Gtk::VBox *lmmseOptions;
|
||||
Adjuster* lmmseIterations;
|
||||
Gtk::VBox *pixelShiftFrame;
|
||||
Gtk::VBox *pixelShiftOptions;
|
||||
MyComboBoxText* pixelShiftMotionMethod;
|
||||
MyCheckButton* pixelShiftShowMotion;
|
||||
MyCheckButton* pixelShiftShowMotionMaskOnly;
|
||||
MyCheckButton* pixelShiftNonGreenCross;
|
||||
MyCheckButton* pixelShiftGreen;
|
||||
MyCheckButton* pixelShiftBlur;
|
||||
MyCheckButton* pixelShiftHoleFill;
|
||||
MyCheckButton* pixelShiftMedian;
|
||||
MyCheckButton* pixelShiftLmmse;
|
||||
MyCheckButton* pixelShiftEqualBright;
|
||||
CheckBox* pixelShiftShowMotion;
|
||||
CheckBox* pixelShiftShowMotionMaskOnly;
|
||||
CheckBox* pixelShiftNonGreenCross;
|
||||
CheckBox* pixelShiftGreen;
|
||||
CheckBox* pixelShiftBlur;
|
||||
CheckBox* pixelShiftHoleFill;
|
||||
CheckBox* pixelShiftMedian;
|
||||
CheckBox* pixelShiftLmmse;
|
||||
CheckBox* pixelShiftEqualBright;
|
||||
Adjuster* pixelShiftSmooth;
|
||||
Adjuster* pixelShiftEperIso;
|
||||
Adjuster* pixelShiftSigma;
|
||||
@@ -58,13 +59,13 @@ protected:
|
||||
Adjuster* pixelShiftSum;
|
||||
Adjuster* pixelShiftMotion;
|
||||
MyComboBoxText* pixelShiftMotionCorrection;
|
||||
MyCheckButton* pixelShiftAutomatic;
|
||||
MyCheckButton* pixelShiftNonGreenHorizontal;
|
||||
MyCheckButton* pixelShiftNonGreenVertical;
|
||||
MyCheckButton* pixelShiftNonGreenCross2;
|
||||
MyCheckButton* pixelShiftNonGreenAmaze;
|
||||
MyCheckButton* pixelShiftExp0;
|
||||
MyCheckButton* pixelShiftMedian3;
|
||||
CheckBox* pixelShiftAutomatic;
|
||||
CheckBox* pixelShiftNonGreenHorizontal;
|
||||
CheckBox* pixelShiftNonGreenVertical;
|
||||
CheckBox* pixelShiftNonGreenCross2;
|
||||
CheckBox* pixelShiftNonGreenAmaze;
|
||||
CheckBox* pixelShiftExp0;
|
||||
CheckBox* pixelShiftMedian3;
|
||||
Adjuster* pixelShiftStddevFactorGreen;
|
||||
Adjuster* pixelShiftStddevFactorRed;
|
||||
Adjuster* pixelShiftStddevFactorBlue;
|
||||
@@ -84,27 +85,11 @@ public:
|
||||
|
||||
void methodChanged ();
|
||||
void imageNumberChanged ();
|
||||
void adjusterChanged (Adjuster* a, double newval);
|
||||
void dcbEnhanceChanged();
|
||||
void pixelShiftShowMotionChanged();
|
||||
void pixelShiftShowMotionMaskOnlyChanged();
|
||||
void pixelShiftHoleFillChanged();
|
||||
void pixelShiftMedianChanged();
|
||||
void pixelShiftMedian3Changed();
|
||||
void pixelShiftGreenChanged();
|
||||
void pixelShiftBlurChanged();
|
||||
void pixelShiftLmmseChanged();
|
||||
void pixelShiftEqualBrightChanged();
|
||||
void pixelShiftNonGreenCrossChanged();
|
||||
void adjusterChanged (Adjuster* a, double newval);
|
||||
void checkBoxToggled (CheckBox* c, CheckValue newval);
|
||||
void pixelShiftMotionMethodChanged();
|
||||
#ifdef PIXELSHIFTDEV
|
||||
void psMotionCorrectionChanged ();
|
||||
void pixelShiftAutomaticChanged();
|
||||
void pixelShiftNonGreenHorizontalChanged();
|
||||
void pixelShiftNonGreenVerticalChanged();
|
||||
void pixelShiftExp0Changed();
|
||||
void pixelShiftNonGreenCross2Changed();
|
||||
void pixelShiftNonGreenAmazeChanged();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
162
rtgui/checkbox.cc
Normal file
162
rtgui/checkbox.cc
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RawTherapee 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 RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
#include "multilangmgr.h"
|
||||
#include "checkbox.h"
|
||||
#include "guiutils.h"
|
||||
|
||||
CheckBox::CheckBox (Glib::ustring label, bool const& multiImageVal)
|
||||
: Gtk::CheckButton (label)
|
||||
, listener (nullptr)
|
||||
, lastActive (false)
|
||||
, inBatchMode (false)
|
||||
, multiImage (multiImageVal)
|
||||
{
|
||||
conn = signal_toggled().connect( sigc::mem_fun(*this, &CheckBox::buttonToggled) );
|
||||
}
|
||||
|
||||
void CheckBox::buttonToggled ()
|
||||
{
|
||||
|
||||
CheckValue newValue;
|
||||
|
||||
if (multiImage) {
|
||||
if (get_inconsistent()) {
|
||||
set_inconsistent (false);
|
||||
ConnectionBlocker bloker (conn);
|
||||
set_active (false);
|
||||
newValue = CheckValue::off;
|
||||
} else if (getLastActive()) {
|
||||
set_inconsistent (true);
|
||||
newValue = CheckValue::unchanged;
|
||||
}
|
||||
} else {
|
||||
newValue = get_active () ? CheckValue::on : CheckValue::off;
|
||||
}
|
||||
setLastActive();
|
||||
|
||||
if (listener) {
|
||||
listener->checkBoxToggled(this, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckBox::setLastActive()
|
||||
{
|
||||
lastActive = get_active();
|
||||
}
|
||||
|
||||
// return the actual bool value, ignoring the inconsistent state
|
||||
bool CheckBox::getLastActive ()
|
||||
{
|
||||
return lastActive;
|
||||
}
|
||||
|
||||
void CheckBox::setValue (CheckValue newValue)
|
||||
{
|
||||
|
||||
ConnectionBlocker blocker (conn);
|
||||
switch (newValue) {
|
||||
case CheckValue::on:
|
||||
set_inconsistent (false);
|
||||
set_active(true);
|
||||
lastActive = true;
|
||||
break;
|
||||
case CheckValue::off:
|
||||
set_inconsistent (false);
|
||||
set_active(true);
|
||||
lastActive = false;
|
||||
break;
|
||||
case CheckValue::unchanged:
|
||||
set_inconsistent (true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CheckBox::setValue (bool active)
|
||||
{
|
||||
|
||||
ConnectionBlocker blocker (conn);
|
||||
if (active) {
|
||||
set_inconsistent (false);
|
||||
set_active(true);
|
||||
lastActive = true;
|
||||
} else {
|
||||
set_inconsistent (false);
|
||||
set_active(true);
|
||||
lastActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
CheckValue CheckBox::getValue ()
|
||||
{
|
||||
return (get_inconsistent() ? CheckValue::unchanged : get_active() ? CheckValue::on : CheckValue::off);
|
||||
}
|
||||
|
||||
Glib::ustring CheckBox::getValueAsStr ()
|
||||
{
|
||||
if (get_inconsistent()) {
|
||||
return M("GENERAL_UNCHANGED");
|
||||
} else if (get_active ()) {
|
||||
return M("GENERAL_ENABLED");
|
||||
} else {
|
||||
return M("GENERAL_DISABLED");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void CheckBox::set_sensitive (bool isSensitive)
|
||||
{
|
||||
Gtk::CheckButton::set_sensitive(isSensitive);
|
||||
}
|
||||
|
||||
void CheckBox::set_tooltip_text (const Glib::ustring& tooltip)
|
||||
{
|
||||
Gtk::CheckButton::set_tooltip_text (tooltip);
|
||||
}
|
||||
|
||||
void CheckBox::set_tooltip_markup (const Glib::ustring& tooltip)
|
||||
{
|
||||
Gtk::CheckButton::set_tooltip_markup (tooltip);
|
||||
}
|
||||
*/
|
||||
|
||||
void CheckBox::setEdited (bool edited)
|
||||
{
|
||||
|
||||
ConnectionBlocker blocker (conn);
|
||||
set_inconsistent (!edited);
|
||||
if (edited) {
|
||||
set_active (lastActive);
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckBox::getEdited ()
|
||||
{
|
||||
|
||||
return !get_inconsistent ();
|
||||
}
|
||||
|
||||
void CheckBox::setCheckBoxListener (CheckBoxListener* cblistener)
|
||||
{
|
||||
listener = cblistener;
|
||||
}
|
78
rtgui/checkbox.h
Normal file
78
rtgui/checkbox.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RawTherapee 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 RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef _CHECKBOX_H_
|
||||
#define _CHECKBOX_H_
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "editedstate.h"
|
||||
#include "guiutils.h"
|
||||
|
||||
class CheckBox;
|
||||
|
||||
enum class CheckValue {
|
||||
on,
|
||||
off,
|
||||
unchanged
|
||||
};
|
||||
|
||||
class CheckBoxListener
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~CheckBoxListener() {};
|
||||
virtual void checkBoxToggled (CheckBox* c, CheckValue newval) {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief subclass of Gtk::CheckButton for convenience
|
||||
*/
|
||||
class CheckBox : public Gtk::CheckButton // Should ideally be private, but in this case build fail on the instantiation
|
||||
{
|
||||
|
||||
CheckBoxListener *listener;
|
||||
bool lastActive;
|
||||
bool inBatchMode;
|
||||
bool const& multiImage;
|
||||
sigc::connection conn;
|
||||
void buttonToggled ();
|
||||
void setLastActive();
|
||||
|
||||
public:
|
||||
//using CheckButton::CheckButton;
|
||||
explicit CheckBox (Glib::ustring label, bool const& multiImageVal);
|
||||
bool getLastActive();
|
||||
void setValue (CheckValue newValue);
|
||||
void setValue (bool active);
|
||||
CheckValue getValue ();
|
||||
void setEdited (bool edited);
|
||||
bool getEdited ();
|
||||
Glib::ustring getValueAsStr ();
|
||||
|
||||
void setCheckBoxListener (CheckBoxListener* cblistener);
|
||||
|
||||
/* Used if the Gtk::CheckButton parent class can be private
|
||||
*
|
||||
void set_sensitive (bool isSensitive = true);
|
||||
void set_tooltip_text (const Glib::ustring& tooltip);
|
||||
void set_tooltip_markup (const Glib::ustring& tooltip);
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
@@ -290,24 +290,6 @@ public:
|
||||
MyScrolledWindow();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief subclass of Gtk::CheckButton in order to handle the last active state
|
||||
*/
|
||||
class MyCheckButton : public Gtk::CheckButton
|
||||
{
|
||||
|
||||
bool lastActive = false;
|
||||
sigc::connection myConnection;
|
||||
public:
|
||||
using CheckButton::CheckButton;
|
||||
void setLastActive() {lastActive = get_active();};
|
||||
void setLastActive(bool active) {lastActive = active;};
|
||||
bool getLastActive() {return lastActive;};
|
||||
void connect(const sigc::connection &connection) {myConnection = connection;};
|
||||
void block(bool blocked) {myConnection.block(blocked);};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief subclass of Gtk::ComboBox in order to handle the scrollwheel
|
||||
*/
|
||||
@@ -341,8 +323,8 @@ public:
|
||||
MyComboBoxText (bool has_entry = false);
|
||||
|
||||
void setPreferredWidth (int minimum_width, int natural_width);
|
||||
void connect(const sigc::connection &connection) {myConnection = connection;};
|
||||
void block(bool blocked) {myConnection.block(blocked);};
|
||||
void connect(const sigc::connection &connection) { myConnection = connection; }
|
||||
void block(bool blocked) { myConnection.block(blocked); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user