| 1 | /**************************************************************************/ |
| 2 | /* default_theme.cpp */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #include "default_theme.h" |
| 32 | |
| 33 | #include "core/os/os.h" |
| 34 | #include "default_font.gen.h" |
| 35 | #include "default_theme_icons.gen.h" |
| 36 | #include "scene/resources/font.h" |
| 37 | #include "scene/resources/gradient_texture.h" |
| 38 | #include "scene/resources/image_texture.h" |
| 39 | #include "scene/resources/style_box_flat.h" |
| 40 | #include "scene/resources/style_box_line.h" |
| 41 | #include "scene/resources/theme.h" |
| 42 | #include "scene/theme/theme_db.h" |
| 43 | #include "servers/text_server.h" |
| 44 | |
| 45 | #include "modules/modules_enabled.gen.h" // For svg. |
| 46 | #ifdef MODULE_SVG_ENABLED |
| 47 | #include "modules/svg/image_loader_svg.h" |
| 48 | #endif |
| 49 | |
| 50 | static const int default_font_size = 16; |
| 51 | |
| 52 | static float scale = 1.0; |
| 53 | |
| 54 | static const int default_margin = 4; |
| 55 | static const int default_corner_radius = 3; |
| 56 | |
| 57 | static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = default_margin, float p_margin_top = default_margin, float p_margin_right = default_margin, float p_margin_bottom = default_margin, int p_corner_radius = default_corner_radius, bool p_draw_center = true, int p_border_width = 0) { |
| 58 | Ref<StyleBoxFlat> style(memnew(StyleBoxFlat)); |
| 59 | style->set_bg_color(p_color); |
| 60 | style->set_content_margin_individual(Math::round(p_margin_left * scale), Math::round(p_margin_top * scale), Math::round(p_margin_right * scale), Math::round(p_margin_bottom * scale)); |
| 61 | |
| 62 | style->set_corner_radius_all(Math::round(p_corner_radius * scale)); |
| 63 | style->set_anti_aliased(true); |
| 64 | // Adjust level of detail based on the corners' effective sizes. |
| 65 | style->set_corner_detail(MIN(Math::ceil(1.5 * p_corner_radius), 6) * scale); |
| 66 | |
| 67 | style->set_draw_center(p_draw_center); |
| 68 | style->set_border_width_all(Math::round(p_border_width * scale)); |
| 69 | |
| 70 | return style; |
| 71 | } |
| 72 | |
| 73 | static Ref<StyleBoxFlat> sb_expand(Ref<StyleBoxFlat> p_sbox, float p_left, float p_top, float p_right, float p_bottom) { |
| 74 | p_sbox->set_expand_margin(SIDE_LEFT, Math::round(p_left * scale)); |
| 75 | p_sbox->set_expand_margin(SIDE_TOP, Math::round(p_top * scale)); |
| 76 | p_sbox->set_expand_margin(SIDE_RIGHT, Math::round(p_right * scale)); |
| 77 | p_sbox->set_expand_margin(SIDE_BOTTOM, Math::round(p_bottom * scale)); |
| 78 | return p_sbox; |
| 79 | } |
| 80 | |
| 81 | // See also `editor_generate_icon()` in `editor/editor_themes.cpp`. |
| 82 | static Ref<ImageTexture> generate_icon(int p_index) { |
| 83 | Ref<Image> img = memnew(Image); |
| 84 | |
| 85 | #ifdef MODULE_SVG_ENABLED |
| 86 | // Upsample icon generation only if the scale isn't an integer multiplier. |
| 87 | // Generating upsampled icons is slower, and the benefit is hardly visible |
| 88 | // with integer scales. |
| 89 | const bool upsample = !Math::is_equal_approx(Math::round(scale), scale); |
| 90 | |
| 91 | Error err = ImageLoaderSVG::create_image_from_string(img, default_theme_icons_sources[p_index], scale, upsample, HashMap<Color, Color>()); |
| 92 | ERR_FAIL_COND_V_MSG(err != OK, Ref<ImageTexture>(), "Failed generating icon, unsupported or invalid SVG data in default theme." ); |
| 93 | #else |
| 94 | // If the SVG module is disabled, we can't really display the UI well, but at least we won't crash. |
| 95 | // 16 pixels is used as it's the most common base size for Godot icons. |
| 96 | img = Image::create_empty(Math::round(16 * scale), Math::round(16 * scale), false, Image::FORMAT_RGBA8); |
| 97 | #endif |
| 98 | |
| 99 | return ImageTexture::create_from_image(img); |
| 100 | } |
| 101 | |
| 102 | static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { |
| 103 | Ref<StyleBox> style(memnew(StyleBoxEmpty)); |
| 104 | style->set_content_margin_individual(Math::round(p_margin_left * scale), Math::round(p_margin_top * scale), Math::round(p_margin_right * scale), Math::round(p_margin_bottom * scale)); |
| 105 | return style; |
| 106 | } |
| 107 | |
| 108 | void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &bold_font, const Ref<Font> &bold_italics_font, const Ref<Font> &italics_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale) { |
| 109 | scale = p_scale; |
| 110 | |
| 111 | // Default theme properties. |
| 112 | theme->set_default_font(default_font); |
| 113 | theme->set_default_font_size(Math::round(default_font_size * scale)); |
| 114 | theme->set_default_base_scale(scale); |
| 115 | |
| 116 | // Font colors |
| 117 | const Color control_font_color = Color(0.875, 0.875, 0.875); |
| 118 | const Color control_font_low_color = Color(0.7, 0.7, 0.7); |
| 119 | const Color control_font_lower_color = Color(0.65, 0.65, 0.65); |
| 120 | const Color control_font_hover_color = Color(0.95, 0.95, 0.95); |
| 121 | const Color control_font_focus_color = Color(0.95, 0.95, 0.95); |
| 122 | const Color control_font_disabled_color = control_font_color * Color(1, 1, 1, 0.5); |
| 123 | const Color control_font_placeholder_color = Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.6f); |
| 124 | const Color control_font_pressed_color = Color(1, 1, 1); |
| 125 | const Color control_selection_color = Color(0.5, 0.5, 0.5); |
| 126 | |
| 127 | // StyleBox colors |
| 128 | const Color style_normal_color = Color(0.1, 0.1, 0.1, 0.6); |
| 129 | const Color style_hover_color = Color(0.225, 0.225, 0.225, 0.6); |
| 130 | const Color style_pressed_color = Color(0, 0, 0, 0.6); |
| 131 | const Color style_disabled_color = Color(0.1, 0.1, 0.1, 0.3); |
| 132 | const Color style_focus_color = Color(1, 1, 1, 0.75); |
| 133 | const Color = Color(0.25, 0.25, 0.25, 1); |
| 134 | const Color = Color(0.175, 0.175, 0.175, 1); |
| 135 | const Color = Color(0.4, 0.4, 0.4, 1); |
| 136 | const Color style_selected_color = Color(1, 1, 1, 0.3); |
| 137 | // Don't use a color too bright to keep the percentage readable. |
| 138 | const Color style_progress_color = Color(1, 1, 1, 0.4); |
| 139 | const Color style_separator_color = Color(0.5, 0.5, 0.5); |
| 140 | |
| 141 | // Convert the generated icon sources to a dictionary for easier access. |
| 142 | // Unlike the editor icons, there is no central repository of icons in the Theme resource itself to keep it tidy. |
| 143 | Dictionary icons; |
| 144 | for (int i = 0; i < default_theme_icons_count; i++) { |
| 145 | icons[default_theme_icons_names[i]] = generate_icon(i); |
| 146 | } |
| 147 | |
| 148 | // Panel |
| 149 | theme->set_stylebox("panel" , "Panel" , make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); |
| 150 | |
| 151 | // Button |
| 152 | |
| 153 | const Ref<StyleBoxFlat> button_normal = make_flat_stylebox(style_normal_color); |
| 154 | const Ref<StyleBoxFlat> button_hover = make_flat_stylebox(style_hover_color); |
| 155 | const Ref<StyleBoxFlat> button_pressed = make_flat_stylebox(style_pressed_color); |
| 156 | const Ref<StyleBoxFlat> button_disabled = make_flat_stylebox(style_disabled_color); |
| 157 | Ref<StyleBoxFlat> focus = make_flat_stylebox(style_focus_color, default_margin, default_margin, default_margin, default_margin, default_corner_radius, false, 2); |
| 158 | // Make the focus outline appear to be flush with the buttons it's focusing. |
| 159 | focus->set_expand_margin_all(Math::round(2 * scale)); |
| 160 | |
| 161 | theme->set_stylebox("normal" , "Button" , button_normal); |
| 162 | theme->set_stylebox("hover" , "Button" , button_hover); |
| 163 | theme->set_stylebox("pressed" , "Button" , button_pressed); |
| 164 | theme->set_stylebox("disabled" , "Button" , button_disabled); |
| 165 | theme->set_stylebox("focus" , "Button" , focus); |
| 166 | |
| 167 | theme->set_font("font" , "Button" , Ref<Font>()); |
| 168 | theme->set_font_size("font_size" , "Button" , -1); |
| 169 | theme->set_constant("outline_size" , "Button" , 0); |
| 170 | |
| 171 | theme->set_color("font_color" , "Button" , control_font_color); |
| 172 | theme->set_color("font_pressed_color" , "Button" , control_font_pressed_color); |
| 173 | theme->set_color("font_hover_color" , "Button" , control_font_hover_color); |
| 174 | theme->set_color("font_focus_color" , "Button" , control_font_focus_color); |
| 175 | theme->set_color("font_hover_pressed_color" , "Button" , control_font_pressed_color); |
| 176 | theme->set_color("font_disabled_color" , "Button" , control_font_disabled_color); |
| 177 | theme->set_color("font_outline_color" , "Button" , Color(1, 1, 1)); |
| 178 | |
| 179 | theme->set_color("icon_normal_color" , "Button" , Color(1, 1, 1, 1)); |
| 180 | theme->set_color("icon_pressed_color" , "Button" , Color(1, 1, 1, 1)); |
| 181 | theme->set_color("icon_hover_color" , "Button" , Color(1, 1, 1, 1)); |
| 182 | theme->set_color("icon_hover_pressed_color" , "Button" , Color(1, 1, 1, 1)); |
| 183 | theme->set_color("icon_focus_color" , "Button" , Color(1, 1, 1, 1)); |
| 184 | theme->set_color("icon_disabled_color" , "Button" , Color(1, 1, 1, 0.4)); |
| 185 | |
| 186 | theme->set_constant("h_separation" , "Button" , Math::round(4 * scale)); |
| 187 | theme->set_constant("icon_max_width" , "Button" , 0); |
| 188 | |
| 189 | // MenuBar |
| 190 | theme->set_stylebox("normal" , "MenuBar" , button_normal); |
| 191 | theme->set_stylebox("hover" , "MenuBar" , button_hover); |
| 192 | theme->set_stylebox("pressed" , "MenuBar" , button_pressed); |
| 193 | theme->set_stylebox("disabled" , "MenuBar" , button_disabled); |
| 194 | theme->set_stylebox("focus" , "MenuBar" , focus); |
| 195 | |
| 196 | theme->set_font("font" , "MenuBar" , Ref<Font>()); |
| 197 | theme->set_font_size("font_size" , "MenuBar" , -1); |
| 198 | theme->set_constant("outline_size" , "MenuBar" , 0); |
| 199 | |
| 200 | theme->set_color("font_color" , "MenuBar" , control_font_color); |
| 201 | theme->set_color("font_pressed_color" , "MenuBar" , control_font_pressed_color); |
| 202 | theme->set_color("font_hover_color" , "MenuBar" , control_font_hover_color); |
| 203 | theme->set_color("font_focus_color" , "MenuBar" , control_font_focus_color); |
| 204 | theme->set_color("font_hover_pressed_color" , "MenuBar" , control_font_pressed_color); |
| 205 | theme->set_color("font_disabled_color" , "MenuBar" , control_font_disabled_color); |
| 206 | theme->set_color("font_outline_color" , "MenuBar" , Color(1, 1, 1)); |
| 207 | |
| 208 | theme->set_constant("h_separation" , "MenuBar" , Math::round(4 * scale)); |
| 209 | |
| 210 | // LinkButton |
| 211 | |
| 212 | theme->set_stylebox("focus" , "LinkButton" , focus); |
| 213 | |
| 214 | theme->set_font("font" , "LinkButton" , Ref<Font>()); |
| 215 | theme->set_font_size("font_size" , "LinkButton" , -1); |
| 216 | |
| 217 | theme->set_color("font_color" , "LinkButton" , control_font_color); |
| 218 | theme->set_color("font_pressed_color" , "LinkButton" , control_font_pressed_color); |
| 219 | theme->set_color("font_hover_color" , "LinkButton" , control_font_hover_color); |
| 220 | theme->set_color("font_focus_color" , "LinkButton" , control_font_focus_color); |
| 221 | theme->set_color("font_outline_color" , "LinkButton" , Color(1, 1, 1)); |
| 222 | |
| 223 | theme->set_constant("outline_size" , "LinkButton" , 0); |
| 224 | theme->set_constant("underline_spacing" , "LinkButton" , Math::round(2 * scale)); |
| 225 | |
| 226 | // OptionButton |
| 227 | theme->set_stylebox("focus" , "OptionButton" , focus); |
| 228 | |
| 229 | Ref<StyleBox> sb_optbutton_normal = make_flat_stylebox(style_normal_color, 2 * default_margin, default_margin, 21, default_margin); |
| 230 | Ref<StyleBox> sb_optbutton_hover = make_flat_stylebox(style_hover_color, 2 * default_margin, default_margin, 21, default_margin); |
| 231 | Ref<StyleBox> sb_optbutton_pressed = make_flat_stylebox(style_pressed_color, 2 * default_margin, default_margin, 21, default_margin); |
| 232 | Ref<StyleBox> sb_optbutton_disabled = make_flat_stylebox(style_disabled_color, 2 * default_margin, default_margin, 21, default_margin); |
| 233 | |
| 234 | theme->set_stylebox("normal" , "OptionButton" , sb_optbutton_normal); |
| 235 | theme->set_stylebox("hover" , "OptionButton" , sb_optbutton_hover); |
| 236 | theme->set_stylebox("pressed" , "OptionButton" , sb_optbutton_pressed); |
| 237 | theme->set_stylebox("disabled" , "OptionButton" , sb_optbutton_disabled); |
| 238 | |
| 239 | Ref<StyleBox> sb_optbutton_normal_mirrored = make_flat_stylebox(style_normal_color, 21, default_margin, 2 * default_margin, default_margin); |
| 240 | Ref<StyleBox> sb_optbutton_hover_mirrored = make_flat_stylebox(style_hover_color, 21, default_margin, 2 * default_margin, default_margin); |
| 241 | Ref<StyleBox> sb_optbutton_pressed_mirrored = make_flat_stylebox(style_pressed_color, 21, default_margin, 2 * default_margin, default_margin); |
| 242 | Ref<StyleBox> sb_optbutton_disabled_mirrored = make_flat_stylebox(style_disabled_color, 21, default_margin, 2 * default_margin, default_margin); |
| 243 | |
| 244 | theme->set_stylebox("normal_mirrored" , "OptionButton" , sb_optbutton_normal_mirrored); |
| 245 | theme->set_stylebox("hover_mirrored" , "OptionButton" , sb_optbutton_hover_mirrored); |
| 246 | theme->set_stylebox("pressed_mirrored" , "OptionButton" , sb_optbutton_pressed_mirrored); |
| 247 | theme->set_stylebox("disabled_mirrored" , "OptionButton" , sb_optbutton_disabled_mirrored); |
| 248 | |
| 249 | theme->set_icon("arrow" , "OptionButton" , icons["option_button_arrow" ]); |
| 250 | |
| 251 | theme->set_font("font" , "OptionButton" , Ref<Font>()); |
| 252 | theme->set_font_size("font_size" , "OptionButton" , -1); |
| 253 | |
| 254 | theme->set_color("font_color" , "OptionButton" , control_font_color); |
| 255 | theme->set_color("font_pressed_color" , "OptionButton" , control_font_pressed_color); |
| 256 | theme->set_color("font_hover_color" , "OptionButton" , control_font_hover_color); |
| 257 | theme->set_color("font_hover_pressed_color" , "OptionButton" , control_font_pressed_color); |
| 258 | theme->set_color("font_focus_color" , "OptionButton" , control_font_focus_color); |
| 259 | theme->set_color("font_disabled_color" , "OptionButton" , control_font_disabled_color); |
| 260 | theme->set_color("font_outline_color" , "OptionButton" , Color(1, 1, 1)); |
| 261 | |
| 262 | theme->set_constant("h_separation" , "OptionButton" , Math::round(4 * scale)); |
| 263 | theme->set_constant("arrow_margin" , "OptionButton" , Math::round(4 * scale)); |
| 264 | theme->set_constant("outline_size" , "OptionButton" , 0); |
| 265 | theme->set_constant("modulate_arrow" , "OptionButton" , false); |
| 266 | |
| 267 | // MenuButton |
| 268 | |
| 269 | theme->set_stylebox("normal" , "MenuButton" , button_normal); |
| 270 | theme->set_stylebox("pressed" , "MenuButton" , button_pressed); |
| 271 | theme->set_stylebox("hover" , "MenuButton" , button_hover); |
| 272 | theme->set_stylebox("disabled" , "MenuButton" , button_disabled); |
| 273 | theme->set_stylebox("focus" , "MenuButton" , focus); |
| 274 | |
| 275 | theme->set_font("font" , "MenuButton" , Ref<Font>()); |
| 276 | theme->set_font_size("font_size" , "MenuButton" , -1); |
| 277 | |
| 278 | theme->set_color("font_color" , "MenuButton" , control_font_color); |
| 279 | theme->set_color("font_pressed_color" , "MenuButton" , control_font_pressed_color); |
| 280 | theme->set_color("font_hover_color" , "MenuButton" , control_font_hover_color); |
| 281 | theme->set_color("font_focus_color" , "MenuButton" , control_font_focus_color); |
| 282 | theme->set_color("font_disabled_color" , "MenuButton" , Color(1, 1, 1, 0.3)); |
| 283 | theme->set_color("font_outline_color" , "MenuButton" , Color(1, 1, 1)); |
| 284 | |
| 285 | theme->set_constant("h_separation" , "MenuButton" , Math::round(4 * scale)); |
| 286 | theme->set_constant("outline_size" , "MenuButton" , 0); |
| 287 | |
| 288 | // CheckBox |
| 289 | |
| 290 | Ref<StyleBox> cbx_empty = memnew(StyleBoxEmpty); |
| 291 | cbx_empty->set_content_margin_all(Math::round(4 * scale)); |
| 292 | Ref<StyleBox> cbx_focus = focus; |
| 293 | cbx_focus->set_content_margin_all(Math::round(4 * scale)); |
| 294 | |
| 295 | theme->set_stylebox("normal" , "CheckBox" , cbx_empty); |
| 296 | theme->set_stylebox("pressed" , "CheckBox" , cbx_empty); |
| 297 | theme->set_stylebox("disabled" , "CheckBox" , cbx_empty); |
| 298 | theme->set_stylebox("hover" , "CheckBox" , cbx_empty); |
| 299 | theme->set_stylebox("hover_pressed" , "CheckBox" , cbx_empty); |
| 300 | theme->set_stylebox("focus" , "CheckBox" , cbx_focus); |
| 301 | |
| 302 | theme->set_icon("checked" , "CheckBox" , icons["checked" ]); |
| 303 | theme->set_icon("checked_disabled" , "CheckBox" , icons["checked" ]); |
| 304 | theme->set_icon("unchecked" , "CheckBox" , icons["unchecked" ]); |
| 305 | theme->set_icon("unchecked_disabled" , "CheckBox" , icons["unchecked" ]); |
| 306 | theme->set_icon("radio_checked" , "CheckBox" , icons["radio_checked" ]); |
| 307 | theme->set_icon("radio_checked_disabled" , "CheckBox" , icons["radio_checked" ]); |
| 308 | theme->set_icon("radio_unchecked" , "CheckBox" , icons["radio_unchecked" ]); |
| 309 | theme->set_icon("radio_unchecked_disabled" , "CheckBox" , icons["radio_unchecked" ]); |
| 310 | |
| 311 | theme->set_font("font" , "CheckBox" , Ref<Font>()); |
| 312 | theme->set_font_size("font_size" , "CheckBox" , -1); |
| 313 | |
| 314 | theme->set_color("font_color" , "CheckBox" , control_font_color); |
| 315 | theme->set_color("font_pressed_color" , "CheckBox" , control_font_pressed_color); |
| 316 | theme->set_color("font_hover_color" , "CheckBox" , control_font_hover_color); |
| 317 | theme->set_color("font_hover_pressed_color" , "CheckBox" , control_font_pressed_color); |
| 318 | theme->set_color("font_focus_color" , "CheckBox" , control_font_focus_color); |
| 319 | theme->set_color("font_disabled_color" , "CheckBox" , control_font_disabled_color); |
| 320 | theme->set_color("font_outline_color" , "CheckBox" , Color(1, 1, 1)); |
| 321 | |
| 322 | theme->set_constant("h_separation" , "CheckBox" , Math::round(4 * scale)); |
| 323 | theme->set_constant("check_v_offset" , "CheckBox" , 0); |
| 324 | theme->set_constant("outline_size" , "CheckBox" , 0); |
| 325 | |
| 326 | // CheckButton |
| 327 | |
| 328 | Ref<StyleBox> cb_empty = memnew(StyleBoxEmpty); |
| 329 | cb_empty->set_content_margin_individual(Math::round(6 * scale), Math::round(4 * scale), Math::round(6 * scale), Math::round(4 * scale)); |
| 330 | |
| 331 | theme->set_stylebox("normal" , "CheckButton" , cb_empty); |
| 332 | theme->set_stylebox("pressed" , "CheckButton" , cb_empty); |
| 333 | theme->set_stylebox("disabled" , "CheckButton" , cb_empty); |
| 334 | theme->set_stylebox("hover" , "CheckButton" , cb_empty); |
| 335 | theme->set_stylebox("hover_pressed" , "CheckButton" , cb_empty); |
| 336 | theme->set_stylebox("focus" , "CheckButton" , focus); |
| 337 | |
| 338 | theme->set_icon("checked" , "CheckButton" , icons["toggle_on" ]); |
| 339 | theme->set_icon("checked_disabled" , "CheckButton" , icons["toggle_on_disabled" ]); |
| 340 | theme->set_icon("unchecked" , "CheckButton" , icons["toggle_off" ]); |
| 341 | theme->set_icon("unchecked_disabled" , "CheckButton" , icons["toggle_off_disabled" ]); |
| 342 | |
| 343 | theme->set_icon("checked_mirrored" , "CheckButton" , icons["toggle_on_mirrored" ]); |
| 344 | theme->set_icon("checked_disabled_mirrored" , "CheckButton" , icons["toggle_on_disabled_mirrored" ]); |
| 345 | theme->set_icon("unchecked_mirrored" , "CheckButton" , icons["toggle_off_mirrored" ]); |
| 346 | theme->set_icon("unchecked_disabled_mirrored" , "CheckButton" , icons["toggle_off_disabled_mirrored" ]); |
| 347 | |
| 348 | theme->set_font("font" , "CheckButton" , Ref<Font>()); |
| 349 | theme->set_font_size("font_size" , "CheckButton" , -1); |
| 350 | |
| 351 | theme->set_color("font_color" , "CheckButton" , control_font_color); |
| 352 | theme->set_color("font_pressed_color" , "CheckButton" , control_font_pressed_color); |
| 353 | theme->set_color("font_hover_color" , "CheckButton" , control_font_hover_color); |
| 354 | theme->set_color("font_hover_pressed_color" , "CheckButton" , control_font_pressed_color); |
| 355 | theme->set_color("font_focus_color" , "CheckButton" , control_font_focus_color); |
| 356 | theme->set_color("font_disabled_color" , "CheckButton" , control_font_disabled_color); |
| 357 | theme->set_color("font_outline_color" , "CheckButton" , Color(1, 1, 1)); |
| 358 | |
| 359 | theme->set_constant("h_separation" , "CheckButton" , Math::round(4 * scale)); |
| 360 | theme->set_constant("check_v_offset" , "CheckButton" , 0); |
| 361 | theme->set_constant("outline_size" , "CheckButton" , 0); |
| 362 | |
| 363 | // Label |
| 364 | |
| 365 | theme->set_stylebox("normal" , "Label" , memnew(StyleBoxEmpty)); |
| 366 | theme->set_font("font" , "Label" , Ref<Font>()); |
| 367 | theme->set_font_size("font_size" , "Label" , -1); |
| 368 | |
| 369 | theme->set_color("font_color" , "Label" , Color(1, 1, 1)); |
| 370 | theme->set_color("font_shadow_color" , "Label" , Color(0, 0, 0, 0)); |
| 371 | theme->set_color("font_outline_color" , "Label" , Color(1, 1, 1)); |
| 372 | |
| 373 | theme->set_constant("shadow_offset_x" , "Label" , Math::round(1 * scale)); |
| 374 | theme->set_constant("shadow_offset_y" , "Label" , Math::round(1 * scale)); |
| 375 | theme->set_constant("outline_size" , "Label" , 0); |
| 376 | theme->set_constant("shadow_outline_size" , "Label" , Math::round(1 * scale)); |
| 377 | theme->set_constant("line_spacing" , "Label" , Math::round(3 * scale)); |
| 378 | |
| 379 | theme->set_type_variation("HeaderSmall" , "Label" ); |
| 380 | theme->set_font_size("font_size" , "HeaderSmall" , default_font_size + 4); |
| 381 | |
| 382 | theme->set_type_variation("HeaderMedium" , "Label" ); |
| 383 | theme->set_font_size("font_size" , "HeaderMedium" , default_font_size + 8); |
| 384 | |
| 385 | theme->set_type_variation("HeaderLarge" , "Label" ); |
| 386 | theme->set_font_size("font_size" , "HeaderLarge" , default_font_size + 12); |
| 387 | |
| 388 | // LineEdit |
| 389 | |
| 390 | Ref<StyleBoxFlat> style_line_edit = make_flat_stylebox(style_normal_color); |
| 391 | // Add a line at the bottom to make LineEdits distinguishable from Buttons. |
| 392 | style_line_edit->set_border_width(SIDE_BOTTOM, 2); |
| 393 | style_line_edit->set_border_color(style_pressed_color); |
| 394 | theme->set_stylebox("normal" , "LineEdit" , style_line_edit); |
| 395 | |
| 396 | theme->set_stylebox("focus" , "LineEdit" , focus); |
| 397 | |
| 398 | Ref<StyleBoxFlat> style_line_edit_read_only = make_flat_stylebox(style_disabled_color); |
| 399 | // Add a line at the bottom to make LineEdits distinguishable from Buttons. |
| 400 | style_line_edit_read_only->set_border_width(SIDE_BOTTOM, 2); |
| 401 | style_line_edit_read_only->set_border_color(style_pressed_color * Color(1, 1, 1, 0.5)); |
| 402 | theme->set_stylebox("read_only" , "LineEdit" , style_line_edit_read_only); |
| 403 | |
| 404 | theme->set_font("font" , "LineEdit" , Ref<Font>()); |
| 405 | theme->set_font_size("font_size" , "LineEdit" , -1); |
| 406 | |
| 407 | theme->set_color("font_color" , "LineEdit" , control_font_color); |
| 408 | theme->set_color("font_selected_color" , "LineEdit" , control_font_pressed_color); |
| 409 | theme->set_color("font_uneditable_color" , "LineEdit" , control_font_disabled_color); |
| 410 | theme->set_color("font_placeholder_color" , "LineEdit" , control_font_placeholder_color); |
| 411 | theme->set_color("font_outline_color" , "LineEdit" , Color(1, 1, 1)); |
| 412 | theme->set_color("caret_color" , "LineEdit" , control_font_hover_color); |
| 413 | theme->set_color("selection_color" , "LineEdit" , control_selection_color); |
| 414 | theme->set_color("clear_button_color" , "LineEdit" , control_font_color); |
| 415 | theme->set_color("clear_button_color_pressed" , "LineEdit" , control_font_pressed_color); |
| 416 | |
| 417 | theme->set_constant("minimum_character_width" , "LineEdit" , 4); |
| 418 | theme->set_constant("outline_size" , "LineEdit" , 0); |
| 419 | theme->set_constant("caret_width" , "LineEdit" , 1); |
| 420 | |
| 421 | theme->set_icon("clear" , "LineEdit" , icons["line_edit_clear" ]); |
| 422 | |
| 423 | // ProgressBar |
| 424 | |
| 425 | theme->set_stylebox("background" , "ProgressBar" , make_flat_stylebox(style_disabled_color, 2, 2, 2, 2, 6)); |
| 426 | theme->set_stylebox("fill" , "ProgressBar" , make_flat_stylebox(style_progress_color, 2, 2, 2, 2, 6)); |
| 427 | |
| 428 | theme->set_font("font" , "ProgressBar" , Ref<Font>()); |
| 429 | theme->set_font_size("font_size" , "ProgressBar" , -1); |
| 430 | |
| 431 | theme->set_color("font_color" , "ProgressBar" , control_font_hover_color); |
| 432 | theme->set_color("font_shadow_color" , "ProgressBar" , Color(0, 0, 0)); |
| 433 | theme->set_color("font_outline_color" , "ProgressBar" , Color(1, 1, 1)); |
| 434 | |
| 435 | theme->set_constant("outline_size" , "ProgressBar" , 0); |
| 436 | |
| 437 | // TextEdit |
| 438 | |
| 439 | theme->set_stylebox("normal" , "TextEdit" , style_line_edit); |
| 440 | theme->set_stylebox("focus" , "TextEdit" , focus); |
| 441 | theme->set_stylebox("read_only" , "TextEdit" , style_line_edit_read_only); |
| 442 | |
| 443 | theme->set_icon("tab" , "TextEdit" , icons["text_edit_tab" ]); |
| 444 | theme->set_icon("space" , "TextEdit" , icons["text_edit_space" ]); |
| 445 | |
| 446 | theme->set_font("font" , "TextEdit" , Ref<Font>()); |
| 447 | theme->set_font_size("font_size" , "TextEdit" , -1); |
| 448 | |
| 449 | theme->set_color("background_color" , "TextEdit" , Color(0, 0, 0, 0)); |
| 450 | theme->set_color("font_color" , "TextEdit" , control_font_color); |
| 451 | theme->set_color("font_selected_color" , "TextEdit" , Color(0, 0, 0, 0)); |
| 452 | theme->set_color("font_readonly_color" , "TextEdit" , control_font_disabled_color); |
| 453 | theme->set_color("font_placeholder_color" , "TextEdit" , control_font_placeholder_color); |
| 454 | theme->set_color("font_outline_color" , "TextEdit" , Color(1, 1, 1)); |
| 455 | theme->set_color("selection_color" , "TextEdit" , control_selection_color); |
| 456 | theme->set_color("current_line_color" , "TextEdit" , Color(0.25, 0.25, 0.26, 0.8)); |
| 457 | theme->set_color("caret_color" , "TextEdit" , control_font_color); |
| 458 | theme->set_color("caret_background_color" , "TextEdit" , Color(0, 0, 0)); |
| 459 | theme->set_color("word_highlighted_color" , "TextEdit" , Color(0.5, 0.5, 0.5, 0.25)); |
| 460 | theme->set_color("search_result_color" , "TextEdit" , Color(0.3, 0.3, 0.3)); |
| 461 | theme->set_color("search_result_border_color" , "TextEdit" , Color(0.3, 0.3, 0.3, 0.4)); |
| 462 | |
| 463 | theme->set_constant("line_spacing" , "TextEdit" , Math::round(4 * scale)); |
| 464 | theme->set_constant("outline_size" , "TextEdit" , 0); |
| 465 | theme->set_constant("caret_width" , "TextEdit" , 1); |
| 466 | |
| 467 | // CodeEdit |
| 468 | |
| 469 | theme->set_stylebox("normal" , "CodeEdit" , style_line_edit); |
| 470 | theme->set_stylebox("focus" , "CodeEdit" , focus); |
| 471 | theme->set_stylebox("read_only" , "CodeEdit" , style_line_edit_read_only); |
| 472 | theme->set_stylebox("completion" , "CodeEdit" , make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); |
| 473 | |
| 474 | theme->set_icon("tab" , "CodeEdit" , icons["text_edit_tab" ]); |
| 475 | theme->set_icon("space" , "CodeEdit" , icons["text_edit_space" ]); |
| 476 | theme->set_icon("breakpoint" , "CodeEdit" , icons["breakpoint" ]); |
| 477 | theme->set_icon("bookmark" , "CodeEdit" , icons["bookmark" ]); |
| 478 | theme->set_icon("executing_line" , "CodeEdit" , icons["arrow_right" ]); |
| 479 | theme->set_icon("can_fold" , "CodeEdit" , icons["arrow_down" ]); |
| 480 | theme->set_icon("folded" , "CodeEdit" , icons["arrow_right" ]); |
| 481 | theme->set_icon("can_fold_code_region" , "CodeEdit" , icons["folder_down_arrow" ]); |
| 482 | theme->set_icon("folded_code_region" , "CodeEdit" , icons["folder_right_arrow" ]); |
| 483 | theme->set_icon("folded_eol_icon" , "CodeEdit" , icons["text_edit_ellipsis" ]); |
| 484 | |
| 485 | theme->set_font("font" , "CodeEdit" , Ref<Font>()); |
| 486 | theme->set_font_size("font_size" , "CodeEdit" , -1); |
| 487 | |
| 488 | theme->set_color("background_color" , "CodeEdit" , Color(0, 0, 0, 0)); |
| 489 | theme->set_color("completion_background_color" , "CodeEdit" , Color(0.17, 0.16, 0.2)); |
| 490 | theme->set_color("completion_selected_color" , "CodeEdit" , Color(0.26, 0.26, 0.27)); |
| 491 | theme->set_color("completion_existing_color" , "CodeEdit" , Color(0.87, 0.87, 0.87, 0.13)); |
| 492 | theme->set_color("completion_scroll_color" , "CodeEdit" , control_font_pressed_color * Color(1, 1, 1, 0.29)); |
| 493 | theme->set_color("completion_scroll_hovered_color" , "CodeEdit" , control_font_pressed_color * Color(1, 1, 1, 0.4)); |
| 494 | theme->set_color("completion_font_color" , "CodeEdit" , Color(0.67, 0.67, 0.67)); |
| 495 | theme->set_color("font_color" , "CodeEdit" , control_font_color); |
| 496 | theme->set_color("font_selected_color" , "CodeEdit" , Color(0, 0, 0, 0)); |
| 497 | theme->set_color("font_readonly_color" , "CodeEdit" , Color(control_font_color.r, control_font_color.g, control_font_color.b, 0.5f)); |
| 498 | theme->set_color("font_placeholder_color" , "CodeEdit" , control_font_placeholder_color); |
| 499 | theme->set_color("font_outline_color" , "CodeEdit" , Color(1, 1, 1)); |
| 500 | theme->set_color("selection_color" , "CodeEdit" , control_selection_color); |
| 501 | theme->set_color("bookmark_color" , "CodeEdit" , Color(0.5, 0.64, 1, 0.8)); |
| 502 | theme->set_color("breakpoint_color" , "CodeEdit" , Color(0.9, 0.29, 0.3)); |
| 503 | theme->set_color("executing_line_color" , "CodeEdit" , Color(0.98, 0.89, 0.27)); |
| 504 | theme->set_color("current_line_color" , "CodeEdit" , Color(0.25, 0.25, 0.26, 0.8)); |
| 505 | theme->set_color("code_folding_color" , "CodeEdit" , Color(0.8, 0.8, 0.8, 0.8)); |
| 506 | theme->set_color("folded_code_region_color" , "CodeEdit" , Color(0.68, 0.46, 0.77, 0.2)); |
| 507 | theme->set_color("caret_color" , "CodeEdit" , control_font_color); |
| 508 | theme->set_color("caret_background_color" , "CodeEdit" , Color(0, 0, 0)); |
| 509 | theme->set_color("brace_mismatch_color" , "CodeEdit" , Color(1, 0.2, 0.2)); |
| 510 | theme->set_color("line_number_color" , "CodeEdit" , Color(0.67, 0.67, 0.67, 0.4)); |
| 511 | theme->set_color("word_highlighted_color" , "CodeEdit" , Color(0.8, 0.9, 0.9, 0.15)); |
| 512 | theme->set_color("line_length_guideline_color" , "CodeEdit" , Color(0.3, 0.5, 0.8, 0.1)); |
| 513 | theme->set_color("search_result_color" , "CodeEdit" , Color(0.3, 0.3, 0.3)); |
| 514 | theme->set_color("search_result_border_color" , "CodeEdit" , Color(0.3, 0.3, 0.3, 0.4)); |
| 515 | |
| 516 | theme->set_constant("completion_lines" , "CodeEdit" , 7); |
| 517 | theme->set_constant("completion_max_width" , "CodeEdit" , 50); |
| 518 | theme->set_constant("completion_scroll_width" , "CodeEdit" , 6); |
| 519 | theme->set_constant("line_spacing" , "CodeEdit" , Math::round(4 * scale)); |
| 520 | theme->set_constant("outline_size" , "CodeEdit" , 0); |
| 521 | |
| 522 | Ref<Texture2D> empty_icon = memnew(ImageTexture); |
| 523 | |
| 524 | const Ref<StyleBoxFlat> style_h_scrollbar = make_flat_stylebox(style_normal_color, 0, 4, 0, 4, 10); |
| 525 | const Ref<StyleBoxFlat> style_v_scrollbar = make_flat_stylebox(style_normal_color, 4, 0, 4, 0, 10); |
| 526 | Ref<StyleBoxFlat> style_scrollbar_grabber = make_flat_stylebox(style_progress_color, 4, 4, 4, 4, 10); |
| 527 | Ref<StyleBoxFlat> style_scrollbar_grabber_highlight = make_flat_stylebox(style_focus_color, 4, 4, 4, 4, 10); |
| 528 | Ref<StyleBoxFlat> style_scrollbar_grabber_pressed = make_flat_stylebox(style_focus_color * Color(0.75, 0.75, 0.75), 4, 4, 4, 4, 10); |
| 529 | |
| 530 | // HScrollBar |
| 531 | |
| 532 | theme->set_stylebox("scroll" , "HScrollBar" , style_h_scrollbar); |
| 533 | theme->set_stylebox("scroll_focus" , "HScrollBar" , focus); |
| 534 | theme->set_stylebox("grabber" , "HScrollBar" , style_scrollbar_grabber); |
| 535 | theme->set_stylebox("grabber_highlight" , "HScrollBar" , style_scrollbar_grabber_highlight); |
| 536 | theme->set_stylebox("grabber_pressed" , "HScrollBar" , style_scrollbar_grabber_pressed); |
| 537 | |
| 538 | theme->set_icon("increment" , "HScrollBar" , empty_icon); |
| 539 | theme->set_icon("increment_highlight" , "HScrollBar" , empty_icon); |
| 540 | theme->set_icon("increment_pressed" , "HScrollBar" , empty_icon); |
| 541 | theme->set_icon("decrement" , "HScrollBar" , empty_icon); |
| 542 | theme->set_icon("decrement_highlight" , "HScrollBar" , empty_icon); |
| 543 | theme->set_icon("decrement_pressed" , "HScrollBar" , empty_icon); |
| 544 | |
| 545 | // VScrollBar |
| 546 | |
| 547 | theme->set_stylebox("scroll" , "VScrollBar" , style_v_scrollbar); |
| 548 | theme->set_stylebox("scroll_focus" , "VScrollBar" , focus); |
| 549 | theme->set_stylebox("grabber" , "VScrollBar" , style_scrollbar_grabber); |
| 550 | theme->set_stylebox("grabber_highlight" , "VScrollBar" , style_scrollbar_grabber_highlight); |
| 551 | theme->set_stylebox("grabber_pressed" , "VScrollBar" , style_scrollbar_grabber_pressed); |
| 552 | |
| 553 | theme->set_icon("increment" , "VScrollBar" , empty_icon); |
| 554 | theme->set_icon("increment_highlight" , "VScrollBar" , empty_icon); |
| 555 | theme->set_icon("increment_pressed" , "VScrollBar" , empty_icon); |
| 556 | theme->set_icon("decrement" , "VScrollBar" , empty_icon); |
| 557 | theme->set_icon("decrement_highlight" , "VScrollBar" , empty_icon); |
| 558 | theme->set_icon("decrement_pressed" , "VScrollBar" , empty_icon); |
| 559 | |
| 560 | const Ref<StyleBoxFlat> style_slider = make_flat_stylebox(style_normal_color, 4, 4, 4, 4, 4); |
| 561 | const Ref<StyleBoxFlat> style_slider_grabber = make_flat_stylebox(style_progress_color, 4, 4, 4, 4, 4); |
| 562 | const Ref<StyleBoxFlat> style_slider_grabber_highlight = make_flat_stylebox(style_focus_color, 4, 4, 4, 4, 4); |
| 563 | |
| 564 | // HSlider |
| 565 | |
| 566 | theme->set_stylebox("slider" , "HSlider" , style_slider); |
| 567 | theme->set_stylebox("grabber_area" , "HSlider" , style_slider_grabber); |
| 568 | theme->set_stylebox("grabber_area_highlight" , "HSlider" , style_slider_grabber_highlight); |
| 569 | |
| 570 | theme->set_icon("grabber" , "HSlider" , icons["slider_grabber" ]); |
| 571 | theme->set_icon("grabber_highlight" , "HSlider" , icons["slider_grabber_hl" ]); |
| 572 | theme->set_icon("grabber_disabled" , "HSlider" , icons["slider_grabber_disabled" ]); |
| 573 | theme->set_icon("tick" , "HSlider" , icons["hslider_tick" ]); |
| 574 | |
| 575 | theme->set_constant("center_grabber" , "HSlider" , 0); |
| 576 | theme->set_constant("grabber_offset" , "HSlider" , 0); |
| 577 | |
| 578 | // VSlider |
| 579 | |
| 580 | theme->set_stylebox("slider" , "VSlider" , style_slider); |
| 581 | theme->set_stylebox("grabber_area" , "VSlider" , style_slider_grabber); |
| 582 | theme->set_stylebox("grabber_area_highlight" , "VSlider" , style_slider_grabber_highlight); |
| 583 | |
| 584 | theme->set_icon("grabber" , "VSlider" , icons["slider_grabber" ]); |
| 585 | theme->set_icon("grabber_highlight" , "VSlider" , icons["slider_grabber_hl" ]); |
| 586 | theme->set_icon("grabber_disabled" , "VSlider" , icons["slider_grabber_disabled" ]); |
| 587 | theme->set_icon("tick" , "VSlider" , icons["vslider_tick" ]); |
| 588 | |
| 589 | theme->set_constant("center_grabber" , "VSlider" , 0); |
| 590 | theme->set_constant("grabber_offset" , "VSlider" , 0); |
| 591 | |
| 592 | // SpinBox |
| 593 | |
| 594 | theme->set_icon("updown" , "SpinBox" , icons["updown" ]); |
| 595 | |
| 596 | // ScrollContainer |
| 597 | |
| 598 | Ref<StyleBoxEmpty> empty; |
| 599 | empty.instantiate(); |
| 600 | theme->set_stylebox("panel" , "ScrollContainer" , empty); |
| 601 | |
| 602 | // Window |
| 603 | |
| 604 | theme->set_stylebox("embedded_border" , "Window" , sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6)); |
| 605 | theme->set_stylebox("embedded_unfocused_border" , "Window" , sb_expand(make_flat_stylebox(style_popup_hover_color, 10, 28, 10, 8), 8, 32, 8, 6)); |
| 606 | |
| 607 | theme->set_font("title_font" , "Window" , Ref<Font>()); |
| 608 | theme->set_font_size("title_font_size" , "Window" , -1); |
| 609 | theme->set_color("title_color" , "Window" , control_font_color); |
| 610 | theme->set_color("title_outline_modulate" , "Window" , Color(1, 1, 1)); |
| 611 | theme->set_constant("title_outline_size" , "Window" , 0); |
| 612 | theme->set_constant("title_height" , "Window" , 36 * scale); |
| 613 | theme->set_constant("resize_margin" , "Window" , Math::round(4 * scale)); |
| 614 | |
| 615 | theme->set_icon("close" , "Window" , icons["close" ]); |
| 616 | theme->set_icon("close_pressed" , "Window" , icons["close_hl" ]); |
| 617 | theme->set_constant("close_h_offset" , "Window" , 18 * scale); |
| 618 | theme->set_constant("close_v_offset" , "Window" , 24 * scale); |
| 619 | |
| 620 | // Dialogs |
| 621 | |
| 622 | // AcceptDialog is currently the base dialog, so this defines styles for all extending nodes. |
| 623 | theme->set_stylebox("panel" , "AcceptDialog" , make_flat_stylebox(style_popup_color, Math::round(8 * scale), Math::round(8 * scale), Math::round(8 * scale), Math::round(8 * scale))); |
| 624 | theme->set_constant("buttons_separation" , "AcceptDialog" , Math::round(10 * scale)); |
| 625 | |
| 626 | // File Dialog |
| 627 | |
| 628 | theme->set_icon("parent_folder" , "FileDialog" , icons["folder_up" ]); |
| 629 | theme->set_icon("back_folder" , "FileDialog" , icons["arrow_left" ]); |
| 630 | theme->set_icon("forward_folder" , "FileDialog" , icons["arrow_right" ]); |
| 631 | theme->set_icon("reload" , "FileDialog" , icons["reload" ]); |
| 632 | theme->set_icon("toggle_hidden" , "FileDialog" , icons["visibility_visible" ]); |
| 633 | theme->set_icon("folder" , "FileDialog" , icons["folder" ]); |
| 634 | theme->set_icon("file" , "FileDialog" , icons["file" ]); |
| 635 | theme->set_color("folder_icon_color" , "FileDialog" , Color(1, 1, 1)); |
| 636 | theme->set_color("file_icon_color" , "FileDialog" , Color(1, 1, 1)); |
| 637 | theme->set_color("file_disabled_color" , "FileDialog" , Color(1, 1, 1, 0.25)); |
| 638 | |
| 639 | // Popup |
| 640 | |
| 641 | theme->set_stylebox("panel" , "PopupPanel" , make_flat_stylebox(style_normal_color)); |
| 642 | |
| 643 | // PopupDialog |
| 644 | |
| 645 | theme->set_stylebox("panel" , "PopupDialog" , make_flat_stylebox(style_normal_color)); |
| 646 | |
| 647 | // PopupMenu |
| 648 | |
| 649 | Ref<StyleBoxLine> separator_horizontal = memnew(StyleBoxLine); |
| 650 | separator_horizontal->set_thickness(Math::round(scale)); |
| 651 | separator_horizontal->set_color(style_separator_color); |
| 652 | separator_horizontal->set_content_margin_individual(default_margin, 0, default_margin, 0); |
| 653 | Ref<StyleBoxLine> separator_vertical = separator_horizontal->duplicate(); |
| 654 | separator_vertical->set_vertical(true); |
| 655 | separator_vertical->set_content_margin_individual(0, default_margin, 0, default_margin); |
| 656 | |
| 657 | // Always display a border for PopupMenus so they can be distinguished from their background. |
| 658 | Ref<StyleBoxFlat> = make_flat_stylebox(style_popup_color); |
| 659 | style_popup_panel->set_border_width_all(2); |
| 660 | style_popup_panel->set_border_color(style_popup_border_color); |
| 661 | Ref<StyleBoxFlat> = style_popup_panel->duplicate(); |
| 662 | style_popup_panel_disabled->set_bg_color(style_disabled_color); |
| 663 | |
| 664 | theme->set_stylebox("panel" , "PopupMenu" , style_popup_panel); |
| 665 | theme->set_stylebox("panel_disabled" , "PopupMenu" , style_popup_panel_disabled); |
| 666 | theme->set_stylebox("hover" , "PopupMenu" , make_flat_stylebox(style_popup_hover_color)); |
| 667 | theme->set_stylebox("separator" , "PopupMenu" , separator_horizontal); |
| 668 | theme->set_stylebox("labeled_separator_left" , "PopupMenu" , separator_horizontal); |
| 669 | theme->set_stylebox("labeled_separator_right" , "PopupMenu" , separator_horizontal); |
| 670 | |
| 671 | theme->set_icon("checked" , "PopupMenu" , icons["checked" ]); |
| 672 | theme->set_icon("checked_disabled" , "PopupMenu" , icons["checked" ]); |
| 673 | theme->set_icon("unchecked" , "PopupMenu" , icons["unchecked" ]); |
| 674 | theme->set_icon("unchecked_disabled" , "PopupMenu" , icons["unchecked" ]); |
| 675 | theme->set_icon("radio_checked" , "PopupMenu" , icons["radio_checked" ]); |
| 676 | theme->set_icon("radio_checked_disabled" , "PopupMenu" , icons["radio_checked" ]); |
| 677 | theme->set_icon("radio_unchecked" , "PopupMenu" , icons["radio_unchecked" ]); |
| 678 | theme->set_icon("radio_unchecked_disabled" , "PopupMenu" , icons["radio_unchecked" ]); |
| 679 | theme->set_icon("submenu" , "PopupMenu" , icons["popup_menu_arrow_right" ]); |
| 680 | theme->set_icon("submenu_mirrored" , "PopupMenu" , icons["popup_menu_arrow_left" ]); |
| 681 | |
| 682 | theme->set_font("font" , "PopupMenu" , Ref<Font>()); |
| 683 | theme->set_font("font_separator" , "PopupMenu" , Ref<Font>()); |
| 684 | theme->set_font_size("font_size" , "PopupMenu" , -1); |
| 685 | theme->set_font_size("font_separator_size" , "PopupMenu" , -1); |
| 686 | |
| 687 | theme->set_color("font_color" , "PopupMenu" , control_font_color); |
| 688 | theme->set_color("font_accelerator_color" , "PopupMenu" , Color(0.7, 0.7, 0.7, 0.8)); |
| 689 | theme->set_color("font_disabled_color" , "PopupMenu" , Color(0.4, 0.4, 0.4, 0.8)); |
| 690 | theme->set_color("font_hover_color" , "PopupMenu" , control_font_color); |
| 691 | theme->set_color("font_separator_color" , "PopupMenu" , control_font_color); |
| 692 | theme->set_color("font_outline_color" , "PopupMenu" , Color(1, 1, 1)); |
| 693 | theme->set_color("font_separator_outline_color" , "PopupMenu" , Color(1, 1, 1)); |
| 694 | |
| 695 | theme->set_constant("indent" , "PopupMenu" , Math::round(10 * scale)); |
| 696 | theme->set_constant("h_separation" , "PopupMenu" , Math::round(4 * scale)); |
| 697 | theme->set_constant("v_separation" , "PopupMenu" , Math::round(4 * scale)); |
| 698 | theme->set_constant("outline_size" , "PopupMenu" , 0); |
| 699 | theme->set_constant("separator_outline_size" , "PopupMenu" , 0); |
| 700 | theme->set_constant("item_start_padding" , "PopupMenu" , Math::round(2 * scale)); |
| 701 | theme->set_constant("item_end_padding" , "PopupMenu" , Math::round(2 * scale)); |
| 702 | theme->set_constant("icon_max_width" , "PopupMenu" , 0); |
| 703 | |
| 704 | // GraphNode |
| 705 | |
| 706 | Ref<StyleBoxFlat> graphnode_normal = make_flat_stylebox(style_normal_color, 18, 12, 18, 12); |
| 707 | graphnode_normal->set_border_color(Color(0.325, 0.325, 0.325, 0.6)); |
| 708 | Ref<StyleBoxFlat> graphnode_selected = graphnode_normal->duplicate(); |
| 709 | graphnode_selected->set_border_color(Color(0.625, 0.625, 0.625, 0.6)); |
| 710 | |
| 711 | Ref<StyleBoxFlat> graphn_sb_titlebar = make_flat_stylebox(style_normal_color.lightened(0.3), 4, 4, 4, 4); |
| 712 | Ref<StyleBoxFlat> graphn_sb_titlebar_selected = graphnode_normal->duplicate(); |
| 713 | graphn_sb_titlebar_selected->set_bg_color(Color(1.0, 0.625, 0.625, 0.6)); |
| 714 | Ref<StyleBoxEmpty> graphnode_slot = make_empty_stylebox(0, 0, 0, 0); |
| 715 | |
| 716 | theme->set_stylebox("panel" , "GraphNode" , graphnode_normal); |
| 717 | theme->set_stylebox("panel_selected" , "GraphNode" , graphnode_selected); |
| 718 | theme->set_stylebox("titlebar" , "GraphNode" , graphn_sb_titlebar); |
| 719 | theme->set_stylebox("titlebar_selected" , "GraphNode" , graphn_sb_titlebar_selected); |
| 720 | theme->set_stylebox("slot" , "GraphNode" , graphnode_slot); |
| 721 | theme->set_icon("port" , "GraphNode" , icons["graph_port" ]); |
| 722 | theme->set_icon("resizer" , "GraphNode" , icons["resizer_se" ]); |
| 723 | theme->set_color("resizer_color" , "GraphNode" , control_font_color); |
| 724 | theme->set_constant("separation" , "GraphNode" , Math::round(2 * scale)); |
| 725 | theme->set_constant("port_h_offset" , "GraphNode" , 0); |
| 726 | |
| 727 | // GraphNodes's title Label. |
| 728 | |
| 729 | theme->set_type_variation("GraphNodeTitleLabel" , "Label" ); |
| 730 | |
| 731 | theme->set_stylebox("normal" , "GraphNodeTitleLabel" , make_empty_stylebox(0, 0, 0, 0)); |
| 732 | theme->set_font("font" , "GraphNodeTitleLabel" , Ref<Font>()); |
| 733 | theme->set_font_size("font_size" , "GraphNodeTitleLabel" , -1); |
| 734 | theme->set_color("font_color" , "GraphNodeTitleLabel" , control_font_color); |
| 735 | theme->set_color("font_shadow_color" , "GraphNodeTitleLabel" , Color(0, 0, 0, 0)); |
| 736 | theme->set_color("font_outline_color" , "GraphNodeTitleLabel" , control_font_color); |
| 737 | theme->set_constant("shadow_offset_x" , "GraphNodeTitleLabel" , Math::round(1 * scale)); |
| 738 | theme->set_constant("shadow_offset_y" , "GraphNodeTitleLabel" , Math::round(1 * scale)); |
| 739 | theme->set_constant("outline_size" , "GraphNodeTitleLabel" , 0); |
| 740 | theme->set_constant("shadow_outline_size" , "GraphNodeTitleLabel" , Math::round(1 * scale)); |
| 741 | theme->set_constant("line_spacing" , "GraphNodeTitleLabel" , Math::round(3 * scale)); |
| 742 | |
| 743 | // Tree |
| 744 | |
| 745 | theme->set_stylebox("panel" , "Tree" , make_flat_stylebox(style_normal_color, 4, 4, 4, 5)); |
| 746 | theme->set_stylebox("focus" , "Tree" , focus); |
| 747 | theme->set_stylebox("selected" , "Tree" , make_flat_stylebox(style_selected_color)); |
| 748 | theme->set_stylebox("selected_focus" , "Tree" , make_flat_stylebox(style_selected_color)); |
| 749 | theme->set_stylebox("cursor" , "Tree" , focus); |
| 750 | theme->set_stylebox("cursor_unfocused" , "Tree" , focus); |
| 751 | theme->set_stylebox("button_pressed" , "Tree" , button_pressed); |
| 752 | theme->set_stylebox("title_button_normal" , "Tree" , make_flat_stylebox(style_pressed_color, 4, 4, 4, 4)); |
| 753 | theme->set_stylebox("title_button_pressed" , "Tree" , make_flat_stylebox(style_hover_color, 4, 4, 4, 4)); |
| 754 | theme->set_stylebox("title_button_hover" , "Tree" , make_flat_stylebox(style_normal_color, 4, 4, 4, 4)); |
| 755 | theme->set_stylebox("custom_button" , "Tree" , button_normal); |
| 756 | theme->set_stylebox("custom_button_pressed" , "Tree" , button_pressed); |
| 757 | theme->set_stylebox("custom_button_hover" , "Tree" , button_hover); |
| 758 | |
| 759 | theme->set_icon("checked" , "Tree" , icons["checked" ]); |
| 760 | theme->set_icon("unchecked" , "Tree" , icons["unchecked" ]); |
| 761 | theme->set_icon("indeterminate" , "Tree" , icons["indeterminate" ]); |
| 762 | theme->set_icon("updown" , "Tree" , icons["updown" ]); |
| 763 | theme->set_icon("select_arrow" , "Tree" , icons["option_button_arrow" ]); |
| 764 | theme->set_icon("arrow" , "Tree" , icons["arrow_down" ]); |
| 765 | theme->set_icon("arrow_collapsed" , "Tree" , icons["arrow_right" ]); |
| 766 | theme->set_icon("arrow_collapsed_mirrored" , "Tree" , icons["arrow_left" ]); |
| 767 | |
| 768 | theme->set_font("title_button_font" , "Tree" , Ref<Font>()); |
| 769 | theme->set_font("font" , "Tree" , Ref<Font>()); |
| 770 | theme->set_font_size("font_size" , "Tree" , -1); |
| 771 | theme->set_font_size("title_button_font_size" , "Tree" , -1); |
| 772 | |
| 773 | theme->set_color("title_button_color" , "Tree" , control_font_color); |
| 774 | theme->set_color("font_color" , "Tree" , control_font_low_color); |
| 775 | theme->set_color("font_selected_color" , "Tree" , control_font_pressed_color); |
| 776 | theme->set_color("font_outline_color" , "Tree" , Color(1, 1, 1)); |
| 777 | theme->set_color("guide_color" , "Tree" , Color(0.7, 0.7, 0.7, 0.25)); |
| 778 | theme->set_color("drop_position_color" , "Tree" , Color(1, 1, 1)); |
| 779 | theme->set_color("relationship_line_color" , "Tree" , Color(0.27, 0.27, 0.27)); |
| 780 | theme->set_color("parent_hl_line_color" , "Tree" , Color(0.27, 0.27, 0.27)); |
| 781 | theme->set_color("children_hl_line_color" , "Tree" , Color(0.27, 0.27, 0.27)); |
| 782 | theme->set_color("custom_button_font_highlight" , "Tree" , control_font_hover_color); |
| 783 | |
| 784 | theme->set_constant("h_separation" , "Tree" , Math::round(4 * scale)); |
| 785 | theme->set_constant("v_separation" , "Tree" , Math::round(4 * scale)); |
| 786 | theme->set_constant("item_margin" , "Tree" , Math::round(16 * scale)); |
| 787 | theme->set_constant("inner_item_margin_bottom" , "Tree" , 0); |
| 788 | theme->set_constant("inner_item_margin_left" , "Tree" , 0); |
| 789 | theme->set_constant("inner_item_margin_right" , "Tree" , 0); |
| 790 | theme->set_constant("inner_item_margin_top" , "Tree" , 0); |
| 791 | theme->set_constant("button_margin" , "Tree" , Math::round(4 * scale)); |
| 792 | theme->set_constant("draw_relationship_lines" , "Tree" , 0); |
| 793 | theme->set_constant("relationship_line_width" , "Tree" , 1); |
| 794 | theme->set_constant("parent_hl_line_width" , "Tree" , 1); |
| 795 | theme->set_constant("children_hl_line_width" , "Tree" , 1); |
| 796 | theme->set_constant("parent_hl_line_margin" , "Tree" , 0); |
| 797 | theme->set_constant("draw_guides" , "Tree" , 1); |
| 798 | theme->set_constant("scroll_border" , "Tree" , Math::round(4 * scale)); |
| 799 | theme->set_constant("scroll_speed" , "Tree" , 12); |
| 800 | theme->set_constant("outline_size" , "Tree" , 0); |
| 801 | theme->set_constant("icon_max_width" , "Tree" , 0); |
| 802 | theme->set_constant("scrollbar_margin_left" , "Tree" , -1); |
| 803 | theme->set_constant("scrollbar_margin_top" , "Tree" , -1); |
| 804 | theme->set_constant("scrollbar_margin_right" , "Tree" , -1); |
| 805 | theme->set_constant("scrollbar_margin_bottom" , "Tree" , -1); |
| 806 | theme->set_constant("scrollbar_h_separation" , "Tree" , Math::round(4 * scale)); |
| 807 | theme->set_constant("scrollbar_v_separation" , "Tree" , Math::round(4 * scale)); |
| 808 | |
| 809 | // ItemList |
| 810 | |
| 811 | theme->set_stylebox("panel" , "ItemList" , make_flat_stylebox(style_normal_color)); |
| 812 | theme->set_stylebox("focus" , "ItemList" , focus); |
| 813 | theme->set_constant("h_separation" , "ItemList" , Math::round(4 * scale)); |
| 814 | theme->set_constant("v_separation" , "ItemList" , Math::round(2 * scale)); |
| 815 | theme->set_constant("icon_margin" , "ItemList" , Math::round(4 * scale)); |
| 816 | theme->set_constant("line_separation" , "ItemList" , Math::round(2 * scale)); |
| 817 | |
| 818 | theme->set_font("font" , "ItemList" , Ref<Font>()); |
| 819 | theme->set_font_size("font_size" , "ItemList" , -1); |
| 820 | |
| 821 | theme->set_color("font_color" , "ItemList" , control_font_lower_color); |
| 822 | theme->set_color("font_hovered_color" , "ItemList" , control_font_hover_color); |
| 823 | theme->set_color("font_selected_color" , "ItemList" , control_font_pressed_color); |
| 824 | theme->set_color("font_outline_color" , "ItemList" , Color(1, 1, 1)); |
| 825 | theme->set_color("guide_color" , "ItemList" , Color(0.7, 0.7, 0.7, 0.25)); |
| 826 | theme->set_stylebox("hovered" , "ItemList" , make_flat_stylebox(Color(1, 1, 1, 0.07))); |
| 827 | theme->set_stylebox("selected" , "ItemList" , make_flat_stylebox(style_selected_color)); |
| 828 | theme->set_stylebox("selected_focus" , "ItemList" , make_flat_stylebox(style_selected_color)); |
| 829 | theme->set_stylebox("cursor" , "ItemList" , focus); |
| 830 | theme->set_stylebox("cursor_unfocused" , "ItemList" , focus); |
| 831 | |
| 832 | theme->set_constant("outline_size" , "ItemList" , 0); |
| 833 | |
| 834 | // TabContainer |
| 835 | |
| 836 | Ref<StyleBoxFlat> style_tab_selected = make_flat_stylebox(style_normal_color, 10, 4, 10, 4, 0); |
| 837 | style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * scale)); |
| 838 | style_tab_selected->set_border_color(style_focus_color); |
| 839 | Ref<StyleBoxFlat> style_tab_unselected = make_flat_stylebox(style_pressed_color, 10, 4, 10, 4, 0); |
| 840 | // Add some spacing between unselected tabs to make them easier to distinguish from each other. |
| 841 | style_tab_unselected->set_border_width(SIDE_LEFT, Math::round(scale)); |
| 842 | style_tab_unselected->set_border_width(SIDE_RIGHT, Math::round(scale)); |
| 843 | style_tab_unselected->set_border_color(style_popup_border_color); |
| 844 | Ref<StyleBoxFlat> style_tab_disabled = style_tab_unselected->duplicate(); |
| 845 | style_tab_disabled->set_bg_color(style_disabled_color); |
| 846 | Ref<StyleBoxFlat> style_tab_hovered = style_tab_unselected->duplicate(); |
| 847 | style_tab_hovered->set_bg_color(Color(0.1, 0.1, 0.1, 0.3)); |
| 848 | |
| 849 | theme->set_stylebox("tab_selected" , "TabContainer" , style_tab_selected); |
| 850 | theme->set_stylebox("tab_hovered" , "TabContainer" , style_tab_hovered); |
| 851 | theme->set_stylebox("tab_unselected" , "TabContainer" , style_tab_unselected); |
| 852 | theme->set_stylebox("tab_disabled" , "TabContainer" , style_tab_disabled); |
| 853 | theme->set_stylebox("panel" , "TabContainer" , make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); |
| 854 | theme->set_stylebox("tabbar_background" , "TabContainer" , make_empty_stylebox(0, 0, 0, 0)); |
| 855 | |
| 856 | theme->set_icon("increment" , "TabContainer" , icons["scroll_button_right" ]); |
| 857 | theme->set_icon("increment_highlight" , "TabContainer" , icons["scroll_button_right_hl" ]); |
| 858 | theme->set_icon("decrement" , "TabContainer" , icons["scroll_button_left" ]); |
| 859 | theme->set_icon("decrement_highlight" , "TabContainer" , icons["scroll_button_left_hl" ]); |
| 860 | theme->set_icon("drop_mark" , "TabContainer" , icons["tabs_drop_mark" ]); |
| 861 | theme->set_icon("menu" , "TabContainer" , icons["tabs_menu" ]); |
| 862 | theme->set_icon("menu_highlight" , "TabContainer" , icons["tabs_menu_hl" ]); |
| 863 | |
| 864 | theme->set_font("font" , "TabContainer" , Ref<Font>()); |
| 865 | theme->set_font_size("font_size" , "TabContainer" , -1); |
| 866 | |
| 867 | theme->set_color("font_selected_color" , "TabContainer" , control_font_hover_color); |
| 868 | theme->set_color("font_hovered_color" , "TabContainer" , control_font_hover_color); |
| 869 | theme->set_color("font_unselected_color" , "TabContainer" , control_font_low_color); |
| 870 | theme->set_color("font_disabled_color" , "TabContainer" , control_font_disabled_color); |
| 871 | theme->set_color("font_outline_color" , "TabContainer" , Color(1, 1, 1)); |
| 872 | theme->set_color("drop_mark_color" , "TabContainer" , Color(1, 1, 1)); |
| 873 | |
| 874 | theme->set_constant("side_margin" , "TabContainer" , Math::round(8 * scale)); |
| 875 | theme->set_constant("icon_separation" , "TabContainer" , Math::round(4 * scale)); |
| 876 | theme->set_constant("icon_max_width" , "TabContainer" , 0); |
| 877 | theme->set_constant("outline_size" , "TabContainer" , 0); |
| 878 | |
| 879 | // TabBar |
| 880 | |
| 881 | theme->set_stylebox("tab_selected" , "TabBar" , style_tab_selected); |
| 882 | theme->set_stylebox("tab_hovered" , "TabBar" , style_tab_hovered); |
| 883 | theme->set_stylebox("tab_unselected" , "TabBar" , style_tab_unselected); |
| 884 | theme->set_stylebox("tab_disabled" , "TabBar" , style_tab_disabled); |
| 885 | theme->set_stylebox("button_pressed" , "TabBar" , button_pressed); |
| 886 | theme->set_stylebox("button_highlight" , "TabBar" , button_normal); |
| 887 | |
| 888 | theme->set_icon("increment" , "TabBar" , icons["scroll_button_right" ]); |
| 889 | theme->set_icon("increment_highlight" , "TabBar" , icons["scroll_button_right_hl" ]); |
| 890 | theme->set_icon("decrement" , "TabBar" , icons["scroll_button_left" ]); |
| 891 | theme->set_icon("decrement_highlight" , "TabBar" , icons["scroll_button_left_hl" ]); |
| 892 | theme->set_icon("drop_mark" , "TabBar" , icons["tabs_drop_mark" ]); |
| 893 | theme->set_icon("close" , "TabBar" , icons["close" ]); |
| 894 | |
| 895 | theme->set_font("font" , "TabBar" , Ref<Font>()); |
| 896 | theme->set_font_size("font_size" , "TabBar" , -1); |
| 897 | |
| 898 | theme->set_color("font_selected_color" , "TabBar" , control_font_hover_color); |
| 899 | theme->set_color("font_hovered_color" , "TabBar" , control_font_hover_color); |
| 900 | theme->set_color("font_unselected_color" , "TabBar" , control_font_low_color); |
| 901 | theme->set_color("font_disabled_color" , "TabBar" , control_font_disabled_color); |
| 902 | theme->set_color("font_outline_color" , "TabBar" , Color(1, 1, 1)); |
| 903 | theme->set_color("drop_mark_color" , "TabBar" , Color(1, 1, 1)); |
| 904 | |
| 905 | theme->set_constant("h_separation" , "TabBar" , Math::round(4 * scale)); |
| 906 | theme->set_constant("icon_max_width" , "TabBar" , 0); |
| 907 | theme->set_constant("outline_size" , "TabBar" , 0); |
| 908 | |
| 909 | // Separators |
| 910 | |
| 911 | theme->set_stylebox("separator" , "HSeparator" , separator_horizontal); |
| 912 | theme->set_stylebox("separator" , "VSeparator" , separator_vertical); |
| 913 | |
| 914 | theme->set_icon("close" , "Icons" , icons["close" ]); |
| 915 | theme->set_font("normal" , "Fonts" , Ref<Font>()); |
| 916 | theme->set_font("large" , "Fonts" , Ref<Font>()); |
| 917 | |
| 918 | theme->set_constant("separation" , "HSeparator" , Math::round(4 * scale)); |
| 919 | theme->set_constant("separation" , "VSeparator" , Math::round(4 * scale)); |
| 920 | |
| 921 | // ColorPicker |
| 922 | |
| 923 | theme->set_constant("margin" , "ColorPicker" , Math::round(4 * scale)); |
| 924 | theme->set_constant("sv_width" , "ColorPicker" , Math::round(256 * scale)); |
| 925 | theme->set_constant("sv_height" , "ColorPicker" , Math::round(256 * scale)); |
| 926 | theme->set_constant("h_width" , "ColorPicker" , Math::round(30 * scale)); |
| 927 | theme->set_constant("label_width" , "ColorPicker" , Math::round(10 * scale)); |
| 928 | theme->set_constant("center_slider_grabbers" , "ColorPicker" , 1); |
| 929 | |
| 930 | theme->set_icon("folded_arrow" , "ColorPicker" , icons["arrow_right" ]); |
| 931 | theme->set_icon("expanded_arrow" , "ColorPicker" , icons["arrow_down" ]); |
| 932 | theme->set_icon("screen_picker" , "ColorPicker" , icons["color_picker_pipette" ]); |
| 933 | theme->set_icon("shape_circle" , "ColorPicker" , icons["picker_shape_circle" ]); |
| 934 | theme->set_icon("shape_rect" , "ColorPicker" , icons["picker_shape_rectangle" ]); |
| 935 | theme->set_icon("shape_rect_wheel" , "ColorPicker" , icons["picker_shape_rectangle_wheel" ]); |
| 936 | theme->set_icon("add_preset" , "ColorPicker" , icons["add" ]); |
| 937 | theme->set_icon("sample_bg" , "ColorPicker" , icons["mini_checkerboard" ]); |
| 938 | theme->set_icon("overbright_indicator" , "ColorPicker" , icons["color_picker_overbright" ]); |
| 939 | theme->set_icon("bar_arrow" , "ColorPicker" , icons["color_picker_bar_arrow" ]); |
| 940 | theme->set_icon("picker_cursor" , "ColorPicker" , icons["color_picker_cursor" ]); |
| 941 | |
| 942 | { |
| 943 | const int precision = 7; |
| 944 | |
| 945 | Ref<Gradient> hue_gradient; |
| 946 | hue_gradient.instantiate(); |
| 947 | PackedFloat32Array offsets; |
| 948 | offsets.resize(precision); |
| 949 | PackedColorArray colors; |
| 950 | colors.resize(precision); |
| 951 | |
| 952 | for (int i = 0; i < precision; i++) { |
| 953 | float h = i / float(precision - 1); |
| 954 | offsets.write[i] = h; |
| 955 | colors.write[i] = Color::from_hsv(h, 1, 1); |
| 956 | } |
| 957 | hue_gradient->set_offsets(offsets); |
| 958 | hue_gradient->set_colors(colors); |
| 959 | |
| 960 | Ref<GradientTexture2D> hue_texture; |
| 961 | hue_texture.instantiate(); |
| 962 | hue_texture->set_width(800); |
| 963 | hue_texture->set_height(6); |
| 964 | hue_texture->set_gradient(hue_gradient); |
| 965 | |
| 966 | theme->set_icon("color_hue" , "ColorPicker" , hue_texture); |
| 967 | } |
| 968 | |
| 969 | { |
| 970 | const int precision = 7; |
| 971 | |
| 972 | Ref<Gradient> hue_gradient; |
| 973 | hue_gradient.instantiate(); |
| 974 | PackedFloat32Array offsets; |
| 975 | offsets.resize(precision); |
| 976 | PackedColorArray colors; |
| 977 | colors.resize(precision); |
| 978 | |
| 979 | for (int i = 0; i < precision; i++) { |
| 980 | float h = i / float(precision - 1); |
| 981 | offsets.write[i] = h; |
| 982 | colors.write[i] = Color::from_ok_hsl(h, 1, 0.5); |
| 983 | } |
| 984 | hue_gradient->set_offsets(offsets); |
| 985 | hue_gradient->set_colors(colors); |
| 986 | |
| 987 | Ref<GradientTexture2D> hue_texture; |
| 988 | hue_texture.instantiate(); |
| 989 | hue_texture->set_width(800); |
| 990 | hue_texture->set_height(6); |
| 991 | hue_texture->set_gradient(hue_gradient); |
| 992 | |
| 993 | theme->set_icon("color_okhsl_hue" , "ColorPicker" , hue_texture); |
| 994 | } |
| 995 | |
| 996 | // ColorPickerButton |
| 997 | |
| 998 | theme->set_icon("bg" , "ColorPickerButton" , icons["mini_checkerboard" ]); |
| 999 | theme->set_stylebox("normal" , "ColorPickerButton" , button_normal); |
| 1000 | theme->set_stylebox("pressed" , "ColorPickerButton" , button_pressed); |
| 1001 | theme->set_stylebox("hover" , "ColorPickerButton" , button_hover); |
| 1002 | theme->set_stylebox("disabled" , "ColorPickerButton" , button_disabled); |
| 1003 | theme->set_stylebox("focus" , "ColorPickerButton" , focus); |
| 1004 | |
| 1005 | theme->set_font("font" , "ColorPickerButton" , Ref<Font>()); |
| 1006 | theme->set_font_size("font_size" , "ColorPickerButton" , -1); |
| 1007 | |
| 1008 | theme->set_color("font_color" , "ColorPickerButton" , Color(1, 1, 1, 1)); |
| 1009 | theme->set_color("font_pressed_color" , "ColorPickerButton" , Color(0.8, 0.8, 0.8, 1)); |
| 1010 | theme->set_color("font_hover_color" , "ColorPickerButton" , Color(1, 1, 1, 1)); |
| 1011 | theme->set_color("font_focus_color" , "ColorPickerButton" , Color(1, 1, 1, 1)); |
| 1012 | theme->set_color("font_disabled_color" , "ColorPickerButton" , Color(0.9, 0.9, 0.9, 0.3)); |
| 1013 | theme->set_color("font_outline_color" , "ColorPickerButton" , Color(1, 1, 1)); |
| 1014 | |
| 1015 | theme->set_constant("h_separation" , "ColorPickerButton" , Math::round(4 * scale)); |
| 1016 | theme->set_constant("outline_size" , "ColorPickerButton" , 0); |
| 1017 | |
| 1018 | // ColorPresetButton |
| 1019 | |
| 1020 | Ref<StyleBoxFlat> preset_sb = make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2); |
| 1021 | preset_sb->set_corner_radius_all(Math::round(2 * scale)); |
| 1022 | preset_sb->set_corner_detail(Math::round(2 * scale)); |
| 1023 | preset_sb->set_anti_aliased(false); |
| 1024 | |
| 1025 | theme->set_stylebox("preset_fg" , "ColorPresetButton" , preset_sb); |
| 1026 | theme->set_icon("preset_bg" , "ColorPresetButton" , icons["mini_checkerboard" ]); |
| 1027 | theme->set_icon("overbright_indicator" , "ColorPresetButton" , icons["color_picker_overbright" ]); |
| 1028 | |
| 1029 | // TooltipPanel + TooltipLabel |
| 1030 | |
| 1031 | theme->set_type_variation("TooltipPanel" , "PopupPanel" ); |
| 1032 | theme->set_stylebox("panel" , "TooltipPanel" , |
| 1033 | make_flat_stylebox(Color(0, 0, 0, 0.5), 2 * default_margin, 0.5 * default_margin, 2 * default_margin, 0.5 * default_margin)); |
| 1034 | |
| 1035 | theme->set_type_variation("TooltipLabel" , "Label" ); |
| 1036 | theme->set_font_size("font_size" , "TooltipLabel" , -1); |
| 1037 | theme->set_font("font" , "TooltipLabel" , Ref<Font>()); |
| 1038 | |
| 1039 | theme->set_color("font_color" , "TooltipLabel" , control_font_color); |
| 1040 | theme->set_color("font_shadow_color" , "TooltipLabel" , Color(0, 0, 0, 0)); |
| 1041 | theme->set_color("font_outline_color" , "TooltipLabel" , Color(0, 0, 0, 0)); |
| 1042 | |
| 1043 | theme->set_constant("shadow_offset_x" , "TooltipLabel" , 1); |
| 1044 | theme->set_constant("shadow_offset_y" , "TooltipLabel" , 1); |
| 1045 | theme->set_constant("outline_size" , "TooltipLabel" , 0); |
| 1046 | |
| 1047 | // RichTextLabel |
| 1048 | |
| 1049 | theme->set_stylebox("focus" , "RichTextLabel" , focus); |
| 1050 | theme->set_stylebox("normal" , "RichTextLabel" , make_empty_stylebox(0, 0, 0, 0)); |
| 1051 | |
| 1052 | theme->set_font("normal_font" , "RichTextLabel" , Ref<Font>()); |
| 1053 | theme->set_font("bold_font" , "RichTextLabel" , bold_font); |
| 1054 | theme->set_font("italics_font" , "RichTextLabel" , italics_font); |
| 1055 | theme->set_font("bold_italics_font" , "RichTextLabel" , bold_italics_font); |
| 1056 | theme->set_font("mono_font" , "RichTextLabel" , Ref<Font>()); |
| 1057 | theme->set_font_size("normal_font_size" , "RichTextLabel" , -1); |
| 1058 | theme->set_font_size("bold_font_size" , "RichTextLabel" , -1); |
| 1059 | theme->set_font_size("italics_font_size" , "RichTextLabel" , -1); |
| 1060 | theme->set_font_size("bold_italics_font_size" , "RichTextLabel" , -1); |
| 1061 | theme->set_font_size("mono_font_size" , "RichTextLabel" , -1); |
| 1062 | |
| 1063 | theme->set_color("default_color" , "RichTextLabel" , Color(1, 1, 1)); |
| 1064 | theme->set_color("font_selected_color" , "RichTextLabel" , Color(0, 0, 0, 0)); |
| 1065 | theme->set_color("selection_color" , "RichTextLabel" , Color(0.1, 0.1, 1, 0.8)); |
| 1066 | |
| 1067 | theme->set_color("font_shadow_color" , "RichTextLabel" , Color(0, 0, 0, 0)); |
| 1068 | |
| 1069 | theme->set_color("font_outline_color" , "RichTextLabel" , Color(1, 1, 1)); |
| 1070 | |
| 1071 | theme->set_constant("shadow_offset_x" , "RichTextLabel" , Math::round(1 * scale)); |
| 1072 | theme->set_constant("shadow_offset_y" , "RichTextLabel" , Math::round(1 * scale)); |
| 1073 | theme->set_constant("shadow_outline_size" , "RichTextLabel" , Math::round(1 * scale)); |
| 1074 | |
| 1075 | theme->set_constant("line_separation" , "RichTextLabel" , 0); |
| 1076 | theme->set_constant("table_h_separation" , "RichTextLabel" , Math::round(3 * scale)); |
| 1077 | theme->set_constant("table_v_separation" , "RichTextLabel" , Math::round(3 * scale)); |
| 1078 | |
| 1079 | theme->set_constant("outline_size" , "RichTextLabel" , 0); |
| 1080 | |
| 1081 | theme->set_color("table_odd_row_bg" , "RichTextLabel" , Color(0, 0, 0, 0)); |
| 1082 | theme->set_color("table_even_row_bg" , "RichTextLabel" , Color(0, 0, 0, 0)); |
| 1083 | theme->set_color("table_border" , "RichTextLabel" , Color(0, 0, 0, 0)); |
| 1084 | |
| 1085 | theme->set_constant("text_highlight_h_padding" , "RichTextLabel" , Math::round(3 * scale)); |
| 1086 | theme->set_constant("text_highlight_v_padding" , "RichTextLabel" , Math::round(3 * scale)); |
| 1087 | |
| 1088 | // Containers |
| 1089 | |
| 1090 | theme->set_icon("h_grabber" , "SplitContainer" , icons["hsplitter" ]); |
| 1091 | theme->set_icon("v_grabber" , "SplitContainer" , icons["vsplitter" ]); |
| 1092 | theme->set_icon("grabber" , "VSplitContainer" , icons["vsplitter" ]); |
| 1093 | theme->set_icon("grabber" , "HSplitContainer" , icons["hsplitter" ]); |
| 1094 | |
| 1095 | theme->set_constant("separation" , "BoxContainer" , Math::round(4 * scale)); |
| 1096 | theme->set_constant("separation" , "HBoxContainer" , Math::round(4 * scale)); |
| 1097 | theme->set_constant("separation" , "VBoxContainer" , Math::round(4 * scale)); |
| 1098 | theme->set_constant("margin_left" , "MarginContainer" , 0); |
| 1099 | theme->set_constant("margin_top" , "MarginContainer" , 0); |
| 1100 | theme->set_constant("margin_right" , "MarginContainer" , 0); |
| 1101 | theme->set_constant("margin_bottom" , "MarginContainer" , 0); |
| 1102 | theme->set_constant("h_separation" , "GridContainer" , Math::round(4 * scale)); |
| 1103 | theme->set_constant("v_separation" , "GridContainer" , Math::round(4 * scale)); |
| 1104 | theme->set_constant("separation" , "SplitContainer" , Math::round(12 * scale)); |
| 1105 | theme->set_constant("separation" , "HSplitContainer" , Math::round(12 * scale)); |
| 1106 | theme->set_constant("separation" , "VSplitContainer" , Math::round(12 * scale)); |
| 1107 | theme->set_constant("minimum_grab_thickness" , "SplitContainer" , Math::round(6 * scale)); |
| 1108 | theme->set_constant("minimum_grab_thickness" , "HSplitContainer" , Math::round(6 * scale)); |
| 1109 | theme->set_constant("minimum_grab_thickness" , "VSplitContainer" , Math::round(6 * scale)); |
| 1110 | theme->set_constant("autohide" , "SplitContainer" , 1); |
| 1111 | theme->set_constant("autohide" , "HSplitContainer" , 1); |
| 1112 | theme->set_constant("autohide" , "VSplitContainer" , 1); |
| 1113 | theme->set_constant("h_separation" , "FlowContainer" , Math::round(4 * scale)); |
| 1114 | theme->set_constant("v_separation" , "FlowContainer" , Math::round(4 * scale)); |
| 1115 | theme->set_constant("h_separation" , "HFlowContainer" , Math::round(4 * scale)); |
| 1116 | theme->set_constant("v_separation" , "HFlowContainer" , Math::round(4 * scale)); |
| 1117 | theme->set_constant("h_separation" , "VFlowContainer" , Math::round(4 * scale)); |
| 1118 | theme->set_constant("v_separation" , "VFlowContainer" , Math::round(4 * scale)); |
| 1119 | |
| 1120 | theme->set_stylebox("panel" , "PanelContainer" , make_flat_stylebox(style_normal_color, 0, 0, 0, 0)); |
| 1121 | |
| 1122 | theme->set_icon("zoom_out" , "GraphEdit" , icons["zoom_less" ]); |
| 1123 | theme->set_icon("zoom_in" , "GraphEdit" , icons["zoom_more" ]); |
| 1124 | theme->set_icon("zoom_reset" , "GraphEdit" , icons["zoom_reset" ]); |
| 1125 | theme->set_icon("grid_toggle" , "GraphEdit" , icons["grid_toggle" ]); |
| 1126 | theme->set_icon("minimap_toggle" , "GraphEdit" , icons["grid_minimap" ]); |
| 1127 | theme->set_icon("snapping_toggle" , "GraphEdit" , icons["grid_snap" ]); |
| 1128 | theme->set_icon("layout" , "GraphEdit" , icons["grid_layout" ]); |
| 1129 | |
| 1130 | theme->set_stylebox("panel" , "GraphEdit" , make_flat_stylebox(style_normal_color, 4, 4, 4, 5)); |
| 1131 | |
| 1132 | theme->set_color("grid_minor" , "GraphEdit" , Color(1, 1, 1, 0.05)); |
| 1133 | theme->set_color("grid_major" , "GraphEdit" , Color(1, 1, 1, 0.2)); |
| 1134 | theme->set_color("selection_fill" , "GraphEdit" , Color(1, 1, 1, 0.3)); |
| 1135 | theme->set_color("selection_stroke" , "GraphEdit" , Color(1, 1, 1, 0.8)); |
| 1136 | theme->set_color("activity" , "GraphEdit" , Color(1, 1, 1)); |
| 1137 | |
| 1138 | // Visual Node Ports |
| 1139 | |
| 1140 | theme->set_constant("port_hotzone_inner_extent" , "GraphEdit" , 22 * scale); |
| 1141 | theme->set_constant("port_hotzone_outer_extent" , "GraphEdit" , 26 * scale); |
| 1142 | |
| 1143 | theme->set_stylebox("panel" , "GraphEditMinimap" , make_flat_stylebox(Color(0.24, 0.24, 0.24), 0, 0, 0, 0)); |
| 1144 | Ref<StyleBoxFlat> style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0, 0); |
| 1145 | style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45)); |
| 1146 | style_minimap_camera->set_border_width_all(1); |
| 1147 | theme->set_stylebox("camera" , "GraphEditMinimap" , style_minimap_camera); |
| 1148 | theme->set_stylebox("node" , "GraphEditMinimap" , make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0, 2)); |
| 1149 | |
| 1150 | theme->set_icon("resizer" , "GraphEditMinimap" , icons["resizer_nw" ]); |
| 1151 | theme->set_color("resizer_color" , "GraphEditMinimap" , Color(1, 1, 1, 0.85)); |
| 1152 | |
| 1153 | // Theme |
| 1154 | |
| 1155 | default_icon = icons["error_icon" ]; |
| 1156 | // Same color as the error icon. |
| 1157 | default_style = make_flat_stylebox(Color(1, 0.365, 0.365), 4, 4, 4, 4, 0, false, 2); |
| 1158 | } |
| 1159 | |
| 1160 | void make_default_theme(float p_scale, Ref<Font> p_font, TextServer::SubpixelPositioning p_font_subpixel, TextServer::Hinting p_font_hinting, TextServer::FontAntialiasing p_font_antialiasing, bool p_font_msdf, bool p_font_generate_mipmaps) { |
| 1161 | Ref<Theme> t; |
| 1162 | t.instantiate(); |
| 1163 | |
| 1164 | Ref<StyleBox> default_style; |
| 1165 | Ref<Texture2D> default_icon; |
| 1166 | Ref<Font> default_font; |
| 1167 | Ref<FontVariation> bold_font; |
| 1168 | Ref<FontVariation> bold_italics_font; |
| 1169 | Ref<FontVariation> italics_font; |
| 1170 | float default_scale = CLAMP(p_scale, 0.5, 8.0); |
| 1171 | |
| 1172 | if (p_font.is_valid()) { |
| 1173 | // Use the custom font defined in the Project Settings. |
| 1174 | default_font = p_font; |
| 1175 | } else { |
| 1176 | // Use the default DynamicFont (separate from the editor font). |
| 1177 | // The default DynamicFont is chosen to have a small file size since it's |
| 1178 | // embedded in both editor and export template binaries. |
| 1179 | Ref<FontFile> dynamic_font; |
| 1180 | dynamic_font.instantiate(); |
| 1181 | dynamic_font->set_data_ptr(_font_OpenSans_SemiBold, _font_OpenSans_SemiBold_size); |
| 1182 | dynamic_font->set_subpixel_positioning(p_font_subpixel); |
| 1183 | dynamic_font->set_hinting(p_font_hinting); |
| 1184 | dynamic_font->set_antialiasing(p_font_antialiasing); |
| 1185 | dynamic_font->set_multichannel_signed_distance_field(p_font_msdf); |
| 1186 | dynamic_font->set_generate_mipmaps(p_font_generate_mipmaps); |
| 1187 | |
| 1188 | default_font = dynamic_font; |
| 1189 | } |
| 1190 | |
| 1191 | if (default_font.is_valid()) { |
| 1192 | bold_font.instantiate(); |
| 1193 | bold_font->set_base_font(default_font); |
| 1194 | bold_font->set_variation_embolden(1.2); |
| 1195 | |
| 1196 | bold_italics_font.instantiate(); |
| 1197 | bold_italics_font->set_base_font(default_font); |
| 1198 | bold_italics_font->set_variation_embolden(1.2); |
| 1199 | bold_italics_font->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0)); |
| 1200 | |
| 1201 | italics_font.instantiate(); |
| 1202 | italics_font->set_base_font(default_font); |
| 1203 | italics_font->set_variation_transform(Transform2D(1.0, 0.2, 0.0, 1.0, 0.0, 0.0)); |
| 1204 | } |
| 1205 | |
| 1206 | fill_default_theme(t, default_font, bold_font, bold_italics_font, italics_font, default_icon, default_style, default_scale); |
| 1207 | |
| 1208 | ThemeDB::get_singleton()->set_default_theme(t); |
| 1209 | |
| 1210 | ThemeDB::get_singleton()->set_fallback_base_scale(default_scale); |
| 1211 | ThemeDB::get_singleton()->set_fallback_icon(default_icon); |
| 1212 | ThemeDB::get_singleton()->set_fallback_stylebox(default_style); |
| 1213 | ThemeDB::get_singleton()->set_fallback_font(default_font); |
| 1214 | ThemeDB::get_singleton()->set_fallback_font_size(default_font_size * default_scale); |
| 1215 | } |
| 1216 | |