1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Made brush creation from selection a separate menu option

Also works with Ctrl+B. Copying no longer creates a project brush.
This commit is contained in:
Manolis Papadeas 2021-05-25 22:48:37 +03:00
parent fa5c178720
commit a77cc05446
4 changed files with 46 additions and 5 deletions

View file

@ -118,6 +118,9 @@ msgstr ""
msgid "Delete"
msgstr ""
msgid "New Brush"
msgstr ""
msgid "Scale Image"
msgstr ""

View file

@ -596,6 +596,11 @@ right_polygon_select_tool={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":75,"unicode":0,"echo":false,"script":null)
]
}
new_brush={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":66,"unicode":0,"echo":false,"script":null)
]
}
[locale]

View file

@ -567,10 +567,6 @@ func copy() -> void:
clipboard.big_bounding_rectangle = big_bounding_rectangle
clipboard.selection_offset = project.selection_offset
var brush : Image = to_copy.get_rect(to_copy.get_used_rect())
project.brushes.append(brush)
Brushes.add_project_brush(brush)
func paste() -> void:
if !clipboard.image:
@ -620,6 +616,40 @@ func delete() -> void:
commit_undo("Draw", _undo_data)
func new_brush() -> void:
var project := Global.current_project
if !project.has_selection:
return
var image : Image = project.frames[project.current_frame].cels[project.current_layer].image
var brush := Image.new()
if is_moving_content:
brush.copy_from(preview_image)
var selected_bitmap_copy := project.selection_bitmap.duplicate()
project.move_bitmap_values(selected_bitmap_copy, false)
clipboard.selection_bitmap = selected_bitmap_copy
else:
brush = image.get_rect(big_bounding_rectangle)
brush.lock()
# Remove unincluded pixels if the selection is not a single rectangle
for x in brush.get_size().x:
for y in brush.get_size().y:
var pos := Vector2(x, y)
var offset_pos = big_bounding_rectangle.position
if offset_pos.x < 0:
offset_pos.x = 0
if offset_pos.y < 0:
offset_pos.y = 0
if not project.selection_bitmap.get_bit(pos + offset_pos):
brush.set_pixelv(pos, Color(0))
brush.unlock()
if !brush.is_invisible():
var brush_used : Image = brush.get_rect(brush.get_used_rect())
project.brushes.append(brush_used)
Brushes.add_project_brush(brush_used)
func select_all() -> void:
var project := Global.current_project
var _undo_data = _get_undo_data(false)

View file

@ -2,7 +2,7 @@ extends Panel
enum FileMenuId {NEW, OPEN, OPEN_LAST_PROJECT, SAVE, SAVE_AS, EXPORT, EXPORT_AS, QUIT}
enum EditMenuId {UNDO, REDO, COPY, CUT, PASTE, DELETE, PREFERENCES}
enum EditMenuId {UNDO, REDO, COPY, CUT, PASTE, DELETE, NEW_BRUSH, PREFERENCES}
enum ViewMenuId {TILE_MODE, WINDOW_TRANSPARENCY, PANEL_LAYOUT, MIRROR_VIEW, SHOW_GRID, SHOW_PIXEL_GRID, SHOW_RULERS, SHOW_GUIDES, SHOW_ANIMATION_TIMELINE, ZEN_MODE, FULLSCREEN_MODE}
enum ImageMenuId {SCALE_IMAGE, CENTRALIZE_IMAGE, CROP_IMAGE, RESIZE_CANVAS, FLIP, ROTATE, INVERT_COLORS, DESATURATION, OUTLINE, HSV, GRADIENT, SHADER}
enum SelectMenuId {SELECT_ALL, CLEAR_SELECTION, INVERT}
@ -81,6 +81,7 @@ func setup_edit_menu() -> void:
"Cut" : InputMap.get_action_list("cut")[0].get_scancode_with_modifiers(),
"Paste" : InputMap.get_action_list("paste")[0].get_scancode_with_modifiers(),
"Delete" : InputMap.get_action_list("delete")[0].get_scancode_with_modifiers(),
"New Brush" : InputMap.get_action_list("new_brush")[0].get_scancode_with_modifiers(),
"Preferences" : 0
}
var edit_menu : PopupMenu = edit_menu_button.get_popup()
@ -305,6 +306,8 @@ func edit_menu_id_pressed(id : int) -> void:
Global.canvas.selection.paste()
EditMenuId.DELETE:
Global.canvas.selection.delete()
EditMenuId.NEW_BRUSH:
Global.canvas.selection.new_brush()
EditMenuId.PREFERENCES:
Global.preferences_dialog.popup_centered(Vector2(400, 280))
Global.dialog_open(true)