1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2025-04-20 23:46:43 +02:00

Compare commits

..

No commits in common. "c249c2e381f5035aca3dd4ec75e61510496be2c5" and "fcaadbc185e648c5c00a07078a2550a91b771d28" have entirely different histories.

21 changed files with 273 additions and 283 deletions

View File

@ -45,7 +45,7 @@ Diya2DNode >> initialize [
vbuffer := nil.
]
{ #category : #accessing }
{ #category : #'as yet unclassified' }
Diya2DNode >> inner: aPoint [
^ self boundingBox containsPoint: (self local: aPoint)
]
@ -57,7 +57,7 @@ Diya2DNode >> local: aPoint [
]
{ #category : #accessing }
{ #category : #'as yet unclassified' }
Diya2DNode >> recFromBuffer [
|maxX maxY minX minY x y|
maxX := minX := vbuffer at: 1.

View File

@ -9,9 +9,34 @@ 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 [
^ self ? #border
^style get: #border
]
{ #category : #accessing }
Diya2DPrimShape >> borderWidth: w [
style set: #border value: w.
]
{ #category : #accessing }
@ -19,6 +44,16 @@ 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 ].
@ -41,7 +76,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.
@ -73,7 +108,7 @@ Diya2DPrimShape >> initialize [
bbox := Rectangle origin: 0@0 corner: 0@0.
]
{ #category : #accessing }
{ #category : #'as yet unclassified' }
Diya2DPrimShape >> inner: aPoint [
bbox ifNil: [ ^false ].
^ bbox containsPoint: (self local: aPoint)
@ -83,8 +118,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]).
]

View File

@ -19,7 +19,9 @@ DiyaApplicationLauncher >> appNode [
DiyaApplicationLauncher >> bindGlobalEvent [
|pointer |
pointer := root addNode: (DiyaCircle r: 10) at: 200@200.
pointer styleName: #pointer.
pointer color: Color orange.
pointer borderColor: Color red.
pointer borderWidth: 2.
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|
@ -78,21 +80,11 @@ 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 styleName: #fps_text.
txtFPS fontSize: 18.
txtFPS color: Color red.
self bindGlobalEvent.
running := true.
self launch: self defaultApplication.

View File

@ -14,9 +14,9 @@ DiyaButton class >> text: string [
]
{ #category : #accessing }
DiyaButton >> icon: ico [
label icon: ico.
label setDirty.
DiyaButton >> icon: id [
label icon: id.
label updateLayout.
]
{ #category : #accessing }
@ -27,6 +27,10 @@ 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
@ -44,9 +48,8 @@ DiyaButton >> text: string [
]
{ #category : #accessing }
DiyaButton >> update [
DiyaButton >> updateLayout [
rec extent: self extent.
label position: 0@0.
label extent: self extent.
^true
]

View File

@ -0,0 +1,20 @@
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
]

View File

@ -67,7 +67,7 @@ DiyaEllipse >> rx [
{ #category : #accessing }
DiyaEllipse >> rx: anObject [
rx := anObject.
self setDirty
dirty := true.
]
{ #category : #accessing }
@ -78,15 +78,15 @@ DiyaEllipse >> ry [
{ #category : #accessing }
DiyaEllipse >> ry: anObject [
ry := anObject.
self setDirty
dirty := true
]
{ #category : #initialization }
DiyaEllipse >> setUpShader [
super setUpShader.
self shader
setUniform: #u_border value: (self ? #border);
setUniform: #u_border_color value: ( self ? #borderColor) asGL4FArray;
setUniform: #u_border value: (style get: #border);
setUniform: #u_border_color value: (style get:#borderColor) asGL4FArray;
setUniform: #u_rx value: rx;
setUniform: #u_ry value: ry.
]

View File

@ -9,51 +9,6 @@ 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 [
@ -62,10 +17,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 styleName:#text_icon_1.
label color: Color orange.
label iconSize: 24.
label icon: 16rF254.
@ -76,39 +31,53 @@ DiyaExampleApp >> setup [
label txt: 'Mouse ', (node1 local: e mapped worldPosition) asIntegerPoint asString].
node := root addNode: (DiyaImageView from:'mrsang.png') at: 10 @ 400.
node styleName: #image_view.
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 extent:200@200.
node := root addNode: (DiyaRectangle new) at: 10@80.
node styleName: #image_view.
node borderWidth: 1.
node extent: 240@320.
node := root addNode: (DiyaText data: String loremIpsum) at: 10@80.
node extent: 240@320.
node wordWrap: true.
node styleName: #text_view.
node fontSize: 16.
node bgColor: Color transparent.
node align: #center.
node := root addNode: (DiyaLine from: 10@10 to: 200@200).
node styleName: #line_view.
node color: (Color red).
node borderWidth: 2.0.
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 styleName: #ell_view.
ell borderWidth: 3.0.
"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 styleName: #poly_view.
node borderWidth: 3.0.
icon := root addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
icon styleName: #text_icon_1 .
icon fontSize: 24.
icon bgColor: Color transparent.
icon color: (Color r: 209/255 g: 66/255 b:245/255 ).
button := root addNode: (DiyaButton text: 'Click me !') at: 240@460.
button extent: 200@40.
button icon:"16rF185"'mrsang.png'.
button styleName: #button_view.
button icon:16rF185"'mrsang.png'".
button iconSize: 24.
^ root
]

View File

@ -10,6 +10,7 @@ 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 }
@ -30,9 +31,11 @@ DiyaFontIcon >> drawText [
]
{ #category : #accessing }
DiyaFontIcon >> fontName [
^ self ? #textIconFamily
{ #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 : #initialization }
@ -45,10 +48,17 @@ 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.
]
@ -57,10 +67,3 @@ 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.
]

View File

@ -5,24 +5,17 @@ Class {
}
{ #category : #accessing }
DiyaImageIcon >> borderWidth [
^0
DiyaImageIcon >> iconSize [
^ self extent x
]
{ #category : #accessing }
DiyaImageIcon >> iconSize [
^ self ? #iconSize
DiyaImageIcon >> iconSize:v [
^ self extent: v@v
]
{ #category : #accessing }
DiyaImageIcon >> initialize [
super initialize.
]
{ #category : #accessing }
DiyaImageIcon >> update [
|v|
v := self iconSize.
self extent: (v@v).
^super update
style set: #border value: 0
]

View File

@ -14,6 +14,14 @@ 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)).
@ -28,12 +36,13 @@ DiyaLabel >> icon [
DiyaLabel >> icon: anObject [
icon := nil.
anObject isNumber ifTrue: [
icon := self addNode: (DiyaFontIcon data: anObject).].
icon := self addNode: (DiyaFontIcon data: anObject).
icon align: #left].
anObject isString ifTrue: [
icon := self addNode: (DiyaImageIcon from: anObject).
].
icon ifNil: [ ^ DiyaCoreAPIError signal: 'Invalid icon identification'].
self setDirty
dirty := true.
]
{ #category : #accessing }
@ -43,6 +52,13 @@ DiyaLabel >> iconSize [
]
{ #category : #accessing }
DiyaLabel >> iconSize: v [
icon ifNil: [ ^self ].
icon iconSize: v
]
{ #category : #initialization }
DiyaLabel >> initialize [
super initialize.
@ -59,11 +75,11 @@ DiyaLabel >> txt [
{ #category : #accessing }
DiyaLabel >> txt: anObject [
txt data: anObject.
self setDirty
dirty := true
]
{ #category : #accessing }
DiyaLabel >> update [
DiyaLabel >> updateLayout [
|offset isize align|
offset := 0.
icon ifNotNil: [
@ -80,6 +96,5 @@ DiyaLabel >> update [
icon ifNil: [ ^self ].
"{ offset. txt extent. txt maxLineWidth. align } inspect."
icon position: (align @( (self extent y - self iconSize ) >> 1)).
^ true
]

View File

@ -62,7 +62,7 @@ DiyaLine >> from [
{ #category : #accessing }
DiyaLine >> from: anObject [
from := anObject.
self setDirty
dirty := true.
]
{ #category : #initialization }
@ -74,9 +74,10 @@ DiyaLine >> initialize [
vbuffer := FFIExternalArray externalNewType: GLfloat size:8.
vbuffer autoRelease.
type := GL_LINES.
style set: #border value: 0
]
{ #category : #accessing }
{ #category : #'as yet unclassified' }
DiyaLine >> inner: aPoint [
^false
]
@ -89,7 +90,7 @@ DiyaLine >> to [
{ #category : #accessing }
DiyaLine >> to: anObject [
to := anObject.
self setDirty
dirty := true.
]
{ #category : #accessing }

View File

@ -13,7 +13,7 @@ Class {
'dirty',
'ehandlers',
'root',
'styleName',
'style',
'id'
],
#pools : [
@ -29,20 +29,6 @@ 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
@ -55,6 +41,7 @@ DiyaNode >> addNode: node at: pos [
node position: pos.
children add: node.
node root: self root.
node style parent: style.
^ node
]
@ -97,21 +84,16 @@ DiyaNode >> initialize [
children := OrderedCollection new.
dirty := false.
ehandlers := Dictionary new.
styleName := nil.
style := DiyaNodeStyle new.
root := nil.
id := Random new nextInt: 1e6
]
{ #category : #accessing }
{ #category : #'as yet unclassified' }
DiyaNode >> inner: aPoint [
^ self subclassResponsibility
]
{ #category : #testing }
DiyaNode >> isDirty [
^ dirty
]
{ #category : #testing }
DiyaNode >> isRoot [
^ false
@ -158,7 +140,7 @@ DiyaNode >> register: aBlock to: eventName [
DiyaNode >> render [
dirty ifTrue:[
dirty := self update not].
shader ifNotNil: [self setUpShader].
shader ifNotNil: [ self setUpShader ].
self draw.
children ifNil: [ ^self ].
children do: [:c | c render ].
@ -196,16 +178,6 @@ DiyaNode >> scale: anObject [
self updateTF.
]
{ #category : #initialization }
DiyaNode >> setClean [
dirty := false
]
{ #category : #initialization }
DiyaNode >> setDirty [
dirty := true
]
{ #category : #accessing }
DiyaNode >> setUpShader [
|mem|
@ -239,23 +211,15 @@ DiyaNode >> shader: anObject [
]
{ #category : #accessing }
DiyaNode >> styleName [
^ styleName
DiyaNode >> style [
^style
]
{ #category : #accessing }
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.
]
DiyaNode >> style: aStyle [
style := aStyle.
dirty := true.
parent ifNotNil: [ style parent: parent style ]
]
{ #category : #accessing }
@ -263,7 +227,7 @@ DiyaNode >> tf [
^ tf
]
{ #category : #'event handling' }
{ #category : #'as yet unclassified' }
DiyaNode >> trigger: evt [
evt enable ifFalse:[^self].
ehandlers at: evt mapped type ifPresent:[:handler| handler value: evt].

View File

@ -0,0 +1,45 @@
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
]

View File

@ -37,7 +37,7 @@ DiyaPolygon >> points [
{ #category : #accessing }
DiyaPolygon >> points: anObject [
points := anObject.
self setDirty
dirty := true
]
{ #category : #accessing }

View File

@ -23,7 +23,7 @@ DiyaRectangle >> drawLines [
{ #category : #accessing }
DiyaRectangle >> extent: v [
bbox := Rectangle origin:0@0 corner: v.
self setDirty
dirty := true
]
{ #category : #accessing }

View File

@ -12,7 +12,7 @@ DiyaRootNode >> boundingBox [
{ #category : #accessing }
DiyaRootNode >> draw [
|c|
c := self ? #bgColor.
c := style get: #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.
styleName := #global
style := DiyaDefaultStyle new
]
{ #category : #'as yet unclassified' }

View File

@ -1,33 +0,0 @@
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
]

View File

@ -1,5 +1,5 @@
Class {
#name : #DiyaTableLayout,
#superclass : #DiyaLayout,
#superclass : #DiyaWidget,
#category : #'Diya-Widgets'
}

View File

@ -27,7 +27,13 @@ DiyaText class >> data: string shader: s [
{ #category : #'menu messages' }
DiyaText >> align [
^ self ? #xAlign
^ self style get: #textAlign
]
{ #category : #'menu messages' }
DiyaText >> align: v [
self style set: #textAlign value: v.
self formatText
]
{ #category : #accessing }
@ -48,11 +54,6 @@ DiyaText >> allocMemory [
vbuffer autoRelease.
]
{ #category : #accessing }
DiyaText >> borderWidth [
^0
]
{ #category : #accessing }
DiyaText >> data [
^ data
@ -61,7 +62,7 @@ DiyaText >> data [
{ #category : #accessing }
DiyaText >> data: anObject [
data := anObject.
self setDirty
dirty := true
]
{ #category : #initialization }
@ -83,22 +84,36 @@ DiyaText >> drawText [
{ #category : #accessing }
DiyaText >> extent: v [
bbox := Rectangle origin: 0@0 corner: (v x) @ (v y negated ).
self setDirty
dirty := true
]
{ #category : #accessing }
DiyaText >> fontName [
^ self ? #fontFamily
^ 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
]
{ #category : #accessing }
DiyaText >> fontSize [
^ self ? #fontSize
^ self style get:#fontSize
]
{ #category : #initialization }
DiyaText >> fontSize: size [
self fontName: nil style:nil size: size
]
{ #category : #accessing }
DiyaText >> fontStyle [
^ self ? #fontStyle
^ self style get: #fontStyle
]
{ #category : #accessing }
@ -172,6 +187,8 @@ DiyaText >> initialize [
data := nil.
wrap := false.
texheight := 0.
style set: #border value: 0.
"style set: #bgcolor value: Color red."
type := GL_QUADS.
maxLineWidth := 0.
]
@ -220,7 +237,7 @@ DiyaText >> texture [
texheight = texture height ifFalse: [
texheight := texture height.
self update.
self setClean.
dirty := false.
].
^texture
]
@ -234,12 +251,19 @@ DiyaText >> update [
vbuffer := FFIExternalArray externalNewType: GLfloat size: data size * 16.
vbuffer autoRelease.
self drawText.
dirty := false.
^true
]
{ #category : #'menu messages' }
DiyaText >> valign [
^ self ? #yAlign
^ self style get: #textVAlign
]
{ #category : #'menu messages' }
DiyaText >> valign: v [
self style set: #textVAlign value: v.
self formatText.
]
{ #category : #accessing }

View File

@ -1,68 +0,0 @@
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
]

View File

@ -12,6 +12,22 @@ 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
@ -20,10 +36,21 @@ DiyaWidget >> extent [
{ #category : #geometry }
DiyaWidget >> extent: size [
extent := size.
self setDirty.
dirty := true.
]
{ #category : #initialization }
DiyaWidget >> initialize [
super initialize.
]
{ #category : #accessing }
DiyaWidget >> update [
self updateLayout.
^ true
]
{ #category : #accessing }
DiyaWidget >> updateLayout [
self subclassResponsibility
]