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