Skip to content

Commit

Permalink
Add ignore_panel_min_size to ScrollContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
WhalesState committed Jan 27, 2024
1 parent ce3796b commit e83525d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions scene/gui/scroll_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ Size2 ScrollContainer::get_minimum_size() const {
min_size.x += v_scroll->get_minimum_size().x;
}
}

min_size += theme_cache.panel_style->get_minimum_size();
if (!ignore_panel_min_size) {
min_size += theme_cache.panel_style->get_minimum_size();
}
return min_size;
}

Expand Down Expand Up @@ -548,6 +549,15 @@ bool ScrollContainer::is_ignoring_scroll_bar_min_size() const {
return ignore_scroll_bar_min_size;
}

void ScrollContainer::set_ignore_panel_min_size(bool p_ignore) {
ignore_panel_min_size = p_ignore;
update_minimum_size();
}

bool ScrollContainer::is_ignoring_panel_min_size() const {
return ignore_panel_min_size;
}

PackedStringArray ScrollContainer::get_configuration_warnings() const {
PackedStringArray warnings = Container::get_configuration_warnings();

Expand Down Expand Up @@ -613,6 +623,9 @@ void ScrollContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_ignore_scroll_bar_min_size", "ignore"), &ScrollContainer::set_ignore_scroll_bar_min_size);
ClassDB::bind_method(D_METHOD("is_ignoring_scroll_bar_min_size"), &ScrollContainer::is_ignoring_scroll_bar_min_size);

ClassDB::bind_method(D_METHOD("set_ignore_panel_min_size", "ignore"), &ScrollContainer::set_ignore_panel_min_size);
ClassDB::bind_method(D_METHOD("is_ignoring_panel_min_size"), &ScrollContainer::is_ignoring_panel_min_size);

ClassDB::bind_method(D_METHOD("get_h_scroll_bar"), &ScrollContainer::get_h_scroll_bar);
ClassDB::bind_method(D_METHOD("get_v_scroll_bar"), &ScrollContainer::get_v_scroll_bar);
ClassDB::bind_method(D_METHOD("ensure_control_visible", "control"), &ScrollContainer::ensure_control_visible);
Expand All @@ -622,6 +635,7 @@ void ScrollContainer::_bind_methods() {

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_focus"), "set_follow_focus", "is_following_focus");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_scroll_bar_min_size"), "set_ignore_scroll_bar_min_size", "is_ignoring_scroll_bar_min_size");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ignore_panel_min_size"), "set_ignore_panel_min_size", "is_ignoring_panel_min_size");

ADD_GROUP("Scroll", "scroll_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal", PROPERTY_HINT_NONE, "suffix:px"), "set_h_scroll", "get_h_scroll");
Expand Down
6 changes: 5 additions & 1 deletion scene/gui/scroll_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class ScrollContainer : public Container {
ScrollMode vertical_scroll_mode = SCROLL_MODE_AUTO;

int deadzone = 0;
bool follow_focus = false;
bool follow_focus = true;
bool ignore_scroll_bar_min_size = true;
bool ignore_panel_min_size = true;

struct ThemeCache {
Ref<StyleBox> panel_style;
Expand Down Expand Up @@ -119,6 +120,9 @@ class ScrollContainer : public Container {
void set_ignore_scroll_bar_min_size(bool p_ignore);
bool is_ignoring_scroll_bar_min_size() const;

void set_ignore_panel_min_size(bool p_ignore);
bool is_ignoring_panel_min_size() const;

HScrollBar *get_h_scroll_bar();
VScrollBar *get_v_scroll_bar();
void ensure_control_visible(Control *p_control);
Expand Down

0 comments on commit e83525d

Please sign in to comment.