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
SizeF
void SetScrollPosition(float horizon, float vertical)
Scroll to the horizon
and vertical
position.
Parameters
float
horizonfloat
vertical
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>
macOS linux
void SetOverlayScrollbar(bool overlay)Set whether to use overlay scrolling.
Parameters
bool
overlay
macOS linux
bool IsOverlayScrollbar() constReturn whether overlay scrolling is used.
Return
bool
void SetScrollbarPolicy(Scroll::Policy hpolicy, Scroll::Policy vpolicy)
Set the policy for displaying horizontal and vertical scrollbars.
Parameters
Scroll::Policy
hpolicy - Policy for horizontal scrollbar.Scroll::Policy
vpolicy - 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>
macOS
void SetScrollElasticity(Scroll::Elasticity helasticity, Scroll::Elasticity velasticity)Set horizontal and vertical scroll elasticity (bounce).
Parameters
Scroll::Elasticity
helasticity - Horizontal scroll elasticity.Scroll::Elasticity
velasticity - Vertical scroll elasticity.
macOS
std::tuple<Scroll::Elasticity, Scroll::Elasticity> GetScrollElasticity() constReturn 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