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/layer selector #456

Merged
merged 10 commits into from Jun 9, 2017
Merged

Feature/layer selector #456

merged 10 commits into from Jun 9, 2017

Conversation

nvh
Copy link
Collaborator

@nvh nvh commented Dec 15, 2016

This is building upon #336 and #436, changing:

  • The names of some of the methods
  • The implementation of the methods to be more defined in terms of each other

It still has supports these selectors:

Selector Result
A Any layer named A
A B Any layer named B that is a descendant of a layer named A (that is: a child, or a child of a child, etc.)
A > B Any layer named B that is a child (i.e. direct child) of a layer named A
A, B Any layer named A or any layer named B
* Any layer (wildcard character)

And adds a couple of API's:

layer = new Layer

# Selects layer(s) that are decendants of this layer
layer.selectChild("A")
layer.selectAllChildren("A*")

context = new Framer.Context(name: "Test")
# Selects layer(s) in a specific context
context.selectLayer("A")
context.selectAllLayers( "A*")

# Selects layer(s) in the current context
Layer.select("A") 
Layer.selectAll("A*")

@awt2542
Copy link
Contributor

awt2542 commented Dec 15, 2016

Really excited about this. A global shortcut variable would be great as well. I've experimented a bit with ƒ() but it's hard to write on mobile and conflicts with Atom's default key bindings. Still – something like $() would be interesting since it in theory could replace layer names as exposed variables and avoid issues like protected names, illegal characters, multiple layers sharing the same name etc.

@nvh
Copy link
Collaborator Author

nvh commented Dec 16, 2016

A global shortcut variable doesn't feel like it fits the Framer Library to me, but you could easily create it yourself by adding

$ = Layer.selectAll

to your project

@nvh
Copy link
Collaborator Author

nvh commented Dec 16, 2016

Also: beware that only works with explicit layer names, set using the name property of a layer (which is the case for imported layers). In Framer we add some magic to show sensible names to the layer panel so button = new Layer shows up as "button" in the layer panel, although it doesn't have an explicit name.

@nvh nvh merged commit c9450ed into master Jun 9, 2017
@nvh nvh deleted the feature/layer-selector branch June 9, 2017 12:27
@marckrenn
Copy link
Contributor

I think the differentiation between Layer.select and Layer.selectAll may cause more trouble through inconsistency than it actually helps.

For example, if your projects has multiple layers with the exact same name (can easily happen with a generic name like "button"), which layer does Layer.select pick?

Hence I'd propose to rewrite the Layer.select method in a way that it always returns an array of matching layers and get rid of Layer.selectAll completely.

@declanv
Copy link

declanv commented Jan 24, 2018

First off...THANK YOU. This functionality is a phenomenal addition. Might I humbly suggest a :not selector, similar to the CSS or jQuery selectors in functionality?

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.

None yet

5 participants