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

Define object selection API. #37

Closed
typesupply opened this issue Jun 16, 2016 · 3 comments
Closed

Define object selection API. #37

typesupply opened this issue Jun 16, 2016 · 3 comments
Assignees

Comments

@typesupply
Copy link
Member

# list of selected objects
subObjects = obj.selection
obj.selection = [subObjects]

# boolean indicating if object is selected
isSelected = obj.selected
obj.selected = True

# will need more elaborate properties
selectedGuides = obj.selectionGuides

Need to look at how RoboFab handled this and build on that without breaking anything.

@jackjennings jackjennings changed the title Define object selection API. Define object selection API Jun 16, 2016
@jackjennings jackjennings changed the title Define object selection API Define object selection API. Jun 16, 2016
@typesupply typesupply self-assigned this Mar 8, 2018
@typesupply
Copy link
Member Author

This needs to be decided so that CurrentContours() CurrentPoints() etc. can be implemented.

Here's how RoboFont 3 handles it.

@typesupply
Copy link
Member Author

typesupply commented Mar 9, 2018

Here’s a proposed API. The only thing that would be required for environments to implement is the object specific selected flag attribute. Everything else can be implemented generically in the base objects.

Any thoughts? cc @benkiel @typemytype

# -------------------------------
# Object Selection Flag (boolean)
# -------------------------------

state = foo.selected
foo.selected = True

The `selected` attribute is supported by:

- font
- layer
- glyph
- contour
- segment
- bPoint
- point
- component
- anchor
- image
- guideline

# ----------------------------------
# Sub-Object Selected Objects (list)
# ----------------------------------

bars = foo.selectedBars
foo.selectedBars = bars

# Font

font.selectedLayers # list of layer objects
font.selectedLayerNames # list of strings
font.selectedGlyphs # list of glyph objects
font.selectedGlyphNames # list of strings
font.selectedGuidelines # list of guideline objects
font.selection # alias for font.selectedGlyphNames, deprecated

# Layer

layer.selectedGlyphs # list of glyph objects
layer.selectedGlyphNames # list of strings

# Glyph

glyph.selectedContours # list of contour objects
glyph.selectedComponents # list of component objects
glyph.selectedAnchors # list of anchor objects
glyph.selectedGuidelines # list of guideline objects

# Contour

contour.selectedSegments # list of segment objects
contour.selectedPoints # list of point objects
contour.selectedBPoints # list of bPoint objects

# Segment

segment.selectedPoints # list of point objects

# ---------------------
# Convenience Functions
# ---------------------

CurrentLayers()
CurrentFontGuidelines()
CurrentContours()
CurrentComponents()
CurrentAnchors()
CurrentGlyphGuidelines()
CurrentSegments()
CurrentPoints()

@benkiel
Copy link
Member

benkiel commented Mar 11, 2018

@typesupply thank you!

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

No branches or pull requests

2 participants