public class Scroller : Layout
{
SmartEvent _scroll;
+ SmartEvent _scrollAnimationStart;
+ SmartEvent _scrollAnimationStop;
SmartEvent _dragStart;
SmartEvent _dragStop;
SmartEvent _scrollpage;
}
/// <summary>
+ /// ScrollAnimationStarted will be triggered when the content animation has been started.
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public event EventHandler ScrollAnimationStarted
+ {
+ add
+ {
+ _scrollAnimationStart.On += value;
+ }
+ remove
+ {
+ _scrollAnimationStart.On -= value;
+ }
+ }
+
+ /// <summary>
+ /// ScrollAnimationStopped will be triggered when the content animation has been stopped.
+ /// </summary>
+ /// <since_tizen> preview </since_tizen>
+ public event EventHandler ScrollAnimationStopped
+ {
+ add
+ {
+ _scrollAnimationStop.On += value;
+ }
+ remove
+ {
+ _scrollAnimationStop.On -= value;
+ }
+ }
+
+ /// <summary>
/// DragStart will be triggered when dragging the contents around has started.
/// </summary>
/// <since_tizen> preview </since_tizen>
{
base.OnRealized();
_scroll = new SmartEvent(this, this.RealHandle, "scroll");
+ _scrollAnimationStart = new SmartEvent(this, this.RealHandle, "scroll,anim,start");
+ _scrollAnimationStop = new SmartEvent(this, this.RealHandle, "scroll,anim,stop");
_dragStart = new SmartEvent(this, this.RealHandle, "scroll,drag,start");
_dragStop = new SmartEvent(this, this.RealHandle, "scroll,drag,stop");
_scrollpage = new SmartEvent(this, this.RealHandle, "scroll,page,changed");
{
public override string TestName => "ScrollerTest3";
public override string TestDescription => "To test ScrollTo operation of Scroller";
+ Scroller _scroller;
public override void Run(Window window)
{
conformant.Show();
Box outterBox = new Box(window)
{
+ BackgroundColor = Color.Gray,
AlignmentX = -1,
AlignmentY = -1,
WeightX = 1,
IsHorizontal = false,
};
outterBox.Show();
- Scroller scroller = new Scroller(window)
+ _scroller = new Scroller(window)
{
AlignmentX = -1,
AlignmentY = -1,
WeightX = 1,
WeightY = 1,
- ScrollBlock = ScrollBlock.Vertical,
HorizontalPageScrollLimit = 1,
};
- scroller.SetPageSize(1.0, 1.0);
- scroller.Show();
+ _scroller.SetPageSize(1.0, 1.0);
+ _scroller.Show();
Box box = new Box(window)
{
WeightY = 1
};
box.Show();
- scroller.SetContent(box);
+ _scroller.SetContent(box);
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 150; i++)
{
Label addlabel = new Label(window)
{
}
conformant.SetContent(outterBox);
- outterBox.PackEnd(scroller);
+ outterBox.PackEnd(_scroller);
Button prev = new Button(window)
{
WeightX = 1,
Text = "next"
};
+
+ int index = 0;
+
prev.Clicked += (s, e) =>
{
- Rect region = new Rect(0, 0, scroller.Geometry.Width, scroller.Geometry.Width);
- Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width);
- scroller.ScrollTo(region, true);
+ Rect region = new Rect(0, _scroller.Geometry.Height * --index, _scroller.Geometry.Width * index, _scroller.Geometry.Height);
+ Console.WriteLine("index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ _scroller.ScrollTo(region, false);
};
+
next.Clicked += (s, e) =>
{
- Rect region = new Rect(0, scroller.Geometry.Height, scroller.Geometry.Width, scroller.Geometry.Height);
- Console.WriteLine("{0} {1}\n", scroller.Geometry.Width, scroller.Geometry.Width);
- scroller.ScrollTo(region, true);
+ Rect region = new Rect(0, _scroller.Geometry.Height * ++index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ Console.WriteLine("index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ _scroller.ScrollTo(region, false);
};
prev.Show();
next.Show();
+
+ Button prev2 = new Button(window)
+ {
+ AlignmentX = -1,
+ WeightX = 1,
+ Text = "animation Prev"
+ };
+ Button next2 = new Button(window)
+ {
+ AlignmentX = -1,
+ WeightX = 1,
+ Text = "animation next"
+ };
+
+ prev2.Clicked += (s, e) =>
+ {
+ Rect region = new Rect(0, _scroller.Geometry.Height * --index, _scroller.Geometry.Width * index, _scroller.Geometry.Height);
+ Console.WriteLine("animation index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ _scroller.ScrollTo(region, true);
+ };
+
+ next2.Clicked += (s, e) =>
+ {
+ Rect region = new Rect(0, _scroller.Geometry.Height * ++index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ Console.WriteLine("animation index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
+ _scroller.ScrollTo(region, true);
+ };
+ prev2.Show();
+ next2.Show();
+
outterBox.PackEnd(prev);
outterBox.PackEnd(next);
+ outterBox.PackEnd(prev2);
+ outterBox.PackEnd(next2);
+
+ _scroller.DragStart += Scroller_DragStart;
+ _scroller.DragStop += Scroller_DragStop;
+ _scroller.ScrollAnimationStarted += Scroller_ScrollStart;
+ _scroller.ScrollAnimationStopped += Scroller_ScrollStop;
+ _scroller.Scrolled += Scroller_Scrolled;
+ }
- scroller.DragStart += Scroller_DragStart;
- scroller.DragStop += Scroller_DragStop;
+ private void Scroller_Scrolled(object sender, EventArgs e)
+ {
+ Console.WriteLine($"scrolled : {_scroller.CurrentRegion}");
+ }
+
+ private void Scroller_ScrollStop(object sender, EventArgs e)
+ {
+ Console.WriteLine("scroll animation stop");
+ }
+
+ private void Scroller_ScrollStart(object sender, EventArgs e)
+ {
+ Console.WriteLine("scroll animation start");
}
private void Scroller_DragStop(object sender, EventArgs e)