Quellcode durchsuchen

Containers with ScrollBars will lay out their controls the first time update() is called on them, in order to auto-size controls before measuring the size of the scrollable region. This fixes an issue where scrollbars would not appear until the Container was clicked / touched, with scrollBarAutoHide disabled, for programmatically created forms.

Adam Blake vor 13 Jahren
Ursprung
Commit
c1ef988b63
3 geänderte Dateien mit 9 neuen und 3 gelöschten Zeilen
  1. 7 1
      gameplay/src/Container.cpp
  2. 2 0
      gameplay/src/Container.h
  3. 0 2
      gameplay/src/Form.cpp

+ 7 - 1
gameplay/src/Container.cpp

@@ -41,7 +41,7 @@ Container::Container()
       _scrollingRight(false), _scrollingDown(false),
       _scrollingMouseVertically(false), _scrollingMouseHorizontally(false),
       _scrollBarOpacityClip(NULL), _zIndexDefault(0), _focusIndexDefault(0), _focusIndexMax(0), _totalWidth(0), _totalHeight(0),
-      _contactIndices(0)
+      _contactIndices(0), _initializedWithScroll(false)
 {
 }
 
@@ -615,6 +615,12 @@ Layout::Type Container::getLayoutType(const char* layoutString)
 
 void Container::updateScroll()
 {
+    if (!_initializedWithScroll)
+    {
+        _initializedWithScroll = true;
+        _layout->update(this, _scrollPosition);
+    }
+
     // Update Time.
     static double lastFrameTime = Game::getGameTime();
     double frameTime = Game::getGameTime();

+ 2 - 0
gameplay/src/Container.h

@@ -507,6 +507,8 @@ private:
     float _totalHeight;
 
     int _contactIndices;
+
+    bool _initializedWithScroll;
 };
 
 }

+ 0 - 2
gameplay/src/Form.cpp

@@ -199,8 +199,6 @@ Form* Form::create(const char* url)
     // Add all the controls to the form.
     form->addControls(theme, formProperties);
 
-    form->update(0.0f);
-
     SAFE_DELETE(properties);
 
     __forms.push_back(form);