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

#944 Reorder palette swatches with drag and drop #1283

Merged
merged 9 commits into from
Dec 8, 2019

Conversation

davidlamhauge
Copy link
Contributor

A much needed feature, is the ability to drag and drop palette swatches.
You can select as many swatches as you want. For every drag and drop, the links to possible vector strokes are updated and re-indexed.
Tested on Ubuntu 18.04, Win10 and Mac.
This closes #944

@scribblemaniac scribblemaniac added 🔹 Minor PR (only one reviewer required) Color Palette Enhancement Hacktoberfest In support of Digital Ocean's yearly open source event running from Oct 1st - Oct 31st. labels Oct 3, 2019
Copy link
Member

@MrStevns MrStevns left a comment

Choose a reason for hiding this comment

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

Overall it looks like it works after expectations, technically there are a few things I'd like to see fixed but it's minor stuff.

I noticed however that this only works for list mode, is there a reason why you haven't activated the same behaviour for grid mode?

Good work David 👍

core_lib/src/structure/layervector.cpp Outdated Show resolved Hide resolved
core_lib/src/structure/object.cpp Outdated Show resolved Hide resolved
app/src/colorpalettewidget.cpp Show resolved Hide resolved
davidlamhauge and others added 5 commits October 3, 2019 19:42
Moving close bracket

Co-Authored-By: Oliver Stevns <CandyFace@users.noreply.github.com>
Keeping code guidelines

Co-Authored-By: Oliver Stevns <CandyFace@users.noreply.github.com>
Keeping coding guidelines

Co-Authored-By: Oliver Stevns <CandyFace@users.noreply.github.com>
@davidlamhauge
Copy link
Contributor Author

davidlamhauge commented Oct 3, 2019

I have made the proposed changes - I think.
Does drag and drop work in grid mode? I haven't been able to make it work, If it's a must, then I'll try again when I have better time.
I had a function that disabled drag 'n drop if multiple swatches were selected. I disabled it here
c69ac35 and re-enabled it here 8614e0f because I tested it with multiple selection, and it worked. It doesn't seem to work any more, so maybe I should reinstate this function? (Annoying...)

Comment on lines 282 to 310
editor()->object()->movePaletteColor(startIndex, endIndex);

editor()->object()->addColour(editor()->object()->getColour(startIndex));
editor()->object()->moveVectorColor(startIndex, editor()->object()->getColourCount() - 1);
for (int i = startIndex; i < endIndex; i++)
{
editor()->object()->moveVectorColor(i + 1, i);
}
editor()->object()->moveVectorColor(editor()->object()->getColourCount() - 1, endIndex);
}
else
{
if (start == row) { return; }

startIndex = start;
endIndex = row;

editor()->object()->movePaletteColor(startIndex, endIndex);

editor()->object()->addColour(editor()->object()->getColour(startIndex));
editor()->object()->moveVectorColor(startIndex, editor()->object()->getColourCount() - 1);
for (int i = startIndex; i > endIndex; i--)
{
editor()->object()->moveVectorColor(i - 1, i);
}
editor()->object()->moveVectorColor(editor()->object()->getColourCount() - 1, endIndex);
}

editor()->object()->removeColour(editor()->object()->getColourCount() - 1);
Copy link
Member

Choose a reason for hiding this comment

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

You call editor()->object a lot, consider creating a local Object* variable so that repeated reference lookup is avoided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some odd reason I had to make both Editor and Object local vars.
When I tried
mObject = editor()->object();
it crashed. It works fine now, with the usual setCore method.

@davidlamhauge
Copy link
Contributor Author

More issues/comment to this one?

@MrStevns
Copy link
Member

MrStevns commented Dec 8, 2019

Merging this one, knowing that the functionality doesn't work for grid view.

@MrStevns MrStevns merged commit 526a0e4 into pencil2d:master Dec 8, 2019
@Jose-Moreno Jose-Moreno added this to the 0.6.5 milestone Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Color Palette Enhancement Hacktoberfest In support of Digital Ocean's yearly open source event running from Oct 1st - Oct 31st. 🔹 Minor PR (only one reviewer required)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] Allow to re-order color swatches in either list or grid mode
4 participants