diff options
-rw-r--r-- | core/io/http_client.cpp | 6 | ||||
-rw-r--r-- | core/io/http_client.h | 1 | ||||
-rw-r--r-- | doc/classes/HTTPClient.xml | 12 | ||||
-rw-r--r-- | doc/classes/HTTPRequest.xml | 4 | ||||
-rw-r--r-- | doc/classes/Node.xml | 4 | ||||
-rw-r--r-- | doc/classes/Viewport.xml | 1 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 30 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.h | 1 | ||||
-rw-r--r-- | editor/plugins/style_box_editor_plugin.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.cpp | 33 | ||||
-rw-r--r-- | editor/plugins/tile_map_editor_plugin.h | 2 | ||||
-rw-r--r-- | platform/javascript/http_client_javascript.cpp | 4 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 1 | ||||
-rw-r--r-- | scene/main/http_request.cpp | 16 | ||||
-rw-r--r-- | scene/main/http_request.h | 3 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 21 | ||||
-rw-r--r-- | scene/resources/style_box.h | 3 |
18 files changed, 112 insertions, 42 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 9d541c4fa7..1904c70f42 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -715,6 +715,10 @@ void HTTPClient::set_read_chunk_size(int p_size) { read_chunk_size = p_size; } +int HTTPClient::get_read_chunk_size() const { + return read_chunk_size; +} + HTTPClient::HTTPClient() { tcp_connection.instance(); @@ -818,6 +822,7 @@ void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("get_response_body_length"), &HTTPClient::get_response_body_length); ClassDB::bind_method(D_METHOD("read_response_body_chunk"), &HTTPClient::read_response_body_chunk); ClassDB::bind_method(D_METHOD("set_read_chunk_size", "bytes"), &HTTPClient::set_read_chunk_size); + ClassDB::bind_method(D_METHOD("get_read_chunk_size"), &HTTPClient::get_read_chunk_size); ClassDB::bind_method(D_METHOD("set_blocking_mode", "enabled"), &HTTPClient::set_blocking_mode); ClassDB::bind_method(D_METHOD("is_blocking_mode_enabled"), &HTTPClient::is_blocking_mode_enabled); @@ -829,6 +834,7 @@ void HTTPClient::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_connection", "get_connection"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "read_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_read_chunk_size", "get_read_chunk_size"); BIND_ENUM_CONSTANT(METHOD_GET); BIND_ENUM_CONSTANT(METHOD_HEAD); diff --git a/core/io/http_client.h b/core/io/http_client.h index 85ee1959a2..ce7fe0491b 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -220,6 +220,7 @@ public: bool is_blocking_mode_enabled() const; void set_read_chunk_size(int p_size); + int get_read_chunk_size() const; Error poll(); diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index 52e4b94051..3347eeafa7 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -170,15 +170,6 @@ Sends the body data raw, as a byte array and does not encode it in any way. </description> </method> - <method name="set_read_chunk_size"> - <return type="void"> - </return> - <argument index="0" name="bytes" type="int"> - </argument> - <description> - Sets the size of the buffer used and maximum bytes to read per iteration. See [method read_response_body_chunk]. - </description> - </method> </methods> <members> <member name="blocking_mode_enabled" type="bool" setter="set_blocking_mode" getter="is_blocking_mode_enabled" default="false"> @@ -187,6 +178,9 @@ <member name="connection" type="StreamPeer" setter="set_connection" getter="get_connection"> The connection to use for this client. </member> + <member name="read_chunk_size" type="int" setter="set_read_chunk_size" getter="get_read_chunk_size" default="4096"> + The size of the buffer used and maximum bytes to read per iteration. See [method read_response_body_chunk]. + </member> </members> <constants> <constant name="METHOD_GET" value="0" enum="Method"> diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index d0e8a5972f..98ba08e6a2 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -93,6 +93,10 @@ <member name="body_size_limit" type="int" setter="set_body_size_limit" getter="get_body_size_limit" default="-1"> Maximum allowed size for response bodies. </member> + <member name="download_chunk_size" type="int" setter="set_download_chunk_size" getter="get_download_chunk_size" default="4096"> + The size of the buffer used and maximum bytes to read per iteration. See [member HTTPClient.read_chunk_size]. + Set this to a higher value (e.g. 65536 for 64 KiB) when downloading large files to achieve better speeds at the cost of memory. + </member> <member name="download_file" type="String" setter="set_download_file" getter="get_download_file" default=""""> The file to download into. Will output any received file into it. </member> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index cecbce90b3..e9fb47cbbd 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -251,7 +251,7 @@ <argument index="0" name="path" type="NodePath"> </argument> <description> - Fetches a node. The [NodePath] can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a [code]null instance[/code] is returned and attempts to access it will result in an "Attempt to call <method> on a null instance." error. + Fetches a node. The [NodePath] can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a [code]null instance[/code] is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error. [b]Note:[/b] Fetching absolute paths only works when the node is inside the scene tree (see [method is_inside_tree]). [b]Example:[/b] Assume your current node is Character and the following tree: [codeblock] @@ -295,7 +295,7 @@ <argument index="0" name="path" type="NodePath"> </argument> <description> - Similar to [method get_node], but does not raise an error if [code]path[/code] does not point to a valid [Node]. + Similar to [method get_node], but does not log an error if [code]path[/code] does not point to a valid [Node]. </description> </method> <method name="get_parent" qualifiers="const"> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 9bc46881f9..4effe9aad2 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -126,6 +126,7 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if the viewport is currently performing a drag operation. </description> </method> <method name="input"> diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 147bab9d1f..15b2193cbe 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -4657,7 +4657,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glGenRenderbuffers(1, &rt->depth); glBindRenderbuffer(GL_RENDERBUFFER, rt->depth); - glRenderbufferStorage(GL_RENDERBUFFER, config.depth_internalformat, rt->width, rt->height); + glRenderbufferStorage(GL_RENDERBUFFER, config.depth_buffer_internalformat, rt->width, rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth); } @@ -4725,7 +4725,7 @@ void RasterizerStorageGLES2::_render_target_allocate(RenderTarget *rt) { glGenRenderbuffers(1, &rt->multisample_depth); glBindRenderbuffer(GL_RENDERBUFFER, rt->multisample_depth); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_internalformat, rt->width, rt->height); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_buffer_internalformat, rt->width, rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->multisample_depth); @@ -5189,7 +5189,7 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar // create a multisample depth buffer, we're not reusing Godots because Godot's didn't get created.. glGenRenderbuffers(1, &rt->external.depth); glBindRenderbuffer(GL_RENDERBUFFER, rt->external.depth); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_internalformat, rt->width, rt->height); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, msaa, config.depth_buffer_internalformat, rt->width, rt->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->external.depth); } @@ -5302,7 +5302,7 @@ RID RasterizerStorageGLES2::canvas_light_shadow_buffer_create(int p_width) { glGenRenderbuffers(1, &cls->depth); glBindRenderbuffer(GL_RENDERBUFFER, cls->depth); - glRenderbufferStorage(GL_RENDERBUFFER, config.depth_internalformat, cls->size, cls->height); + glRenderbufferStorage(GL_RENDERBUFFER, config.depth_buffer_internalformat, cls->size, cls->height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, cls->depth); glGenTextures(1, &cls->distance); @@ -5783,6 +5783,8 @@ void RasterizerStorageGLES2::initialize() { config.keep_original_textures = false; config.shrink_textures_x2 = false; + config.depth_internalformat = GL_DEPTH_COMPONENT; + config.depth_type = GL_UNSIGNED_INT; #ifdef GLES_OVER_GL config.float_texture_supported = true; @@ -5790,20 +5792,20 @@ void RasterizerStorageGLES2::initialize() { config.pvrtc_supported = false; config.etc1_supported = false; config.support_npot_repeat_mipmap = true; - config.depth_internalformat = GL_DEPTH_COMPONENT; - config.depth_type = GL_UNSIGNED_INT; + config.depth_buffer_internalformat = GL_DEPTH_COMPONENT24; #else config.float_texture_supported = config.extensions.has("GL_ARB_texture_float") || config.extensions.has("GL_OES_texture_float"); config.s3tc_supported = config.extensions.has("GL_EXT_texture_compression_s3tc") || config.extensions.has("WEBGL_compressed_texture_s3tc"); config.etc1_supported = config.extensions.has("GL_OES_compressed_ETC1_RGB8_texture") || config.extensions.has("WEBGL_compressed_texture_etc1"); config.pvrtc_supported = config.extensions.has("IMG_texture_compression_pvrtc") || config.extensions.has("WEBGL_compressed_texture_pvrtc"); config.support_npot_repeat_mipmap = config.extensions.has("GL_OES_texture_npot"); - // on mobile check for 24 bit depth support + + // on mobile check for 24 bit depth support for RenderBufferStorage if (config.extensions.has("GL_OES_depth24")) { - config.depth_internalformat = _DEPTH_COMPONENT24_OES; + config.depth_buffer_internalformat = _DEPTH_COMPONENT24_OES; config.depth_type = GL_UNSIGNED_INT; } else { - config.depth_internalformat = GL_DEPTH_COMPONENT16; + config.depth_buffer_internalformat = GL_DEPTH_COMPONENT16; config.depth_type = GL_UNSIGNED_SHORT; } #endif @@ -5882,7 +5884,7 @@ void RasterizerStorageGLES2::initialize() { GLuint depth; glGenTextures(1, &depth); glBindTexture(GL_TEXTURE_2D, depth); - glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, config.depth_internalformat, config.depth_type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, config.depth_type, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -5901,8 +5903,12 @@ void RasterizerStorageGLES2::initialize() { if (status != GL_FRAMEBUFFER_COMPLETE) { // If it fails, test to see if it supports a framebuffer texture using UNSIGNED_SHORT // This is needed because many OSX devices don't support either UNSIGNED_INT or UNSIGNED_SHORT - +#ifdef GLES_OVER_GL config.depth_internalformat = GL_DEPTH_COMPONENT16; +#else + // OES_depth_texture extension only specifies GL_DEPTH_COMPONENT. + config.depth_internalformat = GL_DEPTH_COMPONENT; +#endif config.depth_type = GL_UNSIGNED_SHORT; glGenFramebuffers(1, &fbo); @@ -5910,7 +5916,7 @@ void RasterizerStorageGLES2::initialize() { glGenTextures(1, &depth); glBindTexture(GL_TEXTURE_2D, depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 32, 32, 0, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, config.depth_internalformat, 32, 32, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index 6de530d8c3..daf6b93afc 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -99,6 +99,7 @@ public: GLuint depth_internalformat; GLuint depth_type; + GLuint depth_buffer_internalformat; } config; diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index c4a9803ff4..7e5e278689 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -68,7 +68,14 @@ void StyleBoxPreview::_sb_changed() { void StyleBoxPreview::_redraw() { if (stylebox.is_valid()) { - preview->draw_style_box(stylebox, preview->get_rect()); + Rect2 preview_rect = preview->get_rect(); + + // Re-adjust preview panel to fit all drawn content + Rect2 draw_rect = stylebox->get_draw_rect(preview_rect); + preview_rect.size -= draw_rect.size - preview_rect.size; + preview_rect.position -= draw_rect.position - preview_rect.position; + + preview->draw_style_box(stylebox, preview_rect); } } @@ -81,6 +88,7 @@ void StyleBoxPreview::_bind_methods() { StyleBoxPreview::StyleBoxPreview() { preview = memnew(Control); preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE)); + preview->set_clip_contents(true); preview->connect("draw", this, "_redraw"); add_margin_child(TTR("Preview:"), preview); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 0cef5a8b6f..7651ab8526 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -713,7 +713,7 @@ TextEditor::TextEditor() { goto_menu->get_popup()->add_separator(); bookmarks_menu = memnew(PopupMenu); - bookmarks_menu->set_name(TTR("Bookmarks")); + bookmarks_menu->set_name("Bookmarks"); goto_menu->get_popup()->add_child(bookmarks_menu); goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks"); _update_bookmark_list(); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 385ba4cfda..a8e81b612b 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -52,12 +52,6 @@ void TileMapEditor::_notification(int p_what) { 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(); } @@ -1250,14 +1244,13 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { CanvasItemEditor::get_singleton()->update_viewport(); } - if (show_tile_info) { - int tile_under = node->get_cell(over_tile.x, over_tile.y); - String tile_name = "none"; + 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->show(); + tile_info->set_text(String::num(over_tile.x) + ", " + String::num(over_tile.y) + " [" + tile_name + "]"); if (tool == TOOL_PAINTING) { @@ -1925,7 +1918,6 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { tool = TOOL_NONE; selection_active = false; mouse_over = false; - show_tile_info = true; flip_h = false; flip_v = false; @@ -2055,7 +2047,12 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { // Tile position. tile_info = memnew(Label); - toolbar_right->add_child(tile_info); + tile_info->set_modulate(Color(1, 1, 1, 0.8)); + tile_info->set_mouse_filter(MOUSE_FILTER_IGNORE); + tile_info->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("main", "EditorFonts")); + // The tile info is only displayed after a tile has been hovered. + tile_info->hide(); + CanvasItemEditor::get_singleton()->add_control_to_info_overlay(tile_info); // Menu. options = memnew(MenuButton); @@ -2151,6 +2148,10 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { tile_map_editor->show(); tile_map_editor->get_toolbar()->show(); tile_map_editor->get_toolbar_right()->show(); + // `tile_info` isn't shown here, as it's displayed after a tile has been hovered. + // Otherwise, a translucent black rectangle would be visible as there would be an + // empty Label in the CanvasItemEditor's info overlay. + // Change to TOOL_SELECT when TileMap node is selected, to prevent accidental movement. CanvasItemEditor::get_singleton()->set_current_tool(CanvasItemEditor::TOOL_SELECT); } else { @@ -2158,6 +2159,7 @@ void TileMapEditorPlugin::make_visible(bool p_visible) { tile_map_editor->hide(); tile_map_editor->get_toolbar()->hide(); tile_map_editor->get_toolbar_right()->hide(); + tile_map_editor->get_tile_info()->hide(); tile_map_editor->edit(NULL); } } @@ -2170,7 +2172,6 @@ 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); EDITOR_DEF("editors/tile_map/editor_side", 1); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/tile_map/editor_side", PROPERTY_HINT_ENUM, "Left,Right")); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index e3d678c2fd..6400431bd1 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -109,7 +109,6 @@ class TileMapEditor : public VBoxContainer { bool selection_active; bool mouse_over; - bool show_tile_info; bool flip_h; bool flip_v; @@ -218,6 +217,7 @@ protected: public: HBoxContainer *get_toolbar() const { return toolbar; } HBoxContainer *get_toolbar_right() const { return toolbar_right; } + Label *get_tile_info() const { return tile_info; } bool forward_gui_input(const Ref<InputEvent> &p_event); void forward_canvas_draw_over_viewport(Control *p_overlay); diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp index e6e933811f..1f3f2ed53c 100644 --- a/platform/javascript/http_client_javascript.cpp +++ b/platform/javascript/http_client_javascript.cpp @@ -211,6 +211,10 @@ void HTTPClient::set_read_chunk_size(int p_size) { read_limit = p_size; } +int HTTPClient::get_read_chunk_size() const { + return read_limit; +} + Error HTTPClient::poll() { switch (status) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8ddc31745e..b997d7a064 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4593,6 +4593,7 @@ void TextEdit::_scroll_moved(double p_to_val) { break; } } + n_line = MIN(n_line, text.size() - 1); int line_wrap_amount = times_line_wraps(n_line); int wi = line_wrap_amount - (sc - v_scroll_i - 1); wi = CLAMP(wi, 0, line_wrap_amount); diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 6c922adbd2..0ae330b2ed 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -457,6 +457,18 @@ String HTTPRequest::get_download_file() const { return download_to_file; } + +void HTTPRequest::set_download_chunk_size(int p_chunk_size) { + + ERR_FAIL_COND(get_http_client_status() != HTTPClient::STATUS_DISCONNECTED); + + client->set_read_chunk_size(p_chunk_size); +} + +int HTTPRequest::get_download_chunk_size() const { + return client->get_read_chunk_size(); +} + HTTPClient::Status HTTPRequest::get_http_client_status() const { return client->get_status(); } @@ -524,9 +536,13 @@ void HTTPRequest::_bind_methods() { ClassDB::bind_method(D_METHOD("set_timeout", "timeout"), &HTTPRequest::set_timeout); ClassDB::bind_method(D_METHOD("get_timeout"), &HTTPRequest::get_timeout); + ClassDB::bind_method(D_METHOD("set_download_chunk_size"), &HTTPRequest::set_download_chunk_size); + ClassDB::bind_method(D_METHOD("get_download_chunk_size"), &HTTPRequest::get_download_chunk_size); + ClassDB::bind_method(D_METHOD("_timeout"), &HTTPRequest::_timeout); ADD_PROPERTY(PropertyInfo(Variant::STRING, "download_file", PROPERTY_HINT_FILE), "set_download_file", "get_download_file"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "download_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_download_chunk_size", "get_download_chunk_size"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), "set_use_threads", "is_using_threads"); ADD_PROPERTY(PropertyInfo(Variant::INT, "body_size_limit", PROPERTY_HINT_RANGE, "-1,2000000000"), "set_body_size_limit", "get_body_size_limit"); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_redirects", PROPERTY_HINT_RANGE, "-1,64"), "set_max_redirects", "get_max_redirects"); diff --git a/scene/main/http_request.h b/scene/main/http_request.h index f1f91235a6..fa01172d9f 100644 --- a/scene/main/http_request.h +++ b/scene/main/http_request.h @@ -126,6 +126,9 @@ public: void set_download_file(const String &p_file); String get_download_file() const; + void set_download_chunk_size(int p_chunk_size); + int get_download_chunk_size() const; + void set_body_size_limit(int p_bytes); int get_body_size_limit() const; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index d56360f918..f26b57b572 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -81,6 +81,10 @@ Size2 StyleBox::get_center_size() const { return Size2(); } +Rect2 StyleBox::get_draw_rect(const Rect2 &p_rect) const { + return p_rect; +} + void StyleBox::_bind_methods() { ClassDB::bind_method(D_METHOD("test_mask", "point", "rect"), &StyleBox::test_mask); @@ -175,6 +179,10 @@ float StyleBoxTexture::get_style_margin(Margin p_margin) const { return margin[p_margin]; } +Rect2 StyleBoxTexture::get_draw_rect(const Rect2 &p_rect) const { + return p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); +} + void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const { if (texture.is_null()) return; @@ -685,6 +693,19 @@ inline void adapt_values(int p_index_a, int p_index_b, int *adapted_values, cons 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]); } + +Rect2 StyleBoxFlat::get_draw_rect(const Rect2 &p_rect) const { + Rect2 draw_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]); + + if (shadow_size > 0) { + Rect2 shadow_rect = draw_rect.grow(shadow_size); + shadow_rect.position += shadow_offset; + draw_rect = draw_rect.merge(shadow_rect); + } + + return draw_rect; +} + void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const { //PREPARATIONS diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index d02e107480..ec07b5e885 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -56,6 +56,7 @@ public: float get_margin(Margin p_margin) const; virtual Size2 get_center_size() const; + virtual Rect2 get_draw_rect(const Rect2 &p_rect) const; virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const = 0; CanvasItem *get_current_item_drawn() const; @@ -133,6 +134,7 @@ public: void set_modulate(const Color &p_modulate); Color get_modulate() const; + virtual Rect2 get_draw_rect(const Rect2 &p_rect) const; virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; StyleBoxTexture(); @@ -227,6 +229,7 @@ public: virtual Size2 get_center_size() const; + virtual Rect2 get_draw_rect(const Rect2 &p_rect) const; virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; StyleBoxFlat(); |