mirror of
https://github.com/godotengine/godot
synced 2024-09-05 23:00:58 +00:00
Merge pull request #30062 from zaksnet/fix-referencerect-node
Adds ReferenceRect an option to be visible inside the game
This commit is contained in:
commit
82604195b4
|
@ -4,7 +4,7 @@
|
||||||
Reference frame for GUI.
|
Reference frame for GUI.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
Reference frame for GUI. It's just like an empty control, except an outline border [member border_color] is displayed while editing around its size at all times.
|
A rectangle box that displays only a [member border_color] border color around its rectangle. [ReferenceRect] has no fill [Color].
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
|
@ -12,7 +12,10 @@
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="border_color" type="Color" setter="set_border_color" getter="get_border_color">
|
<member name="border_color" type="Color" setter="set_border_color" getter="get_border_color">
|
||||||
Determines the border [Color] of the [ReferenceRect].
|
Sets the border [Color] of the [ReferenceRect].
|
||||||
|
</member>
|
||||||
|
<member name="editor_only" type="bool" setter="set_editor_only" getter="get_editor_only">
|
||||||
|
If set to [code]true[/code], the [ReferenceRect] will only be visible while in editor. Otherwise, [ReferenceRect] will be visible in game.
|
||||||
</member>
|
</member>
|
||||||
</members>
|
</members>
|
||||||
<constants>
|
<constants>
|
||||||
|
|
|
@ -38,26 +38,41 @@ void ReferenceRect::_notification(int p_what) {
|
||||||
|
|
||||||
if (!is_inside_tree())
|
if (!is_inside_tree())
|
||||||
return;
|
return;
|
||||||
if (Engine::get_singleton()->is_editor_hint())
|
if (Engine::get_singleton()->is_editor_hint() || !editor_only)
|
||||||
draw_rect(Rect2(Point2(), get_size()), border_color, false);
|
draw_rect(Rect2(Point2(), get_size()), border_color, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReferenceRect::set_border_color(const Color &color) {
|
void ReferenceRect::set_border_color(const Color &p_color) {
|
||||||
border_color = color;
|
border_color = p_color;
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Color ReferenceRect::get_border_color() const {
|
Color ReferenceRect::get_border_color() const {
|
||||||
return border_color;
|
return border_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReferenceRect::set_editor_only(const bool &p_enabled) {
|
||||||
|
editor_only = p_enabled;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReferenceRect::get_editor_only() const {
|
||||||
|
return editor_only;
|
||||||
|
}
|
||||||
|
|
||||||
void ReferenceRect::_bind_methods() {
|
void ReferenceRect::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_border_color"), &ReferenceRect::get_border_color);
|
ClassDB::bind_method(D_METHOD("get_border_color"), &ReferenceRect::get_border_color);
|
||||||
ClassDB::bind_method(D_METHOD("set_border_color", "color"), &ReferenceRect::set_border_color);
|
ClassDB::bind_method(D_METHOD("set_border_color", "color"), &ReferenceRect::set_border_color);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_editor_only"), &ReferenceRect::get_editor_only);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_editor_only", "enabled"), &ReferenceRect::set_editor_only);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color");
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "border_color"), "set_border_color", "get_border_color");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "get_editor_only");
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceRect::ReferenceRect() {
|
ReferenceRect::ReferenceRect() {
|
||||||
border_color = Color(1, 0, 0);
|
border_color = Color(1, 0, 0);
|
||||||
|
editor_only = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ class ReferenceRect : public Control {
|
||||||
|
|
||||||
GDCLASS(ReferenceRect, Control);
|
GDCLASS(ReferenceRect, Control);
|
||||||
Color border_color;
|
Color border_color;
|
||||||
|
bool editor_only;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -45,8 +46,11 @@ protected:
|
||||||
public:
|
public:
|
||||||
ReferenceRect();
|
ReferenceRect();
|
||||||
|
|
||||||
void set_border_color(const Color &color);
|
void set_border_color(const Color &p_color);
|
||||||
Color get_border_color() const;
|
Color get_border_color() const;
|
||||||
|
|
||||||
|
void set_editor_only(const bool &p_enabled);
|
||||||
|
bool get_editor_only() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REFERENCE_RECT_H
|
#endif // REFERENCE_RECT_H
|
||||||
|
|
Loading…
Reference in a new issue