Merge branch 'dev' into metadata-exiv2

This commit is contained in:
Flössie 2019-05-16 18:12:47 +02:00
commit 1fc17dab7e
14 changed files with 264 additions and 284 deletions

View File

@ -270,7 +270,8 @@ void rtengine::HaldCLUT::splitClutFilename(
const Glib::ustring& filename, const Glib::ustring& filename,
Glib::ustring& name, Glib::ustring& name,
Glib::ustring& extension, Glib::ustring& extension,
Glib::ustring& profile_name Glib::ustring& profile_name,
bool checkProfile
) )
{ {
Glib::ustring basename = Glib::path_get_basename(filename); Glib::ustring basename = Glib::path_get_basename(filename);
@ -284,17 +285,19 @@ void rtengine::HaldCLUT::splitClutFilename(
name = basename; name = basename;
} }
profile_name = "sRGB"; if (checkProfile) {
profile_name = "sRGB";
if (!name.empty()) { if (!name.empty()) {
for (const auto& working_profile : rtengine::ICCStore::getInstance()->getWorkingProfiles()) { for (const auto& working_profile : rtengine::ICCStore::getInstance()->getWorkingProfiles()) {
if ( if (
!working_profile.empty() // This isn't strictly needed, but an empty wp name should be skipped anyway !working_profile.empty() // This isn't strictly needed, but an empty wp name should be skipped anyway
&& std::search(name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend()) == name.rbegin() && std::search(name.rbegin(), name.rend(), working_profile.rbegin(), working_profile.rend()) == name.rbegin()
) { ) {
profile_name = working_profile; profile_name = working_profile;
name.erase(name.size() - working_profile.size()); name.erase(name.size() - working_profile.size());
break; break;
}
} }
} }
} }

View File

@ -39,7 +39,8 @@ public:
const Glib::ustring& filename, const Glib::ustring& filename,
Glib::ustring& name, Glib::ustring& name,
Glib::ustring& extension, Glib::ustring& extension,
Glib::ustring& profile_name Glib::ustring& profile_name,
bool checkProfile = true
); );
private: private:

View File

@ -2518,13 +2518,13 @@ void ImProcFunctions::rgbProc (Imagefloat* working, LabImage* lab, PipetteBuffer
} }
} }
} else { } else {
float tmpr[4] ALIGNED16;
float tmpg[4] ALIGNED16;
float tmpb[4] ALIGNED16;
for (int i = istart, ti = 0; i < tH; i++, ti++) { for (int i = istart, ti = 0; i < tH; i++, ti++) {
int j = jstart, tj = 0; int j = jstart, tj = 0;
#ifdef __SSE2__ #ifdef __SSE2__
float tmpr[4] ALIGNED16;
float tmpg[4] ALIGNED16;
float tmpb[4] ALIGNED16;
for (; j < tW - 3; j+=4, tj+=4) { for (; j < tW - 3; j+=4, tj+=4) {
//brightness/contrast //brightness/contrast
STVF(tmpr[0], tonecurve(LVF(rtemp[ti * TS + tj]))); STVF(tmpr[0], tonecurve(LVF(rtemp[ti * TS + tj])));

View File

@ -25,83 +25,96 @@
#include "guiutils.h" #include "guiutils.h"
#include "rtimage.h" #include "rtimage.h"
#define MIN_RESET_BUTTON_HEIGHT 17
static double one2one(double val) namespace {
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,
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)
Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep, double vdefault, Gtk::Image *imgIcon1, Gtk::Image *imgIcon2, double2double_fun slider2value_, double2double_fun value2slider_)
{ {
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, Gtk::ALIGN_CENTER); setExpandAlignProperties(imageIcon1, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
} }
imageIcon2 = imgIcon2; if (imgIcon2) {
setExpandAlignProperties(imgIcon2, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
if (imageIcon2) {
setExpandAlignProperties(imageIcon2, false, false, Gtk::ALIGN_CENTER, Gtk::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::ALIGN_BASELINE); setExpandAlignProperties(label, true, false, Gtk::ALIGN_START, Gtk::ALIGN_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_CENTER); setExpandAlignProperties(spin, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
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 ? spin->get_height() : MIN_RESET_BUTTON_HEIGHT); reset->set_size_request(-1, spin->get_height() > MIN_RESET_BUTTON_HEIGHT ? spin->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_CENTER); setExpandAlignProperties(slider, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER);
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);
@ -109,9 +122,9 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep
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);
} }
@ -129,9 +142,9 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep
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);
} }
@ -139,37 +152,30 @@ Adjuster::Adjuster (Glib::ustring vlabel, double vmin, double vmax, double vstep
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, &Adjuster::spinChanged), true); spinChange = spin->signal_value_changed().connect( sigc::mem_fun(*this, &Adjuster::spinChanged), true);
reset->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Adjuster::resetPressed) ); reset->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Adjuster::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);
@ -185,15 +191,6 @@ void Adjuster::addAutoButton (Glib::ustring tooltip)
} }
} }
void Adjuster::delAutoButton ()
{
if (automatic) {
removeIfThere(grid, automatic);
delete automatic;
automatic = nullptr;
}
}
void Adjuster::throwOnButtonRelease(bool throwOnBRelease) void Adjuster::throwOnButtonRelease(bool throwOnBRelease)
{ {
@ -221,7 +218,7 @@ void Adjuster::throwOnButtonRelease(bool throwOnBRelease)
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)
@ -258,7 +255,7 @@ 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();
@ -270,7 +267,7 @@ 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();
@ -283,12 +280,11 @@ void Adjuster::resetValue (bool toInitial)
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;
@ -317,32 +313,35 @@ void Adjuster::resetPressed (GdkEventButton* event)
} }
} }
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 vdefault) void Adjuster::setLimits (double vmin, double vmax, double vstep, double vdefault)
{ {
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(double(10), digits))) > 0.000000000001; digits++); const double shapeVal = shapeValue(vdefault);
spin->set_digits(digits);
spin->set_digits (digits); spin->set_increments(vstep, 2.0 * vstep);
spin->set_increments (vstep, 2.0 * vstep); spin->set_range(vmin, vmax);
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 : value2slider(vmax)); slider->set_increments(vstep, 2.0 * vstep);
setSliderValue(addMode ? shapeValue(vdefault) : value2slider(shapeValue(vdefault))); slider->set_range(addMode ? vmin : value2slider(vmin), addMode ? vmax : value2slider(vmax));
//defaultVal = shapeValue (vdefault); setSliderValue(addMode ? shapeVal : value2slider(shapeVal));
sliderChange.block (false);
spinChange.block (false); sliderChange.block(false);
spinChange.block(false);
} }
void Adjuster::setAddMode(bool addM) void Adjuster::setAddMode(bool addM)
@ -369,39 +368,36 @@ void Adjuster::setAddMode(bool addM)
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, &Adjuster::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;
@ -411,38 +407,36 @@ 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, &Adjuster::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;
@ -450,20 +444,19 @@ void Adjuster::sliderChanged ()
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);
@ -488,7 +481,7 @@ 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;
@ -509,12 +502,12 @@ bool Adjuster::notifyListenerAutoToggled ()
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);
} }
} }
@ -523,13 +516,12 @@ 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 ();
} }
} }
@ -537,7 +529,7 @@ 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;
@ -551,7 +543,7 @@ void Adjuster::showEditedCB ()
} }
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) {
@ -576,50 +568,31 @@ void Adjuster::showEditedCB ()
} }
} }
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));
} }
double Adjuster::getSliderValue() const
inline double Adjuster::getSliderValue()
{ {
double val = slider->get_value(); double val = slider->get_value();
if (logBase) { if (logBase) {
@ -629,29 +602,28 @@ inline double Adjuster::getSliderValue()
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) * (vMax - 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) * (logPivot - 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) * range; 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) * range; val = logPivot - (std::pow(logBase, x) - 1.0) / (logBase - 1.0) * range;
} }
} }
} }
return val; return val;
} }
void Adjuster::setSliderValue(double val)
inline void Adjuster::setSliderValue(double val)
{ {
if (logBase) { if (logBase) {
if (logAnchorMiddle) { if (logAnchorMiddle) {
@ -659,39 +631,96 @@ inline void Adjuster::setSliderValue(double val)
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(logBase) * mid; val = (vMin + mid) + std::log(x * (logBase - 1.0) + 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(logBase) * mid; val = (vMin + mid) - std::log(x * (logBase - 1.0) + 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::log(x * (logBase - 1.0) + 1.0) / std::log(logBase) * 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::log(x * (logBase - 1.0) + 1.0) / std::log(logBase) * 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;
} }

View File

@ -43,7 +43,6 @@ protected:
Gtk::Grid* grid; Gtk::Grid* grid;
Gtk::Label* label; Gtk::Label* label;
Gtk::Image *imageIcon1; Gtk::Image *imageIcon1;
Gtk::Image *imageIcon2;
MyHScale* slider; MyHScale* slider;
MySpinButton* spin; MySpinButton* spin;
Gtk::Button* reset; Gtk::Button* reset;
@ -60,7 +59,6 @@ protected:
double ctorDefaultVal; // default value at construction time double ctorDefaultVal; // default value at construction time
EditedState editedState; EditedState editedState;
EditedState defEditedState; EditedState defEditedState;
EditedState autoState;
int digits; int digits;
Gtk::CheckButton* editedCheckBox; Gtk::CheckButton* editedCheckBox;
bool afterReset; bool afterReset;
@ -75,11 +73,10 @@ protected:
double logPivot; double logPivot;
bool logAnchorMiddle; bool logAnchorMiddle;
double shapeValue (double a); double shapeValue (double a) const;
void refreshLabelStyle ();
double2double_fun value2slider, slider2value; double2double_fun value2slider, slider2value;
double getSliderValue(); double getSliderValue() const;
void setSliderValue(double val); void setSliderValue(double val);
public: public:
@ -90,85 +87,36 @@ public:
~Adjuster () override; ~Adjuster () override;
// Add an "Automatic" checkbox next to the reset button. // Add an "Automatic" checkbox next to the reset button.
void addAutoButton(Glib::ustring tooltip = ""); void addAutoButton(const Glib::ustring &tooltip = "");
// Remove the "Automatic" checkbox next to the reset button.
void delAutoButton();
// Send back the value of og the Auto checkbox // Send back the value of og the Auto checkbox
bool getAutoValue () bool getAutoValue() const;
{ void setAutoValue(bool a);
return automatic != nullptr ? automatic->get_active () : false; bool notifyListenerAutoToggled();
} void autoToggled();
void setAutoValue (bool a); void setAutoInconsistent(bool i);
bool notifyListenerAutoToggled (); bool getAutoInconsistent() const;
void autoToggled (); void setAdjusterListener(AdjusterListener* alistener);
void setAutoInconsistent (bool i)
{
if (automatic) {
automatic->set_inconsistent(i);
}
}
bool getAutoInconsistent ()
{
return automatic ? automatic->get_inconsistent() : true /* we have to return something */;
}
void setAdjusterListener (AdjusterListener* alistener)
{
adjusterListener = alistener;
}
// return the value trimmed to the limits at construction time // return the value trimmed to the limits at construction time
double getValue () double getValue() const;
{
return shapeValue(spin->get_value ());
}
// return the value trimmed to the limits at construction time // return the value trimmed to the limits at construction time
int getIntValue () int getIntValue() const;
{
return spin->get_value_as_int ();
}
// return the value trimmed to the limits at construction time, // return the value trimmed to the limits at construction time,
// method only used by the history manager, so decoration is added if addMode=true // method only used by the history manager, so decoration is added if addMode=true
Glib::ustring getTextValue () Glib::ustring getTextValue() const;
{ void setLabel (const Glib::ustring &lbl);
if (addMode) {
return Glib::ustring::compose("<i>%1</i>", spin->get_text ());
} else {
return spin->get_text ();
}
}
void setLabel (Glib::ustring lbl)
{
label->set_label(lbl);
}
void setValue (double a); void setValue (double a);
void setLimits (double vmin, double vmax, double vstep, double vdefault); void setLimits (double vmin, double vmax, double vstep, double vdefault);
void setEnabled (bool enabled); void setEnabled (bool enabled);
void setDefault (double def); void setDefault (double def);
// will let the adjuster throw it's "changed" signal when the mouse button is released. Can work altogether with the delay value. // will let the adjuster throw it's "changed" signal when the mouse button is released. Can work altogether with the delay value.
void throwOnButtonRelease(bool throwOnBRelease = true); void throwOnButtonRelease(bool throwOnBRelease = true);
void setNbDisplayedChars (int nbr)
{
spin->set_width_chars(nbr);
spin->set_max_width_chars(nbr);
}
void setEditedState (EditedState eState); void setEditedState (EditedState eState);
EditedState getEditedState (); EditedState getEditedState ();
void setDefaultEditedState (EditedState eState); void setDefaultEditedState (EditedState eState);
void showEditedCB (); void showEditedCB ();
bool block(bool isBlocked) bool block(bool isBlocked);
{
bool oldValue = blocked;
blocked = isBlocked;
return oldValue;
}
void setAddMode(bool addM); void setAddMode(bool addM);
bool getAddMode() bool getAddMode() const;
{
return addMode;
};
void spinChanged (); void spinChanged ();
void sliderChanged (); void sliderChanged ();
bool notifyListener (); bool notifyListener ();
@ -177,11 +125,10 @@ public:
void resetValue (bool toInitial); void resetValue (bool toInitial);
void resetPressed (GdkEventButton* event); void resetPressed (GdkEventButton* event);
void editedToggled (); void editedToggled ();
void trimValue (double &val); void trimValue (double &val) const;
void trimValue (float &val); void trimValue (float &val) const;
void trimValue (int &val); void trimValue (int &val) const;
void setLogScale(double base, double pivot, bool anchorMiddle = false);
void setLogScale(double base, double pivot, bool anchorMiddle=false);
}; };
#endif #endif

View File

@ -28,7 +28,7 @@
using namespace rtengine; using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
BayerPreProcess::BayerPreProcess() : FoldableToolPanel(this, "bayerpreprocess", M("TP_PREPROCESS_LABEL"), true) BayerPreProcess::BayerPreProcess() : FoldableToolPanel(this, "bayerpreprocess", M("TP_PREPROCESS_LABEL"), options.prevdemo != PD_Sidecar)
{ {
auto m = ProcEventMapper::getInstance(); auto m = ProcEventMapper::getInstance();
EvLineDenoiseDirection = m->newEvent(DARKFRAME, "HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION"); EvLineDenoiseDirection = m->newEvent(DARKFRAME, "HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION");

View File

@ -28,7 +28,7 @@ using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RAW_LABEL"), true) BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RAW_LABEL"), options.prevdemo != PD_Sidecar)
{ {
auto m = ProcEventMapper::getInstance(); auto m = ProcEventMapper::getInstance();

View File

@ -26,7 +26,7 @@
using namespace rtengine; using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
BayerRAWExposure::BayerRAWExposure () : FoldableToolPanel(this, "bayerrawexposure", M("TP_EXPOS_BLACKPOINT_LABEL"), true) BayerRAWExposure::BayerRAWExposure () : FoldableToolPanel(this, "bayerrawexposure", M("TP_EXPOS_BLACKPOINT_LABEL"), options.prevdemo != PD_Sidecar)
{ {
PexBlack1 = Gtk::manage(new Adjuster (M("TP_RAWEXPOS_BLACK_1"), -2048, 2048, 0.1, 0)); //black level PexBlack1 = Gtk::manage(new Adjuster (M("TP_RAWEXPOS_BLACK_1"), -2048, 2048, 0.1, 0)); //black level
PexBlack1->setAdjusterListener (this); PexBlack1->setAdjusterListener (this);

View File

@ -99,7 +99,7 @@ DirPyrEqualizer::DirPyrEqualizer () : FoldableToolPanel(this, "dirpyrequalizer",
ss += Glib::ustring::compose(" (%1)", M("TP_DIRPYREQUALIZER_LUMACOARSEST")); ss += Glib::ustring::compose(" (%1)", M("TP_DIRPYREQUALIZER_LUMACOARSEST"));
} }
multiplier[i] = Gtk::manage ( new Adjuster (ss, 0, 4, 0.01, 1.0) ); multiplier[i] = Gtk::manage(new Adjuster(std::move(ss), 0, 4, 0.01, 1.0));
multiplier[i]->setAdjusterListener(this); multiplier[i]->setAdjusterListener(this);
pack_start(*multiplier[i]); pack_start(*multiplier[i]);
} }

View File

@ -364,7 +364,7 @@ int ClutComboBox::ClutModel::parseDir(const Glib::ustring& path)
} }
// Fill menu structure with CLUT files // Fill menu structure with CLUT files
std::set<Glib::ustring> entries; std::set<std::string> entries;
unsigned long fileCount = 0; unsigned long fileCount = 0;
@ -390,10 +390,10 @@ int ClutComboBox::ClutModel::parseDir(const Glib::ustring& path)
Glib::ustring name; Glib::ustring name;
Glib::ustring extension; Glib::ustring extension;
Glib::ustring profileName; Glib::ustring profileName;
HaldCLUT::splitClutFilename (entry, name, extension, profileName); HaldCLUT::splitClutFilename (entry, name, extension, profileName, false);
extension = extension.casefold(); extension = extension.casefold();
if (extension.compare("tif") != 0 && extension.compare("png") != 0) { if (extension != "png" && extension != "tif") {
continue; continue;
} }

View File

@ -179,7 +179,7 @@ void MultiLangMgr::load(const Glib::ustring &language, const std::vector<Glib::u
value.replace(pos, 2, "\n"); value.replace(pos, 2, "\n");
pos++; pos++;
} }
hint = translations.emplace_hint(hint, key, value); hint = translations.emplace_hint(hint, std::move(key), std::move(value));
} }
} }
} }

View File

@ -28,7 +28,7 @@
using namespace rtengine; using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
PreProcess::PreProcess () : FoldableToolPanel(this, "preprocess", M("TP_PREPROCESS_LABEL"), true) PreProcess::PreProcess () : FoldableToolPanel(this, "preprocess", M("TP_PREPROCESS_LABEL"), options.prevdemo != PD_Sidecar)
{ {
Gtk::HBox* hotdeadPixel = Gtk::manage( new Gtk::HBox () ); Gtk::HBox* hotdeadPixel = Gtk::manage( new Gtk::HBox () );

View File

@ -290,7 +290,7 @@ Wavelet::Wavelet() :
ss = Glib::ustring::compose( "%1", (i + 1)); ss = Glib::ustring::compose( "%1", (i + 1));
} }
correction[i] = Gtk::manage ( new Adjuster (ss, -100, 350, 1, 0) ); correction[i] = Gtk::manage(new Adjuster(std::move(ss), -100, 350, 1, 0));
correction[i]->setAdjusterListener(this); correction[i]->setAdjusterListener(this);
levBox->pack_start(*correction[i]); levBox->pack_start(*correction[i]);
} }
@ -398,7 +398,7 @@ Wavelet::Wavelet() :
ss = Glib::ustring::compose( "%1", (i + 1)); ss = Glib::ustring::compose( "%1", (i + 1));
} }
correctionch[i] = Gtk::manage ( new Adjuster (ss, -100, 100, 1, 0) ); correctionch[i] = Gtk::manage(new Adjuster(std::move(ss), -100, 100, 1, 0));
correctionch[i]->setAdjusterListener(this); correctionch[i]->setAdjusterListener(this);
chBox->pack_start(*correctionch[i]); chBox->pack_start(*correctionch[i]);
} }

View File

@ -27,7 +27,7 @@
using namespace rtengine; using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
XTransProcess::XTransProcess () : FoldableToolPanel(this, "xtransprocess", M("TP_RAW_LABEL"), true) XTransProcess::XTransProcess () : FoldableToolPanel(this, "xtransprocess", M("TP_RAW_LABEL"), options.prevdemo != PD_Sidecar)
{ {
auto m = ProcEventMapper::getInstance(); auto m = ProcEventMapper::getInstance();
EvDemosaicBorder = m->newEvent(DEMOSAIC, "HISTORY_MSG_RAW_BORDER"); EvDemosaicBorder = m->newEvent(DEMOSAIC, "HISTORY_MSG_RAW_BORDER");