summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-01-27 13:36:14 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-01-27 13:36:14 +0000
commitd95d10c568149734e65a93b8fbd1f61d0ad63bc3 (patch)
treec6f7e6a74f13e72dd9db65fc3c90e36840e7f640 /src
parentSpinButtonToolItem: Handle menu-button press (diff)
downloadinkscape-d95d10c568149734e65a93b8fbd1f61d0ad63bc3.tar.gz
inkscape-d95d10c568149734e65a93b8fbd1f61d0ad63bc3.zip
SpinButtonToolItem: Make numeric menu items depend on adjustment parameters
Diffstat (limited to 'src')
-rw-r--r--src/ui/widget/spin-button-tool-item.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/ui/widget/spin-button-tool-item.cpp b/src/ui/widget/spin-button-tool-item.cpp
index 21a82d48e..e227a51f7 100644
--- a/src/ui/widget/spin-button-tool-item.cpp
+++ b/src/ui/widget/spin-button-tool-item.cpp
@@ -269,7 +269,8 @@ SpinButtonToolItem::create_numeric_menu()
auto lower = adj->get_lower();
auto upper = adj->get_upper();
auto range = upper - lower;
- auto step = range/4.0;
+ auto step = adj->get_step_increment();
+ auto page = adj->get_page_increment();
auto digits = _btn->get_digits();
@@ -283,18 +284,22 @@ SpinButtonToolItem::create_numeric_menu()
// For digits = 2, we get epsilon = 0.9 * 10^-2 = 0.009 etc...
auto epsilon = 0.9 * pow(10.0, -float(digits));
- // For now, let's just set some fixed values at 25% intervals
- // along the adjustment's range.
+ // For now, set some fixed values based on the adjustment's
+ // parameters.
//
- // TODO: Allow values for the list to be specified
+ // TODO: Allow custom values for the list to be specified
// TODO: Allow descriptions to be added
- // TODO: Make the range of values depend on current value?
-
- for (unsigned int i = 0; i < 5; ++i)
+ std::vector<double> values;
+ values.push_back(upper);
+ values.push_back(adj_value + page);
+ values.push_back(adj_value + step);
+ values.push_back(adj_value);
+ values.push_back(adj_value - step);
+ values.push_back(adj_value - page);
+ values.push_back(lower);
+
+ for (auto value : values)
{
- // Get the value for this item and represent it as a string
- auto value = lower + i * step;
-
auto numeric_menu_item = create_numeric_menu_item(&group, value);
numeric_menu->append(*numeric_menu_item);
@@ -303,15 +308,6 @@ SpinButtonToolItem::create_numeric_menu()
// make this menu item active
numeric_menu_item->set_active();
}
- else if (adj_value > value + epsilon &&
- adj_value < value + step - epsilon)
- {
- // Alternatively, if the adjustment value is between this and the
- // next item, then insert another menu item here
- auto active_menu_item = create_numeric_menu_item(&group, adj_value);
- numeric_menu->append(*active_menu_item);
- active_menu_item->set_active();
- }
}
return numeric_menu;