mirror of
https://github.com/godotengine/godot.git
synced 2025-02-16 15:50:45 +00:00
Make NinePatchRect
listen to texture changes
This commit is contained in:
parent
217a20a8a0
commit
4492f7ff97
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "nine_patch_rect.h"
|
#include "nine_patch_rect.h"
|
||||||
|
|
||||||
|
#include "core/core_string_names.h"
|
||||||
#include "scene/scene_string_names.h"
|
#include "scene/scene_string_names.h"
|
||||||
#include "servers/rendering_server.h"
|
#include "servers/rendering_server.h"
|
||||||
|
|
||||||
@ -89,11 +90,26 @@ void NinePatchRect::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT);
|
BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NinePatchRect::_texture_changed() {
|
||||||
|
queue_redraw();
|
||||||
|
update_minimum_size();
|
||||||
|
}
|
||||||
|
|
||||||
void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) {
|
void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) {
|
||||||
if (texture == p_tex) {
|
if (texture == p_tex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (texture.is_valid()) {
|
||||||
|
texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NinePatchRect::_texture_changed));
|
||||||
|
}
|
||||||
|
|
||||||
texture = p_tex;
|
texture = p_tex;
|
||||||
|
|
||||||
|
if (texture.is_valid()) {
|
||||||
|
texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NinePatchRect::_texture_changed));
|
||||||
|
}
|
||||||
|
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
update_minimum_size();
|
update_minimum_size();
|
||||||
emit_signal(SceneStringNames::get_singleton()->texture_changed);
|
emit_signal(SceneStringNames::get_singleton()->texture_changed);
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
AxisStretchMode axis_h = AXIS_STRETCH_MODE_STRETCH;
|
AxisStretchMode axis_h = AXIS_STRETCH_MODE_STRETCH;
|
||||||
AxisStretchMode axis_v = AXIS_STRETCH_MODE_STRETCH;
|
AxisStretchMode axis_v = AXIS_STRETCH_MODE_STRETCH;
|
||||||
|
|
||||||
|
void _texture_changed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
virtual Size2 get_minimum_size() const override;
|
virtual Size2 get_minimum_size() const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user