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

Feature Request: Paperjs chrome extension #1446

Open
kareljan opened this issue Feb 25, 2018 · 8 comments
Open

Feature Request: Paperjs chrome extension #1446

kareljan opened this issue Feb 25, 2018 · 8 comments

Comments

@kareljan
Copy link

Description/Steps to reproduce

I was wondering if there is a paperjs extension to visualise all current layers, groups and paths. A bit like the layers panel in Photoshop or any other graphical tool. My google search came up empty. So I don't think it exists yet.
If there is anyone out there with too much time on there hands and also interested in having such an extension. Please make it :-) It would be so helpful. Also when you select a layer, group or path in the list it gets fullyselected.

So just putting it out here.

@sasensi
Copy link
Contributor

sasensi commented Oct 8, 2018

Hi, I think it is a great idea to have a way to visualize project hierarchy and to have basic interaction with it.
It could help a lot in things like: learning, debugging, building drawing apps...

Actually @lehni and @sapics, before I saw this issue, I was already thinking about doing something like that. But I was more thinking about doing it as a plugin rather than as a chrome extension.
That said, it won't be hard to wrap it in a chrome extension if it is done as a plugin.

Here is the use cases I thought about:

  • expand / collapse groups
  • select / unselect item
  • show / hide item
  • remove item
  • change item select color
  • change item name

About keeping layers panel in sync with the project, I have 2 ideas:

  • the simplest one: user could call an update method on the plugin instance (or click an update button in its UI) when he wants
  • the trickiest one: plugin could set up smart change listeners on paper.js methods that could change its state, updating UI accordingly

@sapics
Copy link
Member

sapics commented Oct 9, 2018

@sasensi Interesting feature 👍
When item is changed, project._changes are pushed with item information.
Thus, you can update layer UI automatically by tracking project._changes.

refs:
https://github.com/paperjs/paper.js/blob/develop/src/item/Item.js#L235
https://github.com/paperjs/paper.js/blob/develop/src/item/Project.js#L103

@lehni
Copy link
Member

lehni commented Oct 9, 2018

I've been thinking along these lines for ages also, but never found the time to do anything about it.

There is actually some hidden change-tracking infrastructure in places that's deactivated by default, see here:

// Change tracking, not in use for now. Activate once required:
// this._changes = [];
// this._changesById = {};

as well as here:

// Have project keep track of changed items so they can be iterated.
// This can be used for example to update the SVG tree. Needs to be
// activated in Project
var changes = this._changes;
if (changes && item) {
var changesById = this._changesById,
id = item._id,
entry = changesById[id];
if (entry) {
entry.flags |= flags;
} else {
changes.push(changesById[id] = { item: item, flags: flags });
}
}

I started adding this for a potential SVG backend, which would need to know about what changed on each animation frame. But such a palette could tap into this as well!

@sasensi
Copy link
Contributor

sasensi commented Oct 16, 2018

For those interested in this feature, I made a prototype (implemented as a plugin) here:

It's not made for production applications but I think it can be quite usefull for debugging (I'm already using it 😃).
I was thinking about making it available in http://sketch.paperjs.org, @lehni and @sapics, can you have a look and tell me what you think about that ?

@lehni
Copy link
Member

lehni commented Oct 16, 2018

@sasensi very cool, I already noticed the project! This is very much aligned with a feature that I meant to implement for ages myself. It would be really great to have it as part of sketch!

For this, we should probably make a bit of a plan. What if we agree on one modern UI framework to use to build a more modern sketch? And then use it for this layers view as well? Personally I'm a fan of Vue, and would have proposed that... I'm not so familiar with Angular or React.

@sasensi
Copy link
Contributor

sasensi commented Oct 16, 2018

@lehni, sure, I'm more experienced with Angular but Vue seems to be great as well.
So about re-building sketch, are you thinking about adding other features ?

@sapics
Copy link
Member

sapics commented Oct 16, 2018

@sasensi Great work! I agree with you, I am very happy if we can use your plugin in sketch!

About frameworks, I have little to say, because I have no experience in Angular, React, TS, ES2015+, a bit of Vue...

@sasensi
Copy link
Contributor

sasensi commented Oct 18, 2018

@lehni and @sapics, I made a PR (paperjs/sketch.paperjs.org#5) to integrate the plugin before a full rebuild of sketch.
You can try it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants