"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "rtgui/adjuster.cc" between
rawtherapee-5.6.tar.xz and rawtherapee-5.7.tar.xz

About: RawTherapee is a powerful cross-platform raw image processing program.

adjuster.cc  (rawtherapee-5.6.tar.xz):adjuster.cc  (rawtherapee-5.7.tar.xz)
skipping to change at line 17 skipping to change at line 17
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* RawTherapee is distributed in the hope that it will be useful, * RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. * along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include "adjuster.h" #include "adjuster.h"
#include <sigc++/slot.h> #include <sigc++/slot.h>
#include <cmath> #include <cmath>
#include "multilangmgr.h" #include "multilangmgr.h"
#include "../rtengine/rtengine.h" #include "../rtengine/rtengine.h"
#include "options.h" #include "options.h"
#include "guiutils.h" #include "guiutils.h"
#include "rtimage.h" #include "rtimage.h"
#define MIN_RESET_BUTTON_HEIGHT 17 namespace {
static double one2one(double val) constexpr int MIN_RESET_BUTTON_HEIGHT = 17;
double one2one(double val)
{ {
return val; return val;
} }
}
Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep Adjuster::Adjuster (
, double vdefault, Gtk::Image *imgIcon1, Gtk::Image *imgIcon2, double2double_fun Glib::ustring vlabel,
slider2value_, double2double_fun value2slider_) double vmin,
{ double vmax,
double vstep,
double vdefault,
Gtk::Image *imgIcon1,
Gtk::Image *imgIcon2,
double2double_fun slider2value,
double2double_fun value2slider)
:
adjustmentName(std::move(vlabel)),
grid(nullptr),
label(nullptr),
imageIcon1(imgIcon1),
automatic(nullptr),
adjusterListener(nullptr),
editedCheckBox(nullptr),
afterReset(false),
blocked(false),
addMode(false),
eventPending(false),
vMin(vmin),
vMax(vmax),
vStep(vstep),
logBase(0),
logPivot(0),
logAnchorMiddle(false),
value2slider(value2slider ? value2slider : &one2one),
slider2value(slider2value ? slider2value : &one2one),
delay(options.adjusterMinDelay)
{
set_hexpand(true); set_hexpand(true);
set_vexpand(false); set_vexpand(false);
label = nullptr;
adjusterListener = nullptr;
afterReset = false;
blocked = false;
automatic = nullptr;
eventPending = false;
grid = NULL;
imageIcon1 = imgIcon1;
logBase = 0;
logPivot = 0;
logAnchorMiddle = false;
if (imageIcon1) { if (imageIcon1) {
setExpandAlignProperties(imageIcon1, false, false, Gtk::ALIGN_CENTER, Gt k::ALIGN_CENTER); setExpandAlignProperties(imageIcon1, false, false, Gtk::ALIGN_CENTER, Gt k::ALIGN_CENTER);
} }
imageIcon2 = imgIcon2; if (imgIcon2) {
setExpandAlignProperties(imgIcon2, false, false, Gtk::ALIGN_CENTER, Gtk:
if (imageIcon2) { :ALIGN_CENTER);
setExpandAlignProperties(imageIcon2, false, false, Gtk::ALIGN_CENTER, Gt
k::ALIGN_CENTER);
} }
slider2value = slider2value_ ? slider2value_ : one2one;
value2slider = value2slider_ ? value2slider_ : one2one;
vMin = vmin;
vMax = vmax;
vStep = vstep;
addMode = false;
delay = options.adjusterMinDelay;
set_column_spacing(0); set_column_spacing(0);
set_column_homogeneous(false); set_column_homogeneous(false);
set_row_spacing(0); set_row_spacing(0);
set_row_homogeneous(false); set_row_homogeneous(false);
editedCheckBox = nullptr; if (!adjustmentName.empty()) {
label = Gtk::manage(new Gtk::Label(adjustmentName));
if (!vlabel.empty()) {
adjustmentName = vlabel;
label = Gtk::manage (new Gtk::Label (adjustmentName));
setExpandAlignProperties(label, true, false, Gtk::ALIGN_START, Gtk::ALIG N_BASELINE); setExpandAlignProperties(label, true, false, Gtk::ALIGN_START, Gtk::ALIG N_BASELINE);
} }
reset = Gtk::manage (new Gtk::Button ()); reset = Gtk::manage(new Gtk::Button());
reset->add (*Gtk::manage (new RTImage ("undo-small.png", "redo-small.png")))
; reset->add(*Gtk::manage(new RTImage("undo-small.png", "redo-small.png")));
setExpandAlignProperties(reset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_ CENTER); setExpandAlignProperties(reset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_ CENTER);
reset->set_relief (Gtk::RELIEF_NONE); reset->set_relief(Gtk::RELIEF_NONE);
reset->set_tooltip_markup (M("ADJUSTER_RESET_TO_DEFAULT")); reset->set_tooltip_markup(M("ADJUSTER_RESET_TO_DEFAULT"));
reset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT); reset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
reset->set_can_focus(false); reset->set_can_focus(false);
spin = Gtk::manage (new MySpinButton ()); spin = Gtk::manage(new MySpinButton());
setExpandAlignProperties(spin, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_C ENTER); setExpandAlignProperties(spin, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_C ENTER);
spin->set_input_purpose(Gtk::INPUT_PURPOSE_DIGITS); spin->set_input_purpose(Gtk::INPUT_PURPOSE_DIGITS);
reset->set_size_request (-1, spin->get_height() > MIN_RESET_BUTTON_HEIGHT ? reset->set_size_request(-1, spin->get_height() > MIN_RESET_BUTTON_HEIGHT ? s
spin->get_height() : MIN_RESET_BUTTON_HEIGHT); pin->get_height() : MIN_RESET_BUTTON_HEIGHT);
slider = Gtk::manage(new MyHScale());
slider = Gtk::manage (new MyHScale ());
setExpandAlignProperties(slider, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CE NTER); setExpandAlignProperties(slider, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CE NTER);
slider->set_draw_value (false); slider->set_draw_value(false);
//slider->set_has_origin(false); // ------------------ This will remove the colored part on the left of the slider's knob //slider->set_has_origin(false); // ------------------ This will remove the colored part on the left of the slider's knob
if (vlabel.empty()) { setLimits(vmin, vmax, vstep, vdefault);
if (adjustmentName.empty()) {
// No label, everything goes in a single row // No label, everything goes in a single row
attach_next_to(*slider, Gtk::POS_LEFT, 1, 1); attach_next_to(*slider, Gtk::POS_LEFT, 1, 1);
if (imageIcon1) { if (imageIcon1) {
attach_next_to(*imageIcon1, *slider, Gtk::POS_LEFT, 1, 1); attach_next_to(*imageIcon1, *slider, Gtk::POS_LEFT, 1, 1);
} }
if (imageIcon2) { if (imgIcon2) {
attach_next_to(*imageIcon2, *slider, Gtk::POS_RIGHT, 1, 1); attach_next_to(*imgIcon2, *slider, Gtk::POS_RIGHT, 1, 1);
attach_next_to(*spin, *imageIcon2, Gtk::POS_RIGHT, 1, 1); attach_next_to(*spin, *imgIcon2, Gtk::POS_RIGHT, 1, 1);
} else { } else {
attach_next_to(*spin, *slider, Gtk::POS_RIGHT, 1, 1); attach_next_to(*spin, *slider, Gtk::POS_RIGHT, 1, 1);
} }
attach_next_to(*reset, *spin, Gtk::POS_RIGHT, 1, 1); attach_next_to(*reset, *spin, Gtk::POS_RIGHT, 1, 1);
} else { } else {
// A label is provided, spreading the widgets in 2 rows // A label is provided, spreading the widgets in 2 rows
attach_next_to(*label, Gtk::POS_LEFT, 1, 1); attach_next_to(*label, Gtk::POS_LEFT, 1, 1);
attach_next_to(*spin, Gtk::POS_RIGHT, 1, 1); attach_next_to(*spin, Gtk::POS_RIGHT, 1, 1);
// A second HBox is necessary // A second HBox is necessary
grid = Gtk::manage(new Gtk::Grid()); grid = Gtk::manage(new Gtk::Grid());
grid->attach_next_to(*slider, Gtk::POS_LEFT, 1, 1); grid->attach_next_to(*slider, Gtk::POS_LEFT, 1, 1);
if (imageIcon1) { if (imageIcon1) {
grid->attach_next_to(*imageIcon1, *slider, Gtk::POS_LEFT, 1, 1); grid->attach_next_to(*imageIcon1, *slider, Gtk::POS_LEFT, 1, 1);
} }
if (imageIcon2) { if (imgIcon2) {
grid->attach_next_to(*imageIcon2, Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*imgIcon2, Gtk::POS_RIGHT, 1, 1);
grid->attach_next_to(*reset, *imageIcon2, Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*reset, *imgIcon2, Gtk::POS_RIGHT, 1, 1);
} else { } else {
grid->attach_next_to(*reset, *slider, Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*reset, *slider, Gtk::POS_RIGHT, 1, 1);
} }
attach_next_to(*grid, *label, Gtk::POS_BOTTOM, 2, 1); attach_next_to(*grid, *label, Gtk::POS_BOTTOM, 2, 1);
} }
setLimits (vmin, vmax, vstep, vdefault); defaultVal = ctorDefaultVal = shapeValue(vdefault);
defaultVal = shapeValue (vdefault);
ctorDefaultVal = shapeValue (vdefault);
editedState = defEditedState = Irrelevant; editedState = defEditedState = Irrelevant;
autoState = Irrelevant;
sliderChange = slider->signal_value_changed().connect( sigc::mem_fun(*this, &Adjuster::sliderChanged) ); sliderChange = slider->signal_value_changed().connect( sigc::mem_fun(*this, &Adjuster::sliderChanged) );
spinChange = spin->signal_value_changed().connect ( sigc::mem_fun(*this, &Ad juster::spinChanged), true); spinChange = spin->signal_value_changed().connect( sigc::mem_fun(*this, &Adj uster::spinChanged), true);
reset->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &A djuster::resetPressed) ); reset->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &A djuster::resetPressed) );
show_all (); show_all();
} }
Adjuster::~Adjuster () Adjuster::~Adjuster ()
{ {
sliderChange.block (true); sliderChange.block(true);
spinChange.block (true); spinChange.block(true);
delayConnection.block (true); delayConnection.block(true);
adjusterListener = nullptr; adjusterListener = nullptr;
if (automatic) {
delete automatic;
}
} }
void Adjuster::addAutoButton (Glib::ustring tooltip) void Adjuster::addAutoButton (const Glib::ustring &tooltip)
{ {
if (!automatic) { if (!automatic) {
automatic = new Gtk::CheckButton (); automatic = Gtk::manage(new Gtk::CheckButton());
//automatic->add (*Gtk::manage (new RTImage ("gears.png"))); //automatic->add (*Gtk::manage (new RTImage ("gears.png")));
automatic->set_tooltip_markup(tooltip.length() ? Glib::ustring::compose( "<b>%1</b>\n\n%2", M("GENERAL_AUTO"), tooltip) : M("GENERAL_AUTO")); automatic->set_tooltip_markup(tooltip.length() ? Glib::ustring::compose( "<b>%1</b>\n\n%2", M("GENERAL_AUTO"), tooltip) : M("GENERAL_AUTO"));
setExpandAlignProperties(automatic, false, false, Gtk::ALIGN_CENTER, Gtk ::ALIGN_CENTER); setExpandAlignProperties(automatic, false, false, Gtk::ALIGN_CENTER, Gtk ::ALIGN_CENTER);
autoChange = automatic->signal_toggled().connect( sigc::mem_fun(*this, & Adjuster::autoToggled) ); autoChange = automatic->signal_toggled().connect( sigc::mem_fun(*this, & Adjuster::autoToggled) );
if (grid) { if (grid) {
// Hombre, adding the checbox next to the reset button because addin g it next to the spin button (as before) // Hombre, adding the checbox next to the reset button because addin g it next to the spin button (as before)
// would diminish the available size for the label and would require a much heavier reorganization of the grid ! // would diminish the available size for the label and would require a much heavier reorganization of the grid !
grid->attach_next_to(*automatic, *reset, Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*automatic, *reset, Gtk::POS_RIGHT, 1, 1);
} else { } else {
attach_next_to(*automatic, *reset, Gtk::POS_RIGHT, 1, 1); attach_next_to(*automatic, *reset, Gtk::POS_RIGHT, 1, 1);
} }
} }
} }
void Adjuster::delAutoButton ()
{
if (automatic) {
removeIfThere(grid, automatic);
delete automatic;
automatic = nullptr;
}
}
void Adjuster::throwOnButtonRelease(bool throwOnBRelease) void Adjuster::throwOnButtonRelease(bool throwOnBRelease)
{ {
if (throwOnBRelease) { if (throwOnBRelease) {
if (!buttonReleaseSlider.connected()) { if (!buttonReleaseSlider.connected()) {
buttonReleaseSlider = slider->signal_button_release_event().connect_ notify( sigc::mem_fun(*this, &Adjuster::sliderReleased) ); buttonReleaseSlider = slider->signal_button_release_event().connect_ notify( sigc::mem_fun(*this, &Adjuster::sliderReleased) );
} }
if (!buttonReleaseSpin.connected()) { if (!buttonReleaseSpin.connected()) {
buttonReleaseSpin = spin->signal_button_release_event().connect_noti fy( sigc::mem_fun(*this, &Adjuster::spinReleased) ); // Use the same callback hook buttonReleaseSpin = spin->signal_button_release_event().connect_noti fy( sigc::mem_fun(*this, &Adjuster::spinReleased) ); // Use the same callback hook
skipping to change at line 224 skipping to change at line 220
buttonReleaseSpin.disconnect(); buttonReleaseSpin.disconnect();
} }
} }
eventPending = false; eventPending = false;
} }
void Adjuster::setDefault (double def) void Adjuster::setDefault (double def)
{ {
defaultVal = shapeValue (def); defaultVal = shapeValue(def);
} }
void Adjuster::setDefaultEditedState (EditedState eState) void Adjuster::setDefaultEditedState (EditedState eState)
{ {
defEditedState = eState; defEditedState = eState;
} }
void Adjuster::autoToggled () void Adjuster::autoToggled ()
{ {
skipping to change at line 261 skipping to change at line 257
if (adjusterListener != nullptr && !blocked) { if (adjusterListener != nullptr && !blocked) {
adjusterListener->adjusterAutoToggled(this, automatic->get_active()); adjusterListener->adjusterAutoToggled(this, automatic->get_active());
} }
} }
void Adjuster::sliderReleased (GdkEventButton* event) void Adjuster::sliderReleased (GdkEventButton* event)
{ {
if ((event != nullptr) && (event->button == 1)) { if ((event != nullptr) && (event->button == 1)) {
if (delayConnection.connected()) { if (delayConnection.connected()) {
delayConnection.disconnect (); delayConnection.disconnect();
} }
notifyListener(); notifyListener();
} }
} }
void Adjuster::spinReleased (GdkEventButton* event) void Adjuster::spinReleased (GdkEventButton* event)
{ {
if ((event != nullptr) && delay == 0) { if ((event != nullptr) && delay == 0) {
if (delayConnection.connected()) { if (delayConnection.connected()) {
delayConnection.disconnect (); delayConnection.disconnect();
} }
notifyListener(); notifyListener();
} }
} }
void Adjuster::resetValue (bool toInitial) void Adjuster::resetValue (bool toInitial)
{ {
if (editedState != Irrelevant) { if (editedState != Irrelevant) {
editedState = defEditedState; editedState = defEditedState;
if (editedCheckBox) { if (editedCheckBox) {
editedChange.block (true); editedChange.block(true);
editedCheckBox->set_active (defEditedState == Edited); editedCheckBox->set_active(defEditedState == Edited);
editedChange.block (false); editedChange.block(false);
} }
refreshLabelStyle ();
} }
afterReset = true; afterReset = true;
if (toInitial) { if (toInitial) {
// resetting to the initial editing value, when the image has been loade d // resetting to the initial editing value, when the image has been loade d
setSliderValue(addMode ? defaultVal : value2slider(defaultVal)); setSliderValue(addMode ? defaultVal : value2slider(defaultVal));
} else { } else {
// resetting to the slider default value // resetting to the slider default value
if (addMode) { if (addMode) {
skipping to change at line 320 skipping to change at line 315
void Adjuster::resetPressed (GdkEventButton* event) void Adjuster::resetPressed (GdkEventButton* event)
{ {
if ((event != nullptr) && (event->state & GDK_CONTROL_MASK) && (event->butto n == 1)) { if ((event != nullptr) && (event->state & GDK_CONTROL_MASK) && (event->butto n == 1)) {
resetValue(true); resetValue(true);
} else { } else {
resetValue(false); resetValue(false);
} }
} }
double Adjuster::shapeValue (double a) double Adjuster::shapeValue (double a) const
{ {
double val = round(a * pow(double(10), digits)) / pow(double(10), digits); const double pow10 = std::pow(10.0, digits);
const double val = std::round(a * pow10) / pow10;
return val == -0.0 ? 0.0 : val; return val == -0.0 ? 0.0 : val;
} }
void Adjuster::setLimits (double vmin, double vmax, double vstep, double vdefaul t) void Adjuster::setLimits (double vmin, double vmax, double vstep, double vdefaul t)
{ {
sliderChange.block(true);
spinChange.block(true);
sliderChange.block (true); double pow10 = vstep;
spinChange.block (true); for (digits = 0; std::fabs(pow10 - floor(pow10)) > 0.000000000001; digits++,
pow10 *= 10.0);
for (digits = 0; fabs(vstep * pow(double(10), digits) - floor(vstep * pow(do const double shapeVal = shapeValue(vdefault);
uble(10), digits))) > 0.000000000001; digits++); spin->set_digits(digits);
spin->set_increments(vstep, 2.0 * vstep);
spin->set_digits (digits); spin->set_range(vmin, vmax);
spin->set_increments (vstep, 2.0 * vstep);
spin->set_range (vmin, vmax);
spin->updateSize(); spin->updateSize();
spin->set_value (shapeValue(vdefault)); spin->set_value(shapeVal);
slider->set_digits (digits);
slider->set_increments (vstep, 2.0 * vstep); slider->set_digits(digits);
slider->set_range (addMode ? vmin : value2slider(vmin), addMode ? vmax : val slider->set_increments(vstep, 2.0 * vstep);
ue2slider(vmax)); slider->set_range(addMode ? vmin : value2slider(vmin), addMode ? vmax : valu
setSliderValue(addMode ? shapeValue(vdefault) : value2slider(shapeValue(vdef e2slider(vmax));
ault))); setSliderValue(addMode ? shapeVal : value2slider(shapeVal));
//defaultVal = shapeValue (vdefault);
sliderChange.block (false); sliderChange.block(false);
spinChange.block (false); spinChange.block(false);
} }
void Adjuster::setAddMode(bool addM) void Adjuster::setAddMode(bool addM)
{ {
if (addM != addMode) { if (addM != addMode) {
// Switching the Adjuster to the new mode // Switching the Adjuster to the new mode
addMode = addM; addMode = addM;
if (addM) { if (addM) {
// Switching to the relative mode // Switching to the relative mode
skipping to change at line 372 skipping to change at line 370
setLimits(-range, range, vStep, 0); setLimits(-range, range, vStep, 0);
} else { } else {
// Switching to the absolute mode // Switching to the absolute mode
setLimits(vMin, vMax, vStep, defaultVal); setLimits(vMin, vMax, vStep, defaultVal);
} }
} }
} }
void Adjuster::spinChanged () void Adjuster::spinChanged ()
{ {
if (delayConnection.connected()) { if (delayConnection.connected()) {
delayConnection.disconnect (); delayConnection.disconnect();
} }
sliderChange.block (true); sliderChange.block(true);
setSliderValue(addMode ? spin->get_value () : value2slider(spin->get_value ( setSliderValue(addMode ? spin->get_value() : value2slider(spin->get_value())
))); );
sliderChange.block (false); sliderChange.block(false);
if (delay == 0) { if (delay == 0) {
if (adjusterListener && !blocked) { if (adjusterListener && !blocked) {
if (!buttonReleaseSlider.connected() || afterReset) { if (!buttonReleaseSlider.connected() || afterReset) {
eventPending = false; eventPending = false;
adjusterListener->adjusterChanged (this, spin->get_value ()); adjusterListener->adjusterChanged(this, spin->get_value());
} else { } else {
eventPending = true; eventPending = true;
} }
} }
} else { } else {
eventPending = true; eventPending = true;
delayConnection = Glib::signal_timeout().connect (sigc::mem_fun(*this, & Adjuster::notifyListener), delay); delayConnection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &A djuster::notifyListener), delay);
} }
if (editedState == UnEdited) { if (editedState == UnEdited) {
editedState = Edited; editedState = Edited;
if (editedCheckBox) { if (editedCheckBox) {
editedChange.block (true); editedChange.block(true);
editedCheckBox->set_active (true); editedCheckBox->set_active(true);
editedChange.block (false); editedChange.block(false);
} }
refreshLabelStyle ();
} }
afterReset = false; afterReset = false;
} }
void Adjuster::sliderChanged () void Adjuster::sliderChanged ()
{ {
if (delayConnection.connected()) { if (delayConnection.connected()) {
delayConnection.disconnect (); delayConnection.disconnect();
} }
spinChange.block (true); spinChange.block(true);
double v = shapeValue(getSliderValue()); const double v = shapeValue(getSliderValue());
spin->set_value (addMode ? v : slider2value(v)); spin->set_value(addMode ? v : slider2value(v));
spinChange.block (false); spinChange.block(false);
if (delay == 0 || afterReset) { if (delay == 0 || afterReset) {
if (adjusterListener && !blocked) { if (adjusterListener && !blocked) {
if (!buttonReleaseSlider.connected() || afterReset) { if (!buttonReleaseSlider.connected() || afterReset) {
eventPending = false; eventPending = false;
adjusterListener->adjusterChanged (this, spin->get_value ()); adjusterListener->adjusterChanged(this, spin->get_value());
} else { } else {
eventPending = true; eventPending = true;
} }
} }
} else { } else {
eventPending = true; eventPending = true;
delayConnection = Glib::signal_timeout().connect (sigc::mem_fun(*this, & Adjuster::notifyListener), delay); delayConnection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &A djuster::notifyListener), delay);
} }
if (!afterReset && editedState == UnEdited) { if (!afterReset && editedState == UnEdited) {
editedState = Edited; editedState = Edited;
if (editedCheckBox) { if (editedCheckBox) {
editedChange.block (true); editedChange.block(true);
editedCheckBox->set_active (true); editedCheckBox->set_active(true);
editedChange.block (false); editedChange.block(false);
} }
refreshLabelStyle ();
} }
afterReset = false; afterReset = false;
} }
void Adjuster::setValue (double a) void Adjuster::setValue (double a)
{ {
spinChange.block(true);
spinChange.block (true); sliderChange.block(true);
sliderChange.block (true); spin->set_value(shapeValue(a));
spin->set_value (shapeValue (a)); setSliderValue(addMode ? shapeValue(a) : value2slider(shapeValue(a)));
setSliderValue(addMode ? shapeValue(a) : value2slider(shapeValue (a))); sliderChange.block(false);
sliderChange.block (false); spinChange.block(false);
spinChange.block (false);
afterReset = false; afterReset = false;
} }
void Adjuster::setAutoValue (bool a) void Adjuster::setAutoValue (bool a)
{ {
if (automatic) { if (automatic) {
bool oldVal = autoChange.block(true); const bool oldVal = autoChange.block(true);
automatic->set_active(a); automatic->set_active(a);
autoChange.block(oldVal); autoChange.block(oldVal);
if (!editedCheckBox) { if (!editedCheckBox) {
// If not used in the BatchEditor panel // If not used in the BatchEditor panel
if (a) { if (a) {
// Disable the slider and spin button // Disable the slider and spin button
spin->set_sensitive(false); spin->set_sensitive(false);
slider->set_sensitive(false); slider->set_sensitive(false);
reset->set_sensitive(false); reset->set_sensitive(false);
skipping to change at line 491 skipping to change at line 483
reset->set_sensitive(true); reset->set_sensitive(true);
} }
} }
} }
} }
bool Adjuster::notifyListener () bool Adjuster::notifyListener ()
{ {
if (eventPending && adjusterListener != nullptr && !blocked) { if (eventPending && adjusterListener != nullptr && !blocked) {
adjusterListener->adjusterChanged (this, spin->get_value ()); adjusterListener->adjusterChanged(this, spin->get_value());
} }
eventPending = false; eventPending = false;
return false; return false;
} }
bool Adjuster::notifyListenerAutoToggled () bool Adjuster::notifyListenerAutoToggled ()
{ {
if (adjusterListener != nullptr && !blocked) { if (adjusterListener != nullptr && !blocked) {
adjusterListener->adjusterAutoToggled(this, automatic->get_active()); adjusterListener->adjusterAutoToggled(this, automatic->get_active());
} }
return false; return false;
} }
void Adjuster::setEnabled (bool enabled) void Adjuster::setEnabled (bool enabled)
{ {
bool autoVal = automatic && !editedCheckBox ? automatic->get_active() : true const bool autoVal = automatic && !editedCheckBox ? automatic->get_active()
; : true;
spin->set_sensitive (enabled && autoVal); spin->set_sensitive(enabled && autoVal);
slider->set_sensitive (enabled && autoVal); slider->set_sensitive(enabled && autoVal);
if (automatic) { if (automatic) {
automatic->set_sensitive (enabled); automatic->set_sensitive(enabled);
} }
} }
void Adjuster::setEditedState (EditedState eState) void Adjuster::setEditedState (EditedState eState)
{ {
if (editedState != eState) { if (editedState != eState) {
if (editedCheckBox) { if (editedCheckBox) {
editedChange.block (true); editedChange.block(true);
editedCheckBox->set_active (eState == Edited); editedCheckBox->set_active(eState == Edited);
editedChange.block (false); editedChange.block(false);
} }
editedState = eState; editedState = eState;
refreshLabelStyle ();
} }
} }
EditedState Adjuster::getEditedState () EditedState Adjuster::getEditedState ()
{ {
if (editedState != Irrelevant && editedCheckBox) { if (editedState != Irrelevant && editedCheckBox) {
editedState = editedCheckBox->get_active () ? Edited : UnEdited; editedState = editedCheckBox->get_active() ? Edited : UnEdited;
} }
return editedState; return editedState;
} }
void Adjuster::showEditedCB () void Adjuster::showEditedCB ()
{ {
if (label) { if (label) {
removeIfThere(this, label, false); removeIfThere(this, label, false);
} }
if (!editedCheckBox) { if (!editedCheckBox) {
editedCheckBox = Gtk::manage(new Gtk::CheckButton (adjustmentName)); editedCheckBox = Gtk::manage(new Gtk::CheckButton(adjustmentName));
editedCheckBox->set_vexpand(false); editedCheckBox->set_vexpand(false);
if (grid) { if (grid) {
editedCheckBox->set_hexpand(true); editedCheckBox->set_hexpand(true);
editedCheckBox->set_halign(Gtk::ALIGN_START); editedCheckBox->set_halign(Gtk::ALIGN_START);
editedCheckBox->set_valign(Gtk::ALIGN_CENTER); editedCheckBox->set_valign(Gtk::ALIGN_CENTER);
attach_next_to(*editedCheckBox, *spin, Gtk::POS_LEFT, 1, 1); attach_next_to(*editedCheckBox, *spin, Gtk::POS_LEFT, 1, 1);
} else { } else {
editedCheckBox->set_hexpand(false); editedCheckBox->set_hexpand(false);
editedCheckBox->set_halign(Gtk::ALIGN_START); editedCheckBox->set_halign(Gtk::ALIGN_START);
skipping to change at line 579 skipping to change at line 570
} else { } else {
attach_next_to(*editedCheckBox, *slider, Gtk::POS_LEFT, 1, 1); attach_next_to(*editedCheckBox, *slider, Gtk::POS_LEFT, 1, 1);
} }
} }
editedChange = editedCheckBox->signal_toggled().connect( sigc::mem_fun(* this, &Adjuster::editedToggled) ); editedChange = editedCheckBox->signal_toggled().connect( sigc::mem_fun(* this, &Adjuster::editedToggled) );
editedCheckBox->show(); editedCheckBox->show();
} }
} }
void Adjuster::refreshLabelStyle ()
{
/* Glib::RefPtr<Gtk::StyleContext> style = label->get_style_context ();
Pango::FontDescription fd = style->get_font ();
fd.set_weight (editedState==Edited ? Pango::WEIGHT_BOLD : Pango::WEIGHT_
NORMAL);
style->set_font (fd);
label->set_style (style);
label->queue_draw ();*/
}
void Adjuster::editedToggled () void Adjuster::editedToggled ()
{ {
if (adjusterListener && !blocked) { if (adjusterListener && !blocked) {
adjusterListener->adjusterChanged (this, spin->get_value ()); adjusterListener->adjusterChanged(this, spin->get_value());
} }
eventPending = false; eventPending = false;
} }
void Adjuster::trimValue (double &val) void Adjuster::trimValue (double &val) const
{ {
val = rtengine::LIM(val, vMin, vMax); val = rtengine::LIM(val, vMin, vMax);
} }
void Adjuster::trimValue (int &val) void Adjuster::trimValue (int &val) const
{ {
val = rtengine::LIM<int>(val, vMin, vMax);
val = rtengine::LIM(val, static_cast<int>(vMin), static_cast<int>(vMax));
} }
void Adjuster::trimValue (float &val) void Adjuster::trimValue (float &val) const
{ {
val = rtengine::LIM<float>(val, vMin, vMax);
val = rtengine::LIM(val, static_cast<float>(vMin), static_cast<float>(vMax))
;
} }
inline double Adjuster::getSliderValue() double Adjuster::getSliderValue() const
{ {
double val = slider->get_value(); double val = slider->get_value();
if (logBase) { if (logBase) {
if (logAnchorMiddle) { if (logAnchorMiddle) {
double mid = (vMax - vMin) / 2; double mid = (vMax - vMin) / 2;
double mmid = vMin + mid; double mmid = vMin + mid;
if (val >= mmid) { if (val >= mmid) {
double range = vMax - mmid; double range = vMax - mmid;
double x = (val - mmid) / range; double x = (val - mmid) / range;
val = logPivot + (pow(logBase, x) - 1.0) / (logBase - 1.0) * (vM ax - logPivot); val = logPivot + (std::pow(logBase, x) - 1.0) / (logBase - 1.0) * (vMax - logPivot);
} else { } else {
double range = mmid - vMin; double range = mmid - vMin;
double x = (mmid - val) / range; double x = (mmid - val) / range;
val = logPivot - (pow(logBase, x) - 1.0) / (logBase - 1.0) * (lo gPivot - vMin); val = logPivot - (std::pow(logBase, x) - 1.0) / (logBase - 1.0) * (logPivot - vMin);
} }
} else { } else {
if (val >= logPivot) { if (val >= logPivot) {
double range = vMax - logPivot; double range = vMax - logPivot;
double x = (val - logPivot) / range; double x = (val - logPivot) / range;
val = logPivot + (pow(logBase, x) - 1.0) / (logBase - 1.0) * ran ge; val = logPivot + (std::pow(logBase, x) - 1.0) / (logBase - 1.0) * range;
} else { } else {
double range = logPivot - vMin; double range = logPivot - vMin;
double x = (logPivot - val) / range; double x = (logPivot - val) / range;
val = logPivot - (pow(logBase, x) - 1.0) / (logBase - 1.0) * ran ge; val = logPivot - (std::pow(logBase, x) - 1.0) / (logBase - 1.0) * range;
} }
} }
} }
return val; return val;
} }
inline void Adjuster::setSliderValue(double val) void Adjuster::setSliderValue(double val)
{ {
if (logBase) { if (logBase) {
if (logAnchorMiddle) { if (logAnchorMiddle) {
double mid = (vMax - vMin) / 2; double mid = (vMax - vMin) / 2;
if (val >= logPivot) { if (val >= logPivot) {
double range = vMax - logPivot; double range = vMax - logPivot;
double x = (val - logPivot) / range; double x = (val - logPivot) / range;
val = (vMin + mid) + log(x * (logBase - 1.0) + 1.0) / log(logBas e) * mid; val = (vMin + mid) + std::log1p(x * (logBase - 1.0)) / std::log( logBase) * mid;
} else { } else {
double range = logPivot - vMin; double range = logPivot - vMin;
double x = (logPivot - val) / range; double x = (logPivot - val) / range;
val = (vMin + mid) - log(x * (logBase - 1.0) + 1.0) / log(logBas e) * mid; val = (vMin + mid) - std::log1p(x * (logBase - 1.0)) / std::log( logBase) * mid;
} }
} else { } else {
if (val >= logPivot) { if (val >= logPivot) {
double range = vMax - logPivot; double range = vMax - logPivot;
double x = (val - logPivot) / range; double x = (val - logPivot) / range;
val = logPivot + log(x * (logBase - 1.0) + 1.0) / log(logBase) * range; val = logPivot + std::log1p(x * (logBase - 1.0)) / std::log(logB ase) * range;
} else { } else {
double range = logPivot - vMin; double range = logPivot - vMin;
double x = (logPivot - val) / range; double x = (logPivot - val) / range;
val = logPivot - log(x * (logBase - 1.0) + 1.0) / log(logBase) * range; val = logPivot - std::log1p(x * (logBase - 1.0)) / std::log(logB ase) * range;
} }
} }
} }
slider->set_value(val); slider->set_value(val);
} }
void Adjuster::setLogScale(double base, double pivot, bool anchorMiddle) void Adjuster::setLogScale(double base, double pivot, bool anchorMiddle)
{ {
spinChange.block (true); spinChange.block(true);
sliderChange.block (true); sliderChange.block(true);
double cur = getSliderValue(); const double cur = getSliderValue();
logBase = base; logBase = base;
logPivot = pivot; logPivot = pivot;
logAnchorMiddle = anchorMiddle; logAnchorMiddle = anchorMiddle;
setSliderValue(cur); setSliderValue(cur);
sliderChange.block (false); sliderChange.block(false);
spinChange.block (false); spinChange.block(false);
}
bool Adjuster::getAutoValue() const
{
return automatic ? automatic->get_active() : false;
}
void Adjuster::setAutoInconsistent(bool i)
{
if (automatic) {
automatic->set_inconsistent(i);
}
}
bool Adjuster::getAutoInconsistent() const
{
return automatic ? automatic->get_inconsistent() : true /* we have to return
something */;
}
void Adjuster::setAdjusterListener (AdjusterListener* alistener)
{
adjusterListener = alistener;
}
double Adjuster::getValue() const
{
return shapeValue(spin->get_value());
}
int Adjuster::getIntValue() const
{
return spin->get_value_as_int();
}
Glib::ustring Adjuster::getTextValue() const
{
if (addMode) {
return Glib::ustring::compose("<i>%1</i>", spin->get_text());
} else {
return spin->get_text();
}
}
void Adjuster::setLabel(const Glib::ustring &lbl)
{
label->set_label(lbl);
}
bool Adjuster::block(bool isBlocked)
{
bool oldValue = blocked;
blocked = isBlocked;
return oldValue;
}
bool Adjuster::getAddMode() const
{
return addMode;
} }
 End of changes. 83 change blocks. 
193 lines changed or deleted 219 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)