diff options
Diffstat (limited to 'scene/gui')
46 files changed, 307 insertions, 308 deletions
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 6f3d8c61cf..04ff11f20c 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -40,7 +40,7 @@ Size2 Button::get_minimum_size() const { minsize.width = 0; if (!expand_icon) { - Ref<Texture> _icon; + Ref<Texture2D> _icon; if (icon.is_null() && has_icon("icon")) _icon = Control::get_icon("icon"); else @@ -150,7 +150,7 @@ void Button::_notification(int p_what) { } Ref<Font> font = get_font("font"); - Ref<Texture> _icon; + Ref<Texture2D> _icon; if (icon.is_null() && has_icon("icon")) _icon = Control::get_icon("icon"); else @@ -249,7 +249,7 @@ String Button::get_text() const { return text; } -void Button::set_icon(const Ref<Texture> &p_icon) { +void Button::set_icon(const Ref<Texture2D> &p_icon) { if (icon == p_icon) return; @@ -259,7 +259,7 @@ void Button::set_icon(const Ref<Texture> &p_icon) { minimum_size_changed(); } -Ref<Texture> Button::get_icon() const { +Ref<Texture2D> Button::get_icon() const { return icon; } @@ -331,7 +331,7 @@ void Button::_bind_methods() { BIND_ENUM_CONSTANT(ALIGN_RIGHT); ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_button_icon", "get_button_icon"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_button_icon", "get_button_icon"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_text"), "set_clip_text", "get_clip_text"); ADD_PROPERTY(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_text_align", "get_text_align"); diff --git a/scene/gui/button.h b/scene/gui/button.h index e975dc52a5..3135b98578 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -48,7 +48,7 @@ private: bool flat; String text; String xl_text; - Ref<Texture> icon; + Ref<Texture2D> icon; bool expand_icon; bool clip_text; TextAlign align; @@ -65,8 +65,8 @@ public: void set_text(const String &p_text); String get_text() const; - void set_icon(const Ref<Texture> &p_icon); - Ref<Texture> get_icon() const; + void set_icon(const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_icon() const; void set_expand_icon(bool p_expand_icon); bool is_expand_icon() const; diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index 443121db32..89bd8ab0dd 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -33,10 +33,10 @@ #include "servers/visual_server.h" Size2 CheckBox::get_icon_size() const { - Ref<Texture> checked = Control::get_icon("checked"); - Ref<Texture> unchecked = Control::get_icon("unchecked"); - Ref<Texture> radio_checked = Control::get_icon("radio_checked"); - Ref<Texture> radio_unchecked = Control::get_icon("radio_unchecked"); + Ref<Texture2D> checked = Control::get_icon("checked"); + Ref<Texture2D> unchecked = Control::get_icon("unchecked"); + Ref<Texture2D> radio_checked = Control::get_icon("radio_checked"); + Ref<Texture2D> radio_unchecked = Control::get_icon("radio_unchecked"); Size2 tex_size = Size2(0, 0); if (!checked.is_null()) @@ -73,8 +73,8 @@ void CheckBox::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); - Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); + Ref<Texture2D> on = Control::get_icon(is_radio() ? "radio_checked" : "checked"); + Ref<Texture2D> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 9d6df94cce..0b093ce850 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -35,8 +35,8 @@ Size2 CheckButton::get_icon_size() const { - Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); - Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); + Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Size2 tex_size = Size2(0, 0); if (!on.is_null()) tex_size = Size2(on->get_width(), on->get_height()); @@ -68,8 +68,8 @@ void CheckButton::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); - Ref<Texture> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); + Ref<Texture2D> on = Control::get_icon(is_disabled() ? "on_disabled" : "on"); + Ref<Texture2D> off = Control::get_icon(is_disabled() ? "off_disabled" : "off"); Ref<StyleBox> sb = get_stylebox("normal"); Vector2 ofs; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 01f4070883..68c12c38fa 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -445,7 +445,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) { c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2); } else if (p_which == 1) { - Ref<Texture> hue = get_icon("color_hue", "ColorPicker"); + Ref<Texture2D> hue = get_icon("color_hue", "ColorPicker"); c->draw_texture_rect(hue, Rect2(Point2(), c->get_size())); int y = c->get_size().y - c->get_size().y * (1.0 - h); Color col = Color(); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4c70bd1d39..be211504a6 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -358,7 +358,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const { if (data.icon_override.has(E->get())) hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED; - p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture", hint)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_icons/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", hint)); } } { @@ -813,11 +813,11 @@ Size2 Control::get_minimum_size() const { return Size2(); } -Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_type) const { +Ref<Texture2D> Control::get_icon(const StringName &p_name, const StringName &p_type) const { if (p_type == StringName() || p_type == get_class_name()) { - const Ref<Texture> *tex = data.icon_override.getptr(p_name); + const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); if (tex) return *tex; } @@ -1063,7 +1063,7 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co bool Control::has_icon_override(const StringName &p_name) const { - const Ref<Texture> *tex = data.icon_override.getptr(p_name); + const Ref<Texture2D> *tex = data.icon_override.getptr(p_name); return tex != NULL; } @@ -1880,7 +1880,7 @@ Rect2 Control::get_anchorable_rect() const { return Rect2(Point2(), get_size()); } -void Control::add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon) { +void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) { if (data.icon_override.has(p_name)) { data.icon_override[p_name]->disconnect("changed", this, "_override_changed"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 357858beb6..67e8ed0d27 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -198,7 +198,7 @@ private: NodePath focus_next; NodePath focus_prev; - HashMap<StringName, Ref<Texture> > icon_override; + HashMap<StringName, Ref<Texture2D> > icon_override; HashMap<StringName, Ref<Shader> > shader_override; HashMap<StringName, Ref<StyleBox> > style_override; HashMap<StringName, Ref<Font> > font_override; @@ -420,14 +420,14 @@ public: /* SKINNING */ - void add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon); + void add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon); void add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader); void add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style); void add_font_override(const StringName &p_name, const Ref<Font> &p_font); void add_color_override(const StringName &p_name, const Color &p_color); void add_constant_override(const StringName &p_name, int p_constant); - Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const; + Ref<Texture2D> get_icon(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<Shader> get_shader(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<StyleBox> get_stylebox(const StringName &p_name, const StringName &p_type = StringName()) const; Ref<Font> get_font(const StringName &p_name, const StringName &p_type = StringName()) const; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 2cc9c1a53a..6e7491e7b4 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -424,7 +424,7 @@ void FileDialog::update_file_list() { dir_access->list_dir_begin(); TreeItem *root = tree->create_item(); - Ref<Texture> folder = get_icon("folder"); + Ref<Texture2D> folder = get_icon("folder"); const Color folder_color = get_color("folder_icon_modulate"); List<String> files; List<String> dirs; @@ -518,7 +518,7 @@ void FileDialog::update_file_list() { if (get_icon_func) { - Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get())); + Ref<Texture2D> icon = get_icon_func(base_dir.plus_file(files.front()->get())); ti->set_icon(0, icon); } diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index d9ab00e0f2..9f6650c276 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -58,7 +58,7 @@ public: MODE_SAVE_FILE }; - typedef Ref<Texture> (*GetIconFunc)(const String &); + typedef Ref<Texture2D> (*GetIconFunc)(const String &); typedef void (*RegisterFunc)(FileDialog *); static GetIconFunc get_icon_func; diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 46c59f42fc..80431cefe0 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -54,7 +54,6 @@ GradientEdit::GradientEdit() { checker = Ref<ImageTexture>(memnew(ImageTexture)); Ref<Image> img = memnew(Image(checker_bg_png)); - checker->create_from_image(img, ImageTexture::FLAG_REPEAT); } int GradientEdit::_get_point_from_pos(int x) { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index c09b2414b2..02445000df 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -357,7 +357,7 @@ void GraphEdit::_notification(int p_what) { bool GraphEdit::_filter_input(const Point2 &p_point) { - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); for (int i = get_child_count() - 1; i >= 0; i--) { @@ -389,7 +389,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseButton> mb = p_ev; if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); Vector2 mpos(mb->get_position().x, mb->get_position().y); for (int i = get_child_count() - 1; i >= 0; i--) { @@ -501,7 +501,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { connecting_target = false; top_layer->update(); - Ref<Texture> port = get_icon("port", "GraphNode"); + Ref<Texture2D> port = get_icon("port", "GraphNode"); Vector2 mpos = mm->get_position(); for (int i = get_child_count() - 1; i >= 0; i--) { diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 7b1bfdfdb5..82e890395a 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -170,7 +170,7 @@ bool GraphNode::has_point(const Point2 &p_point) const { if (comment) { Ref<StyleBox> comment = get_stylebox("comment"); - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> resizer = get_icon("resizer"); if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) { return true; @@ -204,9 +204,9 @@ void GraphNode::_notification(int p_what) { //sb=sb->duplicate(); //sb->call("set_modulate",modulate); - Ref<Texture> port = get_icon("port"); - Ref<Texture> close = get_icon("close"); - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> port = get_icon("port"); + Ref<Texture2D> close = get_icon("close"); + Ref<Texture2D> resizer = get_icon("resizer"); int close_offset = get_constant("close_offset"); int close_h_offset = get_constant("close_h_offset"); Color close_color = get_color("close_color"); @@ -259,14 +259,14 @@ void GraphNode::_notification(int p_what) { const Slot &s = slot_info[E->key()]; //left if (s.enable_left) { - Ref<Texture> p = port; + Ref<Texture2D> p = port; if (s.custom_slot_left.is_valid()) { p = s.custom_slot_left; } p->draw(get_canvas_item(), icofs + Point2(edgeofs, cache_y[E->key()]), s.color_left); } if (s.enable_right) { - Ref<Texture> p = port; + Ref<Texture2D> p = port; if (s.custom_slot_right.is_valid()) { p = s.custom_slot_right; } @@ -291,7 +291,7 @@ void GraphNode::_notification(int p_what) { } } -void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture> &p_custom_left, const Ref<Texture> &p_custom_right) { +void GraphNode::set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left, const Ref<Texture2D> &p_custom_right) { ERR_FAIL_COND(p_idx < 0); @@ -379,7 +379,7 @@ Size2 GraphNode::get_minimum_size() const { Size2 minsize; minsize.x = title_font->get_string_size(title).x; if (show_close) { - Ref<Texture> close = get_icon("close"); + Ref<Texture2D> close = get_icon("close"); minsize.x += sep + close->get_width(); } @@ -606,7 +606,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { return; } - Ref<Texture> resizer = get_icon("resizer"); + Ref<Texture2D> resizer = get_icon("resizer"); if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) { @@ -674,7 +674,7 @@ void GraphNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_title"), &GraphNode::get_title); ClassDB::bind_method(D_METHOD("_gui_input"), &GraphNode::_gui_input); - ClassDB::bind_method(D_METHOD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right", "custom_left", "custom_right"), &GraphNode::set_slot, DEFVAL(Ref<Texture>()), DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("set_slot", "idx", "enable_left", "type_left", "color_left", "enable_right", "type_right", "color_right", "custom_left", "custom_right"), &GraphNode::set_slot, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("clear_slot", "idx"), &GraphNode::clear_slot); ClassDB::bind_method(D_METHOD("clear_all_slots"), &GraphNode::clear_all_slots); ClassDB::bind_method(D_METHOD("is_slot_enabled_left", "idx"), &GraphNode::is_slot_enabled_left); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index e1a81b5f3d..a3eb8ed152 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -52,8 +52,8 @@ private: bool enable_right; int type_right; Color color_right; - Ref<Texture> custom_slot_left; - Ref<Texture> custom_slot_right; + Ref<Texture2D> custom_slot_left; + Ref<Texture2D> custom_slot_right; Slot() { enable_left = false; @@ -112,7 +112,7 @@ protected: public: bool has_point(const Point2 &p_point) const; - void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture> &p_custom_left = Ref<Texture>(), const Ref<Texture> &p_custom_right = Ref<Texture>()); + void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture2D> &p_custom_left = Ref<Texture2D>(), const Ref<Texture2D> &p_custom_right = Ref<Texture2D>()); void clear_slot(int p_idx); void clear_all_slots(); bool is_slot_enabled_left(int p_idx) const; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 526950dbb3..cf798f36e4 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -32,7 +32,7 @@ #include "core/os/os.h" #include "core/project_settings.h" -void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, bool p_selectable) { +void ItemList::add_item(const String &p_item, const Ref<Texture2D> &p_texture, bool p_selectable) { Item item; item.icon = p_texture; @@ -51,7 +51,7 @@ void ItemList::add_item(const String &p_item, const Ref<Texture> &p_texture, boo shape_changed = true; } -void ItemList::add_icon_item(const Ref<Texture> &p_item, bool p_selectable) { +void ItemList::add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable) { Item item; item.icon = p_item; @@ -110,7 +110,7 @@ String ItemList::get_item_tooltip(int p_idx) const { return items[p_idx].tooltip; } -void ItemList::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void ItemList::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_idx, items.size()); @@ -119,9 +119,9 @@ void ItemList::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { shape_changed = true; } -Ref<Texture> ItemList::get_item_icon(int p_idx) const { +Ref<Texture2D> ItemList::get_item_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].icon; } @@ -201,7 +201,7 @@ Color ItemList::get_item_custom_fg_color(int p_idx) const { return items[p_idx].custom_fg; } -void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) { +void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon) { ERR_FAIL_INDEX(p_idx, items.size()); @@ -209,9 +209,9 @@ void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) { update(); shape_changed = true; } -Ref<Texture> ItemList::get_item_tag_icon(int p_idx) const { +Ref<Texture2D> ItemList::get_item_tag_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].tag_icon; } @@ -1398,7 +1398,7 @@ void ItemList::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 3) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; bool disabled = p_items[i + 2]; int idx = get_item_count(); diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index d9b510c762..da9851dd7d 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -52,11 +52,11 @@ public: private: struct Item { - Ref<Texture> icon; + Ref<Texture2D> icon; bool icon_transposed; Rect2i icon_region; Color icon_modulate; - Ref<Texture> tag_icon; + Ref<Texture2D> tag_icon; String text; bool selectable; bool selected; @@ -125,14 +125,14 @@ protected: static void _bind_methods(); public: - void add_item(const String &p_item, const Ref<Texture> &p_texture = Ref<Texture>(), bool p_selectable = true); - void add_icon_item(const Ref<Texture> &p_item, bool p_selectable = true); + void add_item(const String &p_item, const Ref<Texture2D> &p_texture = Ref<Texture2D>(), bool p_selectable = true); + void add_icon_item(const Ref<Texture2D> &p_item, bool p_selectable = true); void set_item_text(int p_idx, const String &p_text); String get_item_text(int p_idx) const; - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); - Ref<Texture> get_item_icon(int p_idx) const; + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_item_icon(int p_idx) const; void set_item_icon_transposed(int p_idx, const bool transposed); bool is_item_icon_transposed(int p_idx) const; @@ -152,8 +152,8 @@ public: void set_item_metadata(int p_idx, const Variant &p_metadata); Variant get_item_metadata(int p_idx) const; - void set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon); - Ref<Texture> get_item_tag_icon(int p_idx) const; + void set_item_tag_icon(int p_idx, const Ref<Texture2D> &p_tag_icon); + Ref<Texture2D> get_item_tag_icon(int p_idx) const; void set_item_tooltip_enabled(int p_idx, const bool p_enabled); bool is_item_tooltip_enabled(int p_idx) const; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 2504989d2c..3f4fd37c08 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -634,7 +634,7 @@ bool LineEdit::_is_over_clear_button(const Point2 &p_pos) const { if (!clear_button_enabled || !has_point(p_pos)) { return false; } - Ref<Texture> icon = Control::get_icon("clear"); + Ref<Texture2D> icon = Control::get_icon("clear"); int x_ofs = get_stylebox("normal")->get_offset().x; return p_pos.x > get_size().width - icon->get_width() - x_ofs; } @@ -748,7 +748,7 @@ void LineEdit::_notification(int p_what) { bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; Color color_icon(1, 1, 1, !is_editable() ? .5 * .9 : .9); if (display_clear_icon) { if (clear_button_status.press_attempt && clear_button_status.pressing_inside) { @@ -1309,7 +1309,7 @@ void LineEdit::set_cursor_position(int p_pos) { int window_width = get_size().width - style->get_minimum_size().width; bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { - Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; + Ref<Texture2D> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; window_width -= r_icon->get_width(); } @@ -1650,7 +1650,7 @@ bool LineEdit::is_selecting_enabled() const { return selecting_enabled; } -void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { +void LineEdit::set_right_icon(const Ref<Texture2D> &p_icon) { if (right_icon == p_icon) { return; } @@ -1659,7 +1659,7 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { update(); } -Ref<Texture> LineEdit::get_right_icon() { +Ref<Texture2D> LineEdit::get_right_icon() { return right_icon; } diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 037238d682..938974453a 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -91,7 +91,7 @@ private: bool shortcut_keys_enabled; - Ref<Texture> right_icon; + Ref<Texture2D> right_icon; struct Selection { @@ -232,8 +232,8 @@ public: void set_selecting_enabled(bool p_enabled); bool is_selecting_enabled() const; - void set_right_icon(const Ref<Texture> &p_icon); - Ref<Texture> get_right_icon(); + void set_right_icon(const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_right_icon(); virtual bool is_text_field() const; LineEdit(); diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 945d1850d7..0ef1f53006 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -70,7 +70,7 @@ void NinePatchRect::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "is_draw_center_enabled"); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); @@ -88,7 +88,7 @@ void NinePatchRect::_bind_methods() { BIND_ENUM_CONSTANT(AXIS_STRETCH_MODE_TILE_FIT); } -void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { +void NinePatchRect::set_texture(const Ref<Texture2D> &p_tex) { if (texture == p_tex) return; @@ -103,7 +103,7 @@ void NinePatchRect::set_texture(const Ref<Texture> &p_tex) { _change_notify("texture"); } -Ref<Texture> NinePatchRect::get_texture() const { +Ref<Texture2D> NinePatchRect::get_texture() const { return texture; } diff --git a/scene/gui/nine_patch_rect.h b/scene/gui/nine_patch_rect.h index 3329c0a64c..0ef7f6b299 100644 --- a/scene/gui/nine_patch_rect.h +++ b/scene/gui/nine_patch_rect.h @@ -47,7 +47,7 @@ public: bool draw_center; int margin[4]; Rect2 region_rect; - Ref<Texture> texture; + Ref<Texture2D> texture; AxisStretchMode axis_h, axis_v; @@ -57,8 +57,8 @@ protected: static void _bind_methods(); public: - void set_texture(const Ref<Texture> &p_tex); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_tex); + Ref<Texture2D> get_texture() const; void set_patch_margin(Margin p_margin, int p_size); int get_patch_margin(Margin p_margin) const; diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 3f46afa8e8..6f656025e6 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -58,7 +58,7 @@ void OptionButton::_notification(int p_what) { return; RID ci = get_canvas_item(); - Ref<Texture> arrow = Control::get_icon("arrow"); + Ref<Texture2D> arrow = Control::get_icon("arrow"); Color clr = Color(1, 1, 1); if (get_constant("modulate_arrow")) { switch (get_draw_mode()) { @@ -114,7 +114,7 @@ void OptionButton::pressed() { popup->popup(); } -void OptionButton::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id) { +void OptionButton::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id) { popup->add_icon_radio_check_item(p_icon, p_label, p_id); if (popup->get_item_count() == 1) @@ -134,7 +134,7 @@ void OptionButton::set_item_text(int p_idx, const String &p_text) { if (current == p_idx) set_text(p_text); } -void OptionButton::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void OptionButton::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { popup->set_item_icon(p_idx, p_icon); @@ -161,7 +161,7 @@ String OptionButton::get_item_text(int p_idx) const { return popup->get_item_text(p_idx); } -Ref<Texture> OptionButton::get_item_icon(int p_idx) const { +Ref<Texture2D> OptionButton::get_item_icon(int p_idx) const { return popup->get_item_icon(p_idx); } @@ -289,7 +289,7 @@ void OptionButton::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 5) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; bool disabled = p_items[i + 2]; int id = p_items[i + 3]; Variant meta = p_items[i + 4]; diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index 04bd28fe28..9658e1fea8 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -57,17 +57,17 @@ protected: static void _bind_methods(); public: - void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1); + void add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1); void add_item(const String &p_label, int p_id = -1); void set_item_text(int p_idx, const String &p_text); - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); void set_item_id(int p_idx, int p_id); void set_item_metadata(int p_idx, const Variant &p_metadata); void set_item_disabled(int p_idx, bool p_disabled); String get_item_text(int p_idx) const; - Ref<Texture> get_item_icon(int p_idx) const; + Ref<Texture2D> get_item_icon(int p_idx) const; int get_item_id(int p_idx) const; int get_item_index(int p_id) const; Variant get_item_metadata(int p_idx) const; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 87f17838cf..b494506c6c 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -467,9 +467,9 @@ void PopupMenu::_notification(int p_what) { Ref<StyleBox> hover = get_stylebox("hover"); Ref<Font> font = get_font("font"); // In Item::checkable_type enum order (less the non-checkable member) - Ref<Texture> check[] = { get_icon("checked"), get_icon("radio_checked") }; - Ref<Texture> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") }; - Ref<Texture> submenu = get_icon("submenu"); + Ref<Texture2D> check[] = { get_icon("checked"), get_icon("radio_checked") }; + Ref<Texture2D> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") }; + Ref<Texture2D> submenu = get_icon("submenu"); Ref<StyleBox> separator = get_stylebox("separator"); Ref<StyleBox> labeled_separator_left = get_stylebox("labeled_separator_left"); Ref<StyleBox> labeled_separator_right = get_stylebox("labeled_separator_right"); @@ -549,7 +549,7 @@ void PopupMenu::_notification(int p_what) { Color icon_color(1, 1, 1, items[i].disabled ? 0.5 : 1); if (items[i].checkable_type) { - Texture *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr(); + Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr(); icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon->get_height()) / 2.0)), icon_color); } @@ -651,7 +651,7 @@ void PopupMenu::add_item(const String &p_label, int p_id, uint32_t p_accel) { minimum_size_changed(); } -void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -671,7 +671,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_id, uint32_t p_accel minimum_size_changed(); } -void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -692,7 +692,7 @@ void PopupMenu::add_radio_check_item(const String &p_label, int p_id, uint32_t p minimum_size_changed(); } -void PopupMenu::add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { +void PopupMenu::add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id, uint32_t p_accel) { Item item; ITEM_SETUP_WITH_ACCEL(p_label, p_id, p_accel); @@ -732,7 +732,7 @@ void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bool p_g minimum_size_changed(); } -void PopupMenu::add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -752,7 +752,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id, bo minimum_size_changed(); } -void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -773,7 +773,7 @@ void PopupMenu::add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ minimum_size_changed(); } -void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { +void PopupMenu::add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id, bool p_global) { Item item; ITEM_SETUP_WITH_SHORTCUT(p_shortcut, p_id, p_global); @@ -810,7 +810,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) { update(); minimum_size_changed(); } -void PopupMenu::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { +void PopupMenu::set_item_icon(int p_idx, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_idx, items.size()); items.write[p_idx].icon = p_icon; @@ -893,9 +893,9 @@ int PopupMenu::get_item_idx_from_text(const String &text) const { return -1; } -Ref<Texture> PopupMenu::get_item_icon(int p_idx) const { +Ref<Texture2D> PopupMenu::get_item_icon(int p_idx) const { - ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_idx, items.size(), Ref<Texture2D>()); return items[p_idx].icon; } @@ -1257,7 +1257,7 @@ void PopupMenu::_set_items(const Array &p_items) { for (int i = 0; i < p_items.size(); i += 10) { String text = p_items[i + 0]; - Ref<Texture> icon = p_items[i + 1]; + Ref<Texture2D> icon = p_items[i + 1]; // For compatibility, use false/true for no/checkbox and integers for other values bool checkable = p_items[i + 2]; bool radio_checkable = (int)p_items[i + 2] == Item::CHECKABLE_TYPE_RADIO_BUTTON; diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index f77ede0a8b..a3a858cfde 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -38,7 +38,7 @@ class PopupMenu : public Popup { GDCLASS(PopupMenu, Popup); struct Item { - Ref<Texture> icon; + Ref<Texture2D> icon; String text; String xl_text; bool checked; @@ -121,25 +121,25 @@ protected: public: void add_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_check_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_radio_check_item(const String &p_label, int p_id = -1, uint32_t p_accel = 0); - void add_icon_radio_check_item(const Ref<Texture> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); + void add_icon_radio_check_item(const Ref<Texture2D> &p_icon, const String &p_label, int p_id = -1, uint32_t p_accel = 0); void add_multistate_item(const String &p_label, int p_max_states, int p_default_state = 0, int p_id = -1, uint32_t p_accel = 0); void add_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_radio_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); - void add_icon_radio_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); + void add_icon_radio_check_shortcut(const Ref<Texture2D> &p_icon, const Ref<ShortCut> &p_shortcut, int p_id = -1, bool p_global = false); void add_submenu_item(const String &p_label, const String &p_submenu, int p_id = -1); void set_item_text(int p_idx, const String &p_text); - void set_item_icon(int p_idx, const Ref<Texture> &p_icon); + void set_item_icon(int p_idx, const Ref<Texture2D> &p_icon); void set_item_checked(int p_idx, bool p_checked); void set_item_id(int p_idx, int p_id); void set_item_accelerator(int p_idx, uint32_t p_accel); @@ -160,7 +160,7 @@ public: String get_item_text(int p_idx) const; int get_item_idx_from_text(const String &text) const; - Ref<Texture> get_item_icon(int p_idx) const; + Ref<Texture2D> get_item_icon(int p_idx) const; bool is_item_checked(int p_idx) const; int get_item_id(int p_idx) const; int get_item_index(int p_id) const; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index b19e1d8362..0c686296b3 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1657,7 +1657,7 @@ void RichTextLabel::_remove_item(Item *p_item, const int p_line, const int p_sub } } -void RichTextLabel::add_image(const Ref<Texture> &p_image, const int p_width, const int p_height) { +void RichTextLabel::add_image(const Ref<Texture2D> &p_image, const int p_width, const int p_height) { if (current->type == ITEM_TABLE) return; @@ -2213,7 +2213,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(image, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(image, "Texture2D"); if (texture.is_valid()) add_image(texture); @@ -2239,7 +2239,7 @@ Error RichTextLabel::append_bbcode(const String &p_bbcode) { String image = p_bbcode.substr(brk_end + 1, end - brk_end - 1); - Ref<Texture> texture = ResourceLoader::load(image, "Texture"); + Ref<Texture2D> texture = ResourceLoader::load(image, "Texture"); if (texture.is_valid()) add_image(texture, width, height); diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 61ac0bd86c..409aec0ca6 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -147,7 +147,7 @@ private: }; struct ItemImage : public Item { - Ref<Texture> image; + Ref<Texture2D> image; Size2 size; ItemImage() { type = ITEM_IMAGE; } }; @@ -407,7 +407,7 @@ protected: public: String get_text(); void add_text(const String &p_text); - void add_image(const Ref<Texture> &p_image, const int p_width = 0, const int p_height = 0); + void add_image(const Ref<Texture2D> &p_image, const int p_width = 0, const int p_height = 0); void add_newline(); bool remove_line(const int p_line); void push_font(const Ref<Font> &p_font); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 45fa212886..8e6d0843a7 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -71,8 +71,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed()) { double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x; - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -148,7 +148,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (drag.active) { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> decr = get_icon("decrement"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); ofs -= decr_size; @@ -159,8 +159,8 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { } else { double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); double incr_size = orientation == VERTICAL ? incr->get_height() : incr->get_width(); @@ -233,8 +233,8 @@ void ScrollBar::_notification(int p_what) { RID ci = get_canvas_item(); - Ref<Texture> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); - Ref<Texture> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); + Ref<Texture2D> decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); + Ref<Texture2D> incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); Ref<StyleBox> bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll"); Ref<StyleBox> grabber; @@ -500,8 +500,8 @@ double ScrollBar::get_grabber_offset() const { Size2 ScrollBar::get_minimum_size() const { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); Ref<StyleBox> bg = get_stylebox("scroll"); Size2 minsize; diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 9b3ed35e6e..85887ef7b1 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -36,7 +36,7 @@ Size2 Slider::get_minimum_size() const { Ref<StyleBox> style = get_stylebox("slider"); Size2i ss = style->get_minimum_size() + style->get_center_size(); - Ref<Texture> grabber = get_icon("grabber"); + Ref<Texture2D> grabber = get_icon("grabber"); Size2i rs = grabber->get_size(); if (orientation == HORIZONTAL) @@ -57,7 +57,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (mb->get_button_index() == BUTTON_LEFT) { if (mb->is_pressed()) { - Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); + Ref<Texture2D> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x; double grab_width = (double)grabber->get_size().width; @@ -87,7 +87,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (grab.active) { Size2i size = get_size(); - Ref<Texture> grabber = get_icon("grabber"); + Ref<Texture2D> grabber = get_icon("grabber"); float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos; if (orientation == VERTICAL) motion = -motion; @@ -167,8 +167,8 @@ void Slider::_notification(int p_what) { Size2i size = get_size(); Ref<StyleBox> style = get_stylebox("slider"); Ref<StyleBox> grabber_area = get_stylebox("grabber_area"); - Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); - Ref<Texture> tick = get_icon("tick"); + Ref<Texture2D> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); + Ref<Texture2D> tick = get_icon("tick"); double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio(); if (orientation == VERTICAL) { diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 92377949f8..c49d7f3d12 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -182,7 +182,7 @@ void SpinBox::_line_edit_focus_exit() { _text_entered(line_edit->get_text()); } -inline void SpinBox::_adjust_width_for_icon(const Ref<Texture> &icon) { +inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) { int w = icon->get_width(); if (w != last_w) { @@ -195,7 +195,7 @@ void SpinBox::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<Texture> updown = get_icon("updown"); + Ref<Texture2D> updown = get_icon("updown"); _adjust_width_for_icon(updown); diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 04491c8477..d3a3d8fe3d 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -62,7 +62,7 @@ class SpinBox : public Range { void _line_edit_focus_exit(); - inline void _adjust_width_for_icon(const Ref<Texture> &icon); + inline void _adjust_width_for_icon(const Ref<Texture2D> &icon); protected: void _gui_input(const Ref<InputEvent> &p_event); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 079907db07..255278be2b 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -74,7 +74,7 @@ void SplitContainer::_resort() { bool second_expanded = (vertical ? second->get_v_size_flags() : second->get_h_size_flags()) & SIZE_EXPAND; // Determine the separation between items - Ref<Texture> g = get_icon("grabber"); + Ref<Texture2D> g = get_icon("grabber"); int sep = get_constant("separation"); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; @@ -123,7 +123,7 @@ Size2 SplitContainer::get_minimum_size() const { /* Calculate MINIMUM SIZE */ Size2i minimum; - Ref<Texture> g = get_icon("grabber"); + Ref<Texture2D> g = get_icon("grabber"); int sep = get_constant("separation"); sep = (dragger_visibility != DRAGGER_HIDDEN_COLLAPSED) ? MAX(sep, vertical ? g->get_height() : g->get_width()) : 0; @@ -182,7 +182,7 @@ void SplitContainer::_notification(int p_what) { return; int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0; - Ref<Texture> tex = get_icon("grabber"); + Ref<Texture2D> tex = get_icon("grabber"); Size2 size = get_size(); if (vertical) diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index b045ff4fe1..402623e53d 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -58,7 +58,7 @@ int TabContainer::_get_top_margin() const { if (!c->has_meta("_tab_icon")) continue; - Ref<Texture> tex = c->get_meta("_tab_icon"); + Ref<Texture2D> tex = c->get_meta("_tab_icon"); if (!tex.is_valid()) continue; content_height = MAX(content_height, tex->get_size().height); @@ -81,7 +81,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; // Handle menu button. - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); if (popup && pos.x > size.width - menu->get_width()) { emit_signal("pre_popup_pressed"); @@ -107,8 +107,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); if (pos.x > size.width - increment->get_width() - popup_ofs) { if (last_tab_cache < tabs.size() - 1) { first_tab_cache += 1; @@ -159,7 +159,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; } - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); if (popup) { if (pos.x >= size.width - menu->get_width()) { @@ -191,8 +191,8 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { popup_ofs = menu->get_width(); } - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); if (pos.x >= size.width - increment->get_width() - popup_ofs) { if (highlight_arrow != 1) { @@ -225,9 +225,9 @@ void TabContainer::_notification(int p_what) { Vector<Control *> tabs = _get_tabs(); int side_margin = get_constant("side_margin"); - Ref<Texture> menu = get_icon("menu"); - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> menu = get_icon("menu"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); int header_width = get_size().width - side_margin * 2; // Find the width of the header area. @@ -272,12 +272,12 @@ void TabContainer::_notification(int p_what) { Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled"); - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> increment_hl = get_icon("increment_highlight"); - Ref<Texture> decrement = get_icon("decrement"); - Ref<Texture> decrement_hl = get_icon("decrement_highlight"); - Ref<Texture> menu = get_icon("menu"); - Ref<Texture> menu_hl = get_icon("menu_highlight"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> increment_hl = get_icon("increment_highlight"); + Ref<Texture2D> decrement = get_icon("decrement"); + Ref<Texture2D> decrement_hl = get_icon("decrement_highlight"); + Ref<Texture2D> menu = get_icon("menu"); + Ref<Texture2D> menu_hl = get_icon("menu_highlight"); Ref<Font> font = get_font("font"); Color font_color_fg = get_color("font_color_fg"); Color font_color_bg = get_color("font_color_bg"); @@ -383,7 +383,7 @@ void TabContainer::_notification(int p_what) { // Draw the tab icon. if (control->has_meta("_tab_icon")) { - Ref<Texture> icon = control->get_meta("_tab_icon"); + Ref<Texture2D> icon = control->get_meta("_tab_icon"); if (icon.is_valid()) { int y = y_center - (icon->get_height() / 2); icon->draw(canvas, Point2i(x_content, y)); @@ -464,7 +464,7 @@ int TabContainer::_get_tab_width(int p_index) const { // Add space for a tab icon. if (control->has_meta("_tab_icon")) { - Ref<Texture> icon = control->get_meta("_tab_icon"); + Ref<Texture2D> icon = control->get_meta("_tab_icon"); if (icon.is_valid()) { width += icon->get_width(); if (text != "") @@ -648,7 +648,7 @@ Variant TabContainer::get_drag_data(const Point2 &p_point) { HBoxContainer *drag_preview = memnew(HBoxContainer); - Ref<Texture> icon = get_tab_icon(tab_over); + Ref<Texture2D> icon = get_tab_icon(tab_over); if (!icon.is_null()) { TextureRect *tf = memnew(TextureRect); tf->set_texture(icon); @@ -745,12 +745,12 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const { int right_ofs = 0; if (popup) { - Ref<Texture> menu = get_icon("menu"); + Ref<Texture2D> menu = get_icon("menu"); right_ofs += menu->get_width(); } if (buttons_visible_cache) { - Ref<Texture> increment = get_icon("increment"); - Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture2D> increment = get_icon("increment"); + Ref<Texture2D> decrement = get_icon("decrement"); right_ofs += increment->get_width() + decrement->get_width(); } if (p_point.x > size.width - right_ofs) { @@ -834,21 +834,21 @@ String TabContainer::get_tab_title(int p_tab) const { return child->get_name(); } -void TabContainer::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { +void TabContainer::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { Control *child = _get_tab(p_tab); ERR_FAIL_COND(!child); child->set_meta("_tab_icon", p_icon); update(); } -Ref<Texture> TabContainer::get_tab_icon(int p_tab) const { +Ref<Texture2D> TabContainer::get_tab_icon(int p_tab) const { Control *child = _get_tab(p_tab); - ERR_FAIL_COND_V(!child, Ref<Texture>()); + ERR_FAIL_COND_V(!child, Ref<Texture2D>()); if (child->has_meta("_tab_icon")) return child->get_meta("_tab_icon"); else - return Ref<Texture>(); + return Ref<Texture2D>(); } void TabContainer::set_tab_disabled(int p_tab, bool p_disabled) { diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index c5a9045ca6..38c029475c 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -93,8 +93,8 @@ public: void set_tab_title(int p_tab, const String &p_title); String get_tab_title(int p_tab) const; - void set_tab_icon(int p_tab, const Ref<Texture> &p_icon); - Ref<Texture> get_tab_icon(int p_tab) const; + void set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_tab_icon(int p_tab) const; void set_tab_disabled(int p_tab, bool p_disabled); bool get_tab_disabled(int p_tab) const; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 6cd95e73fc..4aa7ea8cb1 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -46,7 +46,7 @@ Size2 Tabs::get_minimum_size() const { for (int i = 0; i < tabs.size(); i++) { - Ref<Texture> tex = tabs[i].icon; + Ref<Texture2D> tex = tabs[i].icon; if (tex.is_valid()) { ms.height = MAX(ms.height, tex->get_size().height); if (tabs[i].text != "") @@ -63,7 +63,7 @@ Size2 Tabs::get_minimum_size() const { ms.width += tab_bg->get_minimum_size().width; if (tabs[i].right_button.is_valid()) { - Ref<Texture> rb = tabs[i].right_button; + Ref<Texture2D> rb = tabs[i].right_button; Size2 bms = rb->get_size(); bms.width += get_constant("hseparation"); ms.width += bms.width; @@ -71,7 +71,7 @@ Size2 Tabs::get_minimum_size() const { } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); Size2 bms = cb->get_size(); bms.width += get_constant("hseparation"); ms.width += bms.width; @@ -94,8 +94,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { highlight_arrow = -1; if (buttons_visible) { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -163,8 +163,8 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (buttons_visible) { - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -245,7 +245,7 @@ void Tabs::_notification(int p_what) { Color color_fg = get_color("font_color_fg"); Color color_bg = get_color("font_color_bg"); Color color_disabled = get_color("font_color_disabled"); - Ref<Texture> close = get_icon("close"); + Ref<Texture2D> close = get_icon("close"); int h = get_size().height; int w = 0; @@ -267,10 +267,10 @@ void Tabs::_notification(int p_what) { w = 0; } - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); - Ref<Texture> incr_hl = get_icon("increment_highlight"); - Ref<Texture> decr_hl = get_icon("decrement_highlight"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); + Ref<Texture2D> incr_hl = get_icon("increment_highlight"); + Ref<Texture2D> decr_hl = get_icon("decrement_highlight"); int limit = get_size().width - incr->get_size().width - decr->get_size().width; @@ -313,7 +313,7 @@ void Tabs::_notification(int p_what) { w += sb->get_margin(MARGIN_LEFT); Size2i sb_ms = sb->get_minimum_size(); - Ref<Texture> icon = tabs[i].icon; + Ref<Texture2D> icon = tabs[i].icon; if (icon.is_valid()) { icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2)); @@ -328,7 +328,7 @@ void Tabs::_notification(int p_what) { if (tabs[i].right_button.is_valid()) { Ref<StyleBox> style = get_stylebox("button"); - Ref<Texture> rb = tabs[i].right_button; + Ref<Texture2D> rb = tabs[i].right_button; w += get_constant("hseparation"); @@ -352,7 +352,7 @@ void Tabs::_notification(int p_what) { if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { Ref<StyleBox> style = get_stylebox("button"); - Ref<Texture> cb = close; + Ref<Texture2D> cb = close; w += get_constant("hseparation"); @@ -449,7 +449,7 @@ String Tabs::get_tab_title(int p_tab) const { return tabs[p_tab].text; } -void Tabs::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { +void Tabs::set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].icon = p_icon; @@ -457,9 +457,9 @@ void Tabs::set_tab_icon(int p_tab, const Ref<Texture> &p_icon) { minimum_size_changed(); } -Ref<Texture> Tabs::get_tab_icon(int p_tab) const { +Ref<Texture2D> Tabs::get_tab_icon(int p_tab) const { - ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>()); return tabs[p_tab].icon; } @@ -475,7 +475,7 @@ bool Tabs::get_tab_disabled(int p_tab) const { return tabs[p_tab].disabled; } -void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) { +void Tabs::set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button) { ERR_FAIL_INDEX(p_tab, tabs.size()); tabs.write[p_tab].right_button = p_right_button; @@ -483,9 +483,9 @@ void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) { update(); minimum_size_changed(); } -Ref<Texture> Tabs::get_tab_right_button(int p_tab) const { +Ref<Texture2D> Tabs::get_tab_right_button(int p_tab) const { - ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_tab, tabs.size(), Ref<Texture2D>()); return tabs[p_tab].right_button; } @@ -536,8 +536,8 @@ void Tabs::_update_cache() { Ref<StyleBox> tab_bg = get_stylebox("tab_bg"); Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); Ref<Font> font = get_font("font"); - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); int w = 0; @@ -580,7 +580,7 @@ void Tabs::_update_cache() { slen -= get_constant("hseparation"); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); slen -= cb->get_width(); slen -= get_constant("hseparation"); } @@ -604,7 +604,7 @@ void Tabs::_on_mouse_exited() { update(); } -void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) { +void Tabs::add_tab(const String &p_str, const Ref<Texture2D> &p_icon) { Tab t; t.text = p_str; @@ -806,7 +806,7 @@ int Tabs::get_tab_width(int p_idx) const { int x = 0; - Ref<Texture> tex = tabs[p_idx].icon; + Ref<Texture2D> tex = tabs[p_idx].icon; if (tex.is_valid()) { x += tex->get_width(); if (tabs[p_idx].text != "") @@ -823,13 +823,13 @@ int Tabs::get_tab_width(int p_idx) const { x += tab_bg->get_minimum_size().width; if (tabs[p_idx].right_button.is_valid()) { - Ref<Texture> rb = tabs[p_idx].right_button; + Ref<Texture2D> rb = tabs[p_idx].right_button; x += rb->get_width(); x += get_constant("hseparation"); } if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && p_idx == current)) { - Ref<Texture> cb = get_icon("close"); + Ref<Texture2D> cb = get_icon("close"); x += cb->get_width(); x += get_constant("hseparation"); } @@ -842,8 +842,8 @@ void Tabs::_ensure_no_over_offset() { if (!is_inside_tree()) return; - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); @@ -885,8 +885,8 @@ void Tabs::ensure_tab_visible(int p_idx) { } int prev_offset = offset; - Ref<Texture> incr = get_icon("increment"); - Ref<Texture> decr = get_icon("decrement"); + Ref<Texture2D> incr = get_icon("increment"); + Ref<Texture2D> decr = get_icon("decrement"); int limit = get_size().width - incr->get_width() - decr->get_width(); for (int i = offset; i <= p_idx; i++) { if (tabs[i].ofs_cache + tabs[i].size_cache > limit) { @@ -967,7 +967,7 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tab_disabled", "tab_idx", "disabled"), &Tabs::set_tab_disabled); ClassDB::bind_method(D_METHOD("get_tab_disabled", "tab_idx"), &Tabs::get_tab_disabled); ClassDB::bind_method(D_METHOD("remove_tab", "tab_idx"), &Tabs::remove_tab); - ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture>())); + ClassDB::bind_method(D_METHOD("add_tab", "title", "icon"), &Tabs::add_tab, DEFVAL(""), DEFVAL(Ref<Texture2D>())); ClassDB::bind_method(D_METHOD("set_tab_align", "align"), &Tabs::set_tab_align); ClassDB::bind_method(D_METHOD("get_tab_align"), &Tabs::get_tab_align); ClassDB::bind_method(D_METHOD("get_tab_offset"), &Tabs::get_tab_offset); diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index c06e47a54a..3170acb46f 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -59,7 +59,7 @@ private: String text; String xl_text; - Ref<Texture> icon; + Ref<Texture2D> icon; int ofs_cache; bool disabled; int size_cache; @@ -67,7 +67,7 @@ private: int x_cache; int x_size_cache; - Ref<Texture> right_button; + Ref<Texture2D> right_button; Rect2 rb_rect; Rect2 cb_rect; }; @@ -115,19 +115,19 @@ protected: int get_tab_idx_at_point(const Point2 &p_point) const; public: - void add_tab(const String &p_str = "", const Ref<Texture> &p_icon = Ref<Texture>()); + void add_tab(const String &p_str = "", const Ref<Texture2D> &p_icon = Ref<Texture2D>()); void set_tab_title(int p_tab, const String &p_title); String get_tab_title(int p_tab) const; - void set_tab_icon(int p_tab, const Ref<Texture> &p_icon); - Ref<Texture> get_tab_icon(int p_tab) const; + void set_tab_icon(int p_tab, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_tab_icon(int p_tab) const; void set_tab_disabled(int p_tab, bool p_disabled); bool get_tab_disabled(int p_tab) const; - void set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button); - Ref<Texture> get_tab_right_button(int p_tab) const; + void set_tab_right_button(int p_tab, const Ref<Texture2D> &p_right_button); + Ref<Texture2D> get_tab_right_button(int p_tab) const; void set_tab_align(TabAlign p_align); TabAlign get_tab_align() const; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9d5e004ed3..a5c316848e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1216,7 +1216,7 @@ void TextEdit::_notification(int p_what) { int horizontal_gap = (cache.info_gutter_width * 30) / 100; int gutter_left = cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width; - Ref<Texture> info_icon = text.get_info_icon(line); + Ref<Texture2D> info_icon = text.get_info_icon(line); // Ensure the icon fits the gutter size. Size2i icon_size = info_icon->get_size(); if (icon_size.width > cache.info_gutter_width - horizontal_gap) { @@ -1645,7 +1645,7 @@ void TextEdit::_notification(int p_what) { Point2 title_pos(completion_rect.position.x, completion_rect.position.y + i * get_row_height() + cache.font->get_ascent() + yofs); // Draw completion icon if it is valid. - Ref<Texture> icon = completion_options[l].icon; + Ref<Texture2D> icon = completion_options[l].icon; Rect2 icon_area(completion_rect.position.x, completion_rect.position.y + i * get_row_height(), icon_area_size.width, icon_area_size.height); if (icon.is_valid()) { const real_t max_scale = 0.7f; @@ -5690,7 +5690,7 @@ void TextEdit::remove_breakpoints() { } } -void TextEdit::set_line_info_icon(int p_line, Ref<Texture> p_icon, String p_info) { +void TextEdit::set_line_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info) { ERR_FAIL_INDEX(p_line, text.size()); text.set_info_icon(p_line, p_icon, p_info); update(); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index b4e7dcfebb..a849f62bc5 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -85,7 +85,7 @@ public: bool has_info : 1; int wrap_amount_cache : 24; Map<int, ColorRegionInfo> region_info; - Ref<Texture> info_icon; + Ref<Texture2D> info_icon; String info; String data; Line() { @@ -129,7 +129,7 @@ public: bool is_hidden(int p_line) const { return text[p_line].hidden; } void set_safe(int p_line, bool p_safe) { text.write[p_line].safe = p_safe; } bool is_safe(int p_line) const { return text[p_line].safe; } - void set_info_icon(int p_line, Ref<Texture> p_icon, String p_info) { + void set_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info) { if (p_icon.is_null()) { text.write[p_line].has_info = false; return; @@ -139,7 +139,7 @@ public: text.write[p_line].has_info = true; } bool has_info_icon(int p_line) const { return text[p_line].has_info; } - const Ref<Texture> &get_info_icon(int p_line) const { return text[p_line].info_icon; } + const Ref<Texture2D> &get_info_icon(int p_line) const { return text[p_line].info_icon; } const String &get_info(int p_line) const { return text[p_line].info; } void insert(int p_at, const String &p_text); void remove(int p_at); @@ -208,12 +208,12 @@ private: struct Cache { - Ref<Texture> tab_icon; - Ref<Texture> space_icon; - Ref<Texture> can_fold_icon; - Ref<Texture> folded_icon; - Ref<Texture> folded_eol_icon; - Ref<Texture> executing_icon; + Ref<Texture2D> tab_icon; + Ref<Texture2D> space_icon; + Ref<Texture2D> can_fold_icon; + Ref<Texture2D> folded_icon; + Ref<Texture2D> folded_eol_icon; + Ref<Texture2D> executing_icon; Ref<StyleBox> style_normal; Ref<StyleBox> style_focus; Ref<StyleBox> style_readonly; @@ -603,7 +603,7 @@ public: Array get_breakpoints_array() const; void remove_breakpoints(); - void set_line_info_icon(int p_line, Ref<Texture> p_icon, String p_info = ""); + void set_line_info_icon(int p_line, Ref<Texture2D> p_icon, String p_info = ""); void clear_info_icons(); void set_line_as_hidden(int p_line, bool p_hidden); diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 9ffb69037a..5f2e4cf58e 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -122,7 +122,7 @@ void TextureButton::_notification(int p_what) { case NOTIFICATION_DRAW: { DrawMode draw_mode = get_draw_mode(); - Ref<Texture> texdraw; + Ref<Texture2D> texdraw; switch (draw_mode) { case DRAW_NORMAL: { @@ -252,11 +252,11 @@ void TextureButton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureButton::get_stretch_mode); ADD_GROUP("Textures", "texture_"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_texture", "get_normal_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_pressed_texture", "get_pressed_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_hover", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_hover_texture", "get_hover_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_disabled", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_disabled_texture", "get_disabled_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_focused_texture", "get_focused_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_texture", "get_normal_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_pressed", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_pressed_texture", "get_pressed_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_hover", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_hover_texture", "get_hover_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_disabled", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_disabled_texture", "get_disabled_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_focused", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_focused_texture", "get_focused_texture"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_click_mask", PROPERTY_HINT_RESOURCE_TYPE, "BitMap"), "set_click_mask", "get_click_mask"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand", PROPERTY_HINT_RESOURCE_TYPE, "bool"), "set_expand", "get_expand"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); @@ -270,24 +270,24 @@ void TextureButton::_bind_methods() { BIND_ENUM_CONSTANT(STRETCH_KEEP_ASPECT_COVERED); } -void TextureButton::set_normal_texture(const Ref<Texture> &p_normal) { +void TextureButton::set_normal_texture(const Ref<Texture2D> &p_normal) { normal = p_normal; update(); minimum_size_changed(); } -void TextureButton::set_pressed_texture(const Ref<Texture> &p_pressed) { +void TextureButton::set_pressed_texture(const Ref<Texture2D> &p_pressed) { pressed = p_pressed; update(); } -void TextureButton::set_hover_texture(const Ref<Texture> &p_hover) { +void TextureButton::set_hover_texture(const Ref<Texture2D> &p_hover) { hover = p_hover; update(); } -void TextureButton::set_disabled_texture(const Ref<Texture> &p_disabled) { +void TextureButton::set_disabled_texture(const Ref<Texture2D> &p_disabled) { disabled = p_disabled; update(); @@ -298,19 +298,19 @@ void TextureButton::set_click_mask(const Ref<BitMap> &p_click_mask) { update(); } -Ref<Texture> TextureButton::get_normal_texture() const { +Ref<Texture2D> TextureButton::get_normal_texture() const { return normal; } -Ref<Texture> TextureButton::get_pressed_texture() const { +Ref<Texture2D> TextureButton::get_pressed_texture() const { return pressed; } -Ref<Texture> TextureButton::get_hover_texture() const { +Ref<Texture2D> TextureButton::get_hover_texture() const { return hover; } -Ref<Texture> TextureButton::get_disabled_texture() const { +Ref<Texture2D> TextureButton::get_disabled_texture() const { return disabled; } @@ -319,12 +319,12 @@ Ref<BitMap> TextureButton::get_click_mask() const { return click_mask; } -Ref<Texture> TextureButton::get_focused_texture() const { +Ref<Texture2D> TextureButton::get_focused_texture() const { return focused; }; -void TextureButton::set_focused_texture(const Ref<Texture> &p_focused) { +void TextureButton::set_focused_texture(const Ref<Texture2D> &p_focused) { focused = p_focused; }; diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index e39b94abf0..43b10a8e8b 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -49,11 +49,11 @@ public: }; private: - Ref<Texture> normal; - Ref<Texture> pressed; - Ref<Texture> hover; - Ref<Texture> disabled; - Ref<Texture> focused; + Ref<Texture2D> normal; + Ref<Texture2D> pressed; + Ref<Texture2D> hover; + Ref<Texture2D> disabled; + Ref<Texture2D> focused; Ref<BitMap> click_mask; bool expand; StretchMode stretch_mode; @@ -69,18 +69,18 @@ protected: static void _bind_methods(); public: - void set_normal_texture(const Ref<Texture> &p_normal); - void set_pressed_texture(const Ref<Texture> &p_pressed); - void set_hover_texture(const Ref<Texture> &p_hover); - void set_disabled_texture(const Ref<Texture> &p_disabled); - void set_focused_texture(const Ref<Texture> &p_focused); + void set_normal_texture(const Ref<Texture2D> &p_normal); + void set_pressed_texture(const Ref<Texture2D> &p_pressed); + void set_hover_texture(const Ref<Texture2D> &p_hover); + void set_disabled_texture(const Ref<Texture2D> &p_disabled); + void set_focused_texture(const Ref<Texture2D> &p_focused); void set_click_mask(const Ref<BitMap> &p_click_mask); - Ref<Texture> get_normal_texture() const; - Ref<Texture> get_pressed_texture() const; - Ref<Texture> get_hover_texture() const; - Ref<Texture> get_disabled_texture() const; - Ref<Texture> get_focused_texture() const; + Ref<Texture2D> get_normal_texture() const; + Ref<Texture2D> get_pressed_texture() const; + Ref<Texture2D> get_hover_texture() const; + Ref<Texture2D> get_disabled_texture() const; + Ref<Texture2D> get_focused_texture() const; Ref<BitMap> get_click_mask() const; bool get_expand() const; diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 2d30ff7334..c5650b1795 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -32,19 +32,19 @@ #include "core/engine.h" -void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_under_texture(const Ref<Texture2D> &p_texture) { under = p_texture; update(); minimum_size_changed(); } -Ref<Texture> TextureProgress::get_under_texture() const { +Ref<Texture2D> TextureProgress::get_under_texture() const { return under; } -void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_over_texture(const Ref<Texture2D> &p_texture) { over = p_texture; update(); @@ -53,7 +53,7 @@ void TextureProgress::set_over_texture(const Ref<Texture> &p_texture) { } } -Ref<Texture> TextureProgress::get_over_texture() const { +Ref<Texture2D> TextureProgress::get_over_texture() const { return over; } @@ -94,14 +94,14 @@ Size2 TextureProgress::get_minimum_size() const { return Size2(1, 1); } -void TextureProgress::set_progress_texture(const Ref<Texture> &p_texture) { +void TextureProgress::set_progress_texture(const Ref<Texture2D> &p_texture) { progress = p_texture; update(); minimum_size_changed(); } -Ref<Texture> TextureProgress::get_progress_texture() const { +Ref<Texture2D> TextureProgress::get_progress_texture() const { return progress; } @@ -201,7 +201,7 @@ Point2 TextureProgress::get_relative_center() { return p; } -void TextureProgress::draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) { +void TextureProgress::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) { Vector2 texture_size = p_texture->get_size(); Vector2 topleft = Vector2(stretch_margin[MARGIN_LEFT], stretch_margin[MARGIN_TOP]); Vector2 bottomright = Vector2(stretch_margin[MARGIN_RIGHT], stretch_margin[MARGIN_BOTTOM]); @@ -501,9 +501,9 @@ void TextureProgress::_bind_methods() { ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgress::get_nine_patch_stretch); ADD_GROUP("Textures", "texture_"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_under_texture", "get_under_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_over_texture", "get_over_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_progress_texture", "get_progress_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_under_texture", "get_under_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_over_texture", "get_over_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_progress_texture", "get_progress_texture"); ADD_PROPERTY(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom), Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode"); ADD_GROUP("Tint", "tint_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under"); diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h index e4a40fd6a3..e05f89aa3e 100644 --- a/scene/gui/texture_progress.h +++ b/scene/gui/texture_progress.h @@ -37,9 +37,9 @@ class TextureProgress : public Range { GDCLASS(TextureProgress, Range); - Ref<Texture> under; - Ref<Texture> progress; - Ref<Texture> over; + Ref<Texture2D> under; + Ref<Texture2D> progress; + Ref<Texture2D> over; protected: static void _bind_methods(); @@ -70,14 +70,14 @@ public: void set_radial_center_offset(const Point2 &p_off); Point2 get_radial_center_offset(); - void set_under_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_under_texture() const; + void set_under_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_under_texture() const; - void set_progress_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_progress_texture() const; + void set_progress_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_progress_texture() const; - void set_over_texture(const Ref<Texture> &p_texture); - Ref<Texture> get_over_texture() const; + void set_over_texture(const Ref<Texture2D> &p_texture); + Ref<Texture2D> get_over_texture() const; void set_stretch_margin(Margin p_margin, int p_size); int get_stretch_margin(Margin p_margin) const; @@ -109,7 +109,7 @@ private: Point2 unit_val_to_uv(float val); Point2 get_relative_center(); - void draw_nine_patch_stretched(const Ref<Texture> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate); + void draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate); }; VARIANT_ENUM_CAST(TextureProgress::FillMode); diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 514eff358e..64693e2531 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -129,7 +129,7 @@ void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureRect::get_stretch_mode); ClassDB::bind_method(D_METHOD("_texture_changed"), &TextureRect::_texture_changed); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); ADD_PROPERTY(PropertyInfo(Variant::INT, "stretch_mode", PROPERTY_HINT_ENUM, "Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered,Keep Aspect Covered"), "set_stretch_mode", "get_stretch_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h"); @@ -153,7 +153,7 @@ void TextureRect::_texture_changed() { } } -void TextureRect::set_texture(const Ref<Texture> &p_tex) { +void TextureRect::set_texture(const Ref<Texture2D> &p_tex) { if (p_tex == texture) { return; @@ -173,7 +173,7 @@ void TextureRect::set_texture(const Ref<Texture> &p_tex) { minimum_size_changed(); } -Ref<Texture> TextureRect::get_texture() const { +Ref<Texture2D> TextureRect::get_texture() const { return texture; } diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index ef970fa051..77a2828fd4 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -53,7 +53,7 @@ private: bool expand; bool hflip; bool vflip; - Ref<Texture> texture; + Ref<Texture2D> texture; StretchMode stretch_mode; void _texture_changed(); @@ -64,8 +64,8 @@ protected: static void _bind_methods(); public: - void set_texture(const Ref<Texture> &p_tex); - Ref<Texture> get_texture() const; + void set_texture(const Ref<Texture2D> &p_tex); + Ref<Texture2D> get_texture() const; void set_expand(bool p_expand); bool has_expand() const; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 790e1d5f4f..7bfe060065 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -129,7 +129,7 @@ void TreeItem::set_cell_mode(int p_column, TreeCellMode p_mode) { c.step = 1; c.val = 0; c.checked = false; - c.icon = Ref<Texture>(); + c.icon = Ref<Texture2D>(); c.text = ""; c.icon_max_w = 0; _changed_notify(p_column); @@ -198,16 +198,16 @@ String TreeItem::get_suffix(int p_column) const { return cells[p_column].suffix; } -void TreeItem::set_icon(int p_column, const Ref<Texture> &p_icon) { +void TreeItem::set_icon(int p_column, const Ref<Texture2D> &p_icon) { ERR_FAIL_INDEX(p_column, cells.size()); cells.write[p_column].icon = p_icon; _changed_notify(p_column); } -Ref<Texture> TreeItem::get_icon(int p_column) const { +Ref<Texture2D> TreeItem::get_icon(int p_column) const { - ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>()); + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>()); return cells[p_column].icon; } @@ -522,7 +522,7 @@ void TreeItem::deselect(int p_column) { _cell_deselected(p_column); } -void TreeItem::add_button(int p_column, const Ref<Texture> &p_button, int p_id, bool p_disabled, const String &p_tooltip) { +void TreeItem::add_button(int p_column, const Ref<Texture2D> &p_button, int p_id, bool p_disabled, const String &p_tooltip) { ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_COND(!p_button.is_valid()); @@ -542,9 +542,9 @@ int TreeItem::get_button_count(int p_column) const { ERR_FAIL_INDEX_V(p_column, cells.size(), -1); return cells[p_column].buttons.size(); } -Ref<Texture> TreeItem::get_button(int p_column, int p_idx) const { - ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture>()); - ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture>()); +Ref<Texture2D> TreeItem::get_button(int p_column, int p_idx) const { + ERR_FAIL_INDEX_V(p_column, cells.size(), Ref<Texture2D>()); + ERR_FAIL_INDEX_V(p_idx, cells[p_column].buttons.size(), Ref<Texture2D>()); return cells[p_column].buttons[p_idx].texture; } String TreeItem::get_button_tooltip(int p_column, int p_idx) const { @@ -577,7 +577,7 @@ int TreeItem::get_button_by_id(int p_column, int p_id) const { return -1; } -void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture> &p_button) { +void TreeItem::set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button) { ERR_FAIL_COND(p_button.is_null()); ERR_FAIL_INDEX(p_column, cells.size()); @@ -1026,7 +1026,7 @@ int Tree::compute_item_height(TreeItem *p_item) const { case TreeItem::CELL_MODE_CUSTOM: case TreeItem::CELL_MODE_ICON: { - Ref<Texture> icon = p_item->cells[i].icon; + Ref<Texture2D> icon = p_item->cells[i].icon; if (!icon.is_null()) { Size2i s = p_item->cells[i].get_icon_size(); @@ -1190,7 +1190,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 int bw = 0; for (int j = p_item->cells[i].buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = p_item->cells[i].buttons[j].texture; + Ref<Texture2D> b = p_item->cells[i].buttons[j].texture; Size2 s = b->get_size() + cache.button_pressed->get_minimum_size(); if (s.height < label_h) s.height = label_h; @@ -1305,8 +1305,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 } break; case TreeItem::CELL_MODE_CHECK: { - Ref<Texture> checked = cache.checked; - Ref<Texture> unchecked = cache.unchecked; + Ref<Texture2D> checked = cache.checked; + Ref<Texture2D> unchecked = cache.unchecked; Point2i check_ofs = item_rect.position; check_ofs.y += Math::floor((real_t)(item_rect.size.y - checked->get_height()) / 2); @@ -1350,7 +1350,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (p_item->cells[i].suffix != String()) s += " " + p_item->cells[i].suffix; - Ref<Texture> downarrow = cache.select_arrow; + Ref<Texture2D> downarrow = cache.select_arrow; font->draw(ci, text_pos, s, col, item_rect.size.x - downarrow->get_width()); @@ -1361,7 +1361,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 downarrow->draw(ci, arrow_pos); } else { - Ref<Texture> updown = cache.updown; + Ref<Texture2D> updown = cache.updown; String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step)); @@ -1412,7 +1412,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 break; } - Ref<Texture> downarrow = cache.select_arrow; + Ref<Texture2D> downarrow = cache.select_arrow; Rect2i ir = item_rect; @@ -1462,7 +1462,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (!p_item->disable_folding && !hide_folding && p_item->children) { //has children, draw the guide box - Ref<Texture> arrow; + Ref<Texture2D> arrow; if (p_item->collapsed) { @@ -1775,7 +1775,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool bool already_cursor = (p_item == selected_item) && col == selected_col; for (int j = c.buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = c.buttons[j].texture; + Ref<Texture2D> b = c.buttons[j].texture; int w = b->get_size().width + cache.button_pressed->get_minimum_size().width; if (x > col_width - w) { @@ -3825,7 +3825,7 @@ String Tree::get_tooltip(const Point2 &p_pos) const { pos.x -= get_column_width(i); for (int j = c.buttons.size() - 1; j >= 0; j--) { - Ref<Texture> b = c.buttons[j].texture; + Ref<Texture2D> b = c.buttons[j].texture; Size2 size = b->get_size() + cache.button_pressed->get_minimum_size(); if (pos.x > col_width - size.width) { String tooltip = c.buttons[j].tooltip; diff --git a/scene/gui/tree.h b/scene/gui/tree.h index f3c88eb5ac..2072d0fd13 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -66,7 +66,7 @@ private: TreeCellMode mode; - Ref<Texture> icon; + Ref<Texture2D> icon; Rect2i icon_region; String text; String suffix; @@ -97,7 +97,7 @@ private: struct Button { int id; bool disabled; - Ref<Texture> texture; + Ref<Texture2D> texture; Color color; String tooltip; Button() { @@ -189,8 +189,8 @@ public: void set_suffix(int p_column, String p_suffix); String get_suffix(int p_column) const; - void set_icon(int p_column, const Ref<Texture> &p_icon); - Ref<Texture> get_icon(int p_column) const; + void set_icon(int p_column, const Ref<Texture2D> &p_icon); + Ref<Texture2D> get_icon(int p_column) const; void set_icon_region(int p_column, const Rect2 &p_icon_region); Rect2 get_icon_region(int p_column) const; @@ -201,14 +201,14 @@ public: void set_icon_max_width(int p_column, int p_max); int get_icon_max_width(int p_column) const; - void add_button(int p_column, const Ref<Texture> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); + void add_button(int p_column, const Ref<Texture2D> &p_button, int p_id = -1, bool p_disabled = false, const String &p_tooltip = ""); int get_button_count(int p_column) const; String get_button_tooltip(int p_column, int p_idx) const; - Ref<Texture> get_button(int p_column, int p_idx) const; + Ref<Texture2D> get_button(int p_column, int p_idx) const; int get_button_id(int p_column, int p_idx) const; void erase_button(int p_column, int p_idx); int get_button_by_id(int p_column, int p_id) const; - void set_button(int p_column, int p_idx, const Ref<Texture> &p_button); + void set_button(int p_column, int p_idx, const Ref<Texture2D> &p_button); void set_button_color(int p_column, int p_idx, const Color &p_color); void set_button_disabled(int p_column, int p_idx, bool p_disabled); bool is_button_disabled(int p_column, int p_idx) const; @@ -374,7 +374,7 @@ private: int compute_item_height(TreeItem *p_item) const; int get_item_height(TreeItem *p_item) const; - //void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); + //void draw_item_text(String p_text,const Ref<Texture2D>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color); void draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, const Color &p_color, const Color &p_icon_color); int draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item); void select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev = NULL, bool *r_in_range = NULL, bool p_force_deselect = false); @@ -416,12 +416,12 @@ private: Color title_button_color; - Ref<Texture> checked; - Ref<Texture> unchecked; - Ref<Texture> arrow_collapsed; - Ref<Texture> arrow; - Ref<Texture> select_arrow; - Ref<Texture> updown; + Ref<Texture2D> checked; + Ref<Texture2D> unchecked; + Ref<Texture2D> arrow_collapsed; + Ref<Texture2D> arrow; + Ref<Texture2D> select_arrow; + Ref<Texture2D> updown; Color font_color; Color font_color_selected; diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 0a693d4023..3d8112b986 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -375,12 +375,12 @@ void VideoPlayer::set_stream_position(float p_position) { playback->seek(p_position); } -Ref<Texture> VideoPlayer::get_video_texture() const { +Ref<Texture2D> VideoPlayer::get_video_texture() const { if (playback.is_valid()) return playback->get_texture(); - return Ref<Texture>(); + return Ref<Texture2D>(); } void VideoPlayer::set_autoplay(bool p_enable) { diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index e740e3e4ed..78e7fa05f8 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -86,7 +86,7 @@ public: void set_expand(bool p_expand); bool has_expand() const; - Ref<Texture> get_video_texture() const; + Ref<Texture2D> get_video_texture() const; void set_stream(const Ref<VideoStream> &p_stream); Ref<VideoStream> get_stream() const; |