mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Return a pair in scheme for GncOptionRangeValue<int>.
This is a bit of a hack to handle PlotSize options. They're the only RangeValues that use ints; the rest use doubles because the control is a GtkSpinButton and that uses doubles. The chart code expects a pair with either 'pixel or 'percent saying what to put in front of the number. We hack that too: if value <= 100 then it's percent because 100px is about 3cm on modern monitors and 15mm on HiDPI ones. Bigger numbers are pixels.
This commit is contained in:
parent
b5c0477143
commit
f20c358ce1
@ -183,7 +183,7 @@ scm_to_value<const QofInstance*>(SCM new_value)
|
||||
SWIGTYPE_p_GncBudget, SWIGTYPE_p_GncInvoice,
|
||||
SWIGTYPE_p_GncTaxTable, SWIGTYPE_p_Account
|
||||
};
|
||||
void* ptr{};
|
||||
void* ptr{};
|
||||
auto pos = std::find_if(types.begin(), types.end(),
|
||||
[&new_value, &ptr](auto type){
|
||||
SWIG_ConvertPtr(new_value, &ptr, type, 0);
|
||||
@ -509,7 +509,15 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
|
||||
}
|
||||
return scm_reverse(values);
|
||||
}
|
||||
%}
|
||||
|
||||
SCM get_scm_value(const GncOptionRangeValue<int>& option)
|
||||
{
|
||||
auto val{option.get_value()};
|
||||
auto desig{scm_c_eval_string(val > 100 ? "'pixels" : "'percent")};
|
||||
return scm_cons(desig, scm_from_int(val));
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%include "gnc-option-date.hpp"
|
||||
%include "gnc-option.hpp"
|
||||
@ -531,7 +539,9 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
|
||||
return SCM_BOOL_F;
|
||||
return std::visit([](const auto& option)->SCM {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionMultichoiceValue>)
|
||||
GncOptionMultichoiceValue> ||
|
||||
std::is_same_v<std::decay_t<decltype(option)>,
|
||||
GncOptionRangeValue<int>>)
|
||||
return get_scm_value(option);
|
||||
auto value{option.get_value()};
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(value)>,
|
||||
|
Loading…
Reference in New Issue
Block a user