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
parentHudParentBase
Fields
SlideInput
The internal slider element functioning as the scrollbar.
public readonly SliderBar SlideInput
Field Value
Properties
FocusHandler
Interface used to manage the element's input focus state.
public IFocusHandler FocusHandler { get; }
Property Value
IsMousedOver
Indicates whether the cursor is currently over the scrollbar.
public override bool IsMousedOver { get; }
Property Value
Max
The maximum allowable value.
public float Max { get; set; }
Property Value
Min
The minimum allowable value.
public float Min { get; set; }
Property Value
MouseInput
Mouse input interface for this clickable element.
public IMouseInput MouseInput { get; }
Property Value
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
UpdateValueCallback
Helper property for registering a value update callback during initialization.
public EventHandler UpdateValueCallback { set; }
Property Value
Value
public float Value { get; set; }
Property Value
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
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
Events
ValueChanged
Invoked when the scrollbar value changes.
public event EventHandler ValueChanged