mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-26 03:18:22 +01:00
Cache current stylesheet object in each node to gain FPS
This commit is contained in:
parent
c249c2e381
commit
007d99804f
@ -24,7 +24,7 @@ DiyaExampleApp >> defineStyleSheet [
|
||||
#borderColor -> Color red
|
||||
};
|
||||
define: #text_view styles: {
|
||||
#color -> Color green.
|
||||
#color -> Color orange.
|
||||
#fontSize -> 16.
|
||||
#bgColor -> Color transparent.
|
||||
#xAlign -> #center
|
||||
@ -103,12 +103,12 @@ DiyaExampleApp >> setup [
|
||||
node textureNamed: 'mrsang.png'.
|
||||
node styleName: #poly_view.
|
||||
|
||||
icon := root addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
|
||||
icon styleName: #text_icon_1 .
|
||||
"icon := root addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
|
||||
icon styleName: #text_icon_1 ."
|
||||
|
||||
button := root addNode: (DiyaButton text: 'Click me !') at: 240@460.
|
||||
button extent: 200@40.
|
||||
button icon:"16rF185"'mrsang.png'.
|
||||
button icon:16rF185"'mrsang.png'".
|
||||
button styleName: #button_view.
|
||||
^ root
|
||||
]
|
||||
|
@ -14,6 +14,7 @@ Class {
|
||||
'ehandlers',
|
||||
'root',
|
||||
'styleName',
|
||||
'style',
|
||||
'id'
|
||||
],
|
||||
#pools : [
|
||||
@ -30,17 +31,18 @@ DiyaNode class >> with: shader [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> ? style [
|
||||
| styles value|
|
||||
styleName ifNotNil: [
|
||||
styles := DiyaUIThemesManager uniqueInstance currentTheme ? (self styleName).
|
||||
value := styles at: style ifAbsent:[nil].
|
||||
DiyaNode >> ? styleAttr [
|
||||
| value|
|
||||
styleName ifNotNil: [
|
||||
style ifNil: [
|
||||
style := DiyaUIThemesManager uniqueInstance currentTheme ? (self styleName).
|
||||
].
|
||||
value := style at: styleAttr ifAbsent:[nil].
|
||||
value ifNotNil: [ ^value ].
|
||||
].
|
||||
"try to look at parent"
|
||||
parent ifNil:[self styleNotFound: style].
|
||||
"parent styleName = self styleName ifTrue: [self styleNotFound: style]."
|
||||
^ parent ? style
|
||||
"try to look at parent style"
|
||||
parent ifNil:[self styleNotFound: styleAttr].
|
||||
^ parent ? styleAttr
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -98,6 +100,7 @@ DiyaNode >> initialize [
|
||||
dirty := false.
|
||||
ehandlers := Dictionary new.
|
||||
styleName := nil.
|
||||
style := nil.
|
||||
root := nil.
|
||||
id := Random new nextInt: 1e6
|
||||
]
|
||||
@ -246,16 +249,13 @@ DiyaNode >> styleName [
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> styleName: anObject [
|
||||
styleName := anObject.
|
||||
style := nil.
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #'event handling' }
|
||||
DiyaNode >> styleNotFound: style [
|
||||
"looking for default theme in global"
|
||||
^(DiyaUIThemesManager uniqueInstance defaultTheme ? (self styleName))
|
||||
at: style ifAbsent:[
|
||||
DiyaCoreAPIError signal: 'Query undefined style ', style, ' in', styleName.
|
||||
]
|
||||
DiyaNode >> styleNotFound: styleAttr [
|
||||
DiyaCoreAPIError signal: 'Query undefined style ', styleAttr, ' in', styleName.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user