Backported returning AfterGUIInput from forward_spatial_gui_input from Godot4. Also removed the first index parameter. This fully broke the skeleton editor, it will be fixed soon.

This commit is contained in:
Relintai 2022-08-11 02:24:30 +02:00
parent 061bdd1f2e
commit b6eb2db442
22 changed files with 152 additions and 127 deletions

View File

@ -243,25 +243,23 @@
</description>
</method>
<method name="forward_spatial_gui_input" qualifiers="virtual">
<return type="bool" />
<argument index="0" name="index" type="int" />
<argument index="1" name="camera" type="Camera" />
<argument index="2" name="event" type="InputEvent" />
<return type="int" />
<argument index="0" name="camera" type="Camera" />
<argument index="1" name="event" type="InputEvent" />
<description>
Called when there is a root node in the current edited scene, [method handles] is implemented and an [InputEvent] happens in the 3D viewport. Intercepts the [InputEvent], if [code]return true[/code] [EditorPlugin] consumes the [code]event[/code], otherwise forwards [code]event[/code] to other Editor classes. Example:
[codeblock]
# Prevents the InputEvent to reach other Editor classes
func forward_spatial_gui_input(index, camera, event):
var forward = true
return forward
func forward_spatial_gui_input(camera, event):
return EditorPlugin.AFTER_GUI_INPUT_STOP
[/codeblock]
Must [code]return false[/code] in order to forward the [InputEvent] to other Editor classes. Example:
[codeblock]
# Consumes InputEventMouseMotion and forwards other InputEvent types
func forward_spatial_gui_input(index, camera, event):
var forward = false
func forward_spatial_gui_input(camera, event):
var forward = EditorPlugin.AFTER_GUI_INPUT_STOP
if event is InputEventMouseMotion:
forward = true
forward = EditorPlugin.AFTER_GUI_INPUT_PASS
return forward
[/codeblock]
</description>

View File

@ -7022,20 +7022,25 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
return discard;
}
bool EditorPluginList::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false;
EditorPlugin::AfterGUIInput EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
EditorPlugin::AfterGUIInput after = EditorPlugin::AFTER_GUI_INPUT_PASS;
for (int i = 0; i < plugins_list.size(); i++) {
if ((!serve_when_force_input_enabled) && plugins_list[i]->is_input_event_forwarding_always_enabled()) {
continue;
}
if (plugins_list[i]->forward_spatial_gui_input(p_index, p_camera, p_event)) {
discard = true;
EditorPlugin::AfterGUIInput current_after = plugins_list[i]->forward_spatial_gui_input(p_camera, p_event);
if (current_after == EditorPlugin::AFTER_GUI_INPUT_STOP) {
after = EditorPlugin::AFTER_GUI_INPUT_STOP;
}
if (after != EditorPlugin::AFTER_GUI_INPUT_STOP && current_after == EditorPlugin::AFTER_GUI_INPUT_DESELECT) {
after = EditorPlugin::AFTER_GUI_INPUT_DESELECT;
}
}
return discard;
return after;
}
void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) {

View File

@ -962,7 +962,7 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_spatial_draw_over_viewport(Control *p_overlay);
void forward_spatial_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);

View File

@ -621,12 +621,13 @@ int EditorPlugin::update_overlays() const {
}
}
bool EditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
return get_script_instance()->call("forward_spatial_gui_input", p_index, p_camera, p_event);
int success = get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
return static_cast<EditorPlugin::AfterGUIInput>(success);
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
@ -895,7 +896,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
@ -943,6 +944,10 @@ void EditorPlugin::_bind_methods() {
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP);
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_DESELECT);
}
EditorPlugin::EditorPlugin() :

View File

@ -40,16 +40,16 @@
#include "core/dictionary.h"
#include "core/error_list.h"
#include "core/error_macros.h"
#include "core/io/config_file.h"
#include "core/list.h"
#include "core/method_bind.h"
#include "core/object.h"
#include "core/os/memory.h"
#include "core/reference.h"
#include "core/undo_redo.h"
#include "core/ustring.h"
#include "core/variant.h"
#include "core/vector.h"
#include "core/io/config_file.h"
#include "core/undo_redo.h"
class EditorNode;
class Spatial;
@ -191,6 +191,12 @@ public:
DOCK_SLOT_MAX
};
enum AfterGUIInput {
AFTER_GUI_INPUT_PASS,
AFTER_GUI_INPUT_STOP,
AFTER_GUI_INPUT_DESELECT
};
//TODO: send a resource for editing to the editor node?
void add_control_to_container(CustomControlContainer p_location, Control *p_control);
@ -219,7 +225,7 @@ public:
virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event);
virtual AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
@ -282,6 +288,7 @@ public:
VARIANT_ENUM_CAST(EditorPlugin::CustomControlContainer);
VARIANT_ENUM_CAST(EditorPlugin::DockSlot);
VARIANT_ENUM_CAST(EditorPlugin::AfterGUIInput);
typedef EditorPlugin *(*EditorPluginCreateFunc)(EditorNode *);

View File

@ -128,9 +128,9 @@ void Polygon3DEditor::_wip_close() {
undo_redo->commit_action();
}
bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!node) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Transform gt = node->get_global_transform();
@ -149,7 +149,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
Vector3 spoint;
if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
spoint = gi.xform(spoint);
@ -176,19 +176,19 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
snap_ignore = false;
_polygon_draw();
edited_point = 1;
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_threshold) {
//wip closed
_wip_close();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
wip.push_back(cpoint);
edited_point = wip.size();
snap_ignore = false;
_polygon_draw();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
}
} else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) {
@ -209,7 +209,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
//search edges
@ -244,7 +244,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
_polygon_draw();
snap_ignore = true;
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
} else {
//look for points to move
@ -269,7 +269,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
edited_point_pos = poly[closest_idx];
_polygon_draw();
snap_ignore = false;
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
}
} else {
@ -278,7 +278,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
if (edited_point != -1) {
//apply
ERR_FAIL_INDEX_V(edited_point, poly.size(), false);
ERR_FAIL_INDEX_V(edited_point, poly.size(), EditorPlugin::AFTER_GUI_INPUT_PASS);
poly.write[edited_point] = edited_point_pos;
undo_redo->create_action(TTR("Edit Poly"));
undo_redo->add_do_method(node, "set_polygon", poly);
@ -288,7 +288,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->commit_action();
edited_point = -1;
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
}
}
@ -315,7 +315,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
undo_redo->add_do_method(this, "_polygon_draw");
undo_redo->add_undo_method(this, "_polygon_draw");
undo_redo->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
}
@ -335,7 +335,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
Vector3 spoint;
if (!p.intersects_ray(ray_from, ray_dir, &spoint)) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
spoint = gi.xform(spoint);
@ -357,7 +357,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
float Polygon3DEditor::_get_depth() {

View File

@ -103,7 +103,7 @@ protected:
static void _bind_methods();
public:
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon);
Polygon3DEditor(EditorNode *p_editor);
~Polygon3DEditor();
@ -116,7 +116,7 @@ class Polygon3DEditorPlugin : public EditorPlugin {
EditorNode *editor;
public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual String get_name() const { return "Polygon3DEditor"; }
bool has_main_screen() const { return false; }

View File

@ -311,13 +311,13 @@ PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
set_spatial_node(p_path);
}
bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!path) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Ref<Curve3D> c = path->get_curve();
if (c.is_null()) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Transform gt = path->get_global_transform();
Transform it = gt.affine_inverse();
@ -346,14 +346,14 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
PoolVector<Vector3>::Read r = v3a.read();
if (p_camera->unproject_position(gt.xform(c->get_point_position(0))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing
}
for (int i = 0; i < c->get_point_count() - 1; i++) {
//find the offset and point index of the place to break up
int j = idx;
if (p_camera->unproject_position(gt.xform(c->get_point_position(i + 1))).distance_to(mbpos) < click_dist) {
return false; //nope, existing
return EditorPlugin::AFTER_GUI_INPUT_PASS; //nope, existing
}
while (j < rc && c->get_point_position(i + 1) != r[j]) {
@ -403,7 +403,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "add_point", closest_seg_point, Vector3(), Vector3(), closest_seg + 1);
ur->add_undo_method(c.ptr(), "remove_point", closest_seg + 1);
ur->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
Vector3 org;
@ -422,7 +422,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "add_point", it.xform(inters), Vector3(), Vector3(), -1);
ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
ur->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
//add new at pos
@ -442,27 +442,27 @@ bool PathEditorPlugin::forward_spatial_gui_input(int p_index, Camera *p_camera,
ur->add_do_method(c.ptr(), "remove_point", i);
ur->add_undo_method(c.ptr(), "add_point", c->get_point_position(i), c->get_point_in(i), c->get_point_out(i), i);
ur->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else if (dist_to_p_out < click_dist) {
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove Out-Control Point"));
ur->add_do_method(c.ptr(), "set_point_out", i, Vector3());
ur->add_undo_method(c.ptr(), "set_point_out", i, c->get_point_out(i));
ur->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else if (dist_to_p_in < click_dist) {
UndoRedo *ur = editor->get_undo_redo();
ur->create_action(TTR("Remove In-Control Point"));
ur->add_do_method(c.ptr(), "set_point_in", i, Vector3());
ur->add_undo_method(c.ptr(), "set_point_in", i, c->get_point_in(i));
ur->commit_action();
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
}
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void PathEditorPlugin::edit(Object *p_object) {

View File

@ -114,7 +114,7 @@ public:
Path *get_edited_path() { return path; }
static PathEditorPlugin *singleton;
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event);
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
//virtual bool forward_gui_input(const InputEvent& p_event) { return collision_polygon_editor->forward_gui_input(p_event); }
//virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);

View File

@ -1365,7 +1365,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = editor;
EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding();
if (!force_input_forwarding_list->empty()) {
bool discard = force_input_forwarding_list->forward_spatial_gui_input(index, camera, p_event, true);
bool discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true);
if (discard) {
return;
}
@ -1375,7 +1375,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
if (!over_plugin_list->empty()) {
bool discard = over_plugin_list->forward_spatial_gui_input(index, camera, p_event, false);
bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
if (discard) {
return;
}

View File

@ -131,19 +131,19 @@ Ref<MeshDataResource> MDIEdPlugin::get_mdr() {
return Ref<MeshDataResource>();
}
bool MDIEdPlugin::forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput MDIEdPlugin::forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &p_event) {
if (!ObjectDB::instance_validate(current_mesh_data_instance)) {
current_mesh_data_instance = nullptr;
}
if (current_mesh_data_instance) {
Ref<MDIGizmo> g = get_gizmo_from(current_mesh_data_instance);
if (g.is_valid() && g->forward_spatial_gui_input(index, camera, p_event)) {
return true;
if (g.is_valid()) {
return g->forward_spatial_gui_input(camera, p_event);
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void MDIEdPlugin::add_box() {

View File

@ -61,7 +61,7 @@ public:
Ref<MeshDataResource> get_mdr();
bool forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &p_event);
EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &p_event);
void add_box();
void add_triangle();

View File

@ -228,13 +228,13 @@ void MDIGizmo::select_all() {
redraw();
}
bool MDIGizmo::selection_click(int index, Camera *camera, const Ref<InputEventMouse> &event) {
bool MDIGizmo::selection_click(Camera *camera, const Ref<InputEventMouse> &event) {
if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) {
return selection_click_select_front_or_back(index, camera, event);
return selection_click_select_front_or_back(camera, event);
} else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) {
return selection_click_select_front_or_back(index, camera, event);
return selection_click_select_front_or_back(camera, event);
} else {
return selection_click_select_through(index, camera, event);
return selection_click_select_through(camera, event);
}
return false;
@ -271,7 +271,7 @@ bool MDIGizmo::is_point_visible(const Vector3 &point_orig, const Vector3 &camera
return true;
}
bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, const Ref<InputEventMouse> &event) {
bool MDIGizmo::selection_click_select_front_or_back(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin;
Vector2 gpoint = event->get_position();
@ -349,7 +349,7 @@ bool MDIGizmo::selection_click_select_front_or_back(int index, Camera *camera, c
return false;
}
bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event) {
bool MDIGizmo::selection_click_select_through(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin;
Vector2 gpoint = event->get_position();
@ -415,16 +415,16 @@ bool MDIGizmo::selection_click_select_through(int index, Camera *camera, const R
return false;
}
void MDIGizmo::selection_drag(int index, Camera *camera, const Ref<InputEventMouse> &event) {
void MDIGizmo::selection_drag(Camera *camera, const Ref<InputEventMouse> &event) {
if (handle_selection_type == HANDLE_SELECTION_TYPE_FRONT) {
selection_drag_rect_select_front_back(index, camera, event);
selection_drag_rect_select_front_back(camera, event);
} else if (handle_selection_type == HANDLE_SELECTION_TYPE_BACK) {
selection_drag_rect_select_front_back(index, camera, event);
selection_drag_rect_select_front_back(camera, event);
} else {
selection_drag_rect_select_through(index, camera, event);
selection_drag_rect_select_through(camera, event);
}
}
void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera, const Ref<InputEventMouse> &event) {
void MDIGizmo::selection_drag_rect_select_front_back(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform();
Vector3 ray_from = camera->get_global_transform().origin;
@ -512,7 +512,7 @@ void MDIGizmo::selection_drag_rect_select_front_back(int index, Camera *camera,
redraw();
}
void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event) {
void MDIGizmo::selection_drag_rect_select_through(Camera *camera, const Ref<InputEventMouse> &event) {
Transform gt = get_spatial_node()->get_global_transform();
Vector2 mouse_pos = event->get_position();
@ -578,7 +578,7 @@ void MDIGizmo::selection_drag_rect_select_through(int index, Camera *camera, con
redraw();
}
bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &event) {
EditorPlugin::AfterGUIInput MDIGizmo::forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &event) {
_last_known_camera_facing = camera->get_transform().basis.xform(Vector3(0, 0, -1));
Ref<InputEventMouseButton> event_button = event;
@ -606,7 +606,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
// Dont consume the event here, because the handles will get stuck
// to the mouse pointer if we return true
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
if (!event_button->is_pressed()) {
@ -622,11 +622,16 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
}
if (!had_rect_drag) {
return selection_click(index, camera, event);
if (selection_click(camera, event)) {
return EditorPlugin::AFTER_GUI_INPUT_STOP;
} else {
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
} else {
selection_drag(index, camera, event_button);
selection_drag(camera, event_button);
// Always return false here, so the drag rect thing disappears in the editor
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
} else {
// event is pressed
@ -636,7 +641,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void MDIGizmo::add_to_all_selected(const Vector3 &ofs) {
for (int i = 0; i < _selected_points.size(); ++i) {

View File

@ -83,15 +83,15 @@ public:
void select_all();
bool selection_click(int index, Camera *camera, const Ref<InputEventMouse> &event);
bool selection_click(Camera *camera, const Ref<InputEventMouse> &event);
bool is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform &gt);
bool selection_click_select_front_or_back(int index, Camera *camera, const Ref<InputEventMouse> &event);
bool selection_click_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag(int index, Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_front_back(int index, Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event);
bool forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &event);
bool selection_click_select_front_or_back(Camera *camera, const Ref<InputEventMouse> &event);
bool selection_click_select_through(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_front_back(Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_through(Camera *camera, const Ref<InputEventMouse> &event);
EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *camera, const Ref<InputEvent> &event);
void add_to_all_selected(const Vector3 &ofs);
void mul_all_selected_with_basis(const Basis &b);

View File

@ -1151,13 +1151,17 @@ void ModuleSkeletonEditor::_draw_handles() {
am->surface_set_material(0, handle_material);
}
bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput ModuleSkeletonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!skeleton || tool_mode == TOOL_MODE_BONE_NONE) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
return EditorPlugin::AFTER_GUI_INPUT_PASS;
//TODO
/*
SpatialEditor *se = SpatialEditor::get_singleton();
SpatialEditorViewport *sev = se->get_editor_viewport(p_index);
SpatialEditorViewport *sev = se->get_editor_viewport();
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
@ -1504,6 +1508,7 @@ bool ModuleSkeletonEditor::forward_spatial_gui_input(int p_index, Camera *p_came
}
return false;
*/
}
void ModuleSkeletonEditor::add_bone() {

View File

@ -236,7 +236,7 @@ protected:
static void _bind_methods();
public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event);
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx);
// Transform can be keyed, whether or not to show the button
@ -287,7 +287,7 @@ protected:
static void _bind_methods();
public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return skel_editor->forward_spatial_gui_input(p_index, p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return skel_editor->forward_spatial_gui_input(p_camera, p_event); }
virtual bool can_handle(Object *p_object);
virtual void parse_begin(Object *p_object);
UndoRedo *get_undo_redo() { return undo_redo; }
@ -300,11 +300,11 @@ class ModuleSkeletonEditorPlugin : public EditorPlugin {
EditorNode *editor;
public:
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) {
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (SpatialEditor::get_singleton()->get_tool_mode() != SpatialEditor::TOOL_MODE_EXTERNAL) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
return skeleton_plugin->forward_spatial_gui_input(p_index, p_camera, p_event);
return skeleton_plugin->forward_spatial_gui_input(p_camera, p_event);
}
bool has_main_screen() const { return false; }
virtual bool handles(Object *p_object) const;

View File

@ -44,9 +44,9 @@ SOFTWARE.
#include "scene/gui/slider.h"
#include "scene/gui/scroll_container.h"
bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Ref<InputEventMouseButton> mb = p_event;
@ -56,24 +56,24 @@ bool TerrainWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref
Ref<TerrainLibrary> lib = _world->get_library();
if (!lib.is_valid())
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
EditorPlugin::AfterGUIInput TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor || !_world || !_world->is_inside_world())
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
Camera *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point);
@ -94,7 +94,7 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point
channel = _channel_type;
if (channel == -1)
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
int isolevel = _current_isolevel;
bool mode_add = false;
@ -110,10 +110,10 @@ bool TerrainWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point
_world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel);
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void TerrainWorldEditor::edit(TerrainWorld *p_world) {

View File

@ -39,10 +39,10 @@ public:
};
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(TerrainWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
TerrainWorldEditor();
TerrainWorldEditor(EditorNode *p_editor);
@ -90,7 +90,7 @@ protected:
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "TerrainWorldEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);

View File

@ -43,9 +43,9 @@ SOFTWARE.
#include "scene/gui/scroll_container.h"
#include "scene/gui/slider.h"
bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Ref<InputEventMouseButton> mb = p_event;
@ -55,22 +55,22 @@ bool Terrain2DWorldEditor::forward_spatial_input_event(Camera *p_camera, const R
Ref<Terrain2DLibrary> lib = _world->get_library();
if (!lib.is_valid())
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
EditorPlugin::AfterGUIInput Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
/*
if (!spatial_editor || !_world || !_world->is_inside_world())
return false;
@ -113,7 +113,7 @@ bool Terrain2DWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_poi
return true;
}
*/
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void Terrain2DWorldEditor::edit(Terrain2DWorld *p_world) {

View File

@ -41,10 +41,10 @@ public:
};
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(Terrain2DWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
Terrain2DWorldEditor();
Terrain2DWorldEditor(EditorNode *p_editor);
@ -92,7 +92,7 @@ protected:
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "Terrain2DWorldEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);

View File

@ -44,9 +44,9 @@ SOFTWARE.
#include "scene/gui/slider.h"
#include "scene/gui/scroll_container.h"
bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
EditorPlugin::AfterGUIInput VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) {
if (!_world || !_world->get_editable()) {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
Ref<InputEventMouseButton> mb = p_event;
@ -56,24 +56,24 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref<I
Ref<VoxelLibrary> lib = _world->get_library();
if (!lib.is_valid())
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
if (mb->get_button_index() == BUTTON_LEFT) {
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
//return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
}
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
EditorPlugin::AfterGUIInput VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click) {
if (!spatial_editor || !_world || !_world->is_inside_world())
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
Camera *camera = p_camera;
Vector3 from = camera->project_ray_origin(p_point);
@ -94,7 +94,7 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
channel = _channel_type;
if (channel == -1)
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
int isolevel = _current_isolevel;
bool mode_add = false;
@ -110,10 +110,10 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point,
_world->set_voxel_with_tool(mode_add, res.position, res.normal, selected_voxel, isolevel);
return true;
return EditorPlugin::AFTER_GUI_INPUT_STOP;
}
return false;
return EditorPlugin::AFTER_GUI_INPUT_PASS;
}
void VoxelWorldEditor::edit(VoxelWorld *p_world) {

View File

@ -41,10 +41,10 @@ public:
};
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
EditorPlugin::AfterGUIInput forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event);
void edit(VoxelWorld *p_world);
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
EditorPlugin::AfterGUIInput do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
VoxelWorldEditor();
VoxelWorldEditor(EditorNode *p_editor);
@ -92,7 +92,7 @@ protected:
public:
bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual bool forward_spatial_gui_input(int p_index, Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual EditorPlugin::AfterGUIInput forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "VoxelWorldEditor"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);