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.
18 using System.Collections.Generic;
23 /// It inherits System.EventArgs.
24 /// It contains Item which is <see cref="GenGridItem"/> type.
25 /// All events of GenGrid contain GenGridItemEventArgs as a parameter.
27 public class GenGridItemEventArgs : EventArgs
30 /// Gets or sets GenGrid item.The return type is <see cref="GenGridItem"/>.
32 public GenGridItem Item { get; set; }
34 internal static GenGridItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
36 GenGridItem item = ItemObject.GetItemByHandle(info) as GenGridItem;
37 return new GenGridItemEventArgs() { Item = item };
42 /// It inherits <see cref="Layout"/>.
43 /// The GenGrid is a widget that aims to position objects in a grid layout while actually creating and rendering only the visible ones.
44 /// It has two direction in which a given GenGrid widget expands while placing its items, horizontal and vertical.
45 /// The GenGrid items are represented through <see cref="GenItemClass"/> definition field details.
47 public class GenGrid : Layout, IScrollable
49 ScrollableAdapter _scroller;
50 HashSet<GenGridItem> _children = new HashSet<GenGridItem>();
52 SmartEvent<GenGridItemEventArgs> _selected;
53 SmartEvent<GenGridItemEventArgs> _unselected;
54 SmartEvent<GenGridItemEventArgs> _activated;
55 SmartEvent<GenGridItemEventArgs> _pressed;
56 SmartEvent<GenGridItemEventArgs> _released;
57 SmartEvent<GenGridItemEventArgs> _doubleClicked;
58 SmartEvent<GenGridItemEventArgs> _realized;
59 SmartEvent<GenGridItemEventArgs> _unrealized;
60 SmartEvent<GenGridItemEventArgs> _longpressed;
64 /// Creates and initializes a new instance of the GenGrid class.
66 /// <param name="parent">The parent is a given container which will be attached by GenGrid as a child. It's <see cref="EvasObject"/> type.</param>
67 public GenGrid(EvasObject parent) : base(parent)
69 InitializeSmartEvent();
70 _scroller = new ScrollableAdapter(this);
74 /// ItemSelected is raised when a new gengrid item is selected.
76 public event EventHandler<GenGridItemEventArgs> ItemSelected;
79 /// ItemUnselected is raised when the gengrid item is Unselected.
81 public event EventHandler<GenGridItemEventArgs> ItemUnselected;
84 /// ItemPressed is raised when a new gengrid item is pressed.
86 public event EventHandler<GenGridItemEventArgs> ItemPressed;
89 /// ItemReleased is raised when a new gengrid item is released.
91 public event EventHandler<GenGridItemEventArgs> ItemReleased;
94 /// ItemActivated is raised when a new gengrid item is double clicked or pressed (enter|return|spacebar).
96 public event EventHandler<GenGridItemEventArgs> ItemActivated;
99 /// ItemDoubleClicked is raised when a new gengrid item is double clicked.
101 public event EventHandler<GenGridItemEventArgs> ItemDoubleClicked;
104 /// ItemRealized is raised when a gengrid item is implementing through <see cref="GenItemClass"/>.
106 public event EventHandler<GenGridItemEventArgs> ItemRealized;
109 /// ItemUnrealized is raised when the gengrid item is deleted.
111 public event EventHandler<GenGridItemEventArgs> ItemUnrealized;
114 /// ItemLongPressed is raised when a gengrid item is pressed for a certain amount of time. By default it's 1 second.
116 public event EventHandler<GenGridItemEventArgs> ItemLongPressed;
119 /// Changed is raised when an item is added, removed, resized or moved and when the gengrid is resized or gets "horizontal" property changes.
121 public event EventHandler Changed;
124 /// Gets or sets the item's grid alignment along x-axis within a given gengrid widget.
125 /// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
126 /// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the left along x-axis.
128 public double ItemAlignmentX
133 Interop.Elementary.elm_gengrid_align_get(RealHandle, out align, IntPtr.Zero);
138 double aligny = ItemAlignmentY;
139 Interop.Elementary.elm_gengrid_align_set(RealHandle, value, aligny);
144 /// Gets or sets the item's grid alignment on y-axis within a given gengrid widget.
145 /// Accepted values are in the 0.0 to 1.0 range, with the special value -1.0 used to specify "justify" or "fill" by some users.
146 /// By default, value is 0.0, meaning that the gengrid has its items grid placed exactly in the top along y-axis.
148 public double ItemAlignmentY
153 Interop.Elementary.elm_gengrid_align_get(RealHandle, IntPtr.Zero, out align);
158 double alignx = ItemAlignmentX;
159 Interop.Elementary.elm_gengrid_align_set(RealHandle, alignx, value);
164 /// Gets or sets the manner in which the items grid is filled within a given gengrid widget.
165 /// It is filled if true, otherwise false.
167 public bool FillItems
171 return Interop.Elementary.elm_gengrid_filled_get(RealHandle);
175 Interop.Elementary.elm_gengrid_filled_set(RealHandle, value);
180 /// Gets or sets whether multi-selection is enabled or disabled for a given gengrid widget.
183 /// Multi-selection is the ability to have more than one item selected, on a given gengrid, simultaneously.
184 /// When it is enabled, a sequence of clicks on different items makes them all selected, progressively.
185 /// A click on an already selected item unselects it. If interacting via the keyboard, multi-selection is enabled while holding the "Shift" key.
186 /// By default, multi-selection is disabled.
188 public bool MultipleSelection
192 return Interop.Elementary.elm_gengrid_multi_select_get(RealHandle);
196 Interop.Elementary.elm_gengrid_multi_select_set(RealHandle, value);
201 /// Gets or sets the width for the items of a given gengrid widget.
204 /// A gengrid, after creation, still has no information on the size to give to each of its cells.
205 /// The default width and height just have one finger wide.
206 /// Use this property to force a custom width for your items, making them as big as you wish.
213 Interop.Elementary.elm_gengrid_item_size_get(RealHandle, out width, IntPtr.Zero);
218 int height = ItemHeight;
219 Interop.Elementary.elm_gengrid_item_size_set(RealHandle, value, height);
224 /// Gets or sets the height for the items of a given gengrid widget.
227 /// A gengrid, after creation, still has no information on the size to give to each of its cells.
228 /// The default width and height just have one finger wide.
229 /// Use this property to force a custom height for your items, making them as big as you wish.
231 public int ItemHeight
236 Interop.Elementary.elm_gengrid_item_size_get(RealHandle, IntPtr.Zero, out height);
241 int width = ItemWidth;
242 Interop.Elementary.elm_gengrid_item_size_set(RealHandle, width, value);
247 /// Gets or sets the gengrid select mode by <see cref="GenItemSelectionMode"/>.
249 public GenItemSelectionMode SelectionMode
253 return (GenItemSelectionMode)Interop.Elementary.elm_gengrid_select_mode_get(RealHandle);
257 Interop.Elementary.elm_gengrid_select_mode_set(RealHandle, (int)value);
262 /// Gets or sets the direction for which a given gengrid widget expands while placing its items.
265 /// If true, items are placed in columns from top to bottom and when the space for a column is filled, another one is started on the right, thus expanding the grid horizontally.
266 /// If false, items are placed in rows from left to right, and when the space for a row is filled, another one is started below, thus expanding the grid vertically.
268 public bool IsHorizontal
272 return Interop.Elementary.elm_gengrid_horizontal_get(RealHandle);
276 Interop.Elementary.elm_gengrid_horizontal_set(RealHandle, value);
281 /// Gets or sets whether the gengrid items should be highlighted when an item is selected.
283 public bool IsHighlight
287 return Interop.Elementary.elm_gengrid_highlight_mode_get(RealHandle);
291 Interop.Elementary.elm_gengrid_highlight_mode_set(RealHandle, value);
296 /// Gets the first item in a given gengrid widget.
298 public GenGridItem FirstItem
302 IntPtr handle = Interop.Elementary.elm_gengrid_first_item_get(RealHandle);
303 return ItemObject.GetItemByHandle(handle) as GenGridItem;
308 /// Gets the last item in a given gengrid widget.
310 public GenGridItem LastItem
314 IntPtr handle = Interop.Elementary.elm_gengrid_last_item_get(RealHandle);
315 return ItemObject.GetItemByHandle(handle) as GenGridItem;
320 /// Gets the items count in a given gengrid widget.
322 public uint ItemCount
326 return Interop.Elementary.elm_gengrid_items_count(RealHandle);
331 /// Gets the selected item in a given gengrid widget.
333 public GenGridItem SelectedItem
337 IntPtr handle = Interop.Elementary.elm_gengrid_selected_item_get(RealHandle);
338 return ItemObject.GetItemByHandle(handle) as GenGridItem;
343 /// Gets or sets whether a given gengrid widget is or not able have items reordered.
345 public bool ReorderMode
349 return Interop.Elementary.elm_gengrid_reorder_mode_get(RealHandle);
353 Interop.Elementary.elm_gengrid_reorder_mode_set(RealHandle, value);
358 /// Appends a new item to a given gengrid widget. This adds an item to the end of the gengrid.
360 /// <param name="itemClass">The itemClass defines how to display the data.</param>
361 /// <param name="data">The item data.</param>
362 /// <returns>Return a gengrid item that contains data and itemClass.</returns>
363 /// <seealso cref="GenItemClass"/>
364 /// <seealso cref="GenGridItem"/>
365 public GenGridItem Append(GenItemClass itemClass, object data)
367 GenGridItem item = new GenGridItem(data, itemClass);
368 IntPtr handle = Interop.Elementary.elm_gengrid_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
369 item.Handle = handle;
375 /// Prepends a new item to a given gengrid widget. This adds an item to the beginning of the gengrid.
377 /// <param name="itemClass">The itemClass defines how to display the data.</param>
378 /// <param name="data">The item data.</param>
379 /// <returns>Return a gengrid item that contains data and itemClass.</returns>
380 /// <seealso cref="GenItemClass"/>
381 /// <seealso cref="GenGridItem"/>
382 public GenGridItem Prepend(GenItemClass itemClass, object data)
384 GenGridItem item = new GenGridItem(data, itemClass);
385 IntPtr handle = Interop.Elementary.elm_gengrid_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, null, (IntPtr)item.Id);
386 item.Handle = handle;
392 /// Inserts an item before another in a gengrid widget. This inserts an item before another in the gengrid.
394 /// <param name="itemClass">The itemClass defines how to display the data.</param>
395 /// <param name="data">The item data.</param>
396 /// <param name="before">The item before which to place this new one.</param>
397 /// <returns>Return a gengrid item that contains data and itemClass./></returns>
398 /// <seealso cref="GenItemClass"/>
399 /// <seealso cref="GenGridItem"/>
400 public GenGridItem InsertBefore(GenItemClass itemClass, object data, GenGridItem before)
402 GenGridItem item = new GenGridItem(data, itemClass);
403 IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_before(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, before, null, (IntPtr)item.Id);
404 item.Handle = handle;
410 /// Inserts an item before another in a gengrid widget. This inserts an item after another in the gengrid.
412 /// <param name="itemClass">The itemClass defines how to display the data.</param>
413 /// <param name="data">The item data.</param>
414 /// <param name="after">The item after which to place this new one.</param>
415 /// <returns>Return a gengrid item that contains data and itemClass.</returns>
416 /// <seealso cref="GenItemClass"/>
417 /// <seealso cref="GenGridItem"/>
418 public GenGridItem InsertAfter(GenItemClass itemClass, object data, GenGridItem after)
420 GenGridItem item = new GenGridItem(data, itemClass);
421 IntPtr handle = Interop.Elementary.elm_gengrid_item_insert_after(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, after, null, (IntPtr)item.Id);
422 item.Handle = handle;
428 /// Insert an item in a gengrid widget using a user-defined sort function.
430 /// <param name="itemClass">The itemClass defines how to display the data.</param>
431 /// <param name="data">The item data.</param>
432 /// <param name="comparison">User defined comparison function that defines the sort order based on gengrid item and its data.</param>
433 /// <returns>Return a gengrid item that contains data and itemClass.</returns>
434 public GenGridItem InsertSorted(GenItemClass itemClass, object data, Comparison<object> comparison)
436 GenGridItem item = new GenGridItem(data, itemClass);
438 Interop.Elementary.Eina_Compare_Cb compareCallback = (handle1, handle2) =>
440 GenGridItem first = (ItemObject.GetItemByHandle(handle1) as GenGridItem) ?? item;
441 GenGridItem second = (ItemObject.GetItemByHandle(handle2) as GenGridItem) ?? item;
442 return comparison(first.Data, second.Data);
445 IntPtr handle = Interop.Elementary.elm_gengrid_item_sorted_insert(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, compareCallback, null, (IntPtr)item.Id);
446 item.Handle = handle;
452 /// Shows a given item to the visible area of a gengrid.
454 /// <param name="item">The gengrid item to display.</param>
455 /// <param name="position">The position of the item in the viewport.</param>
456 /// <param name="animated">The type of how to show the item.</param>
458 /// If animated is true, the gengrid shows item by scrolling if it's not fully visible.
459 /// If animated is false, the gengrid shows item by jumping if it's not fully visible.
461 /// <seealso cref="ScrollToPosition"/>
462 public void ScrollTo(GenGridItem item, ScrollToPosition position, bool animated)
466 Interop.Elementary.elm_gengrid_item_bring_in(item.Handle, (int)position);
470 Interop.Elementary.elm_gengrid_item_show(item.Handle, (int)position);
475 /// Updates the contents of all the realized items.
476 /// This updates all realized items by calling all the <see cref="GenItemClass"/> again to get the content, text, and states.
477 /// Use this when the original item data has changed and the changes are desired to reflect.
480 /// <see cref="GenItem.Update()"/> to update just one item.
482 public void UpdateRealizedItems()
484 Interop.Elementary.elm_gengrid_realized_items_update(RealHandle);
488 /// Removes all items from a given gengrid widget.
489 /// This removes(and deletes) all items in obj, making it empty.
492 /// <see cref="ItemObject.Delete()"/> to delete just one item.
496 Interop.Elementary.elm_gengrid_clear(RealHandle);
500 /// Get the item that is at the x, y canvas coords.
502 /// <param name="x">The input x coordinate</param>
503 /// <param name="y">The input y coordinate</param>
504 /// <param name="portionX">The position relative to the item returned here.
505 /// -1, 0 or 1, depending if the coordinate is on the left portion of that item(-1), on the middle section(0) or on the right part(1).
507 /// <param name="portionY">The position relative to the item returned here
508 /// -1, 0 or 1, depending if the coordinate is on the upper portion of that item (-1), on the middle section (0) or on the lower part (1).
510 /// <returns></returns>
511 public GenGridItem GetItemByPosition(int x, int y, out int portionX, out int portionY)
513 IntPtr handle = Interop.Elementary.elm_gengrid_at_xy_item_get(RealHandle, x, y, out portionX, out portionY);
514 return ItemObject.GetItemByHandle(handle) as GenGridItem;
518 /// Creates a widget handle.
520 /// <param name="parent">Parent EvasObject</param>
521 /// <returns>Handle IntPtr</returns>
522 protected override IntPtr CreateHandle(EvasObject parent)
524 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
525 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
527 RealHandle = Interop.Elementary.elm_gengrid_add(handle);
528 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
533 #region IScroller Implementation
536 /// Scrolled will be triggered when the content has been scrolled.
538 public event EventHandler Scrolled
540 add => _scroller.Scrolled += value;
541 remove => _scroller.Scrolled -= value;
545 /// DragStart will be triggered when dragging the contents around has started.
547 public event EventHandler DragStart
549 add => _scroller.DragStart += value;
550 remove => _scroller.DragStart -= value;
554 /// DragStop will be triggered when dragging the contents around has stopped.
556 public event EventHandler DragStop
558 add => _scroller.DragStop += value;
559 remove => _scroller.DragStop -= value;
563 /// PageScrolled will be triggered when the visible page has changed.
565 public event EventHandler PageScrolled
567 add => _scroller.PageScrolled += value;
568 remove => _scroller.PageScrolled -= value;
572 /// Gets the current region in the content object that is visible through the Scroller.
574 public Rect CurrentRegion => _scroller.CurrentRegion;
577 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
580 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
581 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
583 public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
585 get => _scroller.HorizontalScrollBarVisiblePolicy;
586 set => _scroller.HorizontalScrollBarVisiblePolicy = value;
590 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
593 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
594 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
596 public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
598 get => _scroller.VerticalScrollBarVisiblePolicy;
599 set => _scroller.VerticalScrollBarVisiblePolicy = value;
603 /// Sets or gets the value of ScrollBlock.
606 /// This function will block scrolling movement in a given direction.One can disable movements in the X axis, the Y axis or both.
607 /// The default value is ScrollBlock.None, where movements are allowed in both directions.
609 public ScrollBlock ScrollBlock
611 get => _scroller.ScrollBlock;
612 set => _scroller.ScrollBlock = value;
616 /// Sets or gets scroll current page number.
619 /// Current page means the page which meets the top of the viewport.
620 /// If there are two or more pages in the viewport, it returns the number of the page which meets the top of the viewport.
621 /// The page number starts from 0. 0 is the first page.
623 public int VerticalPageIndex => _scroller.VerticalPageIndex;
626 /// Sets or gets scroll current page number.
629 /// Current page means the page which meets the left of the viewport.
630 /// If there are two or more pages in the viewport, it returns the number of the page which meets the left of the viewport.
631 /// The page number starts from 0. 0 is the first page.
633 public int HorizontalPageIndex => _scroller.HorizontalPageIndex;
636 /// Sets or gets the maximum limit of the movable page at vertical direction.
638 public int VerticalPageScrollLimit
640 get => _scroller.VerticalPageScrollLimit;
641 set => _scroller.VerticalPageScrollLimit = value;
645 /// Sets or gets the maximum limit of the movable page at horizontal direction.
647 public int HorizontalPageScrollLimit
649 get => _scroller.HorizontalPageScrollLimit;
650 set => _scroller.HorizontalPageScrollLimit = value;
654 /// Sets or gets the vertical bounce behaviour.
655 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
656 /// This is a visual way to indicate the end has been reached.
657 /// This is enabled by default for both axis.
658 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
660 public bool VerticalBounce
662 get => _scroller.VerticalBounce;
663 set => _scroller.VerticalBounce = value;
667 /// Sets or gets the horizontal bounce behaviour.
668 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
669 /// This is a visual way to indicate the end has been reached.
670 /// This is enabled by default for both axis.
671 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
673 public bool HorizontalBounce
675 get => _scroller.HorizontalBounce;
676 set => _scroller.HorizontalBounce = value;
680 /// Gets the width of the content object of the scroller.
682 public int ChildWidth
684 get => _scroller.ChildWidth;
688 /// Gets the height of the content object of the scroller.
690 public int ChildHeight
692 get => _scroller.ChildHeight;
696 /// Set scrolling gravity values for a scroller.
697 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
698 /// The scroller will adjust the view to glue itself as follows.
699 /// 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
700 /// Default values for x and y are 0.0
702 public double HorizontalGravity
704 get => _scroller.HorizontalGravity;
705 set => _scroller.HorizontalGravity = value;
709 /// Set scrolling gravity values for a scroller.
710 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
711 /// The scroller will adjust the view to glue itself as follows.
712 /// 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
713 /// Default values for x and y are 0.0
715 public double VerticalGravity
717 get => _scroller.VerticalGravity;
718 set => _scroller.VerticalGravity = value;
722 /// Get scroll last page number.
723 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
725 public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber;
728 /// Get scroll last page number.
729 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
731 public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber;
734 /// Set an infinite loop_ for a scroller.
735 /// This function sets the infinite loop vertically.
736 /// If the content is set, it will be shown repeatedly.
738 public bool VerticalLoop
740 get => _scroller.VerticalLoop;
741 set => _scroller.VerticalLoop = value;
745 /// Set an infinite loop_ for a scroller.
746 /// This function sets the infinite loop horizontally.
747 /// If the content is set, it will be shown repeatedly.
749 public bool HorizontalLoop
751 get => _scroller.HorizontalLoop;
752 set => _scroller.HorizontalLoop = value;
756 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
758 public int HorizontalPageSize
760 get => _scroller.HorizontalPageSize;
761 set => _scroller.HorizontalPageSize = value;
765 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
767 public int VerticalPageSize
769 get => _scroller.VerticalPageSize;
770 set => _scroller.VerticalPageSize = value;
774 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
776 public double VerticalRelativePageSize
778 get => _scroller.VerticalRelativePageSize;
779 set => _scroller.VerticalRelativePageSize = value;
783 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
785 public double HorizontalRelativePageSize
787 get => _scroller.HorizontalRelativePageSize;
788 set => _scroller.HorizontalRelativePageSize = value;
792 /// Gets or Sets the page snapping behavior of a scroller.
795 /// When scrolling, if a scroller is paged (see VerticalRelativePageSize),
796 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
797 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
798 /// This function will set if it that is enabled or not, for each axis.
800 public bool VerticalSnap
802 get => _scroller.VerticalSnap;
803 set => _scroller.VerticalSnap = value;
807 /// Gets or Sets the page snapping behavior of a scroller.
810 /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize),
811 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
812 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
813 /// This function will set if it that is enabled or not, for each axis.
815 public bool HorizontalSnap
817 get => _scroller.HorizontalSnap;
818 set => _scroller.HorizontalSnap = value;
822 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
824 public int PageHeight
826 get => _scroller.PageHeight;
827 set => _scroller.PageHeight = value;
831 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
835 get => _scroller.PageWidth;
836 set => _scroller.PageWidth = value;
840 /// Gets or sets the step size to move scroller by key event.
842 public int HorizontalStepSize
844 get => _scroller.HorizontalStepSize;
845 set => _scroller.HorizontalStepSize = value;
849 /// Gets or sets the step size to move scroller by key event.
851 public int VerticalStepSize
853 get => _scroller.VerticalStepSize;
854 set => _scroller.VerticalStepSize = value;
858 /// Gets or sets a value whether mouse wheel is enabled or not over the scroller.
860 public bool WheelDisabled
862 get => _scroller.WheelDisabled;
863 set => _scroller.WheelDisabled = value;
867 /// Gets or sets the type of single direction scroll.
869 public ScrollSingleDirection SingleDirection
871 get => _scroller.SingleDirection;
872 set => _scroller.SingleDirection = value;
876 /// Sets the scroller minimum size limited to the minimum size of the content.
877 /// By default the scroller will be as small as its design allows, irrespective of its content.
878 /// This will make the scroller minimum size the right size horizontally and/or vertically to perfectly fit its content in that direction.
880 /// <param name="horizontal">Enable limiting minimum size horizontally</param>
881 /// <param name="vertical">Enable limiting minimum size vertically</param>
882 public void MinimumLimit(bool horizontal, bool vertical)
884 _scroller.MinimumLimit(horizontal, vertical);
888 /// Shows a specific virtual region within the scroller content object by the page number.
889 /// (0, 0) of the indicated page is located at the top-left corner of the viewport.
891 /// <param name="horizontalPageIndex">The horizontal page number.</param>
892 /// <param name="verticalPageIndex">The vertical page number.</param>
893 /// <param name="animated">True means slider with animation.</param>
894 public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated)
896 _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated);
900 /// Shows a specific virtual region within the scroller content object.
903 /// This ensures that all (or part, if it does not fit) of the designated region in the virtual content object ((0, 0)
904 /// starting at the top-left of the virtual content object) is shown within the scroller.
905 /// If set "animated" to true, it will allows the scroller to "smoothly slide" to this location
906 /// (if configuration in general calls for transitions).
907 /// It may not jump immediately to the new location and may take a while and show other content along the way.
909 /// <param name="region">Rect struct of region.</param>
910 /// <param name="animated">True means allows the scroller to "smoothly slide" to this location.</param>
911 public void ScrollTo(Rect region, bool animated)
913 _scroller.ScrollTo(region, animated);
918 void InitializeSmartEvent()
920 _selected = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "selected", GenGridItemEventArgs.CreateFromSmartEvent);
921 _unselected = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "unselected", GenGridItemEventArgs.CreateFromSmartEvent);
922 _activated = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "activated", GenGridItemEventArgs.CreateFromSmartEvent);
923 _pressed = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "pressed", GenGridItemEventArgs.CreateFromSmartEvent);
924 _released = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "released", GenGridItemEventArgs.CreateFromSmartEvent);
925 _doubleClicked = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "clicked,double", GenGridItemEventArgs.CreateFromSmartEvent);
926 _realized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "realized", GenGridItemEventArgs.CreateFromSmartEvent);
927 _unrealized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "unrealized", GenGridItemEventArgs.CreateFromSmartEvent);
928 _longpressed = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "longpressed", GenGridItemEventArgs.CreateFromSmartEvent);
929 _changed = new SmartEvent(this, this.RealHandle, "changed");
931 _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
932 _unselected.On += (s, e) => { if (e.Item != null) ItemUnselected?.Invoke(this, e); };
933 _activated.On += (s, e) => { if (e.Item != null) ItemActivated?.Invoke(this, e); };
934 _pressed.On += (s, e) => { if (e.Item != null) ItemPressed?.Invoke(this, e); };
935 _released.On += (s, e) => { if (e.Item != null) ItemReleased?.Invoke(this, e); };
936 _doubleClicked.On += (s, e) => { if (e.Item != null) ItemDoubleClicked?.Invoke(this, e); };
937 _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
938 _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
939 _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
940 _changed.On += (s, e) => { Changed?.Invoke(this, e); };
943 void AddInternal(GenGridItem item)
946 item.Deleted += Item_Deleted;
949 void Item_Deleted(object sender, EventArgs e)
951 _children.Remove((GenGridItem)sender);