From 0720659627bc453a0fb9ad9adf59e872321a490b Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sat, 4 Mar 2017 13:48:19 +0100 Subject: [PATCH] fixed reading and displaying of floating-point values in dynamic profile rules --- rtgui/dynamicprofile.cc | 4 ++-- rtgui/dynamicprofilepanel.cc | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/rtgui/dynamicprofile.cc b/rtgui/dynamicprofile.cc index af829b024..749c9b02e 100644 --- a/rtgui/dynamicprofile.cc +++ b/rtgui/dynamicprofile.cc @@ -104,8 +104,8 @@ void get_double_range(DynamicProfileEntry::Range &dest, const Glib::ustring &key) { try { - int min = kf.get_double(group, key + "_min"); - int max = kf.get_double(group, key + "_max"); + double min = kf.get_double(group, key + "_min"); + double max = kf.get_double(group, key + "_max"); if (min <= max) { dest.min = min; dest.max = max; diff --git a/rtgui/dynamicprofilepanel.cc b/rtgui/dynamicprofilepanel.cc index 1f3059a2c..0ac82f7ae 100644 --- a/rtgui/dynamicprofilepanel.cc +++ b/rtgui/dynamicprofilepanel.cc @@ -26,10 +26,10 @@ namespace { template -Glib::ustring to_str(V n) +Glib::ustring to_str(V n, int precision=1) { std::ostringstream buf; - buf << std::setprecision(1) << std::fixed << n; + buf << std::setprecision(precision) << std::fixed << n; return buf.str(); } @@ -369,13 +369,13 @@ void DynamicProfilePanel::render_profilepath( } -#define RENDER_RANGE_(tp, name) \ +#define RENDER_RANGE_(tp, name, prec) \ auto row = *iter; \ Gtk::CellRendererText *ct = static_cast(cell); \ DynamicProfileEntry::Range r = row[columns_. name]; \ DynamicProfileEntry dflt; \ if (r.min > dflt.name.min || r.max < dflt.name.max) { \ - auto value = to_str(r.min) + " - " + to_str(r.max); \ + auto value = to_str(r.min, prec) + " - " + to_str(r.max, prec); \ ct->property_text() = value; \ } else { \ ct->property_text() = ""; \ @@ -384,35 +384,35 @@ void DynamicProfilePanel::render_profilepath( void DynamicProfilePanel::render_iso( Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) { - RENDER_RANGE_(int, iso); + RENDER_RANGE_(int, iso, 0); } void DynamicProfilePanel::render_fnumber( Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) { - RENDER_RANGE_(double, fnumber); + RENDER_RANGE_(double, fnumber, 1); } void DynamicProfilePanel::render_focallen( Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) { - RENDER_RANGE_(double, focallen); + RENDER_RANGE_(double, focallen, 1); } void DynamicProfilePanel::render_shutterspeed( Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) { - RENDER_RANGE_(double, shutterspeed); + RENDER_RANGE_(double, shutterspeed, 4); } void DynamicProfilePanel::render_expcomp( Gtk::CellRenderer *cell, const Gtk::TreeModel::iterator &iter) { - RENDER_RANGE_(double, expcomp); + RENDER_RANGE_(double, expcomp, 1); } #undef RENDER_RANGE_