Skip to content
Permalink
Browse files

Improve demo and migrate it to Spec 2.

Fixes #3855
  • Loading branch information
jecisc committed Jul 10, 2019
1 parent b83d1b7 commit a70425d6caa389cd82164db495f5cfe2aebe137b
Showing with 73 additions and 31 deletions.
  1. +7 −31 src/Athens-Examples/AthensDemoMorph.class.st
  2. +66 −0 src/Athens-Examples/AthensDemoPresenter.class.st
@@ -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
@@ -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 [

@@ -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 }
@@ -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.
You can’t perform that action at this time.