Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DynamicFont breaking mouse grab in inspector spinners #40701

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions scene/resources/dynamic_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ DynamicFontAtSize::~DynamicFontAtSize() {

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

void DynamicFont::_reload_cache() {
void DynamicFont::_reload_cache(const char *p_triggering_property) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason for const char * over const String &?

Copy link
Contributor Author

@opl- opl- Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of my knowledge about project conventions. Also, _change_notify takes in const char *, so I reused the type.

ERR_FAIL_COND(cache_id.size < 1);
if (!data.is_valid()) {
data_at_size.unref();
Expand Down Expand Up @@ -705,15 +705,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 @@ -726,7 +723,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 @@ -739,7 +736,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 @@ -750,7 +747,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 @@ -797,16 +794,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 @@ -921,7 +921,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 @@ -234,7 +234,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