diff options
-rw-r--r-- | core/math/math_2d.h | 8 | ||||
-rw-r--r-- | core/method_bind.h | 1 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 4 | ||||
-rw-r--r-- | drivers/unix/dir_access_unix.cpp | 45 | ||||
-rw-r--r-- | editor/editor_file_system.cpp | 70 | ||||
-rw-r--r-- | editor/editor_file_system.h | 7 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 137 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 21 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/progress_dialog.cpp | 7 | ||||
-rw-r--r-- | editor/property_editor.cpp | 14 | ||||
-rw-r--r-- | main/input_default.cpp | 2 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 1 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 8 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 2 | ||||
-rw-r--r-- | scene/gui/item_list.h | 2 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 546 | ||||
-rw-r--r-- | scene/resources/style_box.h | 94 | ||||
-rw-r--r-- | scene/resources/theme.cpp | 6 | ||||
-rw-r--r-- | servers/visual/shader_language.cpp | 6 |
22 files changed, 762 insertions, 232 deletions
diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 963b5efc43..6fea6c8adb 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -43,6 +43,14 @@ enum Margin { MARGIN_BOTTOM }; +enum Corner { + + CORNER_TOP_LEFT, + CORNER_TOP_RIGHT, + CORNER_BOTTOM_RIGHT, + CORNER_BOTTOM_LEFT +}; + enum Orientation { HORIZONTAL, diff --git a/core/method_bind.h b/core/method_bind.h index 3b4ff96a19..9bf0323733 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -150,6 +150,7 @@ VARIANT_ENUM_CAST(Vector3::Axis); VARIANT_ENUM_CAST(Error); VARIANT_ENUM_CAST(wchar_t); VARIANT_ENUM_CAST(Margin); +VARIANT_ENUM_CAST(Corner); VARIANT_ENUM_CAST(Orientation); VARIANT_ENUM_CAST(HAlign); VARIANT_ENUM_CAST(Variant::Type); diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index ea6ac569f0..24fa117051 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -5177,6 +5177,10 @@ void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emit Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); + if (p_emitting != particles->emitting) { + // Restart is overriden by set_emitting + particles->restart_request = false; + } particles->emitting = p_emitting; } void RasterizerStorageGLES3::particles_set_amount(RID p_particles, int p_amount) { diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index cf54f3fea0..a183a37446 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -223,36 +223,37 @@ Error DirAccessUnix::make_dir(String p_dir) { Error DirAccessUnix::change_dir(String p_dir) { GLOBAL_LOCK_FUNCTION - p_dir = fix_path(p_dir); - char real_current_dir_name[2048]; - getcwd(real_current_dir_name, 2048); - String prev_dir; - if (prev_dir.parse_utf8(real_current_dir_name)) - prev_dir = real_current_dir_name; //no utf8, maybe latin? + // make sure current_dir is valid absolute path + if (current_dir == "." || current_dir == "") { + char real_current_dir_name[2048]; + getcwd(real_current_dir_name, 2048); + current_dir.parse_utf8(real_current_dir_name); + } - chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants - bool worked = (chdir(p_dir.utf8().get_data()) == 0); // we can only give this utf8 + if (p_dir == ".") { + return OK; + } - String base = _get_root_path(); - if (base != "") { + p_dir = fix_path(p_dir); - getcwd(real_current_dir_name, 2048); - String new_dir; - new_dir.parse_utf8(real_current_dir_name); - if (!new_dir.begins_with(base)) - worked = false; - } + String prev_dir = current_dir; - if (worked) { + if (p_dir.is_rel_path()) { + String next_dir = current_dir + "/" + p_dir; + next_dir = next_dir.simplify_path(); + current_dir = next_dir; + } else { + current_dir = p_dir; + } - getcwd(real_current_dir_name, 2048); - if (current_dir.parse_utf8(real_current_dir_name)) - current_dir = real_current_dir_name; //no utf8, maybe latin? + bool worked = (chdir(current_dir.utf8().get_data()) == 0); // we can only give this utf8 + if (!worked) { + current_dir = prev_dir; + return ERR_INVALID_PARAMETER; } - chdir(prev_dir.utf8().get_data()); - return worked ? OK : ERR_INVALID_PARAMETER; + return OK; } String DirAccessUnix::get_current_dir() { diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 2f4ac02703..9d194e0501 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -230,6 +230,28 @@ void EditorFileSystem::_scan_filesystem() { memdelete(f); } + String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2"); + + print_line("try to see fs update2"); + if (FileAccess::exists(update_cache)) { + + print_line("it exists"); + + { + FileAccessRef f = FileAccess::open(update_cache, FileAccess::READ); + String l = f->get_line().strip_edges(); + while (l != String()) { + + print_line("erased cache for: " + l + " " + itos(file_cache.has(l))); + file_cache.erase(l); //erase cache for this, so it gets updated + l = f->get_line().strip_edges(); + } + } + + DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + d->remove(update_cache); //bye bye update cache + } + EditorProgressBG scan_progress("efs", "ScanFS", 1000); ScanProgress sp; @@ -597,11 +619,13 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && _check_missing_imported_files(path)) { fi->type = fc->type; + fi->deps = fc->deps; fi->modified_time = fc->modification_time; fi->import_modified_time = fc->import_modification_time; if (fc->type == String()) { fi->type = ResourceLoader::get_resource_type(path); //there is also the chance that file type changed due to reimport, must probably check this somehow here (or kind of note it for next time in another file?) + //note: I think this should not happen any longer.. } } else { @@ -620,6 +644,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess } fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path); + //fi->deps = ResourceLoader::get_dependencies(path); pointless because it will be reimported, but.. print_line("import extension tried resource type for " + path + " and its " + fi->type); fi->modified_time = 0; fi->import_modified_time = 0; @@ -631,14 +656,17 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess scan_actions.push_back(ia); } } else { - //not imported, so just update type if changed - if (fc && fc->modification_time == mt) { + if (fc && fc->modification_time == mt) { + //not imported, so just update type if changed fi->type = fc->type; fi->modified_time = fc->modification_time; + fi->deps = fc->deps; fi->import_modified_time = 0; } else { + //new or modified time fi->type = ResourceLoader::get_resource_type(path); + fi->deps = _get_dependencies(path); print_line("regular import tried resource type for " + path + " and its " + fi->type); fi->modified_time = mt; fi->import_modified_time = 0; @@ -1187,12 +1215,34 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p return fs; } +void EditorFileSystem::_save_late_updated_files() { + //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file + String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2"); + FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE); + for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) { + f->store_line(E->get()); + } +} + void EditorFileSystem::_resource_saved(const String &p_path) { //print_line("resource saved: "+p_path); EditorFileSystem::get_singleton()->update_file(p_path); } +Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) { + + List<String> deps; + ResourceLoader::get_dependencies(p_path, &deps); + + Vector<String> ret; + for (List<String>::Element *E = deps.front(); E; E = E->next()) { + ret.push_back(E->get()); + } + + return ret; +} + void EditorFileSystem::update_file(const String &p_file) { EditorFileSystemDirectory *fs = NULL; @@ -1217,6 +1267,9 @@ void EditorFileSystem::update_file(const String &p_file) { if (cpos == -1) { + //the file did not exist, it was added + + late_added_files.insert(p_file); //remember that it was added. This mean it will be scanned and imported on editor restart int idx = 0; for (int i = 0; i < fs->files.size(); i++) { @@ -1236,11 +1289,18 @@ void EditorFileSystem::update_file(const String &p_file) { fs->files.insert(idx, fi); } cpos = idx; + } else { + + //the file exists and it was updated, and was not added in this step. + //this means we must force upon next restart to scan it again, to get proper type and dependencies + late_update_files.insert(p_file); + _save_late_updated_files(); //files need to be updated in the re-scan } //print_line("UPDATING: "+p_file); fs->files[cpos]->type = type; fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file); + fs->files[cpos]->deps = _get_dependencies(p_file); //if (FileAccess::exists(p_file+".import")) { // fs->files[cpos]->import_modified_time=FileAccess::get_modified_time(p_file+".import"); //} @@ -1276,6 +1336,9 @@ void EditorFileSystem::_reimport_file(const String &p_file) { } importer_name = cf->get_value("remap", "importer"); } + + } else { + late_added_files.insert(p_file); //imported files do not call update_file(), but just in case.. } Ref<ResourceImporter> importer; @@ -1357,6 +1420,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { } f->store_line(""); + if (gen_files.size()) { f->store_line("[gen]"); Array genf; @@ -1389,6 +1453,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) { //update modified times, to avoid reimport fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file); fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import"); + fs->files[cpos]->deps = _get_dependencies(p_file); + fs->files[cpos]->type = importer->get_resource_type(); //if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it //to reload properly diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index f98758fd03..fd62b06d07 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -137,6 +137,11 @@ class EditorFileSystem : public Node { void _scan_filesystem(); + Set<String> late_added_files; //keep track of files that were added, these will be re-scanned + Set<String> late_update_files; + + void _save_late_updated_files(); + EditorFileSystemDirectory *filesystem; static EditorFileSystem *singleton; @@ -196,6 +201,8 @@ class EditorFileSystem : public Node { bool reimport_on_missing_imported_files; + Vector<String> _get_dependencies(const String &p_path); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 19c77ef737..d8c8d419b9 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -249,8 +249,8 @@ bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEv } String EditorPlugin::get_name() const { - if (get_script_instance() && get_script_instance()->has_method("get_name")) { - return get_script_instance()->call("get_name"); + if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) { + return get_script_instance()->call("get_plugin_name"); } return String(); @@ -450,7 +450,7 @@ void EditorPlugin::_bind_methods() { gizmo.return_val.hint = PROPERTY_HINT_RESOURCE_TYPE; gizmo.return_val.hint_string = "EditorSpatialGizmo"; ClassDB::add_virtual_method(get_class_static(), gizmo); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_name")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen")); ClassDB::add_virtual_method(get_class_static(), MethodInfo("make_visible", PropertyInfo(Variant::BOOL, "visible"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("edit", PropertyInfo(Variant::OBJECT, "object"))); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 7c422eb26e..11150371d2 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -80,17 +80,20 @@ static Ref<StyleBoxLine> make_line_stylebox(Color color, int thickness = 1, floa static Ref<StyleBoxFlat> change_border_color(Ref<StyleBoxFlat> p_style, Color p_color) { Ref<StyleBoxFlat> style = p_style->duplicate(); - style->set_light_color(p_color); - style->set_dark_color(p_color); + style->set_border_color_all(p_color); return style; } static Ref<StyleBoxFlat> add_additional_border(Ref<StyleBoxFlat> p_style, int p_left, int p_top, int p_right, int p_bottom) { Ref<StyleBoxFlat> style = p_style->duplicate(); - style->_set_additional_border_size(MARGIN_LEFT, p_left * EDSCALE); - style->_set_additional_border_size(MARGIN_RIGHT, p_right * EDSCALE); - style->_set_additional_border_size(MARGIN_TOP, p_top * EDSCALE); - style->_set_additional_border_size(MARGIN_BOTTOM, p_bottom * EDSCALE); + style->set_border_width(MARGIN_LEFT, p_left * EDSCALE + style->get_border_width(MARGIN_LEFT)); + style->set_border_width(MARGIN_RIGHT, p_right * EDSCALE + style->get_border_width(MARGIN_RIGHT)); + style->set_border_width(MARGIN_TOP, p_top * EDSCALE + style->get_border_width(MARGIN_TOP)); + style->set_border_width(MARGIN_BOTTOM, p_bottom * EDSCALE + style->get_border_width(MARGIN_BOTTOM)); + style->set_expand_margin_size(MARGIN_LEFT, p_left * EDSCALE); + style->set_expand_margin_size(MARGIN_RIGHT, p_right * EDSCALE); + style->set_expand_margin_size(MARGIN_TOP, p_top * EDSCALE); + style->set_expand_margin_size(MARGIN_BOTTOM, p_bottom * EDSCALE); return style; } @@ -186,8 +189,8 @@ Ref<Theme> create_editor_theme() { // Focus Ref<StyleBoxFlat> focus_sbt = make_flat_stylebox(light_color_1, 4, 4, 4, 4); - focus_sbt->set_draw_center(false); - focus_sbt->set_border_size(border_width); + focus_sbt->set_filled(false); + focus_sbt->set_border_width_all(1 * EDSCALE); focus_sbt = change_border_color(focus_sbt, light_color_2); theme->set_stylebox("Focus", "EditorStyles", focus_sbt); @@ -202,8 +205,10 @@ Ref<Theme> create_editor_theme() { Ref<StyleBoxFlat> style_menu_hover_border = make_flat_stylebox(highlight_color, 4, 4, 4, 4); Ref<StyleBoxFlat> style_menu_hover_bg = make_flat_stylebox(dark_color_2, 4, 4, 4, 4); - style_menu_hover_border->set_draw_center(false); - style_menu_hover_border->_set_additional_border_size(MARGIN_BOTTOM, border_width); + style_menu_hover_border->set_filled(false); + style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width); + style_menu_hover_border->set_expand_margin_size(MARGIN_BOTTOM, border_width); + theme->set_stylebox("normal", "MenuButton", style_menu); theme->set_stylebox("hover", "MenuButton", style_menu); theme->set_stylebox("pressed", "MenuButton", style_menu); @@ -230,24 +235,18 @@ Ref<Theme> create_editor_theme() { // Content of each tab Ref<StyleBoxFlat> style_content_panel = make_flat_stylebox(base_color, 4, 5, 4, 4); - style_content_panel->set_dark_color(title_color_hl); - style_content_panel->set_light_color(title_color_hl); - style_content_panel->set_border_size(border_width); - style_content_panel->set_border_blend(false); + style_content_panel->set_border_color_all(title_color_hl); + style_content_panel->set_border_width_all(border_width); Ref<StyleBoxFlat> style_content_panel_vp = make_flat_stylebox(base_color, border_width, 5, border_width, border_width); - style_content_panel_vp->set_dark_color(title_color_hl); - style_content_panel_vp->set_light_color(title_color_hl); - style_content_panel_vp->set_border_size(border_width); - style_content_panel_vp->set_border_blend(false); + style_content_panel_vp->set_border_color_all(title_color_hl); + style_content_panel_vp->set_border_width_all(border_width); theme->set_stylebox("panel", "TabContainer", style_content_panel); theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); Ref<StyleBoxFlat> style_button_type = make_flat_stylebox(dark_color_1, 6, 4, 6, 4); - style_button_type->set_draw_center(true); - style_button_type->set_border_size(border_width); - style_button_type->set_light_color(light_color_1); - style_button_type->set_dark_color(light_color_1); - style_button_type->set_border_blend(false); + style_button_type->set_filled(true); + style_button_type->set_border_width_all(border_width); + style_button_type->set_border_color_all(light_color_1); Ref<StyleBoxFlat> style_button_type_disabled = change_border_color(style_button_type, dark_color_2); @@ -260,6 +259,7 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("focus", "Button", change_border_color(style_button_type, highlight_color)); theme->set_stylebox("disabled", "Button", style_button_type_disabled); theme->set_color("font_color", "Button", button_font_color); + theme->set_color("font_color_hover", "Button", HIGHLIGHT_COLOR_LIGHT); theme->set_color("font_color_pressed", "Button", highlight_color); theme->set_color("icon_color_hover", "Button", HIGHLIGHT_COLOR_LIGHT); @@ -267,11 +267,9 @@ Ref<Theme> create_editor_theme() { theme->set_color("icon_color_pressed", "Button", Color(highlight_color.r * 1.15, highlight_color.g * 1.15, highlight_color.b * 1.15, highlight_color.a)); // OptionButton - Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 8, 4); - style_option_button->set_border_size(border_width); - style_option_button->set_light_color(light_color_1); - style_option_button->set_dark_color(light_color_1); - style_option_button->set_border_blend(false); + Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4); + style_option_button->set_border_width_all(border_width); + style_option_button->set_border_color_all(light_color_1); theme->set_stylebox("hover", "OptionButton", change_border_color(style_button_type, HIGHLIGHT_COLOR_LIGHT)); theme->set_stylebox("pressed", "OptionButton", change_border_color(style_button_type, highlight_color)); theme->set_stylebox("focus", "OptionButton", change_border_color(style_button_type, highlight_color)); @@ -291,24 +289,20 @@ Ref<Theme> create_editor_theme() { // PopupMenu Ref<StyleBoxFlat> style_popup_menu = make_flat_stylebox(dark_color_1, 8, 8, 8, 8); - style_popup_menu->set_border_size(MAX(EDSCALE, border_width)); - style_popup_menu->set_light_color(light_color_1); - style_popup_menu->set_dark_color(light_color_1); - style_popup_menu->set_border_blend(false); + style_popup_menu->set_border_width_all(MAX(EDSCALE, border_width)); + style_popup_menu->set_border_color_all(light_color_1); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, MAX(EDSCALE, border_width), 8 - MAX(EDSCALE, border_width))); // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4); - style_tree_bg->set_border_size(border_width); - style_tree_bg->set_light_color(dark_color_3); - style_tree_bg->set_dark_color(dark_color_3); + style_tree_bg->set_border_width_all(border_width); + style_tree_bg->set_border_color_all(dark_color_3); theme->set_stylebox("bg", "Tree", style_tree_bg); // Script background Ref<StyleBoxFlat> style_script_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); - style_script_bg->set_border_size(border_width); - style_script_bg->set_light_color(dark_color_3); - style_script_bg->set_dark_color(dark_color_3); + style_script_bg->set_border_width_all(border_width); + style_script_bg->set_border_color_all(dark_color_3); theme->set_stylebox("ScriptPanel", "EditorStyles", style_script_bg); // Tree @@ -333,10 +327,10 @@ Ref<Theme> create_editor_theme() { theme->set_stylebox("selected", "Tree", style_tree_selected); Ref<StyleBoxFlat> style_tree_cursor = make_flat_stylebox(HIGHLIGHT_COLOR_DARK, 4, 4, 4, 4); - style_tree_cursor->set_draw_center(false); - style_tree_cursor->set_border_size(border_width); - style_tree_cursor->set_light_color(light_color_1); - style_tree_cursor->set_dark_color(light_color_1); + style_tree_cursor->set_filled(false); + style_tree_cursor->set_border_width_all(border_width); + style_tree_cursor->set_border_color_all(light_color_1); + Ref<StyleBoxFlat> style_tree_title = make_flat_stylebox(dark_color_3, 4, 4, 4, 4); theme->set_stylebox("cursor", "Tree", style_tree_cursor); theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor); @@ -353,14 +347,13 @@ Ref<Theme> create_editor_theme() { // ItemList Ref<StyleBoxFlat> style_itemlist_bg = make_flat_stylebox(dark_color_1, 4, 4, 4, 4); - style_itemlist_bg->set_border_size(border_width); - style_itemlist_bg->set_light_color(dark_color_3); - style_itemlist_bg->set_dark_color(dark_color_3); + style_itemlist_bg->set_border_width_all(border_width); + style_itemlist_bg->set_border_color_all(dark_color_3); + Ref<StyleBoxFlat> style_itemlist_cursor = make_flat_stylebox(highlight_color, 0, 0, 0, 0); - style_itemlist_cursor->set_draw_center(false); - style_itemlist_cursor->set_border_size(border_width); - style_itemlist_cursor->set_light_color(HIGHLIGHT_COLOR_DARK); - style_itemlist_cursor->set_dark_color(HIGHLIGHT_COLOR_DARK); + style_itemlist_cursor->set_filled(false); + style_itemlist_cursor->set_border_width_all(border_width); + style_itemlist_cursor->set_border_color_all(HIGHLIGHT_COLOR_DARK); theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor); theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor); theme->set_stylebox("selected_focus", "ItemList", style_tree_focus); @@ -371,7 +364,7 @@ Ref<Theme> create_editor_theme() { Ref<StyleBoxFlat> style_tab_fg = make_flat_stylebox(title_color_hl, 15, 5, 15, 5); Ref<StyleBoxFlat> style_tab_bg = make_flat_stylebox(base_color, 15, 5, 15, 5); - style_tab_bg->set_draw_center(false); + style_tab_bg->set_filled(false); // Tabs & TabContainer theme->set_stylebox("tab_fg", "TabContainer", style_tab_fg); @@ -396,7 +389,7 @@ Ref<Theme> create_editor_theme() { Ref<StyleBoxFlat> style_tab_fg_debugger = make_flat_stylebox(dark_color_2, 10, 5, 10, 5); Ref<StyleBoxFlat> style_tab_bg_debugger = make_flat_stylebox(dark_color_2, 10, 5, 10, 5); - style_tab_bg_debugger->set_draw_center(false); + style_tab_bg_debugger->set_filled(false); theme->set_stylebox("DebuggerTabFG", "EditorStyles", style_tab_fg_debugger); theme->set_stylebox("DebuggerTabBG", "EditorStyles", style_tab_bg_debugger); @@ -435,11 +428,10 @@ Ref<Theme> create_editor_theme() { // WindowDialog Ref<StyleBoxFlat> style_window = make_flat_stylebox(dark_color_2, 4, 4, 4, 4); - style_window->set_border_size(MAX(EDSCALE, border_width)); - style_window->set_border_blend(false); - style_window->set_light_color(title_color_hl); - style_window->set_dark_color(title_color_hl); - style_window->_set_additional_border_size(MARGIN_TOP, 24 * EDSCALE); + style_window->set_border_width_all(MAX(EDSCALE, border_width)); + style_window->set_border_color_all(title_color_hl); + style_window->set_border_width(MARGIN_TOP, 24 * EDSCALE); + style_window->set_expand_margin_size(MARGIN_TOP, 24 * EDSCALE); theme->set_stylebox("panel", "WindowDialog", style_window); theme->set_color("title_color", "WindowDialog", title_color_hl_text_color); theme->set_icon("close", "WindowDialog", title_hl_close_icon); @@ -492,16 +484,13 @@ Ref<Theme> create_editor_theme() { // TooltipPanel Ref<StyleBoxFlat> style_tooltip = make_flat_stylebox(Color(1, 1, 1, 0.8), 8, 8, 8, 8); - style_tooltip->set_border_size(border_width); - style_tooltip->set_border_blend(false); - style_tooltip->set_light_color(Color(1, 1, 1, 0.9)); - style_tooltip->set_dark_color(Color(1, 1, 1, 0.9)); + style_tooltip->set_border_width_all(border_width); + style_tooltip->set_border_color_all(Color(1, 1, 1, 0.9)); theme->set_stylebox("panel", "TooltipPanel", style_tooltip); // PopupPanel Ref<StyleBoxFlat> style_dock_select = make_flat_stylebox(base_color); - style_dock_select->set_light_color(light_color_1); - style_dock_select->set_dark_color(light_color_1); + style_dock_select->set_border_color_all(light_color_1); style_dock_select = add_additional_border(style_dock_select, 2, 2, 2, 2); theme->set_stylebox("panel", "PopupPanel", style_dock_select); @@ -522,28 +511,20 @@ Ref<Theme> create_editor_theme() { // GraphNode Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(0, 0, 0, 0.3), 16, 24, 16, 5); - graphsb->set_border_blend(false); - graphsb->set_border_size(border_width); - graphsb->set_light_color(Color(1, 1, 1, 0.6)); - graphsb->set_dark_color(Color(1, 1, 1, 0.6)); + graphsb->set_border_width_all(border_width); + graphsb->set_border_color_all(Color(1, 1, 1, 0.6)); graphsb = add_additional_border(graphsb, 0, -22, 0, 0); Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.4), 16, 24, 16, 5); - graphsbselected->set_border_blend(false); - graphsbselected->set_border_size(border_width); - graphsbselected->set_light_color(Color(1, 1, 1, 0.9)); - graphsbselected->set_dark_color(Color(1, 1, 1, 0.9)); + graphsbselected->set_border_width_all(border_width); + graphsbselected->set_border_color_all(Color(1, 1, 1, 0.9)); graphsbselected = add_additional_border(graphsbselected, 0, -22, 0, 0); Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), 16, 24, 16, 5); - graphsbcomment->set_border_blend(false); - graphsbcomment->set_border_size(border_width); - graphsbcomment->set_light_color(Color(1, 1, 1, 0.6)); - graphsbcomment->set_dark_color(Color(1, 1, 1, 0.6)); + graphsbcomment->set_border_width_all(border_width); + graphsbcomment->set_border_color_all(Color(1, 1, 1, 0.6)); graphsbcomment = add_additional_border(graphsbcomment, 0, -22, 0, 0); Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(0, 0, 0, 0.4), 16, 24, 16, 5); - graphsbcommentselected->set_border_blend(false); - graphsbcommentselected->set_border_size(border_width); - graphsbcommentselected->set_light_color(Color(1, 1, 1, 0.9)); - graphsbcommentselected->set_dark_color(Color(1, 1, 1, 0.9)); + graphsbcommentselected->set_border_width_all(border_width); + graphsbcommentselected->set_border_color_all(Color(1, 1, 1, 0.9)); graphsbcommentselected = add_additional_border(graphsbcommentselected, 0, -22, 0, 0); theme->set_stylebox("frame", "GraphNode", graphsb); theme->set_stylebox("selectedframe", "GraphNode", graphsbselected); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index ae89dfd77f..aa8fb9b25b 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -104,7 +104,7 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const } } - if (p_option == "materials/keep_files" && int(p_options["materials/storage"]) == 0) { + if (p_option == "materials/keep_on_reimport" && int(p_options["materials/storage"]) == 0) { return false; } @@ -1103,7 +1103,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), meshes_out ? 1 : 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_files"), materials_out ? true : false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_on_reimport"), materials_out ? true : false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "geometry/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? true : false)); @@ -1272,7 +1272,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p Map<Ref<Material>, Ref<Material> > mat_map; Map<Ref<ArrayMesh>, Ref<ArrayMesh> > mesh_map; - bool keep_materials = bool(p_options["materials/keep_files"]); + bool keep_materials = bool(p_options["materials/keep_on_reimport"]); _make_external_resources(scene, base_path, external_materials, keep_materials, external_meshes, mat_map, mesh_map); } diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 023424d891..80ff6627b2 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -52,8 +52,15 @@ void TileMapEditor::_notification(int p_what) { search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); } break; + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + bool new_show_tile_info = EditorSettings::get_singleton()->get("editors/tile_map/show_tile_info_on_hover"); + if (new_show_tile_info != show_tile_info) { + show_tile_info = new_show_tile_info; + tile_info->set_visible(show_tile_info); + } + if (is_visible_in_tree()) { _update_palette(); } @@ -912,12 +919,14 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { canvas_item_editor->update(); } - int tile_under = node->get_cell(over_tile.x, over_tile.y); - String tile_name = "none"; + if (show_tile_info) { + int tile_under = node->get_cell(over_tile.x, over_tile.y); + String tile_name = "none"; - if (node->get_tileset()->has_tile(tile_under)) - tile_name = node->get_tileset()->tile_get_name(tile_under); - tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]"); + if (node->get_tileset()->has_tile(tile_under)) + tile_name = node->get_tileset()->tile_get_name(tile_under); + tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]"); + } if (tool == TOOL_PAINTING) { @@ -1439,6 +1448,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { tool = TOOL_NONE; selection_active = false; mouse_over = false; + show_tile_info = true; flip_h = false; flip_v = false; @@ -1602,6 +1612,7 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) { EDITOR_DEF("editors/tile_map/show_tile_ids", false); EDITOR_DEF("editors/tile_map/sort_tiles_by_name", true); EDITOR_DEF("editors/tile_map/bucket_fill_preview", true); + EDITOR_DEF("editors/tile_map/show_tile_info_on_hover", true); tile_map_editor = memnew(TileMapEditor(p_node)); add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE, tile_map_editor); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index a12c56814a..d76884e663 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -97,6 +97,7 @@ class TileMapEditor : public VBoxContainer { bool selection_active; bool mouse_over; + bool show_tile_info; bool flip_h; bool flip_v; diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 51a40faf37..980afee447 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -155,9 +155,10 @@ void ProgressDialog::_popup() { Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); ms += style->get_minimum_size(); - for (int i = 0; i < 4; i++) { - main->set_margin(Margin(i), style->get_margin(Margin(i))); - } + main->set_margin(MARGIN_LEFT, style->get_margin(MARGIN_LEFT)); + main->set_margin(MARGIN_RIGHT, -style->get_margin(MARGIN_RIGHT)); + main->set_margin(MARGIN_TOP, style->get_margin(MARGIN_TOP)); + main->set_margin(MARGIN_BOTTOM, -style->get_margin(MARGIN_BOTTOM)); popup_centered(ms); } diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index d6c1407b62..2f47d3e130 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4774,19 +4774,20 @@ double PropertyValueEvaluator::eval(const String &p_text) { return _default_eval(p_text); } - ScriptInstance *script_instance = script->instance_create(obj); + Object dummy; + ScriptInstance *script_instance = script->instance_create(&dummy); if (!script_instance) return _default_eval(p_text); Variant::CallError call_err; - double result = script_instance->call("e", NULL, 0, call_err); + Variant arg = obj; + const Variant *args[] = { &arg }; + double result = script_instance->call("eval", args, 1, call_err); if (call_err.error == Variant::CallError::CALL_OK) { return result; } print_line("[PropertyValueEvaluator]: Error eval! Error code: " + itos(call_err.error)); - memdelete(script_instance); - return _default_eval(p_text); } @@ -4795,9 +4796,8 @@ void PropertyValueEvaluator::edit(Object *p_obj) { } String PropertyValueEvaluator::_build_script(const String &p_text) { - String script_text = "tool\nextends Object\nfunc e():\n\treturn "; - script_text += p_text.strip_edges(); - script_text += "\n"; + String script_text = + "tool\nextends Object\nfunc eval(s):\n\tself = s\n\treturn " + p_text.strip_edges() + "\n"; return script_text; } diff --git a/main/input_default.cpp b/main/input_default.cpp index e7dc9d4b70..d496717460 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -775,7 +775,7 @@ static const char *s_ControllerMappings[] = { "4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "532e542e442e20496e74657261637420,3dfx InterAct HammerHead FX,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b25,rightshoulder:b27,rightx:a2,start:b31,righty:a3,dpleft:h0.8,lefttrigger:b28,x:b20,dpup:h0.1,back:b30,leftstick:b22,leftshoulder:b26,y:b21,a:b23,dpright:h0.2,righttrigger:b29,b:b24,", "506572666f726d616e63652044657369,PDP Rock Candy Wireless Controller for PS3,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b6,rightshoulder:b18,rightx:a2,start:b16,righty:a3,dpleft:h0.8,lefttrigger:b9,x:b0,dpup:h0.1,back:h0.2,leftstick:b4,leftshoulder:b3,y:b2,a:b1,dpright:h0.2,righttrigger:b10,b:b17,", - "4f5559412047616d6520436f6e74726f,OUYA Game Controller,leftx:a0,lefty:a1,dpdown:b9,rightstick:b7,rightshoulder:b5,rightx:a3,start:b16,righty:a4,dpleft:b10,lefttrigger:b12,x:b1,dpup:b8,back:b14,leftstick:b6,leftshoulder:b4,y:b2,a:b0,dpright:b11,righttrigger:b13,b:b3,", + "4f5559412047616d6520436f6e74726f,OUYA Game Controller,leftx:a1,lefty:a3,dpdown:b12,rightstick:b8,rightshoulder:b10,rightx:a6,start:b-86,righty:a7,dpleft:b13,lefttrigger:b15,x:b2,dpup:b11,leftstick:b7,leftshoulder:b9,y:b3,a:b0,dpright:b14,righttrigger:b16,b:b1,", #endif #ifdef JAVASCRIPT_ENABLED diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 779f909a15..54021b8172 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1629,7 +1629,6 @@ Error OS_Windows::close_dynamic_library(void *p_library_handle) { } Error OS_Windows::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) { - char *error; p_symbol_handle = (void *)GetProcAddress((HMODULE)p_library_handle, p_name.utf8().get_data()); if (!p_symbol_handle) { if (!p_optional) { diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 36d910ca94..d5872d92ec 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -67,10 +67,10 @@ void WindowDialog::_fix_size() { right = panel_texture->get_expand_margin_size(MARGIN_RIGHT); } else if (panel->get_class() == "StyleBoxFlat") { Ref<StyleBoxFlat> panel_flat = panel->cast_to<StyleBoxFlat>(); - top = panel_flat->_get_additional_border_size(MARGIN_TOP); - left = panel_flat->_get_additional_border_size(MARGIN_LEFT); - bottom = panel_flat->_get_additional_border_size(MARGIN_BOTTOM); - right = panel_flat->_get_additional_border_size(MARGIN_RIGHT); + top = panel_flat->get_expand_margin_size(MARGIN_TOP); + left = panel_flat->get_expand_margin_size(MARGIN_LEFT); + bottom = panel_flat->get_expand_margin_size(MARGIN_BOTTOM); + right = panel_flat->get_expand_margin_size(MARGIN_RIGHT); } pos.x = MAX(left, MIN(pos.x, viewport_size.x - size.x - right)); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index d90f0c7898..b30a6000ff 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -339,7 +339,7 @@ void ItemList::set_same_column_width(bool p_enable) { update(); shape_changed = true; } -int ItemList::is_same_column_width() const { +bool ItemList::is_same_column_width() const { return same_column_width; } diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index 5bf343daa5..a80727f568 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -169,7 +169,7 @@ public: int get_fixed_column_width() const; void set_same_column_width(bool p_enable); - int is_same_column_width() const; + bool is_same_column_width() const; void set_max_text_lines(int p_lines); int get_max_text_lines() const; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index bdb17c0ea5..48efa242e9 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "style_box.h" +#include <limits.h> bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const { @@ -161,7 +162,7 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const { if (normal_map.is_valid()) normal_rid = normal_map->get_rid(); - VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NINE_PATCH_STRETCH, VS::NINE_PATCH_STRETCH, draw_center, modulate, normal_rid); + VisualServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), VS::NinePatchAxisMode(axis_h), VS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid); } void StyleBoxTexture::set_draw_center(bool p_draw) { @@ -210,6 +211,28 @@ Rect2 StyleBoxTexture::get_region_rect() const { return region_rect; } +void StyleBoxTexture::set_h_axis_stretch_mode(AxisStretchMode p_mode) { + + axis_h = p_mode; + emit_changed(); +} + +StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_h_axis_stretch_mode() const { + + return axis_h; +} + +void StyleBoxTexture::set_v_axis_stretch_mode(AxisStretchMode p_mode) { + + axis_v = p_mode; + emit_changed(); +} + +StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_v_axis_stretch_mode() const { + + return axis_v; +} + void StyleBoxTexture::set_modulate(const Color &p_modulate) { if (modulate == p_modulate) return; @@ -245,6 +268,12 @@ void StyleBoxTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("set_modulate", "color"), &StyleBoxTexture::set_modulate); ClassDB::bind_method(D_METHOD("get_modulate"), &StyleBoxTexture::get_modulate); + ClassDB::bind_method(D_METHOD("set_h_axis_stretch_mode", "mode"), &StyleBoxTexture::set_h_axis_stretch_mode); + ClassDB::bind_method(D_METHOD("get_h_axis_stretch_mode"), &StyleBoxTexture::get_h_axis_stretch_mode); + + ClassDB::bind_method(D_METHOD("set_v_axis_stretch_mode", "mode"), &StyleBoxTexture::set_v_axis_stretch_mode); + ClassDB::bind_method(D_METHOD("get_v_axis_stretch_mode"), &StyleBoxTexture::get_v_axis_stretch_mode); + ADD_SIGNAL(MethodInfo("texture_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); @@ -260,9 +289,16 @@ void StyleBoxTexture::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_RIGHT); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_TOP); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin_size", "get_expand_margin_size", MARGIN_BOTTOM); + ADD_GROUP("Axis Stretch", "axis_stretch_"); + ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_horizontal", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_h_axis_stretch_mode", "get_h_axis_stretch_mode"); + ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "axis_stretch_vertical", PROPERTY_HINT_ENUM, "Stretch,Tile,Tile Fit"), "set_v_axis_stretch_mode", "get_v_axis_stretch_mode"); ADD_GROUP("Modulate", "modulate_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate_color"), "set_modulate", "get_modulate"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "get_draw_center"); + + BIND_CONSTANT(AXIS_STRETCH_MODE_STRETCH); + BIND_CONSTANT(AXIS_STRETCH_MODE_TILE); + BIND_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT); } StyleBoxTexture::StyleBoxTexture() { @@ -273,6 +309,9 @@ StyleBoxTexture::StyleBoxTexture() { } draw_center = true; modulate = Color(1, 1, 1, 1); + + axis_h = AXIS_STRETCH_MODE_STRETCH; + axis_v = AXIS_STRETCH_MODE_STRETCH; } StyleBoxTexture::~StyleBoxTexture() { } @@ -285,156 +324,507 @@ void StyleBoxFlat::set_bg_color(const Color &p_color) { emit_changed(); } -void StyleBoxFlat::set_light_color(const Color &p_color) { +Color StyleBoxFlat::get_bg_color() const { - light_color = p_color; + return bg_color; +} + +void StyleBoxFlat::set_border_color_all(const Color &p_color) { + for (int i = 0; i < 4; i++) { + + border_color.write()[i] = p_color; + } emit_changed(); } -void StyleBoxFlat::set_dark_color(const Color &p_color) { +Color StyleBoxFlat::get_border_color_all() const { + + return border_color[MARGIN_TOP]; +} +void StyleBoxFlat::set_border_color(Margin p_border, const Color &p_color) { - dark_color = p_color; + border_color.write()[p_border] = p_color; emit_changed(); } +Color StyleBoxFlat::get_border_color(Margin p_border) const { -Color StyleBoxFlat::get_bg_color() const { + return border_color[p_border]; +} - return bg_color; +void StyleBoxFlat::set_border_width_all(int p_size) { + border_width[0] = p_size; + border_width[1] = p_size; + border_width[2] = p_size; + border_width[3] = p_size; + emit_changed(); } -Color StyleBoxFlat::get_light_color() const { +int StyleBoxFlat::get_border_width_min() const { - return light_color; + return MIN(MIN(border_width[0], border_width[1]), MIN(border_width[2], border_width[3])); } -Color StyleBoxFlat::get_dark_color() const { - return dark_color; +void StyleBoxFlat::set_border_width(Margin p_margin, int p_width) { + border_width[p_margin] = p_width; + emit_changed(); +} + +int StyleBoxFlat::get_border_width(Margin p_margin) const { + return border_width[p_margin]; } -void StyleBoxFlat::set_border_size(int p_size) { +void StyleBoxFlat::set_border_blend(bool p_blend) { - border_size = p_size; + blend_border = p_blend; emit_changed(); } -int StyleBoxFlat::get_border_size() const { +bool StyleBoxFlat::get_border_blend() const { - return border_size; + return blend_border; } -void StyleBoxFlat::_set_additional_border_size(Margin p_margin, int p_size) { - additional_border_size[p_margin] = p_size; +void StyleBoxFlat::set_corner_radius_all(int radius) { + + for (int i = 0; i < 4; i++) { + corner_radius[i] = radius; + } + emit_changed(); } +void StyleBoxFlat::set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_botton_right, const int radius_bottom_left) { + corner_radius[0] = radius_top_left; + corner_radius[1] = radius_top_right; + corner_radius[2] = radius_botton_right; + corner_radius[3] = radius_bottom_left; -int StyleBoxFlat::_get_additional_border_size(Margin p_margin) const { - return additional_border_size[p_margin]; + emit_changed(); +} +int StyleBoxFlat::get_corner_radius_min() const { + int smallest = corner_radius[0]; + for (int i = 1; i < 4; i++) { + if (smallest > corner_radius[i]) { + smallest = corner_radius[i]; + } + } + return smallest; } -void StyleBoxFlat::set_border_blend(bool p_blend) { +void StyleBoxFlat::set_corner_radius(const Corner p_corner, const int radius) { - blend = p_blend; + corner_radius[p_corner] = radius; emit_changed(); } +int StyleBoxFlat::get_corner_radius(const Corner p_corner) const { + return corner_radius[p_corner]; +} -bool StyleBoxFlat::get_border_blend() const { +void StyleBoxFlat::set_expand_margin_size(Margin p_expand_margin, float p_size) { + + expand_margin[p_expand_margin] = p_size; + emit_changed(); +} +float StyleBoxFlat::get_expand_margin_size(Margin p_expand_margin) const { + return expand_margin[p_expand_margin]; +} +void StyleBoxFlat::set_filled(bool p_filled) { - return blend; + filled = p_filled; + emit_changed(); } +bool StyleBoxFlat::is_filled() const { -void StyleBoxFlat::set_draw_center(bool p_draw) { + return filled; +} - draw_center = p_draw; +void StyleBoxFlat::set_shadow_color(const Color &p_color) { + + shadow_color = p_color; emit_changed(); } -bool StyleBoxFlat::get_draw_center() const { +Color StyleBoxFlat::get_shadow_color() const { - return draw_center; + return shadow_color; +} + +void StyleBoxFlat::set_shadow_size(const int &p_size) { + + shadow_size = p_size; + emit_changed(); +} +int StyleBoxFlat::get_shadow_size() const { + + return shadow_size; +} + +void StyleBoxFlat::set_anti_aliased(const bool &p_anti_aliased) { + anti_aliased = p_anti_aliased; + emit_changed(); +} +bool StyleBoxFlat::is_anti_aliased() const { + return anti_aliased; +} + +void StyleBoxFlat::set_aa_size(const int &p_aa_size) { + aa_size = p_aa_size; + emit_changed(); +} +int StyleBoxFlat::get_aa_size() const { + return aa_size; } + +void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) { + corner_detail = p_corner_detail; + emit_changed(); +} +int StyleBoxFlat::get_corner_detail() const { + return corner_detail; +} + Size2 StyleBoxFlat::get_center_size() const { return Size2(); } -void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { +inline void set_inner_corner_radius(const Rect2 style_rect, const Rect2 inner_rect, const int corner_radius[4], int *inner_corner_radius) { + int border_left = inner_rect.position.x - style_rect.position.x; + int border_top = inner_rect.position.y - style_rect.position.y; + int border_right = style_rect.size.width - inner_rect.size.width - border_left; + int border_bottom = style_rect.size.height - inner_rect.size.height - border_top; - VisualServer *vs = VisualServer::get_singleton(); - Rect2i r = p_rect; + int rad; + //tl + rad = MIN(border_top, border_left); + inner_corner_radius[0] = MAX(corner_radius[0] - rad, 0); - for (int i = 0; i < border_size; i++) { + //tr + rad = MIN(border_top, border_bottom); + inner_corner_radius[1] = MAX(corner_radius[1] - rad, 0); - Color color_upleft = light_color; - Color color_downright = dark_color; + //br + rad = MIN(border_bottom, border_right); + inner_corner_radius[2] = MAX(corner_radius[2] - rad, 0); - if (blend) { + //bl + rad = MIN(border_bottom, border_left); + inner_corner_radius[3] = MAX(corner_radius[3] - rad, 0); +} - color_upleft.r = (border_size - i) * color_upleft.r / border_size + i * bg_color.r / border_size; - color_upleft.g = (border_size - i) * color_upleft.g / border_size + i * bg_color.g / border_size; - color_upleft.b = (border_size - i) * color_upleft.b / border_size + i * bg_color.b / border_size; +inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color> &colors, const Rect2 style_rect, const int corner_radius[4], + const Rect2 ring_rect, const int border_width[4], const Color inner_color[4], const Color outer_color[4], const int corner_detail) { - color_downright.r = (border_size - i) * color_downright.r / border_size + i * bg_color.r / border_size; - color_downright.g = (border_size - i) * color_downright.g / border_size + i * bg_color.g / border_size; - color_downright.b = (border_size - i) * color_downright.b / border_size + i * bg_color.b / border_size; + int vert_offset = verts.size(); + if (!vert_offset) { + vert_offset = 0; + } + int rings = (border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0) ? 1 : 2; + rings = 2; + + int ring_corner_radius[4]; + set_inner_corner_radius(style_rect, ring_rect, corner_radius, ring_corner_radius); + + //corner radius center points + Vector<Point2> outer_points; + outer_points.push_back(ring_rect.position + Vector2(ring_corner_radius[0], ring_corner_radius[0])); //tl + outer_points.push_back(Point2(ring_rect.position.x + ring_rect.size.x - ring_corner_radius[1], ring_rect.position.y + ring_corner_radius[1])); //tr + outer_points.push_back(ring_rect.position + ring_rect.size - Vector2(ring_corner_radius[2], ring_corner_radius[2])); //br + outer_points.push_back(Point2(ring_rect.position.x + ring_corner_radius[3], ring_rect.position.y + ring_rect.size.y - ring_corner_radius[3])); //bl + + Rect2 inner_rect; + inner_rect = ring_rect.grow_individual(-border_width[MARGIN_LEFT], -border_width[MARGIN_TOP], -border_width[MARGIN_RIGHT], -border_width[MARGIN_BOTTOM]); + int inner_corner_radius[4]; + + Vector<Point2> inner_points; + set_inner_corner_radius(style_rect, inner_rect, corner_radius, inner_corner_radius); + inner_points.push_back(inner_rect.position + Vector2(inner_corner_radius[0], inner_corner_radius[0])); //tl + inner_points.push_back(Point2(inner_rect.position.x + inner_rect.size.x - inner_corner_radius[1], inner_rect.position.y + inner_corner_radius[1])); //tr + inner_points.push_back(inner_rect.position + inner_rect.size - Vector2(inner_corner_radius[2], inner_corner_radius[2])); //br + inner_points.push_back(Point2(inner_rect.position.x + inner_corner_radius[3], inner_rect.position.y + inner_rect.size.y - inner_corner_radius[3])); //bl + + //calculate the vert array + for (int corner_index = 0; corner_index < 4; corner_index++) { + for (int detail = 0; detail <= corner_detail; detail++) { + for (int inner_outer = (2 - rings); inner_outer < 2; inner_outer++) { + float radius; + Color color; + Point2 corner_point; + if (inner_outer == 0) { + radius = inner_corner_radius[corner_index]; + color = *inner_color; + corner_point = inner_points[corner_index]; + } else { + radius = ring_corner_radius[corner_index]; + color = *outer_color; + corner_point = outer_points[corner_index]; + } + float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x; + float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y; + verts.push_back(Vector2(x, y)); + colors.push_back(color); + } } + } + + if (rings == 2) { + int vert_count = (corner_detail + 1) * 4 * rings; + //fill the indices and the colors for the border + for (int i = 0; i < vert_count; i++) { + //poly 1 + indices.push_back(vert_offset + ((i + 0) % vert_count)); + indices.push_back(vert_offset + ((i + 2) % vert_count)); + indices.push_back(vert_offset + ((i + 1) % vert_count)); + //poly 2 + indices.push_back(vert_offset + ((i + 1) % vert_count)); + indices.push_back(vert_offset + ((i + 2) % vert_count)); + indices.push_back(vert_offset + ((i + 3) % vert_count)); + } + } +} - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x, r.position.y + r.size.y - 1), Size2(r.size.x, 1)), color_downright); - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r.position.x + r.size.x - 1, r.position.y), Size2(1, r.size.y)), color_downright); +inline void adapt_values(int p_index_a, int p_index_b, int *adapted_values, const int *p_values, const real_t p_width, const int p_max_a, const int p_max_b) { + if (p_values[p_index_a] + p_values[p_index_b] > p_width) { + float factor; + int newValue; - vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(r.size.x, 1)), color_upleft); - vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, Size2(1, r.size.y)), color_upleft); + factor = (float)p_width / (float)(p_values[p_index_a] + p_values[p_index_b]); - r.position.x++; - r.position.y++; - r.size.x -= 2; - r.size.y -= 2; + newValue = (int)(p_values[p_index_a] * factor); + if (newValue < adapted_values[p_index_a]) { + adapted_values[p_index_a] = newValue; + } + newValue = (int)(p_values[p_index_b] * factor); + if (newValue < adapted_values[p_index_b]) { + adapted_values[p_index_b] = newValue; + } + } else { + adapted_values[p_index_a] = MIN(p_values[p_index_a], adapted_values[p_index_a]); + adapted_values[p_index_b] = MIN(p_values[p_index_b], adapted_values[p_index_b]); + } + adapted_values[p_index_a] = MIN(p_max_a, adapted_values[p_index_a]); + adapted_values[p_index_b] = MIN(p_max_b, adapted_values[p_index_b]); +} +void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { + + //PREPARATIONS + + bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0); + bool aa_on = rounded_corners && anti_aliased; + + Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); + if (aa_on) { + style_rect = style_rect.grow(-((aa_size + 1) / 2)); } - if (draw_center) - vs->canvas_item_add_rect(p_canvas_item, Rect2(r.position, r.size), bg_color); + //adapt borders (prevent weired overlapping/glitchy drawings) + int width = style_rect.size.width; + int height = style_rect.size.height; + int adapted_border[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX }; + adapt_values(MARGIN_TOP, MARGIN_BOTTOM, adapted_border, border_width, height, height, height); + adapt_values(MARGIN_LEFT, MARGIN_RIGHT, adapted_border, border_width, width, width, width); + + //adapt corners (prevent weired overlapping/glitchy drawings) + int adapted_corner[4] = { INT_MAX, INT_MAX, INT_MAX, INT_MAX }; + adapt_values(CORNER_TOP_RIGHT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]); + adapt_values(CORNER_TOP_LEFT, CORNER_BOTTOM_LEFT, adapted_corner, corner_radius, height, height - adapted_border[MARGIN_BOTTOM], height - adapted_border[MARGIN_TOP]); + adapt_values(CORNER_TOP_LEFT, CORNER_TOP_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]); + adapt_values(CORNER_BOTTOM_LEFT, CORNER_BOTTOM_RIGHT, adapted_corner, corner_radius, width, width - adapted_border[MARGIN_RIGHT], width - adapted_border[MARGIN_LEFT]); + + Rect2 infill_rect = style_rect.grow_individual(-adapted_border[MARGIN_LEFT], -adapted_border[MARGIN_TOP], -adapted_border[MARGIN_RIGHT], -adapted_border[MARGIN_BOTTOM]); + + Vector<Point2> verts; + Vector<int> indices; + Vector<Color> colors; + + //DRAWING + VisualServer *vs = VisualServer::get_singleton(); + + //DRAW SHADOW + if (shadow_size > 0) { + int shadow_width[4] = { shadow_size, shadow_size, shadow_size, shadow_size }; + Color shadow_colors[4] = { shadow_color, shadow_color, shadow_color, shadow_color }; + Color shadow_colors_transparent[4]; + for (int i = 0; i < 4; i++) { + shadow_colors_transparent[i] = Color(shadow_color.r, shadow_color.g, shadow_color.b, 0); + } + draw_ring(verts, indices, colors, style_rect, adapted_corner, + style_rect.grow(shadow_size), shadow_width, shadow_colors, shadow_colors_transparent, corner_detail); + } - Rect2i r_add = p_rect; - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y - additional_border_size[MARGIN_TOP]), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_TOP])), light_color); - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y), Size2(additional_border_size[MARGIN_LEFT], r_add.size.height)), light_color); - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x + r_add.size.width, r_add.position.y), Size2(additional_border_size[MARGIN_RIGHT], r_add.size.height)), dark_color); - vs->canvas_item_add_rect(p_canvas_item, Rect2(Point2i(r_add.position.x - additional_border_size[MARGIN_LEFT], r_add.position.y + r_add.size.height), Size2(r_add.size.width + additional_border_size[MARGIN_LEFT] + additional_border_size[MARGIN_RIGHT], additional_border_size[MARGIN_BOTTOM])), dark_color); + //DRAW border + Color bg_color_array[4] = { bg_color, bg_color, bg_color, bg_color }; + const Color *inner_color = ((blend_border) ? bg_color_array : border_color.read().ptr()); + draw_ring(verts, indices, colors, style_rect, adapted_corner, + style_rect, adapted_border, inner_color, border_color.read().ptr(), corner_detail); + + //DRAW INFILL + if (filled) { + int temp_vert_offset = verts.size(); + int no_border[4] = { 0, 0, 0, 0 }; + draw_ring(verts, indices, colors, style_rect, adapted_corner, + infill_rect, no_border, &bg_color, &bg_color, corner_detail); + int added_vert_count = verts.size() - temp_vert_offset; + //fill the indices and the colors for the center + for (int index = 0; index <= added_vert_count / 2; index += 2) { + int i = index; + //poly 1 + indices.push_back(temp_vert_offset + i); + indices.push_back(temp_vert_offset + added_vert_count - 4 - i); + indices.push_back(temp_vert_offset + i + 2); + //poly 1 + indices.push_back(temp_vert_offset + i); + indices.push_back(temp_vert_offset + added_vert_count - 2 - i); + indices.push_back(temp_vert_offset + added_vert_count - 4 - i); + } + } + + if (aa_on) { + + //HELPER ARRAYS + Color border_color_alpha[4]; + for (int i = 0; i < 4; i++) { + Color c = border_color.read().ptr()[i]; + border_color_alpha[i] = Color(c.r, c.g, c.b, 0); + } + Color alpha_bg = Color(bg_color.r, bg_color.g, bg_color.b, 0); + Color bg_color_array_alpha[4] = { alpha_bg, alpha_bg, alpha_bg, alpha_bg }; + + int aa_border_width[4] = { aa_size, aa_size, aa_size, aa_size }; + + if (filled) { + if (!blend_border) { + //INFILL AA + draw_ring(verts, indices, colors, style_rect, adapted_corner, + infill_rect.grow(aa_size), aa_border_width, bg_color_array, bg_color_array_alpha, corner_detail); + } + } else if (!(border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0)) { + //DRAW INNER BORDER AA + draw_ring(verts, indices, colors, style_rect, adapted_corner, + infill_rect, aa_border_width, border_color_alpha, border_color.read().ptr(), corner_detail); + } + //DRAW OUTER BORDER AA + if (!(border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0)) { + draw_ring(verts, indices, colors, style_rect, adapted_corner, + style_rect.grow(aa_size), aa_border_width, border_color.read().ptr(), border_color_alpha, corner_detail); + } + } + + vs->canvas_item_add_triangle_array(p_canvas_item, indices, verts, colors); } float StyleBoxFlat::get_style_margin(Margin p_margin) const { - - return border_size; + return border_width[p_margin]; } void StyleBoxFlat::_bind_methods() { ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &StyleBoxFlat::set_bg_color); ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color); - ClassDB::bind_method(D_METHOD("set_light_color", "color"), &StyleBoxFlat::set_light_color); - ClassDB::bind_method(D_METHOD("get_light_color"), &StyleBoxFlat::get_light_color); - ClassDB::bind_method(D_METHOD("set_dark_color", "color"), &StyleBoxFlat::set_dark_color); - ClassDB::bind_method(D_METHOD("get_dark_color"), &StyleBoxFlat::get_dark_color); - ClassDB::bind_method(D_METHOD("set_border_size", "size"), &StyleBoxFlat::set_border_size); - ClassDB::bind_method(D_METHOD("get_border_size"), &StyleBoxFlat::get_border_size); + + ClassDB::bind_method(D_METHOD("set_border_color", "color"), &StyleBoxFlat::set_border_color_all); + ClassDB::bind_method(D_METHOD("get_border_color", "color"), &StyleBoxFlat::get_border_color_all); + + ClassDB::bind_method(D_METHOD("set_border_width_all", "width"), &StyleBoxFlat::set_border_width_all); + ClassDB::bind_method(D_METHOD("get_border_width_min"), &StyleBoxFlat::get_border_width_min); + + ClassDB::bind_method(D_METHOD("set_border_width", "margin", "width"), &StyleBoxFlat::set_border_width); + ClassDB::bind_method(D_METHOD("get_border_width", "margin"), &StyleBoxFlat::get_border_width); + ClassDB::bind_method(D_METHOD("set_border_blend", "blend"), &StyleBoxFlat::set_border_blend); ClassDB::bind_method(D_METHOD("get_border_blend"), &StyleBoxFlat::get_border_blend); - ClassDB::bind_method(D_METHOD("set_draw_center", "size"), &StyleBoxFlat::set_draw_center); - ClassDB::bind_method(D_METHOD("get_draw_center"), &StyleBoxFlat::get_draw_center); + + ClassDB::bind_method(D_METHOD("set_corner_radius_individual", "radius_top_left", "radius_top_right", "radius_botton_right", "radius_bottom_left"), &StyleBoxFlat::set_corner_radius_individual); + ClassDB::bind_method(D_METHOD("set_corner_radius_all", "radius"), &StyleBoxFlat::set_corner_radius_all); + + ClassDB::bind_method(D_METHOD("set_corner_radius", "corner", "radius"), &StyleBoxFlat::set_corner_radius); + ClassDB::bind_method(D_METHOD("get_corner_radius", "corner"), &StyleBoxFlat::get_corner_radius); + + ClassDB::bind_method(D_METHOD("set_expand_margin", "margin", "size"), &StyleBoxFlat::set_expand_margin_size); + ClassDB::bind_method(D_METHOD("get_expand_margin", "margin"), &StyleBoxFlat::get_expand_margin_size); + + ClassDB::bind_method(D_METHOD("set_filled", "filled"), &StyleBoxFlat::set_filled); + ClassDB::bind_method(D_METHOD("is_filled"), &StyleBoxFlat::is_filled); + + ClassDB::bind_method(D_METHOD("set_shadow_color", "color"), &StyleBoxFlat::set_shadow_color); + ClassDB::bind_method(D_METHOD("get_shadow_color"), &StyleBoxFlat::get_shadow_color); + + ClassDB::bind_method(D_METHOD("set_shadow_size", "size"), &StyleBoxFlat::set_shadow_size); + ClassDB::bind_method(D_METHOD("get_shadow_size"), &StyleBoxFlat::get_shadow_size); + + ClassDB::bind_method(D_METHOD("set_anti_aliased", "anti_aliased"), &StyleBoxFlat::set_anti_aliased); + ClassDB::bind_method(D_METHOD("is_anti_aliased"), &StyleBoxFlat::is_anti_aliased); + + ClassDB::bind_method(D_METHOD("set_aa_size", "size"), &StyleBoxFlat::set_aa_size); + ClassDB::bind_method(D_METHOD("get_aa_size"), &StyleBoxFlat::get_aa_size); + + ClassDB::bind_method(D_METHOD("set_corner_detail", "detail"), &StyleBoxFlat::set_corner_detail); + ClassDB::bind_method(D_METHOD("get_corner_detail"), &StyleBoxFlat::get_corner_detail); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "bg_color"), "set_bg_color", "get_bg_color"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color"), "set_light_color", "get_light_color"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "dark_color"), "set_dark_color", "get_dark_color"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "border_size", PROPERTY_HINT_RANGE, "0,4096"), "set_border_size", "get_border_size"); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filled"), "set_filled", "is_filled"); + + ADD_GROUP("Border Width", "border_width_"); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_top", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "border_width_bottom", PROPERTY_HINT_RANGE, "0,1024,1"), "set_border_width", "get_border_width", MARGIN_BOTTOM); + + ADD_GROUP("Border", "border_"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "border_blend"), "set_border_blend", "get_border_blend"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_bg"), "set_draw_center", "get_draw_center"); + + ADD_GROUP("Corner Radius", "corner_radius_"); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_top_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_TOP_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_top_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_TOP_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail"), "set_corner_detail", "get_corner_detail"); + + ADD_GROUP("Expand Margin", "expand_margin_"); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_right", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_RIGHT); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_top", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_bottom", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_BOTTOM); + + ADD_GROUP("Shadow", "shadow_"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_size"), "set_shadow_size", "get_shadow_size"); + + ADD_GROUP("Anti Aliasing", "anti_aliasing_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "anti_aliasing"), "set_anti_aliased", "is_anti_aliased"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "anti_aliasing_size", PROPERTY_HINT_RANGE, "1,5,1"), "set_aa_size", "get_aa_size"); } StyleBoxFlat::StyleBoxFlat() { bg_color = Color(0.6, 0.6, 0.6); - light_color = Color(0.8, 0.8, 0.8); - dark_color = Color(0.8, 0.8, 0.8); - draw_center = true; - blend = true; - border_size = 0; - additional_border_size[0] = 0; - additional_border_size[1] = 0; - additional_border_size[2] = 0; - additional_border_size[3] = 0; + shadow_color = Color(0, 0, 0, 0.6); + + border_color.append(Color(0.8, 0.8, 0.8)); + border_color.append(Color(0.8, 0.8, 0.8)); + border_color.append(Color(0.8, 0.8, 0.8)); + border_color.append(Color(0.8, 0.8, 0.8)); + + blend_border = false; + filled = true; + anti_aliased = true; + + shadow_size = 0; + corner_detail = 8; + aa_size = 1; + + border_width[0] = 0; + border_width[1] = 0; + border_width[2] = 0; + border_width[3] = 0; + + expand_margin[0] = 0; + expand_margin[1] = 0; + expand_margin[2] = 0; + expand_margin[3] = 0; + + corner_radius[0] = 0; + corner_radius[1] = 0; + corner_radius[2] = 0; + corner_radius[3] = 0; } StyleBoxFlat::~StyleBoxFlat() { } diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 64ce3528aa..a750fae753 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -77,6 +77,14 @@ class StyleBoxTexture : public StyleBox { GDCLASS(StyleBoxTexture, StyleBox); +public: + enum AxisStretchMode { + AXIS_STRETCH_MODE_STRETCH, + AXIS_STRETCH_MODE_TILE, + AXIS_STRETCH_MODE_TILE_FIT, + }; + +private: float expand_margin[4]; float margin[4]; Rect2 region_rect; @@ -84,6 +92,8 @@ class StyleBoxTexture : public StyleBox { Ref<Texture> normal_map; bool draw_center; Color modulate; + AxisStretchMode axis_h; + AxisStretchMode axis_v; protected: virtual float get_style_margin(Margin p_margin) const; @@ -109,6 +119,12 @@ public: bool get_draw_center() const; virtual Size2 get_center_size() const; + void set_h_axis_stretch_mode(AxisStretchMode p_mode); + AxisStretchMode get_h_axis_stretch_mode() const; + + void set_v_axis_stretch_mode(AxisStretchMode p_mode); + AxisStretchMode get_v_axis_stretch_mode() const; + void set_modulate(const Color &p_modulate); Color get_modulate() const; @@ -118,44 +134,88 @@ public: ~StyleBoxTexture(); }; +VARIANT_ENUM_CAST(StyleBoxTexture::AxisStretchMode) + class StyleBoxFlat : public StyleBox { GDCLASS(StyleBoxFlat, StyleBox); Color bg_color; - Color light_color; - Color dark_color; + Color shadow_color; + PoolVector<Color> border_color; - int border_size; - int additional_border_size[4]; + int border_width[4]; + int expand_margin[4]; + int corner_radius[4]; - bool draw_center; - bool blend; + bool filled; + bool blend_border; + bool anti_aliased; + + int corner_detail; + int shadow_size; + int aa_size; protected: virtual float get_style_margin(Margin p_margin) const; static void _bind_methods(); public: + //Color void set_bg_color(const Color &p_color); - void set_light_color(const Color &p_color); - void set_dark_color(const Color &p_color); - Color get_bg_color() const; - Color get_light_color() const; - Color get_dark_color() const; - void set_border_size(int p_size); - int get_border_size() const; + //Border Color + void set_border_color_all(const Color &p_color); + Color get_border_color_all() const; + void set_border_color(Margin p_border, const Color &p_color); + Color get_border_color(Margin p_border) const; + + //BORDER + //width + void set_border_width_all(int p_size); + int get_border_width_min() const; - void _set_additional_border_size(Margin p_margin, int p_size); - int _get_additional_border_size(Margin p_margin) const; + void set_border_width(Margin p_margin, int p_size); + int get_border_width(Margin p_margin) const; + //blend void set_border_blend(bool p_blend); bool get_border_blend() const; - void set_draw_center(bool p_draw); - bool get_draw_center() const; + //CORNER + void set_corner_radius_all(int radius); + void set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_botton_right, const int radius_bottom_left); + int get_corner_radius_min() const; + + void set_corner_radius(Corner p_corner, const int radius); + int get_corner_radius(Corner p_corner) const; + + void set_corner_detail(const int &p_corner_detail); + int get_corner_detail() const; + + //EXPANDS + void set_expand_margin_size(Margin p_expand_margin, float p_size); + float get_expand_margin_size(Margin p_expand_margin) const; + + //FILLED + void set_filled(bool p_draw); + bool is_filled() const; + + //SHADOW + void set_shadow_color(const Color &p_color); + Color get_shadow_color() const; + + void set_shadow_size(const int &p_size); + int get_shadow_size() const; + + //ANTI_ALIASING + void set_anti_aliased(const bool &p_anit_aliasing); + bool is_anti_aliased() const; + //tempAA + void set_aa_size(const int &p_aa_size); + int get_aa_size() const; + virtual Size2 get_center_size() const; virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 1d5aed0444..ac1bb105ac 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -883,7 +883,7 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin ERR_FAIL_V(RES()); } - sbflat->set_border_size(params[0].to_int()); + sbflat->set_border_width_all(params[0].to_int()); if (!params[0].is_valid_integer()) { @@ -929,8 +929,8 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin dark = Color::html(params[3]); } - sbflat->set_dark_color(dark); - sbflat->set_light_color(bright); + sbflat->set_border_color_all(bright); + // sbflat->set_dark_color(dark); sbflat->set_bg_color(normal); if (params.size() == ccodes + 5) { diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 49f9e161fa..f8350ce0f8 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1563,9 +1563,9 @@ const ShaderLanguage::BuiltinFuncDef ShaderLanguage::builtin_func_defs[] = { { "reflect", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, { "refract", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_FLOAT, TYPE_VOID } }, - { "facefordward", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, - { "facefordward", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, - { "facefordward", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, + { "faceforward", TYPE_VEC2, { TYPE_VEC2, TYPE_VEC2, TYPE_VEC2, TYPE_VOID } }, + { "faceforward", TYPE_VEC3, { TYPE_VEC3, TYPE_VEC3, TYPE_VEC3, TYPE_VOID } }, + { "faceforward", TYPE_VEC4, { TYPE_VEC4, TYPE_VEC4, TYPE_VEC4, TYPE_VOID } }, { "matrixCompMult", TYPE_MAT2, { TYPE_MAT2, TYPE_MAT2, TYPE_VOID } }, { "matrixCompMult", TYPE_MAT3, { TYPE_MAT3, TYPE_MAT3, TYPE_VOID } }, |