Skip to content

Commit

Permalink
[bloc] renamed BlElement>>#defaultPath to defaultGeometry. [example] …
Browse files Browse the repository at this point in the history
…added \"sorftware chicken\" example
  • Loading branch information
syrel committed Jan 27, 2017
1 parent 31c63a5 commit 70a0151
Show file tree
Hide file tree
Showing 36 changed files with 208 additions and 138 deletions.
18 changes: 18 additions & 0 deletions src/Bloc-Examples.package/BlChicken.class/class/open.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
examples
open
<example>
| space chicken |

space := BlSpace new.
space extent: 500 @ 500.
space title: 'Software chicken'.

chicken := BlChicken new.
chicken size: 300 @ 350.
space root addChild: chicken.
space root
addEventHandler:
(BlEventHandler
on: BlDblClickEvent
do: [ :evt | BlElementSelection on: evt target ]).
space show
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultLayout
^ BlChickenLayout new
40 changes: 40 additions & 0 deletions src/Bloc-Examples.package/BlChicken.class/instance/initialize.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
initialization
initialize
super initialize.


self addChildren: {
BlChickenHead new
constraintsDo: [ :c |
c frame horizontal alignCenter.
c horizontal exact: 75.
c vertical exact: 75 ];
yourself.
BlChickenBody new
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignCenter.
c horizontal exact: 250.
c vertical exact: 200 ];
yourself.

BlElement new
layout: BlLinearLayout horizontal;
constraintsDo: [ :c |
c frame horizontal alignCenter.
c frame vertical alignBottom.
c horizontal fitContent.
c vertical fitContent ];
addChildren: {
BlChickenLeg new
size: 50@100;
margin: (BlInsets right: 5).
BlChickenLeg new
size: 50@100;
margin: (BlInsets left: 5).
};
yourself



}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"category" : "Bloc-Sparta-Text",
"category" : "Bloc-Examples-Chicken",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "BlElementSelectionExample",
"name" : "BlChicken",
"pools" : [
],
"super" : "Object",
"super" : "BlElement",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
initialization
defaultBackground
^ BlRadialGradientPaint new
stops: {
0 -> Color yellow .
1 -> Color orange };
radius: 200;
center: 100@100
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultBorder
^ BlBorder paint: Color brown lighter width: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultGeometry
^ BlEllipse new
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"category" : "Bloc-Sparta-Text",
"category" : "Bloc-Examples-Chicken",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"area" ],
"name" : "BlSelectionEvent",
],
"name" : "BlChickenBody",
"pools" : [
],
"super" : "BlMouseEvent",
"super" : "BlElement",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultBackground
^ Color yellow
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultBorder
^ BlBorder paint: Color brown width: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
initialization
defaultGeometry
^ BlEllipse new
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
drawing
drawPathOnSpartaCanvas: aCanvas
| anEye |
super drawPathOnSpartaCanvas: aCanvas.

anEye := aCanvas shape circleAt: 0@0 radius: self extent min / 8.0.

aCanvas transform
push;
translateBy: (self width / 4.0) @ (self height / 3.0);
apply.

aCanvas fill
paint: Color white;
path: anEye;
draw;
paint: Color black;
path: (aCanvas shape circleAt: (self extent min / 32.0) @ 0 radius: self extent min / 16.0);
draw.

aCanvas stroke
paint: Color brown;
path: anEye;
width: 1;
draw.

aCanvas transform
translateBy: (self width / 2.0) @ 0;
apply.

aCanvas fill
paint: Color white;
path: anEye;
draw;
paint: Color black;
path: (aCanvas shape circleAt: (self extent min / 32.0) negated @ 0 radius: self extent min / 16.0);
draw.

aCanvas stroke
paint: Color brown;
path: anEye;
width: 1;
draw.

aCanvas transform
translateBy: (self width / 4.0) negated @ (self height / 4.0);
apply.

aCanvas fill
path: (aCanvas path
relative;
moveTo: self width / -16.0 @ 0;
lineTo: self width / 16.0 @ (self height / 2.0);
lineTo: self width / 16.0 @ (self height / -2.0);
lineTo: self width / 16.0 negated @ 0;
close;
finish);
paint: Color red;
draw.

aCanvas transform pop.

Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"category" : "Bloc-Sparta-Text",
"category" : "Bloc-Examples-Chicken",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"origin",
"corner" ],
"name" : "BlSelectionHandler",
],
"name" : "BlChickenHead",
"pools" : [
],
"super" : "BlElementEventListener",
"super" : "BlElement",
"type" : "normal" }
Empty file.
14 changes: 14 additions & 0 deletions src/Bloc-Examples.package/BlChickenLayout.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Bloc-Examples-Chicken",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "BlChickenLayout",
"pools" : [
],
"super" : "BlFrameLayout",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
drawing
drawPathOnSpartaCanvas: aCanvas
| aLegPath |
super drawPathOnSpartaCanvas: aCanvas.

aLegPath := aCanvas path
relative;
moveTo: (self width / 2) asFloat @ 0;
lineTo: 0 @ (self height * 2 / 3) asFloat;
lineTo: self width / 2 * 1.25 negated asFloat @ (self height / 3) asFloat;
moveTo: (self width / 2 * 1.25 negated asFloat @ (self height / 3) asFloat) negated;
lineTo: (self width / 2 * 1.25) asFloat @ (self height / 3) asFloat ;
finish.

aCanvas stroke
path: aLegPath;
paint: Color red;
width: 2;
draw.
14 changes: 14 additions & 0 deletions src/Bloc-Examples.package/BlChickenLeg.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "Bloc-Examples-Chicken",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "BlChickenLeg",
"pools" : [
],
"super" : "BlElement",
"type" : "normal" }
1 change: 1 addition & 0 deletions src/Bloc-Examples.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SystemOrganization addCategory: #'Bloc-Examples'!
SystemOrganization addCategory: 'Bloc-Examples-Animation'!
SystemOrganization addCategory: 'Bloc-Examples-Basic'!
SystemOrganization addCategory: 'Bloc-Examples-Chicken'!
SystemOrganization addCategory: 'Bloc-Examples-Events'!
SystemOrganization addCategory: 'Bloc-Examples-Layout'!
SystemOrganization addCategory: 'Bloc-Examples-MobilePhone'!

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 70a0151

Please sign in to comment.