diff --git a/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st index b8f1f4e2..5437ba10 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st @@ -101,6 +101,12 @@ SpMorphicTextInputFieldAdapter >> getPlaceholderText [ aString localizedForPresenter: self presenter ] ] +{ #category : 'testing' } +SpMorphicTextInputFieldAdapter >> hasKeyboardFocus [ + + ^ widget hasKeyboardFocus +] + { #category : 'testing' } SpMorphicTextInputFieldAdapter >> isPassword [ diff --git a/src/Spec2-Backend-Tests/SpGridLayoutAdapterTest.class.st b/src/Spec2-Backend-Tests/SpGridLayoutAdapterTest.class.st index 0443fbc2..32cd6d29 100644 --- a/src/Spec2-Backend-Tests/SpGridLayoutAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpGridLayoutAdapterTest.class.st @@ -16,147 +16,150 @@ SpGridLayoutAdapterTest >> newLayout [ SpGridLayoutAdapterTest >> testAddAtSamePositionTwiceReplacesChild [ | first second | - layout add: (first := SpButtonPresenter new) at: 1@1. - layout add: (second := SpButtonPresenter new) at: 1@1. - self assert: self adapter children first equals: second adapter widget + layout add: (first := SpButtonPresenter new) atPoint: 1 @ 1. + layout add: (second := SpButtonPresenter new) atPoint: 1 @ 1. + self + assert: self adapter children first + equals: second adapter widget ] { #category : 'tests' } SpGridLayoutAdapterTest >> testAddAtSamePositionTwiceSetsChildrenSingleTime [ - layout add: (SpButtonPresenter new) at: 1@1. - layout add: (SpButtonPresenter new) at: 1@1. + layout add: SpButtonPresenter new atPoint: 1 @ 1. + layout add: SpButtonPresenter new atPoint: 1 @ 1. self assert: self adapter children size equals: 1 ] { #category : 'tests' } SpGridLayoutAdapterTest >> testAddElementAddsToAdapter [ - layout add: SpButtonPresenter new at: 1@1. + layout add: SpButtonPresenter new atPoint: 1 @ 1. self deny: self adapter isEmpty ] { #category : 'tests' } SpGridLayoutAdapterTest >> testAddElementAfterOpenAddsToAdapter [ - layout add: SpButtonPresenter new at: 1@1. + layout add: SpButtonPresenter new atPoint: 1 @ 1. self openInstance. - - layout add: SpButtonPresenter new at: 1@2. + + layout add: SpButtonPresenter new atPoint: 1 @ 2. self assert: self adapter children size equals: 2 ] { #category : 'tests' } SpGridLayoutAdapterTest >> testBeColumnHomogeneous [ - layout + layout beColumnHomogeneous; - add: 'Test' at: 1@1; - add: 'Other label test' at: 2@1. - + add: 'Test' atPoint: 1 @ 1; + add: 'Other label test' atPoint: 2 @ 1. + self openInstance. - - self - assert: presenter adapter widget submorphs first width + + self + assert: presenter adapter widget submorphs first width equals: presenter adapter widget submorphs second width ] { #category : 'tests' } SpGridLayoutAdapterTest >> testBeColumnNotHomogeneous [ - layout + layout beColumnNotHomogeneous; - add: 'Test' at: 1@1; - add: 'Other label test' at: 2@1. - + add: 'Test' atPoint: 1 @ 1; + add: 'Other label test' atPoint: 2 @ 1. + self openInstance. - - self - deny: presenter adapter widget submorphs first width + + self + deny: presenter adapter widget submorphs first width equals: presenter adapter widget submorphs second width ] { #category : 'tests' } SpGridLayoutAdapterTest >> testBeRowHomogeneous [ - layout + layout beRowHomogeneous; - add: 'Test' at: 1@1; - add: (presenter newMorph morph: (Morph new extent: 40@40)) at: 1@2. - + add: 'Test' atPoint: 1 @ 1; + add: (presenter newMorph morph: (Morph new extent: 40 @ 40)) + atPoint: 1 @ 2. + self openInstance. - - self - assert: presenter adapter widget submorphs first height + + self + assert: presenter adapter widget submorphs first height equals: presenter adapter widget submorphs second height ] { #category : 'tests' } SpGridLayoutAdapterTest >> testBeRowNotHomogeneous [ + | testMorph | - testMorph := Morph new - vResizing: #rigid; - extent: 40@40; - yourself. - - layout + vResizing: #rigid; + extent: 40 @ 40; + yourself. + + layout beRowNotHomogeneous; - add: 'Test' at: 1@1; - add: (presenter newMorph morph: testMorph) at: 1@2. - + add: 'Test' atPoint: 1 @ 1; + add: (presenter newMorph morph: testMorph) atPoint: 1 @ 2. + self openInstance. - - self - deny: presenter adapter widget submorphs first height + + self + deny: presenter adapter widget submorphs first height equals: presenter adapter widget submorphs second height ] { #category : 'tests' } SpGridLayoutAdapterTest >> testColumnSpanColumnHomogeneous [ - layout + layout beColumnHomogeneous; - add: 'Test' at: 1@1 span: 2@1; - add: 'Other label test' at: 1@2; add: 'span column'at: 2@2. - + add: 'Test' atPoint: 1 @ 1 span: 2 @ 1; + add: 'Other label test' atPoint: 1 @ 2; + add: 'span column' at: 2 @ 2. + self openInstance. - - self - assert: presenter adapter widget submorphs first width - equals: ( - (presenter adapter widget submorphs second width) - + (presenter adapter widget submorphs third width)) + + self + assert: presenter adapter widget submorphs first width + equals: presenter adapter widget submorphs second width + + presenter adapter widget submorphs third width ] { #category : 'tests' } SpGridLayoutAdapterTest >> testColumnSpanColumnNotHomogeneous [ - layout + layout beColumnNotHomogeneous; - add: 'Test' at: 1@1 span: 2@1; - add: 'Other' at: 1@2; add: 'span column, larger'at: 2@2. - + add: 'Test' atPoint: 1 @ 1 span: 2 @ 1; + add: 'Other' atPoint: 1 @ 2; + add: 'span column, larger' at: 2 @ 2. + self openInstance. - + "the first column width is equal to the sum of two columns" - self - assert: presenter adapter widget submorphs first width - equals: ( - (presenter adapter widget submorphs second width) - + (presenter adapter widget submorphs third width)). + self + assert: presenter adapter widget submorphs first width + equals: presenter adapter widget submorphs second width + + presenter adapter widget submorphs third width. "the first column still needs to be smaller than the first" - self - assert: presenter adapter widget submorphs second width < (presenter adapter widget submorphs third width) + self assert: presenter adapter widget submorphs second width + < presenter adapter widget submorphs third width ] { #category : 'tests' } SpGridLayoutAdapterTest >> testRemoveElementAddedAfterOpenRemovesFromAdapter [ | element | - layout add: (element := SpButtonPresenter new) at: 1@1. + layout add: (element := SpButtonPresenter new) atPoint: 1 @ 1. self openInstance. - + layout remove: element. self assert: self adapter isEmpty ] @@ -165,52 +168,56 @@ SpGridLayoutAdapterTest >> testRemoveElementAddedAfterOpenRemovesFromAdapter [ SpGridLayoutAdapterTest >> testRemoveElementRemovesFromAdapter [ | element | - layout add: (element := SpButtonPresenter new) at: 1@1. + layout add: (element := SpButtonPresenter new) atPoint: 1 @ 1. layout remove: element. self assert: self adapter isEmpty ] { #category : 'tests' } SpGridLayoutAdapterTest >> testRowSpanRowHomogeneous [ + | testMorph | - testMorph := Morph new - vResizing: #rigid; - extent: 40@40; - yourself. - - layout + vResizing: #rigid; + extent: 40 @ 40; + yourself. + + layout beRowHomogeneous; - add: 'Test 1' at: 1@1; add: (presenter newMorph morph: testMorph) at: 2@1 span: 1@2; - add: 'Test 2' at: 1@2. - + add: 'Test 1' atPoint: 1 @ 1; + add: (presenter newMorph morph: testMorph) + atPoint: 2 @ 1 + span: 1 @ 2; + add: 'Test 2' at: 1 @ 2. + self openInstance. - self - assert: presenter adapter widget submorphs second height - equals: - presenter adapter widget submorphs first height + self + assert: presenter adapter widget submorphs second height + equals: presenter adapter widget submorphs first height + presenter adapter widget submorphs third height ] { #category : 'tests' } SpGridLayoutAdapterTest >> testRowSpanRowNotHomogeneous [ + | testMorph | - testMorph := Morph new - vResizing: #rigid; - extent: 40@40; - yourself. - - layout + vResizing: #rigid; + extent: 40 @ 40; + yourself. + + layout beRowNotHomogeneous; - add: 'Test 1' at: 1@1; add: (presenter newMorph morph: testMorph) at: 2@1 span: 1@2; - add: 'Test 2' at: 1@2. - + add: 'Test 1' atPoint: 1 @ 1; + add: (presenter newMorph morph: testMorph) + atPoint: 2 @ 1 + span: 1 @ 2; + add: 'Test 2' at: 1 @ 2. + self openInstance. - - self - assert: presenter adapter widget submorphs second height - equals: - presenter adapter widget submorphs first height + + self + assert: presenter adapter widget submorphs second height + equals: presenter adapter widget submorphs first height + presenter adapter widget submorphs third height ] diff --git a/src/Spec2-Code-Commands/SystemNavigation.extension.st b/src/Spec2-Code-Commands/SystemNavigation.extension.st index 7e85fc8b..122bbeb6 100644 --- a/src/Spec2-Code-Commands/SystemNavigation.extension.st +++ b/src/Spec2-Code-Commands/SystemNavigation.extension.st @@ -9,5 +9,5 @@ SystemNavigation >> browse: anObject [ { #category : '*Spec2-Code-Commands' } SystemNavigation >> inspect: anObject [ - Smalltalk tools inspector inspect: anObject + self tools inspector inspect: anObject ] diff --git a/src/Spec2-Core/SpDropListPresenter.class.st b/src/Spec2-Core/SpDropListPresenter.class.st index 8c9013d4..ccdfce3f 100644 --- a/src/Spec2-Core/SpDropListPresenter.class.st +++ b/src/Spec2-Core/SpDropListPresenter.class.st @@ -352,15 +352,11 @@ SpDropListPresenter >> whenSelectedItemChangedDo: aBlock [ { #category : 'api - events' } SpDropListPresenter >> whenSelectionChangedDo: aBlock [ "Inform when the selection is changed. - The method should be used only if you are interested in the fact that there was - a change, without caring about what has changed. + The method should be used only if you are interested in the fact that + there was a change, without caring about what has changed. If you are interested in the items, use `SpDropListPresenter>>#whenSelectedItemChanged:` - - `aBlock` receive 3 optional arguments: - - new value - - old value - - announcement triggered" + `aBlock` receives an optional argument with the selection object." selection whenChangedDo: aBlock ] diff --git a/src/Spec2-Core/SpNumberInputFieldPresenter.class.st b/src/Spec2-Core/SpNumberInputFieldPresenter.class.st index 37d402b7..eea05786 100644 --- a/src/Spec2-Core/SpNumberInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpNumberInputFieldPresenter.class.st @@ -227,7 +227,7 @@ SpNumberInputFieldPresenter >> whenNumberChangedDo: aBlock [ - old value - the announcement triggering this action" - self whenTextChangedDo: [ :txt | aBlock value: self number ] + self whenTextChangedDo: [ :newValue :oldValue | aBlock cull: self number cull: newValue ] ] { #category : 'api - events' } diff --git a/src/Spec2-Dialogs/SpRequestDialog.class.st b/src/Spec2-Dialogs/SpRequestDialog.class.st index f7f8fa05..93499048 100644 --- a/src/Spec2-Dialogs/SpRequestDialog.class.st +++ b/src/Spec2-Dialogs/SpRequestDialog.class.st @@ -144,7 +144,7 @@ SpRequestDialog >> initializePresenters [ SpRequestDialog >> initializeWindow: aWindowPresenter [ super initializeWindow: aWindowPresenter. - aWindowPresenter whenOpenedDo: [ textInput takeKeyboardFocus ] + aWindowPresenter whenOpenedDo: [ textInput takeKeyboardFocus; selectAll ] ] { #category : 'api - showing' } diff --git a/src/Spec2-Examples/SpDemoTextInputPresenter.class.st b/src/Spec2-Examples/SpDemoTextInputPresenter.class.st index 8af83554..242be394 100644 --- a/src/Spec2-Examples/SpDemoTextInputPresenter.class.st +++ b/src/Spec2-Examples/SpDemoTextInputPresenter.class.st @@ -24,8 +24,8 @@ SpDemoTextInputPresenter class >> example [ SpDemoTextInputPresenter >> defaultLayout [ ^ SpGridLayout new - add: 'Normal:' at: 1 @ 1; - add: fieldNormal at: 2 @ 1 span: 2 @ 1; + add: 'Normal:' atPoint: 1 @ 1; + add: fieldNormal atPoint: 2 @ 1 span: 2 @ 1; add: 'Disabled:' at: 1 @ 2; add: fieldDisabled at: 2 @ 2 span: 2 @ 1; add: 'Placeholder:' at: 1 @ 3; diff --git a/src/Spec2-Layout/SpGridLayout.class.st b/src/Spec2-Layout/SpGridLayout.class.st index 6f3188c8..46d6e352 100644 --- a/src/Spec2-Layout/SpGridLayout.class.st +++ b/src/Spec2-Layout/SpGridLayout.class.st @@ -108,18 +108,39 @@ SpGridLayout >> adapterName [ ^ #GridAdapter ] -{ #category : 'api - adding' } +{ #category : 'deprecated' } SpGridLayout >> add: aName at: aPoint [ - ^ self - add: aName - at: aPoint - span: 1@1 + self deprecated: 'Use add:atPoint:' + on: '24/11/2024' + in: #Pharo13 + transformWith: '`@receiver add: `@arg at: `@aPoint' + -> '`@receiver add: `@arg atPoint: `@aPoint'. + + ^ self add: aName atPoint: aPoint ] -{ #category : 'api - adding' } +{ #category : 'deprecated' } SpGridLayout >> add: aName at: aPoint span: spanPoint [ + self deprecated: 'Use add:atPoint:span:' + on: '24/11/2024' + in: #Pharo13 + transformWith: '`@receiver add: `@arg at: `@aPoint span: `@span' + -> '`@receiver add: `@arg atPoint: `@aPoint span: `@span'. + + ^ self add: aName atPoint: aPoint span: spanPoint +] + +{ #category : 'api - adding' } +SpGridLayout >> add: aName atPoint: aPoint [ + + ^ self add: aName atPoint: aPoint span: 1 @ 1 +] + +{ #category : 'api - adding' } +SpGridLayout >> add: aName atPoint: aPoint span: spanPoint [ + childrenByPosition at: aPoint ifPresent: [ :e | "Remove element at the same position" self remove: e ]. @@ -140,9 +161,21 @@ SpGridLayout >> add: aChild withConstraints: aBlock [ self announceChildAdded: aChild. ] -{ #category : 'accessing' } +{ #category : 'deprecated' } SpGridLayout >> at: aPoint [ + self deprecated: 'Use atPoint:' + on: '24/11/2024' + in: #Pharo13 + transformWith: '`@receiver at: `@aPoint' + -> '`@receiver atPoint: `@aPoint'. + + ^ self atPoint: aPoint +] + +{ #category : 'accessing' } +SpGridLayout >> atPoint: aPoint [ + ^ childrenByPosition at: aPoint ] @@ -261,13 +294,26 @@ SpGridLayout >> isRowHomogeneous [ ^ rowHomogeneous ] -{ #category : 'api - adding' } +{ #category : 'deprecated' } SpGridLayout >> replaceAt: aPoint with: aPresenter [ "This is just a synonym of SpGridLayout>>#add:at:, added for clarity" + self deprecated: 'Use replaceAtPoint:with:' + on: '24/11/2024' + in: #Pharo13 + transformWith: '`@receiver replaceAt:`@aPoint with: `@aPresenter' + -> '`@receiver replaceAtPoint: `@aPoint with: `@aPresenter'. + + ^ self replaceAtPoint: aPoint with: aPresenter +] + +{ #category : 'api - adding' } +SpGridLayout >> replaceAtPoint: aPoint with: aPresenter [ + "This is just a synonym of SpGridLayout>>#add:at:, added for clarity" + ^ self add: aPresenter - at: aPoint + atPoint: aPoint ] { #category : 'api' } diff --git a/src/Spec2-Layout/SpGridLayoutBuilder.class.st b/src/Spec2-Layout/SpGridLayoutBuilder.class.st index 0597b24c..923e1387 100644 --- a/src/Spec2-Layout/SpGridLayoutBuilder.class.st +++ b/src/Spec2-Layout/SpGridLayoutBuilder.class.st @@ -35,7 +35,8 @@ SpGridLayoutBuilder class >> on: aGridLayout [ { #category : 'api' } SpGridLayoutBuilder >> add: aChild [ - layout add: aChild at: self nextColumn @ self currentRow. + + layout add: aChild atPoint: self nextColumn @ self currentRow ] { #category : 'api' } diff --git a/src/Spec2-Tests/SpGridLayoutBuilderTest.class.st b/src/Spec2-Tests/SpGridLayoutBuilderTest.class.st index f53e08cf..c2103a43 100644 --- a/src/Spec2-Tests/SpGridLayoutBuilderTest.class.st +++ b/src/Spec2-Tests/SpGridLayoutBuilderTest.class.st @@ -16,56 +16,40 @@ SpGridLayoutBuilderTest >> newPresenters: nbPresesenters [ { #category : 'tests' } SpGridLayoutBuilderTest >> testBuilderAddsElementsOnRaw [ + | layout presenters | - presenters := self newPresenters: 3. - layout := SpGridLayout build: [ :builder | - builder - add: presenters first; - add: presenters second; - add: presenters third ]. - - self - assert: (layout at: 1@1) - equals: presenters first. - self - assert: (layout at: 2@1) - equals: presenters second. - self - assert: (layout at: 3@1) - equals: presenters third. + layout := SpGridLayout build: [ :builder | + builder + add: presenters first; + add: presenters second; + add: presenters third ]. + + self assert: (layout atPoint: 1 @ 1) equals: presenters first. + self assert: (layout at: 2 @ 1) equals: presenters second. + self assert: (layout at: 3 @ 1) equals: presenters third ] { #category : 'tests' } SpGridLayoutBuilderTest >> testBuilderCanAddElementsOnMultipleRaws [ + | layout presenters | - presenters := self newPresenters: 5. - layout := SpGridLayout build: [ :builder | - builder - add: presenters first; - add: presenters second; - nextRow; - add: presenters third; - nextRow; - add: presenters fourth; - add: presenters fifth ]. - - self - assert: (layout at: 1@1) - equals: presenters first. - self - assert: (layout at: 2@1) - equals: presenters second. - self - assert: (layout at: 1@2) - equals: presenters third. - self - assert: (layout at: 1@3) - equals: presenters fourth. - self - assert: (layout at: 2@3) - equals: presenters fifth. + layout := SpGridLayout build: [ :builder | + builder + add: presenters first; + add: presenters second; + nextRow; + add: presenters third; + nextRow; + add: presenters fourth; + add: presenters fifth ]. + + self assert: (layout atPoint: 1 @ 1) equals: presenters first. + self assert: (layout at: 2 @ 1) equals: presenters second. + self assert: (layout at: 1 @ 2) equals: presenters third. + self assert: (layout at: 1 @ 3) equals: presenters fourth. + self assert: (layout at: 2 @ 3) equals: presenters fifth ] { #category : 'tests' } diff --git a/src/Spec2-Tests/SpNumberInputFieldPresenterTest.class.st b/src/Spec2-Tests/SpNumberInputFieldPresenterTest.class.st index a9e176ea..2a6f6c71 100644 --- a/src/Spec2-Tests/SpNumberInputFieldPresenterTest.class.st +++ b/src/Spec2-Tests/SpNumberInputFieldPresenterTest.class.st @@ -76,6 +76,16 @@ SpNumberInputFieldPresenterTest >> testWhenNumberChangedDo [ self assert: result equals: 10 ] +{ #category : 'tests' } +SpNumberInputFieldPresenterTest >> testWhenNumberChangedDo2Arguments [ + + presenter + number: 10; + whenNumberChangedDo: [ :newValue :oldValue | self deny: newValue equals: oldValue ]. + presenter number: 32. + +] + { #category : 'tests' } SpNumberInputFieldPresenterTest >> testWhenNumberTypeChangedDo [ | count result |