Skip to content

Commit

Permalink
Dependencies clean up: Move example in BlMorphicHost to BlMorphicHost…
Browse files Browse the repository at this point in the history
…Examples
  • Loading branch information
tinchodias committed May 10, 2024
1 parent af7441d commit 0980047
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 33 deletions.
44 changes: 44 additions & 0 deletions src/Bloc-Examples/BlMorphicHostExamples.class.st
@@ -0,0 +1,44 @@
Class {
#name : #BlMorphicHostExamples,
#superclass : #BlExamplesTest,
#instVars : [
'containerMorph'
],
#category : #'Bloc-Examples-Host - Morph'
}

{ #category : #examples }
BlMorphicHostExamples >> squares [
<sampleInstance>
<demo>

| aMorph aHost aSpace |
aMorph := Morph new.
"container morph could also have #spaceFill resizing"
aMorph extent: 400 asPoint.
"Specify a layout policy so the Bloc space fills the whole
extent (including Morph resizing)."
aMorph layoutPolicy: TableLayout new.
aMorph openInWindowLabeled: 'Resize window to layout. Hover squares to color.'.

aHost := BlMorphicHost new.
aHost containerMorph: aMorph.

aSpace := BlSpace new.
aSpace host: aHost.
aSpace show.

aSpace root
background: Color paleBlue;
layout: BlFlowLayout horizontal.

50 timesRepeat: [
aSpace root addChild:
(BlElement new
background: Color random translucent;
addEventHandlerOn: BlMouseEnterEvent
do: [ :evt | evt target background: Color random ];
yourself) ].

^ aSpace
]
33 changes: 0 additions & 33 deletions src/BlocHost-Morphic/BlMorphicHost.class.st
Expand Up @@ -20,39 +20,6 @@ Class {
#category : #'BlocHost-Morphic-Host - Morph'
}

{ #category : #examples }
BlMorphicHost class >> example [

| aMorph aHost aSpace |
aMorph := Morph new.
"container morph could also have #spaceFill resizing"
aMorph extent: 400 asPoint.
"Specify a layout policy so the Bloc space fills the whole
extent (including Morph resizing)."
aMorph layoutPolicy: TableLayout new.
aMorph openInWindowLabeled: 'Resize window to layout. Hover squares to color.'.

aHost := BlMorphicHost new.
aHost containerMorph: aMorph.

aSpace := BlSpace new.
aSpace host: aHost.
aSpace show.

aSpace root
background: Color paleBlue;
layout: BlFlowLayout horizontal.

50 timesRepeat: [
aSpace root addChild:
(BlElement new
background: Color random translucent;
addEventHandlerOn: BlMouseEnterEvent
do: [ :evt |
evt target background: Color random ];
yourself) ]
]

{ #category : #testing }
BlMorphicHost class >> isSupported [
"I can not be used as one of the default Bloc host because I require users to provide containerMorph"
Expand Down

0 comments on commit 0980047

Please sign in to comment.