Skip to content

Commit

Permalink
Merge pull request #1628 from pharo-spec/p13-actions
Browse files Browse the repository at this point in the history
merge P13 spec actions
  • Loading branch information
estebanlm authored Oct 18, 2024
2 parents fed1607 + c7b7333 commit 4abd4fa
Show file tree
Hide file tree
Showing 158 changed files with 4,305 additions and 1,245 deletions.
1 change: 1 addition & 0 deletions .smalltalk.all.ston
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ SmalltalkCISpec {
'Monticello.*',
'Metacello.*',
'System-Settings-Tests.*',
'System-Dependencies-Tests',
'RPackage.*',
'ReleaseTests.*' ],
#classes : [
Expand Down
1 change: 1 addition & 0 deletions .smalltalk.release.ston
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SmalltalkCISpec {
#testing : {
#packages : [
'System-Settings-Tests.*',
'System-Dependencies-Tests',
'ReleaseTests.*' ]
}
}
3 changes: 2 additions & 1 deletion src/BaselineOfSpec2/BaselineOfSpec2.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BaselineOfSpec2 >> baseline: spec [
spec
"Core"
package: 'Spec2-Adapters-Morphic' with: [ spec requires: #('SpecCore') ];
package: 'Spec2-Adapters-Morphic-ListView' with: [ spec requires: #('SpecCore' 'Spec2-Adapters-Morphic') ];
package: 'Spec2-Code-Morphic' with: [ spec requires: #('Spec2-Adapters-Morphic') ];
package: 'Spec2-Code-Diff-Morphic' with: [ spec requires: #('Spec2-Adapters-Morphic') ];
package: 'Spec2-Morphic' with: [ spec requires: #('Spec2-Adapters-Morphic') ];
Expand All @@ -31,7 +32,7 @@ BaselineOfSpec2 >> baseline: spec [
package: 'Spec2-Microdown' with: [ spec requires: #('SpecCore' 'Spec2-Adapters-Morphic') ];
package: 'Spec2-Transformations' ].

spec group: 'Core' with: #('SpecCore' 'Spec2-Microdown' 'Spec2-Morphic' 'Spec2-Adapters-Morphic').
spec group: 'Core' with: #('SpecCore' 'Spec2-Microdown' 'Spec2-Morphic' 'Spec2-Adapters-Morphic' 'Spec2-Adapters-Morphic-ListView').
spec group: 'Code' with: #('Core' 'SpecCoreCode' 'Spec2-Code-Morphic' 'Spec2-Code-Diff-Morphic').
spec group: 'CodeTests' with: #('Code' 'Spec2-Code-Backend-Tests').
spec group: 'Support' with: #('Core' 'Spec2-Morphic-Examples').
Expand Down
8 changes: 6 additions & 2 deletions src/BaselineOfSpecCore/BaselineOfSpecCore.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ BaselineOfSpecCore >> baseline: spec [
package: 'Spec2-Transmission' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Interactions' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commander2' with: [ spec requires: #('Spec2-Core' 'Spec2-Interactions') ];
"ListView"
package: 'Spec2-ListView' with: [ spec requires: #('Spec2-Core') ];
"Code"
package: 'Spec2-Code' with: [ spec requires: #('Spec2-Core' 'Spec2-Commands') ];
package: 'Spec2-Code-Commands' with: [ spec requires: #('Spec2-Core' 'Spec2-Commands') ];
Expand All @@ -34,6 +36,7 @@ BaselineOfSpecCore >> baseline: spec [
package: 'Spec2-Adapters-Stub' with: [ spec requires: #('Spec2-Core') ];
package: 'Spec2-Commander2-Tests' with: [ spec requires: #('Spec2-Commander2') ];
package: 'Spec2-Tests' with: [ spec requires: #('Spec2-Core' 'Spec2-Examples' 'Spec2-Dialogs-Tests') ];
package: 'Spec2-ListView-Tests' with: [ spec requires: #('Spec2-ListView' 'Spec2-Tests') ];
package: 'Spec2-Code-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code') ];
package: 'Spec2-Code-Diff-Tests' with: [ spec requires: #('Spec2-Tests' 'Spec2-Code-Diff') ];
"Examples"
Expand All @@ -51,13 +54,14 @@ BaselineOfSpecCore >> baseline: spec [
'Spec2-Core'
'Spec2-Dialogs'
'Spec2-CommandLine'
'Spec2-Adapters-Stub'
'Spec2-Adapters-Stub'
'Spec2-ListView'
'Spec2-Interactions'
'Spec2-Commander2' ).
spec group: 'Code' with: #('Core' 'Spec2-Code-Commands' 'Spec2-Code' 'Spec2-Code-Diff').
spec group: 'CodeTests' with: #('Spec2-Code-Tests' 'Spec2-Code-Diff-Tests').
spec group: 'Support' with: #('Core' 'Spec2-Examples').
spec group: 'Tests' with: #('Core' 'Spec2-Tests' 'Spec2-Commander2-Tests').
spec group: 'Tests' with: #('Core' 'Spec2-Tests' 'Spec2-Commander2-Tests' 'Spec2-ListView-Tests').
spec group: 'SupportTests' with: #('Support').
spec group: 'Pillar' with: #('Spec2-Pillar' ).
spec group: 'Base' with: #('Core' 'Support').
Expand Down
35 changes: 20 additions & 15 deletions src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
Class {
#name : #SpAlexandrieMorph,
#superclass : #Morph,
#name : 'SpAlexandrieMorph',
#superclass : 'Morph',
#instVars : [
'surface',
'drawBlock',
'lastExtent'
],
#category : #'Spec2-Adapters-Morphic-Alexandrie-Base'
#category : 'Spec2-Adapters-Morphic-Alexandrie-Base',
#package : 'Spec2-Adapters-Morphic-Alexandrie',
#tag : 'Base'
}

{ #category : #accessing }
{ #category : 'accessing' }
SpAlexandrieMorph >> drawBlock: aBlock [

drawBlock := aBlock
]

{ #category : #drawing }
{ #category : 'drawing' }
SpAlexandrieMorph >> drawOn: aMorphicCanvas [

self redraw.
self surface
displayOnMorphicCanvas: aMorphicCanvas
at: bounds origin
aMorphicCanvas
image: self surface asForm
at: self position
sourceRect: (0@0 extent: self extent)
rule: 34
]

{ #category : #drawing }
{ #category : 'drawing' }
SpAlexandrieMorph >> redraw [
| context |

self surface drawDuring: [ :canvas |
drawBlock
cull: canvas
cull: (0@0 extent: self extent) ]
context := self surface newContext.
drawBlock
cull: context
cull: (0@0 extent: self extent)
]

{ #category : #accessing }
{ #category : 'accessing' }
SpAlexandrieMorph >> surface [

lastExtent = self extent ifFalse: [ surface := nil ].
^ surface ifNil: [
lastExtent := self extent.
surface := AthensCairoSurface extent: self extent ]
surface := AeCairoImageSurface extent: self extent ]
]
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Class {
#name : #SpMorphicAlexandrieAdapter,
#superclass : #SpAbstractMorphicAdapter,
#category : #'Spec2-Adapters-Morphic-Alexandrie-Base'
#name : 'SpMorphicAlexandrieAdapter',
#superclass : 'SpAbstractMorphicAdapter',
#category : 'Spec2-Adapters-Morphic-Alexandrie-Base',
#package : 'Spec2-Adapters-Morphic-Alexandrie',
#tag : 'Base'
}

{ #category : #factory }
{ #category : 'factory' }
SpMorphicAlexandrieAdapter >> buildWidget [

| instance |
instance := SpAthensMorph new.

instance := SpAlexandrieMorph new.
self presenter whenDrawBlockChangedDo: [ :newBlock |
instance drawBlock: newBlock ].
self presenter whenExtentChangedDo: [ :newExtent |
Expand All @@ -21,13 +23,13 @@ SpMorphicAlexandrieAdapter >> buildWidget [
^ instance
]

{ #category : #drawing }
{ #category : 'drawing' }
SpMorphicAlexandrieAdapter >> redraw [

widget redraw
]

{ #category : #accessing }
{ #category : 'accessing' }
SpMorphicAlexandrieAdapter >> surface [

^ widget surface
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Adapters-Morphic-Alexandrie/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Spec2-Adapters-Morphic-Alexandrie' }
Package { #name : 'Spec2-Adapters-Morphic-Alexandrie' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"
A morphic adapter for `SpListViewPresenter`
"
Class {
#name : 'SpMorphicListViewAdapter',
#superclass : 'SpMorphicListAdapter',
#category : 'Spec2-Adapters-Morphic-ListView',
#package : 'Spec2-Adapters-Morphic-ListView'
}

{ #category : 'factory' }
SpMorphicListViewAdapter >> buildWidget [
| datasource |

datasource := self newDataSource.
datasource model: self model.
widget := self newTableWith: datasource.

self presenter whenModelChangedDo: [ widget refresh ].
self presenter whenSelectionChangedDo: [ self refreshWidgetSelection ].
self presenter selection whenChangedDo: [ self refreshWidgetSelection ].

self refreshWidgetSelection.
self configureScrolling.

^ widget
]

{ #category : 'factory' }
SpMorphicListViewAdapter >> newDataSource [

^ SpMorphicListViewDataSource new
]

{ #category : 'factory' }
SpMorphicListViewAdapter >> newTableWith: datasource [

^ SpFTTableMorph new
beRowNotHomogeneous;
disableFunction;
dataSource: datasource;
hideColumnHeaders;
beResizable;
setMultipleSelection: self model isMultipleSelection;
dragEnabled: self dragEnabled;
dropEnabled: self dropEnabled;
setBalloonText: self help;
hResizing: #spaceFill;
vResizing: #spaceFill;
onAnnouncement: FTSelectionChanged send: #selectionChanged: to: self;
onAnnouncement: FTStrongSelectionChanged send: #strongSelectionChanged: to: self;
yourself
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"
A morphic datasource for `SpListViewPresenter`, to be used on the `SpMorphicListViewAdapter`.
"
Class {
#name : 'SpMorphicListViewDataSource',
#superclass : 'SpMorphicListDataSource',
#instVars : [
'rowHeights'
],
#category : 'Spec2-Adapters-Morphic-ListView',
#package : 'Spec2-Adapters-Morphic-ListView'
}

{ #category : 'accessing' }
SpMorphicListViewDataSource >> cellColumn: column row: rowIndex [
| cell contentPresenter contentMorph |

cell := FTCellMorph new.

contentPresenter := self model setupAction value: self model.
self model bindAction
value: contentPresenter
value: (self elementAt: rowIndex).

contentMorph := contentPresenter build.

"register wor height"
rowHeights at: rowIndex put: contentMorph height.

^ cell addMorphBack: contentMorph
]

{ #category : 'initialization' }
SpMorphicListViewDataSource >> initialize [

super initialize.
rowHeights := Dictionary new
]

{ #category : 'accessing' }
SpMorphicListViewDataSource >> rowHeight: index [

^ rowHeights
at: index
ifAbsent: [ super rowHeight: index ]
]
1 change: 1 addition & 0 deletions src/Spec2-Adapters-Morphic-ListView/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'Spec2-Adapters-Morphic-ListView' }
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
Class {
#name : 'SpMorphicScrollableAdapterTest',
#superclass : 'TestCase',
#instVars : [
'scrollable',
'presenter'
],
#category : 'Spec2-Adapters-Morphic-Tests',
#package : 'Spec2-Adapters-Morphic-Tests'
}

{ #category : 'running' }
SpMorphicScrollableAdapterTest >> configureBasicContainer: aNumber [

| boxLayout widgets |
boxLayout := SpBoxLayout newVertical.
widgets := (1 to: aNumber) collect: [ : i |
boxLayout add: (SpButtonPresenter new label: i asString; yourself) ].

presenter := SpPresenter new
layout: (scrollable := SpScrollableLayout new
child:(SpPresenter new
layout: boxLayout;
yourself);
yourself);
yourself.

]

{ #category : 'running' }
SpMorphicScrollableAdapterTest >> tearDown [

presenter delete.
super tearDown.
]

{ #category : 'tests' }
SpMorphicScrollableAdapterTest >> testVScrollToAfterOpen100SubPresenters [

| adapterWidget |

self configureBasicContainer: 100.
presenter open.
scrollable withAdapterDo: [ : a | a widget height: 270 ].

self assert: presenter isDisplayed.
self assert: presenter isVisible.

scrollable scrollTo: 0.1 @ 2.
adapterWidget := scrollable adapter widget.
self assert: adapterWidget vScrollbarValue closeTo: 0.74074074074074.

scrollable scrollTo: 0.5 @ 2.
adapterWidget := scrollable adapter widget.
self assert: adapterWidget vScrollbarValue closeTo: 0.74074074074074
]

{ #category : 'tests' }
SpMorphicScrollableAdapterTest >> testVScrollToAfterOpen500SubPresenters [

| adapterWidget |

self configureBasicContainer: 500.
presenter open.
scrollable withAdapterDo: [ : a | a widget height: 270 ].
scrollable scrollTo: 0.1 @ 2.
adapterWidget := scrollable adapter widget.
self assert: adapterWidget vScrollbarValue closeTo: 0.74074074074074
]

{ #category : 'tests' }
SpMorphicScrollableAdapterTest >> testVScrollToBeforeOpen100SubPresenters [

| adapterWidget |

self configureBasicContainer: 100.
scrollable scrollTo: 0.1 @ 2.
presenter open.
adapterWidget := scrollable adapter widget.
self assert: adapterWidget vScrollbarValue closeTo: 0.0
]
Loading

0 comments on commit 4abd4fa

Please sign in to comment.