Debug Draw 3D (and 2D) 1.4.5
Draw 3D debug graphics and 2D overlays with this add-on.
Loading...
Searching...
No Matches
config_2d.h
1#pragma once
2
3#include "common/colors.h"
4#include "utils/compiler.h"
5
6#include <functional>
7
8GODOT_WARNING_DISABLE()
9#include <godot_cpp/classes/font.hpp>
10#include <godot_cpp/classes/ref_counted.hpp>
11GODOT_WARNING_RESTORE()
12using namespace godot;
13
20class DebugDraw2DConfig : public RefCounted {
21 GDCLASS(DebugDraw2DConfig, RefCounted)
22
23public:
27 enum BlockPosition : int {
28 POSITION_LEFT_TOP = 0,
29 POSITION_RIGHT_TOP = 1,
30 POSITION_LEFT_BOTTOM = 2,
31 POSITION_RIGHT_BOTTOM = 3,
32 };
33
34private:
35#pragma region Exposed Parameter Values
36
38 void mark_canvas_dirty();
39
40 // Graphs
41 Vector2i graphs_base_offset = Vector2i(8, 8);
42
43 // TEXT
44 BlockPosition text_block_position = BlockPosition::POSITION_LEFT_TOP;
45 Vector2i text_block_offset = Vector2i(8, 8);
46 Vector2i text_padding = Vector2i(3, 1);
47 real_t text_default_duration = 0.5f;
48 int text_default_size = 12;
49 Color text_foreground_color = Colors::white;
50 Color text_background_color = Colors::gray_bg;
51 Ref<Font> text_custom_font = nullptr;
52
53#pragma endregion // Exposed Parameter Values
54
55 std::function<void()> mark_dirty_func = nullptr;
56
57protected:
59 static void _bind_methods();
60
61public:
64
66 void register_config(std::function<void()> p_mark_dirty);
68 void unregister_config();
69
73 void set_graphs_base_offset(const Vector2i &_offset);
74 Vector2i get_graphs_base_offset() const;
75
80 BlockPosition get_text_block_position() const;
81
85 void set_text_block_offset(const Vector2i &_offset);
86 Vector2i get_text_block_offset() const;
87
91 void set_text_padding(const Vector2i &_padding);
92 Vector2i get_text_padding() const;
93
97 void set_text_default_duration(const real_t &_duration);
98 real_t get_text_default_duration() const;
99
103 void set_text_default_size(const int &_size);
104 int get_text_default_size() const;
105
109 void set_text_foreground_color(const Color &_new_color);
110 Color get_text_foreground_color() const;
111
115 void set_text_background_color(const Color &_new_color);
116 Color get_text_background_color() const;
117
121 void set_text_custom_font(const Ref<Font> &_custom_font);
122 Ref<Font> get_text_custom_font() const;
123};
124
125VARIANT_ENUM_CAST(DebugDraw2DConfig::BlockPosition);
This is a class for storing part of the DebugDraw2D configuration.
Definition config_2d.h:20
void set_text_background_color(const Color &_new_color)
void set_text_default_duration(const real_t &_duration)
void set_text_block_position(BlockPosition _position)
void set_text_padding(const Vector2i &_padding)
void set_graphs_base_offset(const Vector2i &_offset)
void set_text_foreground_color(const Color &_new_color)
void set_text_default_size(const int &_size)
BlockPosition
Definition config_2d.h:27
void set_text_custom_font(const Ref< Font > &_custom_font)
void set_text_block_offset(const Vector2i &_offset)