Debug Draw 3D (and 2D) 1.5.0
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 // TEXT
41 BlockPosition text_block_position = BlockPosition::POSITION_LEFT_TOP;
42 Vector2i text_block_offset = Vector2i(8, 8);
43 Vector2i text_padding = Vector2i(3, 1);
44 real_t text_default_duration = 0.5f;
45 int text_default_size = 12;
46 Color text_foreground_color = Colors::white;
47 Color text_background_color = Colors::gray_bg;
48 Ref<Font> text_custom_font = nullptr;
49
50#pragma endregion // Exposed Parameter Values
51
52 std::function<void()> mark_dirty_func = nullptr;
53
54protected:
56 static void _bind_methods();
57
58public:
61
63 void register_config(std::function<void()> p_mark_dirty);
65 void unregister_config();
66
71 BlockPosition get_text_block_position() const;
72
76 void set_text_block_offset(const Vector2i &_offset);
77 Vector2i get_text_block_offset() const;
78
82 void set_text_padding(const Vector2i &_padding);
83 Vector2i get_text_padding() const;
84
88 void set_text_default_duration(const real_t &_duration);
89 real_t get_text_default_duration() const;
90
94 void set_text_default_size(const int &_size);
95 int get_text_default_size() const;
96
100 void set_text_foreground_color(const Color &_new_color);
101 Color get_text_foreground_color() const;
102
106 void set_text_background_color(const Color &_new_color);
107 Color get_text_background_color() const;
108
112 void set_text_custom_font(const Ref<Font> &_custom_font);
113 Ref<Font> get_text_custom_font() const;
114};
115
116VARIANT_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_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)