635b8a1474
This change introduces a new theme configuration struct to be passed to the aforementioned routines to better control reuse of styles and definitions in the generator. Everything not passed and not explicitly shared is scoped so it is not automatically accessible throughout the routine. This should ensure that the decision to share styles is a conscious one. In the future we will try to reduce the number of unique definitions and share most of it. This PR is a stepping stone on this path. This also puts the effort into separating redefinitions of default theme items vs custom types introduced only by the editor. In a few cases where editor-specific definitions need to reference default definitions we simply fetch them from the theme. It's not ideal and hides the dependency a bit, but hopefully these cases will be abstracted properly in due time.
148 lines
5.3 KiB
C++
148 lines
5.3 KiB
C++
/**************************************************************************/
|
|
/* editor_theme_manager.h */
|
|
/**************************************************************************/
|
|
/* This file is part of: */
|
|
/* GODOT ENGINE */
|
|
/* https://godotengine.org */
|
|
/**************************************************************************/
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
/* */
|
|
/* 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 EDITOR_THEME_MANAGER_H
|
|
#define EDITOR_THEME_MANAGER_H
|
|
|
|
#include "scene/resources/style_box_flat.h"
|
|
#include "scene/resources/theme.h"
|
|
|
|
class EditorThemeManager {
|
|
struct ThemeConfiguration {
|
|
// Basic properties.
|
|
|
|
String preset;
|
|
bool dark_theme = false;
|
|
|
|
Color base_color;
|
|
Color accent_color;
|
|
float contrast = 1.0;
|
|
float icon_saturation = 1.0;
|
|
|
|
// Extra properties.
|
|
|
|
float extra_spacing = 0.0;
|
|
int border_width = 0;
|
|
int corner_radius = 3;
|
|
|
|
bool draw_extra_borders = false;
|
|
float relationship_line_opacity = 1.0;
|
|
int thumb_size = 16;
|
|
int class_icon_size = 16;
|
|
bool increase_scrollbar_touch_area = false;
|
|
float gizmo_handle_scale = 1.0;
|
|
int color_picker_button_height = 28;
|
|
|
|
float default_contrast = 1.0;
|
|
|
|
// Generated properties.
|
|
|
|
int base_margin = 4;
|
|
int increased_margin = 4;
|
|
|
|
int popup_margin = 12;
|
|
int window_border_margin = 8;
|
|
int top_bar_separation = 8;
|
|
int forced_even_separation = 0;
|
|
|
|
Color mono_color;
|
|
Color dark_color_1;
|
|
Color dark_color_2;
|
|
Color dark_color_3;
|
|
Color contrast_color_1;
|
|
Color contrast_color_2;
|
|
Color highlight_color;
|
|
Color highlight_disabled_color;
|
|
Color success_color;
|
|
Color warning_color;
|
|
Color error_color;
|
|
Color extra_border_color_1;
|
|
Color extra_border_color_2;
|
|
|
|
Color font_color;
|
|
Color font_focus_color;
|
|
Color font_hover_color;
|
|
Color font_pressed_color;
|
|
Color font_hover_pressed_color;
|
|
Color font_disabled_color;
|
|
Color font_readonly_color;
|
|
Color font_placeholder_color;
|
|
Color font_outline_color;
|
|
|
|
Color icon_normal_color;
|
|
Color icon_focus_color;
|
|
Color icon_hover_color;
|
|
Color icon_pressed_color;
|
|
Color icon_disabled_color;
|
|
|
|
Color shadow_color;
|
|
Color selection_color;
|
|
Color disabled_border_color;
|
|
Color disabled_bg_color;
|
|
Color separator_color;
|
|
|
|
Ref<StyleBoxFlat> base_style;
|
|
Ref<StyleBoxEmpty> base_empty_style;
|
|
|
|
Ref<StyleBoxFlat> button_style;
|
|
Ref<StyleBoxFlat> button_style_disabled;
|
|
Ref<StyleBoxFlat> button_style_focus;
|
|
Ref<StyleBoxFlat> button_style_pressed;
|
|
Ref<StyleBoxFlat> button_style_hover;
|
|
|
|
Ref<StyleBoxFlat> popup_style;
|
|
Ref<StyleBoxFlat> window_style;
|
|
Ref<StyleBoxFlat> dialog_style;
|
|
Ref<StyleBoxFlat> panel_container_style;
|
|
Ref<StyleBoxFlat> content_panel_style;
|
|
Ref<StyleBoxFlat> tree_panel_style;
|
|
|
|
Vector2 widget_margin;
|
|
};
|
|
|
|
static Ref<Theme> _create_base_theme(const Ref<Theme> &p_old_theme = nullptr);
|
|
static ThemeConfiguration _create_theme_config(const Ref<Theme> &p_theme);
|
|
|
|
static void _create_shared_styles(const Ref<Theme> &p_theme, ThemeConfiguration &p_config);
|
|
static void _populate_standard_styles(const Ref<Theme> &p_theme, ThemeConfiguration &p_config);
|
|
static void _populate_editor_styles(const Ref<Theme> &p_theme, ThemeConfiguration &p_config);
|
|
|
|
static void _generate_text_editor_defaults(ThemeConfiguration &p_config);
|
|
static void _populate_text_editor_styles(const Ref<Theme> &p_theme, ThemeConfiguration &p_config);
|
|
|
|
public:
|
|
static Ref<Theme> generate_theme(const Ref<Theme> &p_old_theme = nullptr);
|
|
static bool is_generated_theme_outdated();
|
|
|
|
static void initialize();
|
|
static void finalize();
|
|
};
|
|
|
|
#endif // EDITOR_THEME_MANAGER_H
|