-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1628 from pharo-spec/p13-actions
merge P13 spec actions
- Loading branch information
Showing
158 changed files
with
4,305 additions
and
1,245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 20 additions & 15 deletions
35
src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Package { #name : #'Spec2-Adapters-Morphic-Alexandrie' } | ||
Package { #name : 'Spec2-Adapters-Morphic-Alexandrie' } |
53 changes: 53 additions & 0 deletions
53
src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewAdapter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] |
46 changes: 46 additions & 0 deletions
46
src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewDataSource.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : 'Spec2-Adapters-Morphic-ListView' } |
75 changes: 0 additions & 75 deletions
75
src/Spec2-Adapters-Morphic-Tests/SpMorphicScrollableAdapterTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] |
Oops, something went wrong.