2021-10-26 08:40:11 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* text_control_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-03 21:27:34 +01:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2021-10-26 08:40:11 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef TEXT_CONTROL_EDITOR_PLUGIN_H
|
|
|
|
#define TEXT_CONTROL_EDITOR_PLUGIN_H
|
|
|
|
|
|
|
|
#include "canvas_item_editor_plugin.h"
|
|
|
|
#include "editor/editor_file_system.h"
|
|
|
|
#include "editor/editor_inspector.h"
|
|
|
|
#include "editor/editor_plugin.h"
|
2022-02-12 02:46:22 +01:00
|
|
|
#include "scene/gui/color_picker.h"
|
2021-10-26 08:40:11 +02:00
|
|
|
#include "scene/gui/color_rect.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
#include "scene/gui/option_button.h"
|
|
|
|
#include "scene/gui/popup_menu.h"
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
class TextControlEditor : public HBoxContainer {
|
|
|
|
GDCLASS(TextControlEditor, HBoxContainer);
|
|
|
|
|
|
|
|
enum FontInfoID {
|
|
|
|
FONT_INFO_THEME_DEFAULT = 0,
|
|
|
|
FONT_INFO_USER_CUSTOM = 1,
|
|
|
|
FONT_INFO_ID = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
Map<String, Map<String, String>> fonts;
|
|
|
|
|
|
|
|
OptionButton *font_list = nullptr;
|
|
|
|
SpinBox *font_size_list = nullptr;
|
|
|
|
OptionButton *font_style_list = nullptr;
|
|
|
|
ColorPickerButton *font_color_picker = nullptr;
|
|
|
|
SpinBox *outline_size_list = nullptr;
|
|
|
|
ColorPickerButton *outline_color_picker = nullptr;
|
|
|
|
Button *clear_formatting = nullptr;
|
|
|
|
|
2022-02-06 11:32:55 +01:00
|
|
|
Vector<Control *> edited_controls;
|
2021-10-26 08:40:11 +02:00
|
|
|
Ref<Font> custom_font;
|
|
|
|
|
|
|
|
protected:
|
2022-02-16 15:17:55 +01:00
|
|
|
void _notification(int p_what);
|
2021-11-26 14:05:35 +01:00
|
|
|
static void _bind_methods();
|
2021-10-26 08:40:11 +02:00
|
|
|
|
|
|
|
void _find_resources(EditorFileSystemDirectory *p_dir);
|
|
|
|
void _reload_fonts(const String &p_path);
|
|
|
|
|
|
|
|
void _update_fonts_menu();
|
|
|
|
void _update_styles_menu();
|
|
|
|
void _update_control();
|
|
|
|
|
|
|
|
void _font_selected(int p_id);
|
|
|
|
void _font_style_selected(int p_id);
|
|
|
|
void _set_font();
|
|
|
|
|
|
|
|
void _font_size_selected(double p_size);
|
|
|
|
void _outline_size_selected(double p_size);
|
|
|
|
|
|
|
|
void _font_color_changed(const Color &p_color);
|
|
|
|
void _outline_color_changed(const Color &p_color);
|
|
|
|
|
|
|
|
void _clear_formatting();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void edit(Object *p_object);
|
|
|
|
bool handles(Object *p_object) const;
|
|
|
|
|
|
|
|
TextControlEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
class TextControlEditorPlugin : public EditorPlugin {
|
|
|
|
GDCLASS(TextControlEditorPlugin, EditorPlugin);
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
TextControlEditor *text_ctl_editor = nullptr;
|
2021-10-26 08:40:11 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String get_name() const override { return "TextControlFontEditor"; }
|
|
|
|
bool has_main_screen() const override { return false; }
|
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
|
|
|
|
2022-01-27 10:36:51 +01:00
|
|
|
TextControlEditorPlugin();
|
2021-10-26 08:40:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TEXT_CONTROL_EDITOR_PLUGIN_H
|