From: pius.lee Date: Thu, 26 Oct 2017 11:13:31 +0000 (+0900) Subject: Revert "[ElmSharp*] Add Scrollable interface" X-Git-Tag: 5.0.0-preview1-00351^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=073b51371ec3dafdc453f39dbfe33a158bb58319;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Revert "[ElmSharp*] Add Scrollable interface" This reverts commit 493888d7f1c6d343d9f43f8888c6be33c9455286. Change-Id: I88a2c702afe450e4f64792d35c44f118839614e9 --- diff --git a/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleGenList.cs b/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleGenList.cs index f465547..7dc18e1 100644 --- a/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleGenList.cs +++ b/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleGenList.cs @@ -189,7 +189,7 @@ namespace ElmSharp.Wearable /// 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. /// - public override ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy + public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy { get { @@ -199,7 +199,6 @@ namespace ElmSharp.Wearable } set { - base.VerticalScrollBarVisiblePolicy = value; int h; Interop.Eext.eext_circle_object_genlist_scroller_policy_get(CircleHandle, out h, IntPtr.Zero); Interop.Eext.eext_circle_object_genlist_scroller_policy_set(CircleHandle, (int)h, (int)value); diff --git a/src/ElmSharp/ElmSharp/Entry.cs b/src/ElmSharp/ElmSharp/Entry.cs index 3929a9a..92f57b5 100755 --- a/src/ElmSharp/ElmSharp/Entry.cs +++ b/src/ElmSharp/ElmSharp/Entry.cs @@ -250,9 +250,8 @@ namespace ElmSharp /// /// The entry is a convenience widget that shows a box in which the user can enter text. /// - public class Entry : Layout, IScrollable + public class Entry : Layout { - ScrollableAdapter _scroller; SmartEvent _clicked; SmartEvent _changedByUser; SmartEvent _cursorChanged; @@ -278,8 +277,6 @@ namespace ElmSharp _activated = new SmartEvent(this, this.RealHandle, "activated"); _activated.On += (s, e) => Activated?.Invoke(this, EventArgs.Empty); - - _scroller = new ScrollableAdapter(this); } /// @@ -791,6 +788,94 @@ namespace ElmSharp } /// + /// Sets or gets the value of HorizontalScrollBarVisiblePolicy + /// + /// + /// 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. + /// + public virtual 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); + } + } + + /// + /// Sets or gets the value of VerticalScrollBarVisiblePolicy + /// + /// + /// 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. + /// + public virtual 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); + } + } + + /// + /// 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. + /// + 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); + } + } + + /// + /// 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. + /// + 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); + } + } + + /// /// Inserts the given text into the entry at the current cursor position. /// /// @@ -1029,390 +1114,5 @@ namespace ElmSharp { return Interop.Elementary.elm_entry_add(parent.Handle); } - - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion } } \ No newline at end of file diff --git a/src/ElmSharp/ElmSharp/GenGrid.cs b/src/ElmSharp/ElmSharp/GenGrid.cs index c27ef52..146112b 100755 --- a/src/ElmSharp/ElmSharp/GenGrid.cs +++ b/src/ElmSharp/ElmSharp/GenGrid.cs @@ -44,9 +44,8 @@ namespace ElmSharp /// It has two direction in which a given GenGrid widget expands while placing its items, horizontal and vertical. /// The GenGrid items are represented through definition field details. /// - public class GenGrid : Layout, IScrollable + public class GenGrid : Layout { - ScrollableAdapter _scroller; HashSet _children = new HashSet(); SmartEvent _selected; @@ -67,7 +66,6 @@ namespace ElmSharp public GenGrid(EvasObject parent) : base(parent) { InitializeSmartEvent(); - _scroller = new ScrollableAdapter(this); } /// @@ -293,6 +291,50 @@ namespace ElmSharp } /// + /// Sets or gets the value of HorizontalScrollBarVisiblePolicy + /// + /// + /// 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. + /// + 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); + } + } + + /// + /// Sets or gets the value of VerticalScrollBarVisiblePolicy + /// + /// + /// 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. + /// + 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); + } + } + + /// /// Gets the first item in a given gengrid widget. /// public GenGridItem FirstItem @@ -530,391 +572,6 @@ namespace ElmSharp return handle; } - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion - void InitializeSmartEvent() { _selected = new SmartEvent(this, this.RealHandle, "selected", GenGridItemEventArgs.CreateFromSmartEvent); diff --git a/src/ElmSharp/ElmSharp/GenList.cs b/src/ElmSharp/ElmSharp/GenList.cs index c8c2c45..600c57b 100755 --- a/src/ElmSharp/ElmSharp/GenList.cs +++ b/src/ElmSharp/ElmSharp/GenList.cs @@ -128,9 +128,8 @@ namespace ElmSharp /// But the price to pay is more complexity when it comes to usage. /// If all you want is a simple list with icons and a single text, use the widget. /// - public class GenList : Layout, IScrollable + public class GenList : Layout { - ScrollableAdapter _scroller; HashSet _children = new HashSet(); SmartEvent _selected; @@ -751,396 +750,9 @@ namespace ElmSharp RealHandle = Interop.Elementary.elm_genlist_add(handle); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); - _scroller = new ScrollableAdapter(this); - return handle; } - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion - void InitializeSmartEvent() { _selected = new SmartEvent(this, this.RealHandle, "selected", GenListItemEventArgs.CreateFromSmartEvent); diff --git a/src/ElmSharp/ElmSharp/IScrollable.cs b/src/ElmSharp/ElmSharp/IScrollable.cs deleted file mode 100644 index d4e9e9f..0000000 --- a/src/ElmSharp/ElmSharp/IScrollable.cs +++ /dev/null @@ -1,334 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace ElmSharp -{ - /// - /// Interface for all other scrollable widgets - /// - public interface IScrollable - { - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - event EventHandler Scrolled; - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - event EventHandler DragStart; - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - event EventHandler DragStop; - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - event EventHandler PageScrolled; - - /// - /// 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 - /// - double VerticalGravity { get; set; } - - /// - /// 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 - /// - double HorizontalGravity { get; set; } - - /// - /// 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. - /// - bool VerticalBounce { get; set; } - - /// - /// 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. - /// - bool HorizontalBounce { get; set; } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - bool WheelDisabled { get; set; } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - ScrollBlock ScrollBlock { get; set; } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy { get; set; } - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy { get; set; } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - Rect CurrentRegion { get; } - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - int VerticalPageScrollLimit { get; set; } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - int HorizontalPageScrollLimit { get; set; } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - int HorizontalPageSize { get; set; } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - int VerticalPageSize { get; set; } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - bool VerticalSnap { get; set; } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - bool HorizontalSnap { get; set; } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - int PageHeight { get; set; } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - int PageWidth { get; set; } - - /// - /// Gets or sets the type of single direction scroll. - /// - ScrollSingleDirection SingleDirection { get; set; } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - int HorizontalStepSize { get; set; } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - int VerticalStepSize { get; set; } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - bool VerticalLoop { get; set; } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - bool HorizontalLoop { get; set; } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - double VerticalRelativePageSize { get; set; } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - double HorizontalRelativePageSize { get; set; } - - /// - /// 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. - /// - int LastVerticalPageNumber { get; } - - /// - /// 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. - /// - int LastHorizontalPageNumber { get; } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - int VerticalPageIndex { get; } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - int HorizontalPageIndex { get; } - - /// - /// Gets the width of the content object of the scroller. - /// - int ChildWidth { get; } - - /// - /// Gets the height of the content object of the scroller. - /// - int ChildHeight { get; } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - void MinimumLimit(bool horizontal, bool vertical); - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated); - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - void ScrollTo(Rect region, bool animated); - } - - /// - /// Enumeration for visible type of scrollbar. - /// - public enum ScrollBarVisiblePolicy - { - /// - /// Show scrollbars as needed - /// - Auto = 0, - - /// - /// Always show scrollbars - /// - Visible, - - /// - /// Never show scrollbars - /// - Invisible - } - - /// - /// Enumeration for visible type of scrollbar. - /// - public enum ScrollBlock - { - /// - /// Scrolling movement is allowed in both direction.(X axis and Y axis) - /// - None = 1, - - /// - /// Scrolling movement is not allowed in Y axis direction. - /// - Vertical = 2, - - /// - /// Scrolling movement is not allowed in X axis direction. - /// - Horizontal = 4 - } - - /// - /// Type that controls how the content is scrolled. - /// - public enum ScrollSingleDirection - { - /// - /// Scroll every direction. - /// - None, - - /// - /// Scroll single direction if the direction is certain. - /// - Soft, - - /// - /// Scroll only single direction. - /// - Hard, - } -} diff --git a/src/ElmSharp/ElmSharp/List.cs b/src/ElmSharp/ElmSharp/List.cs index a8f2bc9..59eec69 100755 --- a/src/ElmSharp/ElmSharp/List.cs +++ b/src/ElmSharp/ElmSharp/List.cs @@ -73,9 +73,8 @@ namespace ElmSharp /// /// /// - public class List : Layout, IScrollable + public class List : Layout { - ScrollableAdapter _scroller; HashSet _children = new HashSet(); SmartEvent _selected; SmartEvent _unselected; @@ -242,396 +241,9 @@ namespace ElmSharp RealHandle = Interop.Elementary.elm_list_add(handle); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); - _scroller = new ScrollableAdapter(this); - return handle; } - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion - void AddInternal(ListItem item) { _children.Add(item); diff --git a/src/ElmSharp/ElmSharp/Panel.cs b/src/ElmSharp/ElmSharp/Panel.cs index b2270d8..f34cde3 100755 --- a/src/ElmSharp/ElmSharp/Panel.cs +++ b/src/ElmSharp/ElmSharp/Panel.cs @@ -44,9 +44,8 @@ namespace ElmSharp /// /// The Panel is a container that can contain subobjects. /// - public class Panel : Layout, IScrollable + public class Panel : Layout { - ScrollableAdapter _scroller; SmartEvent _toggled; /// @@ -57,7 +56,6 @@ namespace ElmSharp { _toggled = new SmartEvent(this, this.RealHandle, "toggled"); _toggled.On += (s, e) => Toggled?.Invoke(this, EventArgs.Empty); - _scroller = new ScrollableAdapter(this); } /// @@ -140,390 +138,5 @@ namespace ElmSharp return handle; } - - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion } } diff --git a/src/ElmSharp/ElmSharp/ScrollableAdapter.cs b/src/ElmSharp/ElmSharp/ScrollableAdapter.cs deleted file mode 100644 index 4f85d2a..0000000 --- a/src/ElmSharp/ElmSharp/ScrollableAdapter.cs +++ /dev/null @@ -1,270 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using static Interop.Elementary; - -namespace ElmSharp -{ - class ScrollableAdapter : IScrollable - { - EvasObject obj; - SmartEvent _scroll; - SmartEvent _dragStart; - SmartEvent _dragStop; - SmartEvent _scrollPage; - - public ScrollableAdapter(List list) : this(list as EvasObject) - { - } - - public ScrollableAdapter(Entry entry) : this(entry as EvasObject) - { - } - - public ScrollableAdapter(Panel panel) : this(panel as EvasObject) - { - } - - public ScrollableAdapter(GenGrid gengrid) : this(gengrid as EvasObject) - { - } - - public ScrollableAdapter(Scroller scroller) : this(scroller as EvasObject) - { - } - - public ScrollableAdapter(GenList genlist) : this(genlist as EvasObject) - { - } - - public ScrollableAdapter(Toolbar toolbar) : this(toolbar as EvasObject) - { - } - - ScrollableAdapter(EvasObject scrollable) - { - obj = scrollable; - _scroll = new SmartEvent(obj, obj.RealHandle, "scroll"); - _dragStart = new SmartEvent(obj, obj.RealHandle, "scroll,drag,start"); - _dragStop = new SmartEvent(obj, obj.RealHandle, "scroll,drag,stop"); - _scrollPage = new SmartEvent(obj, obj.RealHandle, "scroll,page,changed"); - } - - public event EventHandler Scrolled - { - add => _scroll.On += value; - remove => _scroll.On -= value; - } - public event EventHandler DragStart - { - add => _dragStart.On += value; - remove => _dragStart.On -= value; - } - public event EventHandler DragStop - { - add => _dragStop.On += value; - remove => _dragStop.On -= value; - } - public event EventHandler PageScrolled - { - add => _scrollPage.On += value; - remove => _scrollPage.On -= value; - } - - public double VerticalGravity - { - get => Get2(elm_scroller_gravity_get); - set => Set(elm_scroller_gravity_set, HorizontalGravity, value); - } - public double HorizontalGravity - { - get => Get1(elm_scroller_gravity_get); - set => Set(elm_scroller_gravity_set, value, VerticalGravity); - } - public bool VerticalBounce - { - get => Get2(elm_scroller_bounce_get); - set => Set(elm_scroller_bounce_set, HorizontalBounce, value); - } - public bool HorizontalBounce - { - get => Get1(elm_scroller_bounce_get); - set => Set(elm_scroller_bounce_set, value, VerticalBounce); - } - public bool WheelDisabled - { - get => Get(elm_scroller_wheel_disabled_get); - set => Set(elm_scroller_wheel_disabled_set, value); - } - public ScrollBlock ScrollBlock - { - get => (ScrollBlock)Get(elm_scroller_movement_block_get); - set => Set(elm_scroller_movement_block_set, (int)value); - } - public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => (ScrollBarVisiblePolicy)Get2(elm_scroller_policy_get); - set => Set(elm_scroller_policy_set, (int)HorizontalScrollBarVisiblePolicy, (int)value); - } - public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => (ScrollBarVisiblePolicy)Get1(elm_scroller_policy_get); - set => Set(elm_scroller_policy_set, (int)value, (int)VerticalScrollBarVisiblePolicy); - } - - public Rect CurrentRegion - { - get - { - int x, y, w, h; - elm_scroller_region_get(obj.RealHandle, out x, out y, out w, out h); - return new Rect(x, y, w, h); - } - } - - public int VerticalPageScrollLimit - { - get => Get2(elm_scroller_page_scroll_limit_get); - set => Set(elm_scroller_page_scroll_limit_set, HorizontalPageScrollLimit, value); - } - public int HorizontalPageScrollLimit - { - get => Get1(elm_scroller_page_scroll_limit_get); - set => Set(elm_scroller_page_scroll_limit_set, value, VerticalPageScrollLimit); - } - - public int HorizontalPageSize - { - get => Get1(elm_scroller_page_size_get); - set => Set(elm_scroller_page_size_set, value, VerticalPageSize); - } - - public int VerticalPageSize - { - get => Get2(elm_scroller_page_size_get); - set => Set(elm_scroller_page_size_set, HorizontalPageSize, value); - } - - public bool VerticalSnap - { - get => Get2(elm_scroller_page_snap_get); - set => Set(elm_scroller_page_snap_set, HorizontalSnap, value); - } - public bool HorizontalSnap - { - get => Get1(elm_scroller_page_snap_get); - set => Set(elm_scroller_page_snap_set, value, VerticalSnap); - } - public int PageHeight - { - get => Get2(elm_scroller_page_size_get); - set => Set(elm_scroller_page_size_set, PageWidth, value); - } - public int PageWidth - { - get => Get1(elm_scroller_page_size_get); - set => Set(elm_scroller_page_size_set, value, PageHeight); - } - public ScrollSingleDirection SingleDirection - { - get => (ScrollSingleDirection)elm_scroller_single_direction_get(obj.RealHandle); - set => Set(elm_scroller_single_direction_set, (int)value); - } - public int HorizontalStepSize - { - get => Get1(elm_scroller_step_size_get); - set => Set(elm_scroller_step_size_set, value, VerticalStepSize); - } - public int VerticalStepSize - { - get => Get2(elm_scroller_step_size_get); - set => Set(elm_scroller_step_size_set, HorizontalStepSize, value); - } - public bool VerticalLoop - { - get => Get2(elm_scroller_loop_get); - set => Set(elm_scroller_loop_set, HorizontalLoop, value); - } - public bool HorizontalLoop - { - get => Get1(elm_scroller_loop_get); - set => Set(elm_scroller_loop_set, value, VerticalLoop); - } - public double VerticalRelativePageSize - { - get => Get2(elm_scroller_page_relative_get); - set => Set(elm_scroller_page_relative_set, HorizontalRelativePageSize, value); - } - public double HorizontalRelativePageSize - { - get => Get1(elm_scroller_page_relative_get); - set => Set(elm_scroller_page_relative_set, value, VerticalRelativePageSize); - } - - public int LastVerticalPageNumber => Get2(elm_scroller_last_page_get); - - public int LastHorizontalPageNumber => Get1(elm_scroller_last_page_get); - - public int VerticalPageIndex => Get2(elm_scroller_current_page_get); - - public int HorizontalPageIndex => Get1(elm_scroller_current_page_get); - - public int ChildWidth => Get1(elm_scroller_child_size_get); - - public int ChildHeight => Get2(elm_scroller_child_size_get); - - public void MinimumLimit(bool horizontal, bool vertical) - { - Set(elm_scroller_content_min_limit, horizontal, vertical); - } - - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - if (animated) - { - Set(elm_scroller_page_bring_in, horizontalPageIndex, verticalPageIndex); - } - else - { - Set(elm_scroller_page_show, horizontalPageIndex, verticalPageIndex); - } - } - - public void ScrollTo(Rect region, bool animated) - { - if (animated) - { - elm_scroller_region_bring_in(obj.RealHandle, region.X, region.Y, region.Width, region.Height); - } - else - { - elm_scroller_region_show(obj.RealHandle, region.X, region.Y, region.Width, region.Height); - } - } - - delegate T Getter(IntPtr handle); - delegate void Setter(IntPtr handle, T v); - delegate void DoubleGetter(IntPtr handle, out T v1, out T v2); - delegate void DoubleSetter(IntPtr handle, T v1, T v2); - - T Get(Getter func) => func(obj.RealHandle); - void Set(Setter func, T value) => func(obj.RealHandle, value); - - T Get1(DoubleGetter func) - { - T v1, v2; - func(obj.RealHandle, out v1, out v2); - return v1; - } - - T Get2(DoubleGetter func) - { - T v1, v2; - func(obj.RealHandle, out v1, out v2); - return v2; - } - - void Set(DoubleSetter func, T v1, T v2) => func(obj.RealHandle, v1, v2); - } -} diff --git a/src/ElmSharp/ElmSharp/Scroller.cs b/src/ElmSharp/ElmSharp/Scroller.cs index 926b68f..a6063a7 100755 --- a/src/ElmSharp/ElmSharp/Scroller.cs +++ b/src/ElmSharp/ElmSharp/Scroller.cs @@ -19,11 +19,77 @@ using System; namespace ElmSharp { /// + /// Enumeration for visible type of scrollbar. + /// + public enum ScrollBarVisiblePolicy + { + /// + /// Show scrollbars as needed + /// + Auto = 0, + + /// + /// Always show scrollbars + /// + Visible, + + /// + /// Never show scrollbars + /// + Invisible + } + + /// + /// Enumeration for visible type of scrollbar. + /// + public enum ScrollBlock + { + /// + /// Scrolling movement is allowed in both direction.(X axis and Y axis) + /// + None = 1, + + /// + /// Scrolling movement is not allowed in Y axis direction. + /// + Vertical = 2, + + /// + /// Scrolling movement is not allowed in X axis direction. + /// + Horizontal = 4 + } + + /// + /// Type that controls how the content is scrolled. + /// + public enum ScrollSingleDirection + { + /// + /// Scroll every direction. + /// + None, + + /// + /// Scroll single direction if the direction is certain. + /// + Soft, + + /// + /// Scroll only single direction. + /// + Hard, + } + + /// /// The Scroller is a container that holds and clips a single object and allows you to scroll across it. /// - public class Scroller : Layout, IScrollable + public class Scroller : Layout { - ScrollableAdapter _adapter; + SmartEvent _scroll; + SmartEvent _dragStart; + SmartEvent _dragStop; + SmartEvent _scrollpage; /// /// Creates and initializes a new instance of the Scroller class. @@ -45,8 +111,14 @@ namespace ElmSharp /// public event EventHandler Scrolled { - add => _adapter.Scrolled += value; - remove => _adapter.Scrolled -= value; + add + { + _scroll.On += value; + } + remove + { + _scroll.On -= value; + } } /// @@ -54,8 +126,14 @@ namespace ElmSharp /// public event EventHandler DragStart { - add => _adapter.DragStart += value; - remove => _adapter.DragStart -= value; + add + { + _dragStart.On += value; + } + remove + { + _dragStart.On -= value; + } } /// @@ -63,8 +141,14 @@ namespace ElmSharp /// public event EventHandler DragStop { - add => _adapter.DragStop += value; - remove => _adapter.DragStop -= value; + add + { + _dragStop.On += value; + } + remove + { + _dragStop.On -= value; + } } /// @@ -72,14 +156,28 @@ namespace ElmSharp /// public event EventHandler PageScrolled { - add => _adapter.PageScrolled += value; - remove => _adapter.PageScrolled -= value; + add + { + _scrollpage.On += value; + } + remove + { + _scrollpage.On -= value; + } } /// /// Gets the current region in the content object that is visible through the Scroller. /// - public Rect CurrentRegion => _adapter.CurrentRegion; + 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); + } + } /// /// Sets or gets the value of HorizontalScrollBarVisiblePolicy @@ -90,8 +188,17 @@ namespace ElmSharp /// public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy { - get => _adapter.HorizontalScrollBarVisiblePolicy; - set => _adapter.HorizontalScrollBarVisiblePolicy = value; + 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); + } } /// @@ -103,8 +210,17 @@ namespace ElmSharp /// public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy { - get => _adapter.VerticalScrollBarVisiblePolicy; - set => _adapter.VerticalScrollBarVisiblePolicy = value; + 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); + } } /// @@ -116,8 +232,14 @@ namespace ElmSharp /// public ScrollBlock ScrollBlock { - get => _adapter.ScrollBlock; - set => _adapter.ScrollBlock = value; + get + { + return (ScrollBlock)Interop.Elementary.elm_scroller_movement_block_get(RealHandle); + } + set + { + Interop.Elementary.elm_scroller_movement_block_set(RealHandle, (int)value); + } } /// @@ -128,7 +250,15 @@ namespace ElmSharp /// 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. /// - public int VerticalPageIndex => _adapter.VerticalPageIndex; + public int VerticalPageIndex + { + get + { + int v, h; + Interop.Elementary.elm_scroller_current_page_get(RealHandle, out h, out v); + return v; + } + } /// /// Sets or gets scroll current page number. @@ -138,15 +268,32 @@ namespace ElmSharp /// 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. /// - public int HorizontalPageIndex => _adapter.HorizontalPageIndex; + public int HorizontalPageIndex + { + get + { + int v, h; + Interop.Elementary.elm_scroller_current_page_get(RealHandle, out h, out v); + return h; + } + } /// /// Sets or gets the maximum limit of the movable page at vertical direction. /// public int VerticalPageScrollLimit { - get => _adapter.VerticalPageScrollLimit; - set => _adapter.VerticalPageScrollLimit = value; + 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); + } } /// @@ -154,8 +301,17 @@ namespace ElmSharp /// public int HorizontalPageScrollLimit { - get => _adapter.HorizontalPageScrollLimit; - set => _adapter.HorizontalPageScrollLimit = value; + 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); + } } /// @@ -167,8 +323,17 @@ namespace ElmSharp /// public bool VerticalBounce { - get => _adapter.VerticalBounce; - set => _adapter.VerticalBounce = value; + 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); + } } /// @@ -180,8 +345,17 @@ namespace ElmSharp /// public bool HorizontalBounce { - get => _adapter.HorizontalBounce; - set => _adapter.HorizontalBounce = value; + 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); + } } /// @@ -189,7 +363,12 @@ namespace ElmSharp /// public int ChildWidth { - get => _adapter.ChildWidth; + get + { + int w, h; + Interop.Elementary.elm_scroller_child_size_get(RealHandle, out w, out h); + return w; + } } /// @@ -197,7 +376,12 @@ namespace ElmSharp /// public int ChildHeight { - get => _adapter.ChildHeight; + get + { + int w, h; + Interop.Elementary.elm_scroller_child_size_get(RealHandle, out w, out h); + return h; + } } /// @@ -209,8 +393,17 @@ namespace ElmSharp /// public double HorizontalGravity { - get => _adapter.HorizontalGravity; - set => _adapter.HorizontalGravity = value; + 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); + } } /// @@ -222,21 +415,46 @@ namespace ElmSharp /// public double VerticalGravity { - get => _adapter.VerticalGravity; - set => _adapter.VerticalGravity = value; + 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); + } } /// /// 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. /// - public int LastVerticalPageNumber => _adapter.LastVerticalPageNumber; + public int LastVerticalPageNumber + { + get + { + int v, h; + Interop.Elementary.elm_scroller_last_page_get(RealHandle, out h, out v); + return v; + } + } /// /// 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. /// - public int LastHorizontalPageNumber => _adapter.LastHorizontalPageNumber; + public int LastHorizontalPageNumber + { + get + { + int v, h; + Interop.Elementary.elm_scroller_last_page_get(RealHandle, out h, out v); + return h; + } + } /// /// Set an infinite loop_ for a scroller. @@ -245,8 +463,17 @@ namespace ElmSharp /// public bool VerticalLoop { - get => _adapter.VerticalLoop; - set => _adapter.VerticalLoop = value; + 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); + } } /// @@ -256,26 +483,17 @@ namespace ElmSharp /// public bool HorizontalLoop { - get => _adapter.HorizontalLoop; - set => _adapter.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _adapter.HorizontalPageSize; - set => _adapter.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _adapter.VerticalPageSize; - set => _adapter.VerticalPageSize = value; + 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); + } } /// @@ -283,8 +501,17 @@ namespace ElmSharp /// public double VerticalRelativePageSize { - get => _adapter.VerticalRelativePageSize; - set => _adapter.VerticalRelativePageSize = value; + 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); + } } /// @@ -292,8 +519,17 @@ namespace ElmSharp /// public double HorizontalRelativePageSize { - get => _adapter.HorizontalRelativePageSize; - set => _adapter.HorizontalRelativePageSize = value; + 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); + } } /// @@ -307,8 +543,17 @@ namespace ElmSharp /// public bool VerticalSnap { - get => _adapter.VerticalSnap; - set => _adapter.VerticalSnap = value; + 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); + } } /// @@ -322,8 +567,17 @@ namespace ElmSharp /// public bool HorizontalSnap { - get => _adapter.HorizontalSnap; - set => _adapter.HorizontalSnap = value; + 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); + } } /// @@ -331,8 +585,17 @@ namespace ElmSharp /// public int PageHeight { - get => _adapter.PageHeight; - set => _adapter.PageHeight = value; + 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); + } } /// @@ -340,8 +603,17 @@ namespace ElmSharp /// public int PageWidth { - get => _adapter.PageWidth; - set => _adapter.PageWidth = value; + 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); + } } /// @@ -366,8 +638,17 @@ namespace ElmSharp /// public int HorizontalStepSize { - get => _adapter.HorizontalStepSize; - set => _adapter.HorizontalStepSize = value; + 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); + } } /// @@ -375,8 +656,17 @@ namespace ElmSharp /// public int VerticalStepSize { - get => _adapter.VerticalStepSize; - set => _adapter.VerticalStepSize = value; + 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); + } } /// @@ -384,8 +674,14 @@ namespace ElmSharp /// public bool WheelDisabled { - get => _adapter.WheelDisabled; - set => _adapter.WheelDisabled = value; + get + { + return Interop.Elementary.elm_scroller_wheel_disabled_get(RealHandle); + } + set + { + Interop.Elementary.elm_scroller_wheel_disabled_set(RealHandle, value); + } } /// @@ -393,8 +689,14 @@ namespace ElmSharp /// public ScrollSingleDirection SingleDirection { - get => _adapter.SingleDirection; - set => _adapter.SingleDirection = value; + get + { + return (ScrollSingleDirection)Interop.Elementary.elm_scroller_single_direction_get(RealHandle); + } + set + { + Interop.Elementary.elm_scroller_single_direction_set(RealHandle, (int)value); + } } /// @@ -406,7 +708,7 @@ namespace ElmSharp /// Enable limiting minimum size vertically public void MinimumLimit(bool horizontal, bool vertical) { - _adapter.MinimumLimit(horizontal, vertical); + Interop.Elementary.elm_scroller_content_min_limit(RealHandle, horizontal, vertical); } /// @@ -447,7 +749,14 @@ namespace ElmSharp /// True means slider with animation. public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) { - _adapter.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); + if (animated) + { + Interop.Elementary.elm_scroller_page_bring_in(RealHandle, horizontalPageIndex, verticalPageIndex); + } + else + { + Interop.Elementary.elm_scroller_page_show(RealHandle, horizontalPageIndex, verticalPageIndex); + } } /// @@ -464,7 +773,26 @@ namespace ElmSharp /// True means allows the scroller to "smoothly slide" to this location. public void ScrollTo(Rect region, bool animated) { - _adapter.ScrollTo(region, 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); + } + } + + /// + /// The callback of Realized Event + /// + protected override void OnRealized() + { + base.OnRealized(); + _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"); } /// @@ -480,8 +808,6 @@ namespace ElmSharp RealHandle = Interop.Elementary.elm_scroller_add(handle); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); - _adapter = new ScrollableAdapter(this); - return handle; } } diff --git a/src/ElmSharp/ElmSharp/Toolbar.cs b/src/ElmSharp/ElmSharp/Toolbar.cs index 5b92ca7..49d7178 100755 --- a/src/ElmSharp/ElmSharp/Toolbar.cs +++ b/src/ElmSharp/ElmSharp/Toolbar.cs @@ -125,9 +125,8 @@ namespace ElmSharp /// /// The Toolbar is a widget that displays a list of items inside a box. /// - public class Toolbar : Widget, IScrollable + public class Toolbar : Widget { - ScrollableAdapter _scroller; SmartEvent _clicked; SmartEvent _selected; SmartEvent _longpressed; @@ -159,8 +158,6 @@ namespace ElmSharp { e.Item?.SendClicked(); }; - - _scroller = new ScrollableAdapter(this); } /// @@ -469,390 +466,5 @@ namespace ElmSharp return handle; } - - #region IScroller Implementation - - /// - /// Scrolled will be triggered when the content has been scrolled. - /// - public event EventHandler Scrolled - { - add => _scroller.Scrolled += value; - remove => _scroller.Scrolled -= value; - } - - /// - /// DragStart will be triggered when dragging the contents around has started. - /// - public event EventHandler DragStart - { - add => _scroller.DragStart += value; - remove => _scroller.DragStart -= value; - } - - /// - /// DragStop will be triggered when dragging the contents around has stopped. - /// - public event EventHandler DragStop - { - add => _scroller.DragStop += value; - remove => _scroller.DragStop -= value; - } - - /// - /// PageScrolled will be triggered when the visible page has changed. - /// - public event EventHandler PageScrolled - { - add => _scroller.PageScrolled += value; - remove => _scroller.PageScrolled -= value; - } - - /// - /// Gets the current region in the content object that is visible through the Scroller. - /// - public Rect CurrentRegion => _scroller.CurrentRegion; - - /// - /// Sets or gets the value of HorizontalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy - { - get => _scroller.HorizontalScrollBarVisiblePolicy; - set => _scroller.HorizontalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of VerticalScrollBarVisiblePolicy - /// - /// - /// 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. - /// - public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy - { - get => _scroller.VerticalScrollBarVisiblePolicy; - set => _scroller.VerticalScrollBarVisiblePolicy = value; - } - - /// - /// Sets or gets the value of ScrollBlock. - /// - /// - /// 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. - /// - public ScrollBlock ScrollBlock - { - get => _scroller.ScrollBlock; - set => _scroller.ScrollBlock = value; - } - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int VerticalPageIndex => _scroller.VerticalPageIndex; - - /// - /// Sets or gets scroll current page number. - /// - /// - /// 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. - /// - public int HorizontalPageIndex => _scroller.HorizontalPageIndex; - - /// - /// Sets or gets the maximum limit of the movable page at vertical direction. - /// - public int VerticalPageScrollLimit - { - get => _scroller.VerticalPageScrollLimit; - set => _scroller.VerticalPageScrollLimit = value; - } - - /// - /// Sets or gets the maximum limit of the movable page at horizontal direction. - /// - public int HorizontalPageScrollLimit - { - get => _scroller.HorizontalPageScrollLimit; - set => _scroller.HorizontalPageScrollLimit = value; - } - - /// - /// 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. - /// - public bool VerticalBounce - { - get => _scroller.VerticalBounce; - set => _scroller.VerticalBounce = value; - } - - /// - /// 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. - /// - public bool HorizontalBounce - { - get => _scroller.HorizontalBounce; - set => _scroller.HorizontalBounce = value; - } - - /// - /// Gets the width of the content object of the scroller. - /// - public int ChildWidth - { - get => _scroller.ChildWidth; - } - - /// - /// Gets the height of the content object of the scroller. - /// - public int ChildHeight - { - get => _scroller.ChildHeight; - } - - /// - /// 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 - /// - public double HorizontalGravity - { - get => _scroller.HorizontalGravity; - set => _scroller.HorizontalGravity = value; - } - - /// - /// 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 - /// - public double VerticalGravity - { - get => _scroller.VerticalGravity; - set => _scroller.VerticalGravity = value; - } - - /// - /// 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. - /// - public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber; - - /// - /// 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. - /// - public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber; - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop vertically. - /// If the content is set, it will be shown repeatedly. - /// - public bool VerticalLoop - { - get => _scroller.VerticalLoop; - set => _scroller.VerticalLoop = value; - } - - /// - /// Set an infinite loop_ for a scroller. - /// This function sets the infinite loop horizontally. - /// If the content is set, it will be shown repeatedly. - /// - public bool HorizontalLoop - { - get => _scroller.HorizontalLoop; - set => _scroller.HorizontalLoop = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int HorizontalPageSize - { - get => _scroller.HorizontalPageSize; - set => _scroller.HorizontalPageSize = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int VerticalPageSize - { - get => _scroller.VerticalPageSize; - set => _scroller.VerticalPageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double VerticalRelativePageSize - { - get => _scroller.VerticalRelativePageSize; - set => _scroller.VerticalRelativePageSize = value; - } - - /// - /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size. - /// - public double HorizontalRelativePageSize - { - get => _scroller.HorizontalRelativePageSize; - set => _scroller.HorizontalRelativePageSize = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see VerticalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool VerticalSnap - { - get => _scroller.VerticalSnap; - set => _scroller.VerticalSnap = value; - } - - /// - /// Gets or Sets the page snapping behavior of a scroller. - /// - /// - /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize), - /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further, - /// it will stop at the next page boundaries. This is disabled, by default, for both axis. - /// This function will set if it that is enabled or not, for each axis. - /// - public bool HorizontalSnap - { - get => _scroller.HorizontalSnap; - set => _scroller.HorizontalSnap = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageHeight - { - get => _scroller.PageHeight; - set => _scroller.PageHeight = value; - } - - /// - /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis. - /// - public int PageWidth - { - get => _scroller.PageWidth; - set => _scroller.PageWidth = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int HorizontalStepSize - { - get => _scroller.HorizontalStepSize; - set => _scroller.HorizontalStepSize = value; - } - - /// - /// Gets or sets the step size to move scroller by key event. - /// - public int VerticalStepSize - { - get => _scroller.VerticalStepSize; - set => _scroller.VerticalStepSize = value; - } - - /// - /// Gets or sets a value whether mouse wheel is enabled or not over the scroller. - /// - public bool WheelDisabled - { - get => _scroller.WheelDisabled; - set => _scroller.WheelDisabled = value; - } - - /// - /// Gets or sets the type of single direction scroll. - /// - public ScrollSingleDirection SingleDirection - { - get => _scroller.SingleDirection; - set => _scroller.SingleDirection = value; - } - - /// - /// 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. - /// - /// Enable limiting minimum size horizontally - /// Enable limiting minimum size vertically - public void MinimumLimit(bool horizontal, bool vertical) - { - _scroller.MinimumLimit(horizontal, vertical); - } - - /// - /// 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. - /// - /// The horizontal page number. - /// The vertical page number. - /// True means slider with animation. - public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated) - { - _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated); - } - - /// - /// Shows a specific virtual region within the scroller content object. - /// - /// - /// 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. - /// - /// Rect struct of region. - /// True means allows the scroller to "smoothly slide" to this location. - public void ScrollTo(Rect region, bool animated) - { - _scroller.ScrollTo(region, animated); - } - - #endregion } } \ No newline at end of file