Path: blob/master/editor/themes/editor_theme_manager.h
9902 views
/**************************************************************************/1/* editor_theme_manager.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/themes/editor_theme.h"33#include "scene/resources/style_box_flat.h"3435class EditorThemeManager {36static int benchmark_run;37static inline bool outdated_cache = false;38static inline bool outdated_cache_dirty = true;3940static String get_benchmark_key();4142enum ColorMode {43AUTO_COLOR,44DARK_COLOR,45LIGHT_COLOR,46};4748struct ThemeConfiguration {49// Basic properties.5051String preset;52String spacing_preset;5354Color base_color;55Color accent_color;56float contrast = 1.0;57float icon_saturation = 1.0;5859// Extra properties.6061int base_spacing = 4;62int extra_spacing = 0;63Size2 dialogs_buttons_min_size = Size2(105, 34);64int border_width = 0;65int corner_radius = 3;6667bool draw_extra_borders = false;68float relationship_line_opacity = 1.0;69int thumb_size = 16;70int class_icon_size = 16;71bool enable_touch_optimizations = false;72float gizmo_handle_scale = 1.0;73int color_picker_button_height = 28;74float subresource_hue_tint = 0.0;7576float default_contrast = 1.0;7778// Generated properties.7980bool dark_theme = false;8182int base_margin = 4;83int increased_margin = 4;84int separation_margin = 4;85int popup_margin = 12;86int window_border_margin = 8;87int top_bar_separation = 8;88int forced_even_separation = 0;8990Color mono_color;91Color dark_color_1;92Color dark_color_2;93Color dark_color_3;94Color contrast_color_1;95Color contrast_color_2;96Color highlight_color;97Color highlight_disabled_color;98Color success_color;99Color warning_color;100Color error_color;101Color extra_border_color_1;102Color extra_border_color_2;103104Color font_color;105Color font_focus_color;106Color font_hover_color;107Color font_pressed_color;108Color font_hover_pressed_color;109Color font_disabled_color;110Color font_readonly_color;111Color font_placeholder_color;112Color font_outline_color;113114Color icon_normal_color;115Color icon_focus_color;116Color icon_hover_color;117Color icon_pressed_color;118Color icon_disabled_color;119120Color shadow_color;121Color selection_color;122Color disabled_border_color;123Color disabled_bg_color;124Color separator_color;125126Ref<StyleBoxFlat> base_style;127Ref<StyleBoxEmpty> base_empty_style;128129Ref<StyleBoxFlat> button_style;130Ref<StyleBoxFlat> button_style_disabled;131Ref<StyleBoxFlat> button_style_focus;132Ref<StyleBoxFlat> button_style_pressed;133Ref<StyleBoxFlat> button_style_hover;134135Ref<StyleBoxFlat> circle_style_focus;136137Ref<StyleBoxFlat> popup_style;138Ref<StyleBoxFlat> popup_border_style;139Ref<StyleBoxFlat> window_style;140Ref<StyleBoxFlat> dialog_style;141Ref<StyleBoxFlat> panel_container_style;142Ref<StyleBoxFlat> content_panel_style;143Ref<StyleBoxFlat> tree_panel_style;144145Vector2 widget_margin;146147uint32_t hash();148uint32_t hash_fonts();149uint32_t hash_icons();150};151152static Ref<EditorTheme> _create_base_theme(const Ref<EditorTheme> &p_old_theme = nullptr);153static ThemeConfiguration _create_theme_config(const Ref<EditorTheme> &p_theme);154155static void _create_shared_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);156static void _populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);157static void _populate_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);158159static void _populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);160static void _populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config);161162static void _reset_dirty_flag();163164public:165static Ref<EditorTheme> generate_theme(const Ref<EditorTheme> &p_old_theme = nullptr);166static bool is_generated_theme_outdated();167168static bool is_dark_theme();169170static void initialize();171static void finalize();172};173174175