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 /// Enumeration for setting genlist item type.
25 public enum GenListItemType
28 /// if Normal is set then this item is normal item.
33 /// If tree is set then this item is displayed as an item that is able to expand and have child items.
38 /// if Group is set then this item is group index item that is displayed at the top until the next group comes.
44 /// Enumeration for setting genlist's resizing behavior, transverse axis scrolling and items cropping.
46 public enum GenListMode
49 /// The genlist won't set any of its size hints to inform how a possible container should resize it.
50 /// Then, if it's not created as a "resize object", it might end with zeroed dimensions.
51 /// The genlist will respect the container's geometry and, if any of its items won't fit into its transverse axis, one won't be able to scroll it in that direction.
56 /// This is the same as Compress, with the exception that if any of its items won't fit into its transverse axis, one will be able to scroll it in that direction.
61 /// Sets a minimum size hint on the genlist object, so that containers may respect it (and resize itself to fit the child properly).
62 /// More specifically, a minimum size hint will be set for its transverse axis, so that the largest item in that direction fits well.
63 /// This is naturally bound by the genlist object's maximum size hints, set externally.
68 /// Besides setting a minimum size on the transverse axis, just like on Limit, the genlist will set a minimum size on th longitudinal axis, trying to reserve space to all its children to be visible at a time.
69 /// This is naturally bound by the genlist object's maximum size hints, set externally.
75 /// It inherits System.EventArgs.
76 /// It contains Item which is <see cref="GenListItem"/> type.
77 /// All events of GenList contain GenListItemEventArgs as a parameter.
79 public class GenListItemEventArgs : EventArgs
82 /// Gets or sets GenList item. The return type is <see cref="GenListItem"/>.
84 public GenListItem Item { get; set; }
86 internal static GenListItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
88 GenListItem item = ItemObject.GetItemByHandle(info) as GenListItem;
89 return new GenListItemEventArgs() { Item = item };
94 /// Enumeration that defines where to position the item in the genlist.
96 public enum ScrollToPosition
99 /// Scrolls to nowhere.
104 /// Scrolls to the nearest viewport.
109 /// Scrolls to the top of the viewport.
114 /// Scrolls to the middle of the viewport.
119 /// Scrolls to the bottom of the viewport.
125 /// It inherits <see cref="Layout"/>.
126 /// The GenList is a widget that aims to have more expansive list than the simple <see cref="List"/> in ElmSharp that could have more flexible items and allow many more entries while still being fast and low on memory usage.
127 /// At the same time it was also made to be able to do tree structures.
128 /// But the price to pay is more complexity when it comes to usage.
129 /// If all you want is a simple list with icons and a single text, use the <see cref="List"/> widget.
131 public class GenList : Layout, IScrollable
133 ScrollableAdapter _scroller;
134 HashSet<GenListItem> _children = new HashSet<GenListItem>();
136 SmartEvent<GenListItemEventArgs> _selected;
137 SmartEvent<GenListItemEventArgs> _unselected;
138 SmartEvent<GenListItemEventArgs> _activated;
139 SmartEvent<GenListItemEventArgs> _pressed;
140 SmartEvent<GenListItemEventArgs> _released;
141 SmartEvent<GenListItemEventArgs> _doubleClicked;
142 SmartEvent<GenListItemEventArgs> _expanded;
143 SmartEvent<GenListItemEventArgs> _realized;
144 SmartEvent<GenListItemEventArgs> _unrealized;
145 SmartEvent<GenListItemEventArgs> _longpressed;
146 SmartEvent<GenListItemEventArgs> _moved;
147 SmartEvent<GenListItemEventArgs> _movedAfter;
148 SmartEvent<GenListItemEventArgs> _movedBefore;
149 SmartEvent _scrollAnimationStarted;
150 SmartEvent _scrollAnimationStopped;
154 /// Creates and initializes a new instance of the GenList class.
156 /// <param name="parent">The parent is a given container which will be attached by GenList as a child. It's <see cref="EvasObject"/> type.</param>
157 public GenList(EvasObject parent) : base(parent)
162 /// Creates and initializes a new instance of GenList class.
164 protected GenList() : base()
169 /// Gets or sets whether the homogeneous mode is enabled.
172 /// If true, the genlist items have same height and width.
174 public bool Homogeneous
178 return Interop.Elementary.elm_genlist_homogeneous_get(RealHandle);
182 Interop.Elementary.elm_genlist_homogeneous_set(RealHandle, value);
187 /// Gets or sets the horizontal stretching mode. This mode used for sizing items horizontally.
188 /// The default value is <see cref="GenListMode.Scroll"/> which means that if items are too wide to fit, the scroller scrolls horizontally.
189 /// If set <see cref="GenListMode.Compress"/> which means that the item width is fixed (restricted to a minimum of) to the list width when calculating its size in order to allow the height to be calculated based on it.
190 /// If set <see cref="GenListMode.Limit"/> which means that items are expanded to the viewport width and limited to that size.
191 /// if set <see cref="GenListMode.Expand"/> which means that genlist try to reserve space to all its items to be visible at a time.
194 /// Compress makes genlist resize slower as it recalculates every item height again whenever the list width changes.
195 /// The homogeneous mode is so that all items in the genlist are of the same width/height. With Compress, genlist items are initialized fast.
196 /// However, there are no sub-objects in the genlist which can be on the flying resizable (such as TEXTBLOCK).
197 /// If so, then some dynamic resizable objects in the genlist would not be diplayed properly.
199 public GenListMode ListMode
203 return (GenListMode)Interop.Elementary.elm_genlist_mode_get(RealHandle);
207 Interop.Elementary.elm_genlist_mode_set(RealHandle, (int)value);
212 /// Gets the first item in the genlist.
214 public GenListItem FirstItem
218 IntPtr handle = Interop.Elementary.elm_genlist_first_item_get(RealHandle);
219 return ItemObject.GetItemByHandle(handle) as GenListItem;
224 /// Gets the last item in the genlist.
226 public GenListItem LastItem
230 IntPtr handle = Interop.Elementary.elm_genlist_last_item_get(RealHandle);
231 return ItemObject.GetItemByHandle(handle) as GenListItem;
236 /// Gets or sets the reorder mode.
237 /// After turning on the reorder mode, longpress on a normal item triggers reordering of the item.
238 /// You can move the item up and down. However, reordering does not work with group items.
240 public bool ReorderMode
244 return Interop.Elementary.elm_genlist_reorder_mode_get(RealHandle);
248 Interop.Elementary.elm_genlist_reorder_mode_set(RealHandle, value);
253 /// Gets or set the maximum number of items within an item block.
255 public int BlockCount
259 return Interop.Elementary.elm_genlist_block_count_get(RealHandle);
263 Interop.Elementary.elm_genlist_block_count_set(RealHandle, value);
268 /// Gets or sets whether the genlist items should be highlighted when an item is selected.
270 public bool IsHighlight
274 return Interop.Elementary.elm_genlist_highlight_mode_get(RealHandle);
278 Interop.Elementary.elm_genlist_highlight_mode_set(RealHandle, value);
283 /// Gets or sets the timeout in seconds for the longpress event.
285 public double LongPressTimeout
289 return Interop.Elementary.elm_genlist_longpress_timeout_get(RealHandle);
293 Interop.Elementary.elm_genlist_longpress_timeout_set(RealHandle, value);
298 /// Gets or Sets focus upon items selection mode.
301 /// When enabled, every selection of an item inside the <see cref="GenList"/> will automatically set focus to its first focusable widget from the left.
302 /// This is true of course if the selection was made by clicking an unfocusable area in an item or selecting it with a key movement.
303 /// Clicking on a focusable widget inside an item will couse this particular item to get focus as usual.
305 public bool FocusOnSelection
309 return Interop.Elementary.elm_genlist_focus_on_selection_get(RealHandle);
313 Interop.Elementary.elm_genlist_focus_on_selection_set(RealHandle, value);
318 /// Gets or sets whether enable multi-selection in the genlist.
320 public bool IsMultiSelection
324 return Interop.Elementary.elm_genlist_multi_select_get(RealHandle);
328 Interop.Elementary.elm_genlist_multi_select_set(RealHandle, value);
333 /// Gets the selected item in a given genlist widget.
335 public GenListItem SelectedItem
339 IntPtr handle = Interop.Elementary.elm_genlist_selected_item_get(RealHandle);
340 return ItemObject.GetItemByHandle(handle) as GenListItem;
345 /// Gets or sets the genlist select mode by <see cref="GenItemSelectionMode"/>.
347 public GenItemSelectionMode SelectionMode
351 return (GenItemSelectionMode)Interop.Elementary.elm_genlist_select_mode_get(RealHandle);
355 Interop.Elementary.elm_genlist_select_mode_set(RealHandle, (int)value);
360 /// Gets count of items in a this genlist widget
366 return Interop.Elementary.elm_genlist_items_count(RealHandle);
371 /// ItemSelected is raised when a new genlist item is selected.
373 public event EventHandler<GenListItemEventArgs> ItemSelected;
376 /// ItemUnselected is raised when the genlist item is Unselected.
378 public event EventHandler<GenListItemEventArgs> ItemUnselected;
381 /// ItemPressed is raised when a new genlist item is pressed.
383 public event EventHandler<GenListItemEventArgs> ItemPressed;
386 /// ItemReleased is raised when a new genlist item is released.
388 public event EventHandler<GenListItemEventArgs> ItemReleased;
391 /// ItemActivated is raised when a new genlist item is double clicked or pressed (enter|return|spacebar).
393 public event EventHandler<GenListItemEventArgs> ItemActivated;
396 /// ItemDoubleClicked is raised when a new genlist item is double clicked.
398 public event EventHandler<GenListItemEventArgs> ItemDoubleClicked;
401 /// ItemExpanded is raised when a new genlist item is indicated to expand.
403 public event EventHandler<GenListItemEventArgs> ItemExpanded;
406 /// ItemRealized is raised when a new genlist item is created as a real object.
408 public event EventHandler<GenListItemEventArgs> ItemRealized;
411 /// ItemUnrealized is raised when a new genlist item is unrealized.
412 /// After calling unrealize, the item's content objects are deleted and the item object itself is deleted or is put into a floating cache.
414 public event EventHandler<GenListItemEventArgs> ItemUnrealized;
417 /// ItemLongPressed is raised when a genlist item is pressed for a certain amount of time. By default it's 1 second.
419 public event EventHandler<GenListItemEventArgs> ItemLongPressed;
422 /// ItemMoved is raised when a genlist item is moved in the reorder mode.
424 public event EventHandler<GenListItemEventArgs> ItemMoved;
427 /// ItemMovedAfter is raised when a genlist item is moved after another item in the reorder mode.
428 /// To get the relative previous item, use <see cref="GenListItem.Previous"/>.
430 public event EventHandler<GenListItemEventArgs> ItemMovedAfter;
433 /// ItemMovedBefore is raised when a genlist item is moved before another item in the reorder mode.
434 /// To get the relative next item, use <see cref="GenListItem.Next"/>.
436 public event EventHandler<GenListItemEventArgs> ItemMovedBefore;
439 /// Changed is raised when genlist is changed.
441 public event EventHandler Changed
443 add { _changed.On += value; }
444 remove { _changed.On -= value; }
448 /// ScrollAnimationStarted is raised when scrolling animation has started.
450 public event EventHandler ScrollAnimationStarted
452 add { _scrollAnimationStarted.On += value; }
453 remove { _scrollAnimationStarted.On -= value; }
457 /// ScrollAnimationStopped is raised when scrolling animation has stopped.
459 public event EventHandler ScrollAnimationStopped
461 add { _scrollAnimationStopped.On += value; }
462 remove { _scrollAnimationStopped.On -= value; }
466 /// Appends a new item to the end of a given genlist widget.
468 /// <param name="itemClass">The itemClass defines how to display the data.</param>
469 /// <param name="data">The item data.</param>
470 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
471 /// <seealso cref="GenItemClass"/>
472 /// <seealso cref="GenListItem"/>
473 public GenListItem Append(GenItemClass itemClass, object data)
475 return Append(itemClass, data, GenListItemType.Normal);
479 /// Appends a new item with <see cref="GenListItemType"/> to the end of a given genlist widget.
481 /// <param name="itemClass">The itemClass defines how to display the data.</param>
482 /// <param name="data">The item data.</param>
483 /// <param name="type">The genlist item type.</param>
484 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
485 public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type)
487 return Append(itemClass, data, type, null);
491 /// Appends a new item with <see cref="GenListItemType"/> to the end of a given genlist widget or the end of the children list if the parent is given.
493 /// <param name="itemClass">The itemClass defines how to display the data.</param>
494 /// <param name="data">The item data.</param>
495 /// <param name="type">The genlist item type.</param>
496 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
497 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
498 public GenListItem Append(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
500 GenListItem item = new GenListItem(data, itemClass);
501 IntPtr handle = Interop.Elementary.elm_genlist_item_append(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
502 item.Handle = handle;
508 /// Prepends a new item to the beginning of a given genlist widget.
510 /// <param name="itemClass">The itemClass defines how to display the data.</param>
511 /// <param name="data">The item data.</param>
512 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
513 public GenListItem Prepend(GenItemClass itemClass, object data)
515 return Prepend(itemClass, data, GenListItemType.Normal);
519 /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given genlist widget.
521 /// <param name="itemClass">The itemClass defines how to display the data.</param>
522 /// <param name="data">The item data.</param>
523 /// <param name="type">The genlist item type.</param>
524 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
525 public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type)
527 return Prepend(itemClass, data, type, null);
531 /// Prepends a new item with <see cref="GenListItemType"/> to the beginning of a given genlist widget or the beginning of the children list if the parent is given.
533 /// <param name="itemClass">The itemClass defines how to display the data.</param>
534 /// <param name="data">The item data.</param>
535 /// <param name="type">The genlist item type.</param>
536 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
537 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
538 public GenListItem Prepend(GenItemClass itemClass, object data, GenListItemType type, GenListItem parent)
540 GenListItem item = new GenListItem(data, itemClass);
541 IntPtr handle = Interop.Elementary.elm_genlist_item_prepend(RealHandle, itemClass.UnmanagedPtr, (IntPtr)item.Id, parent, (int)type, null, (IntPtr)item.Id);
542 item.Handle = handle;
548 /// Inserts an item before another item in a genlist widget.
549 /// It is the same tree level or group as the item before which it is inserted.????
551 /// <param name="itemClass">The itemClass defines how to display the data.</param>
552 /// <param name="data">The item data.</param>
553 /// <param name="before">The item before which to place this new one.</param>
554 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
555 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before)
557 return InsertBefore(itemClass, data, before, GenListItemType.Normal);
561 /// Inserts an item with <see cref="GenListItemType"/> before another item in a genlist widget.
562 /// It is the same tree level or group as the item before which it is inserted.????
564 /// <param name="itemClass">The itemClass defines how to display the data.</param>
565 /// <param name="data">The item data.</param>
566 /// <param name="before">The item before which to place this new one.</param>
567 /// <param name="type">The genlist item type.</param>
568 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
569 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type)
571 return InsertBefore(itemClass, data, before, type, null);
575 /// Inserts an item with <see cref="GenListItemType"/> before another item under a parent in a genlist widget.
577 /// <param name="itemClass">The itemClass defines how to display the data.</param>
578 /// <param name="data">The item data.</param>
579 /// <param name="before">The item before which to place this new one.</param>
580 /// <param name="type">The genlist item type.</param>
581 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
582 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
583 public GenListItem InsertBefore(GenItemClass itemClass, object data, GenListItem before, GenListItemType type, GenListItem parent)
585 GenListItem item = new GenListItem(data, itemClass);
586 // insert before the `before` list item
587 IntPtr handle = Interop.Elementary.elm_genlist_item_insert_before(
588 RealHandle, // genlist handle
589 itemClass.UnmanagedPtr, // item class
590 (IntPtr)item.Id, // data
593 (int)type, // item type
594 null, // select callback
595 (IntPtr)item.Id); // callback data
596 item.Handle = handle;
602 /// Inserts an item with <see cref="GenListItemType"/> after another item under a parent in a genlist widget.
604 /// <param name="itemClass">The itemClass defines how to display the data.</param>
605 /// <param name="data">The item data.</param>
606 /// <param name="after">The item after which to place this new one.</param>
607 /// <param name="type">The genlist item type.</param>
608 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
609 /// <returns>Return a new added genlist item that contains data and itemClass.</returns>
610 public GenListItem InsertAfter(GenItemClass itemClass, object data, GenListItem after, GenListItemType type, GenListItem parent)
612 GenListItem item = new GenListItem(data, itemClass);
613 // insert before the `before` list item
614 IntPtr handle = Interop.Elementary.elm_genlist_item_insert_before(
615 RealHandle, // genlist handle
616 itemClass.UnmanagedPtr, // item class
617 (IntPtr)item.Id, // data
620 (int)type, // item type
621 null, // select callback
622 (IntPtr)item.Id); // callback data
623 item.Handle = handle;
629 /// Insert an item in a genlist widget using a user-defined sort function.
631 /// <param name="itemClass">The itemClass defines how to display the data.</param>
632 /// <param name="data">The item data.</param>
633 /// <param name="comparison">User defined comparison function that defines the sort order based on genlist item and its data.</param>
634 /// <param name="type">The genlist item type.</param>
635 /// <param name="parent">The parent item, otherwise null if there is no parent item.</param>
636 /// <returns>Return a genlist item that contains data and itemClass.</returns>
637 public GenListItem InsertSorted(GenItemClass itemClass, object data, Comparison<object> comparison, GenListItemType type, GenListItem parent)
639 GenListItem item = new GenListItem(data, itemClass);
641 Interop.Elementary.Eina_Compare_Cb compareCallback = (handle1, handle2) =>
643 GenListItem first = (ItemObject.GetItemByHandle(handle1) as GenListItem) ?? item;
644 GenListItem second = (ItemObject.GetItemByHandle(handle2) as GenListItem) ?? item;
645 return comparison(first.Data, second.Data);
648 IntPtr handle = Interop.Elementary.elm_genlist_item_sorted_insert(
649 RealHandle, // genlist handle
650 itemClass.UnmanagedPtr, // item clas
651 (IntPtr)item.Id, // data
653 (int)type, // item type
654 compareCallback, // compare callback
655 null, //select callback
656 (IntPtr)item.Id); // callback data
657 item.Handle = handle;
663 /// Shows the given item with position type in a genlist.
664 /// When animated is true, genlist will jump to the given item and display it (by animatedly scrolling), if it is not fully visible. This may use animation and may take some time.
665 /// When animated is false, genlist will jump to the given item and display it (by jumping to that position), if it is not fully visible.
667 /// <param name="item">The item to display.</param>
668 /// <param name="position">The position to show the given item to <see cref="ScrollToPosition"/>.</param>
669 /// <param name="animated">The animated indicates how to display the item, by scrolling or by jumping.</param>
670 public void ScrollTo(GenListItem item, ScrollToPosition position, bool animated)
674 Interop.Elementary.elm_genlist_item_bring_in(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
678 Interop.Elementary.elm_genlist_item_show(item.Handle, (Interop.Elementary.Elm_Genlist_Item_Scrollto_Type)position);
683 /// Updates the content of all the realized items.
684 /// This updates all the realized items by calling all the <see cref="GenItemClass"/> again to get the content, text and states.
685 /// Use this when the original item data has changed and the changes are desired to reflect.
686 /// To update just one item, use <see cref="GenListItem.Update"/>.
688 /// <seealso cref="GenListItem.Update"/>
689 public void UpdateRealizedItems()
691 Interop.Elementary.elm_genlist_realized_items_update(RealHandle);
695 /// Removes all items from a given genlist widget.
696 /// This removes (and deletes) all items in obj, making it empty.
697 /// To delete just one item, use <see cref="ItemObject.Delete"/>.
699 /// <seealso cref="ItemObject.Delete"/>
702 Interop.Elementary.elm_genlist_clear(RealHandle);
706 /// Get the item that is at the x, y canvas coords.
708 /// <param name="x">The input x coordinate</param>
709 /// <param name="y">The input y coordinate</param>
710 /// <param name="pos">The position relative to the item returned here
711 /// -1, 0, or 1, depending on whether the coordinate is on the upper portion of that item (-1), in the middle section (0), or on the lower part (1).
713 /// <returns></returns>
714 public GenListItem GetItemByPosition(int x, int y, out int pos)
716 IntPtr handle = Interop.Elementary.elm_genlist_at_xy_item_get(RealHandle, x, y, out pos);
717 return ItemObject.GetItemByHandle(handle) as GenListItem;
721 /// Gets the nth item in a given genlist widget, placed at position nth, in its internal items list.
723 /// <param name="index">The number of the item to grab (0 being the first)</param>
724 /// <returns></returns>
725 public GenListItem GetItemByIndex(int index)
727 IntPtr handle = Interop.Elementary.elm_genlist_nth_item_get(RealHandle, index);
728 return ItemObject.GetItemByHandle(handle) as GenListItem;
732 /// The callback of Unrealize Event
734 protected override void OnRealized()
737 ListMode = GenListMode.Compress;
738 InitializeSmartEvent();
742 /// Creates a widget handle.
744 /// <param name="parent">Parent EvasObject</param>
745 /// <returns>Handle IntPtr</returns>
746 protected override IntPtr CreateHandle(EvasObject parent)
748 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
749 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
751 RealHandle = Interop.Elementary.elm_genlist_add(handle);
752 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
754 _scroller = new ScrollableAdapter(this);
759 #region IScroller Implementation
762 /// Scrolled will be triggered when the content has been scrolled.
764 public event EventHandler Scrolled
766 add => _scroller.Scrolled += value;
767 remove => _scroller.Scrolled -= value;
771 /// DragStart will be triggered when dragging the contents around has started.
773 public event EventHandler DragStart
775 add => _scroller.DragStart += value;
776 remove => _scroller.DragStart -= value;
780 /// DragStop will be triggered when dragging the contents around has stopped.
782 public event EventHandler DragStop
784 add => _scroller.DragStop += value;
785 remove => _scroller.DragStop -= value;
789 /// PageScrolled will be triggered when the visible page has changed.
791 public event EventHandler PageScrolled
793 add => _scroller.PageScrolled += value;
794 remove => _scroller.PageScrolled -= value;
798 /// Gets the current region in the content object that is visible through the Scroller.
800 public Rect CurrentRegion => _scroller.CurrentRegion;
803 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
806 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
807 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
809 public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
811 get => _scroller.HorizontalScrollBarVisiblePolicy;
812 set => _scroller.HorizontalScrollBarVisiblePolicy = value;
816 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
819 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
820 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
822 public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
824 get => _scroller.VerticalScrollBarVisiblePolicy;
825 set => _scroller.VerticalScrollBarVisiblePolicy = value;
829 /// Sets or gets the value of ScrollBlock.
832 /// This function will block scrolling movement in a given direction.One can disable movements in the X axis, the Y axis or both.
833 /// The default value is ScrollBlock.None, where movements are allowed in both directions.
835 public ScrollBlock ScrollBlock
837 get => _scroller.ScrollBlock;
838 set => _scroller.ScrollBlock = value;
842 /// Sets or gets scroll current page number.
845 /// Current page means the page which meets the top of the viewport.
846 /// If there are two or more pages in the viewport, it returns the number of the page which meets the top of the viewport.
847 /// The page number starts from 0. 0 is the first page.
849 public int VerticalPageIndex => _scroller.VerticalPageIndex;
852 /// Sets or gets scroll current page number.
855 /// Current page means the page which meets the left of the viewport.
856 /// If there are two or more pages in the viewport, it returns the number of the page which meets the left of the viewport.
857 /// The page number starts from 0. 0 is the first page.
859 public int HorizontalPageIndex => _scroller.HorizontalPageIndex;
862 /// Sets or gets the maximum limit of the movable page at vertical direction.
864 public int VerticalPageScrollLimit
866 get => _scroller.VerticalPageScrollLimit;
867 set => _scroller.VerticalPageScrollLimit = value;
871 /// Sets or gets the maximum limit of the movable page at horizontal direction.
873 public int HorizontalPageScrollLimit
875 get => _scroller.HorizontalPageScrollLimit;
876 set => _scroller.HorizontalPageScrollLimit = value;
880 /// Sets or gets the vertical bounce behaviour.
881 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
882 /// This is a visual way to indicate the end has been reached.
883 /// This is enabled by default for both axis.
884 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
886 public bool VerticalBounce
888 get => _scroller.VerticalBounce;
889 set => _scroller.VerticalBounce = value;
893 /// Sets or gets the horizontal bounce behaviour.
894 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
895 /// This is a visual way to indicate the end has been reached.
896 /// This is enabled by default for both axis.
897 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
899 public bool HorizontalBounce
901 get => _scroller.HorizontalBounce;
902 set => _scroller.HorizontalBounce = value;
906 /// Gets the width of the content object of the scroller.
908 public int ChildWidth
910 get => _scroller.ChildWidth;
914 /// Gets the height of the content object of the scroller.
916 public int ChildHeight
918 get => _scroller.ChildHeight;
922 /// Set scrolling gravity values for a scroller.
923 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
924 /// The scroller will adjust the view to glue itself as follows.
925 /// 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
926 /// Default values for x and y are 0.0
928 public double HorizontalGravity
930 get => _scroller.HorizontalGravity;
931 set => _scroller.HorizontalGravity = value;
935 /// Set scrolling gravity values for a scroller.
936 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
937 /// The scroller will adjust the view to glue itself as follows.
938 /// 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
939 /// Default values for x and y are 0.0
941 public double VerticalGravity
943 get => _scroller.VerticalGravity;
944 set => _scroller.VerticalGravity = value;
948 /// Get scroll last page number.
949 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
951 public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber;
954 /// Get scroll last page number.
955 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
957 public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber;
960 /// Set an infinite loop_ for a scroller.
961 /// This function sets the infinite loop vertically.
962 /// If the content is set, it will be shown repeatedly.
964 public bool VerticalLoop
966 get => _scroller.VerticalLoop;
967 set => _scroller.VerticalLoop = value;
971 /// Set an infinite loop_ for a scroller.
972 /// This function sets the infinite loop horizontally.
973 /// If the content is set, it will be shown repeatedly.
975 public bool HorizontalLoop
977 get => _scroller.HorizontalLoop;
978 set => _scroller.HorizontalLoop = value;
982 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
984 public int HorizontalPageSize
986 get => _scroller.HorizontalPageSize;
987 set => _scroller.HorizontalPageSize = value;
991 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
993 public int VerticalPageSize
995 get => _scroller.VerticalPageSize;
996 set => _scroller.VerticalPageSize = value;
1000 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
1002 public double VerticalRelativePageSize
1004 get => _scroller.VerticalRelativePageSize;
1005 set => _scroller.VerticalRelativePageSize = value;
1009 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
1011 public double HorizontalRelativePageSize
1013 get => _scroller.HorizontalRelativePageSize;
1014 set => _scroller.HorizontalRelativePageSize = value;
1018 /// Gets or Sets the page snapping behavior of a scroller.
1021 /// When scrolling, if a scroller is paged (see VerticalRelativePageSize),
1022 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
1023 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
1024 /// This function will set if it that is enabled or not, for each axis.
1026 public bool VerticalSnap
1028 get => _scroller.VerticalSnap;
1029 set => _scroller.VerticalSnap = value;
1033 /// Gets or Sets the page snapping behavior of a scroller.
1036 /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize),
1037 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
1038 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
1039 /// This function will set if it that is enabled or not, for each axis.
1041 public bool HorizontalSnap
1043 get => _scroller.HorizontalSnap;
1044 set => _scroller.HorizontalSnap = value;
1048 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1050 public int PageHeight
1052 get => _scroller.PageHeight;
1053 set => _scroller.PageHeight = value;
1057 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1059 public int PageWidth
1061 get => _scroller.PageWidth;
1062 set => _scroller.PageWidth = value;
1066 /// Gets or sets the step size to move scroller by key event.
1068 public int HorizontalStepSize
1070 get => _scroller.HorizontalStepSize;
1071 set => _scroller.HorizontalStepSize = value;
1075 /// Gets or sets the step size to move scroller by key event.
1077 public int VerticalStepSize
1079 get => _scroller.VerticalStepSize;
1080 set => _scroller.VerticalStepSize = value;
1084 /// Gets or sets a value whether mouse wheel is enabled or not over the scroller.
1086 public bool WheelDisabled
1088 get => _scroller.WheelDisabled;
1089 set => _scroller.WheelDisabled = value;
1093 /// Gets or sets the type of single direction scroll.
1095 public ScrollSingleDirection SingleDirection
1097 get => _scroller.SingleDirection;
1098 set => _scroller.SingleDirection = value;
1102 /// Sets the scroller minimum size limited to the minimum size of the content.
1103 /// By default the scroller will be as small as its design allows, irrespective of its content.
1104 /// This will make the scroller minimum size the right size horizontally and/or vertically to perfectly fit its content in that direction.
1106 /// <param name="horizontal">Enable limiting minimum size horizontally</param>
1107 /// <param name="vertical">Enable limiting minimum size vertically</param>
1108 public void MinimumLimit(bool horizontal, bool vertical)
1110 _scroller.MinimumLimit(horizontal, vertical);
1114 /// Shows a specific virtual region within the scroller content object by the page number.
1115 /// (0, 0) of the indicated page is located at the top-left corner of the viewport.
1117 /// <param name="horizontalPageIndex">The horizontal page number.</param>
1118 /// <param name="verticalPageIndex">The vertical page number.</param>
1119 /// <param name="animated">True means slider with animation.</param>
1120 public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated)
1122 _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated);
1126 /// Shows a specific virtual region within the scroller content object.
1129 /// This ensures that all (or part, if it does not fit) of the designated region in the virtual content object ((0, 0)
1130 /// starting at the top-left of the virtual content object) is shown within the scroller.
1131 /// If set "animated" to true, it will allows the scroller to "smoothly slide" to this location
1132 /// (if configuration in general calls for transitions).
1133 /// It may not jump immediately to the new location and may take a while and show other content along the way.
1135 /// <param name="region">Rect struct of region.</param>
1136 /// <param name="animated">True means allows the scroller to "smoothly slide" to this location.</param>
1137 public void ScrollTo(Rect region, bool animated)
1139 _scroller.ScrollTo(region, animated);
1144 void InitializeSmartEvent()
1146 _selected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "selected", GenListItemEventArgs.CreateFromSmartEvent);
1147 _unselected = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unselected", GenListItemEventArgs.CreateFromSmartEvent);
1148 _activated = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "activated", GenListItemEventArgs.CreateFromSmartEvent);
1149 _pressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "pressed", GenListItemEventArgs.CreateFromSmartEvent);
1150 _released = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "released", GenListItemEventArgs.CreateFromSmartEvent);
1151 _doubleClicked = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "clicked,double", GenListItemEventArgs.CreateFromSmartEvent);
1152 _expanded = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "expanded", GenListItemEventArgs.CreateFromSmartEvent);
1153 _realized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "realized", GenListItemEventArgs.CreateFromSmartEvent);
1154 _unrealized = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "unrealized", GenListItemEventArgs.CreateFromSmartEvent);
1155 _longpressed = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "longpressed", GenListItemEventArgs.CreateFromSmartEvent);
1156 _moved = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved", GenListItemEventArgs.CreateFromSmartEvent);
1157 _movedAfter = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,after", GenListItemEventArgs.CreateFromSmartEvent);
1158 _movedBefore = new SmartEvent<GenListItemEventArgs>(this, this.RealHandle, "moved,before", GenListItemEventArgs.CreateFromSmartEvent);
1159 _scrollAnimationStarted = new SmartEvent(this, this.RealHandle, "scroll,anim,start");
1160 _scrollAnimationStopped = new SmartEvent(this, this.RealHandle, "scroll,anim,stop");
1161 _changed = new SmartEvent(this, this.RealHandle, "changed");
1163 _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
1164 _unselected.On += (s, e) => { if (e.Item != null) ItemUnselected?.Invoke(this, e); };
1165 _activated.On += (s, e) => { if (e.Item != null) ItemActivated?.Invoke(this, e); };
1166 _pressed.On += (s, e) => { if (e.Item != null) ItemPressed?.Invoke(this, e); };
1167 _released.On += (s, e) => { if (e.Item != null) ItemReleased?.Invoke(this, e); };
1168 _doubleClicked.On += (s, e) => { if (e.Item != null) ItemDoubleClicked?.Invoke(this, e); };
1169 _expanded.On += (s, e) => { if (e.Item != null) ItemExpanded?.Invoke(this, e); };
1170 _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
1171 _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
1172 _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
1173 _moved.On += (s, e) => { if (e.Item != null) ItemMoved?.Invoke(this, e); };
1174 _movedAfter.On += (s, e) => { if (e.Item != null) ItemMovedAfter?.Invoke(this, e); };
1175 _movedBefore.On += (s, e) => { if (e.Item != null) ItemMovedBefore?.Invoke(this, e); };
1178 void AddInternal(GenListItem item)
1180 _children.Add(item);
1181 item.Deleted += Item_Deleted;
1184 void Item_Deleted(object sender, EventArgs e)
1186 _children.Remove((GenListItem)sender);