| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/box_container.h" |
| 34 |
#include "scene/resources/theme.h" |
| 35 |
|
| 36 |
class Button; |
| 37 |
class ColorPickerButton; |
| 38 |
class ColorRect; |
| 39 |
class MarginContainer; |
| 40 |
class ScrollContainer; |
| 41 |
|
| 42 |
class ThemeEditorPreview : public VBoxContainer { |
| 43 |
GDCLASS(ThemeEditorPreview, VBoxContainer); |
| 44 |
|
| 45 |
ScrollContainer *preview_container = nullptr; |
| 46 |
MarginContainer *preview_root = nullptr; |
| 47 |
ColorRect *preview_bg = nullptr; |
| 48 |
MarginContainer *preview_overlay = nullptr; |
| 49 |
Control *picker_overlay = nullptr; |
| 50 |
Control *hovered_control = nullptr; |
| 51 |
|
| 52 |
struct ThemeCache { |
| 53 |
Ref<StyleBox> preview_picker_overlay; |
| 54 |
Color preview_picker_overlay_color; |
| 55 |
Ref<StyleBox> preview_picker_label; |
| 56 |
Ref<Font> preview_picker_font; |
| 57 |
int font_size = 16; |
| 58 |
} theme_cache; |
| 59 |
|
| 60 |
double time_left = 0; |
| 61 |
|
| 62 |
void _propagate_redraw(Control *p_at); |
| 63 |
void _refresh_interval(); |
| 64 |
void _preview_visibility_changed(); |
| 65 |
|
| 66 |
void _picker_button_cbk(); |
| 67 |
Control *_find_hovered_control(Control *p_parent, Vector2 p_mouse_position); |
| 68 |
|
| 69 |
void _draw_picker_overlay(); |
| 70 |
void _gui_input_picker_overlay(const Ref<InputEvent> &p_event); |
| 71 |
void _reset_picker_overlay(); |
| 72 |
|
| 73 |
protected: |
| 74 |
HBoxContainer *preview_toolbar = nullptr; |
| 75 |
MarginContainer *preview_content = nullptr; |
| 76 |
Button *picker_button = nullptr; |
| 77 |
|
| 78 |
void add_preview_overlay(Control *p_overlay); |
| 79 |
|
| 80 |
void _notification(int p_what); |
| 81 |
static void _bind_methods(); |
| 82 |
|
| 83 |
public: |
| 84 |
void set_preview_theme(const Ref<Theme> &p_theme); |
| 85 |
|
| 86 |
ThemeEditorPreview(); |
| 87 |
}; |
| 88 |
|
| 89 |
class DefaultThemeEditorPreview : public ThemeEditorPreview { |
| 90 |
GDCLASS(DefaultThemeEditorPreview, ThemeEditorPreview); |
| 91 |
|
| 92 |
ColorPickerButton *test_color_picker_button = nullptr; |
| 93 |
|
| 94 |
protected: |
| 95 |
void _notification(int p_what); |
| 96 |
|
| 97 |
public: |
| 98 |
DefaultThemeEditorPreview(); |
| 99 |
}; |
| 100 |
|
| 101 |
class SceneThemeEditorPreview : public ThemeEditorPreview { |
| 102 |
GDCLASS(SceneThemeEditorPreview, ThemeEditorPreview); |
| 103 |
|
| 104 |
Ref<PackedScene> loaded_scene; |
| 105 |
|
| 106 |
Button *reload_scene_button = nullptr; |
| 107 |
|
| 108 |
void _reload_scene(); |
| 109 |
|
| 110 |
protected: |
| 111 |
void _notification(int p_what); |
| 112 |
static void _bind_methods(); |
| 113 |
|
| 114 |
public: |
| 115 |
bool set_preview_scene(const String &p_path); |
| 116 |
String get_preview_scene_path() const; |
| 117 |
|
| 118 |
SceneThemeEditorPreview(); |
| 119 |
}; |