Documentation
¶
Overview ¶
StyleBox is an abstract base class for drawing stylized boxes for UI elements. It is used for panels, buttons, LineEdit backgrounds, Tree backgrounds, etc. and also for testing a transparency mask for pointer signals. If mask test fails on a StyleBox assigned as mask to a control, clicks and motion signals will go through it to the one below.
Note: For control nodes that have Theme Properties, the focus StyleBox is displayed over the normal, hover or pressed StyleBox. This makes the focus StyleBox more reusable across different nodes.
Index ¶
- type Advanced
- type Any
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AsStyleBox() Instance
- func (self Instance) ContentMarginBottom() Float.X
- func (self Instance) ContentMarginLeft() Float.X
- func (self Instance) ContentMarginRight() Float.X
- func (self Instance) ContentMarginTop() Float.X
- func (self Instance) Draw(peer CanvasItem.Instance, rect Rect2.PositionSize)
- func (self Instance) GetCurrentItemDrawn() CanvasItem.Instance
- func (self Instance) GetMargin(margin Rect2.Side) Float.X
- func (self Instance) GetMinimumSize() Vector2.XY
- func (self Instance) GetOffset() Vector2.XY
- func (self Instance) ID() ID
- func (self Instance) SetContentMarginAll(offset Float.X)
- func (self Instance) SetContentMarginBottom(value Float.X)
- func (self Instance) SetContentMarginLeft(value Float.X)
- func (self Instance) SetContentMarginRight(value Float.X)
- func (self Instance) SetContentMarginTop(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) TestMask(point Vector2.XY, rect Rect2.PositionSize) bool
- func (self Instance) Virtual(name string) reflect.Value
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
func (*Extension[T]) AsStyleBox ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) AsStyleBox ¶
func (Instance) ContentMarginBottom ¶
The bottom margin for the contents of this style box. Increasing this value reduces the space available to the contents from the bottom.
If this value is negative, it is ignored and a child-specific margin is used instead. For example, for StyleBoxFlat, the border thickness (if any) is used instead.
It is up to the code using this style box to decide what these contents are: for example, a Button respects this content margin for the textual contents of the button.
GetMargin should be used to fetch this value as consumer instead of reading these properties directly. This is because it correctly respects negative values and the fallback mentioned above.
func (Instance) ContentMarginLeft ¶
The left margin for the contents of this style box. Increasing this value reduces the space available to the contents from the left.
Refer to ContentMarginBottom for extra considerations.
func (Instance) ContentMarginRight ¶
The right margin for the contents of this style box. Increasing this value reduces the space available to the contents from the right.
Refer to ContentMarginBottom for extra considerations.
func (Instance) ContentMarginTop ¶
The top margin for the contents of this style box. Increasing this value reduces the space available to the contents from the top.
Refer to ContentMarginBottom for extra considerations.
func (Instance) Draw ¶
func (self Instance) Draw(peer CanvasItem.Instance, rect Rect2.PositionSize)
Draws a styled rectangle. The [param rect] is defined in local space.
func (Instance) GetCurrentItemDrawn ¶
func (self Instance) GetCurrentItemDrawn() CanvasItem.Instance
Returns the CanvasItem that handles its [Canvasitem.NotificationDraw] or CanvasItem.Draw callback at this moment.
func (Instance) GetMargin ¶
Returns the content margin offset for the specified [Side].
Positive values reduce size inwards, unlike Control's margin values.
func (Instance) GetMinimumSize ¶
Returns the minimum size that this stylebox can be shrunk to.
func (Instance) GetOffset ¶
Returns the "offset" of a stylebox. This helper function returns a value equivalent to Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP)).
func (Instance) SetContentMarginAll ¶
Sets the default margin to 'offset' pixels for all sides.
func (Instance) SetContentMarginBottom ¶
SetContentMarginBottom sets the property returned by [GetContentMargin].
func (Instance) SetContentMarginLeft ¶
SetContentMarginLeft sets the property returned by [GetContentMargin].
func (Instance) SetContentMarginRight ¶
SetContentMarginRight sets the property returned by [GetContentMargin].
func (Instance) SetContentMarginTop ¶
SetContentMarginTop sets the property returned by [GetContentMargin].
type Interface ¶
type Interface interface { Draw(to_canvas_item RID.CanvasItem, rect Rect2.PositionSize) GetDrawRect(rect Rect2.PositionSize) Rect2.PositionSize // Virtual method to be implemented by the user. Returns a custom minimum size that the stylebox must respect when drawing. By default [GetMinimumSize] only takes content margins into account. This method can be overridden to add another size restriction. A combination of the default behavior and the output of this method will be used, to account for both sizes. // // [GetMinimumSize]: https://pkg.go.dev/graphics.gd/classdb/StyleBox#Instance.GetMinimumSize GetMinimumSize() Vector2.XY TestMask(point Vector2.XY, rect Rect2.PositionSize) bool }