||"The more I dig, the deeper I go, the more I realize how little I know" – Mayuresh A Kathe
UserInterfaceTheme design note
Last updated at 6:14 pm UTC on 25 September 2017
Mon, Sep 18, 2017 at 2:09 AM
To: The general-purpose Squeak developers list
One goal of the design was to provide access to a
first-class Theme object, without needing to either write, nor see,
that extra level of indirection in the code.
myMorph userInterfaceTheme color
(myMorph userInterfaceTheme propertyNamed: #color)
The lookup of #color for the example above is then implemented as
Original version ->
"Answer whether I have, or inherit, a value for the visual-attribute specified by aMessage's #selector."
aMessage numArgs > 0 ifTrue: [^ super doesNotUnderstand: aMessage].
scope isEmpty ifTrue: [^ super doesNotUnderstand: aMessage].
^ [self get: scope top class -> aMessage selector]
ensure: [scope pop]
This was changed in update System-mt.963 as a result of some concerns about the details of how the scope variable list might get damaged. When an object requests the applicable them a new UserInterfaceThemeRequest instance is created that knows the actual theme instance and the requesting object. This simplifies the code a little
"Look up the visual-attribute specified by aMessage's #selector in the current theme for the current target object."
^ aMessage numArgs = 0
ifTrue: [self theme get: self target class -> aMessage selector]
ifFalse: [super doesNotUnderstand: aMessage]
and makes it much more understandable