2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
21 namespace ElmSharp.Test
23 public class ScrollerTest6 : TestCaseBase
25 public override string TestName => "ScrollerTest6";
26 public override string TestDescription => "To test basic operation of Scroller";
28 int _currentIndex = 0;
30 public override void Run(Window window)
32 Conformant conformant = new Conformant(window);
34 Box outterBox = new Box(window)
43 conformant.SetContent(outterBox);
45 Scroller scroller = new Scroller(window)
51 ScrollBlock = ScrollBlock.Vertical
56 Box innerBox = new Box(window)
65 scroller.SetContent(innerBox);
67 var rects = new List<Rectangle>();
68 Random rnd = new Random();
69 for(int i = 0; i < 30; i++)
71 var rect = new Rectangle(window)
77 Color = Color.FromRgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)),
80 innerBox.PackEnd(rect);
84 innerBox.SetLayoutCallback(() =>
86 System.Console.WriteLine("!!!! update layout");
87 System.Console.WriteLine("MinimumWith = {0}", innerBox.MinimumWidth);
90 for (int i = 0; i < rects.Count; i++)
92 rects[i].Geometry = new Rect(i / 3 * 400 + innerBox.Geometry.X, i % 3 * 400 + innerBox.Geometry.Y, 400, 400);
94 innerBox.MinimumWidth = (int)Math.Ceiling(rects.Count / 3.0) * 400;
96 Button btn = new Button(window)
102 btn.Clicked += (s, e) =>
104 System.Console.WriteLine("current index {0}", _currentIndex);
105 System.Console.WriteLine("Before Current Region : {0}", scroller.CurrentRegion);
106 int last = rects.Count - 1;
107 innerBox.UnPack(rects[last]);
109 rects.RemoveAt(last);
111 System.Console.WriteLine(" innerBox MinimumWith = {0}", innerBox.MinimumWidth);
112 System.Console.WriteLine("After Current Region : {0}", scroller.CurrentRegion);
114 EcoreMainloop.Post(() =>
116 System.Console.WriteLine("On idler Current Region : {0}", scroller.CurrentRegion);
119 EcoreMainloop.AddTimer(0, () =>
121 System.Console.WriteLine("After 0 sec Current Region : {0}", scroller.CurrentRegion);
125 scroller.Scrolled += (s, e) =>
127 System.Console.WriteLine("Scrolled to {0}", scroller.CurrentRegion);
128 System.Console.WriteLine("in scrolling MinimumWith = {0}", innerBox.MinimumWidth);
133 outterBox.PackEnd(btn);
134 outterBox.PackEnd(scroller);