Add some codes, returnes directly if the value is not changed.

Avoid executing the following value-changed logics if the value does not really change.
This commit is contained in:
风青山
2022-03-16 15:50:48 +08:00
committed by Rindbee
parent ba0421f3d9
commit e561c68256
33 changed files with 952 additions and 34 deletions

View File

@@ -105,6 +105,11 @@ Ref<Texture2D> NinePatchRect::get_texture() const {
void NinePatchRect::set_patch_margin(Side p_side, int p_size) {
ERR_FAIL_INDEX((int)p_side, 4);
if (margin[p_side] == p_size) {
return;
}
margin[p_side] = p_size;
update();
update_minimum_size();
@@ -130,6 +135,10 @@ Rect2 NinePatchRect::get_region_rect() const {
}
void NinePatchRect::set_draw_center(bool p_enabled) {
if (draw_center == p_enabled) {
return;
}
draw_center = p_enabled;
update();
}
@@ -139,6 +148,10 @@ bool NinePatchRect::is_draw_center_enabled() const {
}
void NinePatchRect::set_h_axis_stretch_mode(AxisStretchMode p_mode) {
if (axis_h == p_mode) {
return;
}
axis_h = p_mode;
update();
}
@@ -148,6 +161,10 @@ NinePatchRect::AxisStretchMode NinePatchRect::get_h_axis_stretch_mode() const {
}
void NinePatchRect::set_v_axis_stretch_mode(AxisStretchMode p_mode) {
if (axis_v == p_mode) {
return;
}
axis_v = p_mode;
update();
}