UDreamScrollBar
A scroll bar whose hierarchy is code, not an asset.
本页由 DreamGUIReferenceDocs commandlet 从反射生成,正文是头文件注释的原文(英文),所以不翻译——这样它永远和代码一致。概念讲解见核心概念。
Inherits from UDreamUIControl.
Declared in Public/Controls/DreamScrollBar.h.
A scroll bar whose hierarchy is code, not an asset.
Two nodes: a track, and a handle inside it. BP_HorizontalScrollbar and BP_VerticalScrollbar are two assets because an asset cannot branch on a property; this is one control because code can, and Direction is the only thing they disagreed about. The handle's parent IS the track, which is what the behaviour measures the value against -- a scroll bar handle rides the whole track (unlike a slider's, which is inset by its own size), because its LENGTH already shrinks the travel.
WHAT THIS CLASS STOPPED DOING
It used to carry a UUIScrollbar SUBCLASS and re-place the handle itself, because the component
wrote ratio anchors and exposed neither Handle nor DirectionType to anything but a details panel.
All three of those are fixed at the source now: UUIScrollbar places the handle with absolute
geometry, takes both writes through public setters, and owns the minimum-length floor together
with the drag scale it has to agree with. What is left here is what a control is for -- style,
properties a designer and a <-> binding can reach, and the link to a scroll view.
A bar with no scroll view is a value control in its own right: its value is a position from 0 to 1 and HandleSize is how much of the track the handle covers. Point it at a UUIScrollView and both numbers become the view's -- progress in, progress out -- which is how the standalone bar drives a scroll box.
Clicking the track off the handle puts the handle's CENTRE where the track was clicked, clamped to the ends, and a drag from that press carries on from there -- SScrollBar's behaviour. Until this was checked against the 5.8 source a track click paged one handle length toward the pointer (Unity's behaviour), so existing screens now jump where they used to step.
Neither the track nor the arrows are a place the pad's navigation lands or Tab stops, which is how SScrollBar behaves: the track's UUIScrollbar starts with bCanNavigateHere off (see its class comment) and the arrows are made the same in WireParts. The keys and the stick scroll whatever the bar follows through the focused control instead.
Properties
| Name | Type | Category | In the details panel | From Blueprint | Description |
|---|---|---|---|---|---|
Style | FDreamScrollBarStyle | Scroll Bar | yes | GetStyle / SetStyle | This instance's own look. The project sheet wins while StyleSource says so AND a sheet actually exists; with no sheet in the project this IS the look in effect. A scroll box overwrites it wholesale with its own style's Bar, so one style edit dresses the box and its bar together. |
Direction | EUIScrollbarDirectionType | Scroll Bar | yes | GetDirection / SetDirection | Which way it runs, and which end is zero. One property instead of two Blueprint assets. |
Value | float | Scroll Bar | yes | GetValue / SetValue | Authored position in; mirror of the behaviour's out. A property so .dui and bindings can see it. |
HandleSize | float | Scroll Bar | yes | GetHandleSize / SetHandleSize | How much of the track the handle covers, 0 to 1 -- the visible fraction of whatever is being scrolled. A bar attached to a scroll view has this rewritten from the view on every push; a quarter is what a bare bar shows so it reads as a bar and not as a filled rail. |
bAlwaysShowScrollbar | bool | Scroll Bar | yes | GetAlwaysShowScrollbar / SetAlwaysShowScrollbar | Whether the bar stays put with nothing to scroll -- UMG's bAlwaysShowScrollbar. |
bAlwaysShowScrollbarTrack | bool | Scroll Bar | yes | GetAlwaysShowScrollbarTrack / SetAlwaysShowScrollbarTrack | Whether the TRACK survives the bar hiding itself -- UMG's bAlwaysShowScrollbarTrack, and the groove a desktop scroll bar leaves behind when its thumb has nothing to say. |
MinHandleLength | float | Scroll Bar | yes | GetMinHandleLength / SetMinHandleLength | Floor on the handle's drawn length, in local units. Pushed into the behaviour, which applies it to the drawn length and to the drag scale together -- a handle drawn longer than the fraction it drags with would run at the wrong rate for the whole of a long list. |
NavigationChangeInterval | float | Scroll Bar | yes | GetNavigationChangeInterval / SetNavigationChangeInterval | How far one navigation press moves the value. |
bShowArrows | bool | Scroll Bar | yes | GetShowArrows / SetShowArrows | A step button at each end of the track -- the desktop scroll bar's arrows. |
ArrowStepSize | float | Scroll Bar | yes | GetArrowStepSize / SetArrowStepSize | How far one arrow click moves the value, as a fraction of the whole range. |
AcceptedMouseButtons | int32 | Scroll Bar | yes | GetAcceptedMouseButtons / SetAcceptedMouseButtons | WHICH mouse buttons move this bar -- a bitmask over EDreamUIMouseButtonType, the left button alone by default, which is SScrollBar's rule: its OnMouseButtonDown answers EKeys::LeftMouseButton and nothing else, so a right drag on the handle or a right click on the track leaves the bar where it is and goes on to whatever is behind it. The two arrows answer the same buttons. |
TrackNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | |
HandleNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | |
BarBehaviour | TObjectPtr<UUIScrollbar> | Scroll Bar | - | read only | |
ArrowStartNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | The step buttons. Present in the built-in tree and asleep until bShowArrows wakes them. |
ArrowEndNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | |
ArrowStartGlyphNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | |
ArrowEndGlyphNode | TObjectPtr<UDreamWidget> | Scroll Bar | - | read only | |
ArrowStartBehaviour | TObjectPtr<UUIButton> | Scroll Bar | - | read only | |
ArrowEndBehaviour | TObjectPtr<UUIButton> | Scroll Bar | - | read only |
Functions
| Function | Kind | Description |
|---|---|---|
int32 GetAcceptedMouseButtons() | pure | Get Accepted Mouse Buttons |
bool GetAlwaysShowScrollbar() | pure | Get Always Show Scrollbar |
bool GetAlwaysShowScrollbarTrack() | pure | Get Always Show Scrollbar Track |
float GetArrowStepSize() | pure | Get Arrow Step Size |
EUIScrollbarDirectionType GetDirection() | pure | Get Direction |
float GetHandleSize() | pure | Get Handle Size |
float GetMinHandleLength() | pure | Get Min Handle Length |
float GetNavigationChangeInterval() | pure | Get Navigation Change Interval |
UUIScrollView* GetScrollView() | pure | Get Scroll View |
bool GetShowArrows() | pure | Get Show Arrows |
FDreamScrollBarStyle GetStyle() | pure | By value, not by reference: a UFUNCTION return has to be a value, and a style is a small struct. |
float GetValue() | pure | Get Value |
bool IsHorizontal() | pure | True for LeftToRight and RightToLeft. Everything axis-dependent in here asks this. |
void RefreshFromScrollView() | callable | Take position and visible fraction from the attached view. Called for you whenever it moves. |
void SetAcceptedMouseButtons(int32 InAcceptedMouseButtons) | callable | Writes the bitmask and pushes it onto the bar's behaviours at once -- the next press consults it. |
void SetAlwaysShowScrollbar(bool bInAlwaysShow) | callable | Set Always Show Scrollbar |
void SetAlwaysShowScrollbarTrack(bool bInAlwaysShow) | callable | Set Always Show Scrollbar Track |
void SetArrowStepSize(float InStep) | callable | Set Arrow Step Size |
void SetDirection(EUIScrollbarDirectionType InDirection) | callable | Which way it runs decides the whole rect, so this is a style push and not a field write. |
void SetHandleSize(float InFraction) | callable | Set Handle Size |
void SetMinHandleLength(float InLength) | callable | Set Min Handle Length |
void SetNavigationChangeInterval(float InInterval) | callable | Set Navigation Change Interval |
void SetScrollView(UUIScrollView* InView) | callable | Drive a scroll view with this bar, both ways. |
void SetShowArrows(bool bInShowArrows) | callable | Wakes or sleeps the arrows AND re-insets the track, which is why it is a whole style push. |
void SetState(float InOffsetFraction, float InThumbSizeFraction, bool bInCollapseIfNecessary) | callable | Position and visible fraction in one call -- UMG's SetState, and the shape a scroll view actually pushes: the two numbers always move together, and writing them one at a time lays the handle out twice for one change. |
void SetStyle(FDreamScrollBarStyle InStyle) | callable | Replace the whole look and re-push it -- thickness and margin are geometry, not paint. |
void SetValue(float InValue) | callable | Set Value |
void SetValueWithoutNotify(float InValue) | callable | For a follower: moves the handle without telling anyone, so a two-way link cannot ring. |
Events
| Event | Signature | Description |
|---|---|---|
OnValueChanged | void DreamScrollBarValueChangedEvent__DelegateSignature(float Value) | Re-broadcast from the behaviour, so a consumer binds to the control, not to a part of it. |
OnValueChangedBP | void DreamScrollBarValueChangedEvent__DelegateSignature(float Value) | The <-> convention: two-way bindings synthesize their reverse route against this exact name, so a value control carries it alongside its spoken events. Fires with them. |
Compared with UMG
Every Blueprint-facing member of the UMG class, and where it went. adopt: same name, same meaning. map: here under another name or on another type. reject: deliberately absent, with the reason.
| UMG | Member | Status | Here | Note |
|---|---|---|---|---|
UScrollBar | WidgetStyle | map | Style | FDreamScrollBarStyle, resolved against the project style sheet. Get/SetStyle. |
UScrollBar | bAlwaysShowScrollbar | adopt | bAlwaysShowScrollbar | Default true, not UMG's false: this bar has always drawn whatever it was placed into, and a screen whose bar vanished the moment its list fitted would be a layout that changed under everyone. Only a bar attached to a scroll view can hide itself -- a bare bar is a value control with no 'nothing to scroll' state. |
UScrollBar | bAlwaysShowScrollbarTrack | adopt | bAlwaysShowScrollbarTrack | Keeps the bar on screen with its handle asleep. Only consulted while bAlwaysShowScrollbar is off and the attached view fits. |
UScrollBar | Orientation | map | Direction | EUIScrollbarDirectionType, which says which way it runs AND which end is zero -- four answers where UMG's EOrientation has two. Get/SetDirection. |
UScrollBar | Thickness | map | FDreamScrollBarStyle::Thickness | In the style, because it is what the bar is drawn from. A float: a bar has one thickness across its own axis, and its length is whatever it is scrolling. |
UScrollBar | Padding | map | FDreamScrollBarStyle::BarPadding | New style field, default FMargin(0) = what every bar has drawn. Spent on the bar's rect, not the track's, so the track still reaches both ends of what the bar spans. |
UScrollBar | SetState | adopt | SetState | Position and visible fraction in one call, which is the shape a scroll view actually pushes: writing them one at a time lays the handle out twice for one change. The pointer moves the position only with the mouse buttons in AcceptedMouseButtons -- the left one alone by default, which is SScrollBar's rule (its OnMouseButtonDown tests EKeys::LeftMouseButton); AcceptedMouseButtons is this control's own knob, as on UDreamButton, and a touch always counts. A click on the track off the handle puts the handle's centre there, as SScrollBar's ExecuteOnUserScrolled does, rather than paging. |