NumberInput.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rtc/gui/elements.h>
8 
9 namespace mc_rtc::gui
10 {
11 
12 namespace details
13 {
14 
16 template<typename GetT, typename SetT>
17 struct NumberInputImpl : public CommonInputImpl<GetT, SetT>
18 {
19  static constexpr auto type = Elements::NumberInput;
20 
21  NumberInputImpl(const std::string & name, GetT get_fn, SetT set_fn)
22  : CommonInputImpl<GetT, SetT>(name, get_fn, set_fn)
23  {
24  }
25 
28 };
29 
30 } // namespace details
31 
33 template<typename GetT, typename SetT>
34 auto NumberInput(const std::string & name, GetT get_fn, SetT set_fn)
35 {
36  return details::NumberInputImpl(name, get_fn, set_fn);
37 }
38 
40 template<typename T>
41 auto NumberInput(const std::string & name, T & value)
42 {
43  return details::NumberInputImpl(name, details::read(value), details::write(value));
44 }
45 
46 } // namespace mc_rtc::gui
mc_rtc::gui::NumberInput
auto NumberInput(const std::string &name, GetT get_fn, SetT set_fn)
Definition: NumberInput.h:34
mc_rtc::gui::details::NumberInputImpl::NumberInputImpl
NumberInputImpl(const std::string &name, GetT get_fn, SetT set_fn)
Definition: NumberInput.h:21
mc_rtc::gui::details::NumberInputImpl::NumberInputImpl
NumberInputImpl()
Definition: NumberInput.h:27
mc_rtc::gui::Elements::NumberInput
@ NumberInput
mc_rtc::gui::details::NumberInputImpl::type
static constexpr auto type
Definition: NumberInput.h:19
mc_rtc::gui::details::read
auto read(const T &&value)
Definition: traits.h:188
elements.h
mc_rtc::gui::details::write
auto write(T &value)
Definition: traits.h:224
mc_rtc::gui::details::NumberInputImpl
Definition: NumberInput.h:17
mc_rtc::gui::CommonInputImpl
Definition: elements.h:166
mc_rtc::gui
Definition: Observer.h:15
mc_rtc::gui::Element::name
const std::string & name() const
Definition: elements.h:61