mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-25 23:13:14 +00:00
Add a "Select pixels" option in the right click popup menu button of cel buttons
This commit is contained in:
parent
9fe0f2e2b0
commit
42a00fd91a
3 changed files with 43 additions and 14 deletions
|
@ -2377,10 +2377,16 @@ msgstr ""
|
||||||
msgid "Add Frame Tag"
|
msgid "Add Frame Tag"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Link Cels to"
|
#. An option found in the right click menu of a cel. If selected, all non-transparent pixels of that cel get selected.
|
||||||
|
msgid "Select pixels"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Unlink Cels"
|
#. An option found in the right click menu of a cel. If selected, all selected cels get linked together.
|
||||||
|
msgid "Link cels to"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. An option found in the right click menu of a cel. If selected, all selected cels get unlinked.
|
||||||
|
msgid "Unlink cels"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. An option found in the right click menu of an audio cel. If selected, the audio of the audio layer will start playing from this frame.
|
#. An option found in the right click menu of an audio cel. If selected, the audio of the audio layer will start playing from this frame.
|
||||||
|
|
|
@ -1042,6 +1042,25 @@ func select_cel_rect() -> void:
|
||||||
commit_undo("Select", undo_data_tmp)
|
commit_undo("Select", undo_data_tmp)
|
||||||
|
|
||||||
|
|
||||||
|
func select_cel_pixels(layer: BaseLayer, frame: Frame) -> void:
|
||||||
|
transform_content_confirm()
|
||||||
|
var project := Global.current_project
|
||||||
|
var undo_data_tmp := get_undo_data(false)
|
||||||
|
project.selection_map.crop(project.size.x, project.size.y)
|
||||||
|
project.selection_map.clear()
|
||||||
|
var current_cel := frame.cels[layer.index]
|
||||||
|
var cel_image: Image
|
||||||
|
if current_cel is GroupCel:
|
||||||
|
cel_image = (layer as GroupLayer).blend_children(frame)
|
||||||
|
else:
|
||||||
|
cel_image = current_cel.get_image()
|
||||||
|
project.selection_map.copy_from(cel_image)
|
||||||
|
project.selection_map_changed()
|
||||||
|
big_bounding_rectangle = project.selection_map.get_used_rect()
|
||||||
|
project.selection_offset = Vector2.ZERO
|
||||||
|
commit_undo("Select", undo_data_tmp)
|
||||||
|
|
||||||
|
|
||||||
func _project_switched() -> void:
|
func _project_switched() -> void:
|
||||||
marching_ants_outline.offset = Global.current_project.selection_offset
|
marching_ants_outline.offset = Global.current_project.selection_offset
|
||||||
big_bounding_rectangle = Global.current_project.selection_map.get_used_rect()
|
big_bounding_rectangle = Global.current_project.selection_map.get_used_rect()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
enum MenuOptions { PROPERTIES, DELETE, LINK, UNLINK }
|
enum MenuOptions { PROPERTIES, SELECT_PIXELS, DELETE, LINK, UNLINK }
|
||||||
|
|
||||||
var frame := 0
|
var frame := 0
|
||||||
var layer := 0
|
var layer := 0
|
||||||
|
@ -25,13 +25,7 @@ func _ready() -> void:
|
||||||
for selected in Global.current_project.selected_cels:
|
for selected in Global.current_project.selected_cels:
|
||||||
if selected[1] == layer and selected[0] == frame:
|
if selected[1] == layer and selected[0] == frame:
|
||||||
button_pressed = true
|
button_pressed = true
|
||||||
if cel is PixelCel:
|
if cel is AudioCel:
|
||||||
popup_menu.add_item("Delete")
|
|
||||||
popup_menu.add_item("Link Cels to")
|
|
||||||
popup_menu.add_item("Unlink Cels")
|
|
||||||
elif cel is GroupCel:
|
|
||||||
transparent_checker.visible = false
|
|
||||||
elif cel is AudioCel:
|
|
||||||
popup_menu.add_item("Play audio here")
|
popup_menu.add_item("Play audio here")
|
||||||
_is_playing_audio()
|
_is_playing_audio()
|
||||||
Global.cel_switched.connect(_is_playing_audio)
|
Global.cel_switched.connect(_is_playing_audio)
|
||||||
|
@ -39,6 +33,14 @@ func _ready() -> void:
|
||||||
Global.current_project.fps_changed.connect(_is_playing_audio)
|
Global.current_project.fps_changed.connect(_is_playing_audio)
|
||||||
Global.current_project.layers[layer].audio_changed.connect(_is_playing_audio)
|
Global.current_project.layers[layer].audio_changed.connect(_is_playing_audio)
|
||||||
Global.current_project.layers[layer].playback_frame_changed.connect(_is_playing_audio)
|
Global.current_project.layers[layer].playback_frame_changed.connect(_is_playing_audio)
|
||||||
|
else:
|
||||||
|
popup_menu.add_item("Select pixels")
|
||||||
|
if cel is PixelCel:
|
||||||
|
popup_menu.add_item("Delete")
|
||||||
|
popup_menu.add_item("Link cels to")
|
||||||
|
popup_menu.add_item("Unlink cels")
|
||||||
|
elif cel is GroupCel:
|
||||||
|
transparent_checker.visible = false
|
||||||
|
|
||||||
|
|
||||||
func _notification(what: int) -> void:
|
func _notification(what: int) -> void:
|
||||||
|
@ -132,19 +134,21 @@ func _on_CelButton_pressed() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_PopupMenu_id_pressed(id: int) -> void:
|
func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||||
|
var project := Global.current_project
|
||||||
match id:
|
match id:
|
||||||
MenuOptions.PROPERTIES:
|
MenuOptions.PROPERTIES:
|
||||||
properties.cel_indices = _get_cel_indices()
|
properties.cel_indices = _get_cel_indices()
|
||||||
properties.popup_centered()
|
properties.popup_centered()
|
||||||
MenuOptions.DELETE:
|
MenuOptions.SELECT_PIXELS:
|
||||||
var layer_class := Global.current_project.layers[layer]
|
var layer_class := project.layers[layer]
|
||||||
if layer_class is AudioLayer:
|
if layer_class is AudioLayer:
|
||||||
layer_class.playback_frame = frame
|
layer_class.playback_frame = frame
|
||||||
else:
|
else:
|
||||||
_delete_cel_content()
|
Global.canvas.selection.select_cel_pixels(layer_class, project.frames[frame])
|
||||||
|
MenuOptions.DELETE:
|
||||||
|
_delete_cel_content()
|
||||||
|
|
||||||
MenuOptions.LINK, MenuOptions.UNLINK:
|
MenuOptions.LINK, MenuOptions.UNLINK:
|
||||||
var project := Global.current_project
|
|
||||||
if id == MenuOptions.UNLINK:
|
if id == MenuOptions.UNLINK:
|
||||||
project.undo_redo.create_action("Unlink Cel")
|
project.undo_redo.create_action("Unlink Cel")
|
||||||
var selected_cels := _get_cel_indices(true)
|
var selected_cels := _get_cel_indices(true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue