mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-26 11:28:22 +01:00
Rework on Graphic styling
This commit is contained in:
parent
6d7ab2dcd6
commit
c249c2e381
@ -9,34 +9,9 @@ Class {
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> bgColor [
|
||||
^style get: #bgcolor
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> bgColor: c [
|
||||
^style set: #bgcolor value: c
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> borderColor [
|
||||
^style get: #borderColor
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> borderColor: c [
|
||||
style set: #borderColor value: c.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> borderWidth [
|
||||
^style get: #border
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> borderWidth: w [
|
||||
style set: #border value: w.
|
||||
^ self ? #border
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -44,16 +19,6 @@ Diya2DPrimShape >> boundingBox [
|
||||
^ bbox applyTf: self tf.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> color [
|
||||
^ self style get: #color.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> color: value [
|
||||
^ self style set: #color value: value
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
Diya2DPrimShape >> draw [
|
||||
vbuffer ifNil: [ ^self ].
|
||||
@ -76,7 +41,7 @@ Diya2DPrimShape >> draw [
|
||||
{ #category : #initialization }
|
||||
Diya2DPrimShape >> drawBorder [
|
||||
"Diya2DShader uniqueInstance use."
|
||||
shader setUniform: #u_color value: self borderColor asGL4FArray;
|
||||
shader setUniform: #u_color value: (self ? #borderColor) asGL4FArray;
|
||||
setUniform: #u_texture_type value: 1.
|
||||
OpenGL
|
||||
lineWidth: self borderWidth.
|
||||
@ -108,7 +73,7 @@ Diya2DPrimShape >> initialize [
|
||||
bbox := Rectangle origin: 0@0 corner: 0@0.
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : #accessing }
|
||||
Diya2DPrimShape >> inner: aPoint [
|
||||
bbox ifNil: [ ^false ].
|
||||
^ bbox containsPoint: (self local: aPoint)
|
||||
@ -118,8 +83,8 @@ Diya2DPrimShape >> inner: aPoint [
|
||||
Diya2DPrimShape >> setUpShader [
|
||||
super setUpShader.
|
||||
self shader
|
||||
setUniform: #u_color value: self color asGL4FArray;
|
||||
setUniform: #u_bg_color value: self bgColor asGL4FArray;
|
||||
setUniform: #u_color value: (self ? #color) asGL4FArray;
|
||||
setUniform: #u_bg_color value: (self ? #bgColor) asGL4FArray;
|
||||
setUniform: #u_texture_type value:
|
||||
(self texture ifNil: [ 0 ] ifNotNil:[self texture format]).
|
||||
]
|
||||
|
@ -19,9 +19,7 @@ DiyaApplicationLauncher >> appNode [
|
||||
DiyaApplicationLauncher >> bindGlobalEvent [
|
||||
|pointer |
|
||||
pointer := root addNode: (DiyaCircle r: 10) at: 200@200.
|
||||
pointer color: Color orange.
|
||||
pointer borderColor: Color red.
|
||||
pointer borderWidth: 2.
|
||||
pointer styleName: #pointer.
|
||||
root on: #keydown do:[:e| Transcript show: 'keydown...';cr. running := false.].
|
||||
root on: #quit do: [:e| running := false].
|
||||
root on: #(fingerdown fingermotion mousemotion) do:[:e|
|
||||
@ -80,11 +78,21 @@ DiyaApplicationLauncher >> running [
|
||||
{ #category : #initialization }
|
||||
DiyaApplicationLauncher >> setup [
|
||||
event := SDL_Event new.
|
||||
DiyaUIThemesManager uniqueInstance currentTheme
|
||||
define: #fps_text styles: {
|
||||
#color -> Color red.
|
||||
#fontSize -> 18.
|
||||
#bgColor -> Color transparent.
|
||||
};
|
||||
define: #pointer styles: {
|
||||
#borderColor -> Color red.
|
||||
#bgColor -> Color orange.
|
||||
#border -> 3
|
||||
}.
|
||||
root addNode: (Diya2DNode new) at: 0@0.
|
||||
txtFPS := root addNode:(DiyaText data: '') at: ( self context resolution x - 80)@(self context resolution y - 40).
|
||||
txtFPS extent: 80@40.
|
||||
txtFPS fontSize: 18.
|
||||
txtFPS color: Color red.
|
||||
txtFPS styleName: #fps_text.
|
||||
self bindGlobalEvent.
|
||||
running := true.
|
||||
self launch: self defaultApplication.
|
||||
|
@ -27,10 +27,6 @@ DiyaButton >> iconSize: size [
|
||||
{ #category : #initialization }
|
||||
DiyaButton >> initialize [
|
||||
super initialize.
|
||||
style
|
||||
set:#textAlign value: #center;
|
||||
set:#textVAlign value: #middle;
|
||||
set:#border value: 1.
|
||||
rec := self addNode: (DiyaRectangle new).
|
||||
label := self addNode: (DiyaLabel new).
|
||||
label txt
|
||||
|
@ -1,20 +0,0 @@
|
||||
Class {
|
||||
#name : #DiyaDefaultStyle,
|
||||
#superclass : #DiyaNodeStyle,
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaDefaultStyle >> initialize [
|
||||
super initialize.
|
||||
self set: #bgcolor value:(Color r: 0.2118 g: 0.2118 b: 0.2118).
|
||||
self set: #color value: Color white.
|
||||
self set: #border value: 0.
|
||||
self set: #fontSize value: 18.
|
||||
self set: #fontFamily value: DiyaFontManager uniqueInstance defaultFamily.
|
||||
self set: #fontStyle value: DiyaFontManager uniqueInstance defaultStyle.
|
||||
self set: #borderColor value: (Color r: 0.051 g: 0.051 b: 0.051).
|
||||
self set: #bgcolor2 value: (Color r: 0.1529 g: 0.1529 b: 0.1529).
|
||||
self set: #textAlign value: #left.
|
||||
self set: #textVAlign value: #top
|
||||
]
|
@ -67,7 +67,7 @@ DiyaEllipse >> rx [
|
||||
{ #category : #accessing }
|
||||
DiyaEllipse >> rx: anObject [
|
||||
rx := anObject.
|
||||
dirty := true.
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -78,15 +78,15 @@ DiyaEllipse >> ry [
|
||||
{ #category : #accessing }
|
||||
DiyaEllipse >> ry: anObject [
|
||||
ry := anObject.
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaEllipse >> setUpShader [
|
||||
super setUpShader.
|
||||
self shader
|
||||
setUniform: #u_border value: (style get: #border);
|
||||
setUniform: #u_border_color value: (style get:#borderColor) asGL4FArray;
|
||||
setUniform: #u_border value: (self ? #border);
|
||||
setUniform: #u_border_color value: ( self ? #borderColor) asGL4FArray;
|
||||
setUniform: #u_rx value: rx;
|
||||
setUniform: #u_ry value: ry.
|
||||
]
|
||||
|
@ -9,6 +9,51 @@ DiyaExampleApp >> cleanup [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaExampleApp >> defineStyleSheet [
|
||||
DiyaUIThemesManager uniqueInstance currentTheme
|
||||
define: #text_icon_1 styles: {
|
||||
#color -> Color orange.
|
||||
#fontSize -> 24.
|
||||
#bgColor -> Color transparent.
|
||||
};
|
||||
define: #image_view styles: {
|
||||
#color -> (Color r: 1.0 g:1.0 b:1.0 alpha:1.0 ).
|
||||
#border -> 3.
|
||||
#bgColor -> Color cyan.
|
||||
#borderColor -> Color red
|
||||
};
|
||||
define: #text_view styles: {
|
||||
#color -> Color green.
|
||||
#fontSize -> 16.
|
||||
#bgColor -> Color transparent.
|
||||
#xAlign -> #center
|
||||
};
|
||||
define: #line_view styles: {
|
||||
#color -> Color red.
|
||||
#border -> 4
|
||||
};
|
||||
define: #ell_view styles: {
|
||||
#borderColor -> Color red.
|
||||
#color -> Color white.
|
||||
#bgColor -> Color cyan.
|
||||
#border -> 3.
|
||||
};
|
||||
define: #poly_view styles: {
|
||||
#borderColor -> Color red.
|
||||
#color -> Color green.
|
||||
#border -> 3.
|
||||
};
|
||||
define: #button_view styles: {
|
||||
#borderColor -> Color red.
|
||||
#color -> Color white.
|
||||
#bgColor -> Color magenta.
|
||||
#border -> 1.
|
||||
#yAlign -> #middle.
|
||||
#xAlign -> #center
|
||||
}
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaExampleApp >> main [
|
||||
|
||||
@ -17,10 +62,10 @@ DiyaExampleApp >> main [
|
||||
{ #category : #accessing }
|
||||
DiyaExampleApp >> setup [
|
||||
|node node1 ell label icon button|
|
||||
self defineStyleSheet.
|
||||
label := root addNode: (DiyaLabel new) at: 10@40.
|
||||
label extent: 250@24.
|
||||
label color: Color orange.
|
||||
label iconSize: 24.
|
||||
label styleName:#text_icon_1.
|
||||
label icon: 16rF254.
|
||||
|
||||
|
||||
@ -31,53 +76,39 @@ DiyaExampleApp >> setup [
|
||||
label txt: 'Mouse ', (node1 local: e mapped worldPosition) asIntegerPoint asString].
|
||||
|
||||
node := root addNode: (DiyaImageView from:'mrsang.png') at: 10 @ 400.
|
||||
node color: (Color r: 1.0 g:1.0 b:1.0 alpha:1.0 ).
|
||||
node borderWidth:1.
|
||||
node bgColor: Color cyan.
|
||||
node borderColor: Color red.
|
||||
node borderWidth: 3.0.
|
||||
node styleName: #image_view.
|
||||
node extent:200@200.
|
||||
|
||||
node := root addNode: (DiyaRectangle new) at: 10@80.
|
||||
node borderWidth: 1.
|
||||
node styleName: #image_view.
|
||||
node extent: 240@320.
|
||||
|
||||
node := root addNode: (DiyaText data: String loremIpsum) at: 10@80.
|
||||
node extent: 240@320.
|
||||
node wordWrap: true.
|
||||
node fontSize: 16.
|
||||
node bgColor: Color transparent.
|
||||
node align: #center.
|
||||
node styleName: #text_view.
|
||||
|
||||
node := root addNode: (DiyaLine from: 10@10 to: 200@200).
|
||||
node color: (Color red).
|
||||
node borderWidth: 2.0.
|
||||
node styleName: #line_view.
|
||||
|
||||
ell := root addNode: (DiyaEllipse rx:100 ry: 70) at: 100@300.
|
||||
ell borderColor: Color red.
|
||||
ell color: Color white.
|
||||
ell bgColor: Color cyan.
|
||||
ell rotation: Float pi / 6.0.
|
||||
ell borderWidth: 3.0.
|
||||
ell styleName: #ell_view.
|
||||
"node rotation: Float pi / 2.0."
|
||||
ell textureNamed:'mrsang.png'.
|
||||
ell on: #(mousebuttondown fingerdown) do:[:e|
|
||||
label txt: 'Ellipse clicked', (ell local:e mapped worldPosition) asIntegerPoint asString].
|
||||
|
||||
node := root addNode: (DiyaConvexPolygon points:{250@100. 400@250. 450@80. 350@60}).
|
||||
node color: Color green.
|
||||
node borderColor: Color red.
|
||||
node textureNamed: 'mrsang.png'.
|
||||
node borderWidth: 3.0.
|
||||
node styleName: #poly_view.
|
||||
|
||||
icon := root addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
|
||||
icon fontSize: 24.
|
||||
icon bgColor: Color transparent.
|
||||
icon color: (Color r: 209/255 g: 66/255 b:245/255 ).
|
||||
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 iconSize: 24.
|
||||
button icon:"16rF185"'mrsang.png'.
|
||||
button styleName: #button_view.
|
||||
^ root
|
||||
]
|
||||
|
@ -10,7 +10,6 @@ Class {
|
||||
{ #category : #initialization }
|
||||
DiyaFontIcon >> data: code [
|
||||
super data:(code isArray ifTrue: [ code ] ifFalse:[{code}]).
|
||||
bbox := Rectangle origin: 0@0 corner: ((data size) * (self fontSize) ) @ self fontSize.
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
@ -31,11 +30,9 @@ DiyaFontIcon >> drawText [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaFontIcon >> fontName: name style: face size: size [
|
||||
super fontName: name style:face size: size.
|
||||
data ifNil: [ ^ self ].
|
||||
bbox := Rectangle origin: 0@0 corner: ((data size) * size ) @ size.
|
||||
{ #category : #accessing }
|
||||
DiyaFontIcon >> fontName [
|
||||
^ self ? #textIconFamily
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
@ -48,17 +45,10 @@ DiyaFontIcon >> iconSize [
|
||||
^ self fontSize
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaFontIcon >> iconSize: v [
|
||||
"self extent: "
|
||||
^ self fontSize: v
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaFontIcon >> initialize [
|
||||
super initialize.
|
||||
data := { }.
|
||||
self fontName: 'bootstrap-icons' style: 'Regular' size: 16.
|
||||
vbuffer := FFIExternalArray externalNewType: GLfloat size:24.
|
||||
vbuffer autoRelease.
|
||||
]
|
||||
@ -67,3 +57,10 @@ DiyaFontIcon >> initialize [
|
||||
DiyaFontIcon >> lastSeparatorFrom: i [
|
||||
self shouldNotBeCalled
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaFontIcon >> update [
|
||||
data ifNil: [ ^self ].
|
||||
bbox := Rectangle origin: 0@0 corner: ((data size) * (self fontSize) ) @ self fontSize.
|
||||
^ super update.
|
||||
]
|
||||
|
@ -5,17 +5,24 @@ Class {
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageIcon >> iconSize [
|
||||
^ self extent x
|
||||
DiyaImageIcon >> borderWidth [
|
||||
^0
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageIcon >> iconSize:v [
|
||||
^ self extent: v@v
|
||||
DiyaImageIcon >> iconSize [
|
||||
^ self ? #iconSize
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageIcon >> initialize [
|
||||
super initialize.
|
||||
style set: #border value: 0
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaImageIcon >> update [
|
||||
|v|
|
||||
v := self iconSize.
|
||||
self extent: (v@v).
|
||||
^super update
|
||||
]
|
||||
|
@ -14,14 +14,6 @@ DiyaLabel >> fontSize [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaLabel >> fontSize: value [
|
||||
txt fontSize: value.
|
||||
"icon ifNotNil: [ icon fontSize: value ]."
|
||||
"dirty := true."
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaLabel >> getHAlign: offset [
|
||||
^ 0 max: (txt alignLine: ( txt maxLineWidth)).
|
||||
@ -36,13 +28,12 @@ DiyaLabel >> icon [
|
||||
DiyaLabel >> icon: anObject [
|
||||
icon := nil.
|
||||
anObject isNumber ifTrue: [
|
||||
icon := self addNode: (DiyaFontIcon data: anObject).
|
||||
icon align: #left].
|
||||
icon := self addNode: (DiyaFontIcon data: anObject).].
|
||||
anObject isString ifTrue: [
|
||||
icon := self addNode: (DiyaImageIcon from: anObject).
|
||||
].
|
||||
icon ifNil: [ ^ DiyaCoreAPIError signal: 'Invalid icon identification'].
|
||||
dirty := true.
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -52,13 +43,6 @@ DiyaLabel >> iconSize [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaLabel >> iconSize: v [
|
||||
icon ifNil: [ ^self ].
|
||||
icon iconSize: v
|
||||
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaLabel >> initialize [
|
||||
super initialize.
|
||||
@ -75,7 +59,7 @@ DiyaLabel >> txt [
|
||||
{ #category : #accessing }
|
||||
DiyaLabel >> txt: anObject [
|
||||
txt data: anObject.
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -62,7 +62,7 @@ DiyaLine >> from [
|
||||
{ #category : #accessing }
|
||||
DiyaLine >> from: anObject [
|
||||
from := anObject.
|
||||
dirty := true.
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
@ -74,10 +74,9 @@ DiyaLine >> initialize [
|
||||
vbuffer := FFIExternalArray externalNewType: GLfloat size:8.
|
||||
vbuffer autoRelease.
|
||||
type := GL_LINES.
|
||||
style set: #border value: 0
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
{ #category : #accessing }
|
||||
DiyaLine >> inner: aPoint [
|
||||
^false
|
||||
]
|
||||
@ -90,7 +89,7 @@ DiyaLine >> to [
|
||||
{ #category : #accessing }
|
||||
DiyaLine >> to: anObject [
|
||||
to := anObject.
|
||||
dirty := true.
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -13,7 +13,7 @@ Class {
|
||||
'dirty',
|
||||
'ehandlers',
|
||||
'root',
|
||||
'style',
|
||||
'styleName',
|
||||
'id'
|
||||
],
|
||||
#pools : [
|
||||
@ -29,6 +29,20 @@ DiyaNode class >> with: shader [
|
||||
^self new shader: shader; yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> ? style [
|
||||
| styles value|
|
||||
styleName ifNotNil: [
|
||||
styles := DiyaUIThemesManager uniqueInstance currentTheme ? (self styleName).
|
||||
value := styles at: style 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
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> addNode: node [
|
||||
^self addNode: node at: 0@0
|
||||
@ -41,7 +55,6 @@ DiyaNode >> addNode: node at: pos [
|
||||
node position: pos.
|
||||
children add: node.
|
||||
node root: self root.
|
||||
node style parent: style.
|
||||
^ node
|
||||
]
|
||||
|
||||
@ -84,7 +97,7 @@ DiyaNode >> initialize [
|
||||
children := OrderedCollection new.
|
||||
dirty := false.
|
||||
ehandlers := Dictionary new.
|
||||
style := DiyaNodeStyle new.
|
||||
styleName := nil.
|
||||
root := nil.
|
||||
id := Random new nextInt: 1e6
|
||||
]
|
||||
@ -94,6 +107,11 @@ DiyaNode >> inner: aPoint [
|
||||
^ self subclassResponsibility
|
||||
]
|
||||
|
||||
{ #category : #testing }
|
||||
DiyaNode >> isDirty [
|
||||
^ dirty
|
||||
]
|
||||
|
||||
{ #category : #testing }
|
||||
DiyaNode >> isRoot [
|
||||
^ false
|
||||
@ -221,15 +239,23 @@ DiyaNode >> shader: anObject [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> style [
|
||||
^style
|
||||
DiyaNode >> styleName [
|
||||
^ styleName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNode >> style: aStyle [
|
||||
style := aStyle.
|
||||
dirty := true.
|
||||
parent ifNotNil: [ style parent: parent style ]
|
||||
DiyaNode >> styleName: anObject [
|
||||
styleName := anObject.
|
||||
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.
|
||||
]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -1,45 +0,0 @@
|
||||
Class {
|
||||
#name : #DiyaNodeStyle,
|
||||
#superclass : #DiyaBaseObject,
|
||||
#instVars : [
|
||||
'styles',
|
||||
'parent'
|
||||
],
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
DiyaNodeStyle class >> inherit: parent [
|
||||
^self new parent: parent; yourself
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaNodeStyle >> get: styleName [
|
||||
^ styles at: styleName ifAbsent: [ parent ifNotNil: [ parent get: styleName ] ifNil: nil]
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaNodeStyle >> initialize [
|
||||
super initialize.
|
||||
styles := Dictionary new.
|
||||
parent := nil.
|
||||
"self set: #bgcolor value: Color transparent.
|
||||
self set: #color value:Color white.
|
||||
self set: #border value: 0.
|
||||
self set: #borderColor value: Color transparent."
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNodeStyle >> parent [
|
||||
^ parent
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaNodeStyle >> parent: anObject [
|
||||
parent := anObject
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaNodeStyle >> set: styleName value: value [
|
||||
styles at: styleName put: value
|
||||
]
|
@ -37,7 +37,7 @@ DiyaPolygon >> points [
|
||||
{ #category : #accessing }
|
||||
DiyaPolygon >> points: anObject [
|
||||
points := anObject.
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -23,7 +23,7 @@ DiyaRectangle >> drawLines [
|
||||
{ #category : #accessing }
|
||||
DiyaRectangle >> extent: v [
|
||||
bbox := Rectangle origin:0@0 corner: v.
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
@ -12,7 +12,7 @@ DiyaRootNode >> boundingBox [
|
||||
{ #category : #accessing }
|
||||
DiyaRootNode >> draw [
|
||||
|c|
|
||||
c := style get: #bgcolor.
|
||||
c := self ? #bgColor.
|
||||
OpenGL clearColorR: c red G: c green B: c blue A: c alpha.
|
||||
OpenGL clear: GL_COLOR_BUFFER_BIT.
|
||||
context vbo bind: GL_ARRAY_BUFFER.
|
||||
@ -29,7 +29,7 @@ DiyaRootNode >> initialize [
|
||||
parent := self.
|
||||
shader := nil.
|
||||
root := self.
|
||||
style := DiyaDefaultStyle new
|
||||
styleName := #global
|
||||
]
|
||||
|
||||
{ #category : #'as yet unclassified' }
|
||||
|
33
Diya/DiyaStyleSheet.class.st
Normal file
33
Diya/DiyaStyleSheet.class.st
Normal file
@ -0,0 +1,33 @@
|
||||
Class {
|
||||
#name : #DiyaStyleSheet,
|
||||
#superclass : #DiyaBaseObject,
|
||||
#instVars : [
|
||||
'stylesheet'
|
||||
],
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #convenience }
|
||||
DiyaStyleSheet >> ? sheet [
|
||||
^stylesheet at: sheet ifAbsent:[
|
||||
DiyaCoreAPIError signal: 'Unable to query stylesheet ', sheet
|
||||
].
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaStyleSheet >> define: name styles: styles [
|
||||
stylesheet at: name put: styles asDictionary.
|
||||
^self
|
||||
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaStyleSheet >> initialize [
|
||||
super initialize.
|
||||
stylesheet := Dictionary new.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaStyleSheet >> stylesheet [
|
||||
^ stylesheet
|
||||
]
|
@ -27,13 +27,7 @@ DiyaText class >> data: string shader: s [
|
||||
|
||||
{ #category : #'menu messages' }
|
||||
DiyaText >> align [
|
||||
^ self style get: #textAlign
|
||||
]
|
||||
|
||||
{ #category : #'menu messages' }
|
||||
DiyaText >> align: v [
|
||||
self style set: #textAlign value: v.
|
||||
self formatText
|
||||
^ self ? #xAlign
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -54,6 +48,11 @@ DiyaText >> allocMemory [
|
||||
vbuffer autoRelease.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaText >> borderWidth [
|
||||
^0
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaText >> data [
|
||||
^ data
|
||||
@ -62,7 +61,7 @@ DiyaText >> data [
|
||||
{ #category : #accessing }
|
||||
DiyaText >> data: anObject [
|
||||
data := anObject.
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
@ -84,36 +83,22 @@ DiyaText >> drawText [
|
||||
{ #category : #accessing }
|
||||
DiyaText >> extent: v [
|
||||
bbox := Rectangle origin: 0@0 corner: (v x) @ (v y negated ).
|
||||
dirty := true
|
||||
self setDirty
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaText >> fontName [
|
||||
^ self style get: #fontFamily
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaText >> fontName: name style: face size: size [
|
||||
name ifNotNil: [style set:#fontFamily value: name].
|
||||
face ifNotNil: [style set: #fontStyle value:face].
|
||||
style set: #fontSize value: size.
|
||||
dirty := true.
|
||||
self initTexture
|
||||
^ self ? #fontFamily
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaText >> fontSize [
|
||||
^ self style get:#fontSize
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaText >> fontSize: size [
|
||||
self fontName: nil style:nil size: size
|
||||
^ self ? #fontSize
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaText >> fontStyle [
|
||||
^ self style get: #fontStyle
|
||||
^ self ? #fontStyle
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -187,8 +172,6 @@ DiyaText >> initialize [
|
||||
data := nil.
|
||||
wrap := false.
|
||||
texheight := 0.
|
||||
style set: #border value: 0.
|
||||
"style set: #bgcolor value: Color red."
|
||||
type := GL_QUADS.
|
||||
maxLineWidth := 0.
|
||||
]
|
||||
@ -237,7 +220,7 @@ DiyaText >> texture [
|
||||
texheight = texture height ifFalse: [
|
||||
texheight := texture height.
|
||||
self update.
|
||||
dirty := false.
|
||||
self setClean.
|
||||
].
|
||||
^texture
|
||||
]
|
||||
@ -251,19 +234,12 @@ DiyaText >> update [
|
||||
vbuffer := FFIExternalArray externalNewType: GLfloat size: data size * 16.
|
||||
vbuffer autoRelease.
|
||||
self drawText.
|
||||
dirty := false.
|
||||
^true
|
||||
]
|
||||
|
||||
{ #category : #'menu messages' }
|
||||
DiyaText >> valign [
|
||||
^ self style get: #textVAlign
|
||||
]
|
||||
|
||||
{ #category : #'menu messages' }
|
||||
DiyaText >> valign: v [
|
||||
self style set: #textVAlign value: v.
|
||||
self formatText.
|
||||
^ self ? #yAlign
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
68
Diya/DiyaUIThemesManager.class.st
Normal file
68
Diya/DiyaUIThemesManager.class.st
Normal file
@ -0,0 +1,68 @@
|
||||
Class {
|
||||
#name : #DiyaUIThemesManager,
|
||||
#superclass : #DiyaSingleton,
|
||||
#instVars : [
|
||||
'themes',
|
||||
'currentThemeName'
|
||||
],
|
||||
#category : #'Diya-Graphics'
|
||||
}
|
||||
|
||||
{ #category : #adding }
|
||||
DiyaUIThemesManager >> addTheme:name stylesheet:sheet [
|
||||
themes at:name put: sheet
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaUIThemesManager >> currentTheme [
|
||||
^ themes at: self currentThemeName ifAbsent: [
|
||||
DiyaCoreAPIError signal: 'Undefined theme named', self currentThemeName
|
||||
]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaUIThemesManager >> currentThemeName [
|
||||
^ currentThemeName
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaUIThemesManager >> currentThemeName: anObject [
|
||||
currentThemeName := anObject
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaUIThemesManager >> defaultTheme [
|
||||
^ themes at: #default
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaUIThemesManager >> defineDefaultTheme [
|
||||
self addTheme: #default stylesheet: (DiyaStyleSheet new
|
||||
define: #global styles: {
|
||||
#bgColor -> (Color r: 0.2118 g: 0.2118 b: 0.2118).
|
||||
#color -> Color white.
|
||||
#border -> 0.
|
||||
#fontSize -> 18.
|
||||
#fontFamily -> DiyaFontManager uniqueInstance defaultFamily.
|
||||
#textIconFamily -> 'bootstrap-icons'.
|
||||
#fontStyle -> DiyaFontManager uniqueInstance defaultStyle.
|
||||
#borderColor -> Color transparent.
|
||||
#xAlign -> #left.
|
||||
#yAlign -> #middle.
|
||||
#iconSize -> 24.
|
||||
}
|
||||
)
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
DiyaUIThemesManager >> initialize [
|
||||
super initialize.
|
||||
themes := Dictionary new.
|
||||
self defineDefaultTheme.
|
||||
self currentThemeName: #default.
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaUIThemesManager >> themes [
|
||||
^ themes
|
||||
]
|
@ -12,22 +12,6 @@ DiyaWidget class >> fromStyle: aStyle [
|
||||
^self new style: aStyle; yourself
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaWidget >> bgColor:v [
|
||||
^style set: #bgcolor value: v
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaWidget >> color [
|
||||
^style get: #color
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
DiyaWidget >> color: value [
|
||||
style set: #color value: value
|
||||
]
|
||||
|
||||
{ #category : #geometry }
|
||||
DiyaWidget >> extent [
|
||||
^extent
|
||||
@ -36,7 +20,7 @@ DiyaWidget >> extent [
|
||||
{ #category : #geometry }
|
||||
DiyaWidget >> extent: size [
|
||||
extent := size.
|
||||
dirty := true.
|
||||
self setDirty.
|
||||
]
|
||||
|
||||
{ #category : #initialization }
|
||||
|
Loading…
Reference in New Issue
Block a user