Class Banner
Definition
Namespace: StardewUI.Widgets
Assembly: StardewUI.dll
Draws banner-style text with an optional background.
Inheritance
Object ⇦ View ⇦ Banner
Remarks
This is very similar to a Label inside a Frame, but uses the special SpriteText font which is more prominent than any of the game's available SpriteFonts and often used for top-level headings/menu titles.
Members
Constructors
Name | Description |
---|---|
Banner() |
Properties
Name | Description |
---|---|
ActualBounds | The bounds of this view relative to the origin (0, 0). (Inherited from View) |
Background | Background sprite (including border) to draw underneath the text. |
BackgroundBorderThickness | The thickness of the border edges within the Background. sprite. |
BorderSize | The layout size (not edge thickness) of the entire drawn area including the border, i.e. the InnerSize plus any borders defined in GetBorderThickness(). Does not include the Margin. (Inherited from View) |
ClipOrigin | Origin position for the ClipSize. (Inherited from View) |
ClipSize | Size of the clipping rectangle, outside which content will not be displayed. (Inherited from View) |
ContentBounds | The true bounds of this view's content; i.e. ActualBounds excluding margins. (Inherited from View) |
ContentSize | The size of the view's content, which is drawn inside the padding. Subclasses set this in their OnMeasure(Vector2) method and padding, margins, etc. are handled automatically. (Inherited from View) |
Draggable | Whether or not this view should fire drag events such as DragStart and Drag. (Inherited from View) |
FloatingBounds | Contains the bounds of all floating elements in this view tree, including the current view and all descendants. (Inherited from View) |
FloatingElements | The floating elements to display relative to this view. (Inherited from View) |
Focusable | Whether or not the view should be able to receive focus. Applies only to this specific view, not its children. (Inherited from View) |
HandlesOpacity | Whether the specific view type handles its own opacity. (Inherited from View) |
InnerSize | The size allocated to the entire area inside the border, i.e. ContentSize plus any Padding. Does not include border or Margin. (Inherited from View) |
IsFocusable | Whether or not the view can receive controller focus, i.e. the stick/d-pad controlled cursor can move to this view. Not generally applicable for mouse controls. (Inherited from View) |
LastAvailableSize | The most recent size used in a Measure(Vector2) pass. Used for additional dirty checks. (Inherited from View) |
Layout | Layout settings for this view; determines how its dimensions will be computed. (Inherited from View) |
LayoutOffset | Pixel offset of the view's content, which is applied to all pointer events and child queries. (Inherited from View) |
Margin | Margins (whitespace outside border) for this view. (Inherited from View) |
Name | Simple name for this view, used in log/debug output; does not affect behavior. (Inherited from View) |
Opacity | Opacity (alpha level) of the view. (Inherited from View) |
OuterSize | The size of the entire area occupied by this view including margins, border and padding. (Inherited from View) |
Padding | Padding (whitespace inside border) for this view. (Inherited from View) |
PointerEventsEnabled | Whether this view should receive pointer events like Click or Drag. (Inherited from View) |
PointerStyle | Pointer style to use when this view is hovered. (Inherited from View) |
ScrollWithChildren | If set to an axis, specifies that when any child of the view is scrolled into view (using ScrollIntoView(IEnumerable<ViewChild>, Vector2)), then this entire view should be scrolled along with it. (Inherited from View) |
Tags | The user-defined tags for this view. (Inherited from View) |
Text | The text to display within the banner. |
TextShadowAlpha | Alpha value for the text shadow, per layer in ShadowLayers. |
TextShadowColor | Base color for the text shadow, before applying TextShadowAlpha. |
TextShadowLayers | Specifies which layers of the text shadow should be drawn. |
TextShadowOffset | Offset to draw the text shadow, which is a second copy of the Text drawn entirely black. Text shadows will not be visible unless TextShadowAlpha is non-zero. |
Tooltip | Localized tooltip to display on hover, if any. (Inherited from View) |
Transform | Local transformation to apply to this view, including any children and floating elements. (Inherited from View) |
TransformOrigin | Relative origin position for any Transform on this view. (Inherited from View) |
Visibility | Visibility for this view. (Inherited from View) |
ZIndex | Z order for this view within its direct parent. Higher indices draw later (on top). (Inherited from View) |
Methods
Name | Description |
---|---|
ContainsPoint(Vector2) | Checks if a given point, relative to the view's origin, is within its bounds. (Inherited from View) |
Dispose() | (Inherited from View) |
Draw(ISpriteBatch) | Draws the content for this view. (Inherited from View) |
FindFocusableDescendant(Vector2, Direction) | Searches for a focusable child within this view that is reachable in the specified direction , and returns a result containing the view and search path if found.(Inherited from View) |
FocusSearch(Vector2, Direction) | Finds the next focusable component in a given direction that does not overlap with a current position. (Inherited from View) |
GetBorderThickness() | Measures the thickness of each edge of the border, if the view has a border. (Overrides View.GetBorderThickness()) |
GetChildAt(Vector2, Boolean, Boolean) | Finds the child at a given position. (Inherited from View) |
GetChildPosition(IView) | Computes or retrieves the position of a given direct child. (Inherited from View) |
GetChildren(Boolean) | Gets the current children of this view. (Inherited from View) |
GetChildrenAt(Vector2) | Finds all children at a given position. (Inherited from View) |
GetDefaultFocusChild() | Gets the direct child that should contain cursor focus when a menu or overlay containing this view is first opened. (Inherited from View) |
GetLocalChildren() | Gets the view's children with positions relative to the content area. (Inherited from View) |
GetLocalChildrenAt(Vector2) | Searches for all views at a given position relative to the content area. (Inherited from View) |
HasOutOfBoundsContent() | Checks if the view has content or elements that are all or partially outside the ActualBounds. (Inherited from View) |
HasOwnContent() | Checks if this view displays its own content, independent of any floating elements or children. (Inherited from View) |
IsContentDirty() | Checks whether or not the internal content/layout has changed. (Overrides View.IsContentDirty()) |
IsDirty() | Checks whether or not the view is dirty - i.e. requires a new layout with a full Measure(Vector2). (Inherited from View) |
IsVisible(Vector2?) | Checks if the view is effectively visible, i.e. if it has anything to draw. (Inherited from View) |
LogFocusSearch(string) | Outputs a debug log entry with the current view type, name and specified message. (Inherited from View) |
Measure(Vector2) | Performs layout on this view, updating its OuterSize, ActualBounds and ContentBounds, and arranging any children in their respective positions. (Inherited from View) |
OnButtonPress(ButtonEventArgs) | Called when a button press is received while this view is in the focus path. (Inherited from View) |
OnButtonRepeat(ButtonEventArgs) | Called when a button press is first received, and at recurring intervals thereafter, for as long as the button is held and this view remains in the focus path. (Inherited from View) |
OnClick(ClickEventArgs) | Called when a click is received within this view's bounds. (Inherited from View) |
OnDispose() | Performs additional cleanup when Dispose() is called. (Inherited from View) |
OnDrag(PointerEventArgs) | Called when the view is being dragged (mouse moved while left button held). (Inherited from View) |
OnDrawBorder(ISpriteBatch) | Draws the view's border, if it has one. (Overrides View.OnDrawBorder(ISpriteBatch)) |
OnDrawContent(ISpriteBatch) | Draws the inner content of this view. (Overrides View.OnDrawContent(ISpriteBatch)) |
OnDrop(PointerEventArgs) | Called when the mouse button is released after at least one OnDrag(PointerEventArgs). (Inherited from View) |
OnMeasure(Vector2) | Performs the internal layout. (Overrides View.OnMeasure(Vector2)) |
OnPointerMove(PointerMoveEventArgs) | Called when a pointer movement related to this view occurs. (Inherited from View) |
OnPropertyChanged(PropertyChangedEventArgs) | Raises the PropertyChanged event. (Inherited from View) |
OnPropertyChanged(string) | Raises the PropertyChanged event. (Inherited from View) |
OnUpdate(TimeSpan) | Runs on every update tick. (Inherited from View) |
OnWheel(WheelEventArgs) | Called when a wheel event is received within this view's bounds. (Inherited from View) |
ResetDirty() | Resets any dirty state associated with this view. (Overrides View.ResetDirty()) |
ScrollIntoView(IEnumerable<ViewChild>, Vector2) | Attempts to scroll the specified target into view, including all of its ancestors, if not fully in view. (Inherited from View) |
ToString() | (Inherited from View) |
Events
Name | Description |
---|---|
ButtonPress | Event raised when any button on any input device is pressed. (Inherited from View) |
ButtonRepeat | Event raised when a button is being held while the view is in focus, and has been held long enough since the initial ButtonPress or the previous ButtonRepeat to trigger a repeated press.(Inherited from View) |
Click | Event raised when the view receives a click. (Inherited from View) |
Drag | Event raised when the view is being dragged using the mouse. (Inherited from View) |
DragEnd | Event raised when mouse dragging is stopped, i.e. when the button is released. Always raised after the last Drag, and only once per drag operation. (Inherited from View) |
DragStart | Event raised when mouse dragging is first activated. Always raised before the first Drag, and only once per drag operation. (Inherited from View) |
LeftClick | Event raised when the view receives a click initiated from the left mouse button, or the controller's action button (A). (Inherited from View) |
PointerEnter | Event raised when the pointer enters the view. (Inherited from View) |
PointerLeave | Event raised when the pointer exits the view. (Inherited from View) |
PointerMove | Event raised when the pointer moves within the view. (Inherited from View) |
PropertyChanged | (Inherited from View) |
RightClick | Event raised when the view receives a click initiated from the right mouse button, or the controller's tool-use button (X). (Inherited from View) |
Wheel | Event raised when the scroll wheel moves. (Inherited from View) |
Details
Constructors
Banner()
Properties
Background
Background sprite (including border) to draw underneath the text.
Property Value
BackgroundBorderThickness
The thickness of the border edges within the Background. sprite.
Property Value
Remarks
This property has no effect on the appearance of the Background, but affects how content is positioned inside the border. It is often correct to set it to the same value as the FixedEdges of the Background sprite, but the values are considered independent.
Text
The text to display within the banner.
Property Value
TextShadowAlpha
Alpha value for the text shadow, per layer in ShadowLayers.
Property Value
Remarks
If set to zero, no text shadow will be drawn.
TextShadowColor
Base color for the text shadow, before applying TextShadowAlpha.
Property Value
TextShadowLayers
Specifies which layers of the text shadow should be drawn.
Property Value
Remarks
Layers are additive, so the same TextShadowAlpha will have a different visual intensity depending on which layers are allowed. If set to None, then no shadow will be drawn.
TextShadowOffset
Offset to draw the text shadow, which is a second copy of the Text drawn entirely black. Text shadows will not be visible unless TextShadowAlpha is non-zero.
Property Value
Methods
GetBorderThickness()
Measures the thickness of each edge of the border, if the view has a border.
Returns
The border edge thicknesses.
Remarks
Used only by views that will implement a border via OnDrawBorder(ISpriteBatch). The border thickness is considered during layout, and generally treated as additional Padding for the purposes of setting allowed content size.
Borders usually have a static size, but if the thickness can change, then implementations must account for it in their dirty checking (IsContentDirty()).
IsContentDirty()
Checks whether or not the internal content/layout has changed.
Returns
true
if content has changed; otherwise false
.
Remarks
The base implementation of IsDirty() only checks if the base layout attributes have changed, i.e. Layout, Margin, Padding, etc. It does not know about content/data in any subclasses; those that accept content parameters (like text) will typically use DirtyTracker<T> to hold that content and should implement this method to check their IsDirty states.
OnDrawBorder(ISpriteBatch)
Draws the view's border, if it has one.
Parameters
b
ISpriteBatch
Sprite batch to hold the drawing output.
Remarks
This is called from Draw(ISpriteBatch) after applying Margin but before Padding.
OnDrawContent(ISpriteBatch)
Draws the inner content of this view.
Parameters
b
ISpriteBatch
Sprite batch to hold the drawing output.
Remarks
This is called from Draw(ISpriteBatch) after applying both Margin and Padding.
OnMeasure(Vector2)
Performs the internal layout.
Parameters
availableSize
Vector2
Size available in the container, after applying padding, margin and borders.
Remarks
This is called from Measure(Vector2) only when the layout is dirty (layout parameters or content changed) and a new layout is actually required. Subclasses must implement this and set ContentSize once layout is complete. Typically, Resolve(Vector2, Func<Vector2>) should be used in order to ensure that the original LayoutParameters are respected (e.g. if the actual content size is smaller than the configured size).
The availableSize
provided to the method is pre-adjusted for Margin, Padding, and any border determined by GetBorderThickness().
ResetDirty()
Resets any dirty state associated with this view.
Remarks
This is called at the end of Measure(Vector2), so that on the next pass, all state appears clean unless it was marked dirty after the last pass completed. The default implementation is a no-op; subclasses should use it to clear any private dirty state, e.g. via ResetDirty().