Fixes node selection, and properly ignore mouse on inner comment node body, closes #6298
This commit is contained in:
parent
51d8206ee8
commit
db7f491833
3 changed files with 12 additions and 11 deletions
|
@ -207,9 +207,10 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
|
||||||
|
|
||||||
GraphNode *gn = p_gn->cast_to<GraphNode>();
|
GraphNode *gn = p_gn->cast_to<GraphNode>();
|
||||||
ERR_FAIL_COND(!gn);
|
ERR_FAIL_COND(!gn);
|
||||||
gn->raise();
|
|
||||||
if (gn->is_comment()) {
|
if (gn->is_comment()) {
|
||||||
move_child(gn, 0);
|
move_child(gn, 0);
|
||||||
|
} else {
|
||||||
|
gn->raise();
|
||||||
}
|
}
|
||||||
int first_not_comment = 0;
|
int first_not_comment = 0;
|
||||||
for (int i = 0; i < get_child_count(); i++) {
|
for (int i = 0; i < get_child_count(); i++) {
|
||||||
|
@ -870,23 +871,21 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
|
||||||
if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
|
if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
|
||||||
|
|
||||||
GraphNode *gn = NULL;
|
GraphNode *gn = NULL;
|
||||||
GraphNode *gn_selected = NULL;
|
|
||||||
for (int i = get_child_count() - 1; i >= 0; i--) {
|
for (int i = get_child_count() - 1; i >= 0; i--) {
|
||||||
|
|
||||||
gn_selected = get_child(i)->cast_to<GraphNode>();
|
GraphNode *gn_selected = get_child(i)->cast_to<GraphNode>();
|
||||||
|
|
||||||
if (gn_selected) {
|
if (gn_selected) {
|
||||||
|
|
||||||
if (gn_selected->is_resizing())
|
if (gn_selected->is_resizing())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Rect2 r = gn_selected->get_rect();
|
if (gn_selected->has_point(gn_selected->get_local_mouse_pos())) {
|
||||||
r.size *= zoom;
|
|
||||||
if (r.has_point(get_local_mouse_pos()))
|
|
||||||
gn = gn_selected;
|
gn = gn_selected;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gn) {
|
if (gn) {
|
||||||
|
|
||||||
|
@ -1225,6 +1224,7 @@ GraphEdit::GraphEdit() {
|
||||||
connections_layer->connect("draw", this, "_connections_layer_draw");
|
connections_layer->connect("draw", this, "_connections_layer_draw");
|
||||||
connections_layer->set_name("CLAYER");
|
connections_layer->set_name("CLAYER");
|
||||||
connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offseted
|
connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offseted
|
||||||
|
connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||||
|
|
||||||
h_scroll = memnew(HScrollBar);
|
h_scroll = memnew(HScrollBar);
|
||||||
h_scroll->set_name("_h_scroll");
|
h_scroll->set_name("_h_scroll");
|
||||||
|
|
|
@ -176,6 +176,7 @@ bool GraphNode::has_point(const Point2 &p_point) const {
|
||||||
if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
|
if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Rect2(0, 0, get_size().width, comment->get_margin(MARGIN_TOP)).has_point(p_point)) {
|
if (Rect2(0, 0, get_size().width, comment->get_margin(MARGIN_TOP)).has_point(p_point)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -719,7 +720,7 @@ GraphNode::GraphNode() {
|
||||||
overlay = OVERLAY_DISABLED;
|
overlay = OVERLAY_DISABLED;
|
||||||
show_close = false;
|
show_close = false;
|
||||||
connpos_dirty = true;
|
connpos_dirty = true;
|
||||||
set_mouse_filter(MOUSE_FILTER_PASS);
|
set_mouse_filter(MOUSE_FILTER_STOP);
|
||||||
comment = false;
|
comment = false;
|
||||||
resizeable = false;
|
resizeable = false;
|
||||||
resizing = false;
|
resizing = false;
|
||||||
|
|
|
@ -99,8 +99,6 @@ private:
|
||||||
|
|
||||||
Overlay overlay;
|
Overlay overlay;
|
||||||
|
|
||||||
bool has_point(const Point2 &p_point) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _gui_input(const Ref<InputEvent> &p_ev);
|
void _gui_input(const Ref<InputEvent> &p_ev);
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -111,6 +109,8 @@ protected:
|
||||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||||
|
|
||||||
public:
|
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<Texture> &p_custom_left = Ref<Texture>(), const Ref<Texture> &p_custom_right = Ref<Texture>());
|
||||||
void clear_slot(int p_idx);
|
void clear_slot(int p_idx);
|
||||||
void clear_all_slots();
|
void clear_all_slots();
|
||||||
|
|
Loading…
Reference in a new issue