Debian Codegraph @

editor/import/dynamic_font_import_settings.h

raw symbols SCIP
1 /**************************************************************************/
2 /* dynamic_font_import_settings.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 "core/io/resource_importer.h"
34
35 #include "scene/gui/dialogs.h"
36 #include "scene/gui/tab_container.h"
37 #include "scene/gui/text_edit.h"
38 #include "scene/gui/tree.h"
39 #include "scene/resources/font.h"
40
41 class DynamicFontImportSettingsDialog;
42
43 class DynamicFontImportSettingsData : public RefCounted {
44 GDCLASS(DynamicFontImportSettingsData, RefCounted)
45 friend class DynamicFontImportSettingsDialog;
46
47 HashMap<StringName, Variant> settings;
48 HashMap<StringName, Variant> defaults;
49 List<ResourceImporter::ImportOption> options;
50 DynamicFontImportSettingsDialog *owner = nullptr;
51
52 HashSet<char32_t> selected_chars;
53 HashSet<int32_t> selected_glyphs;
54
55 Ref<FontFile> fd;
56
57 public:
58 bool _set(const StringName &p_name, const Variant &p_value);
59 bool _get(const StringName &p_name, Variant &r_ret) const;
60 void _get_property_list(List<PropertyInfo> *p_list) const;
61
62 Ref<FontFile> get_font() const;
63 };
64
65 class EditorFileDialog;
66 class EditorInspector;
67 class EditorLocaleDialog;
68
69 class DynamicFontImportSettingsDialog : public ConfirmationDialog {
70 GDCLASS(DynamicFontImportSettingsDialog, ConfirmationDialog)
71 friend class DynamicFontImportSettingsData;
72
73 enum ItemButton {
74 BUTTON_ADD_VAR,
75 BUTTON_REMOVE_VAR,
76 };
77
78 static DynamicFontImportSettingsDialog *singleton;
79
80 String base_path;
81
82 Ref<DynamicFontImportSettingsData> import_settings_data;
83 List<ResourceImporter::ImportOption> options_variations;
84 List<ResourceImporter::ImportOption> options_general;
85
86 bool is_pixel = false;
87
88 // Root layout
89 Label *label_warn = nullptr;
90 TabContainer *main_pages = nullptr;
91
92 // Page 1 layout: Rendering Options
93 Label *page1_description = nullptr;
94 Label *font_name_label = nullptr;
95 Label *font_preview_label = nullptr;
96 EditorInspector *inspector_general = nullptr;
97
98 void _main_prop_changed(const String &p_edited_property);
99
100 // Page 2 layout: Preload Configurations
101 Label *page2_description = nullptr;
102 Label *label_vars = nullptr;
103 Button *add_var = nullptr;
104 Tree *vars_list = nullptr;
105 TreeItem *vars_list_root = nullptr;
106 EditorInspector *inspector_vars = nullptr;
107
108 void _variation_add();
109 void _variation_selected();
110 void _variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
111 void _variation_changed(const String &p_edited_property);
112 void _variations_validate();
113
114 TabContainer *preload_pages = nullptr;
115
116 Label *label_glyphs = nullptr;
117 void _glyph_clear();
118 void _glyph_update_lbl();
119
120 // Page 2.0 layout: Translations
121 Label *page2_0_description = nullptr;
122 Tree *locale_tree = nullptr;
123 TreeItem *locale_root = nullptr;
124 Button *btn_fill_locales = nullptr;
125
126 void _locale_edited();
127 void _process_locales();
128
129 // Page 2.1 layout: Text to select glyphs
130 Label *page2_1_description = nullptr;
131 TextEdit *text_edit = nullptr;
132 EditorInspector *inspector_text = nullptr;
133 Button *btn_fill = nullptr;
134
135 List<ResourceImporter::ImportOption> options_text;
136 Ref<DynamicFontImportSettingsData> text_settings_data;
137
138 void _change_text_opts();
139 void _glyph_text_selected();
140
141 // Page 2.2 layout: Character map
142 Label *page2_2_description = nullptr;
143 Tree *glyph_table = nullptr;
144 Tree *glyph_tree = nullptr;
145 TreeItem *glyph_root = nullptr;
146
147 void _glyph_selected();
148 void _range_edited();
149 void _range_selected();
150 void _edit_range(int32_t p_start, int32_t p_end);
151 bool _char_update(int32_t p_char);
152 void _range_update(int32_t p_start, int32_t p_end);
153
154 // Common
155
156 void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name);
157
158 Ref<FontFile> font_preview;
159 Ref<FontFile> font_main;
160
161 void _re_import();
162
163 String _pad_zeros(const String &p_hex) const;
164
165 protected:
166 void _notification(int p_what);
167
168 public:
169 void open_settings(const String &p_path);
170 static DynamicFontImportSettingsDialog *get_singleton();
171
172 DynamicFontImportSettingsDialog();
173 };