Making real Dark Mode edit view


#1

I’m not quite happy with how the Edit View remains white, and want to make a reporter plugin that alters the appearance. I have three questions:

  • What is the best way to fill the edit view with a different colour? I was thinking of drawing a massive rectangle in the back, but it feels clumsy.
  • Related to the above, I am using the SDK template, in which preview() method exists. Its layer only covers the bounds of each bezier path and I cannot fill the whole preview area with my knowledge. How can I get the NSRect of the area?
  • How can I cancel the default drawing of inactive layers and previews so that I can fill the letterforms with white? Currently I can only draw stuff behind of on top what’s already drawn, and feels wasteful.

#2

There is a userDefaults setting to switch the edit view to dark mode:

Glyphs.boolDefaults["GSEditViewDarkMode"] = True

#3

doing dark mode in a reporter plugin is not possible. You would need to reimplement all drawing.


#4

Thanks, I was guessing that might be the case. I could get reasonably close to that though.
But could you answer my questions anyway so that I can learn?


#5
  1. Filling the rect is all you can do.
  2. rect = Font.currentTab.graphicView().bounds()
  3. self.needsExtraMainOutlineDrawingForInactiveLayers = False

#6

The problem with .graphicView().bounds() is that I cannot use it straight away. I can change size using scale of course, but the origin point is based on the location of the currently selected glyph. For example, this doesn’t really fill the view in the way I want:
NSBezierPath.fillRect_(Glyphs.font.currentTab.viewPort)


#7

In some of the reporter methods, the coordinates are set to the active layers origin. Then you need to move your code to a different method backgroundInViewCoords() could work. Or directly drawBackgroundWithOptions_().