Path: blob/master/editor/scene/gui/theme_editor_preview.h
9906 views
/**************************************************************************/1/* theme_editor_preview.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 "scene/gui/box_container.h"33#include "scene/resources/theme.h"3435class Button;36class ColorPickerButton;37class ColorRect;38class MarginContainer;39class ScrollContainer;4041class ThemeEditorPreview : public VBoxContainer {42GDCLASS(ThemeEditorPreview, VBoxContainer);4344ScrollContainer *preview_container = nullptr;45MarginContainer *preview_root = nullptr;46ColorRect *preview_bg = nullptr;47MarginContainer *preview_overlay = nullptr;48Control *picker_overlay = nullptr;49Control *hovered_control = nullptr;5051struct ThemeCache {52Ref<StyleBox> preview_picker_overlay;53Color preview_picker_overlay_color;54Ref<StyleBox> preview_picker_label;55Ref<Font> preview_picker_font;56int font_size = 16;57} theme_cache;5859double time_left = 0;6061void _propagate_redraw(Control *p_at);62void _refresh_interval();63void _preview_visibility_changed();6465void _picker_button_cbk();66Control *_find_hovered_control(Control *p_parent, Vector2 p_mouse_position);6768void _draw_picker_overlay();69void _gui_input_picker_overlay(const Ref<InputEvent> &p_event);70void _reset_picker_overlay();7172protected:73HBoxContainer *preview_toolbar = nullptr;74MarginContainer *preview_content = nullptr;75Button *picker_button = nullptr;7677void add_preview_overlay(Control *p_overlay);7879void _notification(int p_what);80static void _bind_methods();8182public:83void set_preview_theme(const Ref<Theme> &p_theme);8485ThemeEditorPreview();86};8788class DefaultThemeEditorPreview : public ThemeEditorPreview {89GDCLASS(DefaultThemeEditorPreview, ThemeEditorPreview);9091ColorPickerButton *test_color_picker_button = nullptr;9293protected:94void _notification(int p_what);9596public:97DefaultThemeEditorPreview();98};99100class SceneThemeEditorPreview : public ThemeEditorPreview {101GDCLASS(SceneThemeEditorPreview, ThemeEditorPreview);102103Ref<PackedScene> loaded_scene;104105Button *reload_scene_button = nullptr;106107void _reload_scene();108109protected:110void _notification(int p_what);111static void _bind_methods();112113public:114bool set_preview_scene(const String &p_path);115String get_preview_scene_path() const;116117SceneThemeEditorPreview();118};119120121