Add a function to notify font users that the font changed. Closes #5774

This commit is contained in:
Juan Linietsky 2016-07-18 09:59:31 -03:00
parent c328693e83
commit 254d79a560
3 changed files with 12 additions and 0 deletions

View File

@ -12999,6 +12999,11 @@
Return the font descent (number of pixels below the baseline). Return the font descent (number of pixels below the baseline).
</description> </description>
</method> </method>
<method name="update_changes">
<description>
After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it.
</description>
</method>
<method name="get_height" qualifiers="const"> <method name="get_height" qualifiers="const">
<return type="float"> <return type="float">
</return> </return>

View File

@ -71,6 +71,11 @@ void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, co
} }
} }
void Font::update_changes() {
emit_changed();
}
void Font::_bind_methods() { void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1)); ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1));
@ -80,6 +85,7 @@ void Font::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint); ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint);
ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size); ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size);
ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1))); ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1)));
ObjectTypeDB::bind_method(_MD("update_changes"),&Font::update_changes);
} }

View File

@ -61,6 +61,7 @@ public:
void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const; void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const;
virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0; virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0;
void update_changes();
Font(); Font();
}; };