浏览代码

Merge pull request #5942 from pkowal1982/scroll

ScrollContainer expand children bug fix
Juan Linietsky 9 年之前
父节点
当前提交
026c7913cf
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      doc/base/classes.xml
  2. 2 2
      scene/gui/scroll_container.cpp

+ 1 - 1
doc/base/classes.xml

@@ -35063,7 +35063,7 @@
 		A helper node for displaying scrollable elements (e.g. lists).
 		A helper node for displaying scrollable elements (e.g. lists).
 	</brief_description>
 	</brief_description>
 	<description>
 	<description>
-		A ScrollContainer node with a [Control] child and scrollbar child ([HScrollbar], [VScrollBar], or both) will only draw the Control within the ScrollContainer area.  Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer.  Scrollbars will also automatically resize the grabber based on the minimum_size of the Control relative to the ScrollContainer.  Works great with a [Panel] control.
+		A ScrollContainer node with a [Control] child and scrollbar child ([HScrollbar], [VScrollBar], or both) will only draw the Control within the ScrollContainer area.  Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer.  Scrollbars will also automatically resize the grabber based on the minimum_size of the Control relative to the ScrollContainer.  Works great with a [Panel] control.  You can set EXPAND on children size flags, so they will upscale to ScrollContainer size if ScrollContainer size is bigger (scroll is invisible for chosen dimension).
 	</description>
 	</description>
 	<methods>
 	<methods>
 		<method name="get_h_scroll" qualifiers="const">
 		<method name="get_h_scroll" qualifiers="const">

+ 2 - 2
scene/gui/scroll_container.cpp

@@ -228,14 +228,14 @@ void ScrollContainer::_notification(int p_what) {
 			child_max_size.y = MAX(child_max_size.y, minsize.y);
 			child_max_size.y = MAX(child_max_size.y, minsize.y);
 
 
 			Rect2 r = Rect2(-scroll,minsize);
 			Rect2 r = Rect2(-scroll,minsize);
-			if (!scroll_h) {
+			if (!h_scroll->is_visible()) {
 				r.pos.x=0;
 				r.pos.x=0;
 				if (c->get_h_size_flags()&SIZE_EXPAND)
 				if (c->get_h_size_flags()&SIZE_EXPAND)
 					r.size.width=MAX(size.width,minsize.width);
 					r.size.width=MAX(size.width,minsize.width);
 				else
 				else
 					r.size.width=minsize.width;
 					r.size.width=minsize.width;
 			}
 			}
-			if (!scroll_v) {
+			if (!v_scroll->is_visible()) {
 				r.pos.y=0;
 				r.pos.y=0;
 				r.size.height=size.height;
 				r.size.height=size.height;
 				if (c->get_v_size_flags()&SIZE_EXPAND)
 				if (c->get_v_size_flags()&SIZE_EXPAND)