diff --git a/Diya/DiyaExampleApp.class.st b/Diya/DiyaExampleApp.class.st index 6405032..3b62247 100644 --- a/Diya/DiyaExampleApp.class.st +++ b/Diya/DiyaExampleApp.class.st @@ -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 ] diff --git a/Diya/DiyaNode.class.st b/Diya/DiyaNode.class.st index ec48362..2f1d3bf 100644 --- a/Diya/DiyaNode.class.st +++ b/Diya/DiyaNode.class.st @@ -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 }