Debian Codegraph @

scene/gui/flow_container.h

raw symbols SCIP
1 /**************************************************************************/
2 /* flow_container.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/container.h"
34
35 class FlowContainer : public Container {
36 GDCLASS(FlowContainer, Container);
37
38 public:
39 enum AlignmentMode {
40 ALIGNMENT_BEGIN,
41 ALIGNMENT_CENTER,
42 ALIGNMENT_END
43 };
44 enum LastWrapAlignmentMode {
45 LAST_WRAP_ALIGNMENT_INHERIT,
46 LAST_WRAP_ALIGNMENT_BEGIN,
47 LAST_WRAP_ALIGNMENT_CENTER,
48 LAST_WRAP_ALIGNMENT_END
49 };
50
51 private:
52 int cached_size = 0;
53 int cached_line_count = 0;
54 int cached_line_max_child_count = 0;
55
56 bool vertical = false;
57 bool reverse_fill = false;
58 AlignmentMode alignment = ALIGNMENT_BEGIN;
59 LastWrapAlignmentMode last_wrap_alignment = LAST_WRAP_ALIGNMENT_INHERIT;
60
61 struct ThemeCache {
62 int h_separation = 0;
63 int v_separation = 0;
64 } theme_cache;
65
66 void _resort();
67
68 protected:
69 bool is_fixed = false;
70
71 void _notification(int p_what);
72 void _validate_property(PropertyInfo &p_property) const;
73 static void _bind_methods();
74
75 public:
76 int get_line_count() const;
77 int get_line_max_child_count() const;
78
79 void set_alignment(AlignmentMode p_alignment);
80 AlignmentMode get_alignment() const;
81
82 void set_last_wrap_alignment(LastWrapAlignmentMode p_last_wrap_alignment);
83 LastWrapAlignmentMode get_last_wrap_alignment() const;
84
85 void set_vertical(bool p_vertical);
86 bool is_vertical() const;
87
88 void set_reverse_fill(bool p_reverse_fill);
89 bool is_reverse_fill() const;
90
91 virtual Size2 get_minimum_size() const override;
92
93 virtual Vector<int> get_allowed_size_flags_horizontal() const override;
94 virtual Vector<int> get_allowed_size_flags_vertical() const override;
95
96 FlowContainer(bool p_vertical = false);
97 };
98
99 class HFlowContainer : public FlowContainer {
100 GDCLASS(HFlowContainer, FlowContainer);
101
102 public:
103 HFlowContainer() :
104 FlowContainer(false) { is_fixed = true; }
105 };
106
107 class VFlowContainer : public FlowContainer {
108 GDCLASS(VFlowContainer, FlowContainer);
109
110 public:
111 VFlowContainer() :
112 FlowContainer(true) { is_fixed = true; }
113 };
114
115 VARIANT_ENUM_CAST(FlowContainer::AlignmentMode);
116 VARIANT_ENUM_CAST(FlowContainer::LastWrapAlignmentMode);