Scroll
Show a part of view with scrollbar.
| Header | #include "nativeui/scroll.h" |
| Namespace | namespace nu |
| Type | class (RefCounted) |
| Inherits | View |
The Scroll view can show an arbitrary content view inside it.
When the content is larger than the Scroll view, scrollbars will be
optionally showed. When the content view is smaller then the Scroll view,
the content view will be resized to the size of the Scroll view.
Constructors
Scroll()
Create a new Scroll view.
Class properties
const char* kClassName
The class name of this view.
Methods
void SetContentView(scoped_refptr<View> view)
Set the content view.
Parameters
scoped_refptr<View>view
View* GetContentView() const
Return the content view.
Return
View*void SetContentSize(const SizeF& size)
Set the size of content view.
Parameters
const SizeF&size
SizeF GetContentSize() const
Return the size of content view.
Return
SizeFvoid SetScrollPosition(float horizon, float vertical)
Scroll to the horizon and vertical position.
Parameters
floathorizonfloatvertical
std::tuple<float, float> GetScrollPosition() const
Return the horizon and vertical scroll position.
Return
std::tuple<float, float>std::tuple<float, float> GetMaximumScrollPosition() const
Return the maximum horizon and vertical scroll position.
Return
std::tuple<float, float>void SetOverlayScrollbar(bool overlay) macOS linux
Set whether to use overlay scrolling.
Parameters
booloverlay
bool IsOverlayScrollbar() const macOS linux
Return whether overlay scrolling is used.
Return
boolvoid SetScrollbarPolicy(Scroll::Policy hpolicy, Scroll::Policy vpolicy)
Set the policy for displaying horizontal and vertical scrollbars.
Parameters
Scroll::Policyhpolicy - Policy for horizontal scrollbar.Scroll::Policyvpolicy - Policy for vertical scrollbar.
std::tuple<Scroll::Policy, Scroll::Policy> GetScrollbarPolicy() const
Return the display policy of horizontal and vertical scrollbars.
Return
std::tuple<Scroll::Policy, Scroll::Policy>void SetScrollElasticity(Scroll::Elasticity helasticity, Scroll::Elasticity velasticity) macOS
Set horizontal and vertical scroll elasticity (bounce).
Parameters
Scroll::Elasticityhelasticity - Horizontal scroll elasticity.Scroll::Elasticityvelasticity - Vertical scroll elasticity.
std::tuple<Scroll::Elasticity, Scroll::Elasticity> GetScrollElasticity() const macOS
Return the horizontal and vertical scroll elasticity.
Return
std::tuple<Scroll::Elasticity, Scroll::Elasticity>Events
void on_scroll(Scroll* self)
Emitted when the content view is being scrolled.
Parameters
Scroll*self