| 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 |
#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 |
}; |