dynamic_font_import_settings.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #ifndef DYNAMIC_FONT_IMPORT_SETTINGS_H
  31. #define DYNAMIC_FONT_IMPORT_SETTINGS_H
  32. #include "editor/import/resource_importer_dynamic_font.h"
  33. #include "scene/gui/dialogs.h"
  34. #include "scene/gui/item_list.h"
  35. #include "scene/gui/option_button.h"
  36. #include "scene/gui/split_container.h"
  37. #include "scene/gui/subviewport_container.h"
  38. #include "scene/gui/tab_container.h"
  39. #include "scene/gui/text_edit.h"
  40. #include "scene/gui/tree.h"
  41. #include "scene/resources/font.h"
  42. #include "servers/text_server.h"
  43. class DynamicFontImportSettingsData;
  44. class EditorFileDialog;
  45. class EditorInspector;
  46. class EditorLocaleDialog;
  47. class DynamicFontImportSettings : public ConfirmationDialog {
  48. GDCLASS(DynamicFontImportSettings, ConfirmationDialog)
  49. friend class DynamicFontImportSettingsData;
  50. enum ItemButton {
  51. BUTTON_ADD_VAR,
  52. BUTTON_REMOVE_VAR,
  53. };
  54. static DynamicFontImportSettings *singleton;
  55. String base_path;
  56. Ref<DynamicFontImportSettingsData> import_settings_data;
  57. List<ResourceImporter::ImportOption> options_variations;
  58. List<ResourceImporter::ImportOption> options_general;
  59. EditorLocaleDialog *locale_select = nullptr;
  60. Vector<String> script_codes;
  61. // Root layout
  62. Label *label_warn = nullptr;
  63. TabContainer *main_pages = nullptr;
  64. // Page 1 layout: Rendering Options
  65. Label *page1_description = nullptr;
  66. Label *font_preview_label = nullptr;
  67. EditorInspector *inspector_general = nullptr;
  68. void _main_prop_changed(const String &p_edited_property);
  69. // Page 2 layout: Configurations
  70. Label *page2_description = nullptr;
  71. Label *label_vars = nullptr;
  72. Button *add_var = nullptr;
  73. Tree *vars_list = nullptr;
  74. TreeItem *vars_list_root = nullptr;
  75. EditorInspector *inspector_vars = nullptr;
  76. void _variation_add();
  77. void _variation_selected();
  78. void _variation_remove(Object *p_item, int p_column, int p_id);
  79. void _variation_changed(const String &p_edited_property);
  80. void _variations_validate();
  81. // Page 3 layout: Text to select glyphs
  82. Label *page3_description = nullptr;
  83. Label *label_glyphs = nullptr;
  84. TextEdit *text_edit = nullptr;
  85. LineEdit *ftr_edit = nullptr;
  86. LineEdit *lang_edit = nullptr;
  87. void _change_text_opts();
  88. void _glyph_text_selected();
  89. void _glyph_clear();
  90. // Page 4 layout: Character map
  91. Label *page4_description = nullptr;
  92. Tree *glyph_table = nullptr;
  93. Tree *glyph_tree = nullptr;
  94. TreeItem *glyph_root = nullptr;
  95. void _glyph_selected();
  96. void _range_edited();
  97. void _range_selected();
  98. void _edit_range(int32_t p_start, int32_t p_end);
  99. bool _char_update(int32_t p_char);
  100. void _range_update(int32_t p_start, int32_t p_end);
  101. // Page 5 layout: Metadata override
  102. Label *page5_description = nullptr;
  103. Button *add_lang = nullptr;
  104. Button *add_script = nullptr;
  105. Button *add_ot = nullptr;
  106. PopupMenu *menu_scripts = nullptr;
  107. PopupMenu *menu_ot = nullptr;
  108. PopupMenu *menu_ot_ss = nullptr;
  109. PopupMenu *menu_ot_cv = nullptr;
  110. PopupMenu *menu_ot_cu = nullptr;
  111. Tree *lang_list = nullptr;
  112. TreeItem *lang_list_root = nullptr;
  113. Label *label_langs = nullptr;
  114. Tree *script_list = nullptr;
  115. TreeItem *script_list_root = nullptr;
  116. Label *label_script = nullptr;
  117. Tree *ot_list = nullptr;
  118. TreeItem *ot_list_root = nullptr;
  119. Label *label_ot = nullptr;
  120. void _lang_add();
  121. void _lang_add_item(const String &p_locale);
  122. void _lang_remove(Object *p_item, int p_column, int p_id);
  123. void _script_add();
  124. void _script_add_item(int p_option);
  125. void _script_remove(Object *p_item, int p_column, int p_id);
  126. void _ot_add();
  127. void _ot_add_item(int p_option);
  128. void _ot_remove(Object *p_item, int p_column, int p_id);
  129. // Common
  130. void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name);
  131. Ref<Font> font_preview;
  132. Ref<Font> font_main;
  133. Set<char32_t> selected_chars;
  134. Set<int32_t> selected_glyphs;
  135. void _re_import();
  136. String _pad_zeros(const String &p_hex) const;
  137. protected:
  138. void _notification(int p_what);
  139. public:
  140. void open_settings(const String &p_path);
  141. static DynamicFontImportSettings *get_singleton();
  142. DynamicFontImportSettings();
  143. };
  144. #endif // DYNAMIC_FONT_IMPORT_SETTINGS_H