2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 /// Enumeration for paneldirection type.
24 public enum PanelDirection
45 /// The Panel is a container that can contain subobjects.
47 public class Panel : Layout, IScrollable
49 ScrollableAdapter _scroller;
53 /// Creates and initializes a new instance of Panel class.
55 /// <param name="parent">The EvasObject to which the new Panel will be attached as a child.</param>
56 public Panel(EvasObject parent) : base(parent)
58 _toggled = new SmartEvent(this, this.RealHandle, "toggled");
59 _toggled.On += (s, e) => Toggled?.Invoke(this, EventArgs.Empty);
60 _scroller = new ScrollableAdapter(this);
64 /// Sets or gets the hidden status of a given Panel widget.
70 return !Interop.Elementary.elm_panel_hidden_get(RealHandle);
74 Interop.Elementary.elm_panel_hidden_set(RealHandle, !value);
79 /// Sets or gets the direction of a given Panel widget.
81 public PanelDirection Direction
85 return (PanelDirection)Interop.Elementary.elm_panel_orient_get(RealHandle);
89 Interop.Elementary.elm_panel_orient_set(RealHandle, (int)value);
94 /// Toggled will be triggered when toggles Panel.
96 public event EventHandler Toggled;
99 /// Enable or disable scrolling in the Panel.
101 /// <param name="enable">
102 /// Bool value can be false or true.
104 public void SetScrollable(bool enable)
106 Interop.Elementary.elm_panel_scrollable_set(RealHandle, enable);
110 /// Sets the scroll size of Panel.
112 /// <param name="ratio">
113 /// The size of scroll area.
115 public void SetScrollableArea(double ratio)
117 Interop.Elementary.elm_panel_scrollable_content_size_set(RealHandle, ratio);
121 /// Toggles the hidden state of the Panel.
125 Interop.Elementary.elm_panel_toggle(RealHandle);
129 /// Creates a widget handle.
131 /// <param name="parent">Parent EvasObject</param>
132 /// <returns>Handle IntPtr</returns>
133 protected override IntPtr CreateHandle(EvasObject parent)
135 IntPtr handle = Interop.Elementary.elm_layout_add(parent);
136 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
138 RealHandle = Interop.Elementary.elm_panel_add(handle);
139 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
144 #region IScroller Implementation
147 /// Scrolled will be triggered when the content has been scrolled.
149 public event EventHandler Scrolled
151 add => _scroller.Scrolled += value;
152 remove => _scroller.Scrolled -= value;
156 /// DragStart will be triggered when dragging the contents around has started.
158 public event EventHandler DragStart
160 add => _scroller.DragStart += value;
161 remove => _scroller.DragStart -= value;
165 /// DragStop will be triggered when dragging the contents around has stopped.
167 public event EventHandler DragStop
169 add => _scroller.DragStop += value;
170 remove => _scroller.DragStop -= value;
174 /// PageScrolled will be triggered when the visible page has changed.
176 public event EventHandler PageScrolled
178 add => _scroller.PageScrolled += value;
179 remove => _scroller.PageScrolled -= value;
183 /// Gets the current region in the content object that is visible through the Scroller.
185 public Rect CurrentRegion => _scroller.CurrentRegion;
188 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
191 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
192 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
194 public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
196 get => _scroller.HorizontalScrollBarVisiblePolicy;
197 set => _scroller.HorizontalScrollBarVisiblePolicy = value;
201 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
204 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
205 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
207 public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
209 get => _scroller.VerticalScrollBarVisiblePolicy;
210 set => _scroller.VerticalScrollBarVisiblePolicy = value;
214 /// Sets or gets the value of ScrollBlock.
217 /// This function will block scrolling movement in a given direction.One can disable movements in the X axis, the Y axis or both.
218 /// The default value is ScrollBlock.None, where movements are allowed in both directions.
220 public ScrollBlock ScrollBlock
222 get => _scroller.ScrollBlock;
223 set => _scroller.ScrollBlock = value;
227 /// Sets or gets scroll current page number.
230 /// Current page means the page which meets the top of the viewport.
231 /// If there are two or more pages in the viewport, it returns the number of the page which meets the top of the viewport.
232 /// The page number starts from 0. 0 is the first page.
234 public int VerticalPageIndex => _scroller.VerticalPageIndex;
237 /// Sets or gets scroll current page number.
240 /// Current page means the page which meets the left of the viewport.
241 /// If there are two or more pages in the viewport, it returns the number of the page which meets the left of the viewport.
242 /// The page number starts from 0. 0 is the first page.
244 public int HorizontalPageIndex => _scroller.HorizontalPageIndex;
247 /// Sets or gets the maximum limit of the movable page at vertical direction.
249 public int VerticalPageScrollLimit
251 get => _scroller.VerticalPageScrollLimit;
252 set => _scroller.VerticalPageScrollLimit = value;
256 /// Sets or gets the maximum limit of the movable page at horizontal direction.
258 public int HorizontalPageScrollLimit
260 get => _scroller.HorizontalPageScrollLimit;
261 set => _scroller.HorizontalPageScrollLimit = value;
265 /// Sets or gets the vertical bounce behaviour.
266 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
267 /// This is a visual way to indicate the end has been reached.
268 /// This is enabled by default for both axis.
269 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
271 public bool VerticalBounce
273 get => _scroller.VerticalBounce;
274 set => _scroller.VerticalBounce = value;
278 /// Sets or gets the horizontal bounce behaviour.
279 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
280 /// This is a visual way to indicate the end has been reached.
281 /// This is enabled by default for both axis.
282 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
284 public bool HorizontalBounce
286 get => _scroller.HorizontalBounce;
287 set => _scroller.HorizontalBounce = value;
291 /// Gets the width of the content object of the scroller.
293 public int ChildWidth
295 get => _scroller.ChildWidth;
299 /// Gets the height of the content object of the scroller.
301 public int ChildHeight
303 get => _scroller.ChildHeight;
307 /// Set scrolling gravity values for a scroller.
308 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
309 /// The scroller will adjust the view to glue itself as follows.
310 /// 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
311 /// Default values for x and y are 0.0
313 public double HorizontalGravity
315 get => _scroller.HorizontalGravity;
316 set => _scroller.HorizontalGravity = value;
320 /// Set scrolling gravity values for a scroller.
321 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
322 /// The scroller will adjust the view to glue itself as follows.
323 /// 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
324 /// Default values for x and y are 0.0
326 public double VerticalGravity
328 get => _scroller.VerticalGravity;
329 set => _scroller.VerticalGravity = value;
333 /// Get scroll last page number.
334 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
336 public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber;
339 /// Get scroll last page number.
340 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
342 public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber;
345 /// Set an infinite loop_ for a scroller.
346 /// This function sets the infinite loop vertically.
347 /// If the content is set, it will be shown repeatedly.
349 public bool VerticalLoop
351 get => _scroller.VerticalLoop;
352 set => _scroller.VerticalLoop = value;
356 /// Set an infinite loop_ for a scroller.
357 /// This function sets the infinite loop horizontally.
358 /// If the content is set, it will be shown repeatedly.
360 public bool HorizontalLoop
362 get => _scroller.HorizontalLoop;
363 set => _scroller.HorizontalLoop = value;
367 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
369 public int HorizontalPageSize
371 get => _scroller.HorizontalPageSize;
372 set => _scroller.HorizontalPageSize = value;
376 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
378 public int VerticalPageSize
380 get => _scroller.VerticalPageSize;
381 set => _scroller.VerticalPageSize = value;
385 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
387 public double VerticalRelativePageSize
389 get => _scroller.VerticalRelativePageSize;
390 set => _scroller.VerticalRelativePageSize = value;
394 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
396 public double HorizontalRelativePageSize
398 get => _scroller.HorizontalRelativePageSize;
399 set => _scroller.HorizontalRelativePageSize = value;
403 /// Gets or Sets the page snapping behavior of a scroller.
406 /// When scrolling, if a scroller is paged (see VerticalRelativePageSize),
407 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
408 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
409 /// This function will set if it that is enabled or not, for each axis.
411 public bool VerticalSnap
413 get => _scroller.VerticalSnap;
414 set => _scroller.VerticalSnap = value;
418 /// Gets or Sets the page snapping behavior of a scroller.
421 /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize),
422 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
423 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
424 /// This function will set if it that is enabled or not, for each axis.
426 public bool HorizontalSnap
428 get => _scroller.HorizontalSnap;
429 set => _scroller.HorizontalSnap = value;
433 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
435 public int PageHeight
437 get => _scroller.PageHeight;
438 set => _scroller.PageHeight = value;
442 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
446 get => _scroller.PageWidth;
447 set => _scroller.PageWidth = value;
451 /// Gets or sets the step size to move scroller by key event.
453 public int HorizontalStepSize
455 get => _scroller.HorizontalStepSize;
456 set => _scroller.HorizontalStepSize = value;
460 /// Gets or sets the step size to move scroller by key event.
462 public int VerticalStepSize
464 get => _scroller.VerticalStepSize;
465 set => _scroller.VerticalStepSize = value;
469 /// Gets or sets a value whether mouse wheel is enabled or not over the scroller.
471 public bool WheelDisabled
473 get => _scroller.WheelDisabled;
474 set => _scroller.WheelDisabled = value;
478 /// Gets or sets the type of single direction scroll.
480 public ScrollSingleDirection SingleDirection
482 get => _scroller.SingleDirection;
483 set => _scroller.SingleDirection = value;
487 /// Sets the scroller minimum size limited to the minimum size of the content.
488 /// By default the scroller will be as small as its design allows, irrespective of its content.
489 /// This will make the scroller minimum size the right size horizontally and/or vertically to perfectly fit its content in that direction.
491 /// <param name="horizontal">Enable limiting minimum size horizontally</param>
492 /// <param name="vertical">Enable limiting minimum size vertically</param>
493 public void MinimumLimit(bool horizontal, bool vertical)
495 _scroller.MinimumLimit(horizontal, vertical);
499 /// Shows a specific virtual region within the scroller content object by the page number.
500 /// (0, 0) of the indicated page is located at the top-left corner of the viewport.
502 /// <param name="horizontalPageIndex">The horizontal page number.</param>
503 /// <param name="verticalPageIndex">The vertical page number.</param>
504 /// <param name="animated">True means slider with animation.</param>
505 public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated)
507 _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated);
511 /// Shows a specific virtual region within the scroller content object.
514 /// This ensures that all (or part, if it does not fit) of the designated region in the virtual content object ((0, 0)
515 /// starting at the top-left of the virtual content object) is shown within the scroller.
516 /// If set "animated" to true, it will allows the scroller to "smoothly slide" to this location
517 /// (if configuration in general calls for transitions).
518 /// It may not jump immediately to the new location and may take a while and show other content along the way.
520 /// <param name="region">Rect struct of region.</param>
521 /// <param name="animated">True means allows the scroller to "smoothly slide" to this location.</param>
522 public void ScrollTo(Rect region, bool animated)
524 _scroller.ScrollTo(region, animated);