GlyphsApp.UI, GlyphView question

Hey,

I wondering how it was possible to change the color of a layer using GlyphView.
In my code I have this

GlyphView((0, 0, -10, -10), layer=LAYER, backgroundColor=NSColor.clearColor())

Capture d’écran 2022-10-19 à 13.34.25

I know how to draw colored layer in Edit View, but it don’t work in my code:

LAYER = font.selectedLayer[0]

NSColor.whiteColor().set()
LAYER.completeBezierPath.fill()

tab1.group.glyphView = GlyphView((0, 0, -10, -10), layer=LAYER, backgroundColor=NSColor.clearColor())

Default layer color is black and I would like to change it to white.
Btw, there is a doc about GlyphsApp.UI ?

Why do you like it in black? It isn’t possible to change the color at the moment but I can add an option.

You can have a look at the GlyphsView code. It is very short so you might be able to replicate it with the changes you need.

It’s not crucial, but in my case it could help to make my plugin UI a bit more efficient.
I would like to switch to invert current color (black background/white letter)

Can you share me a link to GlyphView code ?

You can set the effective appearance to dark to invert the view. Add the following line before you open the window:

tab1.group.glyphView._nsObject.setAppearance_(NSAppearance.darkAppearance())

(and import NSAppearance)
And you might need to set the background to NSColor.textBackgroundColor() (or any of the dynamic colors that is doing where you need. So maybe NSColor.windowBackgroundColor().

1 Like

It’s work, my letter is white now but I’m using Vanilla Box to create a shape and change it’s background color and when I set this FillColor of this box to black, it’s like the box in above my letter.

tab1.group = Group((60, 30, 80, 120))

tab1.box = Box((10, 2, 170, 170))
tab1.box.setBorderColor(NSColor.colorWithRed_green_blue_alpha_(0, 0, 0, 0.1))
tab1.box.setFillColor(NSColor.colorWithRed_green_blue_alpha_(0, 0, 0, 0.8))
tab1.box.setCornerRadius(6)

tab1.group.glyphView = GlyphView((0, 0, -10, -10), layer=LAYER, backgroundColor=NSColor.clearColor())
tab1.group.glyphView._nsObject.setAppearance_(NSAppearance.darkAppearance())

Here is a screenshot when I set alpha to 0.8 to keep to continue to see the letter.
Capture d’écran 2022-10-20 à 08.37.50

Can you send me a screenshot of the full window (in a private massage if needed)?

You seem to add the box in front of the GlyphView. So, of course you can’t see the letter. Just add the GlyphView to the box, not to the group.

tab1.box.glyphView = GlyphView((0, 0, -10, -10), layer=LAYER, backgroundColor=NSColor.clearColor())

Oh, I thought GlyphView had to be in a group to be displayed.
It would perfectly now, thanks Georg.

Can I ask you a last thing ?
Do you know if it’s possible to change the color of a Vanilla TextBox text ?

Or maybe I can also change my UI like this:

All vanilla controls have an underlying Cocoa/AppKit object (mostly in the ._nsObject property). With them you can do whatever you like. Check the Apple docs for details.
If you add the text to the box, too it might become white automatically as that would happen in a dark mode context.
But I wonder why you like to do all that dark stuff in the first place.

And the GlyphView is a ‘group’ already so you can use it wherever you can add a group.

1 Like

Great to know !
I wanted to use dark to increase contrast UI between left (preview and settings) and right (data) part of this tab.