rawTherapee/rtgui/rotate.cc
Alberto Griggio 11e7739a55 Added option to use a non-linear response for Adjuster sliders
Some of the RT parameters that are currently associated to Adjusters are very
hard to edit precisely by dragging the sliders, because small changes to the
default produce quite visible results. Prominent examples include black level,
WB tint, raw black and white points, and lens correction parameters
(distortion, CA, vignetting, perspective). The problem is made worse for those
settings in which not only small changes are significant, but also the
associated Adjusters have a very large range (again, think of black point and
WB tint). This is due to the fact that the current Adjusters have a linear
response. This commit adds an option to use a non-linear (specifically
logarithmic) response, which causes the sliders to move "slowly" around a
designated pivot point, and progressively faster the further you move away
from the pivot.

Besides adding the functionality to the Adjuster class, this changeset also
enables this behaviour for the following adjusters:

- exposure compensation
- black point
- lightness/contrast/saturation/chromaticity (both in exposure and in L*a*b*)
- WB tint
- channel mixer
- lens corrections (perspective, distortion, CA)
- rotation
- raw black and white points
- raw CA correction
2018-09-20 14:41:29 +02:00

133 lines
3.5 KiB
C++

/*
* 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 "rotate.h"
#include <iomanip>
#include "guiutils.h"
#include "rtimage.h"
using namespace rtengine;
using namespace rtengine::procparams;
Rotate::Rotate () : FoldableToolPanel(this, "rotate", M("TP_ROTATE_LABEL"))
{
rlistener = nullptr;
//TODO the action of the rotation slider is counter-intuitive
Gtk::Image* irotateL = Gtk::manage (new RTImage ("rotate-right-small.png"));
Gtk::Image* irotateR = Gtk::manage (new RTImage ("rotate-left-small.png"));
degree = Gtk::manage (new Adjuster (M("TP_ROTATE_DEGREE"), -45, 45, 0.01, 0, irotateL, irotateR));
degree->setAdjusterListener (this);
pack_start (*degree);
selectStraight = Gtk::manage (new Gtk::Button (M("TP_ROTATE_SELECTLINE")));
selectStraight->set_image (*Gtk::manage (new RTImage ("rotate-straighten-small.png")));
selectStraight->get_style_context()->add_class("independent");
pack_start (*selectStraight, Gtk::PACK_SHRINK, 2);
selectStraight->signal_pressed().connect( sigc::mem_fun(*this, &Rotate::selectStraightPressed) );
degree->setLogScale(2, 0);
show_all ();
}
void Rotate::read (const ProcParams* pp, const ParamsEdited* pedited)
{
disableListener ();
if (pedited) {
degree->setEditedState (pedited->rotate.degree ? Edited : UnEdited);
}
degree->setValue (pp->rotate.degree);
enableListener ();
}
void Rotate::write (ProcParams* pp, ParamsEdited* pedited)
{
pp->rotate.degree = degree->getValue ();
if (pedited) {
pedited->rotate.degree = degree->getEditedState ();
}
}
void Rotate::setDefaults (const ProcParams* defParams, const ParamsEdited* pedited)
{
degree->setDefault (defParams->rotate.degree);
if (pedited) {
degree->setDefaultEditedState (pedited->rotate.degree ? Edited : UnEdited);
} else {
degree->setDefaultEditedState (Irrelevant);
}
}
void Rotate::adjusterChanged (Adjuster* a, double newval)
{
if (listener) {
listener->panelChanged (EvROTDegree, Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), degree->getValue()));
}
}
void Rotate::straighten (double deg)
{
degree->setValue (degree->getValue() + deg);
degree->setEditedState (Edited);
if (listener) {
listener->panelChanged (EvROTDegree, Glib::ustring::format (std::setw(3), std::fixed, std::setprecision(2), degree->getValue()));
}
}
void Rotate::selectStraightPressed ()
{
if (rlistener) {
rlistener->straightenRequested ();
}
}
void Rotate::setBatchMode (bool batchMode)
{
ToolPanel::setBatchMode (batchMode);
degree->showEditedCB ();
}
void Rotate::setAdjusterBehavior (bool rotadd)
{
degree->setAddMode(rotadd);
}
void Rotate::trimValues (rtengine::procparams::ProcParams* pp)
{
degree->trimValue(pp->rotate.degree);
}