Table of Contents

Class ScrollBar

Namespace
RichHudFramework.UI
Assembly
RichHudClient.dll

A clickable scrollbar designed to approximate the appearance of standard Space Engineers scrollbars.

public class ScrollBar : HudElementBase, IReadOnlyHudElement, IReadOnlyHudNode, IReadOnlyHudParent, IClickableElement, IFocusableElement, IValueControl<float>, IValueControl
Inheritance
ScrollBar
Implements
Inherited Members

Examples

This example creates a horizontal ScrollBar with a Label attached to the bottom, whose horizontal offset is set by the slider.

var scrollLabel = new Label
{
    // Align top edge to to ScrollBar's bottom edge
    ParentAlignment = ParentAlignments.Bottom,
    BuilderMode = TextBuilderModes.Lined, // Multi-line text
    Text = "This label gets\ndragged by the slider."
};
var scrollBar = new ScrollBar(parent)
{
    Vertical = false,
    UnpaddedSize = new Vector2(300, 30f),
    // Keep text inside the left/right bounds
    Min = -150f + 0.5f * scrollLabel.TextBoard.TextSize.X,
    Max = 150f - 0.5f * scrollLabel.TextBoard.TextSize.X,
    Percent = 0.5f,
    SlideInput =
    {
        BarColor = Color.Pink,
        SliderColor = Color.Green,
        ToolTip = $"This {nameof(ScrollBar)} drags the text below."
    },
    // Drag text
    UpdateValueCallback = (obj, args) =>
    {
        var sender = (ScrollBar)obj;
        scrollLabel.Offset = new Vector2(sender.Value, 0f);
    }
};
scrollLabel.Register(scrollBar);

Constructors

ScrollBar()

public ScrollBar()

ScrollBar(HudParentBase)

public ScrollBar(HudParentBase parent)

Parameters

parent HudParentBase

Fields

SlideInput

The internal slider element functioning as the scrollbar.

public readonly SliderBar SlideInput

Field Value

SliderBar

Properties

FocusHandler

Interface used to manage the element's input focus state.

public IFocusHandler FocusHandler { get; }

Property Value

IFocusHandler

IsMousedOver

Indicates whether the cursor is currently over the scrollbar.

public override bool IsMousedOver { get; }

Property Value

bool

Max

The maximum allowable value.

public float Max { get; set; }

Property Value

float

Min

The minimum allowable value.

public float Min { get; set; }

Property Value

float

MouseInput

Mouse input interface for this clickable element.

public IMouseInput MouseInput { get; }

Property Value

IMouseInput

Percent

The current value expressed as a normalized value on [0, 1] of the range between Min and Max.

public float Percent { get; set; }

Property Value

float

UpdateValueCallback

Helper property for registering a value update callback during initialization.

public EventHandler UpdateValueCallback { set; }

Property Value

EventHandler

Value

The currently set value, clamped between Min and Max.

public float Value { get; set; }

Property Value

float

Vertical

Determines whether the scrollbar is oriented vertically. If true, the slider operates on the Y-axis.

True by default.

public bool Vertical { get; set; }

Property Value

bool

VisiblePercent

The proportion of the total range that is currently visible as a normalized value on [0, 1].

Automatically hides sliders if VisiblePercent >= 1f.

public float VisiblePercent { get; set; }

Property Value

float

Events

ValueChanged

Invoked when the scrollbar value changes.

public event EventHandler ValueChanged

Event Type

EventHandler