diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/line_edit.cpp | 18 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 4 | ||||
-rw-r--r-- | scene/resources/font.cpp | 60 | ||||
-rw-r--r-- | scene/resources/font.h | 9 |
4 files changed, 90 insertions, 1 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 8c33d306a1..fa54634990 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -664,7 +664,9 @@ void LineEdit::_notification(int p_what) { } Ref<Font> font = get_theme_font(SNAME("font")); - style->draw(ci, Rect2(Point2(), size)); + if (!flat) { + style->draw(ci, Rect2(Point2(), size)); + } if (has_focus()) { get_theme_stylebox(SNAME("focus"))->draw(ci, Rect2(Point2(), size)); @@ -1966,6 +1968,17 @@ Ref<Texture2D> LineEdit::get_right_icon() { return right_icon; } +void LineEdit::set_flat(bool p_enabled) { + if (flat != p_enabled) { + flat = p_enabled; + update(); + } +} + +bool LineEdit::is_flat() const { + return flat; +} + void LineEdit::_text_changed() { _emit_text_change(); _clear_redo(); @@ -2214,6 +2227,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_deselect_on_focus_loss_enabled"), &LineEdit::is_deselect_on_focus_loss_enabled); ClassDB::bind_method(D_METHOD("set_right_icon", "icon"), &LineEdit::set_right_icon); ClassDB::bind_method(D_METHOD("get_right_icon"), &LineEdit::get_right_icon); + ClassDB::bind_method(D_METHOD("set_flat", "enabled"), &LineEdit::set_flat); + ClassDB::bind_method(D_METHOD("is_flat"), &LineEdit::is_flat); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text"))); ADD_SIGNAL(MethodInfo("text_change_rejected", PropertyInfo(Variant::STRING, "rejected_substring"))); @@ -2269,6 +2284,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "deselect_on_focus_loss_enabled"), "set_deselect_on_focus_loss_enabled", "is_deselect_on_focus_loss_enabled"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_right_icon", "get_right_icon"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left,Inherited"), "set_text_direction", "get_text_direction"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "language"), "set_language", "get_language"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_control_chars"), "set_draw_control_chars", "get_draw_control_chars"); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 3364e02e01..2ec7f08865 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -130,6 +130,7 @@ private: bool middle_mouse_paste_enabled = true; Ref<Texture2D> right_icon; + bool flat = false; struct Selection { int begin = 0; @@ -332,6 +333,9 @@ public: void set_right_icon(const Ref<Texture2D> &p_icon); Ref<Texture2D> get_right_icon(); + void set_flat(bool p_enabled); + bool is_flat() const; + virtual bool is_text_field() const override; void show_virtual_keyboard(); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 819ae95715..d9de47afc7 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -70,6 +70,15 @@ void FontData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &FontData::set_antialiased); ClassDB::bind_method(D_METHOD("is_antialiased"), &FontData::is_antialiased); + ClassDB::bind_method(D_METHOD("set_font_name", "name"), &FontData::set_font_name); + ClassDB::bind_method(D_METHOD("get_font_name"), &FontData::get_font_name); + + ClassDB::bind_method(D_METHOD("set_font_style_name", "name"), &FontData::set_font_style_name); + ClassDB::bind_method(D_METHOD("get_font_style_name"), &FontData::get_font_style_name); + + ClassDB::bind_method(D_METHOD("set_font_style", "style"), &FontData::set_font_style); + ClassDB::bind_method(D_METHOD("get_font_style"), &FontData::get_font_style); + ClassDB::bind_method(D_METHOD("set_multichannel_signed_distance_field", "msdf"), &FontData::set_multichannel_signed_distance_field); ClassDB::bind_method(D_METHOD("is_multichannel_signed_distance_field"), &FontData::is_multichannel_signed_distance_field); @@ -190,6 +199,15 @@ bool FontData::_set(const StringName &p_name, const Variant &p_value) { } else if (tokens[0] == "antialiased") { set_antialiased(p_value); return true; + } else if (tokens[0] == "font_name") { + set_font_name(p_value); + return true; + } else if (tokens[0] == "style_name") { + set_font_style_name(p_value); + return true; + } else if (tokens[0] == "font_style") { + set_font_style(p_value); + return true; } else if (tokens[0] == "multichannel_signed_distance_field") { set_multichannel_signed_distance_field(p_value); return true; @@ -295,6 +313,15 @@ bool FontData::_get(const StringName &p_name, Variant &r_ret) const { } else if (tokens[0] == "antialiased") { r_ret = is_antialiased(); return true; + } else if (tokens[0] == "font_name") { + r_ret = get_font_name(); + return true; + } else if (tokens[0] == "style_name") { + r_ret = get_font_style_name(); + return true; + } else if (tokens[0] == "font_style") { + r_ret = get_font_style(); + return true; } else if (tokens[0] == "multichannel_signed_distance_field") { r_ret = is_multichannel_signed_distance_field(); return true; @@ -394,6 +421,9 @@ bool FontData::_get(const StringName &p_name, Variant &r_ret) const { void FontData::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); + p_list->push_back(PropertyInfo(Variant::INT, "font_style", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); p_list->push_back(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE)); @@ -510,6 +540,36 @@ PackedByteArray FontData::get_data() const { return data; } +void FontData::set_font_name(const String &p_name) { + _ensure_rid(0); + TS->font_set_name(cache[0], p_name); +} + +String FontData::get_font_name() const { + _ensure_rid(0); + return TS->font_get_name(cache[0]); +} + +void FontData::set_font_style_name(const String &p_name) { + _ensure_rid(0); + TS->font_set_style_name(cache[0], p_name); +} + +String FontData::get_font_style_name() const { + _ensure_rid(0); + return TS->font_get_style_name(cache[0]); +} + +void FontData::set_font_style(uint32_t p_style) { + _ensure_rid(0); + TS->font_set_style(cache[0], p_style); +} + +uint32_t FontData::get_font_style() const { + _ensure_rid(0); + return TS->font_get_style(cache[0]); +} + void FontData::set_antialiased(bool p_antialiased) { if (antialiased != p_antialiased) { antialiased = p_antialiased; diff --git a/scene/resources/font.h b/scene/resources/font.h index e1f1f6d742..4d9ee72c84 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -79,6 +79,15 @@ public: virtual PackedByteArray get_data() const; // Common properties. + virtual void set_font_name(const String &p_name); + virtual String get_font_name() const; + + virtual void set_font_style_name(const String &p_name); + virtual String get_font_style_name() const; + + virtual void set_font_style(uint32_t p_style); + virtual uint32_t get_font_style() const; + virtual void set_antialiased(bool p_antialiased); virtual bool is_antialiased() const; |