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
9a44dd6e
Unverified
Commit
9a44dd6e
authored
Jun 03, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 03, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39167 from Calinou/tileset-editor-zoom-mouse-wheel-anywhere
Allow mouse zooming without hovering the texture in the TileSet editor
parents
8fc6766d
d10a5b29
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
tile_set_editor_plugin.cpp
editor/plugins/tile_set_editor_plugin.cpp
+24
-9
tile_set_editor_plugin.h
editor/plugins/tile_set_editor_plugin.h
+1
-0
No files found.
editor/plugins/tile_set_editor_plugin.cpp
View file @
9a44dd6e
...
@@ -569,6 +569,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
...
@@ -569,6 +569,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
scroll
=
memnew
(
ScrollContainer
);
scroll
=
memnew
(
ScrollContainer
);
main_vb
->
add_child
(
scroll
);
main_vb
->
add_child
(
scroll
);
scroll
->
set_v_size_flags
(
SIZE_EXPAND_FILL
);
scroll
->
set_v_size_flags
(
SIZE_EXPAND_FILL
);
scroll
->
connect
(
"gui_input"
,
callable_mp
(
this
,
&
TileSetEditor
::
_on_scroll_container_input
));
scroll
->
set_clip_contents
(
true
);
scroll
->
set_clip_contents
(
true
);
empty_message
=
memnew
(
Label
);
empty_message
=
memnew
(
Label
);
...
@@ -1198,6 +1199,27 @@ bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_
...
@@ -1198,6 +1199,27 @@ bool TileSetEditor::is_within_grabbing_distance_of_first_point(const Vector2 &p_
return
distance
<
p_grab_threshold
;
return
distance
<
p_grab_threshold
;
}
}
void
TileSetEditor
::
_on_scroll_container_input
(
const
Ref
<
InputEvent
>
&
p_event
)
{
const
Ref
<
InputEventMouseButton
>
mb
=
p_event
;
if
(
mb
.
is_valid
())
{
// Zoom in/out using Ctrl + mouse wheel. This is done on the ScrollContainer
// to allow performing this action anywhere, even if the cursor isn't
// hovering the texture in the workspace.
if
(
mb
->
get_button_index
()
==
BUTTON_WHEEL_UP
&&
mb
->
is_pressed
()
&&
mb
->
get_control
())
{
print_line
(
"zooming in"
);
_zoom_in
();
// Don't scroll up after zooming in.
accept_event
();
}
else
if
(
mb
->
get_button_index
()
==
BUTTON_WHEEL_DOWN
&&
mb
->
is_pressed
()
&&
mb
->
get_control
())
{
print_line
(
"zooming out"
);
_zoom_out
();
// Don't scroll down after zooming out.
accept_event
();
}
}
}
void
TileSetEditor
::
_on_workspace_input
(
const
Ref
<
InputEvent
>
&
p_ie
)
{
void
TileSetEditor
::
_on_workspace_input
(
const
Ref
<
InputEvent
>
&
p_ie
)
{
if
(
tileset
.
is_null
()
||
!
get_current_texture
().
is_valid
())
{
if
(
tileset
.
is_null
()
||
!
get_current_texture
().
is_valid
())
{
return
;
return
;
...
@@ -1214,8 +1236,8 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
...
@@ -1214,8 +1236,8 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
}
}
current_tile_region
.
position
+=
WORKSPACE_MARGIN
;
current_tile_region
.
position
+=
WORKSPACE_MARGIN
;
Ref
<
InputEventMouseButton
>
mb
=
p_ie
;
const
Ref
<
InputEventMouseButton
>
mb
=
p_ie
;
Ref
<
InputEventMouseMotion
>
mm
=
p_ie
;
const
Ref
<
InputEventMouseMotion
>
mm
=
p_ie
;
if
(
mb
.
is_valid
())
{
if
(
mb
.
is_valid
())
{
if
(
mb
->
is_pressed
()
&&
mb
->
get_button_index
()
==
BUTTON_LEFT
&&
!
creating_shape
)
{
if
(
mb
->
is_pressed
()
&&
mb
->
get_button_index
()
==
BUTTON_LEFT
&&
!
creating_shape
)
{
...
@@ -1239,13 +1261,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
...
@@ -1239,13 +1261,6 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
delete
tiles
;
delete
tiles
;
}
}
}
}
// Mouse Wheel Event
if
(
mb
->
get_button_index
()
==
BUTTON_WHEEL_UP
&&
mb
->
is_pressed
()
&&
mb
->
get_control
())
{
_zoom_in
();
}
else
if
(
mb
->
get_button_index
()
==
BUTTON_WHEEL_DOWN
&&
mb
->
is_pressed
()
&&
mb
->
get_control
())
{
_zoom_out
();
}
}
}
// Drag Middle Mouse
// Drag Middle Mouse
if
(
mm
.
is_valid
())
{
if
(
mm
.
is_valid
())
{
...
...
editor/plugins/tile_set_editor_plugin.h
View file @
9a44dd6e
...
@@ -200,6 +200,7 @@ private:
...
@@ -200,6 +200,7 @@ private:
void
_on_workspace_overlay_draw
();
void
_on_workspace_overlay_draw
();
void
_on_workspace_draw
();
void
_on_workspace_draw
();
void
_on_workspace_process
();
void
_on_workspace_process
();
void
_on_scroll_container_input
(
const
Ref
<
InputEvent
>
&
p_event
);
void
_on_workspace_input
(
const
Ref
<
InputEvent
>
&
p_ie
);
void
_on_workspace_input
(
const
Ref
<
InputEvent
>
&
p_ie
);
void
_on_tool_clicked
(
int
p_tool
);
void
_on_tool_clicked
(
int
p_tool
);
void
_on_priority_changed
(
float
val
);
void
_on_priority_changed
(
float
val
);
...
...
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