mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Create a parent SelectTool script where all selection tools extend from
This commit is contained in:
parent
4c40d7586c
commit
b3d581bad4
|
@ -1,18 +1,4 @@
|
|||
extends BaseTool
|
||||
|
||||
|
||||
var _add := false # Shift + Mouse Click
|
||||
var _subtract := false # Ctrl + Mouse Click
|
||||
var _intersect := false # Shift + Ctrl + Mouse Click
|
||||
var undo_data : Dictionary
|
||||
|
||||
|
||||
func draw_start(_position : Vector2) -> void:
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
undo_data = Global.canvas.selection._get_undo_data(false)
|
||||
_intersect = Tools.shift && Tools.control
|
||||
_add = Tools.shift && !_intersect
|
||||
_subtract = Tools.control && !_intersect
|
||||
extends "res://src/Tools/SelectionTool.gd"
|
||||
|
||||
|
||||
func draw_move(_position : Vector2) -> void:
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
extends BaseTool
|
||||
|
||||
|
||||
var _add := false # Shift + Mouse Click
|
||||
var _subtract := false # Ctrl + Mouse Click
|
||||
var _intersect := false # Shift + Ctrl + Mouse Click
|
||||
var undo_data : Dictionary
|
||||
|
||||
|
||||
func draw_start(_position : Vector2) -> void:
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
undo_data = Global.canvas.selection._get_undo_data(false)
|
||||
_intersect = Tools.shift && Tools.control
|
||||
_add = Tools.shift && !_intersect
|
||||
_subtract = Tools.control && !_intersect
|
||||
extends "res://src/Tools/SelectionTool.gd"
|
||||
|
||||
|
||||
func draw_move(_position : Vector2) -> void:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
extends BaseTool
|
||||
extends "res://src/Tools/SelectionTool.gd"
|
||||
|
||||
|
||||
var _rect := Rect2(0, 0, 0, 0)
|
||||
|
@ -6,14 +6,9 @@ var _start_pos := Vector2.ZERO
|
|||
var _offset := Vector2.ZERO
|
||||
var _move := false
|
||||
|
||||
var _add := false # Shift + Mouse Click
|
||||
var _subtract := false # Ctrl + Mouse Click
|
||||
var _intersect := false # Shift + Ctrl + Mouse Click
|
||||
var _square := false # Mouse Click + Shift
|
||||
var _expand_from_center := false # Mouse Click + Ctrl
|
||||
|
||||
var undo_data : Dictionary
|
||||
|
||||
|
||||
func _input(event : InputEvent) -> void:
|
||||
if !_move and !_rect.has_no_area():
|
||||
|
@ -28,26 +23,20 @@ func _input(event : InputEvent) -> void:
|
|||
|
||||
|
||||
func draw_start(position : Vector2) -> void:
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
undo_data = Global.canvas.selection._get_undo_data(false)
|
||||
.draw_start(position)
|
||||
var selection_position : Vector2 = Global.canvas.selection.big_bounding_rectangle.position
|
||||
var offsetted_pos := position
|
||||
if selection_position.x < 0:
|
||||
offsetted_pos.x -= selection_position.x
|
||||
if selection_position.y < 0:
|
||||
offsetted_pos.y -= selection_position.y
|
||||
|
||||
if offsetted_pos.x >= 0 and offsetted_pos.y >= 0 and Global.current_project.selection_bitmap.get_bit(offsetted_pos) and !Tools.control and !Tools.shift:
|
||||
# Move current selection
|
||||
_move = true
|
||||
_offset = position
|
||||
Global.canvas.selection.move_borders_start()
|
||||
|
||||
else:
|
||||
_start_pos = position
|
||||
_intersect = Tools.shift && Tools.control
|
||||
_add = Tools.shift && !_intersect
|
||||
_subtract = Tools.control && !_intersect
|
||||
|
||||
|
||||
func draw_move(position : Vector2) -> void:
|
||||
|
|
24
src/Tools/SelectionTool.gd
Normal file
24
src/Tools/SelectionTool.gd
Normal file
|
@ -0,0 +1,24 @@
|
|||
extends BaseTool
|
||||
|
||||
|
||||
var _add := false # Shift + Mouse Click
|
||||
var _subtract := false # Ctrl + Mouse Click
|
||||
var _intersect := false # Shift + Ctrl + Mouse Click
|
||||
|
||||
var undo_data : Dictionary
|
||||
|
||||
|
||||
func draw_start(_position : Vector2) -> void:
|
||||
Global.canvas.selection.transform_content_confirm()
|
||||
undo_data = Global.canvas.selection._get_undo_data(false)
|
||||
_intersect = Tools.shift && Tools.control
|
||||
_add = Tools.shift && !_intersect
|
||||
_subtract = Tools.control && !_intersect
|
||||
|
||||
|
||||
func draw_move(_position : Vector2) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func draw_end(_position : Vector2) -> void:
|
||||
pass
|
20
src/Tools/SelectionTool.tscn
Normal file
20
src/Tools/SelectionTool.tscn
Normal file
|
@ -0,0 +1,20 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://src/Tools/BaseTool.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/Tools/SelectionTool.gd" type="Script" id=2]
|
||||
|
||||
[node name="ToolOptions" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="PixelPerfect" parent="." index="1"]
|
||||
visible = false
|
||||
|
||||
[node name="EmptySpacer" parent="." index="2"]
|
||||
visible = false
|
||||
margin_top = 18.0
|
||||
margin_bottom = 30.0
|
||||
|
||||
[node name="Mirror" parent="." index="3"]
|
||||
visible = false
|
||||
margin_top = 18.0
|
||||
margin_bottom = 35.0
|
Loading…
Reference in a new issue