Skip to content

Commit

Permalink
add scroll to change pen size
Browse files Browse the repository at this point in the history
  • Loading branch information
3ddelano committed Jan 27, 2022
1 parent ec26d76 commit 74b1356
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ This is a high-level changelog for each released versions of the plugin.
For a more detailed list of past changes, see the commit history.

1.0.2
------
-------
- Added scroll in draw mode to change pen size
- Auto hide toolbar when in draw mode
- Added keyboard shortcut to toggle toolbar

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Draw Anywhere (Godot Editor)
=========================================
###### (Get it from Godot Asset Library - Coming soon)
###### (Get it from Godot Asset Library - [Asset Library](https://godotengine.org/asset-library/asset/1184))


### Draw anywhere in the Godot Editor. Supports multiple pen sizes and colors.
Expand All @@ -18,7 +18,7 @@ Features
- Floating, draggable toolbar
- Change pen size and color
- Draw over Popups
- Easy keyboard shortcuts
- Easy shortcut keys

Automatic Installation
--------------
Expand Down Expand Up @@ -51,7 +51,7 @@ Once the plugin is enabled, a new floating toolbar will appear. This toolbar has

When draw mode is active, an indicator will be shown in the bottom-left of the screen.

Keyboard Shortcuts
Shortcuts
--------------

### Global shortcuts
Expand All @@ -72,6 +72,8 @@ These shortcuts will only work when draw mode is active
| Z | Clear last line |
| R | Reset the toolbar position |

Scroll to change pen size


Limitations?
--------------
Expand Down
8 changes: 5 additions & 3 deletions addons/draw_anywhere/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Draw Anywhere (Godot Editor)
=========================================
###### (Get it from Godot Asset Library - Coming soon)
###### (Get it from Godot Asset Library - [Asset Library](https://godotengine.org/asset-library/asset/1184))


### Draw anywhere in the Godot Editor. Supports multiple pen sizes and colors.
Expand All @@ -18,7 +18,7 @@ Features
- Floating, draggable toolbar
- Change pen size and color
- Draw over Popups
- Easy keyboard shortcuts
- Easy shortcut keys

Automatic Installation
--------------
Expand Down Expand Up @@ -51,7 +51,7 @@ Once the plugin is enabled, a new floating toolbar will appear. This toolbar has

When draw mode is active, an indicator will be shown in the bottom-left of the screen.

Keyboard Shortcuts
Shortcuts
--------------

### Global shortcuts
Expand All @@ -72,6 +72,8 @@ These shortcuts will only work when draw mode is active
| Z | Clear last line |
| R | Reset the toolbar position |

Scroll to change pen size


Limitations?
--------------
Expand Down
14 changes: 14 additions & 0 deletions addons/draw_anywhere/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var default_plugin_settings = {
}
var draw_settings = {
"size": 1,
"min_size": 1,
"max_size": 16,
"color": Color("#eee"),
"antialised": true,
"begin_cap_mode": Line2D.LINE_CAP_ROUND,
Expand Down Expand Up @@ -147,6 +149,18 @@ func _input(event: InputEvent) -> void:
current_line.add_point(event.position)
get_tree().set_input_as_handled()

# Handle scrolling to change size
if event is InputEventMouseButton and event.pressed:
if event.button_index == BUTTON_WHEEL_UP:
_set_draw_size(draw_settings.size + 1)
elif event.button_index == BUTTON_WHEEL_DOWN:
_set_draw_size(draw_settings.size - 1)


func _set_draw_size(p_size):
draw_settings.size = clamp(p_size, draw_settings.min_size, draw_settings.max_size)
canvas.update_drag_preview_size(self)


func _on_draw_button_pressed(is_now_active):
# Draw button on the toolbar was pressed
Expand Down
3 changes: 3 additions & 0 deletions addons/draw_anywhere/scenes/Canvas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func show_draw_preview(plugin):
draw_preview.visible = true
draw_preview.set_process(true)

func update_drag_preview_size(plugin):
draw_preview.rect_size = Vector2(plugin.draw_settings.size, plugin.draw_settings.size)


func hide_draw_preview():
draw_preview.visible = false
Expand Down

0 comments on commit 74b1356

Please sign in to comment.