Skip to content

Commit

Permalink
Merge branch 'master' into 766-Allow-to-add-an-image-in-the-layout-wi…
Browse files Browse the repository at this point in the history
…thout-declaring-an-image-presenter
  • Loading branch information
jecisc committed Sep 11, 2019
2 parents 871f118 + 0d029c0 commit c523dee
Show file tree
Hide file tree
Showing 70 changed files with 1,253 additions and 356 deletions.
2 changes: 1 addition & 1 deletion src/BaselineOfSpec2/BaselineOfSpec2.class.st
Expand Up @@ -91,7 +91,7 @@ BaselineOfSpec2 >> baseline: spec [
BaselineOfSpec2 >> commander2: spec [
spec
baseline: 'Commander2'
with: [ spec repository: 'github://pharo-spec/Commander2:v1.2.0/src' ]
with: [ spec repository: 'github://pharo-spec/Commander2:v2.x.x/src' ]
]

{ #category : #dependencies }
Expand Down
7 changes: 7 additions & 0 deletions src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st
Expand Up @@ -209,6 +209,13 @@ SpAbstractMorphicAdapter >> extent [
^ self widget extent
]

{ #category : #'api-focus' }
SpAbstractMorphicAdapter >> gtInspectorPreviewIn: composite [
<gtInspectorPresentationOrder: 30>

self widgetDo: [ :w | w gtInspectorMorphIn: composite ]
]

{ #category : #protocol }
SpAbstractMorphicAdapter >> hRigid [

Expand Down
114 changes: 114 additions & 0 deletions src/Spec2-Adapters-Morphic/SpComponentListFastTableDataSource.class.st
@@ -0,0 +1,114 @@
Class {
#name : #SpComponentListFastTableDataSource,
#superclass : #FTDataSource,
#instVars : [
'model'
],
#category : #'Spec2-Adapters-Morphic-ComponentList'
}

{ #category : #accessing }
SpComponentListFastTableDataSource >> cellColumn: column row: rowIndex [
| displayValue cell item |
item := self model presenters at: rowIndex.
cell := FTCellMorph new
cellInset: 5;
yourself.
cell addMorphBack: item buildWithSpec.
^ cell
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> elementAt: rowIndex [

^ self listModel at: rowIndex
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> elements [

^ self model items
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> headerColumn: column [
column id ifNil: [ ^ nil ].
^ FTCellMorph new
listCentering: #center;
addMorph: column id asMorph asReadOnlyMorph;
yourself
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> listModel [
^ model model
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> menuColumn: column row: rowIndex [
| menuPresenter |

menuPresenter := self model contextMenu.
menuPresenter ifNil: [ ^ nil ].
^ SpBindings
value: self model application adapterBindings
during: [
| m |
m := menuPresenter value.
m isMorph
ifTrue: [ m ]
ifFalse: [ m buildWithSpec ] ]
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> model [
^ model
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> model: anObject [
model := anObject
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> newDataSourceMatching: aFTFilter [
| newElements wrappedItem text newDataSource modelCopy |

newElements := self elements select: [ :each |
wrappedItem := self model displayValueOf: each.
table columns anySatisfy: [ :column |
text := column transform: wrappedItem.
aFTFilter matches: text]].

newDataSource := self copy.
modelCopy := self model copy.
modelCopy prepareForFilteredDataSourceWith: newElements.
newDataSource model: modelCopy.

^newDataSource
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> numberOfRows [
^ model
ifNil: [ 0 ]
ifNotNil: [ model presenters size ]
]

{ #category : #accessing }
SpComponentListFastTableDataSource >> searchText: aString [
| search text result |
aString isEmptyOrNil ifTrue: [ ^ #() ].
result := OrderedCollection new.
search := aString trimBoth asLowercase.
1 to: self numberOfRows do: [ :rowIndex |
text := (self model displayValueAt: rowIndex) contents trimBoth asLowercase.
(text beginsWith: search)
ifTrue: [ result add: rowIndex ] ].
^ result asArray
]

{ #category : #'drag and drop' }
SpComponentListFastTableDataSource >> transferFor: passenger from: aMorph [
^(self model transferFor: passenger from: self table) buildWithSpec
]
Expand Up @@ -36,7 +36,7 @@ SpMorphicActionBarAdapter >> buildActionButton: aButtonPresenter [
morph := aButtonPresenter buildWithSpec.
aButtonPresenter adapter
styleName: 'actionButton';
applyStyle: aButtonPresenter to: morph.
applyStyle: morph.

^ morph
]
Expand Down
5 changes: 5 additions & 0 deletions src/Spec2-Adapters-Morphic/SpMorphicBackend.class.st
Expand Up @@ -16,6 +16,11 @@ SpMorphicBackend >> adapterBindingsClass [
^ SpMorphicAdapterBindings
]

{ #category : #'as yet unclassified' }
SpMorphicBackend >> defer: aBlockClosure [
UIManager default defer: aBlockClosure.
]

{ #category : #'private notifying' }
SpMorphicBackend >> notifyError: aSpecNotification [
GrowlMorph
Expand Down
38 changes: 38 additions & 0 deletions src/Spec2-Adapters-Morphic/SpMorphicComponentListAdapter.class.st
@@ -0,0 +1,38 @@
Class {
#name : #SpMorphicComponentListAdapter,
#superclass : #SpAbstractMorphicAdapter,
#category : #'Spec2-Adapters-Morphic-ComponentList'
}

{ #category : #factory }
SpMorphicComponentListAdapter >> buildWidget [

| datasource |
datasource := SpComponentListFastTableDataSource new.
datasource model: self model.
widget := FTTableMorph new
dataSource: datasource;
hideColumnHeaders;
hResizing: #spaceFill;
vResizing: #spaceFill;
setBalloonText: self help;
yourself.
self presenter whenPresentersChangedDo: [ widget refresh ].
^ widget
]

{ #category : #accessing }
SpMorphicComponentListAdapter >> children [

^ self rows collect: [ :row | | cell |
cell := row submorphs first.
cell submorphs first ]
]

{ #category : #accessing }
SpMorphicComponentListAdapter >> rows [

| tableContainer |
tableContainer := self widget submorphs first.
^ tableContainer submorphs
]
12 changes: 7 additions & 5 deletions src/Spec2-Adapters-Morphic/SpMorphicGridLayout.class.st
Expand Up @@ -55,20 +55,22 @@ SpMorphicGridLayout >> calculateExtentFor: aMorph constraint: constraint computa
{ #category : #private }
SpMorphicGridLayout >> calculateHeightFor: aMorph base: aNumber [

self isRowHomogeneous ifTrue: [ ^ aNumber ].
"self isRowHomogeneous ifTrue: [ ^ aNumber ].
aMorph vResizing = #spaceFill ifTrue: [ ^ aNumber ].
^ aMorph height
^ aMorph height"
^ aNumber
]

{ #category : #private }
SpMorphicGridLayout >> calculateWidthFor: aMorph base: aNumber [

self isColumnHomogeneous ifTrue: [ ^ aNumber ].
"self isColumnHomogeneous ifTrue: [ ^ aNumber ].
aMorph hResizing = #spaceFill ifTrue: [ ^ aNumber ].
^ aMorph width
^ aMorph width"
^ aNumber
]

{ #category : #'as yet unclassified' }
{ #category : #accessing }
SpMorphicGridLayout >> columnConstraintsAt: aNumber [

^ layout columnConstraintsAt: aNumber
Expand Down
35 changes: 27 additions & 8 deletions src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st
Expand Up @@ -79,7 +79,7 @@ SpMorphicGridLayoutComputation >> calculateHomogeneousColumnWidths [

columnWidth := 0.
morphs do: [ :each |
columnWidth := columnWidth max: (self styleOf: each) width ].
columnWidth := columnWidth max: (self minWidthOf: each) ].

^ Array new: numColumns withAll: (self baseColumnWidth max: columnWidth)
]
Expand All @@ -95,7 +95,7 @@ SpMorphicGridLayoutComputation >> calculateHomogeneousRowHeights [

rowHeight := 0.
morphs do: [ :each |
rowHeight := rowHeight max: (self styleOf: each) height ].
rowHeight := rowHeight max: (self minHeightOf: each) ].

^ Array new: numRows withAll: (self baseRowHeight max: rowHeight)
]
Expand All @@ -113,7 +113,7 @@ SpMorphicGridLayoutComputation >> calculateNotHomogeneousColumnWidths [
"Assign non expandable values"
morphs do: [ :each | | column |
column := (each valueOfProperty: #gridConstraints) column.
(self isColumnExpandable: column) ifTrue: [
(self isColumnExpandable: column) ifFalse: [
newColumnWidths
at: column
put: ((newColumnWidths at: column) max: ((self styleOf: each) width)) ] ].
Expand All @@ -135,12 +135,11 @@ SpMorphicGridLayoutComputation >> calculateNotHomogeneousColumnWidths [
]

{ #category : #'private computation' }
SpMorphicGridLayoutComputation >> calculateRowHeights [
SpMorphicGridLayoutComputation >> calculateNotHomogeneousRowHeights [
"column heights are
- the max height of cells of that row"
| newRowHeights |

layout isRowHomogeneous
ifTrue: [ ^ self calculateHomogeneousRowHeights ].


newRowHeights := Array new: numRows withAll: 0.
morphs do: [ :each | | row |
row := (each valueOfProperty: #gridConstraints) row.
Expand All @@ -151,6 +150,14 @@ SpMorphicGridLayoutComputation >> calculateRowHeights [
^ newRowHeights
]

{ #category : #'private computation' }
SpMorphicGridLayoutComputation >> calculateRowHeights [

^ layout isRowHomogeneous
ifTrue: [ self calculateHomogeneousRowHeights ]
ifFalse: [ self calculateNotHomogeneousRowHeights ]
]

{ #category : #accessing }
SpMorphicGridLayoutComputation >> cellExtentAt: aPoint [

Expand Down Expand Up @@ -290,6 +297,18 @@ SpMorphicGridLayoutComputation >> maxWidthOf: aCollection [
^ (aCollection collect: [ :each | (each valueOfProperty: #style) width ]) max
]

{ #category : #'private computation' }
SpMorphicGridLayoutComputation >> minHeightOf: aMorph [

^ (self styleOf: aMorph) minHeight ifNil: [ 0 ]
]

{ #category : #'private computation' }
SpMorphicGridLayoutComputation >> minWidthOf: aMorph [

^ (self styleOf: aMorph) minWidth ifNil: [ 0 ]
]

{ #category : #private }
SpMorphicGridLayoutComputation >> numColumns [

Expand Down
12 changes: 6 additions & 6 deletions src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st
Expand Up @@ -10,6 +10,11 @@ Class {
#category : #'Spec2-Adapters-Morphic-Base'
}

{ #category : #accessing }
SpMorphicLinkAdapter >> action [
^ self model action
]

{ #category : #factory }
SpMorphicLinkAdapter >> buildWidget [
"Since Pharo does not yet have a real morph for URL, I create my own. Maybe later we will have real links in Morphic?"
Expand Down Expand Up @@ -55,12 +60,7 @@ SpMorphicLinkAdapter >> mouseLeave: anEvent from: aMorph [
{ #category : #'event handling' }
SpMorphicLinkAdapter >> mouseUp: anEvent from: aMorph [
aMorph color: self urlHoverColor.
WebBrowser openOn: self url
]

{ #category : #accessing }
SpMorphicLinkAdapter >> url [
^ self model url
self action value
]

{ #category : #'accessing colors' }
Expand Down
4 changes: 2 additions & 2 deletions src/Spec2-Adapters-Morphic/SpMorphicMorphAdapter.class.st
Expand Up @@ -16,8 +16,8 @@ SpMorphicMorphAdapter >> buildWidget [
self presenter whenMorphChangedDo: [ :morph |
self applyStyle: morph.
currentMorph owner
replaceSubmorph: currentMorph
by: morph ].
ifNotNil: [ :ownerMorph |
ownerMorph replaceSubmorph: currentMorph by: morph ] ].

^ currentMorph
]

0 comments on commit c523dee

Please sign in to comment.