StyleBox

Inherits: Resource < Reference < Object

继承人: StyleBoxEmptyStyleBoxFlatStyleBoxLineStyleBoxTexture

类别: 核心

简要说明

用于为UI绘制样式化框的基类。

方法

无效

draw ( RID canvas_item, Rect2 rect ) const

Vector2

get_center_size ( ) const

CanvasItem

get_current_item_drawn ( ) const

float

get_default_margin ( Margin margin ) const

float

get_margin ( Margin margin ) const

Vector2

get_minimum_size ( ) const

Vector2

get_offset ( ) const

无效

set_default_margin ( Margin margin, float offset )

bool

test_mask ( Vector2 point, Rect2 rect ) const

描述

样式框是 Resource 它提供了一个抽象基类,用于为UI绘制样式化的框。样式框用于绘制按钮、行编辑背景、树背景等的样式,还用于测试指针信号的透明蒙版。如果对指定为控件掩码的样式框进行掩码测试失败,则单击和运动信号将通过该样式框到达下面的样式框。

属性描述

  • float content_margin_bottom

违约

-1.0

设定器

设置默认值

吸气剂

获取默认值

此样式框内容的下边距。增加该值会从底部减少内容的可用空间。

如果该值为负数,则忽略该值,并使用子级特定的边距。例如 StyleBoxFlat 使用边框厚度(如果有)。

使用这个样式框决定这些内容是什么取决于代码:例如, Button 尊重按钮文本内容的此内容边距。

get_margin 应该用于作为使用者获取此值,而不是直接读取这些属性。这是因为它正确地尊重负值和上面提到的回退。

  • float content_margin_left

违约

-1.0

设定器

设置默认值

吸气剂

获取默认值

此样式框内容的左边距。增加该值会从左侧减少内容的可用空间。

参照 content_margin_bottom 额外考虑。

  • float content_margin_right

违约

-1.0

设定器

设置默认值

吸气剂

获取默认值

此样式框内容的右边距。增加该值会从右侧减少内容的可用空间。

参照 content_margin_bottom 额外考虑。

  • float content_margin_top

违约

-1.0

设定器

设置默认值

吸气剂

获取默认值

此样式框内容的上边距。增加该值将减少从顶部到内容的可用空间。

参照 content_margin_bottom 额外考虑。

方法说明

  • void draw ( RID canvas_item, Rect2 rect ) const

  • Vector2 get_center_size ( ) const

返回指定页边距的内容页边距偏移量。

正值向内减小大小,与 Control 的利润值。

  • Vector2 get_minimum_size ( ) const

返回可缩小此样式框的最小大小。

返回样式框的“偏移量”。此helper函数返回的值等于 Vector2(style.get_margin(MARGIN_LEFT), style.get_margin(MARGIN_TOP)) .

  • void set_default_margin ( Margin margin, float offset )

测试矩形中的位置,返回是否通过蒙版测试。