Debian Codegraph @

scene/gui/range.h

raw symbols SCIP
1 /**************************************************************************/
2 /* range.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/gui/control.h"
34
35 class Range : public Control {
36 GDCLASS(Range, Control);
37
38 struct Shared {
39 double val = 0.0;
40 double min = 0.0;
41 double max = 100.0;
42 double step = 1.0;
43 double page = 0.0;
44 bool exp_ratio = false;
45 bool allow_greater = false;
46 bool allow_lesser = false;
47 HashSet<Range *> owners;
48 void emit_value_changed();
49 void emit_changed();
50 void redraw_owners();
51 };
52
53 Shared *shared = nullptr;
54
55 void _ref_shared(Shared *p_shared);
56 void _unref_shared();
57
58 void _share(Node *p_range);
59
60 void _value_changed_notify();
61 void _changed_notify();
62 void _set_value_no_signal(double p_val);
63
64 protected:
65 static double _snapped_r128(double p_value, double p_step);
66 double _calc_value(double p_val, double p_step) const;
67 virtual void _value_changed(double p_value);
68 void _notify_shared_value_changed() { shared->emit_value_changed(); }
69 void _notification(int p_what);
70
71 static void _bind_methods();
72
73 void _accessibility_action_inc(const Variant &p_data);
74 void _accessibility_action_dec(const Variant &p_data);
75 void _accessibility_action_set_value(const Variant &p_data);
76
77 bool _rounded_values = false;
78
79 GDVIRTUAL1(_value_changed, double)
80
81 public:
82 void set_value(double p_val);
83 void set_value_no_signal(double p_val);
84 void set_min(double p_min);
85 void set_max(double p_max);
86 void set_step(double p_step);
87 void set_page(double p_page);
88 void set_as_ratio(double p_value);
89
90 double get_value() const;
91 double get_min() const;
92 double get_max() const;
93 double get_step() const;
94 double get_page() const;
95 double get_as_ratio() const;
96
97 void set_use_rounded_values(bool p_enable);
98 bool is_using_rounded_values() const;
99
100 void set_exp_ratio(bool p_enable);
101 bool is_ratio_exp() const;
102
103 void set_allow_greater(bool p_allow);
104 bool is_greater_allowed() const;
105
106 void set_allow_lesser(bool p_allow);
107 bool is_lesser_allowed() const;
108
109 void share(Range *p_range);
110 void unshare();
111
112 PackedStringArray get_configuration_warnings() const override;
113
114 Range();
115 ~Range();
116 };