MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / get_cursor_shape

Method get_cursor_shape

scene/gui/text_edit.cpp:3605–3653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3603}
3604
3605Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
3606 if (dragging_selection) {
3607 return get_default_cursor_shape();
3608 }
3609
3610 if (dragging_minimap) {
3611 return CURSOR_ARROW;
3612 }
3613
3614 Vector2i current_hovered_gutter = _get_hovered_gutter(p_pos);
3615 if (current_hovered_gutter != Vector2i(-1, -1)) {
3616 if (gutters[current_hovered_gutter.x].clickable || is_line_gutter_clickable(current_hovered_gutter.y, current_hovered_gutter.x)) {
3617 return CURSOR_POINTING_HAND;
3618 } else {
3619 return CURSOR_ARROW;
3620 }
3621 }
3622 int left_margin = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT));
3623 if (p_pos.x < left_margin + gutters_width + gutter_padding) {
3624 return CURSOR_ARROW;
3625 }
3626
3627 int xmargin_end = get_size().width - Math::ceil(theme_cache.style_normal->get_margin(SIDE_RIGHT));
3628 if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) {
3629 return CURSOR_ARROW;
3630 }
3631
3632 // Hover inline objects.
3633 if (inline_object_click_handler.is_valid()) {
3634 Point2i pos = get_line_column_at_pos(p_pos);
3635 int xmargin_beg = Math::ceil(theme_cache.style_normal->get_margin(SIDE_LEFT)) + gutters_width + gutter_padding;
3636 int wrap_i = get_line_wrap_index_at_column(pos.y, pos.x);
3637 const float wrap_indent = _get_wrap_indent_offset(pos.y, wrap_i, is_layout_rtl());
3638
3639 Ref<TextParagraph> ldata = text.get_line_data(pos.y);
3640 for (Variant k : ldata->get_line_objects(wrap_i)) {
3641 if (!is_inline_info_valid(k)) {
3642 continue;
3643 }
3644 Rect2 obj_rect = ldata->get_line_object_rect(wrap_i, k);
3645 obj_rect.position.x += xmargin_beg + wrap_indent - first_visible_col;
3646 if (p_pos.x > obj_rect.position.x && p_pos.x < obj_rect.get_end().x) {
3647 return CURSOR_POINTING_HAND;
3648 }
3649 }
3650 }
3651
3652 return get_default_cursor_shape();
3653}
3654
3655String TextEdit::get_tooltip(const Point2 &p_pos) const {
3656 if (!tooltip_callback.is_valid()) {

Callers

nothing calls this directly

Calls 10

ceilFunction · 0.85
get_sizeFunction · 0.85
is_inline_info_validFunction · 0.85
get_line_dataMethod · 0.80
get_line_objectsMethod · 0.80
get_line_object_rectMethod · 0.80
Vector2iClass · 0.50
get_marginMethod · 0.45
is_validMethod · 0.45
get_endMethod · 0.45

Tested by

no test coverage detected