Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/scene/gui/graph_frame.h
9896 views
1
/**************************************************************************/
2
/* graph_frame.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/graph_element.h"
34
35
class HBoxContainer;
36
37
class GraphFrame : public GraphElement {
38
GDCLASS(GraphFrame, GraphElement);
39
40
struct _MinSizeCache {
41
int min_size = 0;
42
bool will_stretch = false;
43
int final_size = 0;
44
};
45
46
struct ThemeCache {
47
Ref<StyleBox> panel;
48
Ref<StyleBox> panel_selected;
49
Ref<StyleBox> titlebar;
50
Ref<StyleBox> titlebar_selected;
51
52
Ref<Texture2D> resizer;
53
Color resizer_color;
54
} theme_cache;
55
56
private:
57
String title;
58
59
HBoxContainer *titlebar_hbox = nullptr;
60
Label *title_label = nullptr;
61
62
bool autoshrink_enabled = true;
63
int autoshrink_margin = 40;
64
int drag_margin = 16;
65
66
bool tint_color_enabled = false;
67
Color tint_color = Color(0.3, 0.3, 0.3, 0.75);
68
69
protected:
70
virtual void gui_input(const Ref<InputEvent> &p_event) override;
71
virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
72
73
void _notification(int p_what);
74
static void _bind_methods();
75
76
void _validate_property(PropertyInfo &p_property) const;
77
78
virtual void _resort() override;
79
80
public:
81
void set_title(const String &p_title);
82
String get_title() const;
83
84
void set_autoshrink_enabled(bool p_enable);
85
bool is_autoshrink_enabled() const;
86
87
void set_autoshrink_margin(const int &p_margin);
88
int get_autoshrink_margin() const;
89
90
HBoxContainer *get_titlebar_hbox();
91
Size2 get_titlebar_size() const;
92
93
void set_drag_margin(int p_margin);
94
int get_drag_margin() const;
95
96
void set_tint_color_enabled(bool p_enable);
97
bool is_tint_color_enabled() const;
98
99
void set_tint_color(const Color &p_tint_color);
100
Color get_tint_color() const;
101
102
virtual bool has_point(const Point2 &p_point) const override;
103
virtual Size2 get_minimum_size() const override;
104
105
GraphFrame();
106
};
107
108