Use get_cursor_shape for identifying the cursor shape in AnimationNodeStateMachineEditor
get_cursor_shape() is used in cases where a Control displays different cursors in different areas.
There is no need to set the default cursor shape on every mouse move event.
Fix minor issue with selection order.
(cherry picked from commit 0d96dbcb2a
)
This commit is contained in:
parent
e2bd1ad6da
commit
93447eb1ae
|
@ -343,29 +343,21 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
|
||||||
state_machine_draw->update();
|
state_machine_draw->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
//put ibeam (text cursor) over names to make it clearer that they are editable
|
|
||||||
if (mm.is_valid()) {
|
if (mm.is_valid()) {
|
||||||
state_machine_draw->grab_focus();
|
state_machine_draw->grab_focus();
|
||||||
|
|
||||||
bool over_text_now = false;
|
|
||||||
String new_over_node = StringName();
|
String new_over_node = StringName();
|
||||||
int new_over_node_what = -1;
|
int new_over_node_what = -1;
|
||||||
if (tool_select->is_pressed()) {
|
if (tool_select->is_pressed()) {
|
||||||
for (int i = node_rects.size() - 1; i >= 0; i--) { //inverse to draw order
|
for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order.
|
||||||
|
|
||||||
if (node_rects[i].name.has_point(mm->get_position())) {
|
|
||||||
over_text_now = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node_rects[i].node.has_point(mm->get_position())) {
|
if (node_rects[i].node.has_point(mm->get_position())) {
|
||||||
new_over_node = node_rects[i].node_name;
|
new_over_node = node_rects[i].node_name;
|
||||||
if (node_rects[i].play.has_point(mm->get_position())) {
|
if (node_rects[i].play.has_point(mm->get_position())) {
|
||||||
new_over_node_what = 0;
|
new_over_node_what = 0;
|
||||||
}
|
} else if (node_rects[i].edit.has_point(mm->get_position())) {
|
||||||
if (node_rects[i].edit.has_point(mm->get_position())) {
|
|
||||||
new_over_node_what = 1;
|
new_over_node_what = 1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,16 +367,6 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
|
||||||
over_node_what = new_over_node_what;
|
over_node_what = new_over_node_what;
|
||||||
state_machine_draw->update();
|
state_machine_draw->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (over_text != over_text_now) {
|
|
||||||
if (over_text_now) {
|
|
||||||
state_machine_draw->set_default_cursor_shape(CURSOR_IBEAM);
|
|
||||||
} else {
|
|
||||||
state_machine_draw->set_default_cursor_shape(CURSOR_ARROW);
|
|
||||||
}
|
|
||||||
|
|
||||||
over_text = over_text_now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<InputEventPanGesture> pan_gesture = p_event;
|
Ref<InputEventPanGesture> pan_gesture = p_event;
|
||||||
|
@ -394,6 +376,23 @@ void AnimationNodeStateMachineEditor::_state_machine_gui_input(const Ref<InputEv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Control::CursorShape AnimationNodeStateMachineEditor::get_cursor_shape(const Point2 &p_pos) const {
|
||||||
|
// Put ibeam (text cursor) over names to make it clearer that they are editable.
|
||||||
|
Transform2D xform = panel->get_transform() * state_machine_draw->get_transform();
|
||||||
|
Point2 pos = xform.xform_inv(p_pos);
|
||||||
|
Control::CursorShape cursor_shape = get_default_cursor_shape();
|
||||||
|
|
||||||
|
for (int i = node_rects.size() - 1; i >= 0; i--) { // Inverse to draw order.
|
||||||
|
if (node_rects[i].node.has_point(pos)) {
|
||||||
|
if (node_rects[i].name.has_point(pos)) {
|
||||||
|
cursor_shape = Control::CURSOR_IBEAM;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cursor_shape;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
|
void AnimationNodeStateMachineEditor::_file_opened(const String &p_file) {
|
||||||
file_loaded = ResourceLoader::load(p_file);
|
file_loaded = ResourceLoader::load(p_file);
|
||||||
if (file_loaded.is_valid()) {
|
if (file_loaded.is_valid()) {
|
||||||
|
@ -1295,6 +1294,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
|
||||||
|
|
||||||
panel = memnew(PanelContainer);
|
panel = memnew(PanelContainer);
|
||||||
panel->set_clip_contents(true);
|
panel->set_clip_contents(true);
|
||||||
|
panel->set_mouse_filter(Control::MOUSE_FILTER_PASS);
|
||||||
add_child(panel);
|
add_child(panel);
|
||||||
panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
panel->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||||
|
|
||||||
|
@ -1303,6 +1303,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
|
||||||
state_machine_draw->connect("gui_input", this, "_state_machine_gui_input");
|
state_machine_draw->connect("gui_input", this, "_state_machine_gui_input");
|
||||||
state_machine_draw->connect("draw", this, "_state_machine_draw");
|
state_machine_draw->connect("draw", this, "_state_machine_draw");
|
||||||
state_machine_draw->set_focus_mode(FOCUS_ALL);
|
state_machine_draw->set_focus_mode(FOCUS_ALL);
|
||||||
|
state_machine_draw->set_mouse_filter(Control::MOUSE_FILTER_PASS);
|
||||||
|
|
||||||
state_machine_play_pos = memnew(Control);
|
state_machine_play_pos = memnew(Control);
|
||||||
state_machine_draw->add_child(state_machine_play_pos);
|
state_machine_draw->add_child(state_machine_play_pos);
|
||||||
|
@ -1354,8 +1355,6 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
|
||||||
open_file->connect("file_selected", this, "_file_opened");
|
open_file->connect("file_selected", this, "_file_opened");
|
||||||
undo_redo = EditorNode::get_undo_redo();
|
undo_redo = EditorNode::get_undo_redo();
|
||||||
|
|
||||||
over_text = false;
|
|
||||||
|
|
||||||
over_node_what = -1;
|
over_node_what = -1;
|
||||||
dragging_selected_attempt = false;
|
dragging_selected_attempt = false;
|
||||||
connecting = false;
|
connecting = false;
|
||||||
|
|
|
@ -136,7 +136,6 @@ class AnimationNodeStateMachineEditor : public AnimationTreeNodeEditorPlugin {
|
||||||
StringName selected_transition_from;
|
StringName selected_transition_from;
|
||||||
StringName selected_transition_to;
|
StringName selected_transition_to;
|
||||||
|
|
||||||
bool over_text;
|
|
||||||
StringName over_node;
|
StringName over_node;
|
||||||
int over_node_what;
|
int over_node_what;
|
||||||
|
|
||||||
|
@ -183,6 +182,7 @@ public:
|
||||||
static AnimationNodeStateMachineEditor *get_singleton() { return singleton; }
|
static AnimationNodeStateMachineEditor *get_singleton() { return singleton; }
|
||||||
virtual bool can_edit(const Ref<AnimationNode> &p_node);
|
virtual bool can_edit(const Ref<AnimationNode> &p_node);
|
||||||
virtual void edit(const Ref<AnimationNode> &p_node);
|
virtual void edit(const Ref<AnimationNode> &p_node);
|
||||||
|
virtual CursorShape get_cursor_shape(const Point2 &p_pos) const;
|
||||||
AnimationNodeStateMachineEditor();
|
AnimationNodeStateMachineEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue