1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-19 17:49:47 +00:00
Commit graph

76 commits

Author SHA1 Message Date
Manolis Papadeas 27cb0d2d2f
New selection system (#474)
* Basic move tool

* Added marching ants effect on the selection borders

* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist

- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet

Code is very ugly.

* Sort vectors counter-clockwise to be used as polygon borders

I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere

* More experiments I may or may not need

Trying to generate a polygon from the individual selected pixels

* Change default rectangle select behavior and ability to clip polygons using Control

* Fix rectangle selection clipping

* Split polygon into two with selection subtracting

* Move selection with contents with the move tool

Code is still a mess, don't bother looking.

* Move some methods from SelectionShape.gd to Selection.gd

The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.

* UndoRedo for border moving

Nothing else in the selections system works properly in UndoRedo right now. Needs:

- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content

& for all the rest of the remaining features

* Moving all of the selection shape logic to Selection.gd

Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.

* Move tool works again

Buggy and messy, of course.

* Remove unneeded code and restore selection move undoredo logic

* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image

Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.

* UndoRedo support for creating, deleting, merging and clipping selections

UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.

* Confirm & cancel selection movement, should support undoredo properly too

Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.

* Mirror View affects selection

* Restore Cut, Copy, Paste and Clear Selection

Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.

* Created a new Select menu, which has Select All and Clear Selection as options

Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.

* Draw gizmos as rectangles

No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.

* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts

Still no functionality yet.

* Restore label text

* Minor optimization when clipping selections

This will execute the for loop less times

* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click

Now I should actually make them resize when dragged, aye?

* Very basic gizmo resizing, still a WIP, does not work properly yet

* Start replacing the array of selected pixels with a BitMap

This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader

Still commit is still a WIP, image effects and brushes may not work properly yet.

Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.

* Selection works with mirror view

* Draw a black rectangle when the user is making a rectangular selection

After they release the mouse, the black rectangle becomes the selection

* Make Selection.gd update when undoing/redoing

* Fix brushes not working properly with non-rectangular selections

* Added invert selection

* Cache has_selection as a variable for a speedup

* Fix conflict issues with the shape tools

* Made the bitmap image squared so the marching ants effect will be the same on both dimensions

There may be a better way to fix the issue, perhaps inside the shader itself.

* Some optimizations to call selection_bitmap_changed() less times

* Restored almost all of the image effects

Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect

* Fix Selection.gd not updating when changing project

* Resize the selection bitmap along with image resize

* Restored rotation's old behavior and finally got rid of the selected_pixels array

The rotation does not yet work properly with selections, but at least it now "works".

* Resize selection too when using gizmos

Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.

* Image and bitmap resizing now uses the original data and begin transformation on gizmo click

No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.

* Cancel transformation now works properly when the selection has been resized

* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool

* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds

Resizing currently does not work properly with negative (left & up) canvas boundaries

* Flip image when resizing and the bounding rectangle gets flipped

* Call move_content_confirm() when inverting selection

* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)

* Flip selection when resizing to negative bounding rectangle sizes

And fix preview_image vertical flipping

* Fix rotation so that it works (almost) properly with selections

Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter

* Experimental gizmo rotation - does not work properly yet

Transforming the selection outside of the canvas is still broken.

* Fix some issues with moving selection out of canvas bounds

* Fix more issues with selection getting resized outside of canvas bounds

* Update marching ants effect properly when switching between projects

And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes

* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom

* Remove unneeded parameter from move_bitmap_values()

* Remove more unneeded parameters

* Move the selection only if the cursor is above it and neither shift nor control are currently pressed

* Gradient generation now works on non-rectangular selections

Although this behavior might not be the intended one

* Copy/paste marching ants effect offset

Useful for when the selection is in negative coords

* Fix issue with clear selection & UndoRedo

* Restore the ability to move selection when it's in negative coords

* Made the marching ants offset a Project variable

This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.

* Made the "from current selection" palette preset work with the new selection system

* Fix out of bounds error when using the rectangular select tool on negative coords

* Some code cleanup

* Comment out the rotation gizmo for now, since it does not work properly

* Update marching ants shader params and gizmo sizes when the bitmap changes

* Move some methods around in Selection.gd
2021-04-17 11:30:12 -07:00
Manolis Papadeas 810affb1bc Update CHANGELOG & Translations, clear whitespaces 2021-03-15 03:41:02 +02:00
ballerburg9005 de164ea9de
full support for auto tallscreen/widescreen panel layout (#458)
* full support for auto tallscreen/widescreen panel layout

* Update Main.tscn

* Update CanvasPreviewContainer.tscn

* Update UI.tscn

* tallscreen support - better display scale

* tallscreen support - better display scale

* Update UI.tscn

* Update Main.gd

* tallscreen support - better display scale

* tallscreen support - better display scale

* tallscreen support - alternate panel placement comment-784228607

* tallscreen support - code cleanup

* tallscreen support - color picker swap: comment-785032683

* prettier border

* tallscreen support - color picker

* tallscreen support - pullrequestreview-601156079

* tallscreen support - bugfix & review

Co-authored-by: ballerburg9005 <mathias.steiger@gmail.com>
2021-03-06 05:59:26 -08:00
Manolis Papadeas 35f97ebe6f
Fix issue where the window regains focus and draws immediatly
The issue occurred when the cursor exited the application window very fast while still on the canvas, thus Global.has_focus was still true, then lost focus. When Pixelorama regained focus, it would draw the tool even if the user clicked outside of the drawing canvas.
2021-02-25 07:00:50 -08:00
Manolis Papadeas ce7320ad4f Renamed "Base" to "BaseTool" and made it a class 2021-02-02 17:48:17 +02:00
Variable dc469dd4b5
Var transparent mode (#444)
* allowed and enabled per_pixel_transparency

* Added a Transparency menu

* Added an Alternate screen for transparency

* Added transparency methods

Added the transparency methods plus modified fullscreen such that it resets transparency on toggling hence, Removing the issue of blackness

* Modified the shader to allow transparency

* Added a material to ViewportContainer

Fixed the bug that darkens image when decreasing opacity

* Update Global.gd

* Update Main.gd

* Update TopMenuContainer.gd
2021-02-02 07:29:19 -08:00
Manolis Papadeas 8daacbac5e Added "Performance" tab in Preferences that exposes options related to the application's FPS to the user
This also makes the behavior added in #394 toggle-able.
2021-01-05 20:01:50 +02:00
Laurenz Reinthaler 425b11d4b2
Implement undo and redo while holding (#405) 2020-12-22 07:45:17 -08:00
Laurenz Reinthaler 329f4edc5c
Improve Cpu Usage while in Idle (#394)
Use focus insted of mouse
2020-12-15 07:30:47 -08:00
Manolis Papadeas bd10680f63 Minor changes to the shrink option 2020-11-07 19:12:31 +02:00
gschwind 279228daba
Implement shrink option (#376)
* Add shrink option that allow change default shrink

Shrink option allow to scale the godot application. This path enable
dynamic change of this value in the options.

* Fix the computation of cursor location

For an unknown reason the function get_local_mouse_position return
incorrect current_pixel when shrink is not 1. This path compute the
transformation manually and povide correct values for any shrink value.
2020-11-06 17:57:35 -08:00
Manolis Papadeas 7dd9b36cdc Move "Recent projects" up, just below "Open last project" in the File menu 2020-10-29 22:33:15 +02:00
Manolis Papadeas 4415f86c56 Update CHANGELOG & AboutDialog, trim trailing whitespaces 2020-10-27 23:03:43 +02:00
dasimonde 7126074a0e
Add feature request #276 (#370)
* Add request #276

* Remove a warning message

* Some fixes

* Bug fix. Remove Global.save_project_to_recent_list() from src/Main.gd

Co-authored-by: Daniel Simon <dasimon@gmx.org>
2020-10-26 13:51:55 -07:00
Manolis Papadeas 9be6248024 The default path of the dialogs for opening and saving is now the user's desktop folder 2020-10-25 03:26:31 +02:00
Martin Novák 6f645d996d
Refactor export dialog (#288)
* Split export code from export dialog to Export.gd autoload
Clean access to child nodes of export dialog

* Fix export variables set in Main.gd

* Fix more wrong variable assignments

Co-authored-by: alexhayoo <65853178+alexhayoo@users.noreply.github.com>
2020-07-31 23:26:52 +03:00
OverloadedOrama f88d201e1a Organized Preferences better
As a result, "General" no longer exists.
2020-07-29 01:54:15 +03:00
OverloadedOrama d3cb0c2b17 Gave splash screen and camera_zoom() more time to get executed
This should make the splash screen properly centered on HTML5, and the canvas being always fit to frame when the program starts (in all platforms).
2020-07-22 00:11:33 +03:00
OverloadedOrama 8d9e1e8207 Fullscreen can be toggled on and off from the View menu 2020-07-21 22:11:25 +03:00
OverloadedOrama 826b4da177 Organized all Dialog nodes in Main.tscn under a parent "Dialog" node
Just to make the scene tree look cleaner.
2020-07-18 02:27:47 +03:00
OverloadedOrama d31509035f Add a "Use ZSTD Compression" checkbox on Save Sprite dialog 2020-07-11 02:09:17 +03:00
Kinwailo 4a668f71f5
Refactoring tools (#281)
* Refactoring tools

* Remove unused code

* Fixed some inferring errors and added translations

* Attempt to fix some Script Errors found in the CI workflow

* Fix bucket crash.

* Fix static type convert.

Co-authored-by: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com>
2020-07-09 15:22:17 +03:00
OverloadedOrama 637a60d9ee Saving .pxo files in HTML5 is now possible
Addresses #280
2020-06-30 20:25:43 +03:00
OverloadedOrama 9fbfbc7432 Fix wrong "Export" text changing on the File menu 2020-06-25 05:07:07 +03:00
OverloadedOrama c6b977d48e Set the main viewport's cursor to be cross, and set it as a custom cursor image
Instead of setting the main arrow as a custom cursor every time the cursor gets inside the viewport, set the viewport's default cursor to be the cross, and change the cross's image once in Global.gd
2020-06-13 18:09:46 +03:00
OverloadedOrama 2e587e3634 Made TopMenuContainer.gd and moved all the menu code there from Main.gd
Main.gd is now easier to read
2020-06-13 17:59:57 +03:00
OverloadedOrama 2371238ec0 Removed Import option from the file menu
The "Open" option will handle importing of .pxo files and image files from now on. The "ImportSprites" file dialog node and script are scheduled to be deleted too. Importing spritesheets option will return soon. Next thing I'm going to work on is a preview window that will appear when importing image files.
2020-06-12 01:11:58 +03:00
OverloadedOrama 58bab65518 Implemented zen mode
When zen mode is on, most parts of the UI are invisible, except the drawing canvas and  the top menu bar.
2020-06-09 19:15:25 +03:00
OverloadedOrama 5fda35c2d8 Fixed issues with saving and backups 2020-06-06 02:52:17 +03:00
OverloadedOrama 709a401373 Save backups for all opened projects
current_save_paths and backup_save_paths in OpenSave.gd are arrays now, have paths for every project
2020-06-06 02:16:53 +03:00
OverloadedOrama 9ffce37c0b An asterisk is added to the tab name if there are changes
The window title also changes when switching tabs. And yes, "has_changed_changed" is a stupid method name, I'll find another one sometime later.
2020-06-05 20:15:40 +03:00
OverloadedOrama 6d87901056 Imported image files now open in an new tab
Keep in mind that opening an image file as a new frame might not work properly yet, if the target image has a different size.
2020-06-05 19:51:06 +03:00
OverloadedOrama b276999b12 Closing tabs is now possible 2020-06-05 17:50:52 +03:00
OverloadedOrama 60126e46d3 New image now creates a new tab/project 2020-06-05 04:30:50 +03:00
OverloadedOrama f9bd590d20 Moved size variable from Canvas.gd to Project.gd 2020-06-04 23:20:20 +03:00
OverloadedOrama 4e111a7ac0 Created a Projects class
A Project class contains project-specific data like name, undo_redo, frames, layers, tags and brushes. These variables have been moved from Global. This is the first step towards multiple tab support, where each tab will be a different Project.
2020-06-04 21:05:36 +03:00
OverloadedOrama 7371cd79e4 Fixed image effects
Also replaced flip_image_horizontal() and flip_image_vertical() with just flip_image()
2020-06-03 02:53:15 +03:00
OverloadedOrama 54b628f6cb Made a Frame class, no longer use multiple Canvases for multiple frames
The Canvas is now single node, instead of having multiple canvases for each frame. This should also be a performance optimization, since there are less canvas nodes, so there are less _input() calls. It should also fix a rare Undo/Redo issue with motion drawing and making lines. Could be unstable, needs more testing.

As a side effect, the guides are now the same for all frames, so this should also close #246.
2020-06-03 02:14:24 +03:00
Manolis Papadeas d8136a3e17
Merge branch 'master' into refactoring 2020-06-02 19:58:58 +03:00
OverloadedOrama df0032c515 Created a new Cel class, to handle cel information
Like the Layer class, it is used in place of Canvas.layers nested array mess. It hasn't been tested thoroughly yet, so there may be crashes.
2020-06-01 18:50:31 +03:00
OverloadedOrama a9ca858303 Use a new Layer class to handle layer information
This replaces the old Global.layers nested array mess, and makes the code easier to read and to understand.
2020-06-01 16:42:53 +03:00
OverloadedOrama c538140de2 Changed Global node variables to arrays for left/right
Instead of having 2 variables for left & right nodes, use an array instead. This will help with better looking code, automation and less repetitive code, as seen in ToolButtons.gd. Move related refactoring will follow.
2020-05-31 18:03:44 +03:00
OverloadedOrama 4fc2888b68 Removed coord clamping from fill_gaps()
This should make line making behave as expected when the mouse is outside of canvas boundaries
2020-05-31 00:42:35 +03:00
Hugo Locurcio 9a1f5bf5b8
Remove fallback for OS.min_window_size now that Godot 3.2 is out (#249)
The latest Pixelorama versions require Godot 3.2 to run.
2020-05-31 00:20:41 +03:00
OverloadedOrama c84c6a19d7 Renamed handle_running_pixelorama_with_arguments() to handle_loading_files()
handle_loading_files() is also used for _on_files_dropped()
2020-05-30 00:28:17 +03:00
OverloadedOrama ae89d3e291 Connected "files_dropped" signal to a method
This lets the user drag and drop files into Pixelorama, while it runs, to open them. This doesn't work properly and will crash when it can't open the files. It will get merged into master soon.
2020-05-29 20:19:22 +03:00
OverloadedOrama 379b574257 Split code from PreferencesDialog.gd to HandleLanguages.gd
Also moved PreferencesDialog script & scene to src/Preferences. More Preferences code splitting will follow.
2020-05-28 03:41:28 +03:00
Igor Santarek aae3ae0cf4
Refactoring Main.gd. Mostly cutting big methods into smaller ones. (#244)
* Refactoring Main.gd. Mostly cutting big methods into smaller one.

- Reduced size of _ready method in Main.gd
- Moved code from certain parts of old _ready method into seperate methods
- Fixed the translation bug related to CurrentFrame node in TopMenuContainer scene. The CurrentFrame node wasn't updating the language when I was changing language. I've also changed the translation file for this.
- Fixed Global.palette_option_button.selected related warning. Because of some unknown reasons, git didn't push completed line there.
- Moved code from file_menu_id_pressed and view_menu_id_pressed method in Main.gd to separate methods to make it more readable.

* Removed window_title changes from Main.tscn

Co-authored-by: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com>
2020-05-24 00:22:06 +03:00
Igor Santarek 852e249143
Refactoring image_menu_id_pressed method in Main.gd (#243)
* Refactoring image_menu_id_pressed method in Main.gd

I've moved the code from each "match" case into a seperate method to make it more readable.

Co-authored-by: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com>
2020-05-22 15:05:55 +03:00
OverloadedOrama 12c6118763 Created ToolButtons.gd, moved code from Main.gd there 2020-05-21 21:30:40 +03:00