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