mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-21 13:03:13 +00:00
Selection modes (#798)
* Fix a typo this is required because this is "Paint" Selection (so it's not supposed to cancel selection if we click outside the canvas) * Added Selction Modes Default, Add, Subtract, Intersect * removed whitespace * better options * Removed Separators from headers * formatting * more formatting that i didnt notice * Solved Shortcut conflict * remove whitespace
This commit is contained in:
parent
f16132decb
commit
cbeef73fac
11 changed files with 96 additions and 44 deletions
|
@ -19,7 +19,7 @@ func _ready() -> void:
|
||||||
color_rect.color = Global.left_tool_color
|
color_rect.color = Global.left_tool_color
|
||||||
else:
|
else:
|
||||||
color_rect.color = Global.right_tool_color
|
color_rect.color = Global.right_tool_color
|
||||||
$Header/Label.text = Tools.tools[name].display_name
|
$Label.text = Tools.tools[name].display_name
|
||||||
|
|
||||||
load_config()
|
load_config()
|
||||||
|
|
||||||
|
|
|
@ -15,26 +15,11 @@ margin_right = 116.0
|
||||||
margin_bottom = 4.0
|
margin_bottom = 4.0
|
||||||
rect_min_size = Vector2( 0, 4 )
|
rect_min_size = Vector2( 0, 4 )
|
||||||
|
|
||||||
[node name="Header" type="HBoxContainer" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
margin_top = 8.0
|
margin_top = 8.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 22.0
|
margin_bottom = 22.0
|
||||||
custom_constants/separation = 0
|
|
||||||
|
|
||||||
[node name="HSeparator2" type="HSeparator" parent="Header"]
|
|
||||||
margin_right = 23.0
|
|
||||||
margin_bottom = 14.0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="Header"]
|
|
||||||
margin_left = 23.0
|
|
||||||
margin_right = 92.0
|
|
||||||
margin_bottom = 14.0
|
|
||||||
theme_type_variation = "Header"
|
theme_type_variation = "Header"
|
||||||
text = "Tool Name"
|
text = "Tool Name"
|
||||||
|
align = 1
|
||||||
[node name="HSeparator" type="HSeparator" parent="Header"]
|
autowrap = true
|
||||||
margin_left = 92.0
|
|
||||||
margin_right = 116.0
|
|
||||||
margin_bottom = 14.0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ var _similarity := 100
|
||||||
|
|
||||||
|
|
||||||
func get_config() -> Dictionary:
|
func get_config() -> Dictionary:
|
||||||
return {"similarity": _similarity}
|
var config := .get_config()
|
||||||
|
config["similarity"] = _similarity
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
func set_config(config: Dictionary) -> void:
|
func set_config(config: Dictionary) -> void:
|
||||||
|
@ -23,6 +25,7 @@ func _on_Similarity_value_changed(value: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(position: Vector2) -> void:
|
func apply_selection(position: Vector2) -> void:
|
||||||
|
.apply_selection(position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
if position.x < 0 or position.y < 0:
|
if position.x < 0 or position.y < 0:
|
||||||
return
|
return
|
||||||
|
|
|
@ -65,6 +65,7 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position: Vector2) -> void:
|
func apply_selection(_position: Vector2) -> void:
|
||||||
|
.apply_selection(_position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
if !_add and !_subtract and !_intersect:
|
if !_add and !_subtract and !_intersect:
|
||||||
Global.canvas.selection.clear_selection()
|
Global.canvas.selection.clear_selection()
|
||||||
|
|
|
@ -71,6 +71,7 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position) -> void:
|
func apply_selection(_position) -> void:
|
||||||
|
.apply_selection(_position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
var cleared := false
|
var cleared := false
|
||||||
if !_add and !_subtract and !_intersect:
|
if !_add and !_subtract and !_intersect:
|
||||||
|
|
|
@ -7,6 +7,7 @@ var _allegro_image_segments: Array
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(position: Vector2) -> void:
|
func apply_selection(position: Vector2) -> void:
|
||||||
|
.apply_selection(position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
var size: Vector2 = project.size
|
var size: Vector2 = project.size
|
||||||
if position.x < 0 or position.y < 0 or position.x >= size.x or position.y >= size.y:
|
if position.x < 0 or position.y < 0 or position.x >= size.x or position.y >= size.y:
|
||||||
|
|
|
@ -13,11 +13,11 @@ var _draw_points := []
|
||||||
|
|
||||||
|
|
||||||
func get_config() -> Dictionary:
|
func get_config() -> Dictionary:
|
||||||
return {
|
var config := .get_config()
|
||||||
"brush_type": _brush.type,
|
config["brush_type"] = _brush.type
|
||||||
"brush_index": _brush.index,
|
config["brush_index"] = _brush.index
|
||||||
"brush_size": _brush_size,
|
config["brush_size"] = _brush_size
|
||||||
}
|
return config
|
||||||
|
|
||||||
|
|
||||||
func set_config(config: Dictionary) -> void:
|
func set_config(config: Dictionary) -> void:
|
||||||
|
@ -99,12 +99,14 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position) -> void:
|
func apply_selection(_position) -> void:
|
||||||
|
.apply_selection(_position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
var cleared := false
|
var cleared := false
|
||||||
if !_add and !_subtract and !_intersect:
|
if !_add and !_subtract and !_intersect:
|
||||||
cleared = true
|
cleared = true
|
||||||
Global.canvas.selection.clear_selection()
|
Global.canvas.selection.clear_selection()
|
||||||
if _draw_points.size() > 1:
|
# This is paint selection so we've done >= 1 nstead of > 1
|
||||||
|
if _draw_points.size() >= 1:
|
||||||
var selection_map_copy := SelectionMap.new()
|
var selection_map_copy := SelectionMap.new()
|
||||||
selection_map_copy.copy_from(project.selection_map)
|
selection_map_copy.copy_from(project.selection_map)
|
||||||
if _intersect:
|
if _intersect:
|
||||||
|
|
|
@ -105,6 +105,7 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position) -> void:
|
func apply_selection(_position) -> void:
|
||||||
|
.apply_selection(_position)
|
||||||
if !_ready_to_apply:
|
if !_ready_to_apply:
|
||||||
return
|
return
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
|
|
|
@ -88,6 +88,7 @@ func draw_preview() -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position: Vector2) -> void:
|
func apply_selection(_position: Vector2) -> void:
|
||||||
|
.apply_selection(_position)
|
||||||
var project: Project = Global.current_project
|
var project: Project = Global.current_project
|
||||||
if !_add and !_subtract and !_intersect:
|
if !_add and !_subtract and !_intersect:
|
||||||
Global.canvas.selection.clear_selection()
|
Global.canvas.selection.clear_selection()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
class_name SelectionTool
|
class_name SelectionTool
|
||||||
extends BaseTool
|
extends BaseTool
|
||||||
|
|
||||||
|
enum Mode { DEFAULT, ADD, SUBTRACT, INTERSECT }
|
||||||
|
|
||||||
var undo_data: Dictionary
|
var undo_data: Dictionary
|
||||||
var _move := false
|
var _move := false
|
||||||
var _move_content := true
|
var _move_content := true
|
||||||
|
@ -10,6 +12,7 @@ var _offset := Vector2.ZERO
|
||||||
# click multiple times to create a selection
|
# click multiple times to create a selection
|
||||||
var _ongoing_selection := false
|
var _ongoing_selection := false
|
||||||
|
|
||||||
|
var _mode_selected := 0
|
||||||
var _add := false # Shift + Mouse Click
|
var _add := false # Shift + Mouse Click
|
||||||
var _subtract := false # Ctrl + Mouse Click
|
var _subtract := false # Ctrl + Mouse Click
|
||||||
var _intersect := false # Shift + Ctrl + Mouse Click
|
var _intersect := false # Shift + Ctrl + Mouse Click
|
||||||
|
@ -28,6 +31,32 @@ onready var timer: Timer = $Timer
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
set_spinbox_values()
|
set_spinbox_values()
|
||||||
|
refresh_options()
|
||||||
|
|
||||||
|
|
||||||
|
func refresh_options():
|
||||||
|
# The existence of this function is to ensure all items
|
||||||
|
# are added when we are selecting an option (Bad things will happen if i dont do this...)
|
||||||
|
$Modes.clear()
|
||||||
|
$Modes.add_item("Default (New Selection)")
|
||||||
|
$Modes.add_item("Add to Selection")
|
||||||
|
$Modes.add_item("Subtract from Selection")
|
||||||
|
$Modes.add_item("Intersection of Selections")
|
||||||
|
$Modes.select(_mode_selected)
|
||||||
|
|
||||||
|
|
||||||
|
func get_config() -> Dictionary:
|
||||||
|
var config := .get_config()
|
||||||
|
config["mode_selected"] = _mode_selected
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
func set_config(config: Dictionary) -> void:
|
||||||
|
_mode_selected = config.get("mode_selected", 0)
|
||||||
|
|
||||||
|
|
||||||
|
func update_config() -> void:
|
||||||
|
refresh_options()
|
||||||
|
|
||||||
|
|
||||||
func set_spinbox_values() -> void:
|
func set_spinbox_values() -> void:
|
||||||
|
@ -173,7 +202,22 @@ func draw_end(position: Vector2) -> void:
|
||||||
|
|
||||||
|
|
||||||
func apply_selection(_position: Vector2) -> void:
|
func apply_selection(_position: Vector2) -> void:
|
||||||
pass
|
# if a shortcut is activated then that will be obeyed instead
|
||||||
|
match _mode_selected:
|
||||||
|
Mode.ADD:
|
||||||
|
if !_subtract && !_intersect:
|
||||||
|
_add = true
|
||||||
|
Mode.SUBTRACT:
|
||||||
|
if !_add && !_intersect:
|
||||||
|
_subtract = true
|
||||||
|
Mode.INTERSECT:
|
||||||
|
if !_add && !_subtract:
|
||||||
|
_intersect = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Modes_item_selected(index: int) -> void:
|
||||||
|
_mode_selected = index
|
||||||
|
save_config()
|
||||||
|
|
||||||
|
|
||||||
func _set_cursor_text(rect: Rect2) -> void:
|
func _set_cursor_text(rect: Rect2) -> void:
|
||||||
|
|
|
@ -7,60 +7,73 @@
|
||||||
[node name="ToolOptions" instance=ExtResource( 1 )]
|
[node name="ToolOptions" instance=ExtResource( 1 )]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="PositionLabel" type="Label" parent="." index="2"]
|
[node name="ModeLabel" type="Label" parent="." index="2"]
|
||||||
margin_top = 26.0
|
margin_top = 26.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 40.0
|
margin_bottom = 40.0
|
||||||
text = "Position:"
|
text = "Mode:"
|
||||||
|
|
||||||
[node name="XSpinBox" parent="." index="3" instance=ExtResource( 3 )]
|
[node name="Modes" type="OptionButton" parent="." index="3"]
|
||||||
margin_top = 44.0
|
margin_top = 44.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 68.0
|
margin_bottom = 64.0
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="PositionLabel" type="Label" parent="." index="4"]
|
||||||
|
margin_top = 68.0
|
||||||
|
margin_right = 116.0
|
||||||
|
margin_bottom = 82.0
|
||||||
|
text = "Position:"
|
||||||
|
|
||||||
|
[node name="XSpinBox" parent="." index="5" instance=ExtResource( 3 )]
|
||||||
|
margin_top = 86.0
|
||||||
|
margin_right = 116.0
|
||||||
|
margin_bottom = 110.0
|
||||||
hint_tooltip = "X coordinate of the top left corner"
|
hint_tooltip = "X coordinate of the top left corner"
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
allow_lesser = true
|
allow_lesser = true
|
||||||
prefix = "X:"
|
prefix = "X:"
|
||||||
|
|
||||||
[node name="YSpinBox" parent="." index="4" instance=ExtResource( 3 )]
|
[node name="YSpinBox" parent="." index="6" instance=ExtResource( 3 )]
|
||||||
margin_top = 72.0
|
margin_top = 114.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 96.0
|
margin_bottom = 138.0
|
||||||
hint_tooltip = "Y coordinate of the top left corner"
|
hint_tooltip = "Y coordinate of the top left corner"
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
allow_lesser = true
|
allow_lesser = true
|
||||||
prefix = "Y:"
|
prefix = "Y:"
|
||||||
|
|
||||||
[node name="SizeLabel" type="Label" parent="." index="5"]
|
[node name="SizeLabel" type="Label" parent="." index="7"]
|
||||||
margin_top = 100.0
|
margin_top = 142.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 114.0
|
margin_bottom = 156.0
|
||||||
text = "Size:"
|
text = "Size:"
|
||||||
|
|
||||||
[node name="WSpinBox" parent="." index="6" instance=ExtResource( 3 )]
|
[node name="WSpinBox" parent="." index="8" instance=ExtResource( 3 )]
|
||||||
margin_top = 118.0
|
margin_top = 160.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 142.0
|
margin_bottom = 184.0
|
||||||
hint_tooltip = "Width of selection"
|
hint_tooltip = "Width of selection"
|
||||||
min_value = 1.0
|
min_value = 1.0
|
||||||
value = 1.0
|
value = 1.0
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
prefix = "W:"
|
prefix = "W:"
|
||||||
|
|
||||||
[node name="HSpinBox" parent="." index="7" instance=ExtResource( 3 )]
|
[node name="HSpinBox" parent="." index="9" instance=ExtResource( 3 )]
|
||||||
margin_top = 146.0
|
margin_top = 188.0
|
||||||
margin_right = 116.0
|
margin_right = 116.0
|
||||||
margin_bottom = 170.0
|
margin_bottom = 212.0
|
||||||
hint_tooltip = "Height of selection"
|
hint_tooltip = "Height of selection"
|
||||||
min_value = 1.0
|
min_value = 1.0
|
||||||
value = 1.0
|
value = 1.0
|
||||||
allow_greater = true
|
allow_greater = true
|
||||||
prefix = "H:"
|
prefix = "H:"
|
||||||
|
|
||||||
[node name="Timer" type="Timer" parent="." index="8"]
|
[node name="Timer" type="Timer" parent="." index="10"]
|
||||||
wait_time = 0.2
|
wait_time = 0.2
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="item_selected" from="Modes" to="." method="_on_Modes_item_selected"]
|
||||||
[connection signal="value_changed" from="XSpinBox" to="." method="_on_position_value_changed" binds= [ true ]]
|
[connection signal="value_changed" from="XSpinBox" to="." method="_on_position_value_changed" binds= [ true ]]
|
||||||
[connection signal="value_changed" from="YSpinBox" to="." method="_on_position_value_changed" binds= [ false ]]
|
[connection signal="value_changed" from="YSpinBox" to="." method="_on_position_value_changed" binds= [ false ]]
|
||||||
[connection signal="value_changed" from="WSpinBox" to="." method="_on_size_value_changed" binds= [ true ]]
|
[connection signal="value_changed" from="WSpinBox" to="." method="_on_size_value_changed" binds= [ true ]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue