Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CtrlCV #20

Merged
merged 10 commits into from
Jan 10, 2017
Merged

CtrlCV #20

merged 10 commits into from
Jan 10, 2017

Conversation

caleybrock
Copy link

@caleybrock caleybrock commented Jan 7, 2017

Modify Ctrl+C / Ctrl+V behavior after receiving feedback that people thought copy and paste was broken.

New behaviour:
Select an area.
screen shot 2017-01-09 at 10 50 12 am

Ctrl+C
screen shot 2017-01-09 at 10 50 12 am

Ctrl+V
screen shot 2017-01-09 at 10 50 22 am

Move selection to new position.
screen shot 2017-01-09 at 10 51 00 am

Deselect.
screen shot 2017-01-09 at 10 51 06 am

Some edge cases. When the selected area is on the right or bottom edge, don't offset the paste, just highlight the selection darker. Also note, that Ctrl+V does commit the selection to the canvas before offsetting the overlay, so some of the old behaviour still works.

@caleybrock
Copy link
Author

the SelectionManager tests are failing (expected since I changed behaviour) - fixing now.

@caleybrock
Copy link
Author

unit tests now fixed, but /tests/selection.lasso.json is failing for drawing tests.
looking into how these work and will fix.

@islemaster
Copy link

Looks like selection hits the right-hand edge, but only selection content hits the bottom edge (clarified in person).

// Offset the pasted selection from the original location.
var tool = pskl.app.drawingController.currentToolBehavior;
var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
if (isSelectionTool) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open question: Should this become an early-out? Should we do anything in this method if we don't have a selection tool active?

var isSelectionTool = tool instanceof pskl.tools.drawing.selection.BaseSelect;
if (isSelectionTool) {
var maxHeight = frame.width - 1;
var maxWidth = frame.height - 1;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these backwards?

}

// Save to state when selection is dropped in place.
if (offset === 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in person: Maybe should create a save state for each paste operation after the first one and the deselect operation, instead of only on the deselect operation?

var maxHeight = frame.width - 1;
var maxWidth = frame.height - 1;
var xCoordinate = pixels[pixels.length - 1].col;
var yCoordinate = pixels[pixels.length - 1].row;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using the lasso tool, the 'last' pixel won't necessarily represent the lower-right boundary of your selection.

@caleybrock
Copy link
Author

Updated with what we chatted about. Thanks for the help!

Copy link

@islemaster islemaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Added a few more suggestions, but consider them now-or-later at your discretion.

@@ -91,7 +93,29 @@
}
};

ns.SelectionManager.prototype.paste = function() {
// Iterate through pixels to get the largest x and y values of a selection.
ns.SelectionManager.prototype._getBoundaryEdges = function(pixels) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest some different naming here? You're kind of working out the lower-right corner of your selection's bounding box, and 'edges' may not express that well enough. I'd almost suggest generalizing this function to find and return a bounding box for the set of pixels and name it that, then use bottom and right properties on the returned object. Or maybe just getBottomRightCorner?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this method is effectively static. It'd be nice to write a unit test for it.

// Iterate through pixels to get the largest x and y values of a selection.
ns.SelectionManager.prototype._getBoundaryEdges = function(pixels) {
var xCoordinate = 0;
var yCoordinate = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant in this particular case but it's possible for a selection to (at least temporarily) exist entirely above or to the left of the canvas. It might be more precise here to initialize these to -Infinity.

xCoordinate = pixels[i].col;
}
if (yCoordinate < pixels[i].row) {
yCoordinate = pixels[i].row;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be easier to understand your goal if these were named maxXCoordinate and maxYCoordinate

@caleybrock caleybrock merged commit 511df94 into master Jan 10, 2017
@caleybrock caleybrock deleted the ctrl-c-v branch January 10, 2017 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants