supertux
control_textbox_float.hpp
1 // SuperTux
2 // Copyright (C) 2020 A. Semphris <semphris@protonmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_FLOAT_HPP
18 #define HEADER_SUPERTUX_INTERFACE_CONTROL_TEXTBOX_FLOAT_HPP
19 
20 #include "interface/control_textbox.hpp"
21 
23 {
24 public:
26 
27  virtual void update(float dt_sec) override;
28 
29  float get_value() const { return *m_value; }
30  void set_value(float value) { *m_value = value; revert_value(); }
36  void bind_value(float* value) { m_value = value; revert_value(); }
37 
38 protected:
39  virtual bool parse_value(bool call_on_change = true) override;
40  virtual void revert_value() override;
41 
42 public:
55 
56 private:
57  float* m_value;
58 
59 private:
61  ControlTextboxFloat& operator=(const ControlTextboxFloat&) = delete;
62 };
63 
64 #endif
65 
66 /* EOF */
Definition: control_textbox.hpp:26
virtual void revert_value() override
Reverts the contents of the char vector to the value of the member variable.
Definition: control_textbox_float.cpp:81
Definition: control_textbox_float.hpp:22
bool(* m_validate_float)(ControlTextboxFloat *, float)
Optional, a function to validate the float.
Definition: control_textbox_float.hpp:54
virtual bool parse_value(bool call_on_change=true) override
Transfers the string into the binded variable, if any.
Definition: control_textbox_float.cpp:38
void bind_value(float *value)
Binds a float to this textbox.
Definition: control_textbox_float.hpp:36