Modifications to store histogram settings across sessions

This commit is contained in:
Thanatomanic 2018-09-02 13:39:55 +02:00
parent 6b93927ea1
commit 85d55ebeb6
5 changed files with 89 additions and 55 deletions

View File

@ -2242,7 +2242,7 @@ void EditorPanel::histogramChanged (LUTu & histRed, LUTu & histGreen, LUTu & his
{
if (histogramPanel) {
histogramPanel->histogramChanged (histRed, histGreen, histBlue, histLuma, histRedRaw, histGreenRaw, histBlueRaw, histChroma);
histogramPanel->histogramChanged (histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw);
}
tpc->updateCurveBackgroundHistogram (histToneCurve, histLCurve, histCCurve,/*histCLurve, histLLCurve,*/ histLCAM, histCCAM, histRed, histGreen, histBlue, histLuma, histLRETI);

View File

@ -129,14 +129,14 @@ HistogramPanel::HistogramPanel ()
buttonGrid = Gtk::manage (new Gtk::Grid ());
buttonGrid->set_orientation(Gtk::ORIENTATION_VERTICAL);
showRed->set_active (true);
showGreen->set_active (true);
showBlue->set_active (true);
showValue->set_active (false);//unactive by default
showChro->set_active (false);//unactive by default
showRAW->set_active (false);
showRed->set_active (options.histogramRed);
showGreen->set_active (options.histogramGreen);
showBlue->set_active (options.histogramBlue);
showValue->set_active (options.histogramLuma);
showChro->set_active (options.histogramChroma);
showRAW->set_active (options.histogramRAW);
// no showMode->set_active(), as it's not a ToggleButton
showBAR->set_active (options.histogramBar);
showBAR->set_active (options.histogramBar);
showRed->set_image (showRed->get_active() ? *redImage : *redImage_g);
showGreen->set_image (showGreen->get_active() ? *greenImage : *greenImage_g);
@ -297,12 +297,12 @@ void HistogramPanel::bar_toggled ()
void HistogramPanel::rgbv_toggled ()
{
// Update Display
histogramArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), showChro->get_active(), options.histogramDrawMode);
histogramArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showChro->get_active(), showRAW->get_active(), options.histogramDrawMode);
histogramArea->queue_draw ();
histogramRGBArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showRAW->get_active(), showBAR->get_active(), showChro->get_active());
histogramRGBArea->updateOptions (showRed->get_active(), showGreen->get_active(), showBlue->get_active(), showValue->get_active(), showChro->get_active(), showRAW->get_active(), showBAR->get_active());
histogramRGBArea->updateBackBuffer (0, 0, 0);
histogramArea->queue_draw ();
histogramRGBArea->queue_draw ();
}
void HistogramPanel::setHistRGBInvalid ()
@ -369,8 +369,11 @@ double HistogramScaling::log(double vsize, double val)
//
//
// HistogramRGBArea
HistogramRGBArea::HistogramRGBArea () ://needChroma unactive by default, luma too
val(0), r(0), g(0), b(0), valid(false), needRed(true), needGreen(true), needBlue(true), needLuma(false), rawMode(false), showMode(options.histogramBar), barDisplayed(options.histogramBar), needChroma(false), parent(nullptr)
HistogramRGBArea::HistogramRGBArea () :
val(0), r(0), g(0), b(0), valid(false),
needRed(options.histogramRed), needGreen(options.histogramGreen), needBlue(options.histogramBlue),
needLuma(options.histogramLuma), needChroma(options.histogramChroma), rawMode(options.histogramRAW),
showMode(options.histogramBar), barDisplayed(options.histogramBar), parent(nullptr)
{
get_style_context()->add_class("drawingarea");
@ -583,28 +586,23 @@ void HistogramRGBArea::update (int valh, int rh, int gh, int bh)
idle_register.add(func, harih);
}
void HistogramRGBArea::updateOptions (bool r, bool g, bool b, bool l, bool raw, bool bar, bool c)
void HistogramRGBArea::updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, bool bar)
{
needRed = r;
needGreen = g;
needBlue = b;
needLuma = l;
rawMode = raw;
showMode = bar;
needChroma = c;
// Histogram RGB BAR button logic goes here
options.histogramRed = needRed = r;
options.histogramGreen = needGreen = g;
options.histogramBlue = needBlue = b;
options.histogramLuma = needLuma = l;
options.histogramChroma = needChroma = c;
options.histogramRAW = rawMode = raw;
options.histogramBar = showMode = bar;
// Show/hide the RGB bar widget
if (bar && !barDisplayed) {
// Toggled on, add (show) the widget
parent->add(*this);
options.histogramBar = true;
barDisplayed = true;
} else if (!bar && barDisplayed) {
// Toggled off, remove (hide) the widget
removeIfThere(parent, this, false);
options.histogramBar = false;
barDisplayed = false;
}
@ -661,16 +659,18 @@ void HistogramRGBArea::factorChanged (double newFactor)
//
//
// HistogramArea
HistogramArea::HistogramArea (DrawModeListener *fml) : //needChroma unactive by default, luma too
HistogramArea::HistogramArea (DrawModeListener *fml) :
valid(false), drawMode(options.histogramDrawMode), myDrawModeListener(fml),
oldwidth(-1), oldheight(-1), needLuma(false), needRed(true), needGreen(true), needBlue(true),
rawMode(false), needChroma(false), isPressed(false), movingPosition(0.0)
oldwidth(-1), oldheight(-1),
needRed(options.histogramRed), needGreen(options.histogramGreen), needBlue(options.histogramBlue),
needLuma(options.histogramLuma), needChroma(options.histogramChroma), rawMode(options.histogramRAW),
isPressed(false), movingPosition(0.0)
{
lhist(256);
rhist(256);
ghist(256);
bhist(256);
lhist(256);
chist(256);
get_style_context()->add_class("drawingarea");
@ -724,32 +724,31 @@ void HistogramArea::get_preferred_width_for_height_vfunc (int height, int &minim
get_preferred_width_vfunc (minimum_width, natural_width);
}
void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool raw, bool c, int mode)
void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, int mode)
{
needRed = r;
needGreen = g;
needBlue = b;
needLuma = l;
rawMode = raw;
needChroma = c;
drawMode = mode;
options.histogramRed = needRed = r;
options.histogramGreen = needGreen = g;
options.histogramBlue = needBlue = b;
options.histogramLuma = needLuma = l;
options.histogramChroma = needChroma = c;
options.histogramRAW = rawMode = raw;
options.histogramDrawMode = drawMode = mode;
updateBackBuffer ();
}
void HistogramArea::update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw, LUTu &histChroma)
void HistogramArea::update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histChroma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw)
{
if (histRed) {
lhist = histLuma;
chist = histChroma;
rhist = histRed;
ghist = histGreen;
bhist = histBlue;
lhist = histLuma;
chist = histChroma;
rhistRaw = histRedRaw;
ghistRaw = histGreenRaw;
bhistRaw = histBlueRaw;
valid = true;
} else {
valid = false;

View File

@ -70,10 +70,10 @@ protected:
bool needGreen;
bool needBlue;
bool needLuma;
bool needChroma;
bool rawMode;
bool showMode;
bool barDisplayed;
bool needChroma;
Gtk::Grid* parent;
@ -91,7 +91,7 @@ public:
};
void update (int val, int rh, int gh, int bh);
void updateOptions (bool r, bool g, bool b, bool l, bool raw, bool show, bool c);
void updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, bool show);
void on_realize();
bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr);
@ -104,7 +104,7 @@ private:
void get_preferred_width_vfunc (int &minimum_width, int &natural_width) const;
void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const;
void get_preferred_width_for_height_vfunc (int h, int &minimum_width, int &natural_width) const;
// Some ...
};
class DrawModeListener
@ -124,15 +124,16 @@ private:
type_signal_factor_changed sigFactorChanged;
protected:
LUTu lhist, rhist, ghist, bhist, chist;
LUTu lhistRaw, rhistRaw, ghistRaw, bhistRaw;
LUTu rhist, ghist, bhist, lhist, chist;
LUTu rhistRaw, ghistRaw, bhistRaw, lhistRaw; //lhistRaw is unused?
bool valid;
int drawMode;
DrawModeListener *myDrawModeListener;
int oldwidth, oldheight;
bool needLuma, needRed, needGreen, needBlue, rawMode, needChroma;
bool needRed, needGreen, needBlue, needLuma, needChroma;
bool rawMode;
bool isPressed;
double movingPosition;
@ -143,8 +144,8 @@ public:
~HistogramArea();
void updateBackBuffer ();
void update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw, LUTu &histChroma);
void updateOptions (bool r, bool g, bool b, bool l, bool raw, bool c, int mode);
void update (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histChroma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw);
void updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, int mode);
void on_realize();
bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr);
bool on_button_press_event (GdkEventButton* event);
@ -208,9 +209,9 @@ public:
HistogramPanel ();
~HistogramPanel ();
void histogramChanged (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw, LUTu &histChroma)
void histogramChanged (LUTu &histRed, LUTu &histGreen, LUTu &histBlue, LUTu &histLuma, LUTu &histChroma, LUTu &histRedRaw, LUTu &histGreenRaw, LUTu &histBlueRaw)
{
histogramArea->update (histRed, histGreen, histBlue, histLuma, histRedRaw, histGreenRaw, histBlueRaw, histChroma);
histogramArea->update (histRed, histGreen, histBlue, histLuma, histChroma, histRedRaw, histGreenRaw, histBlueRaw);
}
// pointermotionlistener interface
void pointerMoved (bool validPos, const Glib::ustring &profile, const Glib::ustring &profileW, int x, int y, int r, int g, int b, bool isRaw = false);

View File

@ -419,6 +419,9 @@ void Options::setDefaults()
mainNBVertical = true;
multiDisplayMode = 0;
histogramPosition = 1;
histogramRed = true;
histogramGreen = true;
histogramBlue = true;
histogramBar = true;
histogramHeight = 200;
histogramDrawMode = 0;
@ -1273,6 +1276,30 @@ void Options::readFromFile(Glib::ustring fname)
histogramPosition = keyFile.get_integer("GUI", "HistogramPosition");
}
if (keyFile.has_key("GUI", "HistogramRed")) {
histogramRed = keyFile.get_boolean("GUI", "HistogramRed");
}
if (keyFile.has_key("GUI", "HistogramGreen")) {
histogramGreen = keyFile.get_boolean("GUI", "HistogramGreen");
}
if (keyFile.has_key("GUI", "HistogramBlue")) {
histogramBlue = keyFile.get_boolean("GUI", "HistogramBlue");
}
if (keyFile.has_key("GUI", "HistogramLuma")) {
histogramLuma = keyFile.get_boolean("GUI", "HistogramLuma");
}
if (keyFile.has_key("GUI", "HistogramChroma")) {
histogramChroma = keyFile.get_boolean("GUI", "HistogramChroma");
}
if (keyFile.has_key("GUI", "HistogramRAW")) {
histogramRAW = keyFile.get_boolean("GUI", "HistogramRAW");
}
if (keyFile.has_key("GUI", "HistogramBar")) {
histogramBar = keyFile.get_boolean("GUI", "HistogramBar");
}
@ -1994,6 +2021,12 @@ void Options::saveToFile(Glib::ustring fname)
keyFile.set_double_list ("GUI", "CutOverlayBrush", cutOverlayBrush);
keyFile.set_double_list ("GUI", "NavGuideBrush", navGuideBrush);
keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition);
keyFile.set_boolean ("GUI", "HistogramRed", histogramRed);
keyFile.set_boolean ("GUI", "HistogramGreen", histogramGreen);
keyFile.set_boolean ("GUI", "HistogramBlue", histogramBlue);
keyFile.set_boolean ("GUI", "HistogramLuma", histogramLuma);
keyFile.set_boolean ("GUI", "HistogramChroma", histogramChroma);
keyFile.set_boolean ("GUI", "HistogramRAW", histogramRAW);
keyFile.set_boolean ("GUI", "HistogramBar", histogramBar);
keyFile.set_integer ("GUI", "HistogramHeight", histogramHeight);
keyFile.set_integer ("GUI", "HistogramDrawMode", histogramDrawMode);

View File

@ -256,7 +256,8 @@ public:
bool sndEnable;
int histogramPosition; // 0=disabled, 1=left pane, 2=right pane
//int histogramWorking; // 0=disabled, 1=left pane, 2=right pane
bool histogramRed, histogramGreen, histogramBlue;
bool histogramLuma, histogramChroma, histogramRAW;
bool histogramBar;
int histogramHeight;
int histogramDrawMode;