This may be obvious, but I’m having some difficulties working out how to implement a reporter plugin that needs to know the position of a layer in the font.currentTab.layers array.
I’m basically trying to change the colour of a glyph in the edit view if certain conditions are met based on properties of the adjacent layers. Is there a way to get the layer index of a layer processed via inactiveLayers and Foreground etc, or do I need to forget those methods and build my own way of drawing on top of the individual layers?
Any pointers hugely appreciated, as always. Thanks!
Edit: I know that I can process layers iteratively through the currentTab.layers list, but unsure of the best way to get a bezierpath object on that layer in the same manner as the methods described in the SDK.
Thanks, though I think I may not have been very clear in my use of terminology in the original post. although Layer id’s for individual layers in a glyph are unique, what I mean is more if I have text in a tab with the following:
I can get a list of layer objects that are displayed in the tab (the ‘active’ layer for that glyph). I want to look at a glyph irrespective of whether it’s active or inactive, but change the colour of each layer (letter) depending on whether the preceding or succeeding letter meets certain conditions.
The checks are working properly iterating through font.currentTab.layers, and I can change the colours easily enough, but in the above example I can’t find a way to get B1 to look at A and C, and B2 to look at C and D, when both B’s may be the same active layer and have the same layerId.
I just tried to suggest incorporating the inactiveLayers() method, if you don’t know it already. But then I found out, that I still don’t really understand your attempt, this in-/active layers explanation confuses me. Anyway: are you sure, that coloring the glyphs/layers in different colors is really what you want? I would start questioning that, because if you want to show if certain conditions are fullfilled or not, this might me possible in another way than coloring the glyphs?
If I understand correctly, There is a rather complicated solution:
You can overwrite needsExtraMainOutlineDrawingForInactiveLayer_() and return NO. The implement self.backgroundInViewCoords() and draw all none active layers, yourself. But it seems that I need to add stuff to give you all info you need.
It is not easy to find the position for each layer as there is no proper API for it. One other thing you could try is to count the calls to the drawLayer method. They are in order of the layers. So if you have five visible layer and one is active, the drawForegroundForLayer_options_ is called 4 times in the right order. You just need to check that the active layer is and include that in the count.