Table of Contents

Class ScrollBar

Namespace
MLEM.Ui.Elements
Assembly
MLEM.Ui.dll

A scroll bar element to be used inside of a UiSystem. A scroll bar is an element that features a smaller scroller indicator inside of it that can move up and down. A scroll bar can be scrolled using the mouse or by using the scroll wheel while hovering over its Parent or any of its siblings.

public class ScrollBar : Element, IGenericDataHolder, IDisposable
Inheritance
ScrollBar
Implements
Derived
Inherited Members
Extension Methods

Constructors

ScrollBar(Anchor, Vector2, int, float, bool)

Creates a new scroll bar with the given settings

public ScrollBar(Anchor anchor, Vector2 size, int scrollerSize, float maxValue, bool horizontal = false)

Parameters

anchor Anchor

The scroll bar's anchor

size Vector2

The scroll bar's size

scrollerSize int
maxValue float
horizontal bool

Fields

AutoHideWhenEmpty

This field determines if this scroll bar should automatically be hidden from a Panel if there aren't enough children to allow for scrolling.

public bool AutoHideWhenEmpty

Field Value

bool

Background

The background texture for this scroll bar

public StyleProp<NinePatch> Background

Field Value

StyleProp<NinePatch>

Horizontal

Whether this scroll bar is horizontal

public readonly bool Horizontal

Field Value

bool

MouseDragScrolling

Whether this scroll bar should allow dragging the mouse over its attached Panel's content while holding the left mouse button to scroll, similarly to how scrolling using touch input works.

public bool MouseDragScrolling

Field Value

bool

OnAutoHide

An event that is called when this scroll bar is automatically hidden from a Panel

public Element.GenericCallback OnAutoHide

Field Value

Element.GenericCallback

OnValueChanged

An event that is called when CurrentValue changes

public ScrollBar.ValueChanged OnValueChanged

Field Value

ScrollBar.ValueChanged

ScrollerSize

The scroller's width and height

public Vector2 ScrollerSize

Field Value

Vector2

ScrollerTexture

The texture of this scroll bar's scroller indicator

public StyleProp<NinePatch> ScrollerTexture

Field Value

StyleProp<NinePatch>

SmoothScrollFactor

The factor with which SmoothScrolling happens.

public StyleProp<float> SmoothScrollFactor

Field Value

StyleProp<float>

SmoothScrolling

Whether smooth scrolling should be enabled for this scroll bar. Smooth scrolling causes the CurrentValue to change gradually rather than instantly when scrolling.

public StyleProp<bool> SmoothScrolling

Field Value

StyleProp<bool>

StepPerScroll

The amount added or removed from CurrentValue per single movement of the scroll wheel

public float StepPerScroll

Field Value

float

Properties

CurrentValue

The current value of the scroll bar. This is between 0 and MaxValue at all times.

public float CurrentValue { get; set; }

Property Value

float

IsBeingScrolled

This property is true while the user scrolls on the scroll bar using the mouse or touch input

public bool IsBeingScrolled { get; }

Property Value

bool

MaxValue

The max value that this scroll bar should be able to scroll to. Note that the maximum value does not change the height of the scroll bar.

public float MaxValue { get; set; }

Property Value

float

ScrollerPosition

The position that this scroll bar's scroller is currently at. This value takes the DisplayArea, as well as the Scale into account.

public Vector2 ScrollerPosition { get; }

Property Value

Vector2

Methods

Draw(GameTime, SpriteBatch, float, SpriteBatchContext)

Draws this element and all of its children. Override this method to draw the content of custom elements. Note that, when this is called, SpriteBatch.Begin has already been called with custom Transform etc. applied.

public override void Draw(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context)

Parameters

time GameTime

The game's time

batch SpriteBatch

The sprite batch to use for drawing

alpha float

The alpha to draw this element and its children with

context SpriteBatchContext

The sprite batch context to use for drawing

InitStyle(UiStyle)

Initializes this element's StyleProp<T> instances using the ui system's UiStyle.

protected override void InitStyle(UiStyle style)

Parameters

style UiStyle

The new style

Update(GameTime)

Updates this element and all of its SortedChildren

public override void Update(GameTime time)

Parameters

time GameTime

The game's time