Class ScrollBar
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
- 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
AnchorThe scroll bar's anchor
size
Vector2The scroll bar's size
scrollerSize
intmaxValue
floathorizontal
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
Background
The background texture for this scroll bar
public StyleProp<NinePatch> Background
Field Value
Horizontal
Whether this scroll bar is horizontal
public readonly bool Horizontal
Field Value
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
OnAutoHide
An event that is called when this scroll bar is automatically hidden from a Panel
public Element.GenericCallback OnAutoHide
Field Value
OnValueChanged
An event that is called when CurrentValue changes
public ScrollBar.ValueChanged OnValueChanged
Field Value
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
SmoothScrollFactor
The factor with which SmoothScrolling happens.
public StyleProp<float> SmoothScrollFactor
Field Value
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
StepPerScroll
The amount added or removed from CurrentValue per single movement of the scroll wheel
public float StepPerScroll
Field Value
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
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
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
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
GameTimeThe game's time
batch
SpriteBatchThe sprite batch to use for drawing
alpha
floatThe alpha to draw this element and its children with
context
SpriteBatchContextThe 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
UiStyleThe new style
Update(GameTime)
Updates this element and all of its SortedChildren
public override void Update(GameTime time)
Parameters
time
GameTimeThe game's time