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

Added canvas context menu and duplicate layer command #162

Merged
merged 9 commits into from
Mar 14, 2021
Merged

Conversation

CPKreu
Copy link
Member

@CPKreu CPKreu commented Mar 11, 2021

Added a canvas context menu, containing (De)select all, Copy, Cut, Paste, Bake Pizza and added a duplicate layer command to the layer list

@CPKreu CPKreu added enhancement New feature or request easy Easy difficulty labels Mar 11, 2021
@CPKreu CPKreu requested a review from flabbet March 11, 2021 20:25
Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

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

Insert (1) at the end of the duplicated layer name, add undo support. I don't think you need to write any undo process, you can reuse what already exists

@CPKreu CPKreu requested a review from flabbet March 13, 2021 14:39
@CPKreu CPKreu requested a review from Equbuxu March 13, 2021 17:06
@codecov-io
Copy link

Codecov Report

Merging #162 (92ea451) into master (5894bb5) will increase coverage by 0.15%.
The diff coverage is 70.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
+ Coverage   52.34%   52.49%   +0.15%     
==========================================
  Files         236      237       +1     
  Lines        8953     9030      +77     
  Branches      867      874       +7     
==========================================
+ Hits         4686     4740      +54     
- Misses       4041     4061      +20     
- Partials      226      229       +3     
Impacted Files Coverage Δ
PixiEditor/Views/MainWindow.xaml 0.00% <ø> (ø)
...r/ViewModels/SubViewModels/Main/LayersViewModel.cs 28.35% <33.33%> (-0.22%) ⬇️
...tor/Models/DataHolders/Document/Document.Layers.cs 53.99% <68.51%> (+2.38%) ⬆️
PixiEditor/Helpers/StringExtensions.cs 100.00% <100.00%> (ø)
...ests/ModelsTests/DataHoldersTests/DocumentTests.cs 100.00% <100.00%> (ø)
PixiEditor/Models/DataHolders/Document/Document.cs 76.88% <0.00%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5894bb5...92ea451. Read the comment docs.

Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

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

The code is clean, everything works, I was unable to break it, you've reused the code well and even wrote a test for suffixes, perfect. The only thing I need to ask you is to write a test for the Duplicate layer. Nothing fancy, just if it's added to Layers and is active, you don't need to compare contents or test undo.

Comment on lines 494 to 529
private int? GetHighestSuffix(Layer except, string layerName, Regex regex)
{
int? highestValue = null;

foreach (Layer otherLayer in Layers)
{
if (otherLayer == except)
{
continue;
}

Match otherMatch = regex.Match(otherLayer.Name.Reverse());

if (otherMatch.Groups[2].Value == layerName)
{
bool sucess = int.TryParse(otherMatch.Groups[1].Value.Reverse(), out int number);

if (sucess)
{
if (highestValue == null || highestValue < number)
{
highestValue = number;
}
}
else
{
if (highestValue == null)
{
highestValue = 0;
}
}
}
}

return highestValue;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit too long function, split it a little, please :)

@CPKreu CPKreu requested a review from flabbet March 14, 2021 10:03
Copy link
Member

@flabbet flabbet left a comment

Choose a reason for hiding this comment

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

👌

@flabbet flabbet merged commit c9eaa70 into master Mar 14, 2021
@flabbet flabbet deleted the contextMenus branch March 14, 2021 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy Easy difficulty enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants