0.2.0-dev Download ZIP
125 lines ·6.6 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="StyleBox" inherits="Resource" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Abstract base class for defining stylized boxes for UI elements. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | [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. |
| 8 | [b]Note:[/b] For control nodes that have [i]Theme Properties[/i], the [code]focus[/code] [StyleBox] is displayed over the [code]normal[/code], [code]hover[/code] or [code]pressed[/code] [StyleBox]. This makes the [code]focus[/code] [StyleBox] more reusable across different nodes. |
| 9 | </description> |
| 10 | <tutorials> |
| 11 | </tutorials> |
| 12 | <methods> |
| 13 | <method name="_draw" qualifiers="virtual required const"> |
| 14 | <return type="void" /> |
| 15 | <param index="0" name="to_canvas_item" type="RID" /> |
| 16 | <param index="1" name="rect" type="Rect2" /> |
| 17 | <description> |
| 18 | </description> |
| 19 | </method> |
| 20 | <method name="_get_draw_rect" qualifiers="virtual const"> |
| 21 | <return type="Rect2" /> |
| 22 | <param index="0" name="rect" type="Rect2" /> |
| 23 | <description> |
| 24 | </description> |
| 25 | </method> |
| 26 | <method name="_get_minimum_size" qualifiers="virtual const"> |
| 27 | <return type="Vector2" /> |
| 28 | <description> |
| 29 | Virtual method to be implemented by the user. Returns a custom minimum size that the stylebox must respect when drawing. By default [method get_minimum_size] 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. |
| 30 | </description> |
| 31 | </method> |
| 32 | <method name="_test_mask" qualifiers="virtual const"> |
| 33 | <return type="bool" /> |
| 34 | <param index="0" name="point" type="Vector2" /> |
| 35 | <param index="1" name="rect" type="Rect2" /> |
| 36 | <description> |
| 37 | </description> |
| 38 | </method> |
| 39 | <method name="draw" qualifiers="const"> |
| 40 | <return type="void" /> |
| 41 | <param index="0" name="canvas_item" type="RID" /> |
| 42 | <param index="1" name="rect" type="Rect2" /> |
| 43 | <description> |
| 44 | Draws this stylebox using a canvas item identified by the given [RID]. |
| 45 | The [RID] value can either be the result of [method CanvasItem.get_canvas_item] called on an existing [CanvasItem]-derived node, or directly from creating a canvas item in the [RenderingServer] with [method RenderingServer.canvas_item_create]. |
| 46 | </description> |
| 47 | </method> |
| 48 | <method name="get_content_margin" qualifiers="const"> |
| 49 | <return type="float" /> |
| 50 | <param index="0" name="margin" type="int" enum="Side" /> |
| 51 | <description> |
| 52 | Returns the default margin of the specified [enum Side]. |
| 53 | </description> |
| 54 | </method> |
| 55 | <method name="get_current_item_drawn" qualifiers="const"> |
| 56 | <return type="CanvasItem" /> |
| 57 | <description> |
| 58 | Returns the [CanvasItem] that handles its [constant CanvasItem.NOTIFICATION_DRAW] or [method CanvasItem._draw] callback at this moment. |
| 59 | </description> |
| 60 | </method> |
| 61 | <method name="get_margin" qualifiers="const"> |
| 62 | <return type="float" /> |
| 63 | <param index="0" name="margin" type="int" enum="Side" /> |
| 64 | <description> |
| 65 | Returns the content margin offset for the specified [enum Side]. |
| 66 | Positive values reduce size inwards, unlike [Control]'s margin values. |
| 67 | </description> |
| 68 | </method> |
| 69 | <method name="get_minimum_size" qualifiers="const"> |
| 70 | <return type="Vector2" /> |
| 71 | <description> |
| 72 | Returns the minimum size that this stylebox can be shrunk to. |
| 73 | </description> |
| 74 | </method> |
| 75 | <method name="get_offset" qualifiers="const"> |
| 76 | <return type="Vector2" /> |
| 77 | <description> |
| 78 | Returns the "offset" of a stylebox. This helper function returns a value equivalent to [code]Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP))[/code]. |
| 79 | </description> |
| 80 | </method> |
| 81 | <method name="set_content_margin"> |
| 82 | <return type="void" /> |
| 83 | <param index="0" name="margin" type="int" enum="Side" /> |
| 84 | <param index="1" name="offset" type="float" /> |
| 85 | <description> |
| 86 | Sets the default value of the specified [enum Side] to [param offset] pixels. |
| 87 | </description> |
| 88 | </method> |
| 89 | <method name="set_content_margin_all"> |
| 90 | <return type="void" /> |
| 91 | <param index="0" name="offset" type="float" /> |
| 92 | <description> |
| 93 | Sets the default margin to [param offset] pixels for all sides. |
| 94 | </description> |
| 95 | </method> |
| 96 | <method name="test_mask" qualifiers="const"> |
| 97 | <return type="bool" /> |
| 98 | <param index="0" name="point" type="Vector2" /> |
| 99 | <param index="1" name="rect" type="Rect2" /> |
| 100 | <description> |
| 101 | Test a position in a rectangle, return whether it passes the mask test. |
| 102 | </description> |
| 103 | </method> |
| 104 | </methods> |
| 105 | <members> |
| 106 | <member name="content_margin_bottom" type="float" setter="set_content_margin" getter="get_content_margin" default="-1.0"> |
| 107 | The bottom margin for the contents of this style box. Increasing this value reduces the space available to the contents from the bottom. |
| 108 | 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. |
| 109 | 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. |
| 110 | [method get_margin] 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. |
| 111 | </member> |
| 112 | <member name="content_margin_left" type="float" setter="set_content_margin" getter="get_content_margin" default="-1.0"> |
| 113 | The left margin for the contents of this style box. Increasing this value reduces the space available to the contents from the left. |
| 114 | Refer to [member content_margin_bottom] for extra considerations. |
| 115 | </member> |
| 116 | <member name="content_margin_right" type="float" setter="set_content_margin" getter="get_content_margin" default="-1.0"> |
| 117 | The right margin for the contents of this style box. Increasing this value reduces the space available to the contents from the right. |
| 118 | Refer to [member content_margin_bottom] for extra considerations. |
| 119 | </member> |
| 120 | <member name="content_margin_top" type="float" setter="set_content_margin" getter="get_content_margin" default="-1.0"> |
| 121 | The top margin for the contents of this style box. Increasing this value reduces the space available to the contents from the top. |
| 122 | Refer to [member content_margin_bottom] for extra considerations. |
| 123 | </member> |
| 124 | </members> |
| 125 | </class> |