Path: blob/master/editor/import/dynamic_font_import_settings.h
9898 views
/**************************************************************************/1/* dynamic_font_import_settings.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/io/resource_importer.h"3334#include "scene/gui/dialogs.h"35#include "scene/gui/tab_container.h"36#include "scene/gui/text_edit.h"37#include "scene/gui/tree.h"38#include "scene/resources/font.h"3940class DynamicFontImportSettingsDialog;4142class DynamicFontImportSettingsData : public RefCounted {43GDCLASS(DynamicFontImportSettingsData, RefCounted)44friend class DynamicFontImportSettingsDialog;4546HashMap<StringName, Variant> settings;47HashMap<StringName, Variant> defaults;48List<ResourceImporter::ImportOption> options;49DynamicFontImportSettingsDialog *owner = nullptr;5051HashSet<char32_t> selected_chars;52HashSet<int32_t> selected_glyphs;5354Ref<FontFile> fd;5556public:57bool _set(const StringName &p_name, const Variant &p_value);58bool _get(const StringName &p_name, Variant &r_ret) const;59void _get_property_list(List<PropertyInfo> *p_list) const;6061Ref<FontFile> get_font() const;62};6364class EditorFileDialog;65class EditorInspector;66class EditorLocaleDialog;6768class DynamicFontImportSettingsDialog : public ConfirmationDialog {69GDCLASS(DynamicFontImportSettingsDialog, ConfirmationDialog)70friend class DynamicFontImportSettingsData;7172enum ItemButton {73BUTTON_ADD_VAR,74BUTTON_REMOVE_VAR,75};7677static DynamicFontImportSettingsDialog *singleton;7879String base_path;8081Ref<DynamicFontImportSettingsData> import_settings_data;82List<ResourceImporter::ImportOption> options_variations;83List<ResourceImporter::ImportOption> options_general;8485bool is_pixel = false;8687// Root layout88Label *label_warn = nullptr;89TabContainer *main_pages = nullptr;9091// Page 1 layout: Rendering Options92Label *page1_description = nullptr;93Label *font_name_label = nullptr;94Label *font_preview_label = nullptr;95EditorInspector *inspector_general = nullptr;9697void _main_prop_changed(const String &p_edited_property);9899// Page 2 layout: Preload Configurations100Label *page2_description = nullptr;101Label *label_vars = nullptr;102Button *add_var = nullptr;103Tree *vars_list = nullptr;104TreeItem *vars_list_root = nullptr;105EditorInspector *inspector_vars = nullptr;106107void _variation_add();108void _variation_selected();109void _variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);110void _variation_changed(const String &p_edited_property);111void _variations_validate();112113TabContainer *preload_pages = nullptr;114115Label *label_glyphs = nullptr;116void _glyph_clear();117void _glyph_update_lbl();118119// Page 2.0 layout: Translations120Label *page2_0_description = nullptr;121Tree *locale_tree = nullptr;122TreeItem *locale_root = nullptr;123Button *btn_fill_locales = nullptr;124125void _locale_edited();126void _process_locales();127128// Page 2.1 layout: Text to select glyphs129Label *page2_1_description = nullptr;130TextEdit *text_edit = nullptr;131EditorInspector *inspector_text = nullptr;132Button *btn_fill = nullptr;133134List<ResourceImporter::ImportOption> options_text;135Ref<DynamicFontImportSettingsData> text_settings_data;136137void _change_text_opts();138void _glyph_text_selected();139140// Page 2.2 layout: Character map141Label *page2_2_description = nullptr;142Tree *glyph_table = nullptr;143Tree *glyph_tree = nullptr;144TreeItem *glyph_root = nullptr;145146void _glyph_selected();147void _range_edited();148void _range_selected();149void _edit_range(int32_t p_start, int32_t p_end);150bool _char_update(int32_t p_char);151void _range_update(int32_t p_start, int32_t p_end);152153// Common154155void _add_glyph_range_item(int32_t p_start, int32_t p_end, const String &p_name);156157Ref<FontFile> font_preview;158Ref<FontFile> font_main;159160void _re_import();161162String _pad_zeros(const String &p_hex) const;163164protected:165void _notification(int p_what);166167public:168void open_settings(const String &p_path);169static DynamicFontImportSettingsDialog *get_singleton();170171DynamicFontImportSettingsDialog();172};173174175