Scroll

Show a part of view with scrollbar.

Header#include "nativeui/scroll.h"
Namespacenamespace nu
Typeclass (RefCounted)
InheritsView

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

View* GetContentView() const

Return the content view.

Return

View*

void SetContentSize(const SizeF& size)

Set the size of content view.

Parameters

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

std::tuple<float, float> GetScrollPosition() const

Return the horizon and vertical scroll position.

Return

std::tuple

std::tuple<float, float> GetMaximumScrollPosition() const

Return the maximum horizon and vertical scroll position.

Return

std::tuple

void SetOverlayScrollbar(bool overlay) macOS linux

Set whether to use overlay scrolling.

Parameters

bool IsOverlayScrollbar() const macOS linux

Return 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

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

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

Preventable

No.