diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/button_array.cpp | 12 | ||||
-rw-r--r-- | scene/gui/color_picker.cpp | 22 | ||||
-rw-r--r-- | scene/gui/color_ramp_edit.cpp | 10 | ||||
-rw-r--r-- | scene/gui/container.cpp | 6 | ||||
-rw-r--r-- | scene/gui/control.cpp | 26 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 30 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 26 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 6 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 44 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/popup.cpp | 10 | ||||
-rw-r--r-- | scene/gui/popup_menu.cpp | 16 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 4 | ||||
-rw-r--r-- | scene/gui/scroll_bar.cpp | 14 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 4 | ||||
-rw-r--r-- | scene/gui/slider.cpp | 4 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 6 | ||||
-rw-r--r-- | scene/gui/split_container.cpp | 10 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 16 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 32 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 156 | ||||
-rw-r--r-- | scene/gui/tree.h | 13 |
24 files changed, 275 insertions, 202 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 318db8458b..c1dbc82f3c 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -162,7 +162,7 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) { if (mm.is_valid()) { if (status.press_attempt && status.pressing_button == 0) { bool last_press_inside = status.pressing_inside; - status.pressing_inside = has_point(mm->get_pos()); + status.pressing_inside = has_point(mm->get_position()); if (last_press_inside != status.pressing_inside) update(); } diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index 0d518059c8..1616272e66 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -236,8 +236,8 @@ void ButtonArray::_notification(int p_what) { } Rect2 r; - r.pos[orientation] = ofs; - r.pos[!orientation] = 0; + r.position[orientation] = ofs; + r.position[!orientation] = 0; r.size[orientation] = s; r.size[!orientation] = op_size; @@ -272,10 +272,10 @@ void ButtonArray::_notification(int p_what) { Point2 text_ofs = ((r.size - ssize - sbsize) / 2.0 + Point2(0, f->get_ascent())).floor() + sbofs; if (buttons[i].icon.is_valid()) { - draw_texture(buttons[i].icon, r.pos + Point2(text_ofs.x, Math::floor((r.size.height - buttons[i].icon->get_height()) / 2.0))); + draw_texture(buttons[i].icon, r.position + Point2(text_ofs.x, Math::floor((r.size.height - buttons[i].icon->get_height()) / 2.0))); text_ofs.x += buttons[i].icon->get_width() + icon_sep; } - draw_string(f, text_ofs + r.pos, buttons[i].xl_text, c); + draw_string(f, text_ofs + r.position, buttons[i].xl_text, c); buttons[i]._pos_cache = ofs; buttons[i]._size_cache = s; @@ -313,7 +313,7 @@ void ButtonArray::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - int ofs = orientation == HORIZONTAL ? mb->get_pos().x : mb->get_pos().y; + int ofs = orientation == HORIZONTAL ? mb->get_position().x : mb->get_position().y; for (int i = 0; i < buttons.size(); i++) { @@ -330,7 +330,7 @@ void ButtonArray::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { - int ofs = orientation == HORIZONTAL ? mm->get_pos().x : mm->get_pos().y; + int ofs = orientation == HORIZONTAL ? mm->get_position().x : mm->get_position().y; int new_hover = -1; for (int i = 0; i < buttons.size(); i++) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 662ce63946..f0e486aa50 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -304,8 +304,8 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &ev) { if (bev.is_valid()) { if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { changing_color = true; - float x = CLAMP((float)bev->get_pos().x, 0, 256); - float y = CLAMP((float)bev->get_pos().y, 0, 256); + float x = CLAMP((float)bev->get_position().x, 0, 256); + float y = CLAMP((float)bev->get_position().y, 0, 256); s = x / 256; v = 1.0 - y / 256.0; color.set_hsv(h, s, v, color.a); @@ -323,8 +323,8 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &ev) { if (mev.is_valid()) { if (!changing_color) return; - float x = CLAMP((float)mev->get_pos().x, 0, 256); - float y = CLAMP((float)mev->get_pos().y, 0, 256); + float x = CLAMP((float)mev->get_position().x, 0, 256); + float y = CLAMP((float)mev->get_position().y, 0, 256); s = x / 256; v = 1.0 - y / 256.0; color.set_hsv(h, s, v, color.a); @@ -343,7 +343,7 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) { if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { changing_color = true; - h = 1 - ((float)bev->get_pos().y) / 256.0; + h = 1 - ((float)bev->get_position().y) / 256.0; } else { changing_color = false; @@ -361,7 +361,7 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) { if (!changing_color) return; - float y = CLAMP((float)mev->get_pos().y, 0, 256); + float y = CLAMP((float)mev->get_position().y, 0, 256); h = 1.0 - y / 256.0; color.set_hsv(h, s, v, color.a); last_hsv = color; @@ -378,10 +378,10 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &ev) { if (bev.is_valid()) { if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { - int index = bev->get_pos().x / (preset->get_size().x / presets.size()); + int index = bev->get_position().x / (preset->get_size().x / presets.size()); set_pick_color(presets[index]); } else if (bev->is_pressed() && bev->get_button_index() == BUTTON_RIGHT) { - int index = bev->get_pos().x / (preset->get_size().x / presets.size()); + int index = bev->get_position().x / (preset->get_size().x / presets.size()); presets.erase(presets[index]); _update_presets(); bt_add_preset->show(); @@ -394,7 +394,7 @@ void ColorPicker::_preset_input(const Ref<InputEvent> &ev) { if (mev.is_valid()) { - int index = mev->get_pos().x * presets.size(); + int index = mev->get_position().x * presets.size(); if (preset->get_size().x != 0) { index /= preset->get_size().x; } @@ -422,7 +422,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &ev) { if (mev.is_valid()) { Viewport *r = get_tree()->get_root(); - if (!r->get_visible_rect().has_point(Point2(mev->get_global_pos().x, mev->get_global_pos().y))) + if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y))) return; Ref<Image> img = r->get_screen_capture(); if (!img.is_null()) { @@ -431,7 +431,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &ev) { } if (last_capture.is_valid() && !last_capture->empty()) { int pw = last_capture->get_format() == Image::FORMAT_RGBA8 ? 4 : 3; - int ofs = (mev->get_global_pos().y * last_capture->get_width() + mev->get_global_pos().x) * pw; + int ofs = (mev->get_global_position().y * last_capture->get_width() + mev->get_global_position().x) * pw; PoolVector<uint8_t>::Read r = last_capture->get_data().read(); diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp index 8c47f8559a..33e4ce0403 100644 --- a/scene/gui/color_ramp_edit.cpp +++ b/scene/gui/color_ramp_edit.cpp @@ -88,14 +88,14 @@ void ColorRampEdit::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventMouseButton> mb = p_event; //Show color picker on double click. if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_doubleclick() && mb->is_pressed()) { - grabbed = _get_point_from_pos(mb->get_pos().x); + grabbed = _get_point_from_pos(mb->get_position().x); _show_color_picker(); accept_event(); } //Delete point on right click if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) { - grabbed = _get_point_from_pos(mb->get_pos().x); + grabbed = _get_point_from_pos(mb->get_position().x); if (grabbed != -1) { points.remove(grabbed); grabbed = -1; @@ -109,7 +109,7 @@ void ColorRampEdit::_gui_input(const Ref<InputEvent> &p_event) { //Hold alt key to duplicate selected color if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed() && mb->get_alt()) { - int x = mb->get_pos().x; + int x = mb->get_position().x; grabbed = _get_point_from_pos(x); if (grabbed != -1) { @@ -134,7 +134,7 @@ void ColorRampEdit::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->get_button_index() == 1 && mb->is_pressed()) { update(); - int x = mb->get_pos().x; + int x = mb->get_position().x; int total_w = get_size().width - get_size().height - 3; //Check if color selector was clicked. @@ -214,7 +214,7 @@ void ColorRampEdit::_gui_input(const Ref<InputEvent> &p_event) { int total_w = get_size().width - get_size().height - 3; - int x = mm->get_pos().x; + int x = mm->get_position().x; float newofs = CLAMP(x / float(total_w), 0, 1); diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index c428d524a4..92bb5d43a7 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -96,18 +96,18 @@ void Container::fit_child_in_rect(Control *p_child, const Rect2 &p_rect) { if (!(p_child->get_h_size_flags() & SIZE_FILL)) { r.size.x = minsize.x; - r.pos.x += Math::floor((p_rect.size.x - minsize.x) / 2); + r.position.x += Math::floor((p_rect.size.x - minsize.x) / 2); } if (!(p_child->get_v_size_flags() & SIZE_FILL)) { r.size.y = minsize.y; - r.pos.y += Math::floor((p_rect.size.y - minsize.y) / 2); + r.position.y += Math::floor((p_rect.size.y - minsize.y) / 2); } for (int i = 0; i < 4; i++) p_child->set_anchor(Margin(i), ANCHOR_BEGIN); - p_child->set_position(r.pos); + p_child->set_position(r.position); p_child->set_size(r.size); p_child->set_rotation(0); p_child->set_scale(Vector2(1, 1)); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 83fa20bee5..ae30acf52e 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -58,7 +58,7 @@ void Control::edit_set_state(const Variant &p_state) { Dictionary s = p_state; Rect2 state = s["rect"]; - set_position(state.pos); + set_position(state.position); set_size(state.size); set_rotation(s["rot"]); set_scale(s["scale"]); @@ -94,15 +94,15 @@ void Control::edit_set_rect(const Rect2 &p_edit_rect) { Transform2D postxf; postxf.set_rotation_and_scale(data.rotation, data.scale); - Vector2 new_pos = postxf.xform(p_edit_rect.pos); + Vector2 new_pos = postxf.xform(p_edit_rect.position); Vector2 pos = get_position() + new_pos; Rect2 new_rect = get_rect(); - new_rect.pos = pos.snapped(Vector2(1, 1)); + new_rect.position = pos.snapped(Vector2(1, 1)); new_rect.size = p_edit_rect.size.snapped(Vector2(1, 1)); - set_position(new_rect.pos); + set_position(new_rect.position); set_size(new_rect.size); } @@ -1477,7 +1477,7 @@ Rect2 Control::get_global_rect() const { Rect2 Control::get_window_rect() const { ERR_FAIL_COND_V(!is_inside_tree(), Rect2()); Rect2 gr = get_global_rect(); - gr.pos += get_viewport()->get_visible_rect().pos; + gr.position += get_viewport()->get_visible_rect().position; return gr; } @@ -1949,10 +1949,10 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { Transform2D xform = get_global_transform(); Rect2 rect = get_item_rect(); - points[0] = xform.xform(rect.pos); - points[1] = xform.xform(rect.pos + Point2(rect.size.x, 0)); - points[2] = xform.xform(rect.pos + rect.size); - points[3] = xform.xform(rect.pos + Point2(0, rect.size.y)); + points[0] = xform.xform(rect.position); + points[1] = xform.xform(rect.position + Point2(rect.size.x, 0)); + points[2] = xform.xform(rect.position + rect.size); + points[3] = xform.xform(rect.position + Point2(0, rect.size.y)); const Vector2 dir[4] = { Vector2(-1, 0), @@ -2008,10 +2008,10 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con Transform2D xform = c->get_global_transform(); Rect2 rect = c->get_item_rect(); - points[0] = xform.xform(rect.pos); - points[1] = xform.xform(rect.pos + Point2(rect.size.x, 0)); - points[2] = xform.xform(rect.pos + rect.size); - points[3] = xform.xform(rect.pos + Point2(0, rect.size.y)); + points[0] = xform.xform(rect.position); + points[1] = xform.xform(rect.position + Point2(rect.size.x, 0)); + points[2] = xform.xform(rect.position + rect.size); + points[3] = xform.xform(rect.position + Point2(0, rect.size.y)); float min = 1e7; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 627bc96fb1..60d1350405 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -90,15 +90,15 @@ bool WindowDialog::has_point(const Point2 &p_point) const { // Enlarge upwards for title bar. int title_height = get_constant("title_height", "WindowDialog"); - r.pos.y -= title_height; + r.position.y -= title_height; r.size.y += title_height; // Inflate by the resizable border thickness. if (resizable) { int scaleborder_size = get_constant("scaleborder_size", "WindowDialog"); - r.pos.x -= scaleborder_size; + r.position.x -= scaleborder_size; r.size.width += scaleborder_size * 2; - r.pos.y -= scaleborder_size; + r.position.y -= scaleborder_size; r.size.height += scaleborder_size * 2; } @@ -113,7 +113,7 @@ void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) { if (mb->is_pressed()) { // Begin a possible dragging operation. - drag_type = _drag_hit_test(Point2(mb->get_pos().x, mb->get_pos().y)); + drag_type = _drag_hit_test(Point2(mb->get_position().x, mb->get_position().y)); if (drag_type != DRAG_NONE) drag_offset = get_global_mouse_position() - get_position(); drag_offset_far = get_position() + get_size() - get_global_mouse_position(); @@ -131,7 +131,7 @@ void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) { // Update the cursor while moving along the borders. CursorShape cursor = CURSOR_ARROW; if (resizable) { - int preview_drag_type = _drag_hit_test(Point2(mm->get_pos().x, mm->get_pos().y)); + int preview_drag_type = _drag_hit_test(Point2(mm->get_position().x, mm->get_position().y)); switch (preview_drag_type) { case DRAG_RESIZE_TOP: case DRAG_RESIZE_BOTTOM: @@ -162,28 +162,28 @@ void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) { Size2 min_size = get_minimum_size(); if (drag_type == DRAG_MOVE) { - rect.pos = global_pos - drag_offset; + rect.position = global_pos - drag_offset; } else { if (drag_type & DRAG_RESIZE_TOP) { - int bottom = rect.pos.y + rect.size.height; + int bottom = rect.position.y + rect.size.height; int max_y = bottom - min_size.height; - rect.pos.y = MIN(global_pos.y - drag_offset.y, max_y); - rect.size.height = bottom - rect.pos.y; + rect.position.y = MIN(global_pos.y - drag_offset.y, max_y); + rect.size.height = bottom - rect.position.y; } else if (drag_type & DRAG_RESIZE_BOTTOM) { - rect.size.height = global_pos.y - rect.pos.y + drag_offset_far.y; + rect.size.height = global_pos.y - rect.position.y + drag_offset_far.y; } if (drag_type & DRAG_RESIZE_LEFT) { - int right = rect.pos.x + rect.size.width; + int right = rect.position.x + rect.size.width; int max_x = right - min_size.width; - rect.pos.x = MIN(global_pos.x - drag_offset.x, max_x); - rect.size.width = right - rect.pos.x; + rect.position.x = MIN(global_pos.x - drag_offset.x, max_x); + rect.size.width = right - rect.position.x; } else if (drag_type & DRAG_RESIZE_RIGHT) { - rect.size.width = global_pos.x - rect.pos.x + drag_offset_far.x; + rect.size.width = global_pos.x - rect.position.x + drag_offset_far.x; } } set_size(rect.size); - set_position(rect.pos); + set_position(rect.position); } } } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index c52cdd9325..8d085d5399 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -168,24 +168,24 @@ void GraphEdit::_update_scroll() { continue; Rect2 r; - r.pos = gn->get_offset() * zoom; + r.position = gn->get_offset() * zoom; r.size = gn->get_size() * zoom; screen = screen.merge(r); } - screen.pos -= get_size(); + screen.position -= get_size(); screen.size += get_size() * 2.0; - h_scroll->set_min(screen.pos.x); - h_scroll->set_max(screen.pos.x + screen.size.x); + h_scroll->set_min(screen.position.x); + h_scroll->set_max(screen.position.x + screen.size.x); h_scroll->set_page(get_size().x); if (h_scroll->get_max() - h_scroll->get_min() <= h_scroll->get_page()) h_scroll->hide(); else h_scroll->show(); - v_scroll->set_min(screen.pos.y); - v_scroll->set_max(screen.pos.y + screen.size.y); + v_scroll->set_min(screen.position.y); + v_scroll->set_max(screen.position.y + screen.size.y); v_scroll->set_page(get_size().y); if (v_scroll->get_max() - v_scroll->get_min() <= v_scroll->get_page()) @@ -374,7 +374,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { Ref<Texture> port = get_icon("port", "GraphNode"); - Vector2 mpos(mb->get_pos().x, mb->get_pos().y); + Vector2 mpos(mb->get_position().x, mb->get_position().y); float grab_r = port->get_width() * 0.5 * grab_r_extend; for (int i = get_child_count() - 1; i >= 0; i--) { @@ -483,12 +483,12 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseMotion> mm = p_ev; if (mm.is_valid() && connecting) { - connecting_to = mm->get_pos(); + connecting_to = mm->get_position(); connecting_target = false; top_layer->update(); Ref<Texture> port = get_icon("port", "GraphNode"); - Vector2 mpos = mm->get_pos(); + Vector2 mpos = mm->get_position(); float grab_r = port->get_width() * 0.5 * grab_r_extend; for (int i = get_child_count() - 1; i >= 0; i--) { @@ -546,7 +546,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { } else if (!just_disconected) { String from = connecting_from; int from_slot = connecting_index; - Vector2 ofs = Vector2(mb->get_pos().x, mb->get_pos().y); + Vector2 ofs = Vector2(mb->get_position().x, mb->get_position().y); emit_signal("connection_to_empty", from, from_slot, ofs); } connecting = false; @@ -817,7 +817,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { connecting = false; top_layer->update(); } else { - emit_signal("popup_request", b->get_global_pos()); + emit_signal("popup_request", b->get_global_position()); } } } @@ -880,7 +880,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (gn) { - if (_filter_input(b->get_pos())) + if (_filter_input(b->get_position())) return; dragging = true; @@ -905,7 +905,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { } } else { - if (_filter_input(b->get_pos())) + if (_filter_input(b->get_position())) return; if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) return; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index fb0ff4f320..b5d059eaf5 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -239,7 +239,7 @@ void GraphNode::_notification(int p_what) { if (show_close) { Vector2 cpos = Point2(w + sb->get_margin(MARGIN_LEFT), -close->get_height() + close_offset); draw_texture(close, cpos); - close_rect.pos = cpos; + close_rect.position = cpos; close_rect.size = close->get_size(); } else { close_rect = Rect2(); @@ -586,7 +586,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Vector2 mpos = Vector2(mb->get_pos().x, mb->get_pos().y); + Vector2 mpos = Vector2(mb->get_position().x, mb->get_position().y); if (close_rect.size != Size2() && close_rect.has_point(mpos)) { emit_signal("close_request"); accept_event(); @@ -616,7 +616,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) { Ref<InputEventMouseMotion> mm = p_ev; if (resizing && mm.is_valid()) { - Vector2 mpos = mm->get_pos(); + Vector2 mpos = mm->get_position(); Vector2 diff = mpos - resizing_from; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index a9f063280b..371cf929fe 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -431,7 +431,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && (mb->get_button_index() == BUTTON_LEFT || (allow_rmb_select && mb->get_button_index() == BUTTON_RIGHT)) && mb->is_pressed()) { search_string = ""; //any mousepress cancels - Vector2 pos(mb->get_pos().x, mb->get_pos().y); + Vector2 pos(mb->get_position().x, mb->get_position().y); Ref<StyleBox> bg = get_stylebox("bg"); pos -= bg->get_offset(); pos.y += scroll_bar->get_value(); @@ -475,7 +475,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, Vector2(mb->get_pos().x, mb->get_pos().y)); + emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y)); } } else { @@ -486,7 +486,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (items[i].selected && mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, Vector2(mb->get_pos().x, mb->get_pos().y)); + emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y)); } else { bool selected = !items[i].selected; @@ -501,7 +501,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { if (mb->get_button_index() == BUTTON_RIGHT) { - emit_signal("item_rmb_selected", i, Vector2(mb->get_pos().x, mb->get_pos().y)); + emit_signal("item_rmb_selected", i, Vector2(mb->get_position().x, mb->get_position().y)); } else if (/*select_mode==SELECT_SINGLE &&*/ mb->is_doubleclick()) { emit_signal("item_activated", i); @@ -857,7 +857,7 @@ void ItemList::_notification(int p_what) { items[i].rect_cache = items[i].min_rect_cache; if (same_column_width) items[i].rect_cache.size.x = max_column_width; - items[i].rect_cache.pos = ofs; + items[i].rect_cache.position = ofs; max_h = MAX(max_h, items[i].rect_cache.size.y); ofs.x += items[i].rect_cache.size.x + hseparation; //print_line("item "+itos(i)+" ofs "+rtos(items[i].rect_cache.size.x)); @@ -906,10 +906,10 @@ void ItemList::_notification(int p_what) { int from = scroll_bar->get_value(); int to = from + scroll_bar->get_page(); - if (r.pos.y < from) { - scroll_bar->set_value(r.pos.y); - } else if (r.pos.y + r.size.y > to) { - scroll_bar->set_value(r.pos.y + r.size.y - (to - from)); + if (r.position.y < from) { + scroll_bar->set_value(r.position.y); + } else if (r.position.y + r.size.y > to) { + scroll_bar->set_value(r.position.y + r.size.y - (to - from)); } } @@ -928,25 +928,25 @@ void ItemList::_notification(int p_what) { continue; if (current_columns == 1) { - rcache.size.width = width - rcache.pos.x; + rcache.size.width = width - rcache.position.x; } Rect2 r = rcache; - r.pos += base_ofs; + r.position += base_ofs; // Use stylebox to dimension potential bg color, even if not selected - r.pos.x -= sbsel->get_margin(MARGIN_LEFT); + r.position.x -= sbsel->get_margin(MARGIN_LEFT); r.size.x += sbsel->get_margin(MARGIN_LEFT) + sbsel->get_margin(MARGIN_RIGHT); - r.pos.y -= sbsel->get_margin(MARGIN_TOP); + r.position.y -= sbsel->get_margin(MARGIN_TOP); r.size.y += sbsel->get_margin(MARGIN_TOP) + sbsel->get_margin(MARGIN_BOTTOM); if (items[i].selected) { draw_style_box(sbsel, r); } if (items[i].custom_bg.a > 0.001) { - r.pos.x += 2; + r.position.x += 2; r.size.x -= 4; - r.pos.y += 2; + r.position.y += 2; r.size.y -= 4; draw_rect(r, items[i].custom_bg); } @@ -965,7 +965,7 @@ void ItemList::_notification(int p_what) { Vector2 icon_ofs; - Point2 pos = items[i].rect_cache.pos + icon_ofs + base_ofs; + Point2 pos = items[i].rect_cache.position + icon_ofs + base_ofs; if (icon_mode == ICON_MODE_TOP) { @@ -985,7 +985,7 @@ void ItemList::_notification(int p_what) { if (fixed_icon_size.x > 0 && fixed_icon_size.y > 0) { Rect2 adj = _adjust_to_max_size(items[i].get_icon_size() * icon_scale, icon_size); - draw_rect.pos += adj.pos; + draw_rect.position += adj.position; draw_rect.size = adj.size; } @@ -1001,7 +1001,7 @@ void ItemList::_notification(int p_what) { if (items[i].tag_icon.is_valid()) { - draw_texture(items[i].tag_icon, items[i].rect_cache.pos + base_ofs); + draw_texture(items[i].tag_icon, items[i].rect_cache.position + base_ofs); } if (items[i].text != "") { @@ -1046,7 +1046,7 @@ void ItemList::_notification(int p_what) { text_ofs.y += font->get_ascent(); text_ofs = text_ofs.floor(); text_ofs += base_ofs; - text_ofs += items[i].rect_cache.pos; + text_ofs += items[i].rect_cache.position; for (int j = 0; j < ss; j++) { @@ -1074,7 +1074,7 @@ void ItemList::_notification(int p_what) { text_ofs.y += font->get_ascent(); text_ofs = text_ofs.floor(); text_ofs += base_ofs; - text_ofs += items[i].rect_cache.pos; + text_ofs += items[i].rect_cache.position; draw_string(font, text_ofs, items[i].text, modulate, max_len + 1); } @@ -1083,7 +1083,7 @@ void ItemList::_notification(int p_what) { if (select_mode == SELECT_MULTI && i == current) { Rect2 r = rcache; - r.pos += base_ofs; + r.position += base_ofs; draw_style_box(cursor, r); } } @@ -1141,7 +1141,7 @@ bool ItemList::is_pos_at_end_of_items(const Point2 &p_pos) const { pos.y += scroll_bar->get_value(); Rect2 endrect = items[items.size() - 1].rect_cache; - return (pos.y > endrect.pos.y + endrect.size.y); + return (pos.y > endrect.position.y + endrect.size.y); } String ItemList::get_tooltip(const Point2 &p_pos) const { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 38debe8a77..bc579020bd 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -64,7 +64,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { shift_selection_check_pre(b->get_shift()); - set_cursor_at_pixel_pos(b->get_pos().x); + set_cursor_at_pixel_pos(b->get_position().x); if (b->get_shift()) { @@ -118,7 +118,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (m->get_button_mask() & BUTTON_LEFT) { if (selection.creating) { - set_cursor_at_pixel_pos(m->get_pos().x); + set_cursor_at_pixel_pos(m->get_position().x); selection_fill_at_cursor(); } } diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 655d8ed6f6..8979e0f111 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -170,8 +170,8 @@ void Popup::popup_centered(const Size2 &p_size) { Rect2 rect; rect.size = p_size == Size2() ? get_size() : p_size; - rect.pos = ((window_size - rect.size) / 2.0).floor(); - set_position(rect.pos); + rect.position = ((window_size - rect.size) / 2.0).floor(); + set_position(rect.position); set_size(rect.size); show_modal(exclusive); @@ -193,8 +193,8 @@ void Popup::popup_centered_ratio(float p_screen_ratio) { Rect2 rect; Point2 window_size = get_viewport_rect().size; rect.size = (window_size * p_screen_ratio).floor(); - rect.pos = ((window_size - rect.size) / 2.0).floor(); - set_position(rect.pos); + rect.position = ((window_size - rect.size) / 2.0).floor(); + set_position(rect.position); set_size(rect.size); show_modal(exclusive); @@ -216,7 +216,7 @@ void Popup::popup(const Rect2 &bounds) { // Fit the popup into the optionally provided bounds. if (!bounds.has_no_area()) { - set_position(bounds.pos); + set_position(bounds.position); set_size(bounds.size); } _fix_size(); diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 985d9addc9..c4991700aa 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -190,12 +190,12 @@ void PopupMenu::_activate_submenu(int over) { PopupMenu *pum = pm->cast_to<PopupMenu>(); if (pum) { - pr.pos -= pum->get_global_position(); + pr.position -= pum->get_global_position(); pum->clear_autohide_areas(); - pum->add_autohide_area(Rect2(pr.pos.x, pr.pos.y, pr.size.x, items[over]._ofs_cache)); + pum->add_autohide_area(Rect2(pr.position.x, pr.position.y, pr.size.x, items[over]._ofs_cache)); if (over < items.size() - 1) { int from = items[over + 1]._ofs_cache; - pum->add_autohide_area(Rect2(pr.pos.x, pr.pos.y + from, pr.size.x, pr.size.y - from)); + pum->add_autohide_area(Rect2(pr.position.x, pr.position.y + from, pr.size.x, pr.size.y - from)); } } } @@ -284,7 +284,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { //update hover Ref<InputEventMouseMotion> ie; ie.instance(); - ie->set_pos(b->get_pos() + Vector2(0, s)); + ie->set_position(b->get_position() + Vector2(0, s)); _gui_input(ie); } } break; @@ -303,13 +303,13 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { //update hover Ref<InputEventMouseMotion> ie; ie.instance(); - ie->set_pos(b->get_pos() - Vector2(0, s)); + ie->set_position(b->get_position() - Vector2(0, s)); _gui_input(ie); } } break; case BUTTON_LEFT: { - int over = _get_mouse_over(b->get_pos()); + int over = _get_mouse_over(b->get_position()); if (invalidated_click) { invalidated_click = false; @@ -348,13 +348,13 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) { - if (!Rect2(Point2(), get_size()).has_point(m->get_pos()) && E->get().has_point(m->get_pos())) { + if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) { call_deferred("hide"); return; } } - int over = _get_mouse_over(m->get_pos()); + int over = _get_mouse_over(m->get_position()); int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].ID >= 0 ? items[over].ID : over); if (id < 0) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index a618810c11..d3a49b06d5 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -751,7 +751,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { Item *item = NULL; bool outside; - _find_click(main, b->get_pos(), &item, &line, &outside); + _find_click(main, b->get_position(), &item, &line, &outside); if (item) { @@ -852,7 +852,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { int line = 0; Item *item = NULL; - _find_click(main, m->get_pos(), &item, &line); + _find_click(main, m->get_position(), &item, &line); if (!item) return; // do not update diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 27a16ccc33..bd66cd2745 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -72,7 +72,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (b->is_pressed()) { - double ofs = orientation == VERTICAL ? b->get_pos().y : b->get_pos().x; + double ofs = orientation == VERTICAL ? b->get_position().y : b->get_position().x; Ref<Texture> decr = get_icon("decrement"); Ref<Texture> incr = get_icon("increment"); @@ -130,7 +130,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { if (drag.active) { - double ofs = orientation == VERTICAL ? m->get_pos().y : m->get_pos().x; + double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; Ref<Texture> decr = get_icon("decrement"); double decr_size = orientation == VERTICAL ? decr->get_height() : decr->get_width(); @@ -141,7 +141,7 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) { set_as_ratio(drag.value_at_click + diff); } else { - double ofs = orientation == VERTICAL ? m->get_pos().y : m->get_pos().x; + double ofs = orientation == VERTICAL ? m->get_position().y : m->get_position().x; Ref<Texture> decr = get_icon("decrement"); Ref<Texture> incr = get_icon("increment"); @@ -267,14 +267,14 @@ void ScrollBar::_notification(int p_what) { grabber_rect.size.width = get_grabber_size(); grabber_rect.size.height = get_size().height; - grabber_rect.pos.y = 0; - grabber_rect.pos.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT); + grabber_rect.position.y = 0; + grabber_rect.position.x = get_grabber_offset() + decr->get_width() + bg->get_margin(MARGIN_LEFT); } else { grabber_rect.size.width = get_size().width; grabber_rect.size.height = get_grabber_size(); - grabber_rect.pos.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP); - grabber_rect.pos.x = 0; + grabber_rect.position.y = get_grabber_offset() + decr->get_height() + bg->get_margin(MARGIN_TOP); + grabber_rect.position.x = 0; } grabber->draw(ci, grabber_rect); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 70b4ac47f8..cc1a637d2b 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -233,14 +233,14 @@ void ScrollContainer::_notification(int p_what) { Rect2 r = Rect2(-scroll, minsize); if (!scroll_h || (!h_scroll->is_visible_in_tree() && c->get_h_size_flags() & SIZE_EXPAND)) { - r.pos.x = 0; + r.position.x = 0; if (c->get_h_size_flags() & SIZE_EXPAND) r.size.width = MAX(size.width, minsize.width); else r.size.width = minsize.width; } if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) { - r.pos.y = 0; + r.position.y = 0; r.size.height = size.height; if (c->get_v_size_flags() & SIZE_EXPAND) r.size.height = MAX(size.height, minsize.height); diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index ae2bf0999e..d0e708bf73 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -46,7 +46,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { if (mb->is_pressed()) { Ref<Texture> grabber = get_icon(mouse_inside || has_focus() ? "grabber_highlight" : "grabber"); - grab.pos = orientation == VERTICAL ? mb->get_pos().y : mb->get_pos().x; + grab.pos = orientation == VERTICAL ? mb->get_position().y : mb->get_position().x; double grab_width = (double)grabber->get_size().width; double grab_height = (double)grabber->get_size().height; @@ -75,7 +75,7 @@ void Slider::_gui_input(Ref<InputEvent> p_event) { Size2i size = get_size(); Ref<Texture> grabber = get_icon("grabber"); - float motion = (orientation == VERTICAL ? mm->get_pos().y : mm->get_pos().x) - grab.pos; + float motion = (orientation == VERTICAL ? mm->get_position().y : mm->get_position().x) - grab.pos; if (orientation == VERTICAL) motion = -motion; float areasize = orientation == VERTICAL ? size.height - grabber->get_size().height : size.width - grabber->get_size().width; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 2eb2028391..c5b9df15b9 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -96,7 +96,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed()) { - bool up = mb->get_pos().y < (get_size().height / 2); + bool up = mb->get_position().y < (get_size().height / 2); switch (mb->get_button_index()) { @@ -135,7 +135,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == 1) { //set_default_cursor_shape(CURSOR_VSIZE); - Vector2 cpos = Vector2(mb->get_pos().x, mb->get_pos().y); + Vector2 cpos = Vector2(mb->get_position().x, mb->get_position().y); drag.mouse_pos = cpos; } @@ -155,7 +155,7 @@ void SpinBox::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid() && mm->get_button_mask() & 1) { - Vector2 cpos = mm->get_pos(); + Vector2 cpos = mm->get_position(); if (drag.enabled) { diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 91fd18e2ed..31236fa277 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -286,16 +286,16 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { if (vertical) { - if (mb->get_pos().y > middle_sep && mb->get_pos().y < middle_sep + sep) { + if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) { dragging = true; - drag_from = mb->get_pos().y; + drag_from = mb->get_position().y; drag_ofs = expand_ofs; } } else { - if (mb->get_pos().x > middle_sep && mb->get_pos().x < middle_sep + sep) { + if (mb->get_position().x > middle_sep && mb->get_position().x < middle_sep + sep) { dragging = true; - drag_from = mb->get_pos().x; + drag_from = mb->get_position().x; drag_ofs = expand_ofs; } } @@ -312,7 +312,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) { if (dragging) { - expand_ofs = drag_ofs + ((vertical ? mm->get_pos().y : mm->get_pos().x) - drag_from); + expand_ofs = drag_ofs + ((vertical ? mm->get_position().y : mm->get_position().x) - drag_from); queue_sort(); emit_signal("dragged", get_split_offset()); } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 6bbfa1aeb0..5ebcef3e8d 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -69,7 +69,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) { - Point2 pos(mb->get_pos().x, mb->get_pos().y); + Point2 pos(mb->get_position().x, mb->get_position().y); Size2 size = get_size(); // Click must be on tabs in the tab header area. @@ -233,7 +233,7 @@ void TabContainer::_notification(int p_what) { Control *control = tabs[i + first_tab_cache]->cast_to<Control>(); String text = control->has_meta("_tab_name") ? String(XL_MESSAGE(String(control->get_meta("_tab_name")))) : String(control->get_name()); - int x_content = tab_rect.pos.x + tab_style->get_margin(MARGIN_LEFT); + int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT); int top_margin = tab_style->get_margin(MARGIN_TOP); int y_center = top_margin + (tab_rect.size.y - tab_style->get_minimum_size().y) / 2; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index d94c33e408..cdb7965444 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -85,7 +85,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { if (mm.is_valid()) { - Point2 pos = mm->get_pos(); + Point2 pos = mm->get_position(); highlight_arrow = -1; if (buttons_visible) { @@ -165,7 +165,7 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) { mb->get_button_index() == BUTTON_LEFT) { // clicks - Point2 pos(mb->get_pos().x, mb->get_pos().y); + Point2 pos(mb->get_position().x, mb->get_position().y); if (buttons_visible) { @@ -340,8 +340,8 @@ void Tabs::_notification(int p_what) { Rect2 rb_rect; rb_rect.size = style->get_minimum_size() + rb->get_size(); - rb_rect.pos.x = w; - rb_rect.pos.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2; + rb_rect.position.x = w; + rb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2; if (rb_hover == i) { if (rb_pressing) @@ -350,7 +350,7 @@ void Tabs::_notification(int p_what) { style->draw(ci, rb_rect); } - rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.pos.y + style->get_margin(MARGIN_TOP))); + rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.position.y + style->get_margin(MARGIN_TOP))); w += rb->get_width(); tabs[i].rb_rect = rb_rect; } @@ -364,8 +364,8 @@ void Tabs::_notification(int p_what) { Rect2 cb_rect; cb_rect.size = style->get_minimum_size() + cb->get_size(); - cb_rect.pos.x = w; - cb_rect.pos.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2; + cb_rect.position.x = w; + cb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2; if (!tabs[i].disabled && cb_hover == i) { if (cb_pressing) @@ -374,7 +374,7 @@ void Tabs::_notification(int p_what) { style->draw(ci, cb_rect); } - cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.pos.y + style->get_margin(MARGIN_TOP))); + cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.position.y + style->get_margin(MARGIN_TOP))); w += cb->get_width(); tabs[i].cb_rect = cb_rect; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 4989a3d863..936a9b77f8 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1069,16 +1069,16 @@ void TextEdit::_notification(int p_what) { int th = h + csb->get_minimum_size().y; if (cursor_pos.y + get_row_height() + th > get_size().height) { - completion_rect.pos.y = cursor_pos.y - th; + completion_rect.position.y = cursor_pos.y - th; } else { - completion_rect.pos.y = cursor_pos.y + get_row_height() + csb->get_offset().y; + completion_rect.position.y = cursor_pos.y + get_row_height() + csb->get_offset().y; completion_below = true; } if (cursor_pos.x - nofs + w + scrollw > get_size().width) { - completion_rect.pos.x = get_size().width - w - scrollw; + completion_rect.position.x = get_size().width - w - scrollw; } else { - completion_rect.pos.x = cursor_pos.x - nofs; + completion_rect.position.x = cursor_pos.x - nofs; } completion_rect.size.width = w + 2; @@ -1086,14 +1086,14 @@ void TextEdit::_notification(int p_what) { if (completion_options.size() <= maxlines) scrollw = 0; - draw_style_box(csb, Rect2(completion_rect.pos - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0))); + draw_style_box(csb, Rect2(completion_rect.position - csb->get_offset(), completion_rect.size + csb->get_minimum_size() + Size2(scrollw, 0))); if (cache.completion_background_color.a > 0.01) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.pos, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(completion_rect.position, completion_rect.size + Size2(scrollw, 0)), cache.completion_background_color); } int line_from = CLAMP(completion_index - lines / 2, 0, completion_options.size() - lines); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.pos.x, completion_rect.pos.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color); - draw_rect(Rect2(completion_rect.pos, Size2(nofs, completion_rect.size.height)), cache.completion_existing_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(completion_rect.position.x, completion_rect.position.y + (completion_index - line_from) * get_row_height()), Size2(completion_rect.size.width, get_row_height())), cache.completion_selected_color); + draw_rect(Rect2(completion_rect.position, Size2(nofs, completion_rect.size.height)), cache.completion_existing_color); for (int i = 0; i < lines; i++) { @@ -1105,14 +1105,14 @@ void TextEdit::_notification(int p_what) { text_color = color_regions[j].color; } } - draw_string(cache.font, Point2(completion_rect.pos.x, completion_rect.pos.y + i * get_row_height() + cache.font->get_ascent()), completion_options[l], text_color, completion_rect.size.width); + draw_string(cache.font, Point2(completion_rect.position.x, completion_rect.position.y + i * get_row_height() + cache.font->get_ascent()), completion_options[l], text_color, completion_rect.size.width); } if (scrollw) { //draw a small scroll rectangle to show a position in the options float r = maxlines / (float)completion_options.size(); float o = line_from / (float)completion_options.size(); - draw_rect(Rect2(completion_rect.pos.x + completion_rect.size.width, completion_rect.pos.y + o * completion_rect.size.y, scrollw, completion_rect.size.y * r), scrollc); + draw_rect(Rect2(completion_rect.position.x + completion_rect.size.width, completion_rect.position.y + o * completion_rect.size.y, scrollw, completion_rect.size.y * r), scrollc); } completion_line_ofs = line_from; @@ -1445,7 +1445,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { Ref<InputEventMouseButton> mb = p_gui_input; if (mb.is_valid()) { - if (completion_active && completion_rect.has_point(mb->get_pos())) { + if (completion_active && completion_rect.has_point(mb->get_position())) { if (!mb->is_pressed()) return; @@ -1468,7 +1468,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (mb->get_button_index() == BUTTON_LEFT) { - completion_index = CLAMP(completion_line_ofs + (mb->get_pos().y - completion_rect.pos.y) / get_row_height(), 0, completion_options.size() - 1); + completion_index = CLAMP(completion_line_ofs + (mb->get_position().y - completion_rect.position.y) / get_row_height(), 0, completion_options.size() - 1); completion_current = completion_options[completion_index]; update(); @@ -1500,7 +1500,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { _reset_caret_blink_timer(); int row, col; - _get_mouse_pos(Point2i(mb->get_pos().x, mb->get_pos().y), row, col); + _get_mouse_pos(Point2i(mb->get_position().x, mb->get_position().y), row, col); if (mb->get_command() && highlighted_word != String()) { @@ -1511,7 +1511,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { // toggle breakpoint on gutter click if (draw_breakpoint_gutter) { int gutter = cache.style_normal->get_margin(MARGIN_LEFT); - if (mb->get_pos().x > gutter && mb->get_pos().x <= gutter + cache.breakpoint_gutter_width + 3) { + if (mb->get_position().x > gutter && mb->get_position().x <= gutter + cache.breakpoint_gutter_width + 3) { set_line_as_breakpoint(row, !is_line_set_as_breakpoint(row)); emit_signal("breakpoint_toggled", row); return; @@ -1646,7 +1646,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (select_identifiers_enabled) { if (mm->get_command() && mm->get_button_mask() == 0) { - String new_word = get_word_at_pos(mm->get_pos()); + String new_word = get_word_at_pos(mm->get_position()); if (new_word != highlighted_word) { highlighted_word = new_word; update(); @@ -1666,7 +1666,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { _reset_caret_blink_timer(); int row, col; - _get_mouse_pos(mm->get_pos(), row, col); + _get_mouse_pos(mm->get_position(), row, col); select(selection.selecting_line, selection.selecting_column, row, col); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index b17192fe4f..d864d9fce7 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -610,6 +610,18 @@ Color TreeItem::get_custom_bg_color(int p_column) const { return cells[p_column].bg_color; } +void TreeItem::set_custom_as_button(int p_column, bool p_button) { + + ERR_FAIL_INDEX(p_column, cells.size()); + cells[p_column].custom_button = p_button; +} + +bool TreeItem::is_custom_set_as_button(int p_column) const { + + ERR_FAIL_INDEX_V(p_column, cells.size(), false); + return cells[p_column].custom_button; +} + void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("set_cell_mode", "column", "mode"), &TreeItem::set_cell_mode); @@ -670,6 +682,9 @@ void TreeItem::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_custom_bg_color", "column"), &TreeItem::clear_custom_bg_color); ClassDB::bind_method(D_METHOD("get_custom_bg_color", "column"), &TreeItem::get_custom_bg_color); + ClassDB::bind_method(D_METHOD("set_custom_as_button", "column", "enable"), &TreeItem::set_custom_as_button); + ClassDB::bind_method(D_METHOD("is_custom_set_as_button", "column"), &TreeItem::is_custom_set_as_button); + ClassDB::bind_method(D_METHOD("add_button", "column", "button:Texture", "button_idx", "disabled", "tooltip"), &TreeItem::add_button, DEFVAL(-1), DEFVAL(false), DEFVAL("")); ClassDB::bind_method(D_METHOD("get_button_count", "column"), &TreeItem::get_button_count); ClassDB::bind_method(D_METHOD("get_button:Texture", "column", "button_idx"), &TreeItem::get_button); @@ -732,6 +747,10 @@ TreeItem::~TreeItem() { tree->pressing_for_editor = false; } + if (tree && tree->cache.hover_item == this) { + tree->cache.hover_item = NULL; + } + if (tree && tree->selected_item == this) tree->selected_item = NULL; @@ -772,6 +791,11 @@ void Tree::update_cache() { cache.select_arrow = get_icon("select_arrow"); cache.updown = get_icon("updown"); + cache.custom_button = get_stylebox("custom_button"); + cache.custom_button_hover = get_stylebox("custom_button_hover"); + cache.custom_button_pressed = get_stylebox("custom_button_pressed"); + cache.custom_button_font_highlight = get_color("custom_button_font_highlight"); + cache.font_color = get_color("font_color"); cache.font_color_selected = get_color("font_color_selected"); cache.guide_color = get_color("guide_color"); @@ -833,6 +857,9 @@ int Tree::compute_item_height(TreeItem *p_item) const { if (s.height > height) height = s.height; } + if (p_item->cells[i].mode == TreeItem::CELL_MODE_CUSTOM && p_item->cells[i].custom_button) { + height += cache.custom_button->get_minimum_size().height; + } } break; default: {} @@ -877,8 +904,8 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co bmsize.width = p_cell.icon_max_w; } - p_cell.draw_icon(ci, rect.pos + Size2i(0, Math::floor((real_t)(rect.size.y - bmsize.y) / 2)), bmsize); - rect.pos.x += bmsize.x + cache.hseparation; + p_cell.draw_icon(ci, rect.position + Size2i(0, Math::floor((real_t)(rect.size.y - bmsize.y) / 2)), bmsize); + rect.position.x += bmsize.x + cache.hseparation; rect.size.x -= bmsize.x + cache.hseparation; } @@ -893,8 +920,8 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co if (p_cell.suffix != String()) text += " " + p_cell.suffix; - rect.pos.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); - font->draw(ci, rect.pos, text, p_color, rect.size.x); + rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); + font->draw(ci, rect.position, text, p_color, rect.size.x); } #if 0 @@ -1007,16 +1034,16 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Rect2i item_rect = Rect2i(Point2i(ofs, p_pos.y) - cache.offset + p_draw_ofs, Size2i(w, label_h)); Rect2i cell_rect = item_rect; if (i != 0) { - cell_rect.pos.x -= cache.hseparation; + cell_rect.position.x -= cache.hseparation; cell_rect.size.x += cache.hseparation; } - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.pos.x, cell_rect.pos.y + cell_rect.size.height), cell_rect.pos + cell_rect.size, cache.guide_color, 1); + VisualServer::get_singleton()->canvas_item_add_line(ci, Point2i(cell_rect.position.x, cell_rect.position.y + cell_rect.size.height), cell_rect.position + cell_rect.size, cache.guide_color, 1); if (i == 0) { if (p_item->cells[0].selected && select_mode == SELECT_ROW) { - Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(MARGIN_LEFT), item_rect.pos.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y)); + Rect2i row_rect = Rect2i(Point2i(cache.bg->get_margin(MARGIN_LEFT), item_rect.position.y), Size2i(get_size().width - cache.bg->get_minimum_size().width, item_rect.size.y)); //Rect2 r = Rect2i(row_rect.pos,row_rect.size); //r.grow(cache.selected->get_margin(MARGIN_LEFT)); if (has_focus()) @@ -1028,34 +1055,34 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (p_item->cells[i].selected && select_mode != SELECT_ROW) { - Rect2i r(item_rect.pos, item_rect.size); + Rect2i r(item_rect.position, item_rect.size); if (p_item->cells[i].text.size() > 0) { float icon_width = p_item->cells[i].get_icon_size().width; - r.pos.x += icon_width; + r.position.x += icon_width; r.size.x -= icon_width; } //r.grow(cache.selected->get_margin(MARGIN_LEFT)); if (has_focus()) { cache.selected_focus->draw(ci, r); - p_item->set_meta("__focus_rect", Rect2(r.pos, r.size)); + p_item->set_meta("__focus_rect", Rect2(r.position, r.size)); } else { cache.selected->draw(ci, r); } if (text_editor->is_visible_in_tree()) { - text_editor->set_position(get_global_position() + r.pos); + text_editor->set_position(get_global_position() + r.position); } } if (p_item->cells[i].custom_bg_color) { Rect2 r = cell_rect; - r.pos.x -= cache.hseparation; + r.position.x -= cache.hseparation; r.size.x += cache.hseparation; if (p_item->cells[i].custom_bg_outline) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, r.size.x, 1), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, 1, r.size.y), p_item->cells[i].bg_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x + r.size.x - 1, r.pos.y, 1, r.size.y), p_item->cells[i].bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), p_item->cells[i].bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y - 1, r.size.x, 1), p_item->cells[i].bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), p_item->cells[i].bg_color); } else { VisualServer::get_singleton()->canvas_item_add_rect(ci, r, p_item->cells[i].bg_color); } @@ -1066,22 +1093,22 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Rect2 r = cell_rect; if (drop_mode_section == -1 || drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, r.size.x, 1), cache.drop_position_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, r.size.x, 1), cache.drop_position_color); } if (drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y, 1, r.size.y), cache.drop_position_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x + r.size.x - 1, r.pos.y, 1, r.size.y), cache.drop_position_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y, 1, r.size.y), cache.drop_position_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x + r.size.x - 1, r.position.y, 1, r.size.y), cache.drop_position_color); } if (drop_mode_section == 1 || drop_mode_section == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.pos.x, r.pos.y + r.size.y, r.size.x, 1), cache.drop_position_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(r.position.x, r.position.y + r.size.y, r.size.x, 1), cache.drop_position_color); } } Color col = p_item->cells[i].custom_color ? p_item->cells[i].color : get_color(p_item->cells[i].selected ? "font_color_selected" : "font_color"); - Point2i text_pos = item_rect.pos; + Point2i text_pos = item_rect.position; text_pos.y += Math::floor((item_rect.size.y - font->get_height()) / 2) + font_ascent; switch (p_item->cells[i].mode) { @@ -1094,7 +1121,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Ref<Texture> checked = cache.checked; Ref<Texture> unchecked = cache.unchecked; - Point2i check_ofs = item_rect.pos; + Point2i check_ofs = item_rect.position; check_ofs.y += Math::floor((real_t)(item_rect.size.y - checked->get_height()) / 2); if (p_item->cells[i].checked) { @@ -1109,7 +1136,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 text_pos.x += check_w; item_rect.size.x -= check_w; - item_rect.pos.x += check_w; + item_rect.position.x += check_w; draw_item_rect(p_item->cells[i], item_rect, col); @@ -1137,7 +1164,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 font->draw(ci, text_pos, s, col, item_rect.size.x - downarrow->get_width()); //? - Point2i arrow_pos = item_rect.pos; + Point2i arrow_pos = item_rect.position; arrow_pos.x += item_rect.size.x - downarrow->get_width(); arrow_pos.y += Math::floor(((item_rect.size.y - downarrow->get_height())) / 2.0); @@ -1157,7 +1184,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (!p_item->cells[i].editable) break; - Point2i updown_pos = item_rect.pos; + Point2i updown_pos = item_rect.position; updown_pos.x += item_rect.size.x - updown->get_width(); updown_pos.y += Math::floor(((item_rect.size.y - updown->get_height())) / 2.0); @@ -1176,7 +1203,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 } Point2i icon_ofs = (item_rect.size - icon_size) / 2; - icon_ofs += item_rect.pos; + icon_ofs += item_rect.position; draw_texture_rect(p_item->cells[i].icon, Rect2(icon_ofs, icon_size)); //p_item->cells[i].icon->draw(ci, icon_ofs); @@ -1202,12 +1229,28 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 Ref<Texture> downarrow = cache.select_arrow; Rect2i ir = item_rect; - ir.size.width -= downarrow->get_width(); - draw_item_rect(p_item->cells[i], ir, col); - Point2i arrow_pos = item_rect.pos; + Point2i arrow_pos = item_rect.position; arrow_pos.x += item_rect.size.x - downarrow->get_width(); arrow_pos.y += Math::floor(((item_rect.size.y - downarrow->get_height())) / 2.0); + ir.size.width -= downarrow->get_width(); + + if (p_item->cells[i].custom_button) { + if (cache.hover_item == p_item && cache.hover_cell == i) { + if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) { + draw_style_box(cache.custom_button_pressed, ir); + } else { + draw_style_box(cache.custom_button_hover, ir); + col = cache.custom_button_font_highlight; + } + } else { + draw_style_box(cache.custom_button, ir); + } + ir.size -= cache.custom_button->get_minimum_size(); + ir.position += cache.custom_button->get_offset(); + } + + draw_item_rect(p_item->cells[i], ir, col); downarrow->draw(ci, arrow_pos); @@ -1697,11 +1740,18 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool case TreeItem::CELL_MODE_CUSTOM: { edited_item = p_item; edited_col = col; - custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h)); - emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2)))); + bool on_arrow = x > col_width - cache.select_arrow->get_width(); bring_up_editor = false; - item_edited(col, p_item); + + if (on_arrow || !p_item->cells[col].custom_button) { + custom_popup_rect = Rect2i(get_global_position() + Point2i(col_ofs, _get_title_button_height() + y_ofs + item_h - cache.offset.y), Size2(get_column_width(col), item_h)); + emit_signal("custom_popup_edited", ((bool)(x >= (col_width - item_h / 2)))); + } + + if (!p_item->cells[col].custom_button || !on_arrow) { + item_edited(col, p_item); + } click_handled = true; return -1; } break; @@ -2122,7 +2172,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { Ref<StyleBox> bg = cache.bg; - Point2 pos = mm->get_pos() - bg->get_offset(); + Point2 pos = mm->get_position() - bg->get_offset(); Cache::ClickType old_hover = cache.hover_type; int old_index = cache.hover_index; @@ -2148,9 +2198,9 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { } } - if (drop_mode_flags && root) { + if (root) { - Point2 mpos = mm->get_pos(); + Point2 mpos = mm->get_position(); mpos -= cache.bg->get_offset(); mpos.y -= _get_title_button_height(); if (mpos.y >= 0) { @@ -2163,11 +2213,17 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { int col, h, section; TreeItem *it = _find_item_at_pos(root, mpos, col, h, section); - if (it != drop_mode_over || section != drop_mode_section) { + if (drop_mode_flags && it != drop_mode_over || section != drop_mode_section) { drop_mode_over = it; drop_mode_section = section; update(); } + + if (it != cache.hover_item || col != cache.hover_cell) { + cache.hover_item = it; + cache.hover_cell = col; + update(); + } } } @@ -2180,7 +2236,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (!range_drag_enabled) { - Vector2 cpos = mm->get_pos(); + Vector2 cpos = mm->get_position(); if (cpos.distance_to(pressing_pos) > 2) { range_drag_enabled = true; range_drag_capture_pos = cpos; @@ -2217,7 +2273,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { if (b->get_button_index() == BUTTON_LEFT) { - Point2 pos = b->get_pos() - cache.bg->get_offset(); + Point2 pos = b->get_position() - cache.bg->get_offset(); if (show_column_titles) { pos.y -= _get_title_button_height(); @@ -2251,7 +2307,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { warp_mouse(range_drag_capture_pos); } else { Rect2 rect = get_selected()->get_meta("__focus_rect"); - if (rect.has_point(Point2(b->get_pos().x, b->get_pos().y))) { + if (rect.has_point(Point2(b->get_position().x, b->get_position().y))) { edit_selected(); } else { emit_signal("item_double_clicked"); @@ -2295,7 +2351,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { case BUTTON_LEFT: { Ref<StyleBox> bg = cache.bg; - Point2 pos = b->get_pos() - bg->get_offset(); + Point2 pos = b->get_position() - bg->get_offset(); cache.click_type = Cache::CLICK_NONE; if (show_column_titles && b->get_button_index() == BUTTON_LEFT) { pos.y -= _get_title_button_height(); @@ -2333,7 +2389,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { blocked--; if (pressing_for_editor) { - pressing_pos = b->get_pos(); + pressing_pos = b->get_position(); } if (b->get_button_index() == BUTTON_RIGHT) @@ -2401,7 +2457,7 @@ bool Tree::edit_selected() { edited_item = s; edited_col = col; - custom_popup_rect = Rect2i(get_global_position() + rect.pos, rect.size); + custom_popup_rect = Rect2i(get_global_position() + rect.position, rect.size); emit_signal("custom_popup_edited", false); item_edited(col, s); @@ -2416,7 +2472,7 @@ bool Tree::edit_selected() { } popup_menu->set_size(Size2(rect.size.width, 0)); - popup_menu->set_position(get_global_position() + rect.pos + Point2i(0, rect.size.height)); + popup_menu->set_position(get_global_position() + rect.position + Point2i(0, rect.size.height)); popup_menu->popup(); popup_edited_item = s; popup_edited_item_col = col; @@ -2424,7 +2480,7 @@ bool Tree::edit_selected() { } else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) { - Point2i textedpos = get_global_position() + rect.pos; + Point2i textedpos = get_global_position() + rect.position; text_editor->set_position(textedpos); text_editor->set_size(rect.size); text_editor->clear(); @@ -2671,7 +2727,7 @@ void Tree::_notification(int p_what) { ofs += tbrect.size.width; //text int clip_w = tbrect.size.width - sb->get_minimum_size().width; - f->draw_halign(ci, tbrect.pos + Point2i(sb->get_offset().x, (tbrect.size.height - f->get_height()) / 2 + f->get_ascent()), HALIGN_CENTER, clip_w, columns[i].title, cache.title_button_color); + f->draw_halign(ci, tbrect.position + Point2i(sb->get_offset().x, (tbrect.size.height - f->get_height()) / 2 + f->get_ascent()), HALIGN_CENTER, clip_w, columns[i].title, cache.title_button_color); } } } @@ -3053,11 +3109,11 @@ Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const { int ofs = get_item_offset(p_item); int height = compute_item_height(p_item); Rect2 r; - r.pos.y = ofs; + r.position.y = ofs; r.size.height = height; if (p_column == -1) { - r.pos.x = 0; + r.position.x = 0; r.size.x = get_size().width; } else { @@ -3065,7 +3121,7 @@ Rect2 Tree::get_item_rect(TreeItem *p_item, int p_column) const { for (int i = 0; i < p_column; i++) { accum += get_column_width(i); } - r.pos.x = accum; + r.position.x = accum; r.size.x = get_column_width(p_column); } @@ -3469,6 +3525,7 @@ void Tree::_bind_methods() { ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "pos"))); ADD_SIGNAL(MethodInfo("item_edited")); + ADD_SIGNAL(MethodInfo("item_custom_button_pressed")); ADD_SIGNAL(MethodInfo("item_double_clicked")); ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item"))); //ADD_SIGNAL( MethodInfo("item_doubleclicked" ) ); @@ -3575,6 +3632,9 @@ Tree::Tree() { force_edit_checkbox_only_on_checkbox = false; set_clip_contents(true); + + cache.hover_item = NULL; + cache.hover_cell = -1; } Tree::~Tree() { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 0c07109e7d..097e0110e8 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -81,6 +81,7 @@ private: bool custom_bg_color; bool custom_bg_outline; Color bg_color; + bool custom_button; Variant meta; String tooltip; @@ -107,6 +108,7 @@ private: Cell() { custom_draw_obj = 0; + custom_button = false; mode = TreeItem::CELL_MODE_STRING; min = 0; max = 100; @@ -238,6 +240,9 @@ public: void clear_custom_bg_color(int p_column); Color get_custom_bg_color(int p_column) const; + void set_custom_as_button(int p_column, bool p_button); + bool is_custom_set_as_button(int p_column) const; + void set_tooltip(int p_column, const String &p_tooltip); String get_tooltip(int p_column) const; @@ -369,6 +374,10 @@ private: Ref<StyleBox> title_button; Ref<StyleBox> title_button_hover; Ref<StyleBox> title_button_pressed; + Ref<StyleBox> custom_button; + Ref<StyleBox> custom_button_hover; + Ref<StyleBox> custom_button_pressed; + Color title_button_color; Ref<Texture> checked; @@ -383,6 +392,7 @@ private: Color guide_color; Color drop_position_color; Color relationship_line_color; + Color custom_button_font_highlight; int hseparation; int vseparation; @@ -410,6 +420,9 @@ private: int hover_index; Point2 click_pos; + TreeItem *hover_item; + int hover_cell; + } cache; int _get_title_button_height() const; |