Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/gui/font_config_plugin.h
9902 views
1
/**************************************************************************/
2
/* font_config_plugin.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 "editor/inspector/editor_properties.h"
34
#include "editor/inspector/editor_properties_array_dict.h"
35
#include "editor/plugins/editor_plugin.h"
36
37
/*************************************************************************/
38
39
class EditorPropertyFontMetaObject : public RefCounted {
40
GDCLASS(EditorPropertyFontMetaObject, RefCounted);
41
42
Dictionary dict;
43
44
protected:
45
bool _set(const StringName &p_name, const Variant &p_value);
46
bool _get(const StringName &p_name, Variant &r_ret) const;
47
48
public:
49
void set_dict(const Dictionary &p_dict);
50
Dictionary get_dict();
51
};
52
53
/*************************************************************************/
54
55
class EditorPropertyFontOTObject : public RefCounted {
56
GDCLASS(EditorPropertyFontOTObject, RefCounted);
57
58
Dictionary dict;
59
Dictionary defaults_dict;
60
61
protected:
62
bool _set(const StringName &p_name, const Variant &p_value);
63
bool _get(const StringName &p_name, Variant &r_ret) const;
64
bool _property_can_revert(const StringName &p_name) const;
65
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
66
67
public:
68
void set_dict(const Dictionary &p_dict);
69
Dictionary get_dict();
70
71
void set_defaults(const Dictionary &p_dict);
72
Dictionary get_defaults();
73
};
74
75
/*************************************************************************/
76
77
class EditorPropertyFontMetaOverride : public EditorProperty {
78
GDCLASS(EditorPropertyFontMetaOverride, EditorProperty);
79
80
Ref<EditorPropertyFontMetaObject> object;
81
82
MarginContainer *container = nullptr;
83
VBoxContainer *property_vbox = nullptr;
84
85
Button *edit = nullptr;
86
PopupMenu *menu = nullptr;
87
EditorLocaleDialog *locale_select = nullptr;
88
89
Vector<String> script_codes;
90
91
bool script_editor = false;
92
bool updating = false;
93
int page_length = 20;
94
int page_index = 0;
95
EditorPaginator *paginator = nullptr;
96
97
protected:
98
void _edit_pressed();
99
void _page_changed(int p_page);
100
void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);
101
void _remove(Object *p_button, const String &p_key);
102
void _add_menu();
103
void _add_script(int p_option);
104
void _add_lang(const String &p_locale);
105
void _object_id_selected(const StringName &p_property, ObjectID p_id);
106
107
public:
108
virtual void update_property() override;
109
110
EditorPropertyFontMetaOverride(bool p_script);
111
};
112
113
/*************************************************************************/
114
115
class EditorPropertyOTVariation : public EditorProperty {
116
GDCLASS(EditorPropertyOTVariation, EditorProperty);
117
118
Ref<EditorPropertyFontOTObject> object;
119
120
MarginContainer *container = nullptr;
121
VBoxContainer *property_vbox = nullptr;
122
123
Button *edit = nullptr;
124
125
bool updating = false;
126
int page_length = 20;
127
int page_index = 0;
128
EditorPaginator *paginator = nullptr;
129
130
protected:
131
static void _bind_methods() {}
132
133
void _edit_pressed();
134
void _page_changed(int p_page);
135
void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);
136
void _object_id_selected(const StringName &p_property, ObjectID p_id);
137
138
public:
139
virtual void update_property() override;
140
141
EditorPropertyOTVariation();
142
};
143
144
/*************************************************************************/
145
146
class EditorPropertyOTFeatures : public EditorProperty {
147
GDCLASS(EditorPropertyOTFeatures, EditorProperty);
148
149
enum FeatureGroups {
150
FGRP_STYLISTIC_SET,
151
FGRP_CHARACTER_VARIANT,
152
FGRP_CAPITLS,
153
FGRP_LIGATURES,
154
FGRP_ALTERNATES,
155
FGRP_EAL,
156
FGRP_EAW,
157
FGRP_NUMAL,
158
FGRP_CUSTOM,
159
FGRP_MAX,
160
};
161
162
Ref<EditorPropertyFontOTObject> object;
163
164
MarginContainer *container = nullptr;
165
VBoxContainer *property_vbox = nullptr;
166
167
Button *edit = nullptr;
168
PopupMenu *menu = nullptr;
169
PopupMenu *menu_sub[FGRP_MAX];
170
String group_names[FGRP_MAX];
171
172
bool updating = false;
173
int page_length = 20;
174
int page_index = 0;
175
EditorPaginator *paginator = nullptr;
176
177
protected:
178
void _edit_pressed();
179
void _page_changed(int p_page);
180
void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);
181
void _remove(Object *p_button, int p_key);
182
void _add_menu();
183
void _add_feature(int p_option);
184
void _object_id_selected(const StringName &p_property, ObjectID p_id);
185
186
public:
187
virtual void update_property() override;
188
189
EditorPropertyOTFeatures();
190
};
191
192
/*************************************************************************/
193
194
class EditorInspectorPluginFontVariation : public EditorInspectorPlugin {
195
GDCLASS(EditorInspectorPluginFontVariation, EditorInspectorPlugin);
196
197
public:
198
virtual bool can_handle(Object *p_object) override;
199
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
200
};
201
202
/*************************************************************************/
203
204
class FontPreview : public Control {
205
GDCLASS(FontPreview, Control);
206
207
protected:
208
void _notification(int p_what);
209
static void _bind_methods();
210
211
Ref<Font> prev_font;
212
213
void _preview_changed();
214
215
public:
216
virtual Size2 get_minimum_size() const override;
217
218
void set_data(const Ref<Font> &p_f);
219
};
220
221
/*************************************************************************/
222
223
class EditorInspectorPluginFontPreview : public EditorInspectorPlugin {
224
GDCLASS(EditorInspectorPluginFontPreview, EditorInspectorPlugin);
225
226
public:
227
virtual bool can_handle(Object *p_object) override;
228
virtual void parse_begin(Object *p_object) override;
229
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
230
};
231
232
/*************************************************************************/
233
234
class EditorPropertyFontNamesArray : public EditorPropertyArray {
235
GDCLASS(EditorPropertyFontNamesArray, EditorPropertyArray);
236
237
PopupMenu *menu = nullptr;
238
239
protected:
240
virtual void _add_element() override;
241
242
void _add_font(int p_option);
243
static void _bind_methods() {}
244
245
public:
246
EditorPropertyFontNamesArray();
247
};
248
249
/*************************************************************************/
250
251
class EditorInspectorPluginSystemFont : public EditorInspectorPlugin {
252
GDCLASS(EditorInspectorPluginSystemFont, EditorInspectorPlugin);
253
254
public:
255
virtual bool can_handle(Object *p_object) override;
256
virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;
257
};
258
259
/*************************************************************************/
260
261
class FontEditorPlugin : public EditorPlugin {
262
GDCLASS(FontEditorPlugin, EditorPlugin);
263
264
public:
265
FontEditorPlugin();
266
267
virtual String get_plugin_name() const override { return "Font"; }
268
};
269
270