Skip to content

Commit

Permalink
Fix DynamicFont breaking mouse grab in inspector spinners
Browse files Browse the repository at this point in the history
This was caused by DynamicFont not specifying which property was edited, resulting in the whole inspector property tree being recreated.
  • Loading branch information
opl- committed Sep 11, 2021
1 parent 95162ca commit a8a52f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions scene/resources/dynamic_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {

/////////////////////////

void DynamicFont::_reload_cache() {
void DynamicFont::_reload_cache(const char *p_triggering_property) {
ERR_FAIL_COND(cache_id.size < 1);
if (!data.is_valid()) {
data_at_size.unref();
Expand Down Expand Up @@ -698,15 +698,12 @@ void DynamicFont::_reload_cache() {
}

emit_changed();
_change_notify();
_change_notify(p_triggering_property);
}

void DynamicFont::set_font_data(const Ref<DynamicFontData> &p_data) {
data = p_data;
_reload_cache();

emit_changed();
_change_notify();
_reload_cache(); // not passing the prop name as clearing the font data also clears fallbacks
}

Ref<DynamicFontData> DynamicFont::get_font_data() const {
Expand All @@ -719,7 +716,7 @@ void DynamicFont::set_size(int p_size) {
}
cache_id.size = p_size;
outline_cache_id.size = p_size;
_reload_cache();
_reload_cache("size");
}

int DynamicFont::get_size() const {
Expand All @@ -732,7 +729,7 @@ void DynamicFont::set_outline_size(int p_size) {
}
ERR_FAIL_COND(p_size < 0 || p_size > UINT8_MAX);
outline_cache_id.outline_size = p_size;
_reload_cache();
_reload_cache("outline_size");
}

int DynamicFont::get_outline_size() const {
Expand All @@ -743,7 +740,7 @@ void DynamicFont::set_outline_color(Color p_color) {
if (p_color != outline_color) {
outline_color = p_color;
emit_changed();
_change_notify();
_change_notify("outline_color");
}
}

Expand Down Expand Up @@ -816,16 +813,19 @@ int DynamicFont::get_spacing(int p_type) const {
void DynamicFont::set_spacing(int p_type, int p_value) {
if (p_type == SPACING_TOP) {
spacing_top = p_value;
_change_notify("extra_spacing_top");
} else if (p_type == SPACING_BOTTOM) {
spacing_bottom = p_value;
_change_notify("extra_spacing_bottom");
} else if (p_type == SPACING_CHAR) {
spacing_char = p_value;
_change_notify("extra_spacing_char");
} else if (p_type == SPACING_SPACE) {
spacing_space = p_value;
_change_notify("extra_spacing_space");
}

emit_changed();
_change_notify();
}

float DynamicFont::get_height() const {
Expand Down Expand Up @@ -929,7 +929,6 @@ void DynamicFont::add_fallback(const Ref<DynamicFontData> &p_data) {
fallback_outline_data_at_size.push_back(fallbacks.write[fallbacks.size() - 1]->_get_dynamic_font_at_size(outline_cache_id));
}

_change_notify();
emit_changed();
_change_notify();
}
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/dynamic_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class DynamicFont : public Font {
Color outline_color;

protected:
void _reload_cache();
void _reload_cache(const char *p_triggering_property = "");

bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
Expand Down

0 comments on commit a8a52f5

Please sign in to comment.