Path: blob/master/editor/scene/gui/font_config_plugin.h
9902 views
/**************************************************************************/1/* font_config_plugin.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 "editor/inspector/editor_properties.h"33#include "editor/inspector/editor_properties_array_dict.h"34#include "editor/plugins/editor_plugin.h"3536/*************************************************************************/3738class EditorPropertyFontMetaObject : public RefCounted {39GDCLASS(EditorPropertyFontMetaObject, RefCounted);4041Dictionary dict;4243protected:44bool _set(const StringName &p_name, const Variant &p_value);45bool _get(const StringName &p_name, Variant &r_ret) const;4647public:48void set_dict(const Dictionary &p_dict);49Dictionary get_dict();50};5152/*************************************************************************/5354class EditorPropertyFontOTObject : public RefCounted {55GDCLASS(EditorPropertyFontOTObject, RefCounted);5657Dictionary dict;58Dictionary defaults_dict;5960protected:61bool _set(const StringName &p_name, const Variant &p_value);62bool _get(const StringName &p_name, Variant &r_ret) const;63bool _property_can_revert(const StringName &p_name) const;64bool _property_get_revert(const StringName &p_name, Variant &r_property) const;6566public:67void set_dict(const Dictionary &p_dict);68Dictionary get_dict();6970void set_defaults(const Dictionary &p_dict);71Dictionary get_defaults();72};7374/*************************************************************************/7576class EditorPropertyFontMetaOverride : public EditorProperty {77GDCLASS(EditorPropertyFontMetaOverride, EditorProperty);7879Ref<EditorPropertyFontMetaObject> object;8081MarginContainer *container = nullptr;82VBoxContainer *property_vbox = nullptr;8384Button *edit = nullptr;85PopupMenu *menu = nullptr;86EditorLocaleDialog *locale_select = nullptr;8788Vector<String> script_codes;8990bool script_editor = false;91bool updating = false;92int page_length = 20;93int page_index = 0;94EditorPaginator *paginator = nullptr;9596protected:97void _edit_pressed();98void _page_changed(int p_page);99void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);100void _remove(Object *p_button, const String &p_key);101void _add_menu();102void _add_script(int p_option);103void _add_lang(const String &p_locale);104void _object_id_selected(const StringName &p_property, ObjectID p_id);105106public:107virtual void update_property() override;108109EditorPropertyFontMetaOverride(bool p_script);110};111112/*************************************************************************/113114class EditorPropertyOTVariation : public EditorProperty {115GDCLASS(EditorPropertyOTVariation, EditorProperty);116117Ref<EditorPropertyFontOTObject> object;118119MarginContainer *container = nullptr;120VBoxContainer *property_vbox = nullptr;121122Button *edit = nullptr;123124bool updating = false;125int page_length = 20;126int page_index = 0;127EditorPaginator *paginator = nullptr;128129protected:130static void _bind_methods() {}131132void _edit_pressed();133void _page_changed(int p_page);134void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);135void _object_id_selected(const StringName &p_property, ObjectID p_id);136137public:138virtual void update_property() override;139140EditorPropertyOTVariation();141};142143/*************************************************************************/144145class EditorPropertyOTFeatures : public EditorProperty {146GDCLASS(EditorPropertyOTFeatures, EditorProperty);147148enum FeatureGroups {149FGRP_STYLISTIC_SET,150FGRP_CHARACTER_VARIANT,151FGRP_CAPITLS,152FGRP_LIGATURES,153FGRP_ALTERNATES,154FGRP_EAL,155FGRP_EAW,156FGRP_NUMAL,157FGRP_CUSTOM,158FGRP_MAX,159};160161Ref<EditorPropertyFontOTObject> object;162163MarginContainer *container = nullptr;164VBoxContainer *property_vbox = nullptr;165166Button *edit = nullptr;167PopupMenu *menu = nullptr;168PopupMenu *menu_sub[FGRP_MAX];169String group_names[FGRP_MAX];170171bool updating = false;172int page_length = 20;173int page_index = 0;174EditorPaginator *paginator = nullptr;175176protected:177void _edit_pressed();178void _page_changed(int p_page);179void _property_changed(const String &p_property, const Variant &p_value, const String &p_name = "", bool p_changing = false);180void _remove(Object *p_button, int p_key);181void _add_menu();182void _add_feature(int p_option);183void _object_id_selected(const StringName &p_property, ObjectID p_id);184185public:186virtual void update_property() override;187188EditorPropertyOTFeatures();189};190191/*************************************************************************/192193class EditorInspectorPluginFontVariation : public EditorInspectorPlugin {194GDCLASS(EditorInspectorPluginFontVariation, EditorInspectorPlugin);195196public:197virtual bool can_handle(Object *p_object) override;198virtual 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;199};200201/*************************************************************************/202203class FontPreview : public Control {204GDCLASS(FontPreview, Control);205206protected:207void _notification(int p_what);208static void _bind_methods();209210Ref<Font> prev_font;211212void _preview_changed();213214public:215virtual Size2 get_minimum_size() const override;216217void set_data(const Ref<Font> &p_f);218};219220/*************************************************************************/221222class EditorInspectorPluginFontPreview : public EditorInspectorPlugin {223GDCLASS(EditorInspectorPluginFontPreview, EditorInspectorPlugin);224225public:226virtual bool can_handle(Object *p_object) override;227virtual void parse_begin(Object *p_object) override;228virtual 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;229};230231/*************************************************************************/232233class EditorPropertyFontNamesArray : public EditorPropertyArray {234GDCLASS(EditorPropertyFontNamesArray, EditorPropertyArray);235236PopupMenu *menu = nullptr;237238protected:239virtual void _add_element() override;240241void _add_font(int p_option);242static void _bind_methods() {}243244public:245EditorPropertyFontNamesArray();246};247248/*************************************************************************/249250class EditorInspectorPluginSystemFont : public EditorInspectorPlugin {251GDCLASS(EditorInspectorPluginSystemFont, EditorInspectorPlugin);252253public:254virtual bool can_handle(Object *p_object) override;255virtual 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;256};257258/*************************************************************************/259260class FontEditorPlugin : public EditorPlugin {261GDCLASS(FontEditorPlugin, EditorPlugin);262263public:264FontEditorPlugin();265266virtual String get_plugin_name() const override { return "Font"; }267};268269270