1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*************************************************************************/
/* text_control_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEXT_CONTROL_EDITOR_PLUGIN_H
#define TEXT_CONTROL_EDITOR_PLUGIN_H
#include "canvas_item_editor_plugin.h"
#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/gui/color_rect.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/option_button.h"
#include "scene/gui/popup_menu.h"
/*************************************************************************/
class TextControlEditor : public HBoxContainer {
GDCLASS(TextControlEditor, HBoxContainer);
enum FontInfoID {
FONT_INFO_THEME_DEFAULT = 0,
FONT_INFO_USER_CUSTOM = 1,
FONT_INFO_ID = 100,
};
Map<String, Map<String, String>> fonts;
OptionButton *font_list = nullptr;
SpinBox *font_size_list = nullptr;
OptionButton *font_style_list = nullptr;
ColorPickerButton *font_color_picker = nullptr;
SpinBox *outline_size_list = nullptr;
ColorPickerButton *outline_color_picker = nullptr;
Button *clear_formatting = nullptr;
Vector<Control *> edited_controls;
Ref<Font> custom_font;
protected:
void _notification(int p_notification);
static void _bind_methods();
void _find_resources(EditorFileSystemDirectory *p_dir);
void _reload_fonts(const String &p_path);
void _update_fonts_menu();
void _update_styles_menu();
void _update_control();
void _font_selected(int p_id);
void _font_style_selected(int p_id);
void _set_font();
void _font_size_selected(double p_size);
void _outline_size_selected(double p_size);
void _font_color_changed(const Color &p_color);
void _outline_color_changed(const Color &p_color);
void _clear_formatting();
public:
void edit(Object *p_object);
bool handles(Object *p_object) const;
TextControlEditor();
};
/*************************************************************************/
class TextControlEditorPlugin : public EditorPlugin {
GDCLASS(TextControlEditorPlugin, EditorPlugin);
TextControlEditor *text_ctl_editor;
EditorNode *editor;
public:
virtual String get_name() const override { return "TextControlFontEditor"; }
bool has_main_screen() const override { return false; }
virtual void edit(Object *p_object) override;
virtual bool handles(Object *p_object) const override;
virtual void make_visible(bool p_visible) override;
TextControlEditorPlugin(EditorNode *p_node);
};
#endif // TEXT_CONTROL_EDITOR_PLUGIN_H
|