Minor code adjustment

This commit is contained in:
Hombre
2016-08-31 13:40:02 +02:00
parent 388d43ebce
commit f3d46f4c37
3 changed files with 20 additions and 20 deletions

View File

@@ -225,17 +225,17 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin
position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y)); position->set_text (Glib::ustring::compose ("x: %1, y: %2", x, y));
switch (currentRGBUnit) { switch (currentRGBUnit) {
case (Options::NavigatorUnit::NU_0_1): case (Options::NavigatorUnit::R0_1):
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), r / 255.f)); 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)); 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)); B->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), b / 255.f));
break; break;
case (Options::NavigatorUnit::NU_0_255): case (Options::NavigatorUnit::R0_255):
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r)); R->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), r));
G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g)); G->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), g));
B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b)); B->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), b));
break; break;
case (Options::NavigatorUnit::NU_PERCENT): case (Options::NavigatorUnit::PERCENT):
default: default:
R->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), r * 100.f / 255.f) + Glib::ustring("%")); 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("%")); G->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), g * 100.f / 255.f) + Glib::ustring("%"));
@@ -246,17 +246,17 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin
float h, s, v; float h, s, v;
Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v); Color::rgb2hsv (r * 0xffff / 0xff, g * 0xffff / 0xff, b * 0xffff / 0xff, h, s, v);
switch (currentHSVUnit) { switch (currentHSVUnit) {
case (Options::NavigatorUnit::NU_0_1): case (Options::NavigatorUnit::R0_1):
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h)); H->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), h));
S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s)); S->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), s));
V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v)); V->set_text (Glib::ustring::format(std::fixed, std::setprecision(4), v));
break; break;
case (Options::NavigatorUnit::NU_0_255): case (Options::NavigatorUnit::R0_255):
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), h * 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)); 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)); V->set_text (Glib::ustring::format(std::fixed, std::setprecision(0), v * 255));
break; break;
case (Options::NavigatorUnit::NU_PERCENT): case (Options::NavigatorUnit::PERCENT):
default: default:
H->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), h * 360.f) + Glib::ustring("\xc2\xb0")); 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("%")); S->set_text (Glib::ustring::format(std::fixed, std::setprecision(1), s * 100.f) + Glib::ustring("%"));
@@ -276,23 +276,23 @@ void Navigator::pointerMoved (bool validPos, Glib::ustring profile, Glib::ustrin
void Navigator::cycleUnitsRGB (GdkEventButton *event) { void Navigator::cycleUnitsRGB (GdkEventButton *event) {
uint16_t v = (uint16_t)currentRGBUnit; uint16_t v = (uint16_t)currentRGBUnit;
++v; ++v;
if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { if (v == (uint16_t)Options::NavigatorUnit::_COUNT) {
v = 0; v = 0;
} }
options.navRGBUnit = currentRGBUnit = (Options::NavigatorUnit)v; options.navRGBUnit = currentRGBUnit = (Options::NavigatorUnit)v;
switch (currentRGBUnit) { switch (currentRGBUnit) {
case Options::NavigatorUnit::NU_0_1: case Options::NavigatorUnit::R0_1:
R->set_text ("[0-1]"); R->set_text ("[0-1]");
G->set_text ("[0-1]"); G->set_text ("[0-1]");
B->set_text ("[0-1]"); B->set_text ("[0-1]");
break; break;
case Options::NavigatorUnit::NU_0_255: case Options::NavigatorUnit::R0_255:
R->set_text ("[0-255]"); R->set_text ("[0-255]");
G->set_text ("[0-255]"); G->set_text ("[0-255]");
B->set_text ("[0-255]"); B->set_text ("[0-255]");
break; break;
case Options::NavigatorUnit::NU_PERCENT: case Options::NavigatorUnit::PERCENT:
default: default:
R->set_text ("[%]"); R->set_text ("[%]");
G->set_text ("[%]"); G->set_text ("[%]");
@@ -304,23 +304,23 @@ void Navigator::cycleUnitsRGB (GdkEventButton *event) {
void Navigator::cycleUnitsHSV (GdkEventButton *event) { void Navigator::cycleUnitsHSV (GdkEventButton *event) {
uint16_t v = (uint16_t)currentHSVUnit; uint16_t v = (uint16_t)currentHSVUnit;
++v; ++v;
if (v == (uint16_t)Options::NavigatorUnit::NU__COUNT) { if (v == (uint16_t)Options::NavigatorUnit::_COUNT) {
v = 0; v = 0;
} }
options.navHSVUnit = currentHSVUnit = (Options::NavigatorUnit)v; options.navHSVUnit = currentHSVUnit = (Options::NavigatorUnit)v;
switch (currentHSVUnit) { switch (currentHSVUnit) {
case Options::NavigatorUnit::NU_0_1: case Options::NavigatorUnit::R0_1:
H->set_text ("[0-1]"); H->set_text ("[0-1]");
S->set_text ("[0-1]"); S->set_text ("[0-1]");
V->set_text ("[0-1]"); V->set_text ("[0-1]");
break; break;
case Options::NavigatorUnit::NU_0_255: case Options::NavigatorUnit::R0_255:
H->set_text ("[0-255]"); H->set_text ("[0-255]");
S->set_text ("[0-255]"); S->set_text ("[0-255]");
V->set_text ("[0-255]"); V->set_text ("[0-255]");
break; break;
case Options::NavigatorUnit::NU_PERCENT: case Options::NavigatorUnit::PERCENT:
default: default:
H->set_text ("[\xc2\xb0]"); H->set_text ("[\xc2\xb0]");
S->set_text ("[%]"); S->set_text ("[%]");

View File

@@ -353,8 +353,8 @@ void Options::setDefaults ()
fbShowExpComp = false; fbShowExpComp = false;
fbShowHidden = false; fbShowHidden = false;
fbArrangement = 2; // was 0 fbArrangement = 2; // was 0
navRGBUnit = NavigatorUnit::NU_PERCENT; navRGBUnit = NavigatorUnit::PERCENT;
navHSVUnit = NavigatorUnit::NU_PERCENT; navHSVUnit = NavigatorUnit::PERCENT;
multiUser = true; multiUser = true;
profilePath = "profiles"; profilePath = "profiles";
loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails

View File

@@ -88,10 +88,10 @@ private:
public: public:
enum class NavigatorUnit { enum class NavigatorUnit {
NU_PERCENT, PERCENT,
NU_0_255, R0_255,
NU_0_1, R0_1,
NU__COUNT, _COUNT
}; };
bool savesParamsAtExit; bool savesParamsAtExit;
SaveFormat saveFormat, saveFormatBatch; SaveFormat saveFormat, saveFormatBatch;