Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
8cd5102c
Unverified
Commit
8cd5102c
authored
Feb 10, 2020
by
Rémi Verschelde
Committed by
GitHub
Feb 10, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35704 from KoBeWi/free_the_nodes
Include locked nodes on selection list
parents
b390ad5a
de77bda6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
23 deletions
+72
-23
canvas_item_editor_plugin.cpp
editor/plugins/canvas_item_editor_plugin.cpp
+34
-10
canvas_item_editor_plugin.h
editor/plugins/canvas_item_editor_plugin.h
+1
-1
spatial_editor_plugin.cpp
editor/plugins/spatial_editor_plugin.cpp
+36
-11
spatial_editor_plugin.h
editor/plugins/spatial_editor_plugin.h
+1
-1
No files found.
editor/plugins/canvas_item_editor_plugin.cpp
View file @
8cd5102c
...
...
@@ -606,7 +606,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no
}
}
void
CanvasItemEditor
::
_get_canvas_items_at_pos
(
const
Point2
&
p_pos
,
Vector
<
_SelectResult
>
&
r_items
)
{
void
CanvasItemEditor
::
_get_canvas_items_at_pos
(
const
Point2
&
p_pos
,
Vector
<
_SelectResult
>
&
r_items
,
bool
p_ignore_groups
)
{
Node
*
scene
=
editor
->
get_edited_scene
();
...
...
@@ -621,14 +621,16 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
node
=
node
->
get_parent
();
};
// Replace the node by the group if grouped
CanvasItem
*
canvas_item
=
Object
::
cast_to
<
CanvasItem
>
(
node
);
while
(
node
&&
node
!=
scene
->
get_parent
())
{
CanvasItem
*
canvas_item_tmp
=
Object
::
cast_to
<
CanvasItem
>
(
node
);
if
(
canvas_item_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
canvas_item
=
canvas_item_tmp
;
if
(
!
p_ignore_groups
)
{
// Replace the node by the group if grouped
while
(
node
&&
node
!=
scene
->
get_parent
())
{
CanvasItem
*
canvas_item_tmp
=
Object
::
cast_to
<
CanvasItem
>
(
node
);
if
(
canvas_item_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
canvas_item
=
canvas_item_tmp
;
}
node
=
node
->
get_parent
();
}
node
=
node
->
get_parent
();
}
// Check if the canvas item is already in the list (for groups or scenes)
...
...
@@ -641,7 +643,7 @@ void CanvasItemEditor::_get_canvas_items_at_pos(const Point2 &p_pos, Vector<_Sel
}
//Remove the item if invalid
if
(
!
canvas_item
||
duplicate
||
(
canvas_item
!=
scene
&&
canvas_item
->
get_owner
()
!=
scene
&&
!
scene
->
is_editable_instance
(
canvas_item
->
get_owner
()))
||
_is_node_locked
(
canvas_item
))
{
if
(
!
canvas_item
||
duplicate
||
(
canvas_item
!=
scene
&&
canvas_item
->
get_owner
()
!=
scene
&&
!
scene
->
is_editable_instance
(
canvas_item
->
get_owner
()))
||
(
tool
==
TOOL_LIST_SELECT
&&
_is_node_locked
(
canvas_item
)
))
{
r_items
.
remove
(
i
);
i
--
;
}
else
{
...
...
@@ -2223,7 +2225,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Popup the selection menu list
Point2
click
=
transform
.
affine_inverse
().
xform
(
b
->
get_position
());
_get_canvas_items_at_pos
(
click
,
selection_results
);
_get_canvas_items_at_pos
(
click
,
selection_results
,
b
->
get_alt
()
&&
tool
!=
TOOL_LIST_SELECT
);
if
(
selection_results
.
size
()
==
1
)
{
CanvasItem
*
item
=
selection_results
[
0
].
item
;
...
...
@@ -2245,7 +2247,29 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Ref
<
Texture
>
icon
=
EditorNode
::
get_singleton
()
->
get_object_icon
(
item
,
"Node"
);
String
node_path
=
"/"
+
root_name
+
"/"
+
root_path
.
rel_path_to
(
item
->
get_path
());
selection_menu
->
add_item
(
item
->
get_name
());
int
locked
=
0
;
if
(
_is_node_locked
(
item
))
{
locked
=
1
;
}
else
{
Node
*
scene
=
editor
->
get_edited_scene
();
Node
*
node
=
item
;
while
(
node
&&
node
!=
scene
->
get_parent
())
{
CanvasItem
*
canvas_item_tmp
=
Object
::
cast_to
<
CanvasItem
>
(
node
);
if
(
canvas_item_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
locked
=
2
;
}
node
=
node
->
get_parent
();
}
}
String
suffix
=
String
();
if
(
locked
==
1
)
{
suffix
=
" ("
+
TTR
(
"Locked"
)
+
")"
;
}
else
if
(
locked
==
2
)
{
suffix
=
" ("
+
TTR
(
"Grouped"
)
+
")"
;
}
selection_menu
->
add_item
((
String
)
item
->
get_name
()
+
suffix
);
selection_menu
->
set_item_icon
(
i
,
icon
);
selection_menu
->
set_item_metadata
(
i
,
node_path
);
selection_menu
->
set_item_tooltip
(
i
,
String
(
item
->
get_name
())
+
"
\n
Type: "
+
item
->
get_class
()
+
"
\n
Path: "
+
node_path
);
...
...
editor/plugins/canvas_item_editor_plugin.h
View file @
8cd5102c
...
...
@@ -418,7 +418,7 @@ private:
bool
_is_node_locked
(
const
Node
*
p_node
);
bool
_is_node_movable
(
const
Node
*
p_node
,
bool
p_popup_warning
=
false
);
void
_find_canvas_items_at_pos
(
const
Point2
&
p_pos
,
Node
*
p_node
,
Vector
<
_SelectResult
>
&
r_items
,
const
Transform2D
&
p_parent_xform
=
Transform2D
(),
const
Transform2D
&
p_canvas_xform
=
Transform2D
());
void
_get_canvas_items_at_pos
(
const
Point2
&
p_pos
,
Vector
<
_SelectResult
>
&
r_items
);
void
_get_canvas_items_at_pos
(
const
Point2
&
p_pos
,
Vector
<
_SelectResult
>
&
r_items
,
bool
p_ignore_groups
=
false
);
void
_get_bones_at_pos
(
const
Point2
&
p_pos
,
Vector
<
_SelectResult
>
&
r_items
);
void
_find_canvas_items_in_rect
(
const
Rect2
&
p_rect
,
Node
*
p_node
,
List
<
CanvasItem
*>
*
r_items
,
const
Transform2D
&
p_parent_xform
=
Transform2D
(),
const
Transform2D
&
p_canvas_xform
=
Transform2D
());
...
...
editor/plugins/spatial_editor_plugin.cpp
View file @
8cd5102c
...
...
@@ -250,7 +250,7 @@ void SpatialEditorViewport::_clear_selected() {
editor_selection
->
clear
();
}
void
SpatialEditorViewport
::
_select_clicked
(
bool
p_append
,
bool
p_single
)
{
void
SpatialEditorViewport
::
_select_clicked
(
bool
p_append
,
bool
p_single
,
bool
p_allow_locked
)
{
if
(
!
clicked
)
return
;
...
...
@@ -260,17 +260,20 @@ void SpatialEditorViewport::_select_clicked(bool p_append, bool p_single) {
if
(
!
selected
)
return
;
// Replace the node by the group if grouped
while
(
node
&&
node
!=
editor
->
get_edited_scene
()
->
get_parent
())
{
Spatial
*
selected_tmp
=
Object
::
cast_to
<
Spatial
>
(
node
);
if
(
selected_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
selected
=
selected_tmp
;
if
(
!
p_allow_locked
)
{
// Replace the node by the group if grouped
while
(
node
&&
node
!=
editor
->
get_edited_scene
()
->
get_parent
())
{
Spatial
*
selected_tmp
=
Object
::
cast_to
<
Spatial
>
(
node
);
if
(
selected_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
selected
=
selected_tmp
;
}
node
=
node
->
get_parent
();
}
node
=
node
->
get_parent
();
}
if
(
!
_is_node_locked
(
selected
))
if
(
p_allow_locked
||
!
_is_node_locked
(
selected
))
{
_select
(
selected
,
clicked_wants_append
,
true
);
}
}
void
SpatialEditorViewport
::
_select
(
Node
*
p_node
,
bool
p_append
,
bool
p_single
)
{
...
...
@@ -848,7 +851,7 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
selection_results
.
clear
();
if
(
clicked
)
{
_select_clicked
(
clicked_wants_append
,
true
);
_select_clicked
(
clicked_wants_append
,
true
,
spatial_editor
->
get_tool_mode
()
!=
SpatialEditor
::
TOOL_MODE_LIST_SELECT
);
clicked
=
0
;
}
...
...
@@ -865,7 +868,29 @@ void SpatialEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
String
node_path
=
"/"
+
root_name
+
"/"
+
root_path
.
rel_path_to
(
spat
->
get_path
());
selection_menu
->
add_item
(
spat
->
get_name
());
int
locked
=
0
;
if
(
_is_node_locked
(
spat
))
{
locked
=
1
;
}
else
{
Node
*
ed_scene
=
editor
->
get_edited_scene
();
Node
*
node
=
spat
;
while
(
node
&&
node
!=
ed_scene
->
get_parent
())
{
Spatial
*
selected_tmp
=
Object
::
cast_to
<
Spatial
>
(
node
);
if
(
selected_tmp
&&
node
->
has_meta
(
"_edit_group_"
))
{
locked
=
2
;
}
node
=
node
->
get_parent
();
}
}
String
suffix
=
String
();
if
(
locked
==
1
)
{
suffix
=
" ("
+
TTR
(
"Locked"
)
+
")"
;
}
else
if
(
locked
==
2
)
{
suffix
=
" ("
+
TTR
(
"Grouped"
)
+
")"
;
}
selection_menu
->
add_item
((
String
)
spat
->
get_name
()
+
suffix
);
selection_menu
->
set_item_icon
(
i
,
icon
);
selection_menu
->
set_item_metadata
(
i
,
node_path
);
selection_menu
->
set_item_tooltip
(
i
,
String
(
spat
->
get_name
())
+
"
\n
Type: "
+
spat
->
get_class
()
+
"
\n
Path: "
+
node_path
);
...
...
@@ -2892,7 +2917,7 @@ void SpatialEditorViewport::_selection_result_pressed(int p_result) {
clicked
=
selection_results
[
p_result
].
item
->
get_instance_id
();
if
(
clicked
)
{
_select_clicked
(
clicked_wants_append
,
true
);
_select_clicked
(
clicked_wants_append
,
true
,
spatial_editor
->
get_tool_mode
()
!=
SpatialEditor
::
TOOL_MODE_LIST_SELECT
);
clicked
=
0
;
}
}
...
...
editor/plugins/spatial_editor_plugin.h
View file @
8cd5102c
...
...
@@ -234,7 +234,7 @@ private:
void
_update_name
();
void
_compute_edit
(
const
Point2
&
p_point
);
void
_clear_selected
();
void
_select_clicked
(
bool
p_append
,
bool
p_single
);
void
_select_clicked
(
bool
p_append
,
bool
p_single
,
bool
p_allow_locked
=
false
);
void
_select
(
Node
*
p_node
,
bool
p_append
,
bool
p_single
);
ObjectID
_select_ray
(
const
Point2
&
p_pos
,
bool
p_append
,
bool
&
r_includes_current
,
int
*
r_gizmo_handle
=
NULL
,
bool
p_alt_select
=
false
);
void
_find_items_at_pos
(
const
Point2
&
p_pos
,
bool
&
r_includes_current
,
Vector
<
_RayResult
>
&
results
,
bool
p_alt_select
=
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment