Skip to content

Commit

Permalink
Improve demo and migrate it to Spec 2.
Browse files Browse the repository at this point in the history
Fixes #3855
  • Loading branch information
jecisc committed Jul 10, 2019
1 parent b83d1b7 commit a70425d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 31 deletions.
38 changes: 7 additions & 31 deletions src/Athens-Examples/AthensDemoMorph.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"
Demos for Athens, just run:
AthensDemoMorph example
AthensDemoPresenter open
You can find an implementation of each figure in
corresponding #figure<#>: method
Expand All @@ -19,29 +19,6 @@ Class {
#category : #'Athens-Examples-Demos'
}

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

| demo model window |
demo := self new openInWorld.
(model := DynamicComposablePresenter new)
instantiatePresenters: #(backButton ButtonPresenter forwardButton ButtonPresenter).
model backButton
label: 'Previous Figure';
action: [ demo prevFigure ].
model forwardButton
label: 'Next Figure';
action: [ demo nextFigure ].
window := model
openWithSpecLayout:
(SpecLayout composed
newColumn: [ :c |
c add: #backButton.
c add: #forwardButton ];
yourself).
window title: 'Athens demos' translated
]

{ #category : #utilities }
AthensDemoMorph class >> roundedRectanglePathOn: aCanvas [

Expand Down Expand Up @@ -383,23 +360,22 @@ AthensDemoMorph >> figures [
]

{ #category : #initialization }
AthensDemoMorph >> initialize [
| ref loadFileFailBlock|
AthensDemoMorph >> initialize [
| ref loadFileFailBlock |
super initialize.
self extent: self defaultExtent.
self color: self backColor.
surface := AthensCairoSurface extent: self extent.
current := 1.
frame := 0.
loadFileFailBlock:= AthensCairoSurface fromForm:(Form fromDisplay: (0@0 extent:(300@150))).
loadFileFailBlock := AthensCairoSurface fromForm: (Form fromDisplay: (0 @ 0 extent: 300 @ 150)).
ref := 'Pharo.png' asFileReference.
pharoLogo := AthensCairoSurface createFromFile: ref fullName ifFailed: [ loadFileFailBlock ].
pharoLogo := AthensCairoSurface createFromFile: ref fullName ifFailed: [ loadFileFailBlock ].

ref := 'esug-balloon.png' asFileReference.
esugBallon := AthensCairoSurface createFromFile: ref fullName ifFailed: [ loadFileFailBlock ].
esugBallon := AthensCairoSurface createFromFile: ref fullName ifFailed: [ loadFileFailBlock ].

self startStepping

]

{ #category : #accessing }
Expand Down
66 changes: 66 additions & 0 deletions src/Athens-Examples/AthensDemoPresenter.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"
I am a simple presenter to display the Athens demo.
I'll open an Athens demo morph and will display two buttons to navigate the different demos.
Examples
-------------
self open
"
Class {
#name : #AthensDemoPresenter,
#superclass : #SpPresenter,
#instVars : [
'backButton',
'forwardButton',
'demo'
],
#category : #'Athens-Examples-Demos'
}

{ #category : #specs }
AthensDemoPresenter class >> defaultSpec [
^ SpBoxLayout newVertical
add: #demo;
add:
(SpBoxLayout newHorizontal
add: #backButton;
add: #forwardButton;
yourself)
withConstraints: [ :constraints | constraints height: self toolbarHeight ];
yourself
]

{ #category : #'instance creation' }
AthensDemoPresenter class >> open [
<script>
self new openWithSpec
]

{ #category : #initialization }
AthensDemoPresenter >> initializeWidgets [
backButton := self newButton.
forwardButton := self newButton.
demo := self newMorph.

demo morph: AthensDemoMorph new.

backButton
label: 'Previous Figure';
action: [ demo morph prevFigure ].
forwardButton
label: 'Next Figure';
action: [ demo morph nextFigure ].

self focusOrder
add: backButton;
add: forwardButton
]

{ #category : #initialization }
AthensDemoPresenter >> initializeWindow: aWindowPresenter [
aWindowPresenter
title: 'Athens demos';
initialExtent: demo morph extent + (0 @ 100)
]

0 comments on commit a70425d

Please sign in to comment.