toolkit: a system symbol is a stencil, not a photograph - #436
Merged
Conversation
A platform's own symbols come as pictures whose ALPHA is the shape and whose colour means nothing -- what a platform calls a template image. The toolkit could take one only as an Image, which paints the pixels as they are: a black glyph that disappears on a dark card and never picks up the accent colour when its cell is selected. The alternatives were to rasterise the artwork a second time or to blit it beside the widget by hand, and hand-blitting beside a widget is the thing the fleet's UI rule exists to forbid. StencilIcon reads the alpha and takes the colour from the caller, which makes it an IconFunc like every stock DrawIcon***: it drops into an IconCell, a TreeTableNode, or anywhere else that draws one, and follows the theme and the selection for free. The tinted copy is kept until the ink changes, so a grid redrawing every frame tints once rather than once a frame, and the source is neither modified nor retained. The picture keeps its aspect inside its box -- a system symbol is rarely square, and stretching one is what makes it look like somebody else's icon. Tested with a source whose own colours are red and blue on purpose, so anything reading them instead of the ink shows: a 40x10 picture asserted not to come out square in a square box, the source asserted unmodified, a half-transparent ink asserted to thin the stencil, and the picture asserted identical on a back end without the image primitive -- which draws it a pixel at a time, since the primitive is a speed-up and not a requirement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A platform's own symbols arrive as pictures whose alpha is the shape and whose colour means nothing — what a platform calls a template image. The toolkit could take one only as an
Image, which paints the pixels as they are: a black glyph that disappears on a dark card and never picks up the accent colour when its cell is selected. The alternatives were to rasterise the artwork a second time, or to blit it beside the widget by hand — and hand-blitting beside a widget is exactly what a consumer's "no hand-drawn UI" rule forbids.StencilIcon(pix, w, h)reads the alpha and takes the colour from the caller, which makes it anIconFunclike every stockDrawIcon***: it drops into anIconCell, aTreeTableNode, or anywhere else that draws one, and follows the theme and the selection for free.Tests use a source whose own colours are red and blue on purpose, so anything reading them instead of the ink shows up: a 40×10 picture asserted not to come out square in a square box, the source asserted byte-for-byte unmodified, a half-transparent ink asserted to draw a different picture from an opaque one, and the result asserted identical on a back end without the image primitive — which draws it a pixel at a time, since that primitive is a speed-up and not a requirement.
Coverage stays at 100.0%.