2022-03-21 18:03:15 +01:00
|
|
|
Class {
|
|
|
|
#name : #DiyaExampleApp,
|
|
|
|
#superclass : #DiyaBaseApplication,
|
|
|
|
#category : #'Diya-Applications'
|
|
|
|
}
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaExampleApp >> cleanup [
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-08-07 20:43:16 +02:00
|
|
|
{ #category : #accessing }
|
2022-08-15 12:28:09 +02:00
|
|
|
DiyaExampleApp >> defineNodes [
|
|
|
|
|node2 node1 img ell label icon button texture loading|
|
2022-08-10 22:53:14 +02:00
|
|
|
texture := DiyaImageTex new.
|
2022-08-15 12:28:09 +02:00
|
|
|
label := node addNode: (DiyaLabel new) at: 10@40.
|
2022-08-06 03:11:36 +02:00
|
|
|
label extent: 250@24.
|
2022-08-07 20:43:16 +02:00
|
|
|
label styleName:#text_icon_1.
|
2022-03-23 00:52:15 +01:00
|
|
|
label icon: 16rF254.
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
node1 := node addNode: (DiyaRectangle size:100@150 shader: DiyaExampleShader uniqueInstance) at: 300 @ 40.
|
2022-08-10 22:53:14 +02:00
|
|
|
node1 rotation: 45.
|
|
|
|
node1 scale: 2.0@2.0.
|
2022-03-21 18:03:15 +01:00
|
|
|
node1 on: #(mousebuttondown fingerdown) do:[:e|
|
2022-08-14 15:42:59 +02:00
|
|
|
label txt: 'RECT ', (node1 local: e mapped worldPosition) asIntegerPoint asString].
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
img := node addNode: (DiyaImageView from:'mrsang.png') at: 10 @ 400.
|
2022-08-09 03:14:23 +02:00
|
|
|
img styleName: #image_view.
|
|
|
|
img extent:200@200.
|
2022-08-15 12:28:09 +02:00
|
|
|
node on: #(mousebuttondown fingerdown) do:[:e|
|
2022-08-09 03:14:23 +02:00
|
|
|
"change texture"
|
|
|
|
|p|
|
|
|
|
p := e mapped worldPosition.
|
|
|
|
label txt: 'Mouse ', p asIntegerPoint asString.
|
2022-08-14 18:13:23 +02:00
|
|
|
DiyaRenderer assets
|
2022-08-10 22:53:14 +02:00
|
|
|
addAsset:(texture fromDisplay: (Rectangle origin: ((p x - 100) @ (p y - 100)) extent: 200@200 ) as: 'capture').
|
2022-08-09 03:14:23 +02:00
|
|
|
img textureNamed: 'capture'.
|
|
|
|
|
|
|
|
].
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
node2 := node addNode: (DiyaRectangle new) at: 10@80.
|
|
|
|
node2 styleName: #rect_view.
|
|
|
|
node2 extent: 240@320.
|
2022-03-24 22:48:41 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
node2 := node addNode: (DiyaText data: String loremIpsum) at: 10@80.
|
|
|
|
node2 extent: 240@320.
|
|
|
|
node2 wordWrap: true.
|
|
|
|
node2 styleName: #text_view.
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
node2 := node addNode: (DiyaLine from: 10@10 to: 200@200).
|
|
|
|
node2 styleName: #line_view.
|
2022-03-21 22:39:52 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
ell := node addNode: (DiyaEllipse rx:100 ry: 70) at: 120@300.
|
2022-08-12 22:19:54 +02:00
|
|
|
ell scale: 1.2 @ 1.2.
|
2022-08-07 20:43:16 +02:00
|
|
|
ell styleName: #ell_view.
|
2022-08-13 15:55:51 +02:00
|
|
|
"ell rotation: 30."
|
2022-03-21 18:03:15 +01:00
|
|
|
ell textureNamed:'mrsang.png'.
|
2022-08-13 15:55:51 +02:00
|
|
|
ell addNode: (DiyaTimerNode timeout: 1000 / 6 do:[:n |
|
2022-08-12 22:19:54 +02:00
|
|
|
n parent rotation: n parent rotation + 10.
|
2022-08-13 15:55:51 +02:00
|
|
|
] ).
|
2022-03-21 18:03:15 +01:00
|
|
|
ell on: #(mousebuttondown fingerdown) do:[:e|
|
2022-03-23 00:52:15 +01:00
|
|
|
label txt: 'Ellipse clicked', (ell local:e mapped worldPosition) asIntegerPoint asString].
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
node2 := node addNode: (DiyaConvexPolygon points:{0@40. 150@190. 200@20. 100@0}) at: 250@60.
|
|
|
|
node2 textureNamed: 'mrsang.png'.
|
|
|
|
node2 styleName: #poly_view.
|
2022-03-21 18:03:15 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
icon := node addNode: (DiyaFontIcon data: #(16rF101 16rF155 16rF185 16rF21B 16rF298 16rF254)) at: 240@500.
|
2022-08-08 00:12:54 +02:00
|
|
|
icon styleName: #text_icon_2.
|
2022-03-24 22:48:41 +01:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
button := node addNode: (DiyaButton text: 'Click me !') at: 240@460.
|
2022-08-12 22:19:54 +02:00
|
|
|
icon := DiyaFontIcon data: 16rF130.
|
|
|
|
"icon := DiyaImageIcon from: 'mrsang.png'."
|
|
|
|
icon addNode:(DiyaTimerNode timeout: 1000 / 12 do:[:n |
|
|
|
|
n parent rotation: n parent rotation + 10 pivot: n parent extent / 2.
|
|
|
|
] ).
|
2022-03-24 22:48:41 +01:00
|
|
|
button extent: 200@40.
|
2022-08-12 22:19:54 +02:00
|
|
|
button icon: icon "'mrsang.png'".
|
2022-08-08 00:12:54 +02:00
|
|
|
"button rotation: Float pi / 2.0."
|
2022-08-07 20:43:16 +02:00
|
|
|
button styleName: #button_view.
|
2022-08-13 01:37:42 +02:00
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
loading := node addNode: (DiyaLoadingBar new) at: 240@550.
|
2022-08-13 01:37:42 +02:00
|
|
|
loading extent: 200 @ 20.
|
|
|
|
|
|
|
|
loading addNode: (DiyaTimerNode timeout: 2000 do:[:n |
|
|
|
|
|p|
|
|
|
|
p := (n parent percent + 10).
|
|
|
|
p > 100 ifTrue:[ p := 0].
|
|
|
|
n parent percent: p.
|
|
|
|
] ).
|
2022-08-13 15:55:51 +02:00
|
|
|
|
|
|
|
|
2022-08-15 12:28:09 +02:00
|
|
|
loading := node addNode: (DiyaLoadingBar new) at: 240@580.
|
2022-08-13 15:55:51 +02:00
|
|
|
loading extent: 200 @ 20.
|
|
|
|
|
|
|
|
loading addNode: (DiyaTimerNode timeout: 1000 do:[:n |
|
|
|
|
|p|
|
|
|
|
p := (n parent percent + 10).
|
|
|
|
p > 100 ifTrue:[ p := 0].
|
|
|
|
n parent percent: p.
|
|
|
|
] ).
|
2022-08-15 12:28:09 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaExampleApp >> defineStyleSheet [
|
|
|
|
|fmgr style|
|
|
|
|
fmgr := DiyaFontManager uniqueInstance.
|
|
|
|
#(16 18 24) do:[:fontSize|
|
|
|
|
self stdlog: 'Init font size ', fontSize asString, ' of ', fmgr defaultFamily.
|
|
|
|
style := fmgr style: fmgr defaultStyle from: fmgr defaultFamily.
|
|
|
|
(style textureOf: fontSize)" genPrintableASCII" .
|
|
|
|
].
|
|
|
|
DiyaUIThemesManager uniqueInstance currentTheme
|
|
|
|
define: #text_icon_1 styles: {
|
|
|
|
#color -> Color orange.
|
|
|
|
#fontSize -> 24.
|
|
|
|
#bgColor -> Color transparent.
|
|
|
|
};
|
|
|
|
define: #text_icon_2 extend:#text_icon_1 styles: {
|
|
|
|
#fontSize -> 16.
|
|
|
|
};
|
|
|
|
define: #image_view styles: {
|
|
|
|
#color -> Color white.
|
|
|
|
#border -> 1.
|
|
|
|
#bgColor -> Color cyan.
|
|
|
|
#borderColor -> Color red
|
|
|
|
};
|
|
|
|
define: #rect_view extend: #image_view styles: {
|
|
|
|
#bgColor -> Color transparent.
|
|
|
|
};
|
|
|
|
define: #text_view styles: {
|
|
|
|
#color -> Color orange.
|
|
|
|
#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.
|
|
|
|
#border -> 2.
|
|
|
|
};
|
|
|
|
define: #poly_view styles: {
|
|
|
|
#borderColor -> Color red.
|
|
|
|
#color -> Color green.
|
|
|
|
#border -> 1.
|
|
|
|
#bgColor -> Color transparent.
|
|
|
|
};
|
|
|
|
define: #button_view styles: {
|
|
|
|
#borderColor -> (Color r: 0.051 g: 0.051 b: 0.051).
|
|
|
|
#color -> Color white.
|
|
|
|
#bgColor -> (Color r: 0.1529 g: 0.1529 b: 0.1529).
|
|
|
|
#border -> 1.
|
|
|
|
#yAlign -> #middle.
|
|
|
|
#xAlign -> #center
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #initialization }
|
|
|
|
DiyaExampleApp >> initLoader [
|
|
|
|
loader := DiyaDefaultAppLoader new.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
DiyaExampleApp >> onloaded: aBlock [
|
|
|
|
loader job: [ self defineStyleSheet ] name: 'Initializing themes...'.
|
|
|
|
loader job: [
|
|
|
|
self defineNodes.
|
|
|
|
self node forceReload
|
|
|
|
] name: 'Initializing UI elements...'.
|
|
|
|
|
|
|
|
loader onloaded: aBlock
|
2022-03-21 18:03:15 +01:00
|
|
|
]
|