summaryrefslogtreecommitdiff
path: root/ElmSharp/ElmSharp/Scroller.cs
blob: 35ed35a9c98af0ce4a998f623242bdbd0e09735e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
/*
 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;

namespace ElmSharp
{
    /// <summary>
    /// Enumeration for visible type of scrollbar.
    /// </summary>
    public enum ScrollBarVisiblePolicy
    {
        /// <summary>
        /// Show scrollbars as needed
        /// </summary>
        Auto = 0,

        /// <summary>
        /// Always show scrollbars
        /// </summary>
        Visible,

        /// <summary>
        /// Never show scrollbars
        /// </summary>
        Invisible
    }

    /// <summary>
    /// Enumeration for visible type of scrollbar.
    /// </summary>
    public enum ScrollBlock
    {
        /// <summary>
        /// Scrolling movement is allowed in both direction.(X axis and Y axis)
        /// </summary>
        None = 1,

        /// <summary>
        /// Scrolling movement is not allowed in Y axis direction.
        /// </summary>
        Vertical = 2,

        /// <summary>
        /// Scrolling movement is not allowed in X axis direction.
        /// </summary>
        Horizontal = 4
    }

    /// <summary>
    /// Type that controls how the content is scrolled.
    /// </summary>
    public enum ScrollSingleDirection
    {
        /// <summary>
        /// Scroll every direction.
        /// </summary>
        None,

        /// <summary>
        /// Scroll single direction if the direction is certain.
        /// </summary>
        Soft,

        /// <summary>
        /// Scroll only single direction.
        /// </summary>
        Hard,
    }

    /// <summary>
    /// The Scroller is a container that holds and clips a single object and allows you to scroll across it.
    /// </summary>
    public class Scroller : Layout
    {
        SmartEvent _scroll;
        SmartEvent _dragStart;
        SmartEvent _dragStop;
        SmartEvent _scrollpage;

        /// <summary>
        /// Creates and initializes a new instance of the Scroller class.
        /// </summary>
        /// <param name="parent">The <see cref="EvasObject"/> to which the new Scroller will be attached as a child.</param>
        public Scroller(EvasObject parent) : base(parent)
        {
            _scroll = new SmartEvent(this, this.RealHandle, "scroll");
            _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");
        }

        /// <summary>
        /// Scrolled will be triggered when the content has been scrolled.
        /// </summary>
        public event EventHandler Scrolled
        {
            add
            {
                _scroll.On += value;
            }
            remove
            {
                _scroll.On -= value;
            }
        }

        /// <summary>
        /// DragStart will be triggered when dragging the contents around has started.
        /// </summary>
        public event EventHandler DragStart
        {
            add
            {
                _dragStart.On += value;
            }
            remove
            {
                _dragStart.On -= value;
            }
        }

        /// <summary>
        /// DragStop will be triggered when dragging the contents around has stopped.
        /// </summary>
        public event EventHandler DragStop
        {
            add
            {
                _dragStop.On += value;
            }
            remove
            {
                _dragStop.On -= value;
            }
        }

        /// <summary>
        /// PageScrolled will be triggered when the visible page has changed.
        /// </summary>
        public event EventHandler PageScrolled
        {
            add
            {
                _scrollpage.On += value;
            }
            remove
            {
                _scrollpage.On -= value;
            }
        }

        /// <summary>
        /// Gets the current region in the content object that is visible through the Scroller.
        /// </summary>
        public Rect CurrentRegion
        {
            get
            {
                int x, y, w, h;
                Interop.Elementary.elm_scroller_region_get(RealHandle, out x, out y, out w, out h);
                return new Rect(x, y, w, h);
            }
        }

        /// <summary>
        /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
        /// </summary>
        /// <remarks>
        /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
        /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
        /// </remarks>
        public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
        {
            get
            {
                int policy;
                Interop.Elementary.elm_scroller_policy_get(RealHandle, out policy, IntPtr.Zero);
                return (ScrollBarVisiblePolicy)policy;
            }
            set
            {
                ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
                Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)value, (int)v);
            }
        }

        /// <summary>
        /// Sets or gets the value of VerticalScrollBarVisiblePolicy
        /// </summary>
        /// <remarks>
        /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
        /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
        /// </remarks>
        public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
        {
            get
            {
                int policy;
                Interop.Elementary.elm_scroller_policy_get(RealHandle, IntPtr.Zero, out policy);
                return (ScrollBarVisiblePolicy)policy;
            }
            set
            {
                ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
                Interop.Elementary.elm_scroller_policy_set(RealHandle, (int)h, (int)value);
            }
        }

        /// <summary>
        /// Sets or gets the value of ScrollBlock.
        /// </summary>
        /// <remarks>
        /// This function will block scrolling movement  in a given direction.One can disable movements in the X axis, the Y axis or both.
        /// The default value is ScrollBlock.None, where movements are allowed in both directions.
        /// </remarks>
        public ScrollBlock ScrollBlock
        {
            get
            {
                return (ScrollBlock)Interop.Elementary.elm_scroller_movement_block_get(RealHandle);
            }
            set
            {
                Interop.Elementary.elm_scroller_movement_block_set(RealHandle, (int)value);
            }
        }

        /// <summary>
        /// Sets or gets scroll current page number.
        /// </summary>
        /// <remarks>
        /// Current page means the page which meets the top of the viewport.
        /// If there are two or more pages in the viewport, it returns the number of the page which meets the top of the viewport.
        /// The page number starts from 0. 0 is the first page.
        /// </remarks>
        public int VerticalPageIndex
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_current_page_get(RealHandle, out h, out v);
                return v;
            }
        }

        /// <summary>
        /// Sets or gets scroll current page number.
        /// </summary>
        /// <remarks>
        /// Current page means the page which meets the left of the viewport.
        /// If there are two or more pages in the viewport, it returns the number of the page which meets the left of the viewport.
        /// The page number starts from 0. 0 is the first page.
        /// </remarks>
        public int HorizontalPageIndex
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_current_page_get(RealHandle, out h, out v);
                return h;
            }
        }

        /// <summary>
        /// Sets or gets the maximum limit of the movable page at vertical direction.
        /// </summary>
        public int VerticalPageScrollLimit
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_page_scroll_limit_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                int h = HorizontalPageScrollLimit;
                Interop.Elementary.elm_scroller_page_scroll_limit_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Sets or gets the maximum limit of the movable page at horizontal direction.
        /// </summary>
        public int HorizontalPageScrollLimit
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_page_scroll_limit_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                int v = VerticalPageScrollLimit;
                Interop.Elementary.elm_scroller_page_scroll_limit_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Sets or gets the vertical bounce behaviour.
        /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
        /// This is a visual way to indicate the end has been reached.
        /// This is enabled by default for both axis.
        /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
        /// </summary>
        public bool VerticalBounce
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_bounce_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                bool h = HorizontalBounce;
                Interop.Elementary.elm_scroller_bounce_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Sets or gets the horizontal bounce behaviour.
        /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
        /// This is a visual way to indicate the end has been reached.
        /// This is enabled by default for both axis.
        /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
        /// </summary>
        public bool HorizontalBounce
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_bounce_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                bool v = VerticalBounce;
                Interop.Elementary.elm_scroller_bounce_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Gets the width of the content object of the scroller.
        /// </summary>
        public int ChildWidth
        {
            get
            {
                int w, h;
                Interop.Elementary.elm_scroller_child_size_get(RealHandle, out w, out h);
                return w;
            }
        }

        /// <summary>
        /// Gets the height of the content object of the scroller.
        /// </summary>
        public int ChildHeight
        {
            get
            {
                int w, h;
                Interop.Elementary.elm_scroller_child_size_get(RealHandle, out w, out h);
                return h;
            }
        }

        /// <summary>
        /// Set scrolling gravity values for a scroller.
        /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
        /// The scroller will adjust the view to glue itself as follows.
        /// x=0.0, for staying where it is relative to the left edge of the content x=1.0, for staying where it is relative to the rigth edge of the content y=0.0, for staying where it is relative to the top edge of the content y=1.0, for staying where it is relative to the bottom edge of the content
        /// Default values for x and y are 0.0
        /// </summary>
        public double HorizontalGravity
        {
            get
            {
                double v, h;
                Interop.Elementary.elm_scroller_gravity_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                double v = VerticalGravity;
                Interop.Elementary.elm_scroller_gravity_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Set scrolling gravity values for a scroller.
        /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
        /// The scroller will adjust the view to glue itself as follows.
        /// x=0.0, for staying where it is relative to the left edge of the content x=1.0, for staying where it is relative to the rigth edge of the content y=0.0, for staying where it is relative to the top edge of the content y=1.0, for staying where it is relative to the bottom edge of the content
        /// Default values for x and y are 0.0
        /// </summary>
        public double VerticalGravity
        {
            get
            {
                double v, h;
                Interop.Elementary.elm_scroller_gravity_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                double h = HorizontalGravity;
                Interop.Elementary.elm_scroller_gravity_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Get scroll last page number.
        /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
        /// </summary>
        public int LastVerticalPageNumber
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_last_page_get(RealHandle, out h, out v);
                return v;
            }
        }

        /// <summary>
        /// Get scroll last page number.
        /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
        /// </summary>
        public int LastHorizontalPageNumber
        {
            get
            {
                int v, h;
                Interop.Elementary.elm_scroller_last_page_get(RealHandle, out h, out v);
                return h;
            }
        }

        /// <summary>
        /// Set an infinite loop_ for a scroller.
        /// This function sets the infinite loop vertically.
        /// If the content is set, it will be shown repeatedly.
        /// </summary>
        public bool VerticalLoop
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_loop_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                bool h = HorizontalLoop;
                Interop.Elementary.elm_scroller_loop_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Set an infinite loop_ for a scroller.
        /// This function sets the infinite loop horizontally.
        /// If the content is set, it will be shown repeatedly.
        /// </summary>
        public bool HorizontalLoop
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_loop_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                bool v = VerticalLoop;
                Interop.Elementary.elm_scroller_loop_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Get a given scroller widget's scrolling page size, relative to its viewport size.
        /// </summary>
        public double VerticalRelativePageSize
        {
            get
            {
                double v, h;
                Interop.Elementary.elm_scroller_page_relative_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                double h = HorizontalRelativePageSize;
                Interop.Elementary.elm_scroller_page_relative_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Get a given scroller widget's scrolling page size, relative to its viewport size.
        /// </summary>
        public double HorizontalRelativePageSize
        {
            get
            {
                double v, h;
                Interop.Elementary.elm_scroller_page_relative_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                double v = VerticalRelativePageSize;
                Interop.Elementary.elm_scroller_page_relative_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Gets or Sets the page snapping behavior of a scroller.
        /// </summary>
        public bool VerticalSnap
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_page_snap_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                bool h = HorizontalSnap;
                Interop.Elementary.elm_scroller_page_snap_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Gets or Sets the page snapping behavior of a scroller.
        /// </summary>
        public bool HorizontalSnap
        {
            get
            {
                bool v, h;
                Interop.Elementary.elm_scroller_page_snap_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                bool v = VerticalSnap;
                Interop.Elementary.elm_scroller_page_snap_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
        /// </summary>
        public int PageHeight
        {
            get
            {
                int w, h;
                Interop.Elementary.elm_scroller_page_size_get(RealHandle, out w, out h);
                return h;
            }
            set
            {
                int w = PageWidth;
                Interop.Elementary.elm_scroller_page_size_set(RealHandle, w, value);
            }
        }

        /// <summary>
        /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
        /// </summary>
        public int PageWidth
        {
            get
            {
                int w, h;
                Interop.Elementary.elm_scroller_page_size_get(RealHandle, out w, out h);
                return w;
            }
            set
            {
                int h = PageHeight;
                Interop.Elementary.elm_scroller_page_size_set(RealHandle, value, h);
            }
        }

        /// <summary>
        /// Gets or sets the event propagation for a scroller.
        /// This enables or disables event propagation from the scroller content to the scroller and its parent.
        /// By default event propagation is enabled.
        /// </summary>
        public bool PropagateEvents
        {
            get
            {
                return Interop.Elementary.elm_scroller_propagate_events_get(RealHandle);
            }
            set
            {
                Interop.Elementary.elm_scroller_propagate_events_set(RealHandle, value);
            }
        }

        /// <summary>
        /// Gets or sets the step size to move scroller by key event.
        /// </summary>
        public int HorizontalStepSize
        {
            get
            {
                int h, v;
                Interop.Elementary.elm_scroller_step_size_get(RealHandle, out h, out v);
                return h;
            }
            set
            {
                int v = VerticalStepSize;
                Interop.Elementary.elm_scroller_step_size_set(RealHandle, value, v);
            }
        }

        /// <summary>
        /// Gets or sets the step size to move scroller by key event.
        /// </summary>
        public int VerticalStepSize
        {
            get
            {
                int h, v;
                Interop.Elementary.elm_scroller_step_size_get(RealHandle, out h, out v);
                return v;
            }
            set
            {
                int h = HorizontalStepSize;
                Interop.Elementary.elm_scroller_step_size_set(RealHandle, h, value);
            }
        }

        /// <summary>
        /// Gets or sets a value whether mouse wheel is enabled or not over the scroller.
        /// </summary>
        public bool WheelDisabled
        {
            get
            {
                return Interop.Elementary.elm_scroller_wheel_disabled_get(RealHandle);
            }
            set
            {
                Interop.Elementary.elm_scroller_wheel_disabled_set(RealHandle, value);
            }
        }

        /// <summary>
        /// Gets or sets the type of single direction scroll.
        /// </summary>
        public ScrollSingleDirection SingleDirection
        {
            get
            {
                return (ScrollSingleDirection)Interop.Elementary.elm_scroller_single_direction_get(RealHandle);
            }
            set
            {
                Interop.Elementary.elm_scroller_single_direction_set(RealHandle, (int)value);
            }
        }

        /// <summary>
        /// Sets the scroller minimum size limited to the minimum size of the content.
        /// By default the scroller will be as small as its design allows, irrespective of its content.
        /// This will make the scroller minimum size the right size horizontally and/or vertically to perfectly fit its content in that direction.
        /// </summary>
        /// <param name="horizontal">Enable limiting minimum size horizontally</param>
        /// <param name="vertical">Enable limiting minimum size vertically</param>
        public void MinimumLimit(bool horizontal, bool vertical)
        {
            Interop.Elementary.elm_scroller_content_min_limit(RealHandle, horizontal, vertical);
        }

        /// <summary>
        /// Sets the page size to an absolute fixed value, with 0 turning it off for that axis.
        /// </summary>
        /// <param name="width">The horizontal page size.</param>
        /// <param name="height">The vertical page size.</param>
        public void SetPageSize(int width, int height)
        {
            Interop.Elementary.elm_scroller_page_size_set(RealHandle, width, height);
        }

        /// <summary>
        /// Sets the scroll page size relative to the viewport size.
        /// </summary>
        /// <remarks>
        /// The scroller is capable of limiting scrolling by the user to "pages".
        /// That is to jump by and only show a "whole page" at a time as if the continuous area of the scroller
        /// content is split into page sized pieces. This sets the size of a page relative to the viewport of the scroller.
        /// 1.0 is "1 viewport" which is the size (horizontally or vertically). 0.0 turns it off in that axis.
        /// This is mutually exclusive with the page size (see elm_scroller_page_size_set() for more information).
        /// Likewise 0.5 is "half a viewport". Usable values are normally between 0.0 and 1.0 including 1.0.
        /// If you only want 1 axis to be page "limited", use 0.0 for the other axis.
        /// </remarks>
        /// <param name="width">The horizontal page relative size.</param>
        /// <param name="height">The vertical page relative size.</param>
        public void SetPageSize(double width, double height)
        {
            Interop.Elementary.elm_scroller_page_relative_set(RealHandle, width, height);
        }

        /// <summary>
        /// Shows a specific virtual region within the scroller content object by the page number.
        /// (0, 0) of the indicated page is located at the top-left corner of the viewport.
        /// </summary>
        /// <param name="horizontalPageIndex">The horizontal page number.</param>
        /// <param name="verticalPageIndex">The vertical page number.</param>
        /// <param name="animated">True means slider with animation.</param>
        public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated)
        {
            if (animated)
            {
                Interop.Elementary.elm_scroller_page_bring_in(RealHandle, horizontalPageIndex, verticalPageIndex);
            }
            else
            {
                Interop.Elementary.elm_scroller_page_show(RealHandle, horizontalPageIndex, verticalPageIndex);
            }
        }

        /// <summary>
        /// Shows a specific virtual region within the scroller content object.
        /// </summary>
        /// <remarks>
        /// This ensures that all (or part, if it does not fit) of the designated region in the virtual content object ((0, 0)
        /// starting at the top-left of the virtual content object) is shown within the scroller.
        /// If set "animated" to true, it will allows the scroller to "smoothly slide" to this location
        /// (if configuration in general calls for transitions).
        /// It may not jump immediately to the new location and may take a while and show other content along the way.
        /// </remarks>
        /// <param name="region">Rect struct of region.</param>
        /// <param name="animated">True means allows the scroller to "smoothly slide" to this location.</param>
        public void ScrollTo(Rect region, bool animated)
        {
            if (animated)
            {
                Interop.Elementary.elm_scroller_region_bring_in(RealHandle, region.X, region.Y, region.Width, region.Height);
            }
            else
            {
                Interop.Elementary.elm_scroller_region_show(RealHandle, region.X, region.Y, region.Width, region.Height);
            }
        }

        protected override IntPtr CreateHandle(EvasObject parent)
        {
            IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
            Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");

            RealHandle = Interop.Elementary.elm_scroller_add(handle);
            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);

            return handle;
        }
    }
}