| 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 "editor/themes/editor_theme.h" |
| 34 |
|
| 35 |
class StyleBoxFlat; |
| 36 |
class StyleBoxLine; |
| 37 |
class StyleBoxTexture; |
| 38 |
|
| 39 |
class EditorThemeManager { |
| 40 |
static int benchmark_run; |
| 41 |
static inline bool outdated_cache = false; |
| 42 |
static inline bool outdated_cache_dirty = true; |
| 43 |
|
| 44 |
static String get_benchmark_key(); |
| 45 |
|
| 46 |
enum ColorMode { |
| 47 |
AUTO_COLOR, |
| 48 |
DARK_COLOR, |
| 49 |
LIGHT_COLOR, |
| 50 |
}; |
| 51 |
|
| 52 |
public: |
| 53 |
struct ThemeConfiguration { |
| 54 |
|
| 55 |
|
| 56 |
String style; |
| 57 |
String preset; |
| 58 |
String spacing_preset; |
| 59 |
|
| 60 |
Color base_color; |
| 61 |
Color accent_color; |
| 62 |
float contrast = 1.0; |
| 63 |
float icon_saturation = 1.0; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
int base_spacing = 4; |
| 68 |
int extra_spacing = 0; |
| 69 |
Size2 dialogs_buttons_min_size = Size2(105, 34); |
| 70 |
int border_width = 0; |
| 71 |
int corner_radius = 3; |
| 72 |
|
| 73 |
bool draw_extra_borders = false; |
| 74 |
int draw_relationship_lines; |
| 75 |
float relationship_line_opacity = 1.0; |
| 76 |
int thumb_size = 16; |
| 77 |
int class_icon_size = 16; |
| 78 |
bool enable_touch_optimizations = false; |
| 79 |
float gizmo_handle_scale = 1.0; |
| 80 |
int inspector_property_height = 28; |
| 81 |
float subresource_hue_tint = 0.0; |
| 82 |
float dragging_hover_wait_msec = 0; |
| 83 |
|
| 84 |
|
| 85 |
const float default_icon_saturation = 2.0; |
| 86 |
const int default_relationship_lines = RELATIONSHIP_SELECTED_ONLY; |
| 87 |
const float default_contrast = 0.3; |
| 88 |
const int default_corner_radius = 4; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
bool dark_theme = false; |
| 93 |
bool dark_icon_and_font = false; |
| 94 |
|
| 95 |
int base_margin = 4; |
| 96 |
int increased_margin = 4; |
| 97 |
int separation_margin = 4; |
| 98 |
int popup_margin = 12; |
| 99 |
int window_border_margin = 8; |
| 100 |
int top_bar_separation = 8; |
| 101 |
int forced_even_separation = 0; |
| 102 |
|
| 103 |
Color mono_color; |
| 104 |
Color mono_color_font; |
| 105 |
Color mono_color_inv; |
| 106 |
Color dark_color_1; |
| 107 |
Color dark_color_2; |
| 108 |
Color dark_color_3; |
| 109 |
Color contrast_color_1; |
| 110 |
Color contrast_color_2; |
| 111 |
Color highlight_color; |
| 112 |
Color highlight_disabled_color; |
| 113 |
Color success_color; |
| 114 |
Color warning_color; |
| 115 |
Color error_color; |
| 116 |
Color extra_border_color_1; |
| 117 |
Color extra_border_color_2; |
| 118 |
|
| 119 |
Color font_color; |
| 120 |
Color font_secondary_color; |
| 121 |
Color font_focus_color; |
| 122 |
Color font_hover_color; |
| 123 |
Color font_pressed_color; |
| 124 |
Color font_hover_pressed_color; |
| 125 |
Color font_disabled_color; |
| 126 |
Color font_readonly_color; |
| 127 |
Color font_placeholder_color; |
| 128 |
Color font_outline_color; |
| 129 |
|
| 130 |
Color font_dark_background_color; |
| 131 |
Color font_dark_background_focus_color; |
| 132 |
Color font_dark_background_hover_color; |
| 133 |
Color font_dark_background_pressed_color; |
| 134 |
Color font_dark_background_hover_pressed_color; |
| 135 |
|
| 136 |
Color icon_normal_color; |
| 137 |
Color icon_secondary_color; |
| 138 |
Color icon_focus_color; |
| 139 |
Color icon_hover_color; |
| 140 |
Color icon_pressed_color; |
| 141 |
Color icon_disabled_color; |
| 142 |
|
| 143 |
Color surface_popup_color; |
| 144 |
Color surface_lowest_color; |
| 145 |
Color surface_lower_color; |
| 146 |
Color surface_low_color; |
| 147 |
Color surface_base_color; |
| 148 |
Color surface_high_color; |
| 149 |
Color surface_higher_color; |
| 150 |
Color surface_highest_color; |
| 151 |
|
| 152 |
Color button_normal_color; |
| 153 |
Color button_hover_color; |
| 154 |
Color button_pressed_color; |
| 155 |
Color button_disabled_color; |
| 156 |
Color button_border_normal_color; |
| 157 |
Color button_border_hover_color; |
| 158 |
Color button_border_pressed_color; |
| 159 |
|
| 160 |
Color flat_button_pressed_color; |
| 161 |
Color flat_button_hover_pressed_color; |
| 162 |
Color flat_button_hover_color; |
| 163 |
|
| 164 |
Color shadow_color; |
| 165 |
Color selection_color; |
| 166 |
Color disabled_border_color; |
| 167 |
Color disabled_bg_color; |
| 168 |
Color separator_color; |
| 169 |
|
| 170 |
Ref<StyleBoxFlat> base_style; |
| 171 |
Ref<StyleBoxFlat> focus_style; |
| 172 |
Ref<StyleBoxEmpty> base_empty_style; |
| 173 |
Ref<StyleBoxEmpty> base_empty_wide_style; |
| 174 |
|
| 175 |
Ref<StyleBoxFlat> button_style; |
| 176 |
Ref<StyleBoxFlat> button_style_disabled; |
| 177 |
Ref<StyleBoxFlat> button_style_focus; |
| 178 |
Ref<StyleBoxFlat> button_style_pressed; |
| 179 |
Ref<StyleBoxFlat> button_style_hover; |
| 180 |
|
| 181 |
Ref<StyleBoxFlat> flat_button; |
| 182 |
Ref<StyleBoxFlat> flat_button_pressed; |
| 183 |
Ref<StyleBoxFlat> flat_button_hover_pressed; |
| 184 |
Ref<StyleBoxFlat> flat_button_hover; |
| 185 |
|
| 186 |
Ref<StyleBoxFlat> popup_style; |
| 187 |
Ref<StyleBoxFlat> popup_border_style; |
| 188 |
Ref<StyleBoxFlat> popup_panel_style; |
| 189 |
Ref<StyleBoxFlat> window_style; |
| 190 |
Ref<StyleBoxFlat> window_complex_style; |
| 191 |
Ref<StyleBoxFlat> dialog_style; |
| 192 |
Ref<StyleBoxFlat> panel_container_style; |
| 193 |
Ref<StyleBoxFlat> content_panel_style; |
| 194 |
Ref<StyleBoxFlat> tree_panel_style; |
| 195 |
Ref<StyleBoxFlat> tab_container_style; |
| 196 |
Ref<StyleBoxFlat> foreground_panel; |
| 197 |
|
| 198 |
Vector2 widget_margin; |
| 199 |
|
| 200 |
uint32_t hash(); |
| 201 |
uint32_t hash_fonts(); |
| 202 |
uint32_t hash_icons(); |
| 203 |
}; |
| 204 |
|
| 205 |
enum RelationshipLinesMode { |
| 206 |
RELATIONSHIP_NONE, |
| 207 |
RELATIONSHIP_SELECTED_ONLY, |
| 208 |
RELATIONSHIP_ALL, |
| 209 |
}; |
| 210 |
|
| 211 |
private: |
| 212 |
static Ref<EditorTheme> _create_base_theme(const Ref<EditorTheme> &p_old_theme = nullptr); |
| 213 |
static ThemeConfiguration _create_theme_config(); |
| 214 |
|
| 215 |
static void _populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config); |
| 216 |
static void _populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config); |
| 217 |
|
| 218 |
static void _reset_dirty_flag(); |
| 219 |
|
| 220 |
public: |
| 221 |
static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, int p_corner_width = 0); |
| 222 |
static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1); |
| 223 |
static Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_bottom, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, bool p_draw_center = true); |
| 224 |
static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, float p_grow_begin = 1, float p_grow_end = 1, bool p_vertical = false); |
| 225 |
|
| 226 |
static Ref<EditorTheme> generate_theme(const Ref<EditorTheme> &p_old_theme = nullptr); |
| 227 |
static bool is_generated_theme_outdated(); |
| 228 |
|
| 229 |
static bool is_dark_theme(); |
| 230 |
static bool is_dark_icon_and_font(); |
| 231 |
|
| 232 |
static void initialize(); |
| 233 |
static void finalize(); |
| 234 |
}; |