mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Add a lifecycle method for manual theme item caching to Control
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
#include "scene/main/window.h"
|
||||
|
||||
Size2 ScrollContainer::get_minimum_size() const {
|
||||
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
||||
Size2 min_size;
|
||||
|
||||
// Calculated in this function, as it needs to traverse all child controls once to calculate;
|
||||
@@ -77,10 +76,16 @@ Size2 ScrollContainer::get_minimum_size() const {
|
||||
min_size.x += v_scroll->get_minimum_size().x;
|
||||
}
|
||||
|
||||
min_size += sb->get_minimum_size();
|
||||
min_size += theme_cache.bg_style->get_minimum_size();
|
||||
return min_size;
|
||||
}
|
||||
|
||||
void ScrollContainer::_update_theme_item_cache() {
|
||||
Container::_update_theme_item_cache();
|
||||
|
||||
theme_cache.bg_style = get_theme_stylebox(SNAME("bg"));
|
||||
}
|
||||
|
||||
void ScrollContainer::_cancel_drag() {
|
||||
set_physics_process_internal(false);
|
||||
drag_touching_deaccel = false;
|
||||
@@ -271,9 +276,8 @@ void ScrollContainer::_reposition_children() {
|
||||
Size2 size = get_size();
|
||||
Point2 ofs;
|
||||
|
||||
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
||||
size -= sb->get_minimum_size();
|
||||
ofs += sb->get_offset();
|
||||
size -= theme_cache.bg_style->get_minimum_size();
|
||||
ofs += theme_cache.bg_style->get_offset();
|
||||
bool rtl = is_layout_rtl();
|
||||
|
||||
if (h_scroll->is_visible_in_tree() && h_scroll->get_parent() == this) { //scrolls may have been moved out for reasons
|
||||
@@ -337,8 +341,7 @@ void ScrollContainer::_notification(int p_what) {
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_DRAW: {
|
||||
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
||||
draw_style_box(sb, Rect2(Vector2(), get_size()));
|
||||
draw_style_box(theme_cache.bg_style, Rect2(Vector2(), get_size()));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||
@@ -413,8 +416,7 @@ void ScrollContainer::_notification(int p_what) {
|
||||
|
||||
void ScrollContainer::update_scrollbars() {
|
||||
Size2 size = get_size();
|
||||
Ref<StyleBox> sb = get_theme_stylebox(SNAME("bg"));
|
||||
size -= sb->get_minimum_size();
|
||||
size -= theme_cache.bg_style->get_minimum_size();
|
||||
|
||||
Size2 hmin = h_scroll->get_combined_minimum_size();
|
||||
Size2 vmin = v_scroll->get_combined_minimum_size();
|
||||
|
||||
Reference in New Issue
Block a user