Skip to content

Commit

Permalink
Merge pull request #67 from hpi-swa-teaching/master
Browse files Browse the repository at this point in the history
PowerSqueak Version 0.4
  • Loading branch information
LeonMatthes authored Jun 27, 2018
2 parents 5aac655 + f807eda commit 39c576c
Show file tree
Hide file tree
Showing 56 changed files with 338 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
barFrameFrom: fromNumber height: heightNumber

^ LayoutFrame new
leftFraction: 0 offset: 0;
topFraction: 0 offset: fromNumber;
rightFraction: 1 offset: 0;
bottomFraction: 0 offset: fromNumber + heightNumber
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
toolbuilder
buildWith: builder

| windowSpec slideViewportSpec buttonBarTopSpec window |
| windowSpec slideViewportSpec buttonBarTopSpec menuBarSpec window |
windowSpec := self createWindowSpec: builder.

slideViewportSpec := self createSlideViewportSpec: builder.
Expand All @@ -10,6 +10,9 @@ buildWith: builder
buttonBarTopSpec := self createButtonBarTopSpec: builder.
windowSpec children add: buttonBarTopSpec.

menuBarSpec := self createMenuBarSpec: builder.
windowSpec children add: menuBarSpec.

window := builder build: windowSpec.
self createSlideContainerIn: (builder widgetAt: #SlideViewport).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buttonBarTopData
^ { self addSlideButtonData.
self previousSlideButtonData.
self nextSlideButtonData.
self switchButtonData.
self deleteSlideButtonData.
self selectSlideButtonData.
self textFieldButtonData.
self imageFieldButtonData.
self presentationModeButtonData.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
toolbuilder
buttonHeight

^ Preferences standardButtonFont height * 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
clampSlideNumber: aNumber

^ aNumber
clampLow: self minimumSlideCount
high: self slideCount
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ createButtonBarTopSpec: aBuilder
panelSpec := aBuilder pluggablePanelSpec new.
panelSpec
model: self;
frame: (0@0 corner: 1@0.1);
frame: (self barFrameFrom: self buttonHeight height: self buttonHeight);
name: #ButtonBarTop;
children: OrderedCollection new.

self buttonBarTopData do: [:each |
| button |
button := self createButtonSpec: each with: aBuilder.
panelSpec children add: button].
panelSpec children add: (self createSlideNumberLabelSpec: aBuilder).

^ panelSpec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ createButtonSpec: aDictionary with: aBuilder

| buttonSpec |
buttonSpec := aBuilder pluggableButtonSpec new.
buttonSpec style: #none.
^ buttonSpec
model: (aDictionary at: #model ifAbsent: self);
frame: (aDictionary at: #frame);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
toolbuilder
createMenuBarSpec: aBuilder
| panelSpec |
panelSpec := aBuilder pluggablePanelSpec new.
panelSpec
model: self;
frame: (self barFrameFrom: 0 height: self buttonHeight);
name: #MenuBar;
children: OrderedCollection new.

self menuBarButtonData do: [:each |
| button |
button := self createButtonSpec: each with: aBuilder.
panelSpec children add: button].

^ panelSpec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ createSlide

| newSlide |
newSlide := PSSlide new.
newSlide setModel: self.
self slides add: newSlide afterIndex: self currentSlideNumber.
self selectSlide: self currentSlideNumber + 1.
"self updateSlideNumbers."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
toolbuilder
createSlideNumberLabelSpec: aBuilder

| labelSpec |
labelSpec := aBuilder pluggableInputFieldSpec new.
labelSpec
model: self;
name: #SlideNumberLabel;
frame: (0.2@0.0 corner: 0.3@1.0);
getText: #slideNumberString;
setText: #slideNumberString:.
^ labelSpec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ createSlideViewportSpec: aBuilder
panelSpec := aBuilder pluggablePanelSpec new.
panelSpec
model: self;
frame: (0@0.1 corner: 1@1);
frame: self viewPortLayoutFrame;
name: #SlideViewport;
children: OrderedCollection new.
^ panelSpec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
currentSlideNumberString

^ currentSlideNumber asString
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
deleteSlideButtonData

^ Dictionary withAll: {
#frame -> (0.35@0.0 corner: 0.50@1.0).
#frame -> (0.55@0.0 corner: 0.70@1.0).
#name -> #DeleteSlideButton.
#label -> 'Delete Slide'.
#action -> #deleteSlide}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
duplicateCurrentSlide

self slides
add: self currentSlide copy
afterIndex: self currentSlideNumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
fileButtonData

^ Dictionary withAll: {
#frame -> (0.0@0.0 corner: 0.1@1.0).
#name -> #FileButton.
#label -> 'File'.
#action -> #openFileMenu}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
imageFieldButtonData

^ Dictionary withAll: {
#frame -> (0.3@0.0 corner: 0.35@1.0).
#frame -> (0.5@0.0 corner: 0.55@1.0).
#name -> #imageFieldButton.
#label -> 'I'.
#action -> #newImageField.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
insertButtonData

^ Dictionary withAll: {
#frame -> (0.1@0.0 corner: 0.2@1.0).
#name -> #InsertButton.
#label -> 'Insert'.
#action -> #openInsertMenu}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ loadPresentation
chooseFrom: presentations
values: presentations
title: 'Which presentation do you want me to load?'.
presentationName ifNotNil: [self loadPresentationFromDirectory: self defaultDirectory / presentationName]
presentationName ifNotNil: [self loadPresentationFromDirectory: self defaultDirectory / presentationName].
"self updateSlideNumbers"

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ loadSlideFromDirectory: aDirectory
| slide corruptedMorphs |
corruptedMorphs := 0.
slide := PSSlide new.
slide setModel: self.
aDirectory fileNames do: [:each |
| morph |
morph := self loadMorphFromFile: aDirectory / each.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
loadingButtonData

^ Dictionary withAll: {
#frame -> (0.6@0.0 corner: 0.7@1.0).
#frame -> (0.8@0.0 corner: 0.9@1.0).
#name -> #loadingButton.
#label -> 'Load'.
#action -> #loadPresentation}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
toolbuilder
menuBarButtonData

^ {
self fileButtonData.
self insertButtonData
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
slide management
moveCurrentSlideTo: aNumber

| position |
position := (self clampSlideNumber: aNumber) .
self slides
add: (self slides removeAt: self currentSlideNumber)
afterIndex: position - 1. "position needs to be 0 indexed for add:afterIndex"
"self updateSlideNumbers."
self selectSlide: position
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
nextSlideButtonData

^ Dictionary withAll: {
#frame -> (0.2@0.0 corner: 0.25@1.0).
#frame -> (0.3@0.0 corner: 0.35@1.0).
#name -> #NextSlideButton.
#label -> '>'.
#action -> #nextSlide}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu bar
openFileMenu

| menu |
menu := MenuMorph new.
menu defaultTarget: self.
menu add: 'Save' action: #savePresentation.
menu add: 'Load' action: #loadPresentation.
menu popUpInWorld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu bar
openInsertMenu

| menu |
menu := MenuMorph new.
menu defaultTarget: self.
menu add: 'Text field' action: #newTextField.
menu add: 'Image' action: #newImageField.
menu popUpInWorld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
slide management
openSlideMoveDialog

| userInput |
userInput := UIManager default request: 'Where should I move the current slide???'.
[self moveCurrentSlideTo: userInput asNumber]
on: Error
do: [UIManager inform: 'Not a valid number']
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
presentationModeButtonData

^ Dictionary withAll: {
#frame -> (0.7@0.0 corner: 0.8@1.0).
#frame -> (0.9@0.0 corner: 1.0@1.0).
#name -> #PresentationModeButton.
#label -> 'Present'.
#action -> #enablePresentationMode}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
notifications
riskyOperationMessage

^ 'This operation is risky as it might crash your image.', Character cr, 'Do you want me to proceed?'
^ 'Warning!', Character cr, 'This operation is risky as it might crash your image.', Character cr, 'Do you want me to proceed?'
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
saveButtonData

^ Dictionary withAll: {
#frame -> (0.5@0.0 corner: 0.6@1.0).
#frame -> (0.7@0.0 corner: 0.8@1.0).
#name -> #savingButton.
#label -> 'Save'.
#action -> #savingConfirmation}
#action -> #savePresentation}
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
presentation saving
savePresentation

| directory |
directory := self defaultDirectory.

directory := self getValidPresentationName: directory.
directory ifNil: [^ self].
directory := self createDirectory: 'slides' in: directory.

self slides doWithIndex: [:each :index |
| directoryName |
directoryName := 'slide', index asString.
directory createDirectory: directoryName.
each saveInDirectory: directory / directoryName ]
self warn: self riskyOperationMessage trueChoice: [self savePresentationConfirmed]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
presentation saving
savePresentationConfirmed

| directory |
directory := self defaultDirectory.

directory := self getValidPresentationName: directory.
directory ifNil: [^ self].
directory := self createDirectory: 'slides' in: directory.

self slides doWithIndex: [:each :index |
| directoryName |
directoryName := 'slide', index asString.
directory createDirectory: directoryName.
each saveInDirectory: directory / directoryName ]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
slide management
selectSlide: aNumber

self currentSlideNumber:
(aNumber
clampLow: self minimumSlideCount
high: self slideCount).
self slideContainer showSlide: self currentSlide
self currentSlideNumber: (self clampSlideNumber: aNumber).
self slideContainer showSlide: self currentSlide.
self changed: #slideNumberString
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
selectSlideButtonData

^ Dictionary withAll: {
#frame -> (0.8@0.0 corner: 1.0@1.0).
#frame -> (0.8@0.0 corner: 0.9@1.0).
#name -> #AddSlideButton.
#label -> 'Select Slide'.
#action -> #openSlideSelectionDialog}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
accessing
slideNumberString: aText

| number prefix |
prefix := (aText asString subStrings: '/') at: 1 ifAbsent:[''].
number := prefix asInteger.
number ifNotNil: [self selectSlide: number].
self changed: #slideNumberString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
slideNumberString

^ self currentSlideNumber asString, '/' , self slideCount asString
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
toolbuilder
switchButtonData

^ Dictionary withAll: {
#frame -> (0.35@0.0 corner: 0.45@1.0).
#name -> #moveButton.
#label -> 'Move'.
#action -> #openSlideMoveDialog}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ toolbuilder
textFieldButtonData

^ Dictionary withAll: {
#frame -> (0.25@0.0 corner: 0.3@1.0).
#frame -> (0.45@0.0 corner: 0.5@1.0).
#name -> #textFieldButton.
#label -> 'T'.
#action -> #newTextField.
Expand Down
Loading

0 comments on commit 39c576c

Please sign in to comment.