[NUI] Fixed GridLayout scrolling issue (#1322)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Mon, 20 Jan 2020 07:14:57 +0000 (16:14 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 20 Jan 2020 07:14:57 +0000 (16:14 +0900)
When using GridLayout view with ScrollableBase, it cannot be scrolled.

It cauesd by wrong height measurement and it only happend when setting
WrapContent to layout view.

Save measurement result when using WrapContent.

Co-authored-by: krown <neostom432@nate.com>
src/Tizen.NUI.Components/Controls/ScrollableBase.cs
src/Tizen.NUI/src/public/Layouting/GridLayout.cs

index 1e29196..1e64db7 100755 (executable)
@@ -423,7 +423,7 @@ namespace Tizen.NUI.Components
 
         private void ScrollBy(float displacement, bool animate)
         {
-            if (GetChildCount() == 0 || displacement == 0)
+            if (GetChildCount() == 0 || displacement == 0 || maxScrollDistance < 0)
             {
                 return;
             }
index 8d0cd51..fe1729d 100755 (executable)
@@ -183,23 +183,24 @@ namespace Tizen.NUI
                 }
                 else
                 {
-                  // Grid expands to fit content
+                    // Grid expands to fit content
 
-                  // If number of columns AUTO_FIT then set to 1 column.
-                  _columns = ( _columns > 0 ) ? _columns : 1;
-                  // Calculate numbers of rows, round down result as later check for remainder.
-                  _rows = childCount / _columns;
-                  // If number of cells not cleanly dividable by columns, add another row to house remainder cells.
-                  _rows += ( childCount % _columns > 0 ) ? 1 : 0;
+                    // If number of columns AUTO_FIT then set to 1 column.
+                    _columns = ( _columns > 0 ) ? _columns : 1;
+                    // Calculate numbers of rows, round down result as later check for remainder.
+                    _rows = childCount / _columns;
+                    // If number of cells not cleanly dividable by columns, add another row to house remainder cells.
+                    _rows += ( childCount % _columns > 0 ) ? 1 : 0;
 
-                  availableContentHeight = desiredChildHeight * _rows;
+                    heightSize = desiredChildHeight * _rows + gridLayoutPadding.Top + gridLayoutPadding.Bottom;
+                    availableContentHeight = heightSize - gridLayoutPadding.Top - gridLayoutPadding.Bottom;
                 }
 
-            // If number of columns not defined
-            DetermineNumberOfColumns( availableContentWidth );
+                // If number of columns not defined
+                DetermineNumberOfColumns( availableContentWidth );
 
-            // Locations define the start, end,top and bottom of each cell.
-            _locations.CalculateLocations(_columns, availableContentWidth, availableContentHeight, childCount);
+                // Locations define the start, end,top and bottom of each cell.
+                _locations.CalculateLocations(_columns, availableContentWidth, availableContentHeight, childCount);
 
             } // Children exists