openMSX
FloatSetting.cc
Go to the documentation of this file.
1#include "FloatSetting.hh"
2
3namespace openmsx {
4
6 std::string_view name_, static_string_view description_,
7 double initialValue,
8 double minValue_, double maxValue_,
9 Save save_)
10 : Setting(commandController_, name_, description_,
11 TclObject(initialValue), save_)
12 , minValue(minValue_)
13 , maxValue(maxValue_)
14{
15 auto& interp = getInterpreter();
16 setChecker([this, &interp](TclObject& newValue) {
17 double val = newValue.getDouble(interp); // may throw
18 newValue = std::clamp(val, minValue, maxValue);
19 });
20 init();
21}
22
23std::string_view FloatSetting::getTypeString() const
24{
25 return "float";
26}
27
29{
30 result.addListElement(makeTclList(minValue, maxValue));
31}
32
34{
36}
37
39{
40 setDouble(double(f));
41}
42
43} // namespace openmsx
void additionalInfo(TclObject &result) const override
Helper method for info().
void setDouble(double d)
FloatSetting(CommandController &commandController, std::string_view name, static_string_view description, double initialValue, double minValue, double maxValue, Save save=Save::YES)
void setFloat(float f)
std::string_view getTypeString() const override
Returns a string describing the setting type (integer, string, ..) Could be used in a GUI to pick an ...
void setChecker(std::function< void(TclObject &)> checkFunc_)
Set value-check-callback.
Definition Setting.hh:146
Interpreter & getInterpreter() const
Definition Setting.cc:139
void setValue(const TclObject &newValue) final
Change the value of this setting to the given value.
Definition Setting.cc:81
double getDouble(Interpreter &interp) const
Definition TclObject.cc:122
void addListElement(const T &t)
Definition TclObject.hh:133
static_string_view
This file implemented 3 utility functions:
Definition Autofire.cc:11
TclObject makeTclList(Args &&... args)
Definition TclObject.hh:293