diff --git a/rtgui/navigator.cc b/rtgui/navigator.cc index 4f7e638f2..eea574d24 100644 --- a/rtgui/navigator.cc +++ b/rtgui/navigator.cc @@ -26,9 +26,11 @@ #include "../rtengine/rt_math.h" #include "options.h" +extern Options options; + using namespace rtengine; -Navigator::Navigator () +Navigator::Navigator () : currentRGBUnit(options.navRGBUnit), currentHSVUnit(options.navHSVUnit) { set_label (M("MAIN_MSG_NAVIGATOR")); @@ -127,6 +129,7 @@ Navigator::Navigator () // RGB + Gtk::EventBox *evBox1 = Gtk::manage (new Gtk::EventBox()); Gtk::HBox* hbox1 = Gtk::manage (new Gtk::HBox ()); // container Gtk::Table* table1 = Gtk::manage (new Gtk::Table (3, 2)); @@ -139,11 +142,15 @@ Navigator::Navigator () table1->attach (*lB, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 4, 0); table1->attach (*B, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); - hbox1->pack_start (*table1, Gtk::PACK_EXPAND_WIDGET, 4); + evBox1->add (*table1); + evBox1->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Navigator::cycleUnitsRGB)); + + hbox1->pack_start (*evBox1, Gtk::PACK_EXPAND_WIDGET, 4); hbox1->pack_start (*Gtk::manage (new Gtk::VSeparator()), Gtk::PACK_SHRINK, 4); table0->attach (*hbox1, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); // HSV + Gtk::EventBox *evBox2 = Gtk::manage (new Gtk::EventBox()); Gtk::HBox* hbox2 = Gtk::manage (new Gtk::HBox ()); // container Gtk::Table* table2 = Gtk::manage (new Gtk::Table (3, 2)); @@ -156,7 +163,10 @@ Navigator::Navigator () table2->attach (*lV, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 4, 0); table2->attach (*V, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); - hbox2->pack_start (*table2, Gtk::PACK_EXPAND_WIDGET, 4); + evBox2->add (*table2); + evBox2->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &Navigator::cycleUnitsHSV)); + + hbox2->pack_start (*evBox2, Gtk::PACK_EXPAND_WIDGET, 4); hbox2->pack_start (*Gtk::manage (new Gtk::VSeparator()), Gtk::PACK_SHRINK, 4); table0->attach (*hbox2, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 0, 0); @@ -214,15 +224,45 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin } else { position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y)); - R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); - G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%")); - B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%")); + switch (currentRGBUnit) { + case (Options::NavigatorUnit::NU_0_1): + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f)); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), g / 255.f)); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f)); + break; + case (Options::NavigatorUnit::NU_0_255): + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r)); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g)); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b)); + break; + case (Options::NavigatorUnit::NU_PERCENT): + default: + R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); + G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%")); + B->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), b * 100.f / 255.f) + Glib::ustring("%")); + break; + } float h, s, v; Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v); - H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); - S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%")); - V->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%")); + switch (currentHSVUnit) { + case (Options::NavigatorUnit::NU_0_1): + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h)); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s)); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v)); + break; + case (Options::NavigatorUnit::NU_0_255): + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), h * 255)); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), s * 255)); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), v * 255)); + break; + case (Options::NavigatorUnit::NU_PERCENT): + default: + H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); + S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%")); + V->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), v * 100.f) + Glib::ustring("%")); + break; + } float LAB_a, LAB_b, LAB_l; //rgb2lab (r, g, b, LAB_l, LAB_a, LAB_b); @@ -233,6 +273,61 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin } } +void Navigator::cycleUnitsRGB (GdkEventButton *event) { + uint16_t v = (uint16_t)currentRGBUnit; + ++v; + if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + v = 0; + } + options.navRGBUnit = currentRGBUnit = (Options::NavigatorUnit)v; + + switch (currentRGBUnit) { + case Options::NavigatorUnit::NU_0_1: + R->set_text ("[0-1]"); + G->set_text ("[0-1]"); + B->set_text ("[0-1]"); + break; + case Options::NavigatorUnit::NU_0_255: + R->set_text ("[0-255]"); + G->set_text ("[0-255]"); + B->set_text ("[0-255]"); + break; + case Options::NavigatorUnit::NU_PERCENT: + default: + R->set_text ("[%]"); + G->set_text ("[%]"); + B->set_text ("[%]"); + break; + } +} + +void Navigator::cycleUnitsHSV (GdkEventButton *event) { + uint16_t v = (uint16_t)currentHSVUnit; + ++v; + if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { + v = 0; + } + options.navHSVUnit = currentHSVUnit = (Options::NavigatorUnit)v; + + switch (currentHSVUnit) { + case Options::NavigatorUnit::NU_0_1: + H->set_text ("[0-1]"); + S->set_text ("[0-1]"); + V->set_text ("[0-1]"); + break; + case Options::NavigatorUnit::NU_0_255: + H->set_text ("[0-255]"); + S->set_text ("[0-255]"); + V->set_text ("[0-255]"); + break; + case Options::NavigatorUnit::NU_PERCENT: + default: + H->set_text ("[\xc2\xb0]"); + S->set_text ("[%]"); + V->set_text ("[%]"); + break; + } +} void Navigator::rgb2lab (Glib::ustring profile, Glib::ustring profileW, int r, int g, int b, float &LAB_l, float &LAB_a, float &LAB_b) { diff --git a/rtgui/navigator.h b/rtgui/navigator.h index 3abf34a2f..e0b79d8dd 100644 --- a/rtgui/navigator.h +++ b/rtgui/navigator.h @@ -22,6 +22,7 @@ #include #include "previewwindow.h" #include "pointermotionlistener.h" +#include "options.h" #include "../rtengine/iccstore.h" class Navigator : public Gtk::Frame, public PointerMotionListener @@ -29,6 +30,12 @@ class Navigator : public Gtk::Frame, public PointerMotionListener typedef const double (*TMatrix)[3]; +private: + Options::NavigatorUnit currentRGBUnit; + Options::NavigatorUnit currentHSVUnit; + void cycleUnitsRGB (GdkEventButton *event); + void cycleUnitsHSV (GdkEventButton *event); + protected: Gtk::Label* position; Gtk::Label *R, *G, *B; diff --git a/rtgui/options.cc b/rtgui/options.cc index e723361be..cec5eaef8 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -353,6 +353,8 @@ void Options::setDefaults () fbShowExpComp = false; fbShowHidden = false; fbArrangement = 2; // was 0 + navRGBUnit = NavigatorUnit::NU_PERCENT; + navHSVUnit = NavigatorUnit::NU_PERCENT; multiUser = true; profilePath = "profiles"; loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails @@ -1407,6 +1409,14 @@ int Options::readFromFile (Glib::ustring fname) histogramFullMode = keyFile.get_boolean ("GUI", "HistogramFullMode"); } + if (keyFile.has_key ("GUI", "NavigatorRGBUnit")) { + navRGBUnit = (NavigatorUnit)keyFile.get_integer ("GUI", "NavigatorRGBUnit"); + } + + if (keyFile.has_key ("GUI", "NavigatorHSVUnit")) { + navHSVUnit = (NavigatorUnit)keyFile.get_integer ("GUI", "NavigatorHSVUnit"); + } + if (keyFile.has_key ("GUI", "ShowFilmStripToolBar")) { showFilmStripToolBar = keyFile.get_boolean ("GUI", "ShowFilmStripToolBar"); } @@ -2010,6 +2020,8 @@ int Options::saveToFile (Glib::ustring fname) keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition); keyFile.set_boolean ("GUI", "HistogramBar", histogramBar); keyFile.set_boolean ("GUI", "HistogramFullMode", histogramFullMode); + keyFile.set_integer ("GUI", "NavigatorRGBUnit", (int)navRGBUnit); + keyFile.set_integer ("GUI", "NavigatorHSVUnit", (int)navHSVUnit); keyFile.set_boolean ("GUI", "ShowFilmStripToolBar", showFilmStripToolBar); keyFile.set_boolean ("GUI", "FileBrowserToolbarSingleRow", FileBrowserToolbarSingleRow); keyFile.set_boolean ("GUI", "HideTPVScrollbar", hideTPVScrollbar); diff --git a/rtgui/options.h b/rtgui/options.h index 4da827f36..8d374d4cd 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -86,6 +86,13 @@ private: const Glib::ustring& entryName, Glib::ustring& destination); public: + + enum class NavigatorUnit { + NU_PERCENT, + NU_0_255, + NU_0_1, + NU__COUNT, + }; bool savesParamsAtExit; SaveFormat saveFormat, saveFormatBatch; Glib::ustring savePathTemplate; @@ -133,6 +140,8 @@ public: bool fbShowExpComp; bool fbShowHidden; int fbArrangement; + NavigatorUnit navRGBUnit; + NavigatorUnit navHSVUnit; bool multiUser; static Glib::ustring rtdir; Glib::ustring version;