From 2b4e99e35243d711f7d026a549e6801231b21115 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 11 May 2023 12:11:32 +0200 Subject: [PATCH 01/88] labels can have menus (not working yet) --- src/Spec2-Core/SpLabelPresenter.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spec2-Core/SpLabelPresenter.class.st b/src/Spec2-Core/SpLabelPresenter.class.st index 7d74c974a..94ff758bc 100644 --- a/src/Spec2-Core/SpLabelPresenter.class.st +++ b/src/Spec2-Core/SpLabelPresenter.class.st @@ -6,8 +6,8 @@ _NOTE: In the future, it should be possible to attach another widget to a label, Class { #name : #SpLabelPresenter, #superclass : #SpAbstractWidgetPresenter, - #traits : 'SpTDecoratedText', - #classTraits : 'SpTDecoratedText classTrait', + #traits : 'SpTDecoratedText + SpTContextMenu', + #classTraits : 'SpTDecoratedText classTrait + SpTContextMenu classTrait', #instVars : [ '#label => ObservableSlot' ], From ae2a8813e24533817832f365585d8c03e7329952 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 17 May 2023 10:46:19 +0200 Subject: [PATCH 02/88] working on list view --- .../SpMorphicButtonAdapter.class.st | 2 +- .../SpMorphicListAdapter.class.st | 2 - .../SpMorphicListViewAdapter.class.st | 5 +++ .../SpMorphicTableAdapter.class.st | 5 +-- .../SpAbstractAdapterTest.class.st | 4 +- .../SpLabelAdapterTest.class.st | 1 + .../SpAbstractListPresenter.class.st | 33 --------------- src/Spec2-Core/SpAbstractPresenter.class.st | 7 ---- .../SpAbstractWidgetPresenter.class.st | 6 +-- src/Spec2-Core/SpListPresenter.class.st | 7 ---- src/Spec2-Core/SpListViewPresenter.class.st | 41 +++++++++++++++++++ src/Spec2-Core/SpTPresenterBuilder.trait.st | 6 +++ .../SpListViewPresenter.extension.st | 41 +++++++++++++++++++ src/Spec2-Tests/SpBaseTest.class.st | 9 +++- .../SpVerticalBoxLayoutTest.class.st | 2 + 15 files changed, 112 insertions(+), 59 deletions(-) create mode 100644 src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st create mode 100644 src/Spec2-Core/SpListViewPresenter.class.st create mode 100644 src/Spec2-Examples/SpListViewPresenter.extension.st diff --git a/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st index d6da9c8cd..519a29d22 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicButtonAdapter.class.st @@ -20,7 +20,7 @@ SpMorphicButtonAdapter >> action [ self showSubMenuIfPresent. self widget ifNotNil: [:m | m takeKeyboardFocus ]. - self model performAction. + self model performAction ] { #category : #protocol } diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st index 6a1ae1ffc..f34b70a9d 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st @@ -62,8 +62,6 @@ SpMorphicListAdapter >> buildWidget [ self presenter whenSearchEnabledChangedDo: [ self updateSearch ]. self refreshWidgetHeaderTitle. self refreshWidgetSelection. - self presenter whenItemFilterBlockChangedDo: [ :block | self updateItemFilterBlockWith: block ]. - self updateItemFilterBlockWith: self itemFilter. self configureScrolling. widget diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st new file mode 100644 index 000000000..1ec8555a1 --- /dev/null +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st @@ -0,0 +1,5 @@ +Class { + #name : #SpMorphicListViewAdapter, + #superclass : #SpAbstractMorphicAdapter, + #category : #'Spec2-Adapters-Morphic-List' +} diff --git a/src/Spec2-Adapters-Morphic/SpMorphicTableAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicTableAdapter.class.st index cc9197ce0..7d6e2855d 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicTableAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicTableAdapter.class.st @@ -59,11 +59,8 @@ SpMorphicTableAdapter >> addModelTo: tableMorph [ tableMorph dataSource: self newDataSource. - self presenter whenItemFilterBlockChangedDo: [ :block | - self updateItemFilterBlockWith: block ]. self presenter whenSearchEnabledChangedDo: [ - self updateSearch ]. - self updateItemFilterBlockWith: self itemFilter + self updateSearch ] ] { #category : #configuring } diff --git a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st index 15f3f32c5..9737e7b1d 100644 --- a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st @@ -22,7 +22,7 @@ SpAbstractAdapterTest class >> testParameters [ forSelector: #specInitializationStrategy addOptions: { [ SpInitializationStrategy beforeTest ]. [ SpInitializationStrategy afterTest ] }; forSelector: #backendForTest - addOptions: { SpMorphicBackendForTest }; + addOptions: { "SpMorphicBackendForTest. "GtkBackendForTest }; yourself ] @@ -113,6 +113,7 @@ SpAbstractAdapterTest >> presenter [ { #category : #running } SpAbstractAdapterTest >> runCase [ self resources do: [ :each | each availableFor: self ]. + testSelector printToStdout. [ super setUp. self performTest ] ensure: [ self tearDown. @@ -159,6 +160,7 @@ SpAbstractAdapterTest >> testVisibilityWithBlock [ { #category : #tests } SpAbstractAdapterTest >> testVisibilityWithBlockThatReturnsFalse [ + presenter visibleIf: [ false ]. self deny: self adapter isVisible ] diff --git a/src/Spec2-Backend-Tests/SpLabelAdapterTest.class.st b/src/Spec2-Backend-Tests/SpLabelAdapterTest.class.st index c81086403..0999ee07a 100644 --- a/src/Spec2-Backend-Tests/SpLabelAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpLabelAdapterTest.class.st @@ -14,6 +14,7 @@ SpLabelAdapterTest >> classToTest [ { #category : #tests } SpLabelAdapterTest >> testSetLabelInPresenterSetsInInMorph [ + presenter label: 'something'. self assert: self adapter label equals: 'something' ] diff --git a/src/Spec2-Core/SpAbstractListPresenter.class.st b/src/Spec2-Core/SpAbstractListPresenter.class.st index 030177f68..65fff54db 100644 --- a/src/Spec2-Core/SpAbstractListPresenter.class.st +++ b/src/Spec2-Core/SpAbstractListPresenter.class.st @@ -118,11 +118,6 @@ SpAbstractListPresenter >> disableActivationDuring: aBlock [ activationBlock := oldActivate ] ] -{ #category : #TOREMOVE } -SpAbstractListPresenter >> disableFilter [ - self itemFilter: nil -] - { #category : #private } SpAbstractListPresenter >> doActivateAtIndex: anIndex [ @@ -199,18 +194,6 @@ SpAbstractListPresenter >> itemAtPath: anArray [ ^ self itemAt: anArray first ] -{ #category : #TOREMOVE } -SpAbstractListPresenter >> itemFilter [ - ^ itemFilter -] - -{ #category : #TOREMOVE } -SpAbstractListPresenter >> itemFilter: aBlock [ - "This block will be used with the search field of the list to filter it with the user input dynamically." - - itemFilter := aBlock -] - { #category : #api } SpAbstractListPresenter >> items [ "Answer the items of the list" @@ -241,16 +224,6 @@ SpAbstractListPresenter >> listSize [ ^ self model size ] -{ #category : #TOREMOVE } -SpAbstractListPresenter >> matchBeginOfString [ - self itemFilter: [ :each :pattern | each asLowercase beginsWith: pattern asLowercase ] -] - -{ #category : #TOREMOVE } -SpAbstractListPresenter >> matchSubstring [ - self itemFilter: [ :each :pattern | each asLowercase includesSubstring: pattern asLowercase ] -] - { #category : #api } SpAbstractListPresenter >> model [ "Answer the model for this list. @@ -480,12 +453,6 @@ SpAbstractListPresenter >> whenActivatedDo: aBlock [ activationBlock := aBlock ] -{ #category : #TOREMOVE } -SpAbstractListPresenter >> whenItemFilterBlockChangedDo: aBlock [ - - self property: #itemFilter whenChangedDo: aBlock -] - { #category : #'api - events' } SpAbstractListPresenter >> whenModelChangedDo: aBlock [ "Inform when model has been changed (see `SpAbstractListPresenter>>#model:`. diff --git a/src/Spec2-Core/SpAbstractPresenter.class.st b/src/Spec2-Core/SpAbstractPresenter.class.st index 35a2e41f6..4763f7b6d 100644 --- a/src/Spec2-Core/SpAbstractPresenter.class.st +++ b/src/Spec2-Core/SpAbstractPresenter.class.st @@ -545,13 +545,6 @@ SpAbstractPresenter >> withAdapterDo: aValuable [ ^ self adapter ifNotNil: aValuable ] -{ #category : #'private - utilities' } -SpAbstractPresenter >> withWidgetDo: aValuable [ - "a convenience method to avoid verify by nil all the time" - - ^ self adapter ifNotNil: aValuable -] - { #category : #'private - utilities' } SpAbstractPresenter >> withWindowDo: aValuable [ diff --git a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st index 24c3b71bc..6fbf9905f 100644 --- a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st +++ b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st @@ -316,11 +316,11 @@ SpAbstractWidgetPresenter >> initialize [ wantsDrop := [ :transfer | self dropEnabled ]. acceptDrop := [ :transfer | ]. self whenEnabledChangedDo: [ :value | - self withAdapterDo: [ :w | w update: #enabled: with: { value } ] ]. + self withAdapterDo: [ :anAdapter | anAdapter enabled: value ] ]. self property: #dragEnabled whenChangedDo: [ :value | - self withWidgetDo: [ :w | w update: #dragEnabled: with: { value } ] ]. + self withAdapterDo: [ :anAdapter | anAdapter dragEnabled: value ] ]. self property: #dropEnabled whenChangedDo: [ :value | - self withWidgetDo: [ :w | w update: #dropEnabled: with: { value } ] ] + self withAdapterDo: [ :anAdapter | anAdapter dropEnabled: value ] ] ] { #category : #testing } diff --git a/src/Spec2-Core/SpListPresenter.class.st b/src/Spec2-Core/SpListPresenter.class.st index 0bba41f37..41f018431 100644 --- a/src/Spec2-Core/SpListPresenter.class.st +++ b/src/Spec2-Core/SpListPresenter.class.st @@ -178,13 +178,6 @@ SpListPresenter >> resetListSelection [ self selectIndex: 0 ] -{ #category : #TOREMOVE } -SpListPresenter >> resetSortingBlock [ - "Reset the sortering block with the default value which consists in not sorting" - - self model sortingBlock: nil -] - { #category : #api } SpListPresenter >> updateList [ "Update the list re taking the list defined in `SpAbstractListPresenter>>#model` and filling the list with diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-Core/SpListViewPresenter.class.st new file mode 100644 index 000000000..e2845c2cd --- /dev/null +++ b/src/Spec2-Core/SpListViewPresenter.class.st @@ -0,0 +1,41 @@ +Class { + #name : #SpListViewPresenter, + #superclass : #SpAbstractListPresenter, + #traits : 'SpTSearchable', + #classTraits : 'SpTSearchable classTrait', + #instVars : [ + '#setupAction', + '#bindAction' + ], + #category : #'Spec2-Core-Widgets-ListView' +} + +{ #category : #specs } +SpListViewPresenter class >> adapterName [ + + ^ #ListViewAdapter +] + +{ #category : #api } +SpListViewPresenter >> bind: aBlock [ + + bindAction := aBlock +] + +{ #category : #private } +SpListViewPresenter >> bindAction [ + + ^ bindAction +] + +{ #category : #api } +SpListViewPresenter >> setup: aBlock [ + + setupAction := aBlock +] + +{ #category : #private } +SpListViewPresenter >> setupAction [ + + ^ setupAction +] diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index 1efdb985f..80097f0b3 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -120,6 +120,12 @@ SpTPresenterBuilder >> newList [ ^ self instantiate: SpListPresenter ] +{ #category : #'scripting - widgets' } +SpTPresenterBuilder >> newListView [ + + ^ self instantiate: SpListViewPresenter +] + { #category : #'scripting - widgets' } SpTPresenterBuilder >> newMenu [ ^ self instantiate: SpMenuPresenter diff --git a/src/Spec2-Examples/SpListViewPresenter.extension.st b/src/Spec2-Examples/SpListViewPresenter.extension.st new file mode 100644 index 000000000..a92e4a275 --- /dev/null +++ b/src/Spec2-Examples/SpListViewPresenter.extension.st @@ -0,0 +1,41 @@ +Extension { #name : #SpListViewPresenter } + +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> example [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + open +] + +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> exampleWithIcons [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + "this is an optimisation" + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] diff --git a/src/Spec2-Tests/SpBaseTest.class.st b/src/Spec2-Tests/SpBaseTest.class.st index c36ddfdbc..0ef494e72 100644 --- a/src/Spec2-Tests/SpBaseTest.class.st +++ b/src/Spec2-Tests/SpBaseTest.class.st @@ -20,6 +20,12 @@ SpBaseTest >> adapter [ ^ self subclassResponsibility ] +{ #category : #running } +SpBaseTest >> application [ + + ^ SpApplication new useBackend: #Gtk +] + { #category : #assertions } SpBaseTest >> assertEvent: anEventName isRaisedInPresenter: aPresenter whenDoing: aBlock [ @@ -72,8 +78,9 @@ SpBaseTest >> presenter [ { #category : #running } SpBaseTest >> setUp [ + super setUp. - presenter := self classToTest new. + presenter := self classToTest newApplication: self application. self initializeTestedInstance ] diff --git a/src/Spec2-Tests/SpVerticalBoxLayoutTest.class.st b/src/Spec2-Tests/SpVerticalBoxLayoutTest.class.st index bf8a854f8..5b24e0e9e 100644 --- a/src/Spec2-Tests/SpVerticalBoxLayoutTest.class.st +++ b/src/Spec2-Tests/SpVerticalBoxLayoutTest.class.st @@ -15,6 +15,8 @@ SpVerticalBoxLayoutTest >> initializeTestedInstance [ SpVerticalBoxLayoutTest >> testPresenterExtentFollowsChildrenExtent [ | label button | + presenter application backend name = #Gtk ifTrue: [ self skip ]. + layout add: ((label := presenter newLabel) label: 'Label1'); add: ((button := presenter newButton) label: 'Button1'). From d4ad43cbe7e6d331c4b80a73d3778423ed35eff3 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 26 Jun 2023 22:33:38 +0200 Subject: [PATCH 03/88] clean up --- .../SpMorphicBaseTextAdapter.class.st | 49 +++---------------- .../SpMorphicTextAdapter.class.st | 2 +- .../SpMorphicTextInputFieldAdapter.class.st | 2 +- 3 files changed, 10 insertions(+), 43 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st index b9fab115d..002648cb2 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st @@ -56,18 +56,6 @@ SpMorphicBaseTextAdapter >> announcer [ ^ self model announcer ] -{ #category : #'widget API' } -SpMorphicBaseTextAdapter >> askBeforeDiscardingEdits [ - - ^ self model askBeforeDiscardingEdits -] - -{ #category : #'spec protocol' } -SpMorphicBaseTextAdapter >> askBeforeDiscardingEdits: aBoolean [ - - self widget askBeforeDiscardingEdits: aBoolean -] - { #category : #private } SpMorphicBaseTextAdapter >> bubbleUpEvent: anEvent [ @@ -136,16 +124,9 @@ SpMorphicBaseTextAdapter >> getText [ ^ self model text ] -{ #category : #'spec protocol' } -SpMorphicBaseTextAdapter >> hasEditingConflicts: aBoolean [ - - self widgetDo: [ :w | w hasEditingConflicts: aBoolean ] -] - -{ #category : #'spec protocol' } +{ #category : #private } SpMorphicBaseTextAdapter >> hasUnacceptedEdits: aBoolean [ - - self model hasUnacceptedEdits: aBoolean + "not used" ] { #category : #initialization } @@ -186,9 +167,7 @@ SpMorphicBaseTextAdapter >> pendingText [ SpMorphicBaseTextAdapter >> pendingText: aText [ self widgetDo: [ :w | - w - setText: aText; - hasUnacceptedEdits: true ] + w setText: aText ] ] { #category : #'widget API' } @@ -215,19 +194,19 @@ SpMorphicBaseTextAdapter >> scrollValueChanged: aValue [ self model scrollValue: aValue step ] -{ #category : #'spec protocol' } +{ #category : #selection } SpMorphicBaseTextAdapter >> selectAll [ self widgetDo: [ :w | w selectAll ] ] -{ #category : #'spec protocol' } +{ #category : #selection } SpMorphicBaseTextAdapter >> selectFrom: nodeStart to: nodeStop [ self widget selectFrom: nodeStart to: nodeStop ] -{ #category : #'spec protocol' } +{ #category : #selection } SpMorphicBaseTextAdapter >> selectLine [ self widgetDo: [ :w | @@ -240,7 +219,7 @@ SpMorphicBaseTextAdapter >> selection [ ^ selection ] -{ #category : #'spec protocol' } +{ #category : #selection } SpMorphicBaseTextAdapter >> selectionInterval [ ^ self widget selectionInterval @@ -276,12 +255,6 @@ SpMorphicBaseTextAdapter >> setEnabled: aBoolean to: aWidget [ aWidget enabled: aBoolean ] -{ #category : #'spec protocol' } -SpMorphicBaseTextAdapter >> setHasUnacceptedEdits: aBoolean [ - - self widgetDo: [ :w | w basicHasUnacceptedEdits: aBoolean ] -] - { #category : #'widget API' } SpMorphicBaseTextAdapter >> setScrollValue: aValue [ @@ -298,7 +271,7 @@ SpMorphicBaseTextAdapter >> setSelection: interval [ selection := interval ] -{ #category : #'spec protocol' } +{ #category : #selection } SpMorphicBaseTextAdapter >> setSelectionFromModel: aSelection [ self widget ifNotNil: [ :w | w setSelection: aSelection ] @@ -331,9 +304,3 @@ SpMorphicBaseTextAdapter >> typeByChar: aString [ control: false option: false ] ] - -{ #category : #'widget API' } -SpMorphicBaseTextAdapter >> wantsVisualFeedback [ - - ^ self model wantsVisualFeedback -] diff --git a/src/Spec2-Adapters-Morphic/SpMorphicTextAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicTextAdapter.class.st index 39ca2b518..e6b7b7755 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicTextAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicTextAdapter.class.st @@ -47,7 +47,7 @@ SpMorphicTextAdapter >> buildWidget [ setSelectionSelector: #setSelection:; ghostText: self placeholder; beWrapped; - askBeforeDiscardingEdits: self askBeforeDiscardingEdits; + askBeforeDiscardingEdits: false; autoAccept: true; vResizing: #spaceFill; hResizing: #spaceFill; diff --git a/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st index 8248fb8fd..b5135cc2f 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicTextInputFieldAdapter.class.st @@ -29,7 +29,7 @@ SpMorphicTextInputFieldAdapter >> buildWidget [ entryCompletion: self entryCompletion; ghostText: self getPlaceholderText; encrypted: self encrypted; - askBeforeDiscardingEdits: self askBeforeDiscardingEdits; + askBeforeDiscardingEdits: false; autoAccept: true; vResizing: #spaceFill; hResizing: #spaceFill; From 4d93d44b36ffbda0437f4aa1b3e718b33c5c4a73 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 26 Jun 2023 22:34:29 +0200 Subject: [PATCH 04/88] cleanup --- src/Spec2-Core/SpAbstractAdapter.class.st | 60 ----------------------- 1 file changed, 60 deletions(-) diff --git a/src/Spec2-Core/SpAbstractAdapter.class.st b/src/Spec2-Core/SpAbstractAdapter.class.st index bb7b27cb3..06f14aaba 100644 --- a/src/Spec2-Core/SpAbstractAdapter.class.st +++ b/src/Spec2-Core/SpAbstractAdapter.class.st @@ -81,12 +81,6 @@ SpAbstractAdapter >> adapterWasBuilt [ "hook to add after-build opeations (for example, initial status, etc.)" ] -{ #category : #protocol } -SpAbstractAdapter >> add: aWidget [ - - self subclassResponsibility -] - { #category : #initialization } SpAbstractAdapter >> addEventsTo: aWidget [ @@ -109,24 +103,6 @@ SpAbstractAdapter >> eventHandlerReceiver: aWidget [ ^ aWidget ] -{ #category : #protocol } -SpAbstractAdapter >> hRigid [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> hShrinkWrap [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> hSpaceFill [ - - self subclassResponsibility -] - { #category : #testing } SpAbstractAdapter >> hasWidget: aMorphicButtonAdapter [ @@ -174,12 +150,6 @@ SpAbstractAdapter >> presenter [ ^ model ] -{ #category : #protocol } -SpAbstractAdapter >> removeSubWidgets [ - - self subclassResponsibility -] - { #category : #private } SpAbstractAdapter >> replaceLayoutWith: aLayout [ @@ -227,36 +197,6 @@ SpAbstractAdapter >> update: aSymbol with: anArray [ self perform: aSymbol withArguments: anArray ] -{ #category : #protocol } -SpAbstractAdapter >> useProportionalLayout [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> vRigid [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> vShrinkWrap [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> vSpaceFill [ - - self subclassResponsibility -] - -{ #category : #protocol } -SpAbstractAdapter >> when: anAnnouncement do: aBlock [ - - self subclassResponsibility -] - { #category : #accessing } SpAbstractAdapter >> widget [ ^ widget From 476b8ff800a4419635c478526a22d9b436d3ec61 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 26 Jun 2023 22:39:06 +0200 Subject: [PATCH 05/88] let be defined in the presenter and not in the adapter cleanups --- .../SpAbstractTextPresenter.class.st | 106 ++++++++++-------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index f1033a980..a3951b7b3 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -8,14 +8,12 @@ Class { #traits : 'SpTContextMenu', #classTraits : 'SpTContextMenu classTrait', #instVars : [ - '#hasUnacceptedEdits => ObservableSlot', '#selection => ObservableSlot', - '#wantsVisualFeedback => ObservableSlot', - '#askBeforeDiscardingEdits => ObservableSlot', '#text => ObservableSlot', '#actionToPerform => ObservableSlot', '#readSelection => ObservableSlot', - '#placeholder => ObservableSlot' + '#placeholder => ObservableSlot', + '#editable => ObservableSlot' ], #category : #'Spec2-Core-Widgets' } @@ -33,14 +31,18 @@ SpAbstractTextPresenter >> acceptText: aString [ self property: #text rawValue: aString ] -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> askBeforeDiscardingEdits [ - ^ askBeforeDiscardingEdits +{ #category : #api } +SpAbstractTextPresenter >> beEditable [ + "Allow edition (deny readonly)." + + self editable: true ] -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> askBeforeDiscardingEdits: aBoolean [ - askBeforeDiscardingEdits := aBoolean +{ #category : #api } +SpAbstractTextPresenter >> beNotEditable [ + "Set content text as not editable (readonly)" + + self editable: false ] { #category : #api } @@ -82,6 +84,12 @@ SpAbstractTextPresenter >> cursorPositionIndex: index [ ^ self withAdapterDo: [ :anAdapter | anAdapter cursorPositionIndex: index ] ] +{ #category : #private } +SpAbstractTextPresenter >> editable: aBoolean [ + + editable := aBoolean +] + { #category : #api } SpAbstractTextPresenter >> enabled: aBoolean [ "Set if the widget is enabled (clickable or focusable)" @@ -99,27 +107,6 @@ SpAbstractTextPresenter >> hasEditingConflicts [ ifNotNil: [:w | w hasEditingConflicts ] ] -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> hasEditingConflicts: aBoolean [ - "Set if the text zone has editing conflicts" - - ^ self changed: #hasEditingConflicts: with: { aBoolean } -] - -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> hasUnacceptedEdits [ - "Return if the text zone has unaccepted edits (orange corner)" - - ^ hasUnacceptedEdits -] - -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> hasUnacceptedEdits: aBoolean [ - "Return if the text zone has unaccepted edits (orange corner)" - - hasUnacceptedEdits := aBoolean -] - { #category : #initialization } SpAbstractTextPresenter >> initialize [ super initialize. @@ -128,12 +115,10 @@ SpAbstractTextPresenter >> initialize [ placeholder := ''. actionToPerform := [ :txt | ]. readSelection := [ selection ]. - hasUnacceptedEdits := false. selection := 1 to: 0. - wantsVisualFeedback := true. - askBeforeDiscardingEdits := true. - self registerEvents + self registerEvents. + self registerActions ] { #category : #api } @@ -237,15 +222,22 @@ SpAbstractTextPresenter >> readSelectionBlock: aBlock [ ^ readSelection := aBlock ] +{ #category : #initialization } +SpAbstractTextPresenter >> registerActions [ + + self addActionWith: [ :action | action + beOnlyShortcut; + shortcut: $t ctrl unix | $t ctrl win | $t command mac; + action: [ self showContextMenu ] ] +] + { #category : #initialization } SpAbstractTextPresenter >> registerEvents [ self whenTextChangedDo: [ self changed: #getText ]. - self whenReadSelectionIsChangedDo: [ self changed: #readSelection ]. - self property: #hasUnacceptedEdits whenChangedDo: [ :bool | self changed: #setHasUnacceptedEdits: with: {bool} ]. - self property: #selection whenChangedDo: [ :block | self changed: #setSelectionFromModel: with: {block value} ]. - self property: #wantsVisualFeedback whenChangedDo: [ :bool | self changed: #changed with: #() ]. - self property: #askBeforeDiscardingEdits whenChangedDo: [ :bool | self changed: #askBeforeDiscardingEdits: with: {bool} ] + self + property: #selection + whenChangedDo: [ :aSelection | self updateSelectionFromModel: aSelection ] ] { #category : #'api - selection' } @@ -302,6 +294,13 @@ SpAbstractTextPresenter >> selectionInterval: anInterval [ selection := anInterval ] +{ #category : #api } +SpAbstractTextPresenter >> showContextMenu [ + "If the presenter is displayed, shows the associated context menu" + + self withAdapterDo: [ :anAdapter | anAdapter showContextMenu ] +] + { #category : #api } SpAbstractTextPresenter >> text [ "Answer current text" @@ -338,14 +337,18 @@ SpAbstractTextPresenter >> typeByChar: aString [ self text: (self text ifNil: [ '' ]), (each asString) ] ] -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> wantsVisualFeedback [ - ^ wantsVisualFeedback +{ #category : #'api - selection' } +SpAbstractTextPresenter >> unselectAll [ + "Unselect text" + + self selectionInterval: (1 to: 0) ] -{ #category : #TOREMOVE } -SpAbstractTextPresenter >> wantsVisualFeedback: aBoolean [ - wantsVisualFeedback := aBoolean +{ #category : #private } +SpAbstractTextPresenter >> updateSelectionFromModel: aSelection [ + + self withAdapterDo: [ :anAdapter | + anAdapter setSelectionFromModel: aSelection ] ] { #category : #TOREMOVE } @@ -363,6 +366,17 @@ SpAbstractTextPresenter >> whenAcceptBlockChangedDo: aBlock [ self property: #actionToPerform whenChangedDo: aBlock ] +{ #category : #'api - events' } +SpAbstractTextPresenter >> whenEditableChangedDo: aBlock [ + "Inform when editable property has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #editable whenChangedDo: aBlock +] + { #category : #'api - events' } SpAbstractTextPresenter >> whenPlaceholderChangedDo: aBlock [ "Inform when placeholder has been changed (See `SpAbstractTextPresenter>>#placeholder:`). From e67e575e03306cbbc04c177ce570d1b128261472 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 26 Jun 2023 22:40:23 +0200 Subject: [PATCH 06/88] cleanups --- .../SpTextInputFieldPresenter.class.st | 32 ------------------- src/Spec2-Core/SpTextPresenter.class.st | 32 ------------------- 2 files changed, 64 deletions(-) diff --git a/src/Spec2-Core/SpTextInputFieldPresenter.class.st b/src/Spec2-Core/SpTextInputFieldPresenter.class.st index 62136eeb8..f74eb61b8 100644 --- a/src/Spec2-Core/SpTextInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpTextInputFieldPresenter.class.st @@ -8,7 +8,6 @@ Class { #instVars : [ '#entryCompletion => ObservableSlot', '#isPassword => ObservableSlot', - '#editable => ObservableSlot', '#maxLength => ObservableSlot' ], #category : #'Spec2-Core-Widgets' @@ -20,20 +19,6 @@ SpTextInputFieldPresenter class >> adapterName [ ^ #TextInputFieldAdapter ] -{ #category : #api } -SpTextInputFieldPresenter >> beEditable [ - "Allow edition (deny readonly)." - - self editable: true -] - -{ #category : #api } -SpTextInputFieldPresenter >> beNotEditable [ - "Set content text as not editable (readonly)" - - self editable: false -] - { #category : #api } SpTextInputFieldPresenter >> bePassword [ "Set this input text as a password editor." @@ -54,12 +39,6 @@ SpTextInputFieldPresenter >> beText [ self bePassword: false ] -{ #category : #private } -SpTextInputFieldPresenter >> editable: aBoolean [ - - editable := aBoolean -] - { #category : #api } SpTextInputFieldPresenter >> entryCompletion [ "Return an entry completion used to suggest text while typing" @@ -138,17 +117,6 @@ SpTextInputFieldPresenter >> updateText [ self text: self text. ] -{ #category : #'api - events' } -SpTextInputFieldPresenter >> whenEditableChangedDo: aBlock [ - "Inform when editable property has changed. - `aBlock` has three optional arguments: - - new value - - old value - - the announcement triggering this action" - - self property: #editable whenChangedDo: aBlock -] - { #category : #'api - events' } SpTextInputFieldPresenter >> whenEntryCompletionChangedDo: aBlock [ "Inform when entryCompletion property has changed. diff --git a/src/Spec2-Core/SpTextPresenter.class.st b/src/Spec2-Core/SpTextPresenter.class.st index b53dd96d2..06e80b6f7 100644 --- a/src/Spec2-Core/SpTextPresenter.class.st +++ b/src/Spec2-Core/SpTextPresenter.class.st @@ -9,7 +9,6 @@ Class { #instVars : [ '#scrollValue => ObservableSlot', '#editionContextMenu => ObservableSlot', - '#editable => ObservableSlot', '#wrapWord => ObservableSlot', '#undoRedoHistory' ], @@ -94,20 +93,6 @@ SpTextPresenter >> backendIncludesEditionMenu [ ^ false ] -{ #category : #api } -SpTextPresenter >> beEditable [ - "Allow edition (deny readonly)." - - self editable: true -] - -{ #category : #api } -SpTextPresenter >> beNotEditable [ - "Set content text as not editable (readonly)" - - self editable: false -] - { #category : #api } SpTextPresenter >> beNotWrapWord [ "Set component to not wrap words when text does not fit in screen. @@ -166,12 +151,6 @@ SpTextPresenter >> doTextSelectAndPaste [ self withAdapterDo: [ :anAdapter | anAdapter selectAndPasteText ] ] -{ #category : #private } -SpTextPresenter >> editable: aBoolean [ - - editable := aBoolean -] - { #category : #private } SpTextPresenter >> editionCommandsGroup [ @@ -272,17 +251,6 @@ SpTextPresenter >> whenCursorPositionChangedDo: aBlock [ self property: #cursorPosition whenChangedDo: aBlock ] -{ #category : #'api - events' } -SpTextPresenter >> whenEditableChangedDo: aBlock [ - "Inform when editable property has changed. - `aBlock` has three optional arguments: - - new value - - old value - - the announcement triggering this action" - - self property: #editable whenChangedDo: aBlock -] - { #category : #'api - events' } SpTextPresenter >> whenScrollValueChangedDo: aBlock [ "Inform when scrollValue property has changed. From 662601c1e919818dbab10b7c9fff4627e6428f24 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 27 Jun 2023 11:56:42 +0200 Subject: [PATCH 07/88] working with actions and with easy list view --- .../SpAbstractMorphicAdapter.class.st | 6 +- src/Spec2-Commander2/SpCommand.class.st | 26 +- src/Spec2-Commander2/SpCommandGroup.class.st | 10 + src/Spec2-Core/SpAction.class.st | 109 ++++++ src/Spec2-Core/SpActionGroup.class.st | 56 ++++ src/Spec2-Core/SpBaseActionGroup.class.st | 14 + .../SpEasyListRowPresenter.class.st | 80 +++++ .../SpEasyListViewPresenter.class.st | 316 ++++++++++++++++++ src/Spec2-Core/SpListPresenter.class.st | 2 +- src/Spec2-Core/SpListViewPresenter.class.st | 93 +++++- src/Spec2-Core/SpPresenter.class.st | 4 +- src/Spec2-Core/SpTActionContainer.trait.st | 61 ++++ src/Spec2-Core/SpTPresenterBuilder.trait.st | 16 +- src/Spec2-Core/SpTSearchable.trait.st | 2 +- .../SpTextInputFieldPresenter.class.st | 10 + src/Spec2-Core/SpWindowPresenter.class.st | 2 +- .../SpListViewPresenter.extension.st | 125 ++++++- .../SpEasyListViewPresenterTest.class.st | 62 ++++ .../SpListViewPresenterTest.class.st | 25 ++ 19 files changed, 1001 insertions(+), 18 deletions(-) create mode 100644 src/Spec2-Core/SpAction.class.st create mode 100644 src/Spec2-Core/SpActionGroup.class.st create mode 100644 src/Spec2-Core/SpBaseActionGroup.class.st create mode 100644 src/Spec2-Core/SpEasyListRowPresenter.class.st create mode 100644 src/Spec2-Core/SpEasyListViewPresenter.class.st create mode 100644 src/Spec2-Core/SpTActionContainer.trait.st create mode 100644 src/Spec2-Tests/SpEasyListViewPresenterTest.class.st create mode 100644 src/Spec2-Tests/SpListViewPresenterTest.class.st diff --git a/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st b/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st index 8a803abfc..3b369fc5e 100644 --- a/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st @@ -685,8 +685,10 @@ SpAbstractMorphicAdapter >> vSpaceFill [ { #category : #protocol } SpAbstractMorphicAdapter >> when: anAnnouncement do: aBlock [ - self widgetDo: [ :w | w announcer - when: anAnnouncement do: aBlock ] + self widgetDo: [ :w | + w announcer + when: anAnnouncement + do: aBlock ] ] { #category : #emulating } diff --git a/src/Spec2-Commander2/SpCommand.class.st b/src/Spec2-Commander2/SpCommand.class.st index de8d96267..7110fab25 100644 --- a/src/Spec2-Commander2/SpCommand.class.st +++ b/src/Spec2-Commander2/SpCommand.class.st @@ -27,6 +27,7 @@ SpCommand >> asButtonPresenter [ { #category : #'presenter building' } SpCommand >> buildPresenter [ + ^ presenter := self buildPresenterBlock value: self ] @@ -84,6 +85,16 @@ SpCommand >> iconProvider [ ^ iconProvider ] +{ #category : #accessing } +SpCommand >> id [ + + ^ String streamContents: [ :stream | + | parts | + parts := (self name ifNil: [ 'unknown' ]) substrings. + stream << parts first asLowercase. + parts allButFirstDo: [ :each | stream << each capitalized ] ] +] + { #category : #initialization } SpCommand >> initialize [ @@ -102,13 +113,26 @@ SpCommand >> innerCommand [ ^ innerCommand ] +{ #category : #testing } +SpCommand >> isEnabled [ + + ^ self canBeExecuted +] + +{ #category : #testing } +SpCommand >> isVisible [ + + ^ true +] + { #category : #accessing } SpCommand >> presenter [ ^ presenter ] { #category : #updating } -SpCommand >> updateEnableStatus [ +SpCommand >> updateEnableStatus [ + self presenter ifNil: [ ^ self ]. self presenter enabled: self canBeExecuted ] diff --git a/src/Spec2-Commander2/SpCommandGroup.class.st b/src/Spec2-Commander2/SpCommandGroup.class.st index df6649ce7..1add2bfcc 100644 --- a/src/Spec2-Commander2/SpCommandGroup.class.st +++ b/src/Spec2-Commander2/SpCommandGroup.class.st @@ -114,6 +114,16 @@ SpCommandGroup >> iconProvider: anIconProvider [ iconProvider := anIconProvider ] +{ #category : #accessing } +SpCommandGroup >> id [ + + ^ String streamContents: [ :stream | + | parts | + parts := (self name ifNil: [ 'unknown' ]) substrings. + stream << parts first asLowercase. + parts allButFirstDo: [ :each | stream << each capitalized ] ] +] + { #category : #initialization } SpCommandGroup >> initialize [ diff --git a/src/Spec2-Core/SpAction.class.st b/src/Spec2-Core/SpAction.class.st new file mode 100644 index 000000000..9fda6f469 --- /dev/null +++ b/src/Spec2-Core/SpAction.class.st @@ -0,0 +1,109 @@ +" +An action is a spec command (`SpCommand`) that will be used for context menus and/or shortcuts in the presenters that implement `SpTActionContainer` +" +Class { + #name : #SpAction, + #superclass : #SpCommand, + #instVars : [ + 'action', + 'actionEnabled', + 'visible', + 'actionVisible' + ], + #category : #'Spec2-Core-Base-Command' +} + +{ #category : #'instance creation' } +SpAction class >> newName: aName action: aBlock [ + + ^ self new + name: aName; + action: aBlock; + yourself +] + +{ #category : #'instance creation' } +SpAction class >> newName: aName shortcut: aShortcut action: aBlock [ + + ^ self new + name: aName; + shortcutKey: aShortcut; + action: aBlock; + yourself +] + +{ #category : #'instance creation' } +SpAction class >> newShortcut: aShortcut action: aBlock [ + "action without menu entry" + + ^ self new + name: aShortcut asString; + shortcutKey: aShortcut; + action: aBlock; + beOnlyShortcut; + yourself +] + +{ #category : #accessing } +SpAction >> action: aBlock [ + + action := aBlock +] + +{ #category : #accessing } +SpAction >> actionEnabled: aBlock [ + + actionEnabled := aBlock +] + +{ #category : #accessing } +SpAction >> actionVisible: aBlock [ + + actionVisible := aBlock +] + +{ #category : #accessing } +SpAction >> beOnlyShortcut [ + + visible := false +] + +{ #category : #testing } +SpAction >> canBeExecuted [ + + actionEnabled ifNil: [ ^ true ]. + ^ actionEnabled cull: self context +] + +{ #category : #executing } +SpAction >> execute [ + + action ifNil: [ ^ self ]. + self canBeExecuted ifFalse: [ ^ self ]. + + action cull: self context +] + +{ #category : #initialization } +SpAction >> initialize [ + + decoratedCommand := CmCommand new. + decoratedCommand name: nil. + visible := true. + super initialize. + +] + +{ #category : #testing } +SpAction >> isVisible [ + + ^ visible + and: [ actionVisible isNil or: [ actionVisible value ] ] +] + +{ #category : #accessing } +SpAction >> shortcut: aKeyCombination [ + "just a synonym" + + self shortcutKey: aKeyCombination +] diff --git a/src/Spec2-Core/SpActionGroup.class.st b/src/Spec2-Core/SpActionGroup.class.st new file mode 100644 index 000000000..4cdab6c4a --- /dev/null +++ b/src/Spec2-Core/SpActionGroup.class.st @@ -0,0 +1,56 @@ +" +An action group is a spec command group (`SpCommandGroup`) that will be used for context menus and/or shortcuts in the presenters that implement `SpTActionContainer` +" +Class { + #name : #SpActionGroup, + #superclass : #SpCommandGroup, + #category : #'Spec2-Core-Base-Command' +} + +{ #category : #'instance creation' } +SpActionGroup class >> newName: aName [ + + ^ self new + name: aName; + yourself +] + +{ #category : #'instance creation' } +SpActionGroup class >> newName: aName with: aBlock [ + + ^ (self newName: aName) + in: [ :this | aBlock value: this ]; + yourself +] + +{ #category : #accessing } +SpActionGroup >> add: anAction [ + + self register: anAction +] + +{ #category : #accessing } +SpActionGroup >> addActionWith: aBlock [ + | action | + + action := SpAction new. + aBlock value: action. + self add: action +] + +{ #category : #accessing } +SpActionGroup >> addGroupWith: aBlock [ + | action | + + action := self class new. + aBlock value: action. + self add: action + +] + +{ #category : #initialization } +SpActionGroup >> initialize [ + + decoratedGroup := SpBaseActionGroup new. + super initialize +] diff --git a/src/Spec2-Core/SpBaseActionGroup.class.st b/src/Spec2-Core/SpBaseActionGroup.class.st new file mode 100644 index 000000000..c93bf44d0 --- /dev/null +++ b/src/Spec2-Core/SpBaseActionGroup.class.st @@ -0,0 +1,14 @@ +Class { + #name : #SpBaseActionGroup, + #superclass : #CmCommandGroup, + #category : #'Spec2-Core-Base-Command' +} + +{ #category : #private } +SpBaseActionGroup >> ensureNotDuplicated: aCommandOrGroup [ + "we do not really care if this has not name (since groups as sections may not show it + and actions as shortcuts do not need it)" + + aCommandOrGroup name ifNil: [ ^ self ]. + super ensureNotDuplicated: aCommandOrGroup +] diff --git a/src/Spec2-Core/SpEasyListRowPresenter.class.st b/src/Spec2-Core/SpEasyListRowPresenter.class.st new file mode 100644 index 000000000..ab099a9e0 --- /dev/null +++ b/src/Spec2-Core/SpEasyListRowPresenter.class.st @@ -0,0 +1,80 @@ +Class { + #name : #SpEasyListRowPresenter, + #superclass : #SpPresenter, + #traits : 'SpTModel', + #classTraits : 'SpTModel classTrait', + #instVars : [ + 'listView', + 'iconPresenter', + 'textPresenter' + ], + #category : #'Spec2-Core-Widgets-ListView' +} + +{ #category : #layout } +SpEasyListRowPresenter >> defaultLayout [ + + ^ self textLayout +] + +{ #category : #layout } +SpEasyListRowPresenter >> iconLayout [ + + ^ SpBoxLayout newHorizontal + spacing: 5; + add: iconPresenter expand: false; + add: textPresenter; + yourself +] + +{ #category : #initialization } +SpEasyListRowPresenter >> initializePresenters [ + + iconPresenter := self newImage. + textPresenter := self newLabel +] + +{ #category : #accessing } +SpEasyListRowPresenter >> listView [ + + ^ listView +] + +{ #category : #accessing } +SpEasyListRowPresenter >> listView: aListView [ + + listView := aListView. + listView hasIcons + ifTrue: [ self useIconLayout ] + ifFalse: [ self useTextLayout ] +] + +{ #category : #layout } +SpEasyListRowPresenter >> textLayout [ + + ^ SpBoxLayout newHorizontal + add: textPresenter; + yourself +] + +{ #category : #initialization } +SpEasyListRowPresenter >> updatePresenter [ + + self model ifNil: [ ^ self ]. + + self listView hasIcons + ifTrue: [ iconPresenter image: (self listView displayIcon value: self model) ]. + textPresenter label: (self listView display value: self model) +] + +{ #category : #layout } +SpEasyListRowPresenter >> useIconLayout [ + + self layout: self iconLayout +] + +{ #category : #layout } +SpEasyListRowPresenter >> useTextLayout [ + + self layout: self textLayout +] diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st new file mode 100644 index 000000000..dfd58f07d --- /dev/null +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -0,0 +1,316 @@ +Class { + #name : #SpEasyListViewPresenter, + #superclass : #SpPresenter, + #traits : 'SpTSearchable', + #classTraits : 'SpTSearchable classTrait', + #instVars : [ + '#display => ObservableSlot', + '#displayIcon => ObservableSlot', + '#searchInput', + '#listView', + '#headerPanel', + '#lastSelectedRow => WeakSlot' + ], + #category : #'Spec2-Core-Widgets-ListView' +} + +{ #category : #specs } +SpEasyListViewPresenter class >> adapterName [ + + ^ #EasyListViewAdapter +] + +{ #category : #examples } +SpEasyListViewPresenter class >> example [ + "This example show a simple list with all classes, using all the default settings." + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + open; + yourself +] + +{ #category : #examples } +SpEasyListViewPresenter class >> exampleWithHeaderTitle [ + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + headerTitle: 'Title'; + open; + yourself +] + +{ #category : #examples } +SpEasyListViewPresenter class >> exampleWithIcons [ + "This example show a simple list with icons." + + ^ self new + application: (SpApplication new useBackend: #Gtk); + displayIcon: [ :e | self iconNamed: #forwardIcon ]; + items: (1 to: 10) asArray; + open; + yourself +] + +{ #category : #'api - actions' } +SpEasyListViewPresenter >> actionGroup [ + + ^ listView actionGroup +] + +{ #category : #'api - actions' } +SpEasyListViewPresenter >> actionGroup: aSpCommandGroup [ + + listView actionGroup: aSpCommandGroup +] + +{ #category : #private } +SpEasyListViewPresenter >> activateSearchWith: aString [ + + lastSelectedRow := listView selectedItem. + + searchInput text: aString. + searchInput show. + searchInput takeKeyboardFocus. + searchInput unselectAll. + searchInput cursorPositionIndex: aString size +] + +{ #category : #'api - actions' } +SpEasyListViewPresenter >> addAction: aSpCommand [ + + listView addAction: aSpCommand +] + +{ #category : #initialization } +SpEasyListViewPresenter >> connectPresenters [ + + searchInput + addAction: (SpAction + newShortcut: Character escape asKeyCombination + action: [ self deactivateSearch: false ]); + addAction: (SpAction + newShortcut: Character cr asKeyCombination + action: [ self deactivateSearch: true ]); + whenTextChangedDo: [ :aString | self selectFirst: aString ]. + + listView eventHandler + whenKeyDownDo: [ :event | self maybeActivateSearchOn: event ]; + whenFocusReceivedDo: [ :event | searchInput hide ] +] + +{ #category : #private } +SpEasyListViewPresenter >> deactivateSearch: acceptSelection [ + | currentSelection | + + currentSelection := listView selectedItem. + searchInput hide. + listView selectItem: (acceptSelection + ifTrue: [ currentSelection ] + ifFalse: [ lastSelectedRow ]). + listView takeKeyboardFocus +] + +{ #category : #layout } +SpEasyListViewPresenter >> defaultLayout [ + + ^ SpOverlayLayout new + child: (SpBoxLayout newVertical + add: headerPanel expand: false; + add: listView; + yourself); + addOverlay: searchInput withConstraints: [ :c | c vAlignEnd; hAlignEnd ]; + yourself +] + +{ #category : #api } +SpEasyListViewPresenter >> display [ + "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a + displayable string." + + ^ display +] + +{ #category : #api } +SpEasyListViewPresenter >> display: aBlock [ + "Set the block that will be applied on each of the list items. + The result of the block will be used to display the item on the screen. + `aBlock` receives one argument. + Here is the typical example: + + initializePresenters + ... + fontFamilyList := self newList. + fontFamilyList display: [ :fontFamily | fontFamily familyName ] + ... + " + + display := aBlock +] + +{ #category : #api } +SpEasyListViewPresenter >> displayIcon [ + "Return the block used to return an icon that will be displayed in the list" + + ^ displayIcon +] + +{ #category : #api } +SpEasyListViewPresenter >> displayIcon: aBlock [ + "Set a block which takes an item as argument and returns the icon to display in the list. + `aBlock` receives one argument" + + displayIcon := aBlock +] + +{ #category : #private } +SpEasyListViewPresenter >> displayValueFor: anObject [ + + ^ self display value: anObject +] + +{ #category : #private } +SpEasyListViewPresenter >> findFirst: aString [ + | items | + + items := listView items. + items isEmptyOrNil ifTrue: [ ^ 0 ]. + + (listView selection selectedIndex max: 1) to: items size do: [ :index | + (self + performSearch: (items at: index) + matching: aString) + ifTrue: [ ^ index ] ]. + + ^ 0 +] + +{ #category : #testing } +SpEasyListViewPresenter >> hasHeaderTitle [ + "Answer true if the list has a title (See `SpListPresenter>>#headerTitle:`)." + + ^ headerPanel isVisible +] + +{ #category : #testing } +SpEasyListViewPresenter >> hasIcons [ + "Answer true if the list has an icon provider (See `SpListPresenter>>#icons:`)." + + ^ self displayIcon notNil +] + +{ #category : #api } +SpEasyListViewPresenter >> headerTitle [ + "Answer the header title." + + ^ headerPanel label +] + +{ #category : #api } +SpEasyListViewPresenter >> headerTitle: aString [ + "Set the header title." + + headerPanel label:( aString ifNil: [ '' ]). + aString isEmptyOrNil + ifTrue: [ headerPanel hide ] + ifFalse: [ headerPanel show ] +] + +{ #category : #api } +SpEasyListViewPresenter >> hideHeaderTitle [ + + headerPanel hide +] + +{ #category : #private } +SpEasyListViewPresenter >> iconFor: anItem [ + + ^ self displayIcon + cull: anItem + cull: self +] + +{ #category : #initialization } +SpEasyListViewPresenter >> initialize [ + + super initialize. + self initializeTSearchable. + display := [ :object | object asString ] +] + +{ #category : #initialization } +SpEasyListViewPresenter >> initializePresenters [ + + headerPanel := self newLabel. + listView := self newListView + setup: [ :aPresenter | + (aPresenter instantiate: SpEasyListRowPresenter) + listView: self; + yourself ]; + bind: [ :aPresenter :anObject | + aPresenter model: anObject ]; + yourself. + searchInput := self newTextInput. + + headerPanel hide. + searchInput hide +] + +{ #category : #api } +SpEasyListViewPresenter >> items: anOrderedCollection [ + + listView items: anOrderedCollection +] + +{ #category : #private } +SpEasyListViewPresenter >> maybeActivateSearchOn: event [ + + self isSearchEnabled ifFalse: [ ^ self ]. + "any modifier other than shift?" + (event modifiers any + or: [ (event keyValue between: 32 and: 127) not ]) + ifTrue: [ ^ self ]. + self activateSearchWith: event character asString +] + +{ #category : #initialization } +SpEasyListViewPresenter >> registerEvents [ + + super registerEvents. + + self whenDisplayChangedDo: [ listView refresh ] +] + +{ #category : #private } +SpEasyListViewPresenter >> selectFirst: aString [ + | index | + + index := self findFirst: aString. + index = 0 ifTrue: [ ^ self ]. + + listView selectIndex: index +] + +{ #category : #'api - events' } +SpEasyListViewPresenter >> whenDisplayChangedDo: aBlock [ + "Inform when the display block has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #display whenChangedDo: aBlock +] + +{ #category : #'api - events' } +SpEasyListViewPresenter >> whenIconsChangedDo: aBlock [ + "Inform when the icons block has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #displayIcon whenChangedDo: aBlock +] diff --git a/src/Spec2-Core/SpListPresenter.class.st b/src/Spec2-Core/SpListPresenter.class.st index 41f018431..cfb886d54 100644 --- a/src/Spec2-Core/SpListPresenter.class.st +++ b/src/Spec2-Core/SpListPresenter.class.st @@ -158,7 +158,7 @@ SpListPresenter >> prepareForFilteredDataSourceWith: items [ model := items ] -{ #category : #private } +{ #category : #initialization } SpListPresenter >> registerEvents [ super registerEvents. "Do not use whenAutoDeselectChangedDo: to avoid the deprecation warning." diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-Core/SpListViewPresenter.class.st index e2845c2cd..578d7de17 100644 --- a/src/Spec2-Core/SpListViewPresenter.class.st +++ b/src/Spec2-Core/SpListViewPresenter.class.st @@ -1,11 +1,11 @@ Class { #name : #SpListViewPresenter, #superclass : #SpAbstractListPresenter, - #traits : 'SpTSearchable', - #classTraits : 'SpTSearchable classTrait', + #classTraits : 'SpTActionContainer classTrait', #instVars : [ '#setupAction', - '#bindAction' + '#bindAction', + '#headerTitle => ObservableSlot' ], #category : #'Spec2-Core-Widgets-ListView' } @@ -28,6 +28,64 @@ SpListViewPresenter >> bindAction [ ^ bindAction ] +{ #category : #testing } +SpListViewPresenter >> hasHeaderTitle [ + "Answer true if the list has a title (See `SpListPresenter>>#headerTitle:`)." + + ^ headerTitle isEmptyOrNil not +] + +{ #category : #api } +SpListViewPresenter >> headerTitle [ + "Answer the header title." + + ^ headerTitle +] + +{ #category : #api } +SpListViewPresenter >> headerTitle: aString [ + "Set the header title." + + headerTitle := aString +] + +{ #category : #initialization } +SpListViewPresenter >> initialize [ + + super initialize. + self registerActions. + self initializeItemFactory. + +] + +{ #category : #initialization } +SpListViewPresenter >> initializeItemFactory [ + "Just set up the defaults (to ensure we have a working list at any moment)" + + self setup: [ :aPresenter | aPresenter newLabel ]. + self bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] +] + +{ #category : #initialization } +SpListViewPresenter >> registerActions [ + + self addActionWith: [ :action | action + beOnlyShortcut; + shortcut: $t ctrl unix | $t ctrl win | $t command mac; + action: [ self showContextMenu ] ] +] + +{ #category : #initialization } +SpListViewPresenter >> registerEvents [ + + super registerEvents. + + self + property: #headerTitle + whenChangedDo: [ + self withAdapterDo: [ :anAdapter | anAdapter refreshList ] ] +] + { #category : #api } SpListViewPresenter >> setup: aBlock [ @@ -39,3 +97,32 @@ SpListViewPresenter >> setupAction [ ^ setupAction ] + +{ #category : #api } +SpListViewPresenter >> showContextMenu [ + "If the presenter is displayed, shows the associated context menu" + + self withAdapterDo: [ :anAdapter | anAdapter showContextMenu ] +] + +{ #category : #'api - events' } +SpListViewPresenter >> whenDisplayChangedDo: aBlock [ + "Inform when the display block has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #display whenChangedDo: aBlock +] + +{ #category : #'api - events' } +SpListViewPresenter >> whenIconsChangedDo: aBlock [ + "Inform when the icons block has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #icon whenChangedDo: aBlock +] diff --git a/src/Spec2-Core/SpPresenter.class.st b/src/Spec2-Core/SpPresenter.class.st index e283fc18f..80f1a0911 100644 --- a/src/Spec2-Core/SpPresenter.class.st +++ b/src/Spec2-Core/SpPresenter.class.st @@ -84,8 +84,8 @@ SpMyPresenter >> initializeLayout Class { #name : #SpPresenter, #superclass : #SpAbstractPresenter, - #traits : 'SpTPresenterBuilder', - #classTraits : 'SpTPresenterBuilder classTrait', + #traits : 'SpTPresenterBuilder + SpTActionContainer', + #classTraits : 'SpTPresenterBuilder classTrait + SpTActionContainer classTrait', #instVars : [ '#application', '#focusOrder', diff --git a/src/Spec2-Core/SpTActionContainer.trait.st b/src/Spec2-Core/SpTActionContainer.trait.st new file mode 100644 index 000000000..bab7b8d45 --- /dev/null +++ b/src/Spec2-Core/SpTActionContainer.trait.st @@ -0,0 +1,61 @@ +Trait { + #name : #SpTActionContainer, + #instVars : [ + 'actionGroup' + ], + #category : #'Spec2-Core-Base-Command' +} + +{ #category : #'api - actions' } +SpTActionContainer >> actionGroup [ + + ^ actionGroup +] + +{ #category : #'api - actions' } +SpTActionContainer >> actionGroup: aSpCommandGroup [ + + aSpCommandGroup beRoot. + actionGroup := aSpCommandGroup + +] + +{ #category : #'api - actions' } +SpTActionContainer >> actionsWith: aBlock [ + + actionGroup := nil. + aBlock value: self ensureActionGroup +] + +{ #category : #'api - actions' } +SpTActionContainer >> addAction: aSpCommand [ + + self ensureActionGroup register: aSpCommand +] + +{ #category : #'api - actions' } +SpTActionContainer >> addActionWith: aBlock [ + + self ensureActionGroup addActionWith: aBlock +] + +{ #category : #private } +SpTActionContainer >> ensureActionGroup [ + + ^ actionGroup ifNil: [ actionGroup := SpActionGroup new beRoot ] +] + +{ #category : #initialization } +SpTActionContainer >> initialize [ + + self class initializeSlots: self. + super initialize. +] + +{ #category : #'api - events' } +SpTActionContainer >> whenCommandGroupChangedDo: aBlock [ + "Inform when menu definition changed. + `aBlock` receives zero arguments." + + self property: #actionGroup whenChangedDo: aBlock +] diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index 80097f0b3..e9e80a108 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -99,6 +99,12 @@ SpTPresenterBuilder >> newDynamicPresentersListIn: accessorSymbol usingBuilder: self build ] +{ #category : #'scripting - lists' } +SpTPresenterBuilder >> newEasyListView [ + + ^ self instantiate: SpEasyListViewPresenter +] + { #category : #'scripting - layouts' } SpTPresenterBuilder >> newGridLayout [ @@ -115,12 +121,12 @@ SpTPresenterBuilder >> newLabel [ ^ self instantiate: SpLabelPresenter ] -{ #category : #'scripting - widgets' } +{ #category : #'scripting - lists' } SpTPresenterBuilder >> newList [ ^ self instantiate: SpListPresenter ] -{ #category : #'scripting - widgets' } +{ #category : #'scripting - lists' } SpTPresenterBuilder >> newListView [ ^ self instantiate: SpListViewPresenter @@ -250,7 +256,7 @@ SpTPresenterBuilder >> newStatusBar [ ^ self instantiate: SpStatusBarPresenter ] -{ #category : #'scripting - widgets' } +{ #category : #'scripting - lists' } SpTPresenterBuilder >> newTable [ ^ self instantiate: SpTablePresenter @@ -302,13 +308,13 @@ SpTPresenterBuilder >> newToolbarToggleButton [ ^ self instantiate: SpToolbarToggleButtonPresenter ] -{ #category : #'scripting - widgets' } +{ #category : #'scripting - lists' } SpTPresenterBuilder >> newTree [ ^ self instantiate: SpTreePresenter ] -{ #category : #'scripting - widgets' } +{ #category : #'scripting - lists' } SpTPresenterBuilder >> newTreeTable [ ^ self instantiate: SpTreeTablePresenter diff --git a/src/Spec2-Core/SpTSearchable.trait.st b/src/Spec2-Core/SpTSearchable.trait.st index a2b03832c..b36f13169 100644 --- a/src/Spec2-Core/SpTSearchable.trait.st +++ b/src/Spec2-Core/SpTSearchable.trait.st @@ -59,7 +59,7 @@ SpTSearchable >> performDefaultSearch: item matching: pattern [ | text | text := (self searchValueOf: item) asString trimBoth asLowercase. - ^ text beginsWith: pattern + ^ text beginsWith: pattern asLowercase ] { #category : #private } diff --git a/src/Spec2-Core/SpTextInputFieldPresenter.class.st b/src/Spec2-Core/SpTextInputFieldPresenter.class.st index f74eb61b8..e982fcb91 100644 --- a/src/Spec2-Core/SpTextInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpTextInputFieldPresenter.class.st @@ -99,6 +99,16 @@ SpTextInputFieldPresenter >> removeEntryCompletion [ self entryCompletion: nil ] +{ #category : #'api - focus' } +SpTextInputFieldPresenter >> takeKeyboardFocusWithoutSelecting [ + "Causes this presenter to have the keyboard focus for the window it's inside. + Unlike `takeKeyboardFocus` this method will not select the text inside." + + self flag: #MorphicMissing. + self withAdapterDo: [ :anAdapter | + anAdapter takeKeyboardFocusWithoutSelecting ] +] + { #category : #api } SpTextInputFieldPresenter >> text: aString [ "Set input text contents." diff --git a/src/Spec2-Core/SpWindowPresenter.class.st b/src/Spec2-Core/SpWindowPresenter.class.st index 2b0835eb8..d9f4251b6 100644 --- a/src/Spec2-Core/SpWindowPresenter.class.st +++ b/src/Spec2-Core/SpWindowPresenter.class.st @@ -603,7 +603,7 @@ SpWindowPresenter >> triggerOkAction [ SpWindowPresenter >> updateTitle [ "Update the window title" - self changed: #title: with: { self title } + self withAdapterDo: [ :anAdapter | anAdapter title: self title ] ] { #category : #'api - events' } diff --git a/src/Spec2-Examples/SpListViewPresenter.extension.st b/src/Spec2-Examples/SpListViewPresenter.extension.st index a92e4a275..789ef9c68 100644 --- a/src/Spec2-Examples/SpListViewPresenter.extension.st +++ b/src/Spec2-Examples/SpListViewPresenter.extension.st @@ -12,14 +12,136 @@ SpListViewPresenter class >> example [ open ] +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> exampleReplaceItems [ + "This example shows how to replace dynamically the list of elements." + | presenter listView button items | + + items := #(). + + presenter := SpPresenter newApplication: (SpApplication new useBackend: #Gtk). + presenter layout: (SpBoxLayout newVertical + add: (listView := presenter newListView); + add: (button := presenter newButton) expand: false; + yourself). + + listView + items: #(); + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]. + + button + label: 'Add'; + action: [ listView items: (items := items copyWith: self environment allClasses atRandom) ]. + + ^ presenter open +] + +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> exampleWithActions [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + actionsWith: [ :rootGroup | rootGroup + addGroupWith: [ :aGroup | aGroup + name: 'Group 1'; + beDisplayedAsGroup; + addActionWith: [ :act | act + name: 'Test 1'; + shortcut: $a ctrl; + action: [ 'Test 1.1' crTrace ] ]; + addActionWith: [ :act | act + name: 'Test 2'; + action: [ 'Test 1.2' crTrace ] ] ]; + addGroupWith: [ :subGroup1 | subGroup1 + name: 'Group 2'; + addActionWith: [ :act | act + name: 'Test 1'; + shortcut: $y ctrl; + action: [ 'Test 2.1' crTrace ]; + actionEnabled: [ false ] ]; + addActionWith: [ :act | act + name: 'Test 2'; + action: [ 'Test 2.2' crTrace ] ] ]; + addActionWith: [ :act | act + name: 'Test 3'; + shortcut: $a ctrl; + action: [ 'Test 3' crTrace ] ]; + addActionWith: [ :act | act + name: 'Test 4'; + shortcut: Character escape asKeyCombination; + action: [ 'Test 4' crTrace ] ] ]; + open +] + { #category : #'*Spec2-Examples' } SpListViewPresenter class >> exampleWithIcons [ "This example shows how to construct a list with icons. It shows also the fact you can put any presenter inside, giving a huge power to your lists." - self new + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + selectItem: Object; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : #'*Spec2-Examples' } +SpListViewPresenter class >> exampleWithIconsMultipleSelection [ + "This example shows how to construct a list with multiple selection available. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new application: (SpApplication new useBackend: #Gtk); + beMultipleSelection; items: self environment allClasses; setup: [ :aPresenter | | presenter | @@ -31,7 +153,6 @@ SpListViewPresenter class >> exampleWithIcons [ yourself); yourself ]; bind: [ :aPresenter :aClass | | icon image label | - "this is an optimisation" icon := Smalltalk ui icons iconNamed: aClass systemIconName. image := aPresenter layout children first. image image: icon. diff --git a/src/Spec2-Tests/SpEasyListViewPresenterTest.class.st b/src/Spec2-Tests/SpEasyListViewPresenterTest.class.st new file mode 100644 index 000000000..39d627a0b --- /dev/null +++ b/src/Spec2-Tests/SpEasyListViewPresenterTest.class.st @@ -0,0 +1,62 @@ +Class { + #name : #SpEasyListViewPresenterTest, + #superclass : #SpListViewPresenterTest, + #category : #'Spec2-Tests-Core-Widgets' +} + +{ #category : #accessing } +SpEasyListViewPresenterTest >> classToTest [ + + ^ SpEasyListViewPresenter +] + +{ #category : #initialization } +SpEasyListViewPresenterTest >> initializeTestedInstance [ +] + +{ #category : #'tests - header' } +SpEasyListViewPresenterTest >> testHideHeaderTitleUnsetsTitle [ + + presenter + headerTitle: 'title'; + hideHeaderTitle. + + self deny: presenter hasHeaderTitle +] + +{ #category : #'tests - header' } +SpEasyListViewPresenterTest >> testIconFor [ + presenter + items: #(#add #back #catalog); + displayIcon: [ :item | Smalltalk ui icons iconNamed: item asSymbol ]. + self assert: (presenter iconFor: #add) equals: (Smalltalk ui icons iconNamed: #add) +] + +{ #category : #'tests - header' } +SpEasyListViewPresenterTest >> testSetHeaderTitleHasTitle [ + + presenter headerTitle: 'title'. + + self assert: presenter hasHeaderTitle +] + +{ #category : #'tests - header' } +SpEasyListViewPresenterTest >> testSetHeaderTitleSetsTitle [ + + presenter headerTitle: 'title'. + + self assert: presenter headerTitle equals: 'title' +] + +{ #category : #tests } +SpEasyListViewPresenterTest >> testWhenIconsChangedDo [ + | icon counter | + + counter := 0. + presenter whenIconsChangedDo: [ :iconBlock | + icon := iconBlock cull: #add. + counter := counter + 1 ]. + presenter displayIcon: [ :item | Smalltalk ui icons iconNamed: item asSymbol ]. + self assert: icon equals: (Smalltalk ui icons iconNamed: #add). + self assert: counter equals: 1 +] diff --git a/src/Spec2-Tests/SpListViewPresenterTest.class.st b/src/Spec2-Tests/SpListViewPresenterTest.class.st new file mode 100644 index 000000000..2fb340338 --- /dev/null +++ b/src/Spec2-Tests/SpListViewPresenterTest.class.st @@ -0,0 +1,25 @@ +Class { + #name : #SpListViewPresenterTest, + #superclass : #SpAbstractListPresenterTest, + #category : #'Spec2-Tests-Core-Widgets' +} + +{ #category : #accessing } +SpListViewPresenterTest >> classToTest [ + + ^ SpListViewPresenter +] + +{ #category : #initialization } +SpListViewPresenterTest >> initializeTestedInstance [ + + presenter + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] +] + +{ #category : #running } +SpListViewPresenterTest >> tearDown [ + + presenter withWindowDo: [ :w | w close ] +] From 3b8d7d2dbaadcce4dbeb625444511c2b3665afd4 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 3 Jul 2023 12:16:40 +0200 Subject: [PATCH 08/88] add a test to check the selection is updated even after open. --- src/Spec2-Tests/SpDropListPresenterTest.class.st | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Spec2-Tests/SpDropListPresenterTest.class.st b/src/Spec2-Tests/SpDropListPresenterTest.class.st index de5cf923a..491efcb9a 100644 --- a/src/Spec2-Tests/SpDropListPresenterTest.class.st +++ b/src/Spec2-Tests/SpDropListPresenterTest.class.st @@ -39,6 +39,21 @@ SpDropListPresenterTest >> testEmptyList [ self assert: presenter selectedIndex equals: 0 ] +{ #category : #tests } +SpDropListPresenterTest >> testSelectItemAfterOpen [ + + presenter items: #( $a $b $c ). + presenter selectItem: $c. + + [ + presenter open. + self assert: presenter selectedItem equals: $c. + presenter selectItem: $b. + self assert: presenter selectedItem equals: $b. + ] + ensure: [ presenter withWindowDo: #close ] +] + { #category : #tests } SpDropListPresenterTest >> testSetItemsWithCollectionSmallerThanSelection [ From 62454ad3dc99a514159fd0757f47c828212b4c27 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 3 Jul 2023 12:29:53 +0200 Subject: [PATCH 09/88] this should not be needed --- src/Spec2-Core/SpAbstractFormButtonPresenter.class.st | 9 --------- src/Spec2-Core/SpAbstractTextPresenter.class.st | 8 -------- 2 files changed, 17 deletions(-) diff --git a/src/Spec2-Core/SpAbstractFormButtonPresenter.class.st b/src/Spec2-Core/SpAbstractFormButtonPresenter.class.st index de14abea3..079011e48 100644 --- a/src/Spec2-Core/SpAbstractFormButtonPresenter.class.st +++ b/src/Spec2-Core/SpAbstractFormButtonPresenter.class.st @@ -26,15 +26,6 @@ SpAbstractFormButtonPresenter >> click [ self toggleState ] -{ #category : #api } -SpAbstractFormButtonPresenter >> enabled: aBoolean [ - "Set if the button is enabled." - - super enabled: aBoolean. - self changed: #enabled. - -] - { #category : #initialization } SpAbstractFormButtonPresenter >> initialize [ super initialize. diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index a3951b7b3..c640e464b 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -90,14 +90,6 @@ SpAbstractTextPresenter >> editable: aBoolean [ editable := aBoolean ] -{ #category : #api } -SpAbstractTextPresenter >> enabled: aBoolean [ - "Set if the widget is enabled (clickable or focusable)" - - super enabled: aBoolean. - self changed: #enabled: with: { aBoolean } -] - { #category : #TOREMOVE } SpAbstractTextPresenter >> hasEditingConflicts [ "Return if the text zone has editing conflicts" From c35acb3e17ad478206f4d01f30294ee749c7225a Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 3 Jul 2023 12:30:23 +0200 Subject: [PATCH 10/88] add multiselection api --- .../SpEasyListViewPresenter.class.st | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st index dfd58f07d..7da4cf891 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -31,6 +31,17 @@ SpEasyListViewPresenter class >> example [ yourself ] +{ #category : #examples } +SpEasyListViewPresenter class >> exampleMultipleSelection [ + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + beMultipleSelection; + open; + yourself +] + { #category : #examples } SpEasyListViewPresenter class >> exampleWithHeaderTitle [ @@ -84,6 +95,18 @@ SpEasyListViewPresenter >> addAction: aSpCommand [ listView addAction: aSpCommand ] +{ #category : #api } +SpEasyListViewPresenter >> beMultipleSelection [ + + listView beMultipleSelection +] + +{ #category : #api } +SpEasyListViewPresenter >> beSingleSelection [ + + listView beSingleSelection +] + { #category : #initialization } SpEasyListViewPresenter >> connectPresenters [ From c2bacdcef52b84272bb1c4e901a73e53f1622bae Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 3 Jul 2023 12:30:49 +0200 Subject: [PATCH 11/88] add an example --- src/Spec2-Examples/SpLabelPresenter.extension.st | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Spec2-Examples/SpLabelPresenter.extension.st b/src/Spec2-Examples/SpLabelPresenter.extension.st index 5366fd57a..a5aeec45e 100644 --- a/src/Spec2-Examples/SpLabelPresenter.extension.st +++ b/src/Spec2-Examples/SpLabelPresenter.extension.st @@ -9,3 +9,16 @@ SpLabelPresenter class >> example [ label: 'Label example'; open ] + +{ #category : #'*Spec2-Examples' } +SpLabelPresenter class >> exampleWithDecoration [ + "This example opens a spec window with a decorated label." + + ^ self new + label: 'Label example'; + displayColor: [ Color random ]; + displayItalic: [ :aClass | true ]; + displayBold: [ :aClass | true ]; + displayUnderline: [ :aClass | true ]; + open +] From bc509402f391ee601a186679531277994c26fbae Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 4 Jul 2023 15:59:22 +0200 Subject: [PATCH 12/88] added a morphic adapter for SpListViewPresenter --- .../SpAbstractMorphicListAdapter.class.st | 18 +++---- .../SpMorphicListAdapter.class.st | 46 ++++++++++------ .../SpMorphicListViewAdapter.class.st | 54 ++++++++++++++++++- .../SpMorphicListViewDataSource.class.st | 32 +++++++++++ 4 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st diff --git a/src/Spec2-Adapters-Morphic/SpAbstractMorphicListAdapter.class.st b/src/Spec2-Adapters-Morphic/SpAbstractMorphicListAdapter.class.st index bb0174f93..129cd49aa 100644 --- a/src/Spec2-Adapters-Morphic/SpAbstractMorphicListAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpAbstractMorphicListAdapter.class.st @@ -39,19 +39,19 @@ SpAbstractMorphicListAdapter >> addKeyBindingsTo: aWidget [ { #category : #scrolling } SpAbstractMorphicListAdapter >> configureScrolling [ - self presenter verticalAlignment - whenChangedDo: [ widget - scrollToIndex: self presenter verticalAlignment desiredVisibleRow ]. - - self presenter - whenDisplayDo: [ widget - scrollToIndex: self presenter verticalAlignment desiredVisibleRow. - self scrollingChanged ]. + | vAlignment | + + vAlignment := self presenter verticalAlignment. + vAlignment whenChangedDo: [ + widget scrollToIndex: vAlignment desiredVisibleRow ]. + self presenter whenDisplayDo: [ + widget scrollToIndex: vAlignment desiredVisibleRow. + self scrollingChanged ]. widget onAnnouncement: FTScrollingChanged send: #scrollingChanged - to: self. + to: self ] { #category : #'widget API' } diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st index f34b70a9d..690f93e98 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st @@ -38,23 +38,9 @@ SpMorphicListAdapter >> backgroundColorFor: anItem at: index [ SpMorphicListAdapter >> buildWidget [ | datasource | - datasource := SpMorphicListDataSource new. + datasource := self newDataSource. datasource model: self model. - widget := SpFTTableMorph new - dataSource: datasource; - hideColumnHeaders; - enableSearch; - beResizable; - columns: { self newListColumn }; - 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. + widget := self newTableWith: datasource. self presenter whenModelChangedDo: [ widget refresh ]. self presenter whenSelectionChangedDo: [ self refreshWidgetSelection ]. @@ -62,8 +48,8 @@ SpMorphicListAdapter >> buildWidget [ self presenter whenSearchEnabledChangedDo: [ self updateSearch ]. self refreshWidgetHeaderTitle. self refreshWidgetSelection. - self configureScrolling. + widget bindKeyCombination: Character space toAction: [ self model clickOnSelectedItem ]. @@ -109,6 +95,12 @@ SpMorphicListAdapter >> listSize [ ^ self model listSize ] +{ #category : #factory } +SpMorphicListAdapter >> newDataSource [ + + ^ SpMorphicListDataSource new +] + { #category : #factory } SpMorphicListAdapter >> newListColumn [ | column | @@ -135,6 +127,26 @@ SpMorphicListAdapter >> newListColumn [ yourself ] +{ #category : #factory } +SpMorphicListAdapter >> newTableWith: datasource [ + + ^ SpFTTableMorph new + dataSource: datasource; + hideColumnHeaders; + enableSearch; + beResizable; + columns: { self newListColumn }; + 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 +] + { #category : #'widget API' } SpMorphicListAdapter >> refreshList [ diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st index 1ec8555a1..c72665f0c 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st @@ -1,5 +1,55 @@ +" +A morphic adapter for `SpListViewPresenter` +" Class { #name : #SpMorphicListViewAdapter, - #superclass : #SpAbstractMorphicAdapter, - #category : #'Spec2-Adapters-Morphic-List' + #superclass : #SpMorphicListAdapter, + #category : #'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 + bindKeyCombination: Character space + toAction: [ self model clickOnSelectedItem ]. + + ^ widget +] + +{ #category : #factory } +SpMorphicListViewAdapter >> newDataSource [ + + ^ SpMorphicListViewDataSource new +] + +{ #category : #factory } +SpMorphicListViewAdapter >> newTableWith: datasource [ + + ^ SpFTTableMorph new + dataSource: datasource; + hideColumnHeaders; + enableSearch; + 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 +] diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st new file mode 100644 index 000000000..b9074da46 --- /dev/null +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st @@ -0,0 +1,32 @@ +" +A morphic datasource for `SpListViewPresenter`, to be used on the `SpMorphicListViewAdapter`. +" +Class { + #name : #SpMorphicListViewDataSource, + #superclass : #SpMorphicListDataSource, + #category : #'Spec2-Adapters-Morphic-ListView' +} + +{ #category : #accessing } +SpMorphicListViewDataSource >> cellColumn: column row: rowIndex [ + | cell contentPresenter | + + cell := FTCellMorph new. + + contentPresenter := self model setupAction value: self model. + self model bindAction + value: contentPresenter + value: (self elementAt: rowIndex). + + ^ cell addMorphBack: contentPresenter build +] + +{ #category : #accessing } +SpMorphicListViewDataSource >> headerColumn: column [ + + column id ifNil: [ ^ nil ]. + ^ FTCellMorph new + listCentering: #left; + addMorph: column id asMorph asReadOnlyMorph; + yourself +] From 0e1ea48e2693c80c0d28abe11acf033652b29ea9 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 4 Jul 2023 16:06:38 +0200 Subject: [PATCH 13/88] add a `selectItem:scrollToSelection:` API --- src/Spec2-Core/SpAbstractListPresenter.class.st | 11 +++++++++++ src/Spec2-Examples/SpListPresenter.extension.st | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Spec2-Core/SpAbstractListPresenter.class.st b/src/Spec2-Core/SpAbstractListPresenter.class.st index 65fff54db..ad303890e 100644 --- a/src/Spec2-Core/SpAbstractListPresenter.class.st +++ b/src/Spec2-Core/SpAbstractListPresenter.class.st @@ -330,6 +330,17 @@ SpAbstractListPresenter >> selectItem: anItem [ self selectionMode selectItem: anItem ] +{ #category : #'api - selection' } +SpAbstractListPresenter >> selectItem: anItem scrollToSelection: shouldScrollToSelection [ + "Select item `anItem`. + If `shouldScrollToSelection` is true, selection will scroll the presenter view + to show selected element." + + self + selectIndex: (self items indexOf: anItem) + scrollToSelection: shouldScrollToSelection +] + { #category : #'api - selection' } SpAbstractListPresenter >> selectItems: aCollection [ "Select items included in `aCollection` if they are included in model list. diff --git a/src/Spec2-Examples/SpListPresenter.extension.st b/src/Spec2-Examples/SpListPresenter.extension.st index d4219d3e4..50a4184bb 100644 --- a/src/Spec2-Examples/SpListPresenter.extension.st +++ b/src/Spec2-Examples/SpListPresenter.extension.st @@ -75,3 +75,14 @@ SpListPresenter class >> exampleWithIcons [ open; yourself ] + +{ #category : #'*Spec2-Examples' } +SpListPresenter class >> exampleWithIconsAndSelectedItem [ + + ^ self new + displayIcon: [ :aClass | self iconNamed: aClass systemIconName ]; + items: Smalltalk allClasses; + selectItem: Object scrollToSelection: true; + open; + yourself +] From 08e51362d72b2e84f4f1a9997614413c2d12f8b0 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 4 Jul 2023 16:07:30 +0200 Subject: [PATCH 14/88] add ports to easy list --- .../SpEasyListViewPresenter.extension.st | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Spec2-Transmission/SpEasyListViewPresenter.extension.st diff --git a/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st b/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st new file mode 100644 index 000000000..f16d58705 --- /dev/null +++ b/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st @@ -0,0 +1,37 @@ +Extension { #name : #SpEasyListViewPresenter } + +{ #category : #'*Spec2-Transmission' } +SpEasyListViewPresenter >> defaultInputPort [ + + ^ self inputItemsPort +] + +{ #category : #'*Spec2-Transmission' } +SpEasyListViewPresenter >> defaultOutputPort [ + + ^ self outputSelectionPort +] + +{ #category : #'*Spec2-Transmission' } +SpEasyListViewPresenter >> inputItemsPort [ + + ^ (SpListItemsPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] + +{ #category : #'*Spec2-Transmission' } +SpEasyListViewPresenter >> outputActivationPort [ + + ^ (SpActivationPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] + +{ #category : #'*Spec2-Transmission' } +SpEasyListViewPresenter >> outputSelectionPort [ + + ^ (SpSelectionPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] From f378ea9643137cad82a45f1968a082d0ad8d9aad Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 4 Jul 2023 16:09:01 +0200 Subject: [PATCH 15/88] add a flag to rememeber to change list with easyList --- src/Spec2-Core/SpTPresenterBuilder.trait.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index e9e80a108..5a6430b82 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -101,7 +101,7 @@ SpTPresenterBuilder >> newDynamicPresentersListIn: accessorSymbol usingBuilder: { #category : #'scripting - lists' } SpTPresenterBuilder >> newEasyListView [ - + self flag: #TODO. "replace newList with this" ^ self instantiate: SpEasyListViewPresenter ] From 6eb4a2214867e4f217cc7c478daee3d7ddb14bd5 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:14:44 +0200 Subject: [PATCH 16/88] fix and error while hiding component (the place in layout should not be taken, intead the visible components should take all place avaiable) --- ...hicBoxLayoutCalculatorLeftToRight.class.st | 11 ++++--- ...hicBoxLayoutCalculatorTopToBottom.class.st | 31 ++++++++++--------- .../SpMorphicLayoutAdapter.class.st | 20 ++++++------ .../SpListViewPresenter.extension.st | 10 +++--- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st index ed47394cf..78152c462 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st @@ -51,7 +51,7 @@ SpMorphicBoxLayoutCalculatorLeftToRight >> calculateCellFor: aMorph [ { #category : #calculating } SpMorphicBoxLayoutCalculatorLeftToRight >> calculateFor: aMorph in: newBounds [ "An optimized left-to-right list layout" - | inset extent posX posY centering extraPerCell cell amount last | + | inset extent posX posY centering extraPerCell cell amount last submorphs | size := properties minCellSize asPoint. minX := size x. minY := size y. size := properties maxCellSize asPoint. maxX := size x. maxY := size y. @@ -61,9 +61,12 @@ SpMorphicBoxLayoutCalculatorLeftToRight >> calculateFor: aMorph in: newBounds [ width := height := 0. firstCell := lastCell := nil. - properties reverseTableCells - ifTrue:[ aMorph submorphsReverseDo: [ :each | self calculateCellFor: each ] ] - ifFalse:[ aMorph submorphsDo: [ :each | self calculateCellFor: each ] ]. + submorphs := aMorph submorphs. + properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. + submorphs do: [ :each | + each visible + ifTrue: [ self calculateCellFor: each ] + ifFalse: [ each privateBounds: (each bounds topLeft extent: 0@0) ] ]. number > 1 ifTrue:[ width := width + ((number-1) * inset) ]. diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st index 1eb68544f..92ac06e0c 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st @@ -8,41 +8,41 @@ Class { } { #category : #calculating } -SpMorphicBoxLayoutCalculatorTopToBottom >> calculateCellFor: m [ +SpMorphicBoxLayoutCalculatorTopToBottom >> calculateCellFor: aMorph [ | sizeX props sizeY cell | - props := m layoutProperties ifNil:[m]. + props := aMorph layoutProperties ifNil:[aMorph]. props disableTableLayout ifTrue:[ ^ self ]. number := number + 1. - cell := LayoutCell new target: m. + cell := LayoutCell new target: aMorph. (props vResizing == #spaceFill) ifTrue:[ cell vSpaceFill: true. - extra := m spaceFillWeight. + extra := aMorph spaceFillWeight. cell extraSpace: extra. sum := sum + extra. ] ifFalse:[cell vSpaceFill: false]. (props hResizing == #spaceFill) ifTrue:[vFill := true]. - size := m minExtent. sizeX := size x. sizeY := size y. + size := aMorph minExtentWithVisibility. sizeX := size x. sizeY := size y. sizeX < minX ifTrue:[sizeX := minX] ifFalse:[sizeX > maxX ifTrue:[sizeX := maxX]]. - sizeY < minY + + ((sizeY < minY) or: [ aMorph visible not ]) ifTrue:[sizeY := minY] ifFalse:[sizeY > maxY ifTrue:[sizeY := maxY]]. cell cellSize: sizeY. - firstCell ifNil:[firstCell := cell] ifNotNil:[lastCell nextCell: cell]. + firstCell ifNil:[ firstCell := cell ] ifNotNil:[ lastCell nextCell: cell ]. lastCell := cell. height := height + sizeY. - sizeX > width ifTrue:[width := sizeX]. - + sizeX > width ifTrue:[ width := sizeX ] ] { #category : #calculating } SpMorphicBoxLayoutCalculatorTopToBottom >> calculateFor: aMorph in: newBounds [ "An optimized top-to-bottom list layout" - | inset extent posX posY centering extraPerCell cell amount last | + | inset extent posX posY centering extraPerCell cell amount last submorphs | size := properties minCellSize asPoint. minX := size x. minY := size y. size := properties maxCellSize asPoint. maxX := size x. maxY := size y. @@ -52,11 +52,14 @@ SpMorphicBoxLayoutCalculatorTopToBottom >> calculateFor: aMorph in: newBounds [ width := height := 0. firstCell := lastCell := nil. - properties reverseTableCells - ifTrue:[aMorph submorphsReverseDo: [ :each | self calculateCellFor: each]] - ifFalse:[aMorph submorphsDo: [ :each | self calculateCellFor: each]]. + submorphs := aMorph submorphs. + properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. + submorphs do: [ :each | + each visible + ifTrue: [ self calculateCellFor: each ] + ifFalse: [ each privateBounds: (each bounds topLeft extent: 0@0) ] ]. - number > 1 ifTrue:[height := height + (number-1 * inset)]. + number > 1 ifTrue:[height := height + (number-1 * inset) ]. (properties vResizing == #shrinkWrap and:[properties rubberBandCells or:[sum isZero]]) ifTrue:[extent := (extent x max: width) @ height]. diff --git a/src/Spec2-Adapters-Morphic/SpMorphicLayoutAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicLayoutAdapter.class.st index f3bb3e14c..b924a88f7 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicLayoutAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicLayoutAdapter.class.st @@ -151,16 +151,16 @@ SpMorphicLayoutAdapter >> newPanel [ SpMorphicLayoutAdapter >> newPanelWith: aLayout [ ^ Morph new - layoutPolicy: aLayout; - hResizing: #spaceFill; - vResizing: #spaceFill; - color: Color transparent; - borderColor: Color transparent; - clipSubmorphs: true; - "stop being grabbed"beSticky; - borderWidth: 0; - extent: 0 @ 0; - yourself + layoutPolicy: aLayout; + hResizing: #spaceFill; + vResizing: #spaceFill; + color: Color transparent; + borderColor: Color transparent; + clipSubmorphs: true; + "stop being grabbed"beSticky; + borderWidth: 0; + extent: 0 @ 0; + yourself ] { #category : #initialization } diff --git a/src/Spec2-Examples/SpListViewPresenter.extension.st b/src/Spec2-Examples/SpListViewPresenter.extension.st index 789ef9c68..53801a14e 100644 --- a/src/Spec2-Examples/SpListViewPresenter.extension.st +++ b/src/Spec2-Examples/SpListViewPresenter.extension.st @@ -19,7 +19,7 @@ SpListViewPresenter class >> exampleReplaceItems [ items := #(). - presenter := SpPresenter newApplication: (SpApplication new useBackend: #Gtk). + presenter := SpPresenter newApplication: (SpApplication new "useBackend: #Gtk"). presenter layout: (SpBoxLayout newVertical add: (listView := presenter newListView); add: (button := presenter newButton) expand: false; @@ -85,7 +85,7 @@ SpListViewPresenter class >> exampleWithIcons [ to your lists." ^ self new - application: (SpApplication new useBackend: #Gtk); + "application: (SpApplication new useBackend: #Gtk);" items: self environment allClasses; setup: [ :aPresenter | | presenter | @@ -112,9 +112,9 @@ SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ to your lists." ^ self new - application: (SpApplication new useBackend: #Gtk); + "application: (SpApplication new useBackend: #Gtk);" items: self environment allClasses; - selectItem: Object; + selectItem: Object scrollToSelection: true; setup: [ :aPresenter | | presenter | (presenter := aPresenter newPresenter) @@ -140,7 +140,7 @@ SpListViewPresenter class >> exampleWithIconsMultipleSelection [ to your lists." ^ self new - application: (SpApplication new useBackend: #Gtk); + "application: (SpApplication new useBackend: #Gtk);" beMultipleSelection; items: self environment allClasses; setup: [ :aPresenter | From 7c7f0c48e8ecd5becb97e04dadac3ac5f58a4533 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:15:20 +0200 Subject: [PATCH 17/88] fix call to event --- .../SpAbstractMorphicAdapter.class.st | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st b/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st index 3b369fc5e..27f408f46 100644 --- a/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpAbstractMorphicAdapter.class.st @@ -4,6 +4,9 @@ I am an abstract class providing all the properties shared amongs all the morphi Class { #name : #SpAbstractMorphicAdapter, #superclass : #SpAbstractAdapter, + #instVars : [ + 'savedExtentBeforeHide' + ], #category : #'Spec2-Adapters-Morphic-Base' } @@ -122,8 +125,8 @@ SpAbstractMorphicAdapter >> applyStyle: morph [ { #category : #initialization } SpAbstractMorphicAdapter >> applyVisibility [ - "It may happen that some presenters use generic adapters and they do not have an associated presenter. - In that case, do not manage visibility..." + "It may happen that some presenters use generic adapters and they do not have an + associated presenter. In that case, do not manage visibility..." self presenter ifNil: [ ^ self ]. self widget visible: self presenter isVisible. @@ -326,7 +329,7 @@ SpAbstractMorphicAdapter >> installFocusReceivedEvent: anEvent to: aWidget [ aWidget announcer when: MorphGotFocus - do: [ anEvent action value ] + do: [ anEvent action cull: anEvent ] ] { #category : #'event installing' } From b73fead6966fb86a6a159ef44f139c6982f79cf7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:16:19 +0200 Subject: [PATCH 18/88] add action to compatibility with adapter --- src/Spec2-Core/SpToolbarButtonPresenter.class.st | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Spec2-Core/SpToolbarButtonPresenter.class.st b/src/Spec2-Core/SpToolbarButtonPresenter.class.st index 052f317dd..89d21bae4 100644 --- a/src/Spec2-Core/SpToolbarButtonPresenter.class.st +++ b/src/Spec2-Core/SpToolbarButtonPresenter.class.st @@ -103,6 +103,12 @@ SpToolbarButtonPresenter >> label: aString [ label := aString ] +{ #category : #private } +SpToolbarButtonPresenter >> performAction [ + + self action value +] + { #category : #'api - events' } SpToolbarButtonPresenter >> whenIconChangedDo: aBlock [ "Inform when icon property has changed. From 9b6efc6cdf24a68170190fd1d408a0f4d9c69eab Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:16:47 +0200 Subject: [PATCH 19/88] use scroll to selection and play with search place --- src/Spec2-Core/SpEasyListViewPresenter.class.st | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st index 7da4cf891..88caaf072 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -144,7 +144,7 @@ SpEasyListViewPresenter >> defaultLayout [ add: headerPanel expand: false; add: listView; yourself); - addOverlay: searchInput withConstraints: [ :c | c vAlignEnd; hAlignEnd ]; + addOverlay: searchInput withConstraints: [ :c | c vAlignStart; hAlignEnd ]; yourself ] @@ -292,10 +292,10 @@ SpEasyListViewPresenter >> maybeActivateSearchOn: event [ self isSearchEnabled ifFalse: [ ^ self ]. "any modifier other than shift?" - (event modifiers any + (event anyModifierKeyPressed or: [ (event keyValue between: 32 and: 127) not ]) ifTrue: [ ^ self ]. - self activateSearchWith: event character asString + self activateSearchWith: event keyCharacter asString ] { #category : #initialization } @@ -313,7 +313,7 @@ SpEasyListViewPresenter >> selectFirst: aString [ index := self findFirst: aString. index = 0 ifTrue: [ ^ self ]. - listView selectIndex: index + listView selectIndex: index scrollToSelection: true ] { #category : #'api - events' } From 503e34f9fa46bbd99ba09452d0e40da20c851245 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:17:19 +0200 Subject: [PATCH 20/88] prevent divide by zero in some cases (like invisible calculations) --- src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st | 6 ++++++ src/Spec2-Adapters-Morphic/SpRubTextFieldMorph.class.st | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st b/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st index 337eebdae..adbdae466 100644 --- a/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st +++ b/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st @@ -10,6 +10,12 @@ SpRubTextFieldArea >> defaultBounds [ ^ super defaultBounds topLeft extent: 3@3 ] +{ #category : #geometry } +SpRubTextFieldArea >> height [ + + ^ super height max: 1 +] + { #category : #accessing } SpRubTextFieldArea >> updateMarginsWithHeight: aNumber [ | minHeight newMargin | diff --git a/src/Spec2-Adapters-Morphic/SpRubTextFieldMorph.class.st b/src/Spec2-Adapters-Morphic/SpRubTextFieldMorph.class.st index 690d1c975..5b5446f86 100644 --- a/src/Spec2-Adapters-Morphic/SpRubTextFieldMorph.class.st +++ b/src/Spec2-Adapters-Morphic/SpRubTextFieldMorph.class.st @@ -39,7 +39,7 @@ SpRubTextFieldMorph >> drawKeyboardFocusOn: aCanvas [ SpRubTextFieldMorph >> extent: aPoint [ self updateTextAreaMarginsWith: aPoint y. - super extent: aPoint + super extent: aPoint ] { #category : #initialization } From 796552725ddbeb7120d4b846946db2c95da498e6 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:18:16 +0200 Subject: [PATCH 21/88] no predefined search on listview (or default action) --- src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st index c72665f0c..2ecb8b8c5 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st @@ -22,10 +22,6 @@ SpMorphicListViewAdapter >> buildWidget [ self refreshWidgetSelection. self configureScrolling. - widget - bindKeyCombination: Character space - toAction: [ self model clickOnSelectedItem ]. - ^ widget ] From 9169e1d348fff36d71c1ff2a318ec382c0e2019f Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:18:43 +0200 Subject: [PATCH 22/88] no search on list view --- src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st index 2ecb8b8c5..10e1c2874 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st @@ -35,9 +35,9 @@ SpMorphicListViewAdapter >> newDataSource [ SpMorphicListViewAdapter >> newTableWith: datasource [ ^ SpFTTableMorph new + disableFunction; dataSource: datasource; hideColumnHeaders; - enableSearch; beResizable; setMultipleSelection: self model isMultipleSelection; dragEnabled: self dragEnabled; From 8eaaa70883ffed35f597ef72953410a22522a909 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:19:05 +0200 Subject: [PATCH 23/88] add some #doNotUse flags --- src/Spec2-Layout/SpBoxLayout.class.st | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Spec2-Layout/SpBoxLayout.class.st b/src/Spec2-Layout/SpBoxLayout.class.st index 7f5be97b3..1ce313c25 100644 --- a/src/Spec2-Layout/SpBoxLayout.class.st +++ b/src/Spec2-Layout/SpBoxLayout.class.st @@ -258,6 +258,8 @@ SpBoxLayout >> addLast: aName [ - another layout or - a Symbol, matching the name of the instance variable who will contain the element to add." + self flag: #doNotUse. + self addLast: aName withConstraints: [ :constraints | ] @@ -274,6 +276,8 @@ SpBoxLayout >> addLast: aName expand: shouldExpand [ `shouldExpand` is a boolean indicating whether the new child is to be given extra space allocated to the box." + self flag: #doNotUse. + self addLast: aName withConstraints: [ :constraints | @@ -283,6 +287,8 @@ SpBoxLayout >> addLast: aName expand: shouldExpand [ { #category : #private } SpBoxLayout >> addLast: aName expand: shouldExpand fill: shouldFill [ + self flag: #doNotUse. + self addLast: aName withConstraints: [ :constraints | @@ -294,6 +300,8 @@ SpBoxLayout >> addLast: aName expand: shouldExpand fill: shouldFill [ { #category : #private } SpBoxLayout >> addLast: aName expand: shouldExpand fill: shouldFill padding: aNumber [ + self flag: #doNotUse. + self addLast: aName withConstraints: [ :constraints | @@ -316,6 +324,8 @@ SpBoxLayout >> addLast: aName withConstraints: aBlock [ NOTICE that the direct usage of this method is NOT recommended. Consider using add:/add:expand: instead" + self flag: #doNotUse. + self add: aName withConstraints: [ :constraints | From 4184efec3c41b09833c316d69e35df2a7a6458f6 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 8 Jul 2023 08:41:36 +0200 Subject: [PATCH 24/88] oops --- .../SpMorphicBoxLayoutCalculatorTopToBottom.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st index 92ac06e0c..3544a2e42 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st @@ -23,7 +23,7 @@ SpMorphicBoxLayoutCalculatorTopToBottom >> calculateCellFor: aMorph [ sum := sum + extra. ] ifFalse:[cell vSpaceFill: false]. (props hResizing == #spaceFill) ifTrue:[vFill := true]. - size := aMorph minExtentWithVisibility. sizeX := size x. sizeY := size y. + size := aMorph minExtent. sizeX := size x. sizeY := size y. sizeX < minX ifTrue:[sizeX := minX] ifFalse:[sizeX > maxX ifTrue:[sizeX := maxX]]. From 1fce8f9059f9f191c8822db66b11d870a1ca5de7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 13 Jul 2023 08:00:32 +0200 Subject: [PATCH 25/88] fix shortcuts when they have no name --- src/Spec2-Commander2/SpCommand.class.st | 10 ++++++++-- src/Spec2-Core/SpAbstractTextPresenter.class.st | 2 +- src/Spec2-Core/SpAction.class.st | 15 +++++++++++++-- src/Spec2-Core/SpActionGroup.class.st | 10 ++++++++++ src/Spec2-Core/SpListViewPresenter.class.st | 2 +- src/Spec2-Core/SpTActionContainer.trait.st | 6 ++++++ 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/Spec2-Commander2/SpCommand.class.st b/src/Spec2-Commander2/SpCommand.class.st index 7110fab25..b749acbf0 100644 --- a/src/Spec2-Commander2/SpCommand.class.st +++ b/src/Spec2-Commander2/SpCommand.class.st @@ -89,8 +89,14 @@ SpCommand >> iconProvider [ SpCommand >> id [ ^ String streamContents: [ :stream | - | parts | - parts := (self name ifNil: [ 'unknown' ]) substrings. + | parts name | + + name := self name + ifNil: [ + self shortcutKey + ifNotNil: [ 'shortcut ', self shortcutKey asString ] + ifNil: [ 'unknown' ] ]. + parts := name substrings. stream << parts first asLowercase. parts allButFirstDo: [ :each | stream << each capitalized ] ] ] diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index c640e464b..2f45eb720 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -218,7 +218,7 @@ SpAbstractTextPresenter >> readSelectionBlock: aBlock [ SpAbstractTextPresenter >> registerActions [ self addActionWith: [ :action | action - beOnlyShortcut; + beShortcutOnly; shortcut: $t ctrl unix | $t ctrl win | $t command mac; action: [ self showContextMenu ] ] ] diff --git a/src/Spec2-Core/SpAction.class.st b/src/Spec2-Core/SpAction.class.st index 9fda6f469..3785a27c2 100644 --- a/src/Spec2-Core/SpAction.class.st +++ b/src/Spec2-Core/SpAction.class.st @@ -40,7 +40,7 @@ SpAction class >> newShortcut: aShortcut action: aBlock [ name: aShortcut asString; shortcutKey: aShortcut; action: aBlock; - beOnlyShortcut; + beShortcutOnly; yourself ] @@ -63,7 +63,7 @@ SpAction >> actionVisible: aBlock [ ] { #category : #accessing } -SpAction >> beOnlyShortcut [ +SpAction >> beShortcutOnly [ visible := false ] @@ -101,6 +101,17 @@ SpAction >> isVisible [ and: [ actionVisible isNil or: [ actionVisible value ] ] ] +{ #category : #printing } +SpAction >> printOn: stream [ + + stream << 'a SpAction('. + stream << 'Name: ' << (self name ifNil: [ 'No name' ]). + stream << ' Shortcut: ' << (self shortcutKey + ifNotNil: [ :key | key asString ] + ifNil: [ 'No shortcut' ]). + stream << ')' +] + { #category : #accessing } SpAction >> shortcut: aKeyCombination [ "just a synonym" diff --git a/src/Spec2-Core/SpActionGroup.class.st b/src/Spec2-Core/SpActionGroup.class.st index 4cdab6c4a..433315128 100644 --- a/src/Spec2-Core/SpActionGroup.class.st +++ b/src/Spec2-Core/SpActionGroup.class.st @@ -48,6 +48,16 @@ SpActionGroup >> addGroupWith: aBlock [ ] +{ #category : #accessing } +SpActionGroup >> addShortcutWith: aBlock [ + | action | + + action := SpAction new. + action beShortcutOnly. + aBlock value: action. + self add: action +] + { #category : #initialization } SpActionGroup >> initialize [ diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-Core/SpListViewPresenter.class.st index 578d7de17..694c5d8af 100644 --- a/src/Spec2-Core/SpListViewPresenter.class.st +++ b/src/Spec2-Core/SpListViewPresenter.class.st @@ -70,7 +70,7 @@ SpListViewPresenter >> initializeItemFactory [ SpListViewPresenter >> registerActions [ self addActionWith: [ :action | action - beOnlyShortcut; + beShortcutOnly; shortcut: $t ctrl unix | $t ctrl win | $t command mac; action: [ self showContextMenu ] ] ] diff --git a/src/Spec2-Core/SpTActionContainer.trait.st b/src/Spec2-Core/SpTActionContainer.trait.st index bab7b8d45..fcc69ead0 100644 --- a/src/Spec2-Core/SpTActionContainer.trait.st +++ b/src/Spec2-Core/SpTActionContainer.trait.st @@ -39,6 +39,12 @@ SpTActionContainer >> addActionWith: aBlock [ self ensureActionGroup addActionWith: aBlock ] +{ #category : #'api - actions' } +SpTActionContainer >> addShortcutWith: aBlock [ + + self ensureActionGroup addShortcutWith: aBlock +] + { #category : #private } SpTActionContainer >> ensureActionGroup [ From 31b963c9489a3fa030def61b7662b815d91d81f4 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 13 Jul 2023 08:01:43 +0200 Subject: [PATCH 26/88] moved to gtk package --- src/Spec2-Commander2/SpCommand.class.st | 16 ---------------- src/Spec2-Commander2/SpCommandGroup.class.st | 10 ---------- 2 files changed, 26 deletions(-) diff --git a/src/Spec2-Commander2/SpCommand.class.st b/src/Spec2-Commander2/SpCommand.class.st index b749acbf0..1d91b21c8 100644 --- a/src/Spec2-Commander2/SpCommand.class.st +++ b/src/Spec2-Commander2/SpCommand.class.st @@ -85,22 +85,6 @@ SpCommand >> iconProvider [ ^ iconProvider ] -{ #category : #accessing } -SpCommand >> id [ - - ^ String streamContents: [ :stream | - | parts name | - - name := self name - ifNil: [ - self shortcutKey - ifNotNil: [ 'shortcut ', self shortcutKey asString ] - ifNil: [ 'unknown' ] ]. - parts := name substrings. - stream << parts first asLowercase. - parts allButFirstDo: [ :each | stream << each capitalized ] ] -] - { #category : #initialization } SpCommand >> initialize [ diff --git a/src/Spec2-Commander2/SpCommandGroup.class.st b/src/Spec2-Commander2/SpCommandGroup.class.st index 1add2bfcc..df6649ce7 100644 --- a/src/Spec2-Commander2/SpCommandGroup.class.st +++ b/src/Spec2-Commander2/SpCommandGroup.class.st @@ -114,16 +114,6 @@ SpCommandGroup >> iconProvider: anIconProvider [ iconProvider := anIconProvider ] -{ #category : #accessing } -SpCommandGroup >> id [ - - ^ String streamContents: [ :stream | - | parts | - parts := (self name ifNil: [ 'unknown' ]) substrings. - stream << parts first asLowercase. - parts allButFirstDo: [ :each | stream << each capitalized ] ] -] - { #category : #initialization } SpCommandGroup >> initialize [ From 06573de85c66e17ad7d0448574e4454732d57b3f Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 13 Jul 2023 08:01:53 +0200 Subject: [PATCH 27/88] enhanced a bit --- src/Spec2-Examples/SpPopoverExample.class.st | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Spec2-Examples/SpPopoverExample.class.st b/src/Spec2-Examples/SpPopoverExample.class.st index e6327d567..cfe0b7ff6 100644 --- a/src/Spec2-Examples/SpPopoverExample.class.st +++ b/src/Spec2-Examples/SpPopoverExample.class.st @@ -30,13 +30,14 @@ SpPopoverExample class >> open [ SpPopoverExample >> defaultLayout [ ^ SpBoxLayout newLeftToRight - hAlignCenter; - vAlignCenter; - add: top expand: false; - add: left expand: false; - add: bottom expand: false; - add: right expand: false; - yourself + spacing: 5; + hAlignCenter; + vAlignCenter; + add: left expand: false; + add: top expand: false; + add: bottom expand: false; + add: right expand: false; + yourself ] { #category : #initialization } From 456ff6dd1b25d9219a664ff7354e24189c8361cf Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 13 Jul 2023 12:36:36 +0200 Subject: [PATCH 28/88] adding a lot of warining comments to make people understand just the fact they can define actions on any presenter that does no means they will actually *get them* (because you need the focus for it). --- src/Spec2-Core/SpTActionContainer.trait.st | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Spec2-Core/SpTActionContainer.trait.st b/src/Spec2-Core/SpTActionContainer.trait.st index fcc69ead0..1bd498858 100644 --- a/src/Spec2-Core/SpTActionContainer.trait.st +++ b/src/Spec2-Core/SpTActionContainer.trait.st @@ -14,6 +14,10 @@ SpTActionContainer >> actionGroup [ { #category : #'api - actions' } SpTActionContainer >> actionGroup: aSpCommandGroup [ + "WARNING. Defining action in presenters that are not able to grab the keyboard focus + is mostly useless (because they will never have the focus to answer to). + Shortcut actions, however, can be installed and they will be available in children + presenters when they are focused." aSpCommandGroup beRoot. actionGroup := aSpCommandGroup @@ -22,6 +26,10 @@ SpTActionContainer >> actionGroup: aSpCommandGroup [ { #category : #'api - actions' } SpTActionContainer >> actionsWith: aBlock [ + "WARNING. Defining action in presenters that are not able to grab the keyboard focus + is mostly useless (because they will never have the focus to answer to). + Shortcut actions, however, can be installed and they will be available in children + presenters when they are focused." actionGroup := nil. aBlock value: self ensureActionGroup @@ -30,7 +38,7 @@ SpTActionContainer >> actionsWith: aBlock [ { #category : #'api - actions' } SpTActionContainer >> addAction: aSpCommand [ - self ensureActionGroup register: aSpCommand + self ensureActionGroup add: aSpCommand ] { #category : #'api - actions' } @@ -41,6 +49,10 @@ SpTActionContainer >> addActionWith: aBlock [ { #category : #'api - actions' } SpTActionContainer >> addShortcutWith: aBlock [ + "WARNING. Defining action in presenters that are not able to grab the keyboard focus + is mostly useless (because they will never have the focus to answer to). + Shortcut actions, however, can be installed and they will be available in children + presenters when they are focused." self ensureActionGroup addShortcutWith: aBlock ] From 0fd5a43e404ca868555e793e94b492f3363dae75 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 1 Aug 2023 11:22:55 +0200 Subject: [PATCH 29/88] lot of work on SpDropListPresenter and SpDropDownPresenter --- .../SpAbstractListPresenter.class.st | 203 +---------------- src/Spec2-Core/SpDropDownPresenter.class.st | 191 ++++++++++++++++ .../SpEasyListViewPresenter.class.st | 2 +- src/Spec2-Core/SpListViewPresenter.class.st | 22 -- src/Spec2-Core/SpTSelectionMode.trait.st | 208 ++++++++++++++++++ .../SpDropDownPresenter.extension.st | 56 +++++ .../SpDropListPresenter.extension.st | 16 ++ 7 files changed, 474 insertions(+), 224 deletions(-) create mode 100644 src/Spec2-Core/SpDropDownPresenter.class.st create mode 100644 src/Spec2-Core/SpTSelectionMode.trait.st create mode 100644 src/Spec2-Examples/SpDropDownPresenter.extension.st diff --git a/src/Spec2-Core/SpAbstractListPresenter.class.st b/src/Spec2-Core/SpAbstractListPresenter.class.st index ad303890e..5d7943e0b 100644 --- a/src/Spec2-Core/SpAbstractListPresenter.class.st +++ b/src/Spec2-Core/SpAbstractListPresenter.class.st @@ -4,10 +4,9 @@ A base for list presenters, it defines basic functionality common to all lists. Class { #name : #SpAbstractListPresenter, #superclass : #SpAbstractWidgetPresenter, - #traits : 'SpTHaveWrappingScrollBars + SpTContextMenu + SpTAlignableColumn', - #classTraits : 'SpTHaveWrappingScrollBars classTrait + SpTContextMenu classTrait + SpTAlignableColumn classTrait', + #traits : 'SpTHaveWrappingScrollBars + SpTContextMenu + SpTAlignableColumn + SpTSelectionMode', + #classTraits : 'SpTHaveWrappingScrollBars classTrait + SpTContextMenu classTrait + SpTAlignableColumn classTrait + SpTSelectionMode classTrait', #instVars : [ - '#selectionMode', '#activationBlock', '#activateOnSingleClick', '#model', @@ -266,138 +265,6 @@ SpAbstractListPresenter >> registerEvents [ self withAdapterDo: [ :anAdapter | anAdapter updateMenu ] ] ] -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectAll [ - "Select all items in the list or table. - It does not triggers activation event." - - self selection selectAll -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectFirst [ - "Select first element in list. - Useful to avoid selecting by index." - - ^ self selectIndex: 1 -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectIndex: anInteger [ - "Select item at position `anInteger`. - Selection will not scroll the presenter view to show selected element." - - self selectionMode selectIndex: anInteger -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectIndex: anIndex scrollToSelection: shouldScrollToSelection [ - "Select item at position `anInteger`. - If `shouldScrollToSelection` is true, selection will scroll the presenter view - to show selected element." - - self selectIndex: anIndex. - shouldScrollToSelection ifTrue: [ - self verticalAlignment desiredVisibleRow: anIndex ]. -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectIndexes: aCollectionOfIndexes [ - "Select items at positions included in `aCollectionOfIndexes`. - NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. - Selection will not scroll the presenter view to show selected(s) element(s)." - - self selectionMode selectIndexes: aCollectionOfIndexes -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectIndexes: aCollectionOfIndexes scrollToSelection: shouldScrollToSelection [ - "Select items at positions included in `aCollectionOfIndexes`. - NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. - If `shouldScrollToSelection` is true, selection will scroll the presenter view - to show first selected element." - - self selectIndexes: aCollectionOfIndexes. - shouldScrollToSelection ifTrue: [ - self verticalAlignment desiredVisibleRow: aCollectionOfIndexes first ]. -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectItem: anItem [ - "Select `anItem` if it is included in model list. - It does not scrolls to selected element." - - self selectionMode selectItem: anItem -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectItem: anItem scrollToSelection: shouldScrollToSelection [ - "Select item `anItem`. - If `shouldScrollToSelection` is true, selection will scroll the presenter view - to show selected element." - - self - selectIndex: (self items indexOf: anItem) - scrollToSelection: shouldScrollToSelection -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectItems: aCollection [ - "Select items included in `aCollection` if they are included in model list. - NOTE: In single selection mode it will select the first element of `aCollection` - It does not scrolls to selected element." - - self selectionMode selectItems: aCollection -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectedItem [ - "Return selected item." - - ^ self selection selectedItem -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectedItems [ - "Return all the selected items in the case of a multiple selection list" - - ^ self selection selectedItems -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectedItemsSorted [ - "Return all the selected items sorted by their index" - - ^ self itemsAt: self selection selectedIndexes sort -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selection [ - "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). - This is not the item selected, but the selection container (it may contain one or many selected - items)" - - ^ selectionMode -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectionMode [ - "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). - This is not the item selected, but the selection container (it may contain one or many selected - items). - This is the same as `SpAbstractListPresenter>>#selection`" - - ^ selectionMode -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> selectionMode: aMode [ - - selectionMode ifNotNil: [ - selectionMode transferSubscriptionsTo: aMode ]. - selectionMode := aMode -] - { #category : #api } SpAbstractListPresenter >> sortingBlock [ "Answer the sorting block defined to sort the model list. @@ -417,27 +284,6 @@ SpAbstractListPresenter >> sortingBlock: aBlock [ self model sortingBlock: aBlock ] -{ #category : #'api - selection' } -SpAbstractListPresenter >> unselectAll [ - "Remove all selections" - - self selection unselectAll -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> unselectIndex: anInteger [ - "Remove selection of element at index `anInteger`" - - self selection unselectIndex: anInteger -] - -{ #category : #'api - selection' } -SpAbstractListPresenter >> unselectItem: anObject [ - "Remove selection of element `anObject`" - - self selection unselectItem: anObject -] - { #category : #api } SpAbstractListPresenter >> updateItemsKeepingSelection: aCollection [ "Update list items keeping current selection. @@ -475,16 +321,6 @@ SpAbstractListPresenter >> whenModelChangedDo: aBlock [ model whenChangedDo: aBlock ] -{ #category : #'api - events' } -SpAbstractListPresenter >> whenNoneSelectedDo: aBlock [ - "Inform when the list has clean selection (there are no items selected). - `aBlock` receives zero arguments" - - self whenSelectionChangedDo: [ :selection | - selection selectedItem - ifNil: [ aBlock value ] ] -] - { #category : #'api - events' } SpAbstractListPresenter >> whenSearchEnabledChangedDo: aBlock [ "Inform when search enabled/disabled has changed. @@ -493,41 +329,6 @@ SpAbstractListPresenter >> whenSearchEnabledChangedDo: aBlock [ self property: #searchEnabled whenChangedDo: aBlock ] -{ #category : #'api - events' } -SpAbstractListPresenter >> whenSelectedDo: aBlock [ - "Inform when an item was selected (a real object in the items list). - `aBlock` receives one argument (the new selected element)" - - self whenSelectionChangedDo: [ :selection | - selection selectedItem - ifNotNil: [ :item | aBlock value: item ] ] -] - -{ #category : #'api - events' } -SpAbstractListPresenter >> whenSelectedItemChangedDo: aBlock [ - "Inform when the selected item is changed. - `aBlock` receive one optional argument: the selected item (can be nil)" - - self selection whenChangedDo: [ aBlock cull: self selectedItem ] -] - -{ #category : #'api - events' } -SpAbstractListPresenter >> whenSelectionChangedDo: aBlock [ - "Inform when there are changes in selection. - This method works for all selection modes (single, multiple and no selection). - `aBlock` receives an optional argument with the selection object." - - self selection whenChangedDo: aBlock -] - -{ #category : #'api - events' } -SpAbstractListPresenter >> whenSelectionModeChangedDo: aBlock [ - "Inform when selection mode (single/multiple) changed. - `aBlock` receives zero arguments." - - selectionMode whenChangedDo: aBlock -] - { #category : #'api - events' } SpAbstractListPresenter >> whenSortingBlockChangedDo: aBlock [ "Inform when sorting block changed. diff --git a/src/Spec2-Core/SpDropDownPresenter.class.st b/src/Spec2-Core/SpDropDownPresenter.class.st new file mode 100644 index 000000000..e587ba9f5 --- /dev/null +++ b/src/Spec2-Core/SpDropDownPresenter.class.st @@ -0,0 +1,191 @@ +Class { + #name : #SpDropDownPresenter, + #superclass : #SpAbstractWidgetPresenter, + #instVars : [ + 'setupAction', + 'bindAction', + 'model', + 'display', + 'selection' + ], + #category : #'Spec2-Core-Widgets-ListView' +} + +{ #category : #specs } +SpDropDownPresenter class >> adapterName [ + + ^ #DropDownAdapter +] + +{ #category : #api } +SpDropDownPresenter >> bind: aBlock [ + + bindAction := aBlock +] + +{ #category : #private } +SpDropDownPresenter >> bindAction [ + + ^ bindAction +] + +{ #category : #private } +SpDropDownPresenter >> display [ + + ^ display +] + +{ #category : #api } +SpDropDownPresenter >> display: aBlock [ + "Set the block that will be applied on the selected list item. + The result of the block will be used to display the item on the screen, + as the text field content. + `aBlock` receives one argument. + " + + display := aBlock +] + +{ #category : #initialization } +SpDropDownPresenter >> initialize [ + + super initialize. + self model: self newEmptyModel. + self initializeItemFactory. + selection := SpSingleSelectionMode on: self. + self display: [ :anObject | anObject asString ] +] + +{ #category : #initialization } +SpDropDownPresenter >> initializeItemFactory [ + "Just set up the defaults (to ensure we have a working list at any moment)" + + self setup: [ :aPresenter | aPresenter newLabel ]. + self bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] +] + +{ #category : #api } +SpDropDownPresenter >> items [ + "Answer the items of the list" + + ^ self model collection +] + +{ #category : #api } +SpDropDownPresenter >> items: aSequenceableCollection [ + "Set the items of the list. + `aSequenceableCollection` is a collection of your domain specific items. + This resets the collection model and unselects any previously selected item." + + model collection: aSequenceableCollection +] + +{ #category : #api } +SpDropDownPresenter >> model [ + "Answer the model for this list. + It is tipically, an instance of `SpCollectionListModel`." + + ^ model +] + +{ #category : #api } +SpDropDownPresenter >> model: aModel [ + "Sets the model used to feed the list presenter with elements of the list. + It is tipically an instance of `SpCollectionListModel`." + + model := aModel. + model whenChangedDo: [ + self withAdapterDo: [ :anAdapter | anAdapter refreshList ] ] +] + +{ #category : #private } +SpDropDownPresenter >> newEmptyModel [ + + ^ SpCollectionListModel on: #() +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selectFirst [ + "Select first element in list. + Useful to avoid selecting by index." + + ^ self selectIndex: 1 +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selectIndex: anInteger [ + "Select item at position `anInteger`. + Selection will not scroll the presenter view to show selected element." + + self selection selectIndex: anInteger +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selectItem: anItem [ + "Select `anItem` if it is included in model list. + It does not scrolls to selected element." + + self selection selectItem: anItem +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selectedIndex [ + "Return selected index." + + ^ self selection selectedIndex +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selectedItem [ + "Return selected item." + + ^ self selection selectedItem +] + +{ #category : #'api - selection' } +SpDropDownPresenter >> selection [ + "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). + This is not the item selected, but the selection container (it may contain one or many selected + items)" + + ^ selection +] + +{ #category : #api } +SpDropDownPresenter >> setup: aBlock [ + + setupAction := aBlock +] + +{ #category : #private } +SpDropDownPresenter >> setupAction [ + + ^ setupAction +] + +{ #category : #'api - events' } +SpDropDownPresenter >> whenSelectedDo: aBlock [ + "Inform when an item was selected (a real object in the items list). + `aBlock` receives one argument (the new selected element)" + + self whenSelectionChangedDo: [ :aSelection | + aSelection selectedItem + ifNotNil: [ :item | aBlock value: item ] ] +] + +{ #category : #'api - events' } +SpDropDownPresenter >> whenSelectedItemChangedDo: aBlock [ + "Inform when the selected item is changed. + `aBlock` receive one optional argument: the selected item (can be nil)" + + self selection whenChangedDo: [ aBlock cull: self selectedItem ] +] + +{ #category : #'api - events' } +SpDropDownPresenter >> whenSelectionChangedDo: aBlock [ + "Inform when there are changes in selection. + This method works for all selection modes (single, multiple and no selection). + `aBlock` receives an optional argument with the selection object." + + self selection whenChangedDo: aBlock +] diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st index 88caaf072..a2fa9b6c8 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -25,7 +25,7 @@ SpEasyListViewPresenter class >> example [ "This example show a simple list with all classes, using all the default settings." ^ self new - application: (SpApplication new useBackend: #Gtk); + "application: (SpApplication new useBackend: #Gtk);" items: self environment allClasses; open; yourself diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-Core/SpListViewPresenter.class.st index 694c5d8af..275f8ee2c 100644 --- a/src/Spec2-Core/SpListViewPresenter.class.st +++ b/src/Spec2-Core/SpListViewPresenter.class.st @@ -104,25 +104,3 @@ SpListViewPresenter >> showContextMenu [ self withAdapterDo: [ :anAdapter | anAdapter showContextMenu ] ] - -{ #category : #'api - events' } -SpListViewPresenter >> whenDisplayChangedDo: aBlock [ - "Inform when the display block has changed. - `aBlock` has three optional arguments: - - new value - - old value - - the announcement triggering this action" - - self property: #display whenChangedDo: aBlock -] - -{ #category : #'api - events' } -SpListViewPresenter >> whenIconsChangedDo: aBlock [ - "Inform when the icons block has changed. - `aBlock` has three optional arguments: - - new value - - old value - - the announcement triggering this action" - - self property: #icon whenChangedDo: aBlock -] diff --git a/src/Spec2-Core/SpTSelectionMode.trait.st b/src/Spec2-Core/SpTSelectionMode.trait.st new file mode 100644 index 000000000..ef495c519 --- /dev/null +++ b/src/Spec2-Core/SpTSelectionMode.trait.st @@ -0,0 +1,208 @@ +" +Add selectable api to widgets +" +Trait { + #name : #SpTSelectionMode, + #instVars : [ + 'selectionMode' + ], + #category : #'Spec2-Core-Widgets-Table' +} + +{ #category : #'api - selection' } +SpTSelectionMode >> selectAll [ + "Select all items in the list or table. + It does not triggers activation event." + + self selection selectAll +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectFirst [ + "Select first element in list. + Useful to avoid selecting by index." + + ^ self selectIndex: 1 +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectIndex: anInteger [ + "Select item at position `anInteger`. + Selection will not scroll the presenter view to show selected element." + + self selectionMode selectIndex: anInteger +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectIndex: anIndex scrollToSelection: shouldScrollToSelection [ + "Select item at position `anInteger`. + If `shouldScrollToSelection` is true, selection will scroll the presenter view + to show selected element." + + self selectIndex: anIndex. + shouldScrollToSelection ifTrue: [ + self verticalAlignment desiredVisibleRow: anIndex ]. +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectIndexes: aCollectionOfIndexes [ + "Select items at positions included in `aCollectionOfIndexes`. + NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. + Selection will not scroll the presenter view to show selected(s) element(s)." + + self selectionMode selectIndexes: aCollectionOfIndexes +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectIndexes: aCollectionOfIndexes scrollToSelection: shouldScrollToSelection [ + "Select items at positions included in `aCollectionOfIndexes`. + NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. + If `shouldScrollToSelection` is true, selection will scroll the presenter view + to show first selected element." + + self selectIndexes: aCollectionOfIndexes. + shouldScrollToSelection ifTrue: [ + self verticalAlignment desiredVisibleRow: aCollectionOfIndexes first ]. +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectItem: anItem [ + "Select `anItem` if it is included in model list. + It does not scrolls to selected element." + + self selectionMode selectItem: anItem +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectItem: anItem scrollToSelection: shouldScrollToSelection [ + "Select item `anItem`. + If `shouldScrollToSelection` is true, selection will scroll the presenter view + to show selected element." + + self + selectIndex: (self items indexOf: anItem) + scrollToSelection: shouldScrollToSelection +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectItems: aCollection [ + "Select items included in `aCollection` if they are included in model list. + NOTE: In single selection mode it will select the first element of `aCollection` + It does not scrolls to selected element." + + self selectionMode selectItems: aCollection +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectedItem [ + "Return selected item." + + ^ self selection selectedItem +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectedItems [ + "Return all the selected items in the case of a multiple selection list" + + ^ self selection selectedItems +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectedItemsSorted [ + "Return all the selected items sorted by their index" + + ^ self itemsAt: self selection selectedIndexes sort +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selection [ + "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). + This is not the item selected, but the selection container (it may contain one or many selected + items)" + + ^ self selectionMode +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectionMode [ + "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). + This is not the item selected, but the selection container (it may contain one or many selected + items). + This is the same as `SpAbstractListPresenter>>#selection`" + + ^ selectionMode +] + +{ #category : #'api - selection' } +SpTSelectionMode >> selectionMode: aMode [ + + selectionMode ifNotNil: [ + selectionMode transferSubscriptionsTo: aMode ]. + selectionMode := aMode +] + +{ #category : #'api - selection' } +SpTSelectionMode >> unselectAll [ + "Remove all selections" + + self selection unselectAll +] + +{ #category : #'api - selection' } +SpTSelectionMode >> unselectIndex: anInteger [ + "Remove selection of element at index `anInteger`" + + self selection unselectIndex: anInteger +] + +{ #category : #'api - selection' } +SpTSelectionMode >> unselectItem: anObject [ + "Remove selection of element `anObject`" + + self selection unselectItem: anObject +] + +{ #category : #'api - events' } +SpTSelectionMode >> whenNoneSelectedDo: aBlock [ + "Inform when the list has clean selection (there are no items selected). + `aBlock` receives zero arguments" + + self whenSelectionChangedDo: [ :selection | + selection selectedItem + ifNil: [ aBlock value ] ] +] + +{ #category : #'api - events' } +SpTSelectionMode >> whenSelectedDo: aBlock [ + "Inform when an item was selected (a real object in the items list). + `aBlock` receives one argument (the new selected element)" + + self whenSelectionChangedDo: [ :selection | + selection selectedItem + ifNotNil: [ :item | aBlock value: item ] ] +] + +{ #category : #'api - events' } +SpTSelectionMode >> whenSelectedItemChangedDo: aBlock [ + "Inform when the selected item is changed. + `aBlock` receive one optional argument: the selected item (can be nil)" + + self selection whenChangedDo: [ aBlock cull: self selectedItem ] +] + +{ #category : #'api - events' } +SpTSelectionMode >> whenSelectionChangedDo: aBlock [ + "Inform when there are changes in selection. + This method works for all selection modes (single, multiple and no selection). + `aBlock` receives an optional argument with the selection object." + + self selection whenChangedDo: aBlock +] + +{ #category : #'api - events' } +SpTSelectionMode >> whenSelectionModeChangedDo: aBlock [ + "Inform when selection mode (single/multiple) changed. + `aBlock` receives zero arguments." + + selectionMode whenChangedDo: aBlock +] diff --git a/src/Spec2-Examples/SpDropDownPresenter.extension.st b/src/Spec2-Examples/SpDropDownPresenter.extension.st new file mode 100644 index 000000000..8eb20434e --- /dev/null +++ b/src/Spec2-Examples/SpDropDownPresenter.extension.st @@ -0,0 +1,56 @@ +Extension { #name : #SpDropDownPresenter } + +{ #category : #'*Spec2-Examples' } +SpDropDownPresenter class >> example [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + display: [ :aClass | aClass name ]; + open +] + +{ #category : #'*Spec2-Examples' } +SpDropDownPresenter class >> exampleWithIcons [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + "spacing: 5;" + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : #'*Spec2-Examples' } +SpDropDownPresenter class >> exampleWithSelectedItem [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClassesAndTraits; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + display: [ :aClass | aClass name ]; + selectItem: Object; + whenSelectionChangedDo: [ :aSelection | aSelection selectedItem crTrace ]; + open +] diff --git a/src/Spec2-Examples/SpDropListPresenter.extension.st b/src/Spec2-Examples/SpDropListPresenter.extension.st index f3e51fcc2..9d1eed6ae 100644 --- a/src/Spec2-Examples/SpDropListPresenter.extension.st +++ b/src/Spec2-Examples/SpDropListPresenter.extension.st @@ -4,6 +4,7 @@ Extension { #name : #SpDropListPresenter } SpDropListPresenter class >> example [ ^ (self new + application: (SpApplication new useBackend: #Gtk); help: 'Select the presenter.'; items: SpPresenter withAllSubclasses; display: [ :aClass | aClass name ]; @@ -12,3 +13,18 @@ SpDropListPresenter class >> example [ extent: 400 @ 25; yourself ] + +{ #category : #'*Spec2-Examples' } +SpDropListPresenter class >> exampleWithIcons [ + + ^ (self new + application: (SpApplication new useBackend: #Gtk); + help: 'Select the presenter.'; + items: SpPresenter withAllSubclasses; + display: [ :aClass | aClass name ]; + displayIcon: [ :aClass | self iconNamed: aClass systemIconName ]; + whenSelectedItemChangedDo: [ :aClass | aClass crTrace ]; + open) + resize: 400 @ 25; + yourself +] From fda23dd8d2f4b65b7d9f442c7b51b544b906cd68 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 1 Aug 2023 11:58:33 +0200 Subject: [PATCH 30/88] add alexandrie presenter --- .../SpAlexandrieMorph.class.st | 43 +++++++++ .../SpMorphicAlexandrieAdapter.class.st | 34 +++++++ .../package.st | 1 + .../SpAlexandriePresenter.class.st | 94 +++++++++++++++++++ .../SpTPresenterBuilder.extension.st | 7 ++ src/Spec2-Alexandrie/package.st | 1 + 6 files changed, 180 insertions(+) create mode 100644 src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st create mode 100644 src/Spec2-Adapters-Morphic-Alexandrie/SpMorphicAlexandrieAdapter.class.st create mode 100644 src/Spec2-Adapters-Morphic-Alexandrie/package.st create mode 100644 src/Spec2-Alexandrie/SpAlexandriePresenter.class.st create mode 100644 src/Spec2-Alexandrie/SpTPresenterBuilder.extension.st create mode 100644 src/Spec2-Alexandrie/package.st diff --git a/src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st b/src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st new file mode 100644 index 000000000..8a3c2f2c3 --- /dev/null +++ b/src/Spec2-Adapters-Morphic-Alexandrie/SpAlexandrieMorph.class.st @@ -0,0 +1,43 @@ +Class { + #name : #SpAlexandrieMorph, + #superclass : #Morph, + #instVars : [ + 'surface', + 'drawBlock', + 'lastExtent' + ], + #category : #'Spec2-Adapters-Morphic-Alexandrie-Base' +} + +{ #category : #accessing } +SpAlexandrieMorph >> drawBlock: aBlock [ + + drawBlock := aBlock +] + +{ #category : #drawing } +SpAlexandrieMorph >> drawOn: aMorphicCanvas [ + + self redraw. + self surface + displayOnMorphicCanvas: aMorphicCanvas + at: bounds origin +] + +{ #category : #drawing } +SpAlexandrieMorph >> redraw [ + + self surface drawDuring: [ :canvas | + drawBlock + cull: canvas + cull: (0@0 extent: self extent) ] +] + +{ #category : #accessing } +SpAlexandrieMorph >> surface [ + + lastExtent = self extent ifFalse: [ surface := nil ]. + ^ surface ifNil: [ + lastExtent := self extent. + surface := AthensCairoSurface extent: self extent ] +] diff --git a/src/Spec2-Adapters-Morphic-Alexandrie/SpMorphicAlexandrieAdapter.class.st b/src/Spec2-Adapters-Morphic-Alexandrie/SpMorphicAlexandrieAdapter.class.st new file mode 100644 index 000000000..eb663dcf7 --- /dev/null +++ b/src/Spec2-Adapters-Morphic-Alexandrie/SpMorphicAlexandrieAdapter.class.st @@ -0,0 +1,34 @@ +Class { + #name : #SpMorphicAlexandrieAdapter, + #superclass : #SpAbstractMorphicAdapter, + #category : #'Spec2-Adapters-Morphic-Alexandrie-Base' +} + +{ #category : #factory } +SpMorphicAlexandrieAdapter >> buildWidget [ + + | instance | + instance := SpAthensMorph new. + self presenter whenDrawBlockChangedDo: [ :newBlock | + instance drawBlock: newBlock ]. + self presenter whenExtentChangedDo: [ :newExtent | + instance extent: newExtent ]. + instance extent: self presenter surfaceExtent. + instance drawBlock: self presenter drawBlock. + instance setBalloonText: self model help. + self presenter whenHelpChangedDo: [ + instance setBalloonText: self model help ]. + ^ instance +] + +{ #category : #drawing } +SpMorphicAlexandrieAdapter >> redraw [ + + widget redraw +] + +{ #category : #accessing } +SpMorphicAlexandrieAdapter >> surface [ + + ^ widget surface +] diff --git a/src/Spec2-Adapters-Morphic-Alexandrie/package.st b/src/Spec2-Adapters-Morphic-Alexandrie/package.st new file mode 100644 index 000000000..5422aea30 --- /dev/null +++ b/src/Spec2-Adapters-Morphic-Alexandrie/package.st @@ -0,0 +1 @@ +Package { #name : #'Spec2-Adapters-Morphic-Alexandrie' } diff --git a/src/Spec2-Alexandrie/SpAlexandriePresenter.class.st b/src/Spec2-Alexandrie/SpAlexandriePresenter.class.st new file mode 100644 index 000000000..b6e293870 --- /dev/null +++ b/src/Spec2-Alexandrie/SpAlexandriePresenter.class.st @@ -0,0 +1,94 @@ +Class { + #name : #SpAlexandriePresenter, + #superclass : #SpAbstractWidgetPresenter, + #traits : 'SpTContextMenu', + #classTraits : 'SpTContextMenu classTrait', + #instVars : [ + '#drawBlock => ObservableSlot', + '#surfaceExtent => ObservableSlot' + ], + #category : #'Spec2-Alexandrie' +} + +{ #category : #specs } +SpAlexandriePresenter class >> adapterName [ + + ^ #AlexandrieAdapter +] + +{ #category : #defaults } +SpAlexandriePresenter class >> defaultSurfaceExtent [ + + ^ 300@300 +] + +{ #category : #documentation } +SpAlexandriePresenter class >> documentFactoryMethodSelector [ + + ^ #newAlexandrie +] + +{ #category : #api } +SpAlexandriePresenter >> drawBlock [ + "Answer the block used to draw into an athens canvas." + + ^ drawBlock +] + +{ #category : #api } +SpAlexandriePresenter >> drawBlock: aBlock [ + "Set the block used to draw into the athens canvas. + `aBlock` receives one argument, the `AthensCanvas` instance used to draw the surface. + (See `SpAthensPresenter class>>#example` as an example of usage)" + + drawBlock := aBlock +] + +{ #category : #initialization } +SpAlexandriePresenter >> initialize [ + + super initialize. + self surfaceExtent: self class defaultSurfaceExtent +] + +{ #category : #api } +SpAlexandriePresenter >> redraw [ + + self withAdapterDo: [ :anAdapter | anAdapter redraw ] +] + +{ #category : #api } +SpAlexandriePresenter >> surfaceExtent [ + "Anwer the surface extent (the size the surface will have)" + + ^ surfaceExtent +] + +{ #category : #api } +SpAlexandriePresenter >> surfaceExtent: anExtent [ + "Set surface extent (a point) to contain the athens drawing." + + surfaceExtent := anExtent +] + +{ #category : #'api - events' } +SpAlexandriePresenter >> whenDrawBlockChangedDo: aBlock [ + "Inform when drawBlock has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #drawBlock whenChangedDo: aBlock +] + +{ #category : #'api - events' } +SpAlexandriePresenter >> whenExtentChangedDo: aBlock [ + "Inform when the Athens surface extent has changed. + `aBlock` has three optional arguments: + - new value + - old value + - the announcement triggering this action" + + self property: #surfaceExtent whenChangedDo: aBlock +] diff --git a/src/Spec2-Alexandrie/SpTPresenterBuilder.extension.st b/src/Spec2-Alexandrie/SpTPresenterBuilder.extension.st new file mode 100644 index 000000000..aa903d031 --- /dev/null +++ b/src/Spec2-Alexandrie/SpTPresenterBuilder.extension.st @@ -0,0 +1,7 @@ +Extension { #name : #SpTPresenterBuilder } + +{ #category : #'*Spec2-Alexandrie' } +SpTPresenterBuilder >> newAlexandrie [ + + ^ self instantiate: SpAlexandriePresenter +] diff --git a/src/Spec2-Alexandrie/package.st b/src/Spec2-Alexandrie/package.st new file mode 100644 index 000000000..a508b596f --- /dev/null +++ b/src/Spec2-Alexandrie/package.st @@ -0,0 +1 @@ +Package { #name : #'Spec2-Alexandrie' } From 324c7016fbd3276adc183a201fd2bd5396c4c8f1 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 1 Aug 2023 17:51:20 +0200 Subject: [PATCH 31/88] add an example --- .../SpDropListPresenter.extension.st | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Spec2-Examples/SpDropListPresenter.extension.st b/src/Spec2-Examples/SpDropListPresenter.extension.st index 9d1eed6ae..ab7fedf78 100644 --- a/src/Spec2-Examples/SpDropListPresenter.extension.st +++ b/src/Spec2-Examples/SpDropListPresenter.extension.st @@ -2,6 +2,7 @@ Extension { #name : #SpDropListPresenter } { #category : #'*Spec2-Examples' } SpDropListPresenter class >> example [ + "Show a simple dropdown list." ^ (self new application: (SpApplication new useBackend: #Gtk); @@ -14,8 +15,24 @@ SpDropListPresenter class >> example [ yourself ] +{ #category : #'*Spec2-Examples' } +SpDropListPresenter class >> exampleWithActions [ + "This example shows how to add icons to a dropdown list." + + ^ (self new + application: (SpApplication new useBackend: #Gtk); + help: 'Select the presenter.'; + addItemLabeled: 'Action 1' do: [ 'Action 1' crTrace ]; + addItemLabeled: 'Action 2' do: [ 'Action 2' crTrace ]; + addItemLabeled: 'Action 3' do: [ 'Action 3' crTrace ]; + open) + resize: 400 @ 25; + yourself +] + { #category : #'*Spec2-Examples' } SpDropListPresenter class >> exampleWithIcons [ + "This example shows how to add icons to a dropdown list." ^ (self new application: (SpApplication new useBackend: #Gtk); @@ -25,6 +42,6 @@ SpDropListPresenter class >> exampleWithIcons [ displayIcon: [ :aClass | self iconNamed: aClass systemIconName ]; whenSelectedItemChangedDo: [ :aClass | aClass crTrace ]; open) - resize: 400 @ 25; - yourself + resize: 400 @ 25; + yourself ] From 262a3293dd35026ea44a74e45ea05e04858361f4 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 1 Aug 2023 18:26:36 +0200 Subject: [PATCH 32/88] remove gtk call --- src/Spec2-Examples/SpDropListPresenter.extension.st | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Spec2-Examples/SpDropListPresenter.extension.st b/src/Spec2-Examples/SpDropListPresenter.extension.st index ab7fedf78..3418e18ed 100644 --- a/src/Spec2-Examples/SpDropListPresenter.extension.st +++ b/src/Spec2-Examples/SpDropListPresenter.extension.st @@ -5,7 +5,6 @@ SpDropListPresenter class >> example [ "Show a simple dropdown list." ^ (self new - application: (SpApplication new useBackend: #Gtk); help: 'Select the presenter.'; items: SpPresenter withAllSubclasses; display: [ :aClass | aClass name ]; @@ -20,7 +19,6 @@ SpDropListPresenter class >> exampleWithActions [ "This example shows how to add icons to a dropdown list." ^ (self new - application: (SpApplication new useBackend: #Gtk); help: 'Select the presenter.'; addItemLabeled: 'Action 1' do: [ 'Action 1' crTrace ]; addItemLabeled: 'Action 2' do: [ 'Action 2' crTrace ]; @@ -35,7 +33,6 @@ SpDropListPresenter class >> exampleWithIcons [ "This example shows how to add icons to a dropdown list." ^ (self new - application: (SpApplication new useBackend: #Gtk); help: 'Select the presenter.'; items: SpPresenter withAllSubclasses; display: [ :aClass | aClass name ]; From 5721842b9aeeb745878f78bc2c035f1e692921a0 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 18 Aug 2023 09:11:44 +0200 Subject: [PATCH 33/88] moved --- src/Spec2-Core/SpAbstractWidgetPresenter.class.st | 2 +- src/{Spec2-Morphic => Spec2-Core}/SpLinkPresenter.class.st | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{Spec2-Morphic => Spec2-Core}/SpLinkPresenter.class.st (98%) diff --git a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st index 6fbf9905f..1b81683c6 100644 --- a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st +++ b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st @@ -245,7 +245,7 @@ SpAbstractWidgetPresenter >> color: aColor [ ^ color := aColor ] -{ #category : #initialization } +{ #category : #TOREMOVE } SpAbstractWidgetPresenter >> defaultColor [ ^ self theme backgroundColor ] diff --git a/src/Spec2-Morphic/SpLinkPresenter.class.st b/src/Spec2-Core/SpLinkPresenter.class.st similarity index 98% rename from src/Spec2-Morphic/SpLinkPresenter.class.st rename to src/Spec2-Core/SpLinkPresenter.class.st index c4ad2cb42..bee778a47 100644 --- a/src/Spec2-Morphic/SpLinkPresenter.class.st +++ b/src/Spec2-Core/SpLinkPresenter.class.st @@ -11,7 +11,7 @@ Class { '#label => ObservableSlot', '#action => ObservableSlot' ], - #category : #'Spec2-Morphic-Widgets' + #category : #'Spec2-Core-Widgets' } { #category : #specs } From 348c2f3829719886264f57dc9f86d780c6f71602 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 11 Sep 2023 11:48:06 +0200 Subject: [PATCH 34/88] windows can be "activated" (moved to the front and getting the focus) --- src/Spec2-Adapters-Morphic/SpMorphicWindowAdapter.class.st | 7 +++++++ src/Spec2-Core/SpWindowPresenter.class.st | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicWindowAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicWindowAdapter.class.st index 39499c828..aa7a87b46 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicWindowAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicWindowAdapter.class.st @@ -15,6 +15,13 @@ SpMorphicWindowAdapter >> aboutTitle [ ifFalse: [m class name]]. ] +{ #category : #'spec protocol' } +SpMorphicWindowAdapter >> activate [ + + self widgetDo: [ :w | + w activate ] +] + { #category : #initialization } SpMorphicWindowAdapter >> addFocusRotationKeyBindings [ "Windows should not process keybindings (because then the active widget will not get diff --git a/src/Spec2-Core/SpWindowPresenter.class.st b/src/Spec2-Core/SpWindowPresenter.class.st index d9f4251b6..c98ddd351 100644 --- a/src/Spec2-Core/SpWindowPresenter.class.st +++ b/src/Spec2-Core/SpWindowPresenter.class.st @@ -89,6 +89,12 @@ SpWindowPresenter >> aboutTitle [ ^ self presenter toolName ] +{ #category : #api } +SpWindowPresenter >> activate [ + + self withAdapterDo: [ :anAdapter | anAdapter activate ] +] + { #category : #'private - building' } SpWindowPresenter >> addPresenterIn: widget withSpecLayout: aSpec [ From 31ebec9ed9c73e2a46abf8267bf1492cd18f2874 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 12 Sep 2023 14:58:35 +0200 Subject: [PATCH 35/88] add a way to choose a different styleScheme (like background color, etc.), to work with syntaxHighlightTheme (so I can have a dark text editor within a light theme and the oposite). --- src/Spec2-Adapters-Morphic/SpStyle.class.st | 4 ++- .../SpMorphicCodeAdapter.class.st | 12 ++++++- src/Spec2-Code/SpCodePresenter.class.st | 36 +++++++++++++++++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpStyle.class.st b/src/Spec2-Adapters-Morphic/SpStyle.class.st index 3ddc6c738..62fe440e0 100644 --- a/src/Spec2-Adapters-Morphic/SpStyle.class.st +++ b/src/Spec2-Adapters-Morphic/SpStyle.class.st @@ -127,7 +127,9 @@ SpStyle class >> defaultStyleSheetData [ .lines8 [ Geometry { #minHeight: 160, #height: 160 } ] ], .textInputField [ Geometry { #height: 24, #minHeight: 24 } ], .textSearchField [ Geometry { #height: 24, #minHeight: 24 } ], - .code [ Font { #name: EnvironmentFont(#code) } ], + .code [ Font { #name: EnvironmentFont(#code) } ], + .codeLight [ Draw { #backgroundColor: #white } ], + .codeDark [ Draw { #backgroundColor: #212121 } ], .patch [ Font { #name: EnvironmentFont(#code) } ], .codePopover [ Draw { #color: #transparent }, diff --git a/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st b/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st index bd34c8fd9..b818cb3c1 100644 --- a/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st +++ b/src/Spec2-Code-Morphic/SpMorphicCodeAdapter.class.st @@ -182,6 +182,16 @@ SpMorphicCodeAdapter >> originMorphFor: aMorph [ ^ aMorph textArea cursor ] +{ #category : #styling } +SpMorphicCodeAdapter >> presenterStyles [ + "The presenters in the style. + styleScheme is taken as just another style (not ideal, but it does the work, )" + + ^ self presenter styleScheme + ifNotNil: [ :aScheme | self presenter styles copyWith: aScheme ] + ifNil: [ self presenter styles ] +] + { #category : #NOCompletion } SpMorphicCodeAdapter >> receiverClass [ @@ -259,7 +269,7 @@ SpMorphicCodeAdapter >> setSyntaxHighlightThemeFor: textArea [ theme := self presenter syntaxHighlightTheme. theme ifNil: [ ^ self ]. - textArea shoutStyler + textArea shoutStyler styler: (SpMorphicCodeTextStyler newWithAttributeTableNamed: theme); refreshStyling ] diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 3ebadf59e..10ab54f7b 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -16,7 +16,8 @@ Class { '#resetBlock', '#environment', '#systemNavigation', - '#syntaxHighlightTheme => ObservableSlot' + '#syntaxHighlightTheme => ObservableSlot', + '#styleScheme' ], #category : #'Spec2-Code-Base' } @@ -109,8 +110,20 @@ SpCodePresenter class >> documentFactoryMethodSelector [ SpCodePresenter class >> example [ ^ self new - text: 'some method: 42'; - open + text: '42 factorial'; + open +] + +{ #category : #examples } +SpCodePresenter class >> exampleChangingSchemeAndHighlightTheme [ + + "if you are using a dark theme, this will not look different (use 'codeLight' scheme to see + something cool) ;)" + ^ self new + syntaxHighlightTheme: 'Dark'; + styleScheme: 'codeDark'; + text: '42 factorial'; + open ] { #category : #examples } @@ -703,6 +716,23 @@ SpCodePresenter >> smartCharacters: aBoolean [ smartCharacters := aBoolean ] +{ #category : #api } +SpCodePresenter >> styleScheme [ + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', 'solarized-light', 'tango'" + + ^ styleScheme +] + +{ #category : #api } +SpCodePresenter >> styleScheme: aSymbol [ + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', 'solarized-light', 'tango'. + + Note: In morphic this will be interpreted as a simple style (since you can use a style + to define a scheme)" + + styleScheme := aSymbol +] + { #category : #private } SpCodePresenter >> syntaxHighlight: aBoolean [ From 1f71b01e1cfd2ed4f62547a9816dd8c76170e0bb Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 28 Sep 2023 22:45:12 +0200 Subject: [PATCH 36/88] add some missing api methods --- .../SpEasyListViewPresenter.class.st | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st index a2fa9b6c8..33bdfed98 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -77,6 +77,18 @@ SpEasyListViewPresenter >> actionGroup: aSpCommandGroup [ listView actionGroup: aSpCommandGroup ] +{ #category : #api } +SpEasyListViewPresenter >> activateOnDoubleClick [ + + listView activateOnDoubleClick +] + +{ #category : #api } +SpEasyListViewPresenter >> activateOnSingleClick [ + + listView activateOnSingleClick +] + { #category : #private } SpEasyListViewPresenter >> activateSearchWith: aString [ @@ -95,6 +107,12 @@ SpEasyListViewPresenter >> addAction: aSpCommand [ listView addAction: aSpCommand ] +{ #category : #api } +SpEasyListViewPresenter >> addScrollBarStyle: aStyle [ + + listView addScrollBarStyle: aStyle +] + { #category : #api } SpEasyListViewPresenter >> beMultipleSelection [ @@ -148,6 +166,12 @@ SpEasyListViewPresenter >> defaultLayout [ yourself ] +{ #category : #api } +SpEasyListViewPresenter >> disable [ + + self enabled: false +] + { #category : #api } SpEasyListViewPresenter >> display [ "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a @@ -194,6 +218,12 @@ SpEasyListViewPresenter >> displayValueFor: anObject [ ^ self display value: anObject ] +{ #category : #api } +SpEasyListViewPresenter >> enable [ + + self enabled: true +] + { #category : #private } SpEasyListViewPresenter >> findFirst: aString [ | items | @@ -281,6 +311,12 @@ SpEasyListViewPresenter >> initializePresenters [ searchInput hide ] +{ #category : #api } +SpEasyListViewPresenter >> items [ + + ^ listView items +] + { #category : #api } SpEasyListViewPresenter >> items: anOrderedCollection [ @@ -298,6 +334,12 @@ SpEasyListViewPresenter >> maybeActivateSearchOn: event [ self activateSearchWith: event keyCharacter asString ] +{ #category : #api } +SpEasyListViewPresenter >> model [ + + ^ listView model +] + { #category : #initialization } SpEasyListViewPresenter >> registerEvents [ @@ -306,6 +348,18 @@ SpEasyListViewPresenter >> registerEvents [ self whenDisplayChangedDo: [ listView refresh ] ] +{ #category : #api } +SpEasyListViewPresenter >> removeScrollBarStyle: aStyle [ + + ^ listView removeScrollBarStyle: aStyle +] + +{ #category : #api } +SpEasyListViewPresenter >> scrollBarStyles [ + + ^ listView scrollBarStyles +] + { #category : #private } SpEasyListViewPresenter >> selectFirst: aString [ | index | @@ -316,6 +370,18 @@ SpEasyListViewPresenter >> selectFirst: aString [ listView selectIndex: index scrollToSelection: true ] +{ #category : #'api - selection' } +SpEasyListViewPresenter >> selectedItem [ + + ^ listView selectedItem +] + +{ #category : #api } +SpEasyListViewPresenter >> updateItemsKeepingSelection: aCollection [ + + listView updateItemsKeepingSelection: aCollection +] + { #category : #'api - events' } SpEasyListViewPresenter >> whenDisplayChangedDo: aBlock [ "Inform when the display block has changed. @@ -337,3 +403,15 @@ SpEasyListViewPresenter >> whenIconsChangedDo: aBlock [ self property: #displayIcon whenChangedDo: aBlock ] + +{ #category : #api } +SpEasyListViewPresenter >> withScrollBars [ + + listView withScrollBars +] + +{ #category : #api } +SpEasyListViewPresenter >> withoutScrollBars [ + + listView withoutScrollBars +] From d1cc66bbf9f3d688a48f064f50870b440fcf4e1f Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 28 Sep 2023 22:45:44 +0200 Subject: [PATCH 37/88] modes can answer if they have an icon and/or a label --- .../SpIconAndLabelToolbarDisplayMode.class.st | 12 ++++++++++++ src/Spec2-Core/SpIconToolbarDisplayMode.class.st | 6 ++++++ src/Spec2-Core/SpLabelToolbarDisplayMode.class.st | 6 ++++++ src/Spec2-Core/SpToolbarDisplayMode.class.st | 12 ++++++++++++ 4 files changed, 36 insertions(+) diff --git a/src/Spec2-Core/SpIconAndLabelToolbarDisplayMode.class.st b/src/Spec2-Core/SpIconAndLabelToolbarDisplayMode.class.st index eb9b80d26..f969026f3 100644 --- a/src/Spec2-Core/SpIconAndLabelToolbarDisplayMode.class.st +++ b/src/Spec2-Core/SpIconAndLabelToolbarDisplayMode.class.st @@ -22,6 +22,18 @@ SpIconAndLabelToolbarDisplayMode >> extent [ ^ 45@45 ] +{ #category : #testing } +SpIconAndLabelToolbarDisplayMode >> hasIcon [ + + ^ true +] + +{ #category : #testing } +SpIconAndLabelToolbarDisplayMode >> hasLabel [ + + ^ true +] + { #category : #printing } SpIconAndLabelToolbarDisplayMode >> label [ diff --git a/src/Spec2-Core/SpIconToolbarDisplayMode.class.st b/src/Spec2-Core/SpIconToolbarDisplayMode.class.st index 3c589dfec..ee6a6b5b0 100644 --- a/src/Spec2-Core/SpIconToolbarDisplayMode.class.st +++ b/src/Spec2-Core/SpIconToolbarDisplayMode.class.st @@ -21,6 +21,12 @@ SpIconToolbarDisplayMode >> extent [ ^ 30@30 ] +{ #category : #testing } +SpIconToolbarDisplayMode >> hasIcon [ + + ^ true +] + { #category : #accessing } SpIconToolbarDisplayMode >> label [ diff --git a/src/Spec2-Core/SpLabelToolbarDisplayMode.class.st b/src/Spec2-Core/SpLabelToolbarDisplayMode.class.st index bae69135f..436dfd5a8 100644 --- a/src/Spec2-Core/SpLabelToolbarDisplayMode.class.st +++ b/src/Spec2-Core/SpLabelToolbarDisplayMode.class.st @@ -20,6 +20,12 @@ SpLabelToolbarDisplayMode >> extent [ ^ 45@25 ] +{ #category : #testing } +SpLabelToolbarDisplayMode >> hasLabel [ + + ^ true +] + { #category : #accessing } SpLabelToolbarDisplayMode >> label [ diff --git a/src/Spec2-Core/SpToolbarDisplayMode.class.st b/src/Spec2-Core/SpToolbarDisplayMode.class.st index 1af1e22eb..85d4a74a7 100644 --- a/src/Spec2-Core/SpToolbarDisplayMode.class.st +++ b/src/Spec2-Core/SpToolbarDisplayMode.class.st @@ -73,6 +73,18 @@ SpToolbarDisplayMode >> extent [ ^ self subclassResponsibility ] +{ #category : #testing } +SpToolbarDisplayMode >> hasIcon [ + + ^ false +] + +{ #category : #testing } +SpToolbarDisplayMode >> hasLabel [ + + ^ false +] + { #category : #accessing } SpToolbarDisplayMode >> height [ From ded7c3c593596f6141ab89324110e2ddc304d4b6 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 29 Sep 2023 16:42:16 +0200 Subject: [PATCH 38/88] fix box layout hide/show of presenters, it was not working correctly --- .../SpMorphicBaseBoxLayout.class.st | 4 +- .../SpMorphicBoxAdapter.class.st | 4 +- ...hicBoxLayoutCalculatorLeftToRight.class.st | 11 ++-- ...hicBoxLayoutCalculatorTopToBottom.class.st | 11 ++-- .../SpMorphicBoxLayoutTest.class.st | 55 +++++++++++++++++-- 5 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBaseBoxLayout.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBaseBoxLayout.class.st index b89283612..66d43de46 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBaseBoxLayout.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBaseBoxLayout.class.st @@ -36,7 +36,9 @@ SpMorphicBaseBoxLayout >> applyVerticalHomogeneousLayout: aMorph in: aRect [ self error: 'It does not looks like a spec box panel' ]. allMorphs := aMorph submorphs flatCollect: [ :each | each submorphs ]. - elementHeight := (aRect height - (self borderWidth * 2) - (self spacing * (allMorphs size - 1)) / (allMorphs size max: 1)) floor. + elementHeight := (aRect height + - (self borderWidth * 2) + - (self spacing * (allMorphs size - 1)) / (allMorphs size max: 1)) floor. allMorphs do: [ :each | each minHeight: elementHeight ] diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st index 25bfbae4d..821533913 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st @@ -229,10 +229,10 @@ SpMorphicBoxAdapter >> newVertical [ ^ (self newPanelWith: self newPanelLayout) listDirection: #topToBottom; - addMorphBack: ((startPanel := self newPanel) + addMorphBack: ((startPanel := self newPanelWith: SpMorphicBoxChildLayout new) listDirection: #topToBottom; yourself); - addMorphBack: ((endPanel := self newPanel) + addMorphBack: ((endPanel := self newPanelWith: SpMorphicBoxChildLayout new) listDirection: #topToBottom; vResizing: #shrinkWrap; height: 0; diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st index 78152c462..232876fa2 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st @@ -45,7 +45,9 @@ SpMorphicBoxLayoutCalculatorLeftToRight >> calculateCellFor: aMorph [ lastCell := cell. width := width + sizeX. sizeY > height - ifTrue: [ height := sizeY ] + ifTrue: [ height := sizeY ]. + + ^ sizeX@sizeY ] { #category : #calculating } @@ -63,10 +65,11 @@ SpMorphicBoxLayoutCalculatorLeftToRight >> calculateFor: aMorph in: newBounds [ submorphs := aMorph submorphs. properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. - submorphs do: [ :each | - each visible + submorphs do: [ :each | | cellExtent | + cellExtent := each visible ifTrue: [ self calculateCellFor: each ] - ifFalse: [ each privateBounds: (each bounds topLeft extent: 0@0) ] ]. + ifFalse: [ 0@0 ]. + each privateBounds: (each bounds topLeft extent: cellExtent) ]. number > 1 ifTrue:[ width := width + ((number-1) * inset) ]. diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st index 3544a2e42..00b118b80 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st @@ -36,7 +36,9 @@ SpMorphicBoxLayoutCalculatorTopToBottom >> calculateCellFor: aMorph [ lastCell := cell. height := height + sizeY. - sizeX > width ifTrue:[ width := sizeX ] + sizeX > width ifTrue:[ width := sizeX ]. + + ^ sizeX@sizeY ] { #category : #calculating } @@ -54,10 +56,11 @@ SpMorphicBoxLayoutCalculatorTopToBottom >> calculateFor: aMorph in: newBounds [ submorphs := aMorph submorphs. properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. - submorphs do: [ :each | - each visible + submorphs do: [ :each | | cellExtent | + cellExtent := each visible ifTrue: [ self calculateCellFor: each ] - ifFalse: [ each privateBounds: (each bounds topLeft extent: 0@0) ] ]. + ifFalse: [ 0@0 ]. + each privateBounds: (each bounds topLeft extent: cellExtent) ]. number > 1 ifTrue:[height := height + (number-1 * inset) ]. diff --git a/src/Spec2-Morphic-Backend-Tests/SpMorphicBoxLayoutTest.class.st b/src/Spec2-Morphic-Backend-Tests/SpMorphicBoxLayoutTest.class.st index ea834b069..5e97b0a4b 100644 --- a/src/Spec2-Morphic-Backend-Tests/SpMorphicBoxLayoutTest.class.st +++ b/src/Spec2-Morphic-Backend-Tests/SpMorphicBoxLayoutTest.class.st @@ -177,6 +177,51 @@ SpMorphicBoxLayoutTest >> testClassIsDisplayedWithCorrectAlignment [ self assert: table left <= table submorphs first left ] +{ #category : #tests } +SpMorphicBoxLayoutTest >> testHiddenPresenterTakesAnyHeight [ + | presenter l1 l2 | + + (presenter := SpPresenter new) + layout: (SpBoxLayout newTopToBottom + add: (l1 := presenter newLabel label: 'Line 1') expand: false; + add: (l2 := presenter newLabel label: 'Line 2'); + yourself). + + l1 hide. + + [ presenter open ] + ensure: [ presenter window close ]. + + self + assert: presenter adapter widget height + equals: (l2 adapter widget height + 2) "This is the space left by the layout between cells to start laying the next (is 1, but we have 2 components hence 2 :)" +] + +{ #category : #tests } +SpMorphicBoxLayoutTest >> testHiddenPresenterThenShownResizesContentCorrectly [ + | presenter l1 l2 height | + + (presenter := SpPresenter new) + layout: (SpBoxLayout newTopToBottom + add: (l1 := presenter newLabel label: 'Line 1') expand: false; + add: (l2 := presenter newLabel label: 'Line 2'); + yourself). + + [ + presenter open. + height := l1 adapter widget height. + l1 hide. + MorphicRenderLoop new doOneCycle. + self assert: l1 adapter widget height equals: 0. + l1 show. + MorphicRenderLoop new doOneCycle. + self assert: l1 adapter widget height equals: height ] + ensure: [ + presenter window close ]. + + +] + { #category : #tests } SpMorphicBoxLayoutTest >> testLayoutHeightTakesAllSpaceNeeded [ @@ -228,11 +273,13 @@ SpMorphicBoxLayoutTest >> testNestedLayoutModifiesHeightOfTopLayout [ { #category : #tests } SpMorphicBoxLayoutTest >> testPresenterTakesRightHeight [ - | presenter l1 l2 | - (presenter := SpPresenter new) layout: (SpBoxLayout newTopToBottom - add: (l1 := presenter newLabel label: 'Line 1') expand: false; - add: (l2 := presenter newLabel label: 'Line 2') expand: false). + + (presenter := SpPresenter new) + layout: (SpBoxLayout newTopToBottom + add: (l1 := presenter newLabel label: 'Line 1') expand: false; + add: (l2 := presenter newLabel label: 'Line 2') expand: false; + yourself). presenter build. From 580f23a15a7e0491f3aec0e28eb5b38cf96adfc0 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 29 Sep 2023 16:43:04 +0200 Subject: [PATCH 39/88] add an example --- src/Spec2-Examples/SpPanedLayout.extension.st | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Spec2-Examples/SpPanedLayout.extension.st diff --git a/src/Spec2-Examples/SpPanedLayout.extension.st b/src/Spec2-Examples/SpPanedLayout.extension.st new file mode 100644 index 000000000..22250263f --- /dev/null +++ b/src/Spec2-Examples/SpPanedLayout.extension.st @@ -0,0 +1,23 @@ +Extension { #name : #SpPanedLayout } + +{ #category : #'*Spec2-Examples' } +SpPanedLayout class >> exampleNotResizingStartChild [ + + | app presenter child1 child2 | + + app := SpApplication new. + + presenter := SpPresenter newApplication: app. + presenter layout: (SpPanedLayout newVertical + positionOfSlider: 50; + add: (child1 := presenter newListView) + withConstraints: [ :c | c beNotResizable ]; + add: (child2 := presenter newListView); + yourself). + + child1 items: #(one two). + child2 items: String loremIpsum substrings. + + presenter open + +] From 7485787ea20d450bd4f4d0c2130a37cebfbe3b94 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 09:41:12 +0200 Subject: [PATCH 40/88] do not adjust size all the time because it causes a problem with overlapping widgets --- .../SpMorphicBoxLayoutCalculatorLeftToRight.class.st | 8 ++++++-- .../SpMorphicBoxLayoutCalculatorTopToBottom.class.st | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st index 232876fa2..52dd80ee8 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorLeftToRight.class.st @@ -65,11 +65,15 @@ SpMorphicBoxLayoutCalculatorLeftToRight >> calculateFor: aMorph in: newBounds [ submorphs := aMorph submorphs. properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. - submorphs do: [ :each | | cellExtent | + submorphs do: [ :each | + | cellExtent oldExtent | + oldExtent := each extent. cellExtent := each visible ifTrue: [ self calculateCellFor: each ] ifFalse: [ 0@0 ]. - each privateBounds: (each bounds topLeft extent: cellExtent) ]. + "decide if restore or not" + ((oldExtent x = 0) or: [ cellExtent x = 0 ]) ifTrue: [ + each privateBounds: (each bounds topLeft extent: cellExtent) ] ]. number > 1 ifTrue:[ width := width + ((number-1) * inset) ]. diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st index 00b118b80..3243f41e3 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxLayoutCalculatorTopToBottom.class.st @@ -56,11 +56,15 @@ SpMorphicBoxLayoutCalculatorTopToBottom >> calculateFor: aMorph in: newBounds [ submorphs := aMorph submorphs. properties reverseTableCells ifTrue:[ submorphs := submorphs reversed ]. - submorphs do: [ :each | | cellExtent | + submorphs do: [ :each | + | cellExtent oldExtent | + oldExtent := each extent. cellExtent := each visible ifTrue: [ self calculateCellFor: each ] ifFalse: [ 0@0 ]. - each privateBounds: (each bounds topLeft extent: cellExtent) ]. + "decide if restore or not" + ((oldExtent y = 0) or: [ cellExtent y = 0 ]) ifTrue: [ + each privateBounds: (each bounds topLeft extent: cellExtent) ] ]. number > 1 ifTrue:[height := height + (number-1 * inset) ]. From c73c3162cff3f758d51b20a7fdfb1b638b2d44e7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 09:44:51 +0200 Subject: [PATCH 41/88] run tests --- .github/workflows/spec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index e6fb3248e..86576bace 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -6,9 +6,9 @@ env: on: push: - branches: [ Pharo11, dev-1.0 ] + branches: [ Pharo11, dev-1.0, dev-3.0 ] pull_request: - branches: [ Pharo11, dev-1.0 ] + branches: [ Pharo11, dev-1.0. dev-3.0 ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 074b71ca13fee35bead989e893020ef3fb7a2951 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 09:59:21 +0200 Subject: [PATCH 42/88] remove debug code --- src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st index 9737e7b1d..120244986 100644 --- a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st @@ -113,7 +113,6 @@ SpAbstractAdapterTest >> presenter [ { #category : #running } SpAbstractAdapterTest >> runCase [ self resources do: [ :each | each availableFor: self ]. - testSelector printToStdout. [ super setUp. self performTest ] ensure: [ self tearDown. From 9d2ea02f5842d929852dcf3ecc8855441bbb3adb Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 10:01:34 +0200 Subject: [PATCH 43/88] add actionMofifier idiom --- src/Spec2-Core/Character.extension.st | 10 ++++++++++ src/Spec2-Core/KMKeyCombination.extension.st | 12 ++++++++++++ src/Spec2-Tests/SpActionModifierTest.class.st | 13 +++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/Spec2-Core/Character.extension.st create mode 100644 src/Spec2-Core/KMKeyCombination.extension.st create mode 100644 src/Spec2-Tests/SpActionModifierTest.class.st diff --git a/src/Spec2-Core/Character.extension.st b/src/Spec2-Core/Character.extension.st new file mode 100644 index 000000000..9099d9d64 --- /dev/null +++ b/src/Spec2-Core/Character.extension.st @@ -0,0 +1,10 @@ +Extension { #name : #Character } + +{ #category : #'*Spec2-Core' } +Character >> actionModifier [ + "Define the action action modifier depending in which platform we are running. + e.g. $x actionModifier will resolve in $x ctrl in unix and windows systems and $x command + in mac" + + ^ self asKeyCombination actionModifier +] diff --git a/src/Spec2-Core/KMKeyCombination.extension.st b/src/Spec2-Core/KMKeyCombination.extension.st new file mode 100644 index 000000000..b159f60f1 --- /dev/null +++ b/src/Spec2-Core/KMKeyCombination.extension.st @@ -0,0 +1,12 @@ +Extension { #name : #KMKeyCombination } + +{ #category : #'*Spec2-Core' } +KMKeyCombination >> actionModifier [ + "Define the action action modifier depending in which platform we are running. + e.g. $x actionModifier will resolve in $x ctrl in unix and windows systems and $x command + in mac" + + ^ (KMModifier command + self) mac + | (KMModifier control + self) unix + | (KMModifier control + self) win +] diff --git a/src/Spec2-Tests/SpActionModifierTest.class.st b/src/Spec2-Tests/SpActionModifierTest.class.st new file mode 100644 index 000000000..3faa5ba64 --- /dev/null +++ b/src/Spec2-Tests/SpActionModifierTest.class.st @@ -0,0 +1,13 @@ +Class { + #name : #SpActionModifierTest, + #superclass : #TestCase, + #category : #'Spec2-Tests-Core' +} + +{ #category : #tests } +SpActionModifierTest >> testActionModifier [ + + self + assert: $x actionModifier + equals: ($x ctrl unix | $x ctrl win | $x command mac) +] From e688caac843dfc0619e579b5b506f6ee181b44f3 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 10:09:00 +0200 Subject: [PATCH 44/88] fix --- .../SpAbstractListAdapterSingleSelectionTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Backend-Tests/SpAbstractListAdapterSingleSelectionTest.class.st b/src/Spec2-Backend-Tests/SpAbstractListAdapterSingleSelectionTest.class.st index eb5670d53..7b1a343e8 100644 --- a/src/Spec2-Backend-Tests/SpAbstractListAdapterSingleSelectionTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractListAdapterSingleSelectionTest.class.st @@ -23,7 +23,7 @@ SpAbstractListAdapterSingleSelectionTest >> initializeTestedInstance [ { #category : #running } SpAbstractListAdapterSingleSelectionTest >> tearDown [ - presenter delete. + presenter ifNotNil: #delete. super tearDown ] From ab3ed64256ed4af1b84d17f340510c89efe685e8 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 10:44:55 +0200 Subject: [PATCH 45/88] ensure exists --- .../SpAbstractListAdapterMultipleSelectionTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Backend-Tests/SpAbstractListAdapterMultipleSelectionTest.class.st b/src/Spec2-Backend-Tests/SpAbstractListAdapterMultipleSelectionTest.class.st index 51b422b43..58a5d6a75 100644 --- a/src/Spec2-Backend-Tests/SpAbstractListAdapterMultipleSelectionTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractListAdapterMultipleSelectionTest.class.st @@ -22,7 +22,7 @@ SpAbstractListAdapterMultipleSelectionTest >> initializeTestedInstance [ { #category : #running } SpAbstractListAdapterMultipleSelectionTest >> tearDown [ - presenter delete. + presenter ifNotNil: #delete. super tearDown ] From e54b7388021c6c3bd7e46fb855353d44d39b9318 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 10:56:11 +0200 Subject: [PATCH 46/88] oops --- src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st index 120244986..ef92b0f05 100644 --- a/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st +++ b/src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st @@ -22,7 +22,7 @@ SpAbstractAdapterTest class >> testParameters [ forSelector: #specInitializationStrategy addOptions: { [ SpInitializationStrategy beforeTest ]. [ SpInitializationStrategy afterTest ] }; forSelector: #backendForTest - addOptions: { "SpMorphicBackendForTest. "GtkBackendForTest }; + addOptions: { SpMorphicBackendForTest. "GtkBackendForTest" }; yourself ] From 4069289b97624d58f08c222a9a5ac55bfeb4f35f Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 30 Sep 2023 11:32:41 +0200 Subject: [PATCH 47/88] oops (2) --- src/Spec2-Tests/SpBaseTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Tests/SpBaseTest.class.st b/src/Spec2-Tests/SpBaseTest.class.st index 0ef494e72..6584c5753 100644 --- a/src/Spec2-Tests/SpBaseTest.class.st +++ b/src/Spec2-Tests/SpBaseTest.class.st @@ -23,7 +23,7 @@ SpBaseTest >> adapter [ { #category : #running } SpBaseTest >> application [ - ^ SpApplication new useBackend: #Gtk + ^ SpApplication new ] { #category : #assertions } From c5e7fc96f84df2266a7e70f4f9fa0a73c4f0f53e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:05:51 +0200 Subject: [PATCH 48/88] fix package --- src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st | 3 --- src/Spec2-Core/SpLinkPresenter.class.st | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st index cdf2c8a50..6862cdb9c 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicLinkAdapter.class.st @@ -1,7 +1,4 @@ " -Description --------------------- - I am the adapter used to bridge a URLPresenter and a morphic " Class { diff --git a/src/Spec2-Core/SpLinkPresenter.class.st b/src/Spec2-Core/SpLinkPresenter.class.st index 29636c261..276dfabfd 100644 --- a/src/Spec2-Core/SpLinkPresenter.class.st +++ b/src/Spec2-Core/SpLinkPresenter.class.st @@ -11,8 +11,8 @@ Class { '#label => ObservableSlot', '#action => ObservableSlot' ], - #category : 'Spec2-Morphic-Widgets', - #package : 'Spec2-Morphic', + #category : 'Spec2-Core-Widgets', + #package : 'Spec2-Core', #tag : 'Widgets' } From 3e6fffd63e9b09504c761ef18c2c8170e0beb17b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:09:26 +0200 Subject: [PATCH 49/88] fix missing trait --- src/Spec2-Core/SpAbstractListPresenter.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spec2-Core/SpAbstractListPresenter.class.st b/src/Spec2-Core/SpAbstractListPresenter.class.st index 801971510..a56e749f2 100644 --- a/src/Spec2-Core/SpAbstractListPresenter.class.st +++ b/src/Spec2-Core/SpAbstractListPresenter.class.st @@ -4,8 +4,8 @@ A base for list presenters, it defines basic functionality common to all lists. Class { #name : 'SpAbstractListPresenter', #superclass : 'SpAbstractWidgetPresenter', - #traits : 'SpTHaveWrappingScrollBars + SpTContextMenu + SpTAlignableColumn', - #classTraits : 'SpTHaveWrappingScrollBars classTrait + SpTContextMenu classTrait + SpTAlignableColumn classTrait', + #traits : 'SpTHaveWrappingScrollBars + SpTContextMenu + SpTAlignableColumn + SpTSelectionMode', + #classTraits : 'SpTHaveWrappingScrollBars classTrait + SpTContextMenu classTrait + SpTAlignableColumn classTrait + SpTSelectionMode classTrait', #instVars : [ '#activationBlock', '#activateOnSingleClick', From 924925e94a0dd5bf9d1e1a86d15a501e5454584a Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:12:00 +0200 Subject: [PATCH 50/88] fix missing trait --- src/Spec2-Core/SpPresenter.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spec2-Core/SpPresenter.class.st b/src/Spec2-Core/SpPresenter.class.st index cbbd0cbfa..92fd42451 100644 --- a/src/Spec2-Core/SpPresenter.class.st +++ b/src/Spec2-Core/SpPresenter.class.st @@ -84,8 +84,8 @@ SpMyPresenter >> initializeLayout Class { #name : 'SpPresenter', #superclass : 'SpAbstractPresenter', - #traits : 'SpTPresenterBuilder', - #classTraits : 'SpTPresenterBuilder classTrait', + #traits : 'SpTPresenterBuilder + SpTActionContainer', + #classTraits : 'SpTPresenterBuilder classTrait + SpTActionContainer classTrait', #instVars : [ '#application', '#focusOrder', From a7a31b6ddaa00af6981b512cf158bd08be6c21f1 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:21:02 +0200 Subject: [PATCH 51/88] add missing method --- src/Spec2-Core/SpAbstractTextPresenter.class.st | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index c07b8d0b4..fbe8d0e35 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -86,6 +86,14 @@ SpAbstractTextPresenter >> cursorPositionIndex: index [ ^ self withAdapterDo: [ :anAdapter | anAdapter cursorPositionIndex: index ] ] + +{ #category : 'private' } +SpAbstractTextPresenter >> editable: aBoolean [ + + editable := aBoolean +] + + { #category : 'api' } SpAbstractTextPresenter >> enabled: aBoolean [ "Set if the widget is enabled (clickable or focusable)" From 532be80148a4c99b3fbf659640610a7daa156d78 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:40:19 +0200 Subject: [PATCH 52/88] add missing methods --- src/Spec2-Code/SpCodePresenter.class.st | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 33c25f53d..5e10e8a58 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -16,7 +16,8 @@ Class { '#resetBlock', '#environment', '#systemNavigation', - '#syntaxHighlightTheme => ObservableSlot' + '#syntaxHighlightTheme => ObservableSlot'. + '#styleScheme' ], #category : 'Spec2-Code-Base', #package : 'Spec2-Code', @@ -728,6 +729,27 @@ SpCodePresenter >> syntaxHighlightTheme: aSymbol [ syntaxHighlightTheme := aSymbol ] +{ #category : 'api' } +SpCodePresenter >> styleScheme [ + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', + 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', + 'solarized-light', 'tango'" + + ^ styleScheme +] + +{ #category : 'api' } +SpCodePresenter >> styleScheme: aSymbol [ + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', + 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', + 'solarized-light', 'tango'. + + Note: In morphic this will be interpreted as a simple style (since you can use a style + to define a scheme)" + + styleScheme := aSymbol +] + { #category : 'command support' } SpCodePresenter >> systemNavigation [ @@ -865,3 +887,4 @@ SpCodePresenter >> withoutSyntaxHighlight [ self syntaxHighlight: false ] + From 65e5846fbbd85ec0e41cc164e92b68ab58196f6e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:40:24 +0200 Subject: [PATCH 53/88] not used --- src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st index 89ff66bcc..8986f1d8d 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBaseTextAdapter.class.st @@ -128,8 +128,7 @@ SpMorphicBaseTextAdapter >> getText [ { #category : 'spec protocol' } SpMorphicBaseTextAdapter >> hasUnacceptedEdits: aBoolean [ - - self model hasUnacceptedEdits: aBoolean + "not used" ] { #category : 'initialization' } From a7a72388059c2498ba1bf8867fae80ff1d858643 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 11:43:04 +0200 Subject: [PATCH 54/88] oops... typo --- src/Spec2-Code/SpCodePresenter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 5e10e8a58..8d53e58bf 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -16,7 +16,7 @@ Class { '#resetBlock', '#environment', '#systemNavigation', - '#syntaxHighlightTheme => ObservableSlot'. + '#syntaxHighlightTheme => ObservableSlot', '#styleScheme' ], #category : 'Spec2-Code-Base', From 7cbadf472c7dd6cbb3ce998415d88497d16777c4 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 12:53:54 +0200 Subject: [PATCH 55/88] delegate basic inform to backend (since we can use different notification methods) --- .../SpMorphicBackend.class.st | 13 ++- .../SpMorphicListViewAdapter.class.st | 14 +-- .../SpMorphicListViewDataSource.class.st | 12 ++- .../SpRubTextFieldArea.class.st | 2 +- src/Spec2-Core/Character.extension.st | 4 +- src/Spec2-Core/KMKeyCombination.extension.st | 4 +- .../SpAbstractTextPresenter.class.st | 2 - src/Spec2-Core/SpAction.class.st | 34 +++--- src/Spec2-Core/SpActionGroup.class.st | 22 ++-- src/Spec2-Core/SpApplicationBackend.class.st | 6 ++ src/Spec2-Core/SpBaseActionGroup.class.st | 10 +- src/Spec2-Core/SpDropDownPresenter.class.st | 54 +++++----- .../SpEasyListRowPresenter.class.st | 26 ++--- .../SpEasyListViewPresenter.class.st | 102 +++++++++--------- src/Spec2-Core/SpListViewPresenter.class.st | 34 +++--- src/Spec2-Core/SpNotificationCenter.class.st | 24 +++-- src/Spec2-Core/SpNotificationItem.class.st | 14 +-- src/Spec2-Core/SpTActionContainer.trait.st | 24 +++-- src/Spec2-Core/SpTSelectionMode.trait.st | 52 ++++----- .../SpTextInputFieldPresenter.class.st | 2 +- src/Spec2-Core/SpTextPresenter.class.st | 2 +- 21 files changed, 248 insertions(+), 209 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBackend.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBackend.class.st index 474f66cd1..3b347afc5 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBackend.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBackend.class.st @@ -39,6 +39,15 @@ SpMorphicBackend >> forceDefer: aBlock [ UIManager default defer: aBlock ] +{ #category : 'ui - dialogs' } +SpMorphicBackend >> inform: aString [ + + (ProvideAnswerNotification signal: aString) ifNotNil: [ :answer | ^ true ]. + GrowlMorph + openWithLabel: 'Information' translated + contents: aString +] + { #category : 'private - notifying' } SpMorphicBackend >> notifyError: aSpecNotification [ @@ -57,13 +66,13 @@ SpMorphicBackend >> notifyInfo: aSpecNotification [ contents: aSpecNotification message ] -{ #category : 'ui dialogs' } +{ #category : 'ui - dialogs' } SpMorphicBackend >> selectDirectoryTitle: aString [ ^ UIManager default chooseDirectory: aString path: '' ] -{ #category : 'ui dialogs' } +{ #category : 'ui - dialogs' } SpMorphicBackend >> selectFileTitle: aString [ ^ UIManager default diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st index 10e1c2874..9b10b10e8 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st @@ -2,12 +2,14 @@ A morphic adapter for `SpListViewPresenter` " Class { - #name : #SpMorphicListViewAdapter, - #superclass : #SpMorphicListAdapter, - #category : #'Spec2-Adapters-Morphic-ListView' + #name : 'SpMorphicListViewAdapter', + #superclass : 'SpMorphicListAdapter', + #category : 'Spec2-Adapters-Morphic-ListView', + #package : 'Spec2-Adapters-Morphic', + #tag : 'ListView' } -{ #category : #factory } +{ #category : 'factory' } SpMorphicListViewAdapter >> buildWidget [ | datasource | @@ -25,13 +27,13 @@ SpMorphicListViewAdapter >> buildWidget [ ^ widget ] -{ #category : #factory } +{ #category : 'factory' } SpMorphicListViewAdapter >> newDataSource [ ^ SpMorphicListViewDataSource new ] -{ #category : #factory } +{ #category : 'factory' } SpMorphicListViewAdapter >> newTableWith: datasource [ ^ SpFTTableMorph new diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st b/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st index b9074da46..a82a507dc 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st @@ -2,12 +2,14 @@ A morphic datasource for `SpListViewPresenter`, to be used on the `SpMorphicListViewAdapter`. " Class { - #name : #SpMorphicListViewDataSource, - #superclass : #SpMorphicListDataSource, - #category : #'Spec2-Adapters-Morphic-ListView' + #name : 'SpMorphicListViewDataSource', + #superclass : 'SpMorphicListDataSource', + #category : 'Spec2-Adapters-Morphic-ListView', + #package : 'Spec2-Adapters-Morphic', + #tag : 'ListView' } -{ #category : #accessing } +{ #category : 'accessing' } SpMorphicListViewDataSource >> cellColumn: column row: rowIndex [ | cell contentPresenter | @@ -21,7 +23,7 @@ SpMorphicListViewDataSource >> cellColumn: column row: rowIndex [ ^ cell addMorphBack: contentPresenter build ] -{ #category : #accessing } +{ #category : 'accessing' } SpMorphicListViewDataSource >> headerColumn: column [ column id ifNil: [ ^ nil ]. diff --git a/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st b/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st index af2a771d4..bc19c226e 100644 --- a/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st +++ b/src/Spec2-Adapters-Morphic/SpRubTextFieldArea.class.st @@ -12,7 +12,7 @@ SpRubTextFieldArea >> defaultBounds [ ^ super defaultBounds topLeft extent: 3@3 ] -{ #category : #geometry } +{ #category : 'geometry' } SpRubTextFieldArea >> height [ ^ super height max: 1 diff --git a/src/Spec2-Core/Character.extension.st b/src/Spec2-Core/Character.extension.st index 9099d9d64..5faa95ae6 100644 --- a/src/Spec2-Core/Character.extension.st +++ b/src/Spec2-Core/Character.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #Character } +Extension { #name : 'Character' } -{ #category : #'*Spec2-Core' } +{ #category : '*Spec2-Core' } Character >> actionModifier [ "Define the action action modifier depending in which platform we are running. e.g. $x actionModifier will resolve in $x ctrl in unix and windows systems and $x command diff --git a/src/Spec2-Core/KMKeyCombination.extension.st b/src/Spec2-Core/KMKeyCombination.extension.st index b159f60f1..241ed8f99 100644 --- a/src/Spec2-Core/KMKeyCombination.extension.st +++ b/src/Spec2-Core/KMKeyCombination.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #KMKeyCombination } +Extension { #name : 'KMKeyCombination' } -{ #category : #'*Spec2-Core' } +{ #category : '*Spec2-Core' } KMKeyCombination >> actionModifier [ "Define the action action modifier depending in which platform we are running. e.g. $x actionModifier will resolve in $x ctrl in unix and windows systems and $x command diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index fbe8d0e35..edabd4c0d 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -86,14 +86,12 @@ SpAbstractTextPresenter >> cursorPositionIndex: index [ ^ self withAdapterDo: [ :anAdapter | anAdapter cursorPositionIndex: index ] ] - { #category : 'private' } SpAbstractTextPresenter >> editable: aBoolean [ editable := aBoolean ] - { #category : 'api' } SpAbstractTextPresenter >> enabled: aBoolean [ "Set if the widget is enabled (clickable or focusable)" diff --git a/src/Spec2-Core/SpAction.class.st b/src/Spec2-Core/SpAction.class.st index 3785a27c2..f134aaa33 100644 --- a/src/Spec2-Core/SpAction.class.st +++ b/src/Spec2-Core/SpAction.class.st @@ -2,18 +2,20 @@ An action is a spec command (`SpCommand`) that will be used for context menus and/or shortcuts in the presenters that implement `SpTActionContainer` " Class { - #name : #SpAction, - #superclass : #SpCommand, + #name : 'SpAction', + #superclass : 'SpCommand', #instVars : [ 'action', 'actionEnabled', 'visible', 'actionVisible' ], - #category : #'Spec2-Core-Base-Command' + #category : 'Spec2-Core-Base-Command', + #package : 'Spec2-Core', + #tag : 'Base-Command' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpAction class >> newName: aName action: aBlock [ ^ self new @@ -22,7 +24,7 @@ SpAction class >> newName: aName action: aBlock [ yourself ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpAction class >> newName: aName shortcut: aShortcut action: aBlock [ ^ self new @@ -32,7 +34,7 @@ SpAction class >> newName: aName shortcut: aShortcut action: aBlock [ yourself ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpAction class >> newShortcut: aShortcut action: aBlock [ "action without menu entry" @@ -44,38 +46,38 @@ SpAction class >> newShortcut: aShortcut action: aBlock [ yourself ] -{ #category : #accessing } +{ #category : 'accessing' } SpAction >> action: aBlock [ action := aBlock ] -{ #category : #accessing } +{ #category : 'accessing' } SpAction >> actionEnabled: aBlock [ actionEnabled := aBlock ] -{ #category : #accessing } +{ #category : 'accessing' } SpAction >> actionVisible: aBlock [ actionVisible := aBlock ] -{ #category : #accessing } +{ #category : 'accessing' } SpAction >> beShortcutOnly [ visible := false ] -{ #category : #testing } +{ #category : 'testing' } SpAction >> canBeExecuted [ actionEnabled ifNil: [ ^ true ]. ^ actionEnabled cull: self context ] -{ #category : #executing } +{ #category : 'executing' } SpAction >> execute [ action ifNil: [ ^ self ]. @@ -84,7 +86,7 @@ SpAction >> execute [ action cull: self context ] -{ #category : #initialization } +{ #category : 'initialization' } SpAction >> initialize [ decoratedCommand := CmCommand new. @@ -94,14 +96,14 @@ SpAction >> initialize [ ] -{ #category : #testing } +{ #category : 'testing' } SpAction >> isVisible [ ^ visible and: [ actionVisible isNil or: [ actionVisible value ] ] ] -{ #category : #printing } +{ #category : 'printing' } SpAction >> printOn: stream [ stream << 'a SpAction('. @@ -112,7 +114,7 @@ SpAction >> printOn: stream [ stream << ')' ] -{ #category : #accessing } +{ #category : 'accessing' } SpAction >> shortcut: aKeyCombination [ "just a synonym" diff --git a/src/Spec2-Core/SpActionGroup.class.st b/src/Spec2-Core/SpActionGroup.class.st index 433315128..36b8b998c 100644 --- a/src/Spec2-Core/SpActionGroup.class.st +++ b/src/Spec2-Core/SpActionGroup.class.st @@ -2,12 +2,14 @@ An action group is a spec command group (`SpCommandGroup`) that will be used for context menus and/or shortcuts in the presenters that implement `SpTActionContainer` " Class { - #name : #SpActionGroup, - #superclass : #SpCommandGroup, - #category : #'Spec2-Core-Base-Command' + #name : 'SpActionGroup', + #superclass : 'SpCommandGroup', + #category : 'Spec2-Core-Base-Command', + #package : 'Spec2-Core', + #tag : 'Base-Command' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpActionGroup class >> newName: aName [ ^ self new @@ -15,7 +17,7 @@ SpActionGroup class >> newName: aName [ yourself ] -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpActionGroup class >> newName: aName with: aBlock [ ^ (self newName: aName) @@ -23,13 +25,13 @@ SpActionGroup class >> newName: aName with: aBlock [ yourself ] -{ #category : #accessing } +{ #category : 'accessing' } SpActionGroup >> add: anAction [ self register: anAction ] -{ #category : #accessing } +{ #category : 'accessing' } SpActionGroup >> addActionWith: aBlock [ | action | @@ -38,7 +40,7 @@ SpActionGroup >> addActionWith: aBlock [ self add: action ] -{ #category : #accessing } +{ #category : 'accessing' } SpActionGroup >> addGroupWith: aBlock [ | action | @@ -48,7 +50,7 @@ SpActionGroup >> addGroupWith: aBlock [ ] -{ #category : #accessing } +{ #category : 'accessing' } SpActionGroup >> addShortcutWith: aBlock [ | action | @@ -58,7 +60,7 @@ SpActionGroup >> addShortcutWith: aBlock [ self add: action ] -{ #category : #initialization } +{ #category : 'initialization' } SpActionGroup >> initialize [ decoratedGroup := SpBaseActionGroup new. diff --git a/src/Spec2-Core/SpApplicationBackend.class.st b/src/Spec2-Core/SpApplicationBackend.class.st index 49599fa45..d42ca09a2 100644 --- a/src/Spec2-Core/SpApplicationBackend.class.st +++ b/src/Spec2-Core/SpApplicationBackend.class.st @@ -49,6 +49,12 @@ SpApplicationBackend >> defaultConfigurationFor: anApplication [ ^ self subclassResponsibility ] +{ #category : 'ui - dialogs' } +SpApplicationBackend >> inform: aString [ + + self subclassResponsibility +] + { #category : 'initialization' } SpApplicationBackend >> initialize [ diff --git a/src/Spec2-Core/SpBaseActionGroup.class.st b/src/Spec2-Core/SpBaseActionGroup.class.st index c93bf44d0..1b7ad6017 100644 --- a/src/Spec2-Core/SpBaseActionGroup.class.st +++ b/src/Spec2-Core/SpBaseActionGroup.class.st @@ -1,10 +1,12 @@ Class { - #name : #SpBaseActionGroup, - #superclass : #CmCommandGroup, - #category : #'Spec2-Core-Base-Command' + #name : 'SpBaseActionGroup', + #superclass : 'CmCommandGroup', + #category : 'Spec2-Core-Base-Command', + #package : 'Spec2-Core', + #tag : 'Base-Command' } -{ #category : #private } +{ #category : 'private' } SpBaseActionGroup >> ensureNotDuplicated: aCommandOrGroup [ "we do not really care if this has not name (since groups as sections may not show it and actions as shortcuts do not need it)" diff --git a/src/Spec2-Core/SpDropDownPresenter.class.st b/src/Spec2-Core/SpDropDownPresenter.class.st index e587ba9f5..3fc609bb0 100644 --- a/src/Spec2-Core/SpDropDownPresenter.class.st +++ b/src/Spec2-Core/SpDropDownPresenter.class.st @@ -1,6 +1,6 @@ Class { - #name : #SpDropDownPresenter, - #superclass : #SpAbstractWidgetPresenter, + #name : 'SpDropDownPresenter', + #superclass : 'SpAbstractWidgetPresenter', #instVars : [ 'setupAction', 'bindAction', @@ -8,34 +8,36 @@ Class { 'display', 'selection' ], - #category : #'Spec2-Core-Widgets-ListView' + #category : 'Spec2-Core-Widgets-ListView', + #package : 'Spec2-Core', + #tag : 'Widgets-ListView' } -{ #category : #specs } +{ #category : 'specs' } SpDropDownPresenter class >> adapterName [ ^ #DropDownAdapter ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> bind: aBlock [ bindAction := aBlock ] -{ #category : #private } +{ #category : 'private' } SpDropDownPresenter >> bindAction [ ^ bindAction ] -{ #category : #private } +{ #category : 'private' } SpDropDownPresenter >> display [ ^ display ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> display: aBlock [ "Set the block that will be applied on the selected list item. The result of the block will be used to display the item on the screen, @@ -46,7 +48,7 @@ SpDropDownPresenter >> display: aBlock [ display := aBlock ] -{ #category : #initialization } +{ #category : 'initialization' } SpDropDownPresenter >> initialize [ super initialize. @@ -56,7 +58,7 @@ SpDropDownPresenter >> initialize [ self display: [ :anObject | anObject asString ] ] -{ #category : #initialization } +{ #category : 'initialization' } SpDropDownPresenter >> initializeItemFactory [ "Just set up the defaults (to ensure we have a working list at any moment)" @@ -64,14 +66,14 @@ SpDropDownPresenter >> initializeItemFactory [ self bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> items [ "Answer the items of the list" ^ self model collection ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> items: aSequenceableCollection [ "Set the items of the list. `aSequenceableCollection` is a collection of your domain specific items. @@ -80,7 +82,7 @@ SpDropDownPresenter >> items: aSequenceableCollection [ model collection: aSequenceableCollection ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> model [ "Answer the model for this list. It is tipically, an instance of `SpCollectionListModel`." @@ -88,7 +90,7 @@ SpDropDownPresenter >> model [ ^ model ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> model: aModel [ "Sets the model used to feed the list presenter with elements of the list. It is tipically an instance of `SpCollectionListModel`." @@ -98,13 +100,13 @@ SpDropDownPresenter >> model: aModel [ self withAdapterDo: [ :anAdapter | anAdapter refreshList ] ] ] -{ #category : #private } +{ #category : 'private' } SpDropDownPresenter >> newEmptyModel [ ^ SpCollectionListModel on: #() ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selectFirst [ "Select first element in list. Useful to avoid selecting by index." @@ -112,7 +114,7 @@ SpDropDownPresenter >> selectFirst [ ^ self selectIndex: 1 ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selectIndex: anInteger [ "Select item at position `anInteger`. Selection will not scroll the presenter view to show selected element." @@ -120,7 +122,7 @@ SpDropDownPresenter >> selectIndex: anInteger [ self selection selectIndex: anInteger ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selectItem: anItem [ "Select `anItem` if it is included in model list. It does not scrolls to selected element." @@ -128,21 +130,21 @@ SpDropDownPresenter >> selectItem: anItem [ self selection selectItem: anItem ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selectedIndex [ "Return selected index." ^ self selection selectedIndex ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selectedItem [ "Return selected item." ^ self selection selectedItem ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpDropDownPresenter >> selection [ "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). This is not the item selected, but the selection container (it may contain one or many selected @@ -151,19 +153,19 @@ SpDropDownPresenter >> selection [ ^ selection ] -{ #category : #api } +{ #category : 'api' } SpDropDownPresenter >> setup: aBlock [ setupAction := aBlock ] -{ #category : #private } +{ #category : 'private' } SpDropDownPresenter >> setupAction [ ^ setupAction ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpDropDownPresenter >> whenSelectedDo: aBlock [ "Inform when an item was selected (a real object in the items list). `aBlock` receives one argument (the new selected element)" @@ -173,7 +175,7 @@ SpDropDownPresenter >> whenSelectedDo: aBlock [ ifNotNil: [ :item | aBlock value: item ] ] ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpDropDownPresenter >> whenSelectedItemChangedDo: aBlock [ "Inform when the selected item is changed. `aBlock` receive one optional argument: the selected item (can be nil)" @@ -181,7 +183,7 @@ SpDropDownPresenter >> whenSelectedItemChangedDo: aBlock [ self selection whenChangedDo: [ aBlock cull: self selectedItem ] ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpDropDownPresenter >> whenSelectionChangedDo: aBlock [ "Inform when there are changes in selection. This method works for all selection modes (single, multiple and no selection). diff --git a/src/Spec2-Core/SpEasyListRowPresenter.class.st b/src/Spec2-Core/SpEasyListRowPresenter.class.st index ab099a9e0..1a679dff7 100644 --- a/src/Spec2-Core/SpEasyListRowPresenter.class.st +++ b/src/Spec2-Core/SpEasyListRowPresenter.class.st @@ -1,6 +1,6 @@ Class { - #name : #SpEasyListRowPresenter, - #superclass : #SpPresenter, + #name : 'SpEasyListRowPresenter', + #superclass : 'SpPresenter', #traits : 'SpTModel', #classTraits : 'SpTModel classTrait', #instVars : [ @@ -8,16 +8,18 @@ Class { 'iconPresenter', 'textPresenter' ], - #category : #'Spec2-Core-Widgets-ListView' + #category : 'Spec2-Core-Widgets-ListView', + #package : 'Spec2-Core', + #tag : 'Widgets-ListView' } -{ #category : #layout } +{ #category : 'layout' } SpEasyListRowPresenter >> defaultLayout [ ^ self textLayout ] -{ #category : #layout } +{ #category : 'layout' } SpEasyListRowPresenter >> iconLayout [ ^ SpBoxLayout newHorizontal @@ -27,20 +29,20 @@ SpEasyListRowPresenter >> iconLayout [ yourself ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListRowPresenter >> initializePresenters [ iconPresenter := self newImage. textPresenter := self newLabel ] -{ #category : #accessing } +{ #category : 'accessing' } SpEasyListRowPresenter >> listView [ ^ listView ] -{ #category : #accessing } +{ #category : 'accessing' } SpEasyListRowPresenter >> listView: aListView [ listView := aListView. @@ -49,7 +51,7 @@ SpEasyListRowPresenter >> listView: aListView [ ifFalse: [ self useTextLayout ] ] -{ #category : #layout } +{ #category : 'layout' } SpEasyListRowPresenter >> textLayout [ ^ SpBoxLayout newHorizontal @@ -57,7 +59,7 @@ SpEasyListRowPresenter >> textLayout [ yourself ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListRowPresenter >> updatePresenter [ self model ifNil: [ ^ self ]. @@ -67,13 +69,13 @@ SpEasyListRowPresenter >> updatePresenter [ textPresenter label: (self listView display value: self model) ] -{ #category : #layout } +{ #category : 'layout' } SpEasyListRowPresenter >> useIconLayout [ self layout: self iconLayout ] -{ #category : #layout } +{ #category : 'layout' } SpEasyListRowPresenter >> useTextLayout [ self layout: self textLayout diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-Core/SpEasyListViewPresenter.class.st index 33bdfed98..6a31a0deb 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-Core/SpEasyListViewPresenter.class.st @@ -1,6 +1,6 @@ Class { - #name : #SpEasyListViewPresenter, - #superclass : #SpPresenter, + #name : 'SpEasyListViewPresenter', + #superclass : 'SpPresenter', #traits : 'SpTSearchable', #classTraits : 'SpTSearchable classTrait', #instVars : [ @@ -11,16 +11,18 @@ Class { '#headerPanel', '#lastSelectedRow => WeakSlot' ], - #category : #'Spec2-Core-Widgets-ListView' + #category : 'Spec2-Core-Widgets-ListView', + #package : 'Spec2-Core', + #tag : 'Widgets-ListView' } -{ #category : #specs } +{ #category : 'specs' } SpEasyListViewPresenter class >> adapterName [ ^ #EasyListViewAdapter ] -{ #category : #examples } +{ #category : 'examples' } SpEasyListViewPresenter class >> example [ "This example show a simple list with all classes, using all the default settings." @@ -31,7 +33,7 @@ SpEasyListViewPresenter class >> example [ yourself ] -{ #category : #examples } +{ #category : 'examples' } SpEasyListViewPresenter class >> exampleMultipleSelection [ ^ self new @@ -42,7 +44,7 @@ SpEasyListViewPresenter class >> exampleMultipleSelection [ yourself ] -{ #category : #examples } +{ #category : 'examples' } SpEasyListViewPresenter class >> exampleWithHeaderTitle [ ^ self new @@ -53,7 +55,7 @@ SpEasyListViewPresenter class >> exampleWithHeaderTitle [ yourself ] -{ #category : #examples } +{ #category : 'examples' } SpEasyListViewPresenter class >> exampleWithIcons [ "This example show a simple list with icons." @@ -65,31 +67,31 @@ SpEasyListViewPresenter class >> exampleWithIcons [ yourself ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpEasyListViewPresenter >> actionGroup [ ^ listView actionGroup ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpEasyListViewPresenter >> actionGroup: aSpCommandGroup [ listView actionGroup: aSpCommandGroup ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> activateOnDoubleClick [ listView activateOnDoubleClick ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> activateOnSingleClick [ listView activateOnSingleClick ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> activateSearchWith: aString [ lastSelectedRow := listView selectedItem. @@ -101,31 +103,31 @@ SpEasyListViewPresenter >> activateSearchWith: aString [ searchInput cursorPositionIndex: aString size ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpEasyListViewPresenter >> addAction: aSpCommand [ listView addAction: aSpCommand ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> addScrollBarStyle: aStyle [ listView addScrollBarStyle: aStyle ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> beMultipleSelection [ listView beMultipleSelection ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> beSingleSelection [ listView beSingleSelection ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListViewPresenter >> connectPresenters [ searchInput @@ -142,7 +144,7 @@ SpEasyListViewPresenter >> connectPresenters [ whenFocusReceivedDo: [ :event | searchInput hide ] ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> deactivateSearch: acceptSelection [ | currentSelection | @@ -154,7 +156,7 @@ SpEasyListViewPresenter >> deactivateSearch: acceptSelection [ listView takeKeyboardFocus ] -{ #category : #layout } +{ #category : 'layout' } SpEasyListViewPresenter >> defaultLayout [ ^ SpOverlayLayout new @@ -166,13 +168,13 @@ SpEasyListViewPresenter >> defaultLayout [ yourself ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> disable [ self enabled: false ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> display [ "Answer the display block that will transform the objects from `SpAbstractListPresenter>>#model` into a displayable string." @@ -180,7 +182,7 @@ SpEasyListViewPresenter >> display [ ^ display ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> display: aBlock [ "Set the block that will be applied on each of the list items. The result of the block will be used to display the item on the screen. @@ -197,14 +199,14 @@ SpEasyListViewPresenter >> display: aBlock [ display := aBlock ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> displayIcon [ "Return the block used to return an icon that will be displayed in the list" ^ displayIcon ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> displayIcon: aBlock [ "Set a block which takes an item as argument and returns the icon to display in the list. `aBlock` receives one argument" @@ -212,19 +214,19 @@ SpEasyListViewPresenter >> displayIcon: aBlock [ displayIcon := aBlock ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> displayValueFor: anObject [ ^ self display value: anObject ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> enable [ self enabled: true ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> findFirst: aString [ | items | @@ -240,28 +242,28 @@ SpEasyListViewPresenter >> findFirst: aString [ ^ 0 ] -{ #category : #testing } +{ #category : 'testing' } SpEasyListViewPresenter >> hasHeaderTitle [ "Answer true if the list has a title (See `SpListPresenter>>#headerTitle:`)." ^ headerPanel isVisible ] -{ #category : #testing } +{ #category : 'testing' } SpEasyListViewPresenter >> hasIcons [ "Answer true if the list has an icon provider (See `SpListPresenter>>#icons:`)." ^ self displayIcon notNil ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> headerTitle [ "Answer the header title." ^ headerPanel label ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> headerTitle: aString [ "Set the header title." @@ -271,13 +273,13 @@ SpEasyListViewPresenter >> headerTitle: aString [ ifFalse: [ headerPanel show ] ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> hideHeaderTitle [ headerPanel hide ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> iconFor: anItem [ ^ self displayIcon @@ -285,7 +287,7 @@ SpEasyListViewPresenter >> iconFor: anItem [ cull: self ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListViewPresenter >> initialize [ super initialize. @@ -293,7 +295,7 @@ SpEasyListViewPresenter >> initialize [ display := [ :object | object asString ] ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListViewPresenter >> initializePresenters [ headerPanel := self newLabel. @@ -311,19 +313,19 @@ SpEasyListViewPresenter >> initializePresenters [ searchInput hide ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> items [ ^ listView items ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> items: anOrderedCollection [ listView items: anOrderedCollection ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> maybeActivateSearchOn: event [ self isSearchEnabled ifFalse: [ ^ self ]. @@ -334,13 +336,13 @@ SpEasyListViewPresenter >> maybeActivateSearchOn: event [ self activateSearchWith: event keyCharacter asString ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> model [ ^ listView model ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListViewPresenter >> registerEvents [ super registerEvents. @@ -348,19 +350,19 @@ SpEasyListViewPresenter >> registerEvents [ self whenDisplayChangedDo: [ listView refresh ] ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> removeScrollBarStyle: aStyle [ ^ listView removeScrollBarStyle: aStyle ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> scrollBarStyles [ ^ listView scrollBarStyles ] -{ #category : #private } +{ #category : 'private' } SpEasyListViewPresenter >> selectFirst: aString [ | index | @@ -370,19 +372,19 @@ SpEasyListViewPresenter >> selectFirst: aString [ listView selectIndex: index scrollToSelection: true ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpEasyListViewPresenter >> selectedItem [ ^ listView selectedItem ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> updateItemsKeepingSelection: aCollection [ listView updateItemsKeepingSelection: aCollection ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpEasyListViewPresenter >> whenDisplayChangedDo: aBlock [ "Inform when the display block has changed. `aBlock` has three optional arguments: @@ -393,7 +395,7 @@ SpEasyListViewPresenter >> whenDisplayChangedDo: aBlock [ self property: #display whenChangedDo: aBlock ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpEasyListViewPresenter >> whenIconsChangedDo: aBlock [ "Inform when the icons block has changed. `aBlock` has three optional arguments: @@ -404,13 +406,13 @@ SpEasyListViewPresenter >> whenIconsChangedDo: aBlock [ self property: #displayIcon whenChangedDo: aBlock ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> withScrollBars [ listView withScrollBars ] -{ #category : #api } +{ #category : 'api' } SpEasyListViewPresenter >> withoutScrollBars [ listView withoutScrollBars diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-Core/SpListViewPresenter.class.st index 275f8ee2c..d30c177e4 100644 --- a/src/Spec2-Core/SpListViewPresenter.class.st +++ b/src/Spec2-Core/SpListViewPresenter.class.st @@ -1,55 +1,57 @@ Class { - #name : #SpListViewPresenter, - #superclass : #SpAbstractListPresenter, + #name : 'SpListViewPresenter', + #superclass : 'SpAbstractListPresenter', #classTraits : 'SpTActionContainer classTrait', #instVars : [ '#setupAction', '#bindAction', '#headerTitle => ObservableSlot' ], - #category : #'Spec2-Core-Widgets-ListView' + #category : 'Spec2-Core-Widgets-ListView', + #package : 'Spec2-Core', + #tag : 'Widgets-ListView' } -{ #category : #specs } +{ #category : 'specs' } SpListViewPresenter class >> adapterName [ ^ #ListViewAdapter ] -{ #category : #api } +{ #category : 'api' } SpListViewPresenter >> bind: aBlock [ bindAction := aBlock ] -{ #category : #private } +{ #category : 'private' } SpListViewPresenter >> bindAction [ ^ bindAction ] -{ #category : #testing } +{ #category : 'testing' } SpListViewPresenter >> hasHeaderTitle [ "Answer true if the list has a title (See `SpListPresenter>>#headerTitle:`)." ^ headerTitle isEmptyOrNil not ] -{ #category : #api } +{ #category : 'api' } SpListViewPresenter >> headerTitle [ "Answer the header title." ^ headerTitle ] -{ #category : #api } +{ #category : 'api' } SpListViewPresenter >> headerTitle: aString [ "Set the header title." headerTitle := aString ] -{ #category : #initialization } +{ #category : 'initialization' } SpListViewPresenter >> initialize [ super initialize. @@ -58,7 +60,7 @@ SpListViewPresenter >> initialize [ ] -{ #category : #initialization } +{ #category : 'initialization' } SpListViewPresenter >> initializeItemFactory [ "Just set up the defaults (to ensure we have a working list at any moment)" @@ -66,7 +68,7 @@ SpListViewPresenter >> initializeItemFactory [ self bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] ] -{ #category : #initialization } +{ #category : 'initialization' } SpListViewPresenter >> registerActions [ self addActionWith: [ :action | action @@ -75,7 +77,7 @@ SpListViewPresenter >> registerActions [ action: [ self showContextMenu ] ] ] -{ #category : #initialization } +{ #category : 'initialization' } SpListViewPresenter >> registerEvents [ super registerEvents. @@ -86,19 +88,19 @@ SpListViewPresenter >> registerEvents [ self withAdapterDo: [ :anAdapter | anAdapter refreshList ] ] ] -{ #category : #api } +{ #category : 'api' } SpListViewPresenter >> setup: aBlock [ setupAction := aBlock ] -{ #category : #private } +{ #category : 'private' } SpListViewPresenter >> setupAction [ ^ setupAction ] -{ #category : #api } +{ #category : 'api' } SpListViewPresenter >> showContextMenu [ "If the presenter is displayed, shows the associated context menu" diff --git a/src/Spec2-Core/SpNotificationCenter.class.st b/src/Spec2-Core/SpNotificationCenter.class.st index 666432b39..3a5130235 100644 --- a/src/Spec2-Core/SpNotificationCenter.class.st +++ b/src/Spec2-Core/SpNotificationCenter.class.st @@ -2,17 +2,19 @@ I'm a simple object holding a limited list of notification items. " Class { - #name : #SpNotificationCenter, - #superclass : #Object, + #name : 'SpNotificationCenter', + #superclass : 'Object', #instVars : [ 'items', 'limit', 'application' ], - #category : #'Spec2-Core-Notification' + #category : 'Spec2-Core-Notification', + #package : 'Spec2-Core', + #tag : 'Notification' } -{ #category : #adding } +{ #category : 'adding' } SpNotificationCenter >> add: aSpNotificationItem [ items size > limit ifTrue: [ items removeLast: self bulkSize ]. @@ -20,12 +22,12 @@ SpNotificationCenter >> add: aSpNotificationItem [ self updateIfNecessary. ] -{ #category : #accessing } +{ #category : 'accessing' } SpNotificationCenter >> application [ ^ application ] -{ #category : #adding } +{ #category : 'adding' } SpNotificationCenter >> bulkSize [ "Returns the number of itesm that should be removed when the limit is reached. Pay attention that the limit MUST always be larger than bulkSize" @@ -33,13 +35,13 @@ SpNotificationCenter >> bulkSize [ ^ 5 ] -{ #category : #adding } +{ #category : 'adding' } SpNotificationCenter >> forApplication: app [ application := app ] -{ #category : #initialization } +{ #category : 'initialization' } SpNotificationCenter >> initialize [ super initialize. @@ -49,17 +51,17 @@ SpNotificationCenter >> initialize [ items := OrderedCollection new. ] -{ #category : #accessing } +{ #category : 'accessing' } SpNotificationCenter >> items [ ^ items ] -{ #category : #accessing } +{ #category : 'accessing' } SpNotificationCenter >> limit [ ^ limit ] -{ #category : #adding } +{ #category : 'adding' } SpNotificationCenter >> updateIfNecessary [ | notifs | diff --git a/src/Spec2-Core/SpNotificationItem.class.st b/src/Spec2-Core/SpNotificationItem.class.st index 3c369893d..7b60d98d0 100644 --- a/src/Spec2-Core/SpNotificationItem.class.st +++ b/src/Spec2-Core/SpNotificationItem.class.st @@ -2,26 +2,28 @@ I'm a simple object representing a notification. " Class { - #name : #SpNotificationItem, - #superclass : #Object, + #name : 'SpNotificationItem', + #superclass : 'Object', #instVars : [ 'text' ], - #category : #'Spec2-Core-Notification' + #category : 'Spec2-Core-Notification', + #package : 'Spec2-Core', + #tag : 'Notification' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } SpNotificationItem class >> with: aString [ ^ self new text: aString ; yourself ] -{ #category : #accessing } +{ #category : 'accessing' } SpNotificationItem >> text [ ^ text ] -{ #category : #accessing } +{ #category : 'accessing' } SpNotificationItem >> text: aString [ text := aString ] diff --git a/src/Spec2-Core/SpTActionContainer.trait.st b/src/Spec2-Core/SpTActionContainer.trait.st index 1bd498858..6dfa32495 100644 --- a/src/Spec2-Core/SpTActionContainer.trait.st +++ b/src/Spec2-Core/SpTActionContainer.trait.st @@ -1,18 +1,20 @@ Trait { - #name : #SpTActionContainer, + #name : 'SpTActionContainer', #instVars : [ 'actionGroup' ], - #category : #'Spec2-Core-Base-Command' + #category : 'Spec2-Core-Base-Command', + #package : 'Spec2-Core', + #tag : 'Base-Command' } -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> actionGroup [ ^ actionGroup ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> actionGroup: aSpCommandGroup [ "WARNING. Defining action in presenters that are not able to grab the keyboard focus is mostly useless (because they will never have the focus to answer to). @@ -24,7 +26,7 @@ SpTActionContainer >> actionGroup: aSpCommandGroup [ ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> actionsWith: aBlock [ "WARNING. Defining action in presenters that are not able to grab the keyboard focus is mostly useless (because they will never have the focus to answer to). @@ -35,19 +37,19 @@ SpTActionContainer >> actionsWith: aBlock [ aBlock value: self ensureActionGroup ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> addAction: aSpCommand [ self ensureActionGroup add: aSpCommand ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> addActionWith: aBlock [ self ensureActionGroup addActionWith: aBlock ] -{ #category : #'api - actions' } +{ #category : 'api - actions' } SpTActionContainer >> addShortcutWith: aBlock [ "WARNING. Defining action in presenters that are not able to grab the keyboard focus is mostly useless (because they will never have the focus to answer to). @@ -57,20 +59,20 @@ SpTActionContainer >> addShortcutWith: aBlock [ self ensureActionGroup addShortcutWith: aBlock ] -{ #category : #private } +{ #category : 'private' } SpTActionContainer >> ensureActionGroup [ ^ actionGroup ifNil: [ actionGroup := SpActionGroup new beRoot ] ] -{ #category : #initialization } +{ #category : 'initialization' } SpTActionContainer >> initialize [ self class initializeSlots: self. super initialize. ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTActionContainer >> whenCommandGroupChangedDo: aBlock [ "Inform when menu definition changed. `aBlock` receives zero arguments." diff --git a/src/Spec2-Core/SpTSelectionMode.trait.st b/src/Spec2-Core/SpTSelectionMode.trait.st index ef495c519..09ec03dc6 100644 --- a/src/Spec2-Core/SpTSelectionMode.trait.st +++ b/src/Spec2-Core/SpTSelectionMode.trait.st @@ -2,14 +2,16 @@ Add selectable api to widgets " Trait { - #name : #SpTSelectionMode, + #name : 'SpTSelectionMode', #instVars : [ 'selectionMode' ], - #category : #'Spec2-Core-Widgets-Table' + #category : 'Spec2-Core-Widgets-Table', + #package : 'Spec2-Core', + #tag : 'Widgets-Table' } -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectAll [ "Select all items in the list or table. It does not triggers activation event." @@ -17,7 +19,7 @@ SpTSelectionMode >> selectAll [ self selection selectAll ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectFirst [ "Select first element in list. Useful to avoid selecting by index." @@ -25,7 +27,7 @@ SpTSelectionMode >> selectFirst [ ^ self selectIndex: 1 ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectIndex: anInteger [ "Select item at position `anInteger`. Selection will not scroll the presenter view to show selected element." @@ -33,7 +35,7 @@ SpTSelectionMode >> selectIndex: anInteger [ self selectionMode selectIndex: anInteger ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectIndex: anIndex scrollToSelection: shouldScrollToSelection [ "Select item at position `anInteger`. If `shouldScrollToSelection` is true, selection will scroll the presenter view @@ -44,7 +46,7 @@ SpTSelectionMode >> selectIndex: anIndex scrollToSelection: shouldScrollToSelect self verticalAlignment desiredVisibleRow: anIndex ]. ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectIndexes: aCollectionOfIndexes [ "Select items at positions included in `aCollectionOfIndexes`. NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. @@ -53,7 +55,7 @@ SpTSelectionMode >> selectIndexes: aCollectionOfIndexes [ self selectionMode selectIndexes: aCollectionOfIndexes ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectIndexes: aCollectionOfIndexes scrollToSelection: shouldScrollToSelection [ "Select items at positions included in `aCollectionOfIndexes`. NOTE: in single selection mode, first element of `aCollectionOfIndexes` will be selected. @@ -65,7 +67,7 @@ SpTSelectionMode >> selectIndexes: aCollectionOfIndexes scrollToSelection: shoul self verticalAlignment desiredVisibleRow: aCollectionOfIndexes first ]. ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectItem: anItem [ "Select `anItem` if it is included in model list. It does not scrolls to selected element." @@ -73,7 +75,7 @@ SpTSelectionMode >> selectItem: anItem [ self selectionMode selectItem: anItem ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectItem: anItem scrollToSelection: shouldScrollToSelection [ "Select item `anItem`. If `shouldScrollToSelection` is true, selection will scroll the presenter view @@ -84,7 +86,7 @@ SpTSelectionMode >> selectItem: anItem scrollToSelection: shouldScrollToSelectio scrollToSelection: shouldScrollToSelection ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectItems: aCollection [ "Select items included in `aCollection` if they are included in model list. NOTE: In single selection mode it will select the first element of `aCollection` @@ -93,28 +95,28 @@ SpTSelectionMode >> selectItems: aCollection [ self selectionMode selectItems: aCollection ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectedItem [ "Return selected item." ^ self selection selectedItem ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectedItems [ "Return all the selected items in the case of a multiple selection list" ^ self selection selectedItems ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectedItemsSorted [ "Return all the selected items sorted by their index" ^ self itemsAt: self selection selectedIndexes sort ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selection [ "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). This is not the item selected, but the selection container (it may contain one or many selected @@ -123,7 +125,7 @@ SpTSelectionMode >> selection [ ^ self selectionMode ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectionMode [ "Answer the selection object (an instance of `SpSingleSelectionMode` or `SpMultipleSelectionMode`). This is not the item selected, but the selection container (it may contain one or many selected @@ -133,7 +135,7 @@ SpTSelectionMode >> selectionMode [ ^ selectionMode ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> selectionMode: aMode [ selectionMode ifNotNil: [ @@ -141,28 +143,28 @@ SpTSelectionMode >> selectionMode: aMode [ selectionMode := aMode ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> unselectAll [ "Remove all selections" self selection unselectAll ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> unselectIndex: anInteger [ "Remove selection of element at index `anInteger`" self selection unselectIndex: anInteger ] -{ #category : #'api - selection' } +{ #category : 'api - selection' } SpTSelectionMode >> unselectItem: anObject [ "Remove selection of element `anObject`" self selection unselectItem: anObject ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTSelectionMode >> whenNoneSelectedDo: aBlock [ "Inform when the list has clean selection (there are no items selected). `aBlock` receives zero arguments" @@ -172,7 +174,7 @@ SpTSelectionMode >> whenNoneSelectedDo: aBlock [ ifNil: [ aBlock value ] ] ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTSelectionMode >> whenSelectedDo: aBlock [ "Inform when an item was selected (a real object in the items list). `aBlock` receives one argument (the new selected element)" @@ -182,7 +184,7 @@ SpTSelectionMode >> whenSelectedDo: aBlock [ ifNotNil: [ :item | aBlock value: item ] ] ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTSelectionMode >> whenSelectedItemChangedDo: aBlock [ "Inform when the selected item is changed. `aBlock` receive one optional argument: the selected item (can be nil)" @@ -190,7 +192,7 @@ SpTSelectionMode >> whenSelectedItemChangedDo: aBlock [ self selection whenChangedDo: [ aBlock cull: self selectedItem ] ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTSelectionMode >> whenSelectionChangedDo: aBlock [ "Inform when there are changes in selection. This method works for all selection modes (single, multiple and no selection). @@ -199,7 +201,7 @@ SpTSelectionMode >> whenSelectionChangedDo: aBlock [ self selection whenChangedDo: aBlock ] -{ #category : #'api - events' } +{ #category : 'api - events' } SpTSelectionMode >> whenSelectionModeChangedDo: aBlock [ "Inform when selection mode (single/multiple) changed. `aBlock` receives zero arguments." diff --git a/src/Spec2-Core/SpTextInputFieldPresenter.class.st b/src/Spec2-Core/SpTextInputFieldPresenter.class.st index 396068bec..e75b96448 100644 --- a/src/Spec2-Core/SpTextInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpTextInputFieldPresenter.class.st @@ -101,7 +101,7 @@ SpTextInputFieldPresenter >> removeEntryCompletion [ self entryCompletion: nil ] -{ #category : #'api - focus' } +{ #category : 'api - focus' } SpTextInputFieldPresenter >> takeKeyboardFocusWithoutSelecting [ "Causes this presenter to have the keyboard focus for the window it's inside. Unlike `takeKeyboardFocus` this method will not select the text inside." diff --git a/src/Spec2-Core/SpTextPresenter.class.st b/src/Spec2-Core/SpTextPresenter.class.st index e70b1813e..dcbd925c3 100644 --- a/src/Spec2-Core/SpTextPresenter.class.st +++ b/src/Spec2-Core/SpTextPresenter.class.st @@ -161,7 +161,7 @@ SpTextPresenter >> editionCommandsGroup [ toSetContext: self defaultCommandsContext ] -{ #category : #private } +{ #category : 'private' } SpTextPresenter >> editionContextKeyBindings [ ^ self editionCommandsGroup asKMCategory From 929d04f0ad2b9aa55afbb43b82b3145e61801cb2 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 13:36:17 +0200 Subject: [PATCH 56/88] applying deprecations --- .../SpCodeDebugItCommand.class.st | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st b/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st index 549c77d30..c2e4260a9 100644 --- a/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st +++ b/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st @@ -41,17 +41,18 @@ SpCodeDebugItCommand >> compile: aStream for: anObject in: evalContext [ | methodClass | methodClass := evalContext - ifNil: [ anObject class ] - ifNotNil: [ evalContext methodClass ]. + ifNotNil: [ evalContext methodClass ] + ifNil: [ anObject class ]. ^ context class compiler - source: aStream; - class: methodClass; - context: evalContext; - requestor: context; "it should enable a visibility of current tool variables in new debugger" - noPattern: true; - failBlock: [ ^ nil ]; - compile + source: aStream; + class: methodClass; + context: evalContext; + requestor: context; + "it should enable a visibility of current tool variables in new debugger" + isScripting: true; + failBlock: [ ^ nil ]; + compile ] { #category : 'private' } From 78563433a2b83a11e0a0d9d0b76cb0c1b74a7e18 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 13:36:49 +0200 Subject: [PATCH 57/88] delegating to backend --- src/Spec2-Core/SpApplication.class.st | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Spec2-Core/SpApplication.class.st b/src/Spec2-Core/SpApplication.class.st index 6c847e664..3db77e91d 100644 --- a/src/Spec2-Core/SpApplication.class.st +++ b/src/Spec2-Core/SpApplication.class.st @@ -255,10 +255,7 @@ SpApplication >> iconProvider: anIconProvider [ SpApplication >> inform: aString [ "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." - ^ self newInform - title: 'Alert'; - label: aString; - openModal + ^ self backend inform: aString ] { #category : 'accessing' } From ab1861d996f6f66e86b867d8f895c6d6afe54dda Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 19 Oct 2023 15:14:00 +0200 Subject: [PATCH 58/88] format --- src/Spec2-Core/SpApplication.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Spec2-Core/SpApplication.class.st b/src/Spec2-Core/SpApplication.class.st index 3db77e91d..1b068e817 100644 --- a/src/Spec2-Core/SpApplication.class.st +++ b/src/Spec2-Core/SpApplication.class.st @@ -286,7 +286,8 @@ SpApplication >> newPresenter: aPresenterClass [ { #category : 'accessing' } SpApplication >> notificationCenter [ "should be placed in initialize." - ^ notificationCenter ifNil: [ notificationCenter := SpNotificationCenter new forApplication: self; yourself ] + ^ notificationCenter ifNil: [ + notificationCenter := SpNotificationCenter new forApplication: self; yourself ] ] { #category : 'ui - dialogs' } From b7b7495d085567573daf03d7d60aa622c0de9cdf Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 20 Oct 2023 22:45:21 +0200 Subject: [PATCH 59/88] moved to commander2 package to avoid a cyclic dependence --- .../SpAction.class.st | 12 ++++++++--- .../SpActionGroup.class.st | 6 +++--- .../SpBaseActionGroup.class.st | 6 +++--- .../SpTActionContainer.trait.st | 6 +++--- .../SpAbstractSelectionMode.class.st | 8 ++++--- .../SpAbstractTextPresenter.class.st | 8 ------- .../SpAbstractWidgetPresenter.class.st | 8 ++++--- .../SpDialogWindowPresenter.class.st | 21 ++++++++++++++----- src/Spec2-Core/SpWindowPresenter.class.st | 2 +- 9 files changed, 45 insertions(+), 32 deletions(-) rename src/{Spec2-Core => Spec2-Commander2}/SpAction.class.st (92%) rename src/{Spec2-Core => Spec2-Commander2}/SpActionGroup.class.st (93%) rename src/{Spec2-Core => Spec2-Commander2}/SpBaseActionGroup.class.st (81%) rename src/{Spec2-Core => Spec2-Commander2}/SpTActionContainer.trait.st (96%) diff --git a/src/Spec2-Core/SpAction.class.st b/src/Spec2-Commander2/SpAction.class.st similarity index 92% rename from src/Spec2-Core/SpAction.class.st rename to src/Spec2-Commander2/SpAction.class.st index f134aaa33..bf65a923f 100644 --- a/src/Spec2-Core/SpAction.class.st +++ b/src/Spec2-Commander2/SpAction.class.st @@ -10,9 +10,9 @@ Class { 'visible', 'actionVisible' ], - #category : 'Spec2-Core-Base-Command', - #package : 'Spec2-Core', - #tag : 'Base-Command' + #category : 'Spec2-Commander2-Action', + #package : 'Spec2-Commander2', + #tag : 'Action' } { #category : 'instance creation' } @@ -70,6 +70,12 @@ SpAction >> beShortcutOnly [ visible := false ] +{ #category : 'accessing' } +SpAction >> beToggleButton [ + + self configureAsToolBarToggleButton +] + { #category : 'testing' } SpAction >> canBeExecuted [ diff --git a/src/Spec2-Core/SpActionGroup.class.st b/src/Spec2-Commander2/SpActionGroup.class.st similarity index 93% rename from src/Spec2-Core/SpActionGroup.class.st rename to src/Spec2-Commander2/SpActionGroup.class.st index 36b8b998c..7340f4dd8 100644 --- a/src/Spec2-Core/SpActionGroup.class.st +++ b/src/Spec2-Commander2/SpActionGroup.class.st @@ -4,9 +4,9 @@ An action group is a spec command group (`SpCommandGroup`) that will be used for Class { #name : 'SpActionGroup', #superclass : 'SpCommandGroup', - #category : 'Spec2-Core-Base-Command', - #package : 'Spec2-Core', - #tag : 'Base-Command' + #category : 'Spec2-Commander2-Action', + #package : 'Spec2-Commander2', + #tag : 'Action' } { #category : 'instance creation' } diff --git a/src/Spec2-Core/SpBaseActionGroup.class.st b/src/Spec2-Commander2/SpBaseActionGroup.class.st similarity index 81% rename from src/Spec2-Core/SpBaseActionGroup.class.st rename to src/Spec2-Commander2/SpBaseActionGroup.class.st index 1b7ad6017..a6a70e1e4 100644 --- a/src/Spec2-Core/SpBaseActionGroup.class.st +++ b/src/Spec2-Commander2/SpBaseActionGroup.class.st @@ -1,9 +1,9 @@ Class { #name : 'SpBaseActionGroup', #superclass : 'CmCommandGroup', - #category : 'Spec2-Core-Base-Command', - #package : 'Spec2-Core', - #tag : 'Base-Command' + #category : 'Spec2-Commander2-Action', + #package : 'Spec2-Commander2', + #tag : 'Action' } { #category : 'private' } diff --git a/src/Spec2-Core/SpTActionContainer.trait.st b/src/Spec2-Commander2/SpTActionContainer.trait.st similarity index 96% rename from src/Spec2-Core/SpTActionContainer.trait.st rename to src/Spec2-Commander2/SpTActionContainer.trait.st index 6dfa32495..175d1078e 100644 --- a/src/Spec2-Core/SpTActionContainer.trait.st +++ b/src/Spec2-Commander2/SpTActionContainer.trait.st @@ -3,9 +3,9 @@ Trait { #instVars : [ 'actionGroup' ], - #category : 'Spec2-Core-Base-Command', - #package : 'Spec2-Core', - #tag : 'Base-Command' + #category : 'Spec2-Commander2-Action', + #package : 'Spec2-Commander2', + #tag : 'Action' } { #category : 'api - actions' } diff --git a/src/Spec2-Core/SpAbstractSelectionMode.class.st b/src/Spec2-Core/SpAbstractSelectionMode.class.st index 3ddfd76ac..696de4df3 100644 --- a/src/Spec2-Core/SpAbstractSelectionMode.class.st +++ b/src/Spec2-Core/SpAbstractSelectionMode.class.st @@ -18,13 +18,15 @@ Class { { #category : 'documentation' } SpAbstractSelectionMode class >> addDocumentSectionHierarchy: aBuilder [ - + aBuilder newLine. - aBuilder header: [ :builder | builder text: 'Hierarchy' ] withLevel: 2. + aBuilder + header: [ :builder | builder text: 'Hierarchy' ] + withLevel: 2. SpDocumentHierarchyBuilder new fromClass: SpAbstractSelectionMode; builder: aBuilder; - filter: [ :eachClass | eachClass package packageName beginsWith: 'Spec2-' ]; + filter: [ :eachClass | eachClass package name beginsWith: 'Spec2-' ]; buildFor: self ] diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index edabd4c0d..f5ada47d5 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -92,14 +92,6 @@ SpAbstractTextPresenter >> editable: aBoolean [ editable := aBoolean ] -{ #category : 'api' } -SpAbstractTextPresenter >> enabled: aBoolean [ - "Set if the widget is enabled (clickable or focusable)" - - super enabled: aBoolean. - self changed: #enabled: with: { aBoolean } -] - { #category : 'TOREMOVE' } SpAbstractTextPresenter >> hasEditingConflicts [ "Return if the text zone has editing conflicts" diff --git a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st index 5ea113548..9e5bb893f 100644 --- a/src/Spec2-Core/SpAbstractWidgetPresenter.class.st +++ b/src/Spec2-Core/SpAbstractWidgetPresenter.class.st @@ -78,12 +78,14 @@ SpAbstractWidgetPresenter class >> addDocumentSectionFactoryMethod: aBuilder [ { #category : 'documentation' } SpAbstractWidgetPresenter class >> addDocumentSectionHierarchy: aBuilder [ - + aBuilder newLine. - aBuilder header: [ :builder | builder text: 'Hierarchy' ] withLevel: 2. + aBuilder + header: [ :builder | builder text: 'Hierarchy' ] + withLevel: 2. SpDocumentHierarchyBuilder new builder: aBuilder; - filter: [ :eachClass | eachClass package packageName beginsWith: 'Spec2-' ]; + filter: [ :eachClass | eachClass package name beginsWith: 'Spec2-' ]; buildFor: self ] diff --git a/src/Spec2-Core/SpDialogWindowPresenter.class.st b/src/Spec2-Core/SpDialogWindowPresenter.class.st index 3b0d83bd0..c70011140 100644 --- a/src/Spec2-Core/SpDialogWindowPresenter.class.st +++ b/src/Spec2-Core/SpDialogWindowPresenter.class.st @@ -82,7 +82,7 @@ SpDialogWindowPresenter >> addDefaultButton: aButtonPresenter [ ^ defaultButton ] -{ #category : 'NOTUSED' } +{ #category : 'api' } SpDialogWindowPresenter >> addDefaultButton: aString do: aBlock [ "Adds button logic to dialog." @@ -109,10 +109,7 @@ SpDialogWindowPresenter >> beOk [ { #category : 'api' } SpDialogWindowPresenter >> buttons [ - "Answer an OrderedCollection that contains all defined buttons. - Default action will always be the last one." - - self flag: #TODO. "Default action should be configurable, not the last action defined." + "Answer an OrderedCollection that contains all defined buttons." ^ buttons ] @@ -146,6 +143,14 @@ SpDialogWindowPresenter >> cancelled [ ^ cancelled ] +{ #category : 'api' } +SpDialogWindowPresenter >> defaultButton [ + "add a previously defined defaultButton. + this is also a 'suggested action'." + + ^ defaultButton +] + { #category : 'private' } SpDialogWindowPresenter >> executeDefaultAction [ @@ -153,6 +158,12 @@ SpDialogWindowPresenter >> executeDefaultAction [ defaultButton action cull: self ] +{ #category : 'testing' } +SpDialogWindowPresenter >> hasDefaultButton [ + + ^ defaultButton notNil +] + { #category : 'initialization' } SpDialogWindowPresenter >> initialize [ diff --git a/src/Spec2-Core/SpWindowPresenter.class.st b/src/Spec2-Core/SpWindowPresenter.class.st index d781d0fd4..e797c4b97 100644 --- a/src/Spec2-Core/SpWindowPresenter.class.st +++ b/src/Spec2-Core/SpWindowPresenter.class.st @@ -611,7 +611,7 @@ SpWindowPresenter >> triggerOkAction [ SpWindowPresenter >> updateTitle [ "Update the window title" - self changed: #title: with: { self title } + self withAdapterDo: [ :anAdapter | anAdapter title: self title ] ] { #category : 'api - events' } From 828da259ca94d0680be7adaea0b65156c8566660 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 20 Oct 2023 22:45:40 +0200 Subject: [PATCH 60/88] format --- src/Spec2-Layout/SpExecutableLayout.class.st | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Layout/SpExecutableLayout.class.st b/src/Spec2-Layout/SpExecutableLayout.class.st index 257d2bb4c..5b1436401 100644 --- a/src/Spec2-Layout/SpExecutableLayout.class.st +++ b/src/Spec2-Layout/SpExecutableLayout.class.st @@ -39,13 +39,15 @@ SpExecutableLayout class >> addDocumentSection: aBuilder label: label methods: m { #category : 'documentation' } SpExecutableLayout class >> addDocumentSectionHierarchy: aBuilder [ - + aBuilder newLine. - aBuilder header: [ :builder | builder text: 'Hierarchy' ] withLevel: 2. + aBuilder + header: [ :builder | builder text: 'Hierarchy' ] + withLevel: 2. SpDocumentHierarchyBuilder new fromClass: Object; builder: aBuilder; - filter: [ :eachClass | eachClass package packageName beginsWith: 'Spec2-' ]; + filter: [ :eachClass | eachClass package name beginsWith: 'Spec2-' ]; buildFor: self ] From f4536e4611e186ca1c110daab63a9725263638be Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 20 Oct 2023 22:45:53 +0200 Subject: [PATCH 61/88] format --- src/Spec2-Code/SpCodePresenter.class.st | 44 ++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 8d53e58bf..022d4d7fb 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -708,6 +708,28 @@ SpCodePresenter >> smartCharacters: aBoolean [ smartCharacters := aBoolean ] +{ #category : 'api' } +SpCodePresenter >> styleScheme [ + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', + 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', + 'solarized-light', 'tango'" + + ^ styleScheme +] + +{ #category : 'api' } +SpCodePresenter >> styleScheme: aSymbol [ + + "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', + 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', + 'solarized-light', 'tango'. + + Note: In morphic this will be interpreted as a simple style (since you can use a style + to define a scheme)" + + styleScheme := aSymbol +] + { #category : 'private' } SpCodePresenter >> syntaxHighlight: aBoolean [ @@ -729,27 +751,6 @@ SpCodePresenter >> syntaxHighlightTheme: aSymbol [ syntaxHighlightTheme := aSymbol ] -{ #category : 'api' } -SpCodePresenter >> styleScheme [ - "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', - 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', - 'solarized-light', 'tango'" - - ^ styleScheme -] - -{ #category : 'api' } -SpCodePresenter >> styleScheme: aSymbol [ - "The name of the style scheme theme to use (e.g. 'Adwaita', 'Adwaita-dark', 'classic', - 'classic-dark', 'cobalt', 'cobalt-light', 'kate', 'kate-dark', 'oblivion', 'solarized-dark', - 'solarized-light', 'tango'. - - Note: In morphic this will be interpreted as a simple style (since you can use a style - to define a scheme)" - - styleScheme := aSymbol -] - { #category : 'command support' } SpCodePresenter >> systemNavigation [ @@ -887,4 +888,3 @@ SpCodePresenter >> withoutSyntaxHighlight [ self syntaxHighlight: false ] - From 1c49e5ef976f6f255519e740e026ac2c06c07510 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 20 Oct 2023 22:48:33 +0200 Subject: [PATCH 62/88] adda generic property changed output port (and use it for sliders) --- .../SpEasyListViewPresenter.extension.st | 12 ++--- .../SpPropertyChangedPort.class.st | 46 +++++++++++++++++++ .../SpSliderPresenter.extension.st | 9 ++++ 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 src/Spec2-Transmission/SpPropertyChangedPort.class.st create mode 100644 src/Spec2-Transmission/SpSliderPresenter.extension.st diff --git a/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st b/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st index f16d58705..63ea8de16 100644 --- a/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st +++ b/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st @@ -1,18 +1,18 @@ -Extension { #name : #SpEasyListViewPresenter } +Extension { #name : 'SpEasyListViewPresenter' } -{ #category : #'*Spec2-Transmission' } +{ #category : '*Spec2-Transmission' } SpEasyListViewPresenter >> defaultInputPort [ ^ self inputItemsPort ] -{ #category : #'*Spec2-Transmission' } +{ #category : '*Spec2-Transmission' } SpEasyListViewPresenter >> defaultOutputPort [ ^ self outputSelectionPort ] -{ #category : #'*Spec2-Transmission' } +{ #category : '*Spec2-Transmission' } SpEasyListViewPresenter >> inputItemsPort [ ^ (SpListItemsPort newPresenter: self) @@ -20,7 +20,7 @@ SpEasyListViewPresenter >> inputItemsPort [ yourself ] -{ #category : #'*Spec2-Transmission' } +{ #category : '*Spec2-Transmission' } SpEasyListViewPresenter >> outputActivationPort [ ^ (SpActivationPort newPresenter: self) @@ -28,7 +28,7 @@ SpEasyListViewPresenter >> outputActivationPort [ yourself ] -{ #category : #'*Spec2-Transmission' } +{ #category : '*Spec2-Transmission' } SpEasyListViewPresenter >> outputSelectionPort [ ^ (SpSelectionPort newPresenter: self) diff --git a/src/Spec2-Transmission/SpPropertyChangedPort.class.st b/src/Spec2-Transmission/SpPropertyChangedPort.class.st new file mode 100644 index 000000000..8a5f0ebae --- /dev/null +++ b/src/Spec2-Transmission/SpPropertyChangedPort.class.st @@ -0,0 +1,46 @@ +Class { + #name : 'SpPropertyChangedPort', + #superclass : 'SpOutputPort', + #instVars : [ + 'property' + ], + #category : 'Spec2-Transmission-Base', + #package : 'Spec2-Transmission', + #tag : 'Base' +} + +{ #category : 'instance creation' } +SpPropertyChangedPort class >> newPresenter: aPresenter property: aSymbol [ + + ^ self new + presenter: aPresenter; + property: aSymbol; + yourself +] + +{ #category : 'instance creation' } +SpPropertyChangedPort class >> portName [ + + ^ #property +] + +{ #category : 'attaching' } +SpPropertyChangedPort >> attachTransmission: aTransmission to: aPresenter [ + + aPresenter property: self property whenChangedDo: [ :aValue | + self + transmitWith: aTransmission + value: (self applyTransform: aValue) ] +] + +{ #category : 'accessing' } +SpPropertyChangedPort >> property [ + + ^ property +] + +{ #category : 'accessing' } +SpPropertyChangedPort >> property: aSymbol [ + + property := aSymbol +] diff --git a/src/Spec2-Transmission/SpSliderPresenter.extension.st b/src/Spec2-Transmission/SpSliderPresenter.extension.st new file mode 100644 index 000000000..9a9171472 --- /dev/null +++ b/src/Spec2-Transmission/SpSliderPresenter.extension.st @@ -0,0 +1,9 @@ +Extension { #name : 'SpSliderPresenter' } + +{ #category : '*Spec2-Transmission' } +SpSliderPresenter >> absoluteValueOutputPort [ + + ^ SpPropertyChangedPort + newPresenter: self + property: #absoluteValue +] From 026ec5d3ac756fb8ca9c8af4f5471d27e3255e43 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sun, 22 Oct 2023 17:34:57 +0200 Subject: [PATCH 63/88] move SpTActionContainer to fix a cyclic dependency --- .../SpTActionContainer.trait.st | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) rename src/{Spec2-Commander2 => Spec2-Core}/SpTActionContainer.trait.st (85%) diff --git a/src/Spec2-Commander2/SpTActionContainer.trait.st b/src/Spec2-Core/SpTActionContainer.trait.st similarity index 85% rename from src/Spec2-Commander2/SpTActionContainer.trait.st rename to src/Spec2-Core/SpTActionContainer.trait.st index 175d1078e..e5acc0ec9 100644 --- a/src/Spec2-Commander2/SpTActionContainer.trait.st +++ b/src/Spec2-Core/SpTActionContainer.trait.st @@ -3,9 +3,9 @@ Trait { #instVars : [ 'actionGroup' ], - #category : 'Spec2-Commander2-Action', - #package : 'Spec2-Commander2', - #tag : 'Action' + #category : 'Spec2-Core-Base', + #package : 'Spec2-Core', + #tag : 'Base' } { #category : 'api - actions' } @@ -62,7 +62,12 @@ SpTActionContainer >> addShortcutWith: aBlock [ { #category : 'private' } SpTActionContainer >> ensureActionGroup [ - ^ actionGroup ifNil: [ actionGroup := SpActionGroup new beRoot ] + self flag: #TODO. "This is a fake break of dependency (dependency is + still there, but hidden). Think about a real fix (like, not using commander for actions." + ^ actionGroup ifNil: [ + | c | + c := self class environment at: #SpActionGroup. + actionGroup := c new beRoot ] ] { #category : 'initialization' } From 5710d7a81762747e70fbfc7b030627c57643d06b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 7 Nov 2023 17:11:34 -0300 Subject: [PATCH 64/88] use default button --- src/Spec2-Core/SpAbstractPresenter.class.st | 8 ++++---- src/Spec2-Core/SpEditableListPresenter.class.st | 8 +++----- src/Spec2-Examples/SpDemoModal2Presenter.class.st | 9 ++++----- .../SpDropDownPresenter.extension.st | 8 ++++---- .../SpDropListPresenter.extension.st | 4 ++-- src/Spec2-Examples/SpLabelPresenter.extension.st | 3 +-- src/Spec2-Examples/SpListPresenter.extension.st | 2 +- .../SpListViewPresenter.extension.st | 14 +++++++------- src/Spec2-Examples/SpPanedLayout.extension.st | 4 ++-- 9 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/Spec2-Core/SpAbstractPresenter.class.st b/src/Spec2-Core/SpAbstractPresenter.class.st index a0afc81a3..0632c4696 100644 --- a/src/Spec2-Core/SpAbstractPresenter.class.st +++ b/src/Spec2-Core/SpAbstractPresenter.class.st @@ -312,12 +312,12 @@ SpAbstractPresenter >> initializeDialogWindow: aDialogWindowPresenter [ Override this to set buttons other than the default (Ok, Cancel)." aDialogWindowPresenter - addButton: 'Ok' do: [ :presenter | - presenter triggerOkAction. - presenter close ]; addButton: 'Cancel' do: [ :presenter | presenter triggerCancelAction. - presenter close ] + presenter close ]; + addDefaultButton: 'Ok' do: [ :presenter | + presenter triggerOkAction. + presenter close ] ] { #category : 'initialization' } diff --git a/src/Spec2-Core/SpEditableListPresenter.class.st b/src/Spec2-Core/SpEditableListPresenter.class.st index 4b67ca326..6d5a84d75 100644 --- a/src/Spec2-Core/SpEditableListPresenter.class.st +++ b/src/Spec2-Core/SpEditableListPresenter.class.st @@ -140,11 +140,9 @@ SpEditableListPresenter >> initialize [ { #category : 'initialization' } SpEditableListPresenter >> initializeDialogWindow: aWindow [ - aWindow - addButton: 'Ok' - do: [ :presenter | - self performOkAction. - presenter close ] + aWindow addDefaultButton: 'Ok' do: [ :presenter | + self performOkAction. + presenter close ] ] { #category : 'initialization' } diff --git a/src/Spec2-Examples/SpDemoModal2Presenter.class.st b/src/Spec2-Examples/SpDemoModal2Presenter.class.st index f1c884873..96787e281 100644 --- a/src/Spec2-Examples/SpDemoModal2Presenter.class.st +++ b/src/Spec2-Examples/SpDemoModal2Presenter.class.st @@ -22,13 +22,12 @@ SpDemoModal2Presenter >> initializeDialogWindow: aDialog [ aDialog closeOnBackdropClick: false; - addButton: 'Validate' do: [ :presenter | - self inform: 'Validate'. - presenter close ]; - addButton: 'Reset' - do: [ :presenter | + addButton: 'Reset' do: [ :presenter | self inform: 'This action does not close the modal' ]; addButton: 'Cancel' do: [ :presenter | self inform: 'Cancel'. + presenter close ]; + addDefaultButton: 'Validate' do: [ :presenter | + self inform: 'Validate'. presenter close ] ] diff --git a/src/Spec2-Examples/SpDropDownPresenter.extension.st b/src/Spec2-Examples/SpDropDownPresenter.extension.st index 8eb20434e..9f4b300c7 100644 --- a/src/Spec2-Examples/SpDropDownPresenter.extension.st +++ b/src/Spec2-Examples/SpDropDownPresenter.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #SpDropDownPresenter } +Extension { #name : 'SpDropDownPresenter' } -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpDropDownPresenter class >> example [ "This example show the simples list view you can make: A list with a label" @@ -13,7 +13,7 @@ SpDropDownPresenter class >> example [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpDropDownPresenter class >> exampleWithIcons [ "This example shows how to construct a list with icons. It shows also the fact you can put any presenter inside, giving a huge power @@ -40,7 +40,7 @@ SpDropDownPresenter class >> exampleWithIcons [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpDropDownPresenter class >> exampleWithSelectedItem [ "This example show the simples list view you can make: A list with a label" diff --git a/src/Spec2-Examples/SpDropListPresenter.extension.st b/src/Spec2-Examples/SpDropListPresenter.extension.st index 15da84e84..634db83f8 100644 --- a/src/Spec2-Examples/SpDropListPresenter.extension.st +++ b/src/Spec2-Examples/SpDropListPresenter.extension.st @@ -14,7 +14,7 @@ SpDropListPresenter class >> example [ yourself ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpDropListPresenter class >> exampleWithActions [ "This example shows how to add icons to a dropdown list." @@ -28,7 +28,7 @@ SpDropListPresenter class >> exampleWithActions [ yourself ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpDropListPresenter class >> exampleWithIcons [ "This example shows how to add icons to a dropdown list." diff --git a/src/Spec2-Examples/SpLabelPresenter.extension.st b/src/Spec2-Examples/SpLabelPresenter.extension.st index 47ddbb6ff..0bb2154a5 100644 --- a/src/Spec2-Examples/SpLabelPresenter.extension.st +++ b/src/Spec2-Examples/SpLabelPresenter.extension.st @@ -2,7 +2,6 @@ Extension { #name : 'SpLabelPresenter' } { #category : '*Spec2-Examples' } SpLabelPresenter class >> example [ - "This example opens a spec window with a label." ^ self new @@ -10,7 +9,7 @@ SpLabelPresenter class >> example [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpLabelPresenter class >> exampleWithDecoration [ "This example opens a spec window with a decorated label." diff --git a/src/Spec2-Examples/SpListPresenter.extension.st b/src/Spec2-Examples/SpListPresenter.extension.st index a14b95219..fb78f03df 100644 --- a/src/Spec2-Examples/SpListPresenter.extension.st +++ b/src/Spec2-Examples/SpListPresenter.extension.st @@ -76,7 +76,7 @@ SpListPresenter class >> exampleWithIcons [ yourself ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListPresenter class >> exampleWithIconsAndSelectedItem [ ^ self new diff --git a/src/Spec2-Examples/SpListViewPresenter.extension.st b/src/Spec2-Examples/SpListViewPresenter.extension.st index 53801a14e..527c77aaf 100644 --- a/src/Spec2-Examples/SpListViewPresenter.extension.st +++ b/src/Spec2-Examples/SpListViewPresenter.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #SpListViewPresenter } +Extension { #name : 'SpListViewPresenter' } -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> example [ "This example show the simples list view you can make: A list with a label" @@ -12,7 +12,7 @@ SpListViewPresenter class >> example [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> exampleReplaceItems [ "This example shows how to replace dynamically the list of elements." | presenter listView button items | @@ -37,7 +37,7 @@ SpListViewPresenter class >> exampleReplaceItems [ ^ presenter open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> exampleWithActions [ "This example show the simples list view you can make: A list with a label" @@ -78,7 +78,7 @@ SpListViewPresenter class >> exampleWithActions [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> exampleWithIcons [ "This example shows how to construct a list with icons. It shows also the fact you can put any presenter inside, giving a huge power @@ -105,7 +105,7 @@ SpListViewPresenter class >> exampleWithIcons [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ "This example shows how to construct a list with icons. It shows also the fact you can put any presenter inside, giving a huge power @@ -133,7 +133,7 @@ SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ open ] -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpListViewPresenter class >> exampleWithIconsMultipleSelection [ "This example shows how to construct a list with multiple selection available. It shows also the fact you can put any presenter inside, giving a huge power diff --git a/src/Spec2-Examples/SpPanedLayout.extension.st b/src/Spec2-Examples/SpPanedLayout.extension.st index 22250263f..777b5a597 100644 --- a/src/Spec2-Examples/SpPanedLayout.extension.st +++ b/src/Spec2-Examples/SpPanedLayout.extension.st @@ -1,6 +1,6 @@ -Extension { #name : #SpPanedLayout } +Extension { #name : 'SpPanedLayout' } -{ #category : #'*Spec2-Examples' } +{ #category : '*Spec2-Examples' } SpPanedLayout class >> exampleNotResizingStartChild [ | app presenter child1 child2 | From 1e0e4c14afa01b99de9ee51eb81b91b53e80decc Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 7 Nov 2023 17:11:52 -0300 Subject: [PATCH 65/88] format --- src/Spec2-Core/SpDropDownPresenter.class.st | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Core/SpDropDownPresenter.class.st b/src/Spec2-Core/SpDropDownPresenter.class.st index 3fc609bb0..0c794a261 100644 --- a/src/Spec2-Core/SpDropDownPresenter.class.st +++ b/src/Spec2-Core/SpDropDownPresenter.class.st @@ -55,15 +55,17 @@ SpDropDownPresenter >> initialize [ self model: self newEmptyModel. self initializeItemFactory. selection := SpSingleSelectionMode on: self. - self display: [ :anObject | anObject asString ] + self display: [ :anObject | anObject asString ] ] { #category : 'initialization' } SpDropDownPresenter >> initializeItemFactory [ "Just set up the defaults (to ensure we have a working list at any moment)" - self setup: [ :aPresenter | aPresenter newLabel ]. - self bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] + self setup: [ :aPresenter | + aPresenter newLabel ]. + self bind: [ :aPresenter :anObject | + aPresenter label: (self display value: anObject) asString ] ] { #category : 'api' } From 16c9f1d1f02991f8809fcb5c7ae8297294a7f476 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 7 Nov 2023 17:12:14 -0300 Subject: [PATCH 66/88] add transmissions to new dropdown presenter --- .../SpDropDownPresenter.extension.st | 25 +++++++++++++++++++ .../SpDropDownSelectionPort.class.st | 22 ++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/Spec2-Transmission/SpDropDownPresenter.extension.st create mode 100644 src/Spec2-Transmission/SpDropDownSelectionPort.class.st diff --git a/src/Spec2-Transmission/SpDropDownPresenter.extension.st b/src/Spec2-Transmission/SpDropDownPresenter.extension.st new file mode 100644 index 000000000..0df04f23f --- /dev/null +++ b/src/Spec2-Transmission/SpDropDownPresenter.extension.st @@ -0,0 +1,25 @@ +Extension { #name : 'SpDropDownPresenter' } + +{ #category : '*Spec2-Transmission' } +SpDropDownPresenter >> defaultInputPort [ + + ^ self inputItemsPort +] + +{ #category : '*Spec2-Transmission' } +SpDropDownPresenter >> defaultOutputPort [ + + ^ self outputSelectionPort +] + +{ #category : '*Spec2-Transmission' } +SpDropDownPresenter >> inputItemsPort [ + + ^ SpListItemsPort newPresenter: self +] + +{ #category : '*Spec2-Transmission' } +SpDropDownPresenter >> outputSelectionPort [ + + ^ SpDropDownSelectionPort newPresenter: self +] diff --git a/src/Spec2-Transmission/SpDropDownSelectionPort.class.st b/src/Spec2-Transmission/SpDropDownSelectionPort.class.st new file mode 100644 index 000000000..cab028ccf --- /dev/null +++ b/src/Spec2-Transmission/SpDropDownSelectionPort.class.st @@ -0,0 +1,22 @@ +Class { + #name : 'SpDropDownSelectionPort', + #superclass : 'SpOutputPort', + #category : 'Spec2-Transmission-Base', + #package : 'Spec2-Transmission', + #tag : 'Base' +} + +{ #category : 'accessing' } +SpDropDownSelectionPort class >> portName [ + + ^ #selection +] + +{ #category : 'attaching' } +SpDropDownSelectionPort >> attachTransmission: aTransmission to: aPresenter [ + + aPresenter whenSelectionChangedDo: [ :anObject | + self + transmitWith: aTransmission + value: (self applyTransform: anObject) ] +] From 0d5768921ac65125754b4e595ba7fc394a975dba Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 7 Nov 2023 17:12:31 -0300 Subject: [PATCH 67/88] add new dropdown accessor --- src/Spec2-Core/SpTPresenterBuilder.trait.st | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index cf59b4dbc..dc5cbe7bd 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -80,6 +80,12 @@ SpTPresenterBuilder >> newDiff [ ^ self instantiate: SpDiffPresenter ] +{ #category : 'scripting - lists' } +SpTPresenterBuilder >> newDropDown [ + + ^ self instantiate: SpDropDownPresenter +] + { #category : 'scripting - widgets' } SpTPresenterBuilder >> newDropList [ ^ self instantiate: SpDropListPresenter From 8a5f8917b124def5b25776fb3c8368d57961ec0b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 7 Nov 2023 17:12:51 -0300 Subject: [PATCH 68/88] add missing performAction --- src/Spec2-Core/SpToolbarButtonPresenter.class.st | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Spec2-Core/SpToolbarButtonPresenter.class.st b/src/Spec2-Core/SpToolbarButtonPresenter.class.st index cd3bc2142..b7e8418db 100644 --- a/src/Spec2-Core/SpToolbarButtonPresenter.class.st +++ b/src/Spec2-Core/SpToolbarButtonPresenter.class.st @@ -105,6 +105,12 @@ SpToolbarButtonPresenter >> label: aString [ label := aString ] +{ #category : 'private' } +SpToolbarButtonPresenter >> performAction [ + + self action value +] + { #category : 'api - events' } SpToolbarButtonPresenter >> whenIconChangedDo: aBlock [ "Inform when icon property has changed. From 86c54c1dcd4db87e70f9aa5309d00186a6b4ee3f Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 14 Nov 2023 15:44:52 +0100 Subject: [PATCH 69/88] format --- src/Spec2-Core/SpLinkPresenter.class.st | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Spec2-Core/SpLinkPresenter.class.st b/src/Spec2-Core/SpLinkPresenter.class.st index 276dfabfd..069914396 100644 --- a/src/Spec2-Core/SpLinkPresenter.class.st +++ b/src/Spec2-Core/SpLinkPresenter.class.st @@ -51,6 +51,7 @@ SpLinkPresenter >> defaultColor [ SpLinkPresenter >> initialize [ super initialize. + self whenLabelChangedDo: [ self changed: #getText ] ] From 27b4453822798f0de7bf005c6558cbadc57603a7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 24 Nov 2023 09:25:33 +0100 Subject: [PATCH 70/88] apply deprecations --- src/Spec2-Core/SpAbstractPresenter.class.st | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Spec2-Core/SpAbstractPresenter.class.st b/src/Spec2-Core/SpAbstractPresenter.class.st index 0632c4696..062ef99b5 100644 --- a/src/Spec2-Core/SpAbstractPresenter.class.st +++ b/src/Spec2-Core/SpAbstractPresenter.class.st @@ -518,9 +518,7 @@ SpAbstractPresenter >> validateInto: aValidationReport [ { #category : 'events' } SpAbstractPresenter >> whenBuiltDo: aBlock [ - self announcer - when: SpWidgetBuilt - do: aBlock + self announcer when: SpWidgetBuilt do: aBlock for: aBlock receiver ] { #category : 'events' } From d02005caf5a90722eeffe64fdf0d899fea82044d Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 25 Nov 2023 08:35:41 +0100 Subject: [PATCH 71/88] fix colimn alignment --- .../SpMorphicTableCellBuilder.class.st | 44 ++++++++++++++++--- .../SpTablePresenter.extension.st | 17 +++++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicTableCellBuilder.class.st b/src/Spec2-Adapters-Morphic/SpMorphicTableCellBuilder.class.st index 0d175c1b4..fc0d568bd 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicTableCellBuilder.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicTableCellBuilder.class.st @@ -22,12 +22,31 @@ SpMorphicTableCellBuilder class >> on: aDataSource [ { #category : 'private' } SpMorphicTableCellBuilder >> addAlignmentColumn: aTableColumn item: item to: content [ + | block containerMorph alignment | - aTableColumn displayAlignment ifNotNil: [ :block | - ^ content asText addAttribute: (block cull: item) asTextAlignment ]. - - ^ content + (block := aTableColumn displayAlignment) ifNil: [ ^ content ]. + + alignment := (block cull: item) asTextAlignment. + containerMorph := Morph new + color: Color transparent; + layoutPolicy: TableLayout new; + hResizing: #spaceFill; + vResizing: #spaceFill; + borderWidth: 0; + yourself. + + alignment = TextAlignment rightFlush ifTrue: [ + containerMorph listDirection: #rightToLeft ]. + alignment = TextAlignment leftFlush ifTrue: [ + containerMorph listDirection: #leftToRight ]. + + alignment = TextAlignment centered + ifTrue: [ containerMorph addMorphBack: self newFillerMorph ]. + containerMorph addMorphBack: content asMorph asReadOnlyMorph. + alignment = TextAlignment centered + ifTrue: [ containerMorph addMorphBack: self newFillerMorph ]. + ^ containerMorph ] { #category : 'private' } @@ -146,6 +165,17 @@ SpMorphicTableCellBuilder >> item [ ^ self dataSource elementAt: self rowIndex ] +{ #category : 'private' } +SpMorphicTableCellBuilder >> newFillerMorph [ + "This is used as a helper to center text when applying alignment=centered" + + ^ Morph new + color: Color transparent; + hResizing: #spaceFill; + vResizing: #spaceFill; + yourself +] + { #category : 'accessing' } SpMorphicTableCellBuilder >> rowIndex [ ^ rowIndex @@ -268,7 +298,6 @@ SpMorphicTableCellBuilder >> visitStringColumn: aTableColumn [ content := aTableColumn readObject: item. "add properties" - content := self addAlignmentColumn: aTableColumn item: item to: content. content := self addColorColumn: aTableColumn item: item to: content. content := self addItalicColumn: aTableColumn item: item to: content. content := self addBoldColumn: aTableColumn item: item to: content. @@ -277,9 +306,12 @@ SpMorphicTableCellBuilder >> visitStringColumn: aTableColumn [ aTableColumn isEditable ifTrue: [ self visitStringColumnEditable: aTableColumn on: content ] ifFalse: [ "add cell" + "I need to calculate here alignement because I will wrap the content + into a container morph, so it needs to be the last one before applying" + content := self addAlignmentColumn: aTableColumn item: item to: content. self addCell: content column: aTableColumn. "add background (this is a special case of properties, - since background needs to be applied to the cell and not to the text)" + since background needs to be applied to the cell and not to the text)" self addBackgroundColorColumn: aTableColumn item: item toMorph: cell ] ] diff --git a/src/Spec2-Examples/SpTablePresenter.extension.st b/src/Spec2-Examples/SpTablePresenter.extension.st index 2d863414b..c05797a89 100644 --- a/src/Spec2-Examples/SpTablePresenter.extension.st +++ b/src/Spec2-Examples/SpTablePresenter.extension.st @@ -96,6 +96,23 @@ SpTablePresenter class >> exampleSorting [ open ] +{ #category : '*Spec2-Examples' } +SpTablePresenter class >> exampleWithColumnAlignment [ + "Shows how we can align columns" + | column | + + column := SpStringTableColumn new + title: 'Alignments'; + evaluated: [ :object | object ]; + displayAlignment: [ :object | SpColumnAlignment perform: object ]; + yourself. + + SpTablePresenter new + items: { #right. #center. #left }; + addColumn: column; + open +] + { #category : '*Spec2-Examples' } SpTablePresenter class >> exampleWithColumnHeaders [ From e2bd97c92229cabd9fa3397e2100c0039315055e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Sat, 25 Nov 2023 08:35:59 +0100 Subject: [PATCH 72/88] format --- src/Spec2-Core/SpTableColumn.class.st | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Core/SpTableColumn.class.st b/src/Spec2-Core/SpTableColumn.class.st index b2ee58c0d..d96116ca4 100644 --- a/src/Spec2-Core/SpTableColumn.class.st +++ b/src/Spec2-Core/SpTableColumn.class.st @@ -21,13 +21,15 @@ Class { { #category : 'adding' } SpTableColumn class >> addDocumentSectionHierarchy: aBuilder [ - + aBuilder newLine. - aBuilder header: [ :builder | builder text: 'Hierarchy' ] withLevel: 2. + aBuilder + header: [ :builder | builder text: 'Hierarchy' ] + withLevel: 2. SpDocumentHierarchyBuilder new fromClass: SpTableColumn; builder: aBuilder; - filter: [ :eachClass | eachClass package packageName beginsWith: 'Spec2-' ]; + filter: [ :eachClass | eachClass package name beginsWith: 'Spec2-' ]; buildFor: self ] From 4a05478960caea5eb17573318c003a3d86908471 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 28 Nov 2023 16:19:27 +0100 Subject: [PATCH 73/88] add select index/item to select dialog --- src/Spec2-Dialogs/SpSelectDialog.class.st | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Spec2-Dialogs/SpSelectDialog.class.st b/src/Spec2-Dialogs/SpSelectDialog.class.st index b0eaebd10..efedf8c12 100644 --- a/src/Spec2-Dialogs/SpSelectDialog.class.st +++ b/src/Spec2-Dialogs/SpSelectDialog.class.st @@ -183,6 +183,18 @@ SpSelectDialog >> openModal [ ifFalse: [ nil ] ] +{ #category : 'api' } +SpSelectDialog >> selectIndex: aNumber [ + + list selectIndex: aNumber +] + +{ #category : 'api' } +SpSelectDialog >> selectItem: anObject [ + + list selectItem: anObject +] + { #category : 'api' } SpSelectDialog >> selectedItem [ From 2604fe237ccef77708f203214805c69346b1793e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 29 Nov 2023 12:44:45 +0100 Subject: [PATCH 74/88] listview work moved to separated package (so I can merge without including, for the moment) --- .../SpMorphicListViewAdapter.class.st | 3 +-- .../SpMorphicListViewDataSource.class.st | 3 +-- .../package.st | 1 + src/Spec2-Core/SpTPresenterBuilder.trait.st | 18 ------------------ src/Spec2-Dialogs/SpApplication.extension.st | 5 +---- .../SpDropDownPresenter.class.st | 5 ++--- .../SpEasyListRowPresenter.class.st | 5 ++--- .../SpEasyListViewPresenter.class.st | 5 ++--- .../SpListViewPresenter.class.st | 5 ++--- .../SpTPresenterBuilder.extension.st | 19 +++++++++++++++++++ src/Spec2-ListView/package.st | 1 + 11 files changed, 32 insertions(+), 38 deletions(-) rename src/{Spec2-Adapters-Morphic => Spec2-Adapters-Morphic-ListView}/SpMorphicListViewAdapter.class.st (95%) rename src/{Spec2-Adapters-Morphic => Spec2-Adapters-Morphic-ListView}/SpMorphicListViewDataSource.class.st (93%) create mode 100644 src/Spec2-Adapters-Morphic-ListView/package.st rename src/{Spec2-Core => Spec2-ListView}/SpDropDownPresenter.class.st (97%) rename src/{Spec2-Core => Spec2-ListView}/SpEasyListRowPresenter.class.st (93%) rename src/{Spec2-Core => Spec2-ListView}/SpEasyListViewPresenter.class.st (98%) rename src/{Spec2-Core => Spec2-ListView}/SpListViewPresenter.class.st (95%) create mode 100644 src/Spec2-ListView/SpTPresenterBuilder.extension.st create mode 100644 src/Spec2-ListView/package.st diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st b/src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewAdapter.class.st similarity index 95% rename from src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st rename to src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewAdapter.class.st index 9b10b10e8..44333deb3 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewAdapter.class.st +++ b/src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewAdapter.class.st @@ -5,8 +5,7 @@ Class { #name : 'SpMorphicListViewAdapter', #superclass : 'SpMorphicListAdapter', #category : 'Spec2-Adapters-Morphic-ListView', - #package : 'Spec2-Adapters-Morphic', - #tag : 'ListView' + #package : 'Spec2-Adapters-Morphic-ListView' } { #category : 'factory' } diff --git a/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st b/src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewDataSource.class.st similarity index 93% rename from src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st rename to src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewDataSource.class.st index a82a507dc..ccc7a6320 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicListViewDataSource.class.st +++ b/src/Spec2-Adapters-Morphic-ListView/SpMorphicListViewDataSource.class.st @@ -5,8 +5,7 @@ Class { #name : 'SpMorphicListViewDataSource', #superclass : 'SpMorphicListDataSource', #category : 'Spec2-Adapters-Morphic-ListView', - #package : 'Spec2-Adapters-Morphic', - #tag : 'ListView' + #package : 'Spec2-Adapters-Morphic-ListView' } { #category : 'accessing' } diff --git a/src/Spec2-Adapters-Morphic-ListView/package.st b/src/Spec2-Adapters-Morphic-ListView/package.st new file mode 100644 index 000000000..6ccea4bf7 --- /dev/null +++ b/src/Spec2-Adapters-Morphic-ListView/package.st @@ -0,0 +1 @@ +Package { #name : 'Spec2-Adapters-Morphic-ListView' } diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index dc5cbe7bd..6383dbb3f 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -80,12 +80,6 @@ SpTPresenterBuilder >> newDiff [ ^ self instantiate: SpDiffPresenter ] -{ #category : 'scripting - lists' } -SpTPresenterBuilder >> newDropDown [ - - ^ self instantiate: SpDropDownPresenter -] - { #category : 'scripting - widgets' } SpTPresenterBuilder >> newDropList [ ^ self instantiate: SpDropListPresenter @@ -107,12 +101,6 @@ SpTPresenterBuilder >> newDynamicPresentersListIn: accessorSymbol usingBuilder: self build ] -{ #category : 'scripting - lists' } -SpTPresenterBuilder >> newEasyListView [ - self flag: #TODO. "replace newList with this" - ^ self instantiate: SpEasyListViewPresenter -] - { #category : 'scripting - layouts' } SpTPresenterBuilder >> newGridLayout [ @@ -134,12 +122,6 @@ SpTPresenterBuilder >> newList [ ^ self instantiate: SpListPresenter ] -{ #category : 'scripting - lists' } -SpTPresenterBuilder >> newListView [ - - ^ self instantiate: SpListViewPresenter -] - { #category : 'scripting - widgets' } SpTPresenterBuilder >> newMenu [ ^ self instantiate: SpMenuPresenter diff --git a/src/Spec2-Dialogs/SpApplication.extension.st b/src/Spec2-Dialogs/SpApplication.extension.st index 59115c33f..a57915663 100644 --- a/src/Spec2-Dialogs/SpApplication.extension.st +++ b/src/Spec2-Dialogs/SpApplication.extension.st @@ -24,10 +24,7 @@ SpApplication >> confirm: aString [ SpApplication >> inform: aString [ "Displays an inform dialog, for more configurable version please use `self application newInform title: ....`." - ^ self newInform - title: 'Alert'; - label: aString; - openModal + ^ self backend inform: aString ] { #category : '*Spec2-Dialogs' } diff --git a/src/Spec2-Core/SpDropDownPresenter.class.st b/src/Spec2-ListView/SpDropDownPresenter.class.st similarity index 97% rename from src/Spec2-Core/SpDropDownPresenter.class.st rename to src/Spec2-ListView/SpDropDownPresenter.class.st index 0c794a261..b4f9346d5 100644 --- a/src/Spec2-Core/SpDropDownPresenter.class.st +++ b/src/Spec2-ListView/SpDropDownPresenter.class.st @@ -8,9 +8,8 @@ Class { 'display', 'selection' ], - #category : 'Spec2-Core-Widgets-ListView', - #package : 'Spec2-Core', - #tag : 'Widgets-ListView' + #category : 'Spec2-ListView', + #package : 'Spec2-ListView' } { #category : 'specs' } diff --git a/src/Spec2-Core/SpEasyListRowPresenter.class.st b/src/Spec2-ListView/SpEasyListRowPresenter.class.st similarity index 93% rename from src/Spec2-Core/SpEasyListRowPresenter.class.st rename to src/Spec2-ListView/SpEasyListRowPresenter.class.st index 1a679dff7..afd87a74f 100644 --- a/src/Spec2-Core/SpEasyListRowPresenter.class.st +++ b/src/Spec2-ListView/SpEasyListRowPresenter.class.st @@ -8,9 +8,8 @@ Class { 'iconPresenter', 'textPresenter' ], - #category : 'Spec2-Core-Widgets-ListView', - #package : 'Spec2-Core', - #tag : 'Widgets-ListView' + #category : 'Spec2-ListView', + #package : 'Spec2-ListView' } { #category : 'layout' } diff --git a/src/Spec2-Core/SpEasyListViewPresenter.class.st b/src/Spec2-ListView/SpEasyListViewPresenter.class.st similarity index 98% rename from src/Spec2-Core/SpEasyListViewPresenter.class.st rename to src/Spec2-ListView/SpEasyListViewPresenter.class.st index 6a31a0deb..599153141 100644 --- a/src/Spec2-Core/SpEasyListViewPresenter.class.st +++ b/src/Spec2-ListView/SpEasyListViewPresenter.class.st @@ -11,9 +11,8 @@ Class { '#headerPanel', '#lastSelectedRow => WeakSlot' ], - #category : 'Spec2-Core-Widgets-ListView', - #package : 'Spec2-Core', - #tag : 'Widgets-ListView' + #category : 'Spec2-ListView', + #package : 'Spec2-ListView' } { #category : 'specs' } diff --git a/src/Spec2-Core/SpListViewPresenter.class.st b/src/Spec2-ListView/SpListViewPresenter.class.st similarity index 95% rename from src/Spec2-Core/SpListViewPresenter.class.st rename to src/Spec2-ListView/SpListViewPresenter.class.st index d30c177e4..24da78090 100644 --- a/src/Spec2-Core/SpListViewPresenter.class.st +++ b/src/Spec2-ListView/SpListViewPresenter.class.st @@ -7,9 +7,8 @@ Class { '#bindAction', '#headerTitle => ObservableSlot' ], - #category : 'Spec2-Core-Widgets-ListView', - #package : 'Spec2-Core', - #tag : 'Widgets-ListView' + #category : 'Spec2-ListView', + #package : 'Spec2-ListView' } { #category : 'specs' } diff --git a/src/Spec2-ListView/SpTPresenterBuilder.extension.st b/src/Spec2-ListView/SpTPresenterBuilder.extension.st new file mode 100644 index 000000000..fc1242dcf --- /dev/null +++ b/src/Spec2-ListView/SpTPresenterBuilder.extension.st @@ -0,0 +1,19 @@ +Extension { #name : 'SpTPresenterBuilder' } + +{ #category : '*Spec2-ListView' } +SpTPresenterBuilder >> newDropDown [ + + ^ self instantiate: SpDropDownPresenter +] + +{ #category : '*Spec2-ListView' } +SpTPresenterBuilder >> newEasyListView [ + + ^ self instantiate: SpEasyListViewPresenter +] + +{ #category : '*Spec2-ListView' } +SpTPresenterBuilder >> newListView [ + + ^ self instantiate: SpListViewPresenter +] diff --git a/src/Spec2-ListView/package.st b/src/Spec2-ListView/package.st new file mode 100644 index 000000000..0168ae961 --- /dev/null +++ b/src/Spec2-ListView/package.st @@ -0,0 +1 @@ +Package { #name : 'Spec2-ListView' } From 85846835a1b6b7e23f07ad111ac3fb3ad5626132 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 29 Nov 2023 12:47:11 +0100 Subject: [PATCH 75/88] moved tests too --- .../SpEasyListViewPresenterTest.class.st | 21 ++++++++++--------- .../SpListViewPresenterTest.class.st | 13 ++++++------ src/Spec2-ListView-Tests/package.st | 1 + src/Spec2-Tests/SpActionModifierTest.class.st | 10 +++++---- 4 files changed, 25 insertions(+), 20 deletions(-) rename src/{Spec2-Tests => Spec2-ListView-Tests}/SpEasyListViewPresenterTest.class.st (76%) rename src/{Spec2-Tests => Spec2-ListView-Tests}/SpListViewPresenterTest.class.st (59%) create mode 100644 src/Spec2-ListView-Tests/package.st diff --git a/src/Spec2-Tests/SpEasyListViewPresenterTest.class.st b/src/Spec2-ListView-Tests/SpEasyListViewPresenterTest.class.st similarity index 76% rename from src/Spec2-Tests/SpEasyListViewPresenterTest.class.st rename to src/Spec2-ListView-Tests/SpEasyListViewPresenterTest.class.st index 39d627a0b..e15a99817 100644 --- a/src/Spec2-Tests/SpEasyListViewPresenterTest.class.st +++ b/src/Spec2-ListView-Tests/SpEasyListViewPresenterTest.class.st @@ -1,20 +1,21 @@ Class { - #name : #SpEasyListViewPresenterTest, - #superclass : #SpListViewPresenterTest, - #category : #'Spec2-Tests-Core-Widgets' + #name : 'SpEasyListViewPresenterTest', + #superclass : 'SpListViewPresenterTest', + #category : 'Spec2-ListView-Tests', + #package : 'Spec2-ListView-Tests' } -{ #category : #accessing } +{ #category : 'accessing' } SpEasyListViewPresenterTest >> classToTest [ ^ SpEasyListViewPresenter ] -{ #category : #initialization } +{ #category : 'initialization' } SpEasyListViewPresenterTest >> initializeTestedInstance [ ] -{ #category : #'tests - header' } +{ #category : 'tests - header' } SpEasyListViewPresenterTest >> testHideHeaderTitleUnsetsTitle [ presenter @@ -24,7 +25,7 @@ SpEasyListViewPresenterTest >> testHideHeaderTitleUnsetsTitle [ self deny: presenter hasHeaderTitle ] -{ #category : #'tests - header' } +{ #category : 'tests - header' } SpEasyListViewPresenterTest >> testIconFor [ presenter items: #(#add #back #catalog); @@ -32,7 +33,7 @@ SpEasyListViewPresenterTest >> testIconFor [ self assert: (presenter iconFor: #add) equals: (Smalltalk ui icons iconNamed: #add) ] -{ #category : #'tests - header' } +{ #category : 'tests - header' } SpEasyListViewPresenterTest >> testSetHeaderTitleHasTitle [ presenter headerTitle: 'title'. @@ -40,7 +41,7 @@ SpEasyListViewPresenterTest >> testSetHeaderTitleHasTitle [ self assert: presenter hasHeaderTitle ] -{ #category : #'tests - header' } +{ #category : 'tests - header' } SpEasyListViewPresenterTest >> testSetHeaderTitleSetsTitle [ presenter headerTitle: 'title'. @@ -48,7 +49,7 @@ SpEasyListViewPresenterTest >> testSetHeaderTitleSetsTitle [ self assert: presenter headerTitle equals: 'title' ] -{ #category : #tests } +{ #category : 'tests' } SpEasyListViewPresenterTest >> testWhenIconsChangedDo [ | icon counter | diff --git a/src/Spec2-Tests/SpListViewPresenterTest.class.st b/src/Spec2-ListView-Tests/SpListViewPresenterTest.class.st similarity index 59% rename from src/Spec2-Tests/SpListViewPresenterTest.class.st rename to src/Spec2-ListView-Tests/SpListViewPresenterTest.class.st index 2fb340338..f8817a952 100644 --- a/src/Spec2-Tests/SpListViewPresenterTest.class.st +++ b/src/Spec2-ListView-Tests/SpListViewPresenterTest.class.st @@ -1,16 +1,17 @@ Class { - #name : #SpListViewPresenterTest, - #superclass : #SpAbstractListPresenterTest, - #category : #'Spec2-Tests-Core-Widgets' + #name : 'SpListViewPresenterTest', + #superclass : 'SpAbstractListPresenterTest', + #category : 'Spec2-ListView-Tests', + #package : 'Spec2-ListView-Tests' } -{ #category : #accessing } +{ #category : 'accessing' } SpListViewPresenterTest >> classToTest [ ^ SpListViewPresenter ] -{ #category : #initialization } +{ #category : 'initialization' } SpListViewPresenterTest >> initializeTestedInstance [ presenter @@ -18,7 +19,7 @@ SpListViewPresenterTest >> initializeTestedInstance [ bind: [ :aPresenter :anObject | aPresenter label: anObject asString ] ] -{ #category : #running } +{ #category : 'running' } SpListViewPresenterTest >> tearDown [ presenter withWindowDo: [ :w | w close ] diff --git a/src/Spec2-ListView-Tests/package.st b/src/Spec2-ListView-Tests/package.st new file mode 100644 index 000000000..8b580782f --- /dev/null +++ b/src/Spec2-ListView-Tests/package.st @@ -0,0 +1 @@ +Package { #name : 'Spec2-ListView-Tests' } diff --git a/src/Spec2-Tests/SpActionModifierTest.class.st b/src/Spec2-Tests/SpActionModifierTest.class.st index 3faa5ba64..020f9690a 100644 --- a/src/Spec2-Tests/SpActionModifierTest.class.st +++ b/src/Spec2-Tests/SpActionModifierTest.class.st @@ -1,10 +1,12 @@ Class { - #name : #SpActionModifierTest, - #superclass : #TestCase, - #category : #'Spec2-Tests-Core' + #name : 'SpActionModifierTest', + #superclass : 'TestCase', + #category : 'Spec2-Tests-Core', + #package : 'Spec2-Tests', + #tag : 'Core' } -{ #category : #tests } +{ #category : 'tests' } SpActionModifierTest >> testActionModifier [ self From 1efd124bd7e7711841eb4fdccd7b5f9786385d6a Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 29 Nov 2023 12:50:39 +0100 Subject: [PATCH 76/88] update baseline --- src/BaselineOfSpecCore/BaselineOfSpecCore.class.st | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BaselineOfSpecCore/BaselineOfSpecCore.class.st b/src/BaselineOfSpecCore/BaselineOfSpecCore.class.st index 68f89d33c..1e3aa1c56 100644 --- a/src/BaselineOfSpecCore/BaselineOfSpecCore.class.st +++ b/src/BaselineOfSpecCore/BaselineOfSpecCore.class.st @@ -23,6 +23,10 @@ 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') ]; + package: 'Spec2-Adapters-Morphic-ListView' with: [ spec requires: #('Spec2-ListView') ]; + package: 'Spec2-ListView-Tests' with: [ spec requires: #('Spec2-ListView') ]; "Code" package: 'Spec2-Code' with: [ spec requires: #('Spec2-Core' 'Spec2-Commands') ]; package: 'Spec2-Code-Commands' with: [ spec requires: #('Spec2-Core' 'Spec2-Commands') ]; From 0c6f1755c4b60ce611c7892d7d3318e7b7a01210 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Thu, 7 Dec 2023 15:19:10 +0100 Subject: [PATCH 77/88] commenting the set of bounds to zero since it does not seems to be needed and it is causing a problem while restoring the component after hiding it. Hopefully this will not backfire, but there is a message to deal with the problem if this fix does not works out in all cases :P --- .../SpMorphicOverlayLayout.class.st | 8 ++++++-- src/Spec2-Core/SpNumberInputFieldPresenter.class.st | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicOverlayLayout.class.st b/src/Spec2-Adapters-Morphic/SpMorphicOverlayLayout.class.st index 8b50d5421..ad692f864 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicOverlayLayout.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicOverlayLayout.class.st @@ -75,8 +75,12 @@ SpMorphicOverlayLayout >> layout: aMorph in: layoutBounds [ constraints isOverlay ifTrue: [ self layoutOverlay: eachMorph in: layoutBounds ] ifFalse: [ eachMorph bounds: layoutBounds ] ] - ifFalse: [ - eachMorph bounds: (0@0 corner: 0@0) ] ] + ifFalse: [ + "in fact, this seems to not be necessary (while causing a problem on hide then show + again since I do not have the bounds anymore. If this fails, the solution is to + keep the old size in an extended property of the morph and then re-add it when + declaring it visible again (hopefully not needed)." + "eachMorph bounds: (0@0 corner: 0@0)" ] ] ] { #category : 'layout' } diff --git a/src/Spec2-Core/SpNumberInputFieldPresenter.class.st b/src/Spec2-Core/SpNumberInputFieldPresenter.class.st index 8de5091ea..37d402b7a 100644 --- a/src/Spec2-Core/SpNumberInputFieldPresenter.class.st +++ b/src/Spec2-Core/SpNumberInputFieldPresenter.class.st @@ -140,7 +140,8 @@ SpNumberInputFieldPresenter >> number [ "Answer the number ingressed." ^ self text trimmed - ifNotEmpty: [ :aString | aString asNumber ] + ifNotEmpty: [ :aString | + self numberType readFrom: aString ifFail: [ 0 ] ] ifEmpty: [ 0 ] ] From a8e44cb1be94fd71d94a21887cffe15ae59741ad Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 15 Dec 2023 10:51:43 +0100 Subject: [PATCH 78/88] remove (it was removed before) --- .../SpCodeDebugItCommand.class.st | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st b/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st index 5f7fdb2a1..f93d142ff 100644 --- a/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st +++ b/src/Spec2-Code-Commands/SpCodeDebugItCommand.class.st @@ -36,25 +36,6 @@ SpCodeDebugItCommand class >> defaultShortcutKey [ | $d shift control unix ] -{ #category : 'private' } -SpCodeDebugItCommand >> compile: aStream for: anObject in: evalContext [ - | methodClass | - - methodClass := evalContext - ifNotNil: [ evalContext methodClass ] - ifNil: [ anObject class ]. - - ^ context class compiler - source: aStream; - class: methodClass; - context: evalContext; - requestor: context; - "it should enable a visibility of current tool variables in new debugger" - isScripting: true; - failBlock: [ ^ nil ]; - compile -] - { #category : 'private' } SpCodeDebugItCommand >> debug: aStream [ From 01ff23e372d9d8222c2f2dcc2c87b5905da590a2 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 15 Dec 2023 10:51:51 +0100 Subject: [PATCH 79/88] add mock --- src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st b/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st index 7274b6c2a..ef96abcaa 100644 --- a/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st +++ b/src/Spec2-Code-Tests/SpCodeSystemNavigationMock.class.st @@ -30,10 +30,9 @@ SpCodeSystemNavigationMock >> browseHierarchy: aClass selector: aSelector [ ] { #category : 'enumerating' } -SpCodeSystemNavigationMock >> browseMessageList: aList name: labelString autoSelect: autoSelectString refreshingBlock: aBlock [ +SpCodeSystemNavigationMock >> browseMessageList: aList name: labelString highlight: autoSelectString refreshingBlock: aBlock [ messageList := aList - ] { #category : 'accessing' } From da2d1111f1496055a4fb1fc97bad3a68aac2b43d Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 11:13:35 +0100 Subject: [PATCH 80/88] fix some tests --- src/Spec2-Core/SpAbstractTextPresenter.class.st | 15 --------------- src/Spec2-Core/SpDialogWindowPresenter.class.st | 7 +++++++ src/Spec2-Examples/SpPanedLayout.extension.st | 8 +++----- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/Spec2-Core/SpAbstractTextPresenter.class.st b/src/Spec2-Core/SpAbstractTextPresenter.class.st index f5ada47d5..49ee180c3 100644 --- a/src/Spec2-Core/SpAbstractTextPresenter.class.st +++ b/src/Spec2-Core/SpAbstractTextPresenter.class.st @@ -338,21 +338,6 @@ SpAbstractTextPresenter >> updateSelectionFromModel: aSelection [ anAdapter setSelectionFromModel: aSelection ] ] -{ #category : 'TOREMOVE' } -SpAbstractTextPresenter >> whenAboutToStyleChangedDo: aBlock [ - "Set a block to perform when the about to style block changed" - - self whenAboutToStyleBlockChanged: [:block :old :announcement :anAnnouncer | - aBlock cull: (block value) cull: old cull: announcement cull: anAnnouncer ] -] - -{ #category : 'TOREMOVE' } -SpAbstractTextPresenter >> whenAcceptBlockChangedDo: aBlock [ - "Set a block to perform when the accept block changed" - - self property: #actionToPerform whenChangedDo: aBlock -] - { #category : 'api - events' } SpAbstractTextPresenter >> whenEditableChangedDo: aBlock [ "Inform when editable property has changed. diff --git a/src/Spec2-Core/SpDialogWindowPresenter.class.st b/src/Spec2-Core/SpDialogWindowPresenter.class.st index c70011140..010948a96 100644 --- a/src/Spec2-Core/SpDialogWindowPresenter.class.st +++ b/src/Spec2-Core/SpDialogWindowPresenter.class.st @@ -76,8 +76,15 @@ SpDialogWindowPresenter >> addButton: aString do: aBlock [ { #category : 'private' } SpDialogWindowPresenter >> addDefaultButton: aButtonPresenter [ "Adds button logic to dialog." + | actionBlock | + + actionBlock := aButtonPresenter action. defaultButton := self addButton: aButtonPresenter. + aButtonPresenter action: [ + actionBlock value. + "this is ugly, but this is how we can ensure this is not keeping the status as cancelled." + self beOk ]. defaultButton addStyle: 'default'. ^ defaultButton ] diff --git a/src/Spec2-Examples/SpPanedLayout.extension.st b/src/Spec2-Examples/SpPanedLayout.extension.st index 777b5a597..83d939782 100644 --- a/src/Spec2-Examples/SpPanedLayout.extension.st +++ b/src/Spec2-Examples/SpPanedLayout.extension.st @@ -8,16 +8,14 @@ SpPanedLayout class >> exampleNotResizingStartChild [ app := SpApplication new. presenter := SpPresenter newApplication: app. - presenter layout: (SpPanedLayout newVertical + presenter layout: (SpPanedLayout newTopToBottom positionOfSlider: 50; - add: (child1 := presenter newListView) - withConstraints: [ :c | c beNotResizable ]; - add: (child2 := presenter newListView); + add: (child1 := presenter newList) withConstraints: [ :c | c beNotResizable ]; + add: (child2 := presenter newList); yourself). child1 items: #(one two). child2 items: String loremIpsum substrings. presenter open - ] From af3cb100a079b85d022cd00952a9539403b7b1dd Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 11:28:06 +0100 Subject: [PATCH 81/88] fix pharo version --- .github/workflows/spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spec.yml b/.github/workflows/spec.yml index cd2828bb6..6fc295ddc 100644 --- a/.github/workflows/spec.yml +++ b/.github/workflows/spec.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest ] - smalltalk: [ Pharo64-11 ] + smalltalk: [ Pharo64-12 ] runs-on: ${{ matrix.os }} name: ${{ matrix.smalltalk }} on ${{ matrix.os }} steps: From 84425606c6de76571251b7e02da838f05186e7bc Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 11:32:09 +0100 Subject: [PATCH 82/88] remove test (it was testing a removed functionality) --- .../SpListCommonPropertiestTest.class.st | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Spec2-Backend-Tests/SpListCommonPropertiestTest.class.st b/src/Spec2-Backend-Tests/SpListCommonPropertiestTest.class.st index ab2891c8f..bb52fbc6c 100644 --- a/src/Spec2-Backend-Tests/SpListCommonPropertiestTest.class.st +++ b/src/Spec2-Backend-Tests/SpListCommonPropertiestTest.class.st @@ -27,15 +27,6 @@ SpListCommonPropertiestTest >> testChangingFromSingleToMultipleSelection [ self assert: presenter isMultipleSelection ] -{ #category : 'tests' } -SpListCommonPropertiestTest >> testEnablingFilteringUpdateOpenedList [ - self deny: self adapter hasFilter. - presenter matchSubstring. - self assert: self adapter hasFilter. - presenter itemFilter: nil. - self deny: self adapter hasFilter -] - { #category : 'tests' } SpListCommonPropertiestTest >> testRemoveHeaderTitleInPresenterRemovesColumnHeaderMorph [ self flag: #pharo7. From 1eff529638e89a55b4ce269eb4a65772498cc5f7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 12:58:49 +0100 Subject: [PATCH 83/88] move the factory method --- src/Spec2-Core/SpTPresenterBuilder.trait.st | 5 +++++ src/Spec2-Morphic/SpTPresenterBuilder.extension.st | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Spec2-Core/SpTPresenterBuilder.trait.st b/src/Spec2-Core/SpTPresenterBuilder.trait.st index 6383dbb3f..ef41427db 100644 --- a/src/Spec2-Core/SpTPresenterBuilder.trait.st +++ b/src/Spec2-Core/SpTPresenterBuilder.trait.st @@ -117,6 +117,11 @@ SpTPresenterBuilder >> newLabel [ ^ self instantiate: SpLabelPresenter ] +{ #category : 'scripting - widgets' } +SpTPresenterBuilder >> newLink [ + ^ self instantiate: SpLinkPresenter +] + { #category : 'scripting - widgets' } SpTPresenterBuilder >> newList [ ^ self instantiate: SpListPresenter diff --git a/src/Spec2-Morphic/SpTPresenterBuilder.extension.st b/src/Spec2-Morphic/SpTPresenterBuilder.extension.st index 72d760288..2184ad13a 100644 --- a/src/Spec2-Morphic/SpTPresenterBuilder.extension.st +++ b/src/Spec2-Morphic/SpTPresenterBuilder.extension.st @@ -1,10 +1,5 @@ Extension { #name : 'SpTPresenterBuilder' } -{ #category : '*Spec2-Morphic' } -SpTPresenterBuilder >> newLink [ - ^ self instantiate: SpLinkPresenter -] - { #category : '*Spec2-Morphic' } SpTPresenterBuilder >> newMorph [ From 6cbe943274404b3833c2bbcf01f42c6189f63f5b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 13:16:47 +0100 Subject: [PATCH 84/88] move examples to listview presenter package to fix dependency --- .../SpDropDownPresenter.extension.st | 56 ------ .../SpListViewPresenter.extension.st | 162 ------------------ .../SpDropDownPresenter.class.st | 55 ++++++ .../SpListViewPresenter.class.st | 161 +++++++++++++++++ 4 files changed, 216 insertions(+), 218 deletions(-) delete mode 100644 src/Spec2-Examples/SpDropDownPresenter.extension.st delete mode 100644 src/Spec2-Examples/SpListViewPresenter.extension.st diff --git a/src/Spec2-Examples/SpDropDownPresenter.extension.st b/src/Spec2-Examples/SpDropDownPresenter.extension.st deleted file mode 100644 index 9f4b300c7..000000000 --- a/src/Spec2-Examples/SpDropDownPresenter.extension.st +++ /dev/null @@ -1,56 +0,0 @@ -Extension { #name : 'SpDropDownPresenter' } - -{ #category : '*Spec2-Examples' } -SpDropDownPresenter class >> example [ - "This example show the simples list view you can make: A list with a label" - - self new - application: (SpApplication new useBackend: #Gtk); - items: self environment allClasses; - setup: [ :aPresenter | aPresenter newLabel ]; - bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - display: [ :aClass | aClass name ]; - open -] - -{ #category : '*Spec2-Examples' } -SpDropDownPresenter class >> exampleWithIcons [ - "This example shows how to construct a list with icons. - It shows also the fact you can put any presenter inside, giving a huge power - to your lists." - - ^ self new - application: (SpApplication new useBackend: #Gtk); - items: self environment allClasses; - setup: [ :aPresenter | - | presenter | - (presenter := aPresenter newPresenter) - layout: (SpBoxLayout newHorizontal - "spacing: 5;" - add: presenter newImage expand: false; - add: presenter newLabel; - yourself); - yourself ]; - bind: [ :aPresenter :aClass | | icon image label | - icon := Smalltalk ui icons iconNamed: aClass systemIconName. - image := aPresenter layout children first. - image image: icon. - label := aPresenter layout children second. - label label: aClass name ]; - open -] - -{ #category : '*Spec2-Examples' } -SpDropDownPresenter class >> exampleWithSelectedItem [ - "This example show the simples list view you can make: A list with a label" - - self new - application: (SpApplication new useBackend: #Gtk); - items: self environment allClassesAndTraits; - setup: [ :aPresenter | aPresenter newLabel ]; - bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - display: [ :aClass | aClass name ]; - selectItem: Object; - whenSelectionChangedDo: [ :aSelection | aSelection selectedItem crTrace ]; - open -] diff --git a/src/Spec2-Examples/SpListViewPresenter.extension.st b/src/Spec2-Examples/SpListViewPresenter.extension.st deleted file mode 100644 index 527c77aaf..000000000 --- a/src/Spec2-Examples/SpListViewPresenter.extension.st +++ /dev/null @@ -1,162 +0,0 @@ -Extension { #name : 'SpListViewPresenter' } - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> example [ - "This example show the simples list view you can make: A list with a label" - - self new - application: (SpApplication new useBackend: #Gtk); - items: self environment allClasses; - setup: [ :aPresenter | aPresenter newLabel ]; - bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - open -] - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> exampleReplaceItems [ - "This example shows how to replace dynamically the list of elements." - | presenter listView button items | - - items := #(). - - presenter := SpPresenter newApplication: (SpApplication new "useBackend: #Gtk"). - presenter layout: (SpBoxLayout newVertical - add: (listView := presenter newListView); - add: (button := presenter newButton) expand: false; - yourself). - - listView - items: #(); - setup: [ :aPresenter | aPresenter newLabel ]; - bind: [ :aPresenter :aClass | aPresenter label: aClass name ]. - - button - label: 'Add'; - action: [ listView items: (items := items copyWith: self environment allClasses atRandom) ]. - - ^ presenter open -] - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> exampleWithActions [ - "This example show the simples list view you can make: A list with a label" - - self new - application: (SpApplication new useBackend: #Gtk); - items: self environment allClasses; - setup: [ :aPresenter | aPresenter newLabel ]; - bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; - actionsWith: [ :rootGroup | rootGroup - addGroupWith: [ :aGroup | aGroup - name: 'Group 1'; - beDisplayedAsGroup; - addActionWith: [ :act | act - name: 'Test 1'; - shortcut: $a ctrl; - action: [ 'Test 1.1' crTrace ] ]; - addActionWith: [ :act | act - name: 'Test 2'; - action: [ 'Test 1.2' crTrace ] ] ]; - addGroupWith: [ :subGroup1 | subGroup1 - name: 'Group 2'; - addActionWith: [ :act | act - name: 'Test 1'; - shortcut: $y ctrl; - action: [ 'Test 2.1' crTrace ]; - actionEnabled: [ false ] ]; - addActionWith: [ :act | act - name: 'Test 2'; - action: [ 'Test 2.2' crTrace ] ] ]; - addActionWith: [ :act | act - name: 'Test 3'; - shortcut: $a ctrl; - action: [ 'Test 3' crTrace ] ]; - addActionWith: [ :act | act - name: 'Test 4'; - shortcut: Character escape asKeyCombination; - action: [ 'Test 4' crTrace ] ] ]; - open -] - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> exampleWithIcons [ - "This example shows how to construct a list with icons. - It shows also the fact you can put any presenter inside, giving a huge power - to your lists." - - ^ self new - "application: (SpApplication new useBackend: #Gtk);" - items: self environment allClasses; - setup: [ :aPresenter | - | presenter | - (presenter := aPresenter newPresenter) - layout: (SpBoxLayout newHorizontal - spacing: 5; - add: presenter newImage expand: false; - add: presenter newLabel; - yourself); - yourself ]; - bind: [ :aPresenter :aClass | | icon image label | - icon := Smalltalk ui icons iconNamed: aClass systemIconName. - image := aPresenter layout children first. - image image: icon. - label := aPresenter layout children second. - label label: aClass name ]; - open -] - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ - "This example shows how to construct a list with icons. - It shows also the fact you can put any presenter inside, giving a huge power - to your lists." - - ^ self new - "application: (SpApplication new useBackend: #Gtk);" - items: self environment allClasses; - selectItem: Object scrollToSelection: true; - setup: [ :aPresenter | - | presenter | - (presenter := aPresenter newPresenter) - layout: (SpBoxLayout newHorizontal - spacing: 5; - add: presenter newImage expand: false; - add: presenter newLabel; - yourself); - yourself ]; - bind: [ :aPresenter :aClass | | icon image label | - icon := Smalltalk ui icons iconNamed: aClass systemIconName. - image := aPresenter layout children first. - image image: icon. - label := aPresenter layout children second. - label label: aClass name ]; - open -] - -{ #category : '*Spec2-Examples' } -SpListViewPresenter class >> exampleWithIconsMultipleSelection [ - "This example shows how to construct a list with multiple selection available. - It shows also the fact you can put any presenter inside, giving a huge power - to your lists." - - ^ self new - "application: (SpApplication new useBackend: #Gtk);" - beMultipleSelection; - items: self environment allClasses; - setup: [ :aPresenter | - | presenter | - (presenter := aPresenter newPresenter) - layout: (SpBoxLayout newHorizontal - spacing: 5; - add: presenter newImage expand: false; - add: presenter newLabel; - yourself); - yourself ]; - bind: [ :aPresenter :aClass | | icon image label | - icon := Smalltalk ui icons iconNamed: aClass systemIconName. - image := aPresenter layout children first. - image image: icon. - label := aPresenter layout children second. - label label: aClass name ]; - open -] diff --git a/src/Spec2-ListView/SpDropDownPresenter.class.st b/src/Spec2-ListView/SpDropDownPresenter.class.st index b4f9346d5..f212fbdeb 100644 --- a/src/Spec2-ListView/SpDropDownPresenter.class.st +++ b/src/Spec2-ListView/SpDropDownPresenter.class.st @@ -18,6 +18,61 @@ SpDropDownPresenter class >> adapterName [ ^ #DropDownAdapter ] +{ #category : 'examples' } +SpDropDownPresenter class >> example [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + display: [ :aClass | aClass name ]; + open +] + +{ #category : 'examples' } +SpDropDownPresenter class >> exampleWithIcons [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + "spacing: 5;" + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : 'examples' } +SpDropDownPresenter class >> exampleWithSelectedItem [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClassesAndTraits; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + display: [ :aClass | aClass name ]; + selectItem: Object; + whenSelectionChangedDo: [ :aSelection | aSelection selectedItem crTrace ]; + open +] + { #category : 'api' } SpDropDownPresenter >> bind: aBlock [ diff --git a/src/Spec2-ListView/SpListViewPresenter.class.st b/src/Spec2-ListView/SpListViewPresenter.class.st index 24da78090..77a2ed227 100644 --- a/src/Spec2-ListView/SpListViewPresenter.class.st +++ b/src/Spec2-ListView/SpListViewPresenter.class.st @@ -17,6 +17,167 @@ SpListViewPresenter class >> adapterName [ ^ #ListViewAdapter ] +{ #category : 'examples' } +SpListViewPresenter class >> example [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + open +] + +{ #category : 'examples' } +SpListViewPresenter class >> exampleReplaceItems [ + "This example shows how to replace dynamically the list of elements." + | presenter listView button items | + + items := #(). + + presenter := SpPresenter newApplication: (SpApplication new "useBackend: #Gtk"). + presenter layout: (SpBoxLayout newVertical + add: (listView := presenter newListView); + add: (button := presenter newButton) expand: false; + yourself). + + listView + items: #(); + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]. + + button + label: 'Add'; + action: [ listView items: (items := items copyWith: self environment allClasses atRandom) ]. + + ^ presenter open +] + +{ #category : 'examples' } +SpListViewPresenter class >> exampleWithActions [ + "This example show the simples list view you can make: A list with a label" + + self new + application: (SpApplication new useBackend: #Gtk); + items: self environment allClasses; + setup: [ :aPresenter | aPresenter newLabel ]; + bind: [ :aPresenter :aClass | aPresenter label: aClass name ]; + actionsWith: [ :rootGroup | rootGroup + addGroupWith: [ :aGroup | aGroup + name: 'Group 1'; + beDisplayedAsGroup; + addActionWith: [ :act | act + name: 'Test 1'; + shortcut: $a ctrl; + action: [ 'Test 1.1' crTrace ] ]; + addActionWith: [ :act | act + name: 'Test 2'; + action: [ 'Test 1.2' crTrace ] ] ]; + addGroupWith: [ :subGroup1 | subGroup1 + name: 'Group 2'; + addActionWith: [ :act | act + name: 'Test 1'; + shortcut: $y ctrl; + action: [ 'Test 2.1' crTrace ]; + actionEnabled: [ false ] ]; + addActionWith: [ :act | act + name: 'Test 2'; + action: [ 'Test 2.2' crTrace ] ] ]; + addActionWith: [ :act | act + name: 'Test 3'; + shortcut: $a ctrl; + action: [ 'Test 3' crTrace ] ]; + addActionWith: [ :act | act + name: 'Test 4'; + shortcut: Character escape asKeyCombination; + action: [ 'Test 4' crTrace ] ] ]; + open +] + +{ #category : 'examples' } +SpListViewPresenter class >> exampleWithIcons [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + "application: (SpApplication new useBackend: #Gtk);" + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : 'examples' } +SpListViewPresenter class >> exampleWithIconsAndSelectedItem [ + "This example shows how to construct a list with icons. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + "application: (SpApplication new useBackend: #Gtk);" + items: self environment allClasses; + selectItem: Object scrollToSelection: true; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + +{ #category : 'examples' } +SpListViewPresenter class >> exampleWithIconsMultipleSelection [ + "This example shows how to construct a list with multiple selection available. + It shows also the fact you can put any presenter inside, giving a huge power + to your lists." + + ^ self new + "application: (SpApplication new useBackend: #Gtk);" + beMultipleSelection; + items: self environment allClasses; + setup: [ :aPresenter | + | presenter | + (presenter := aPresenter newPresenter) + layout: (SpBoxLayout newHorizontal + spacing: 5; + add: presenter newImage expand: false; + add: presenter newLabel; + yourself); + yourself ]; + bind: [ :aPresenter :aClass | | icon image label | + icon := Smalltalk ui icons iconNamed: aClass systemIconName. + image := aPresenter layout children first. + image image: icon. + label := aPresenter layout children second. + label label: aClass name ]; + open +] + { #category : 'api' } SpListViewPresenter >> bind: aBlock [ From 774b6e6744578d972aff556178377dcb104bcdfc Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 13:38:53 +0100 Subject: [PATCH 85/88] moving also the test --- .../SpLinkPresenterTest.class.st | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename src/{Spec2-Morphic-Tests => Spec2-Tests}/SpLinkPresenterTest.class.st (91%) diff --git a/src/Spec2-Morphic-Tests/SpLinkPresenterTest.class.st b/src/Spec2-Tests/SpLinkPresenterTest.class.st similarity index 91% rename from src/Spec2-Morphic-Tests/SpLinkPresenterTest.class.st rename to src/Spec2-Tests/SpLinkPresenterTest.class.st index 648137c04..c26436100 100644 --- a/src/Spec2-Morphic-Tests/SpLinkPresenterTest.class.st +++ b/src/Spec2-Tests/SpLinkPresenterTest.class.st @@ -1,8 +1,9 @@ Class { #name : 'SpLinkPresenterTest', #superclass : 'SpSmokeTest', - #category : 'Spec2-Morphic-Tests', - #package : 'Spec2-Morphic-Tests' + #category : 'Spec2-Tests-Core-Widgets', + #package : 'Spec2-Tests', + #tag : 'Core-Widgets' } { #category : 'accessing' } From 11db99faee1ce70ad185e91f6bea1eb4e0242d65 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 18 Dec 2023 13:46:10 +0100 Subject: [PATCH 86/88] remove itemFilter --- src/Spec2-Core/SpAbstractListPresenter.class.st | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Spec2-Core/SpAbstractListPresenter.class.st b/src/Spec2-Core/SpAbstractListPresenter.class.st index a56e749f2..837552841 100644 --- a/src/Spec2-Core/SpAbstractListPresenter.class.st +++ b/src/Spec2-Core/SpAbstractListPresenter.class.st @@ -10,7 +10,6 @@ Class { '#activationBlock', '#activateOnSingleClick', '#model', - '#itemFilter => ObservableSlot', '#verticalAlignment' ], #category : 'Spec2-Core-Widgets-Table', From 4a410314d75fe356f874b047bb7e7d0b73ae5f3b Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 19 Dec 2023 10:22:08 +0100 Subject: [PATCH 87/88] move to local package to avoid dependency complains --- .../SpDropDownPresenter.class.st | 24 ++++++++++++ .../SpEasyListViewPresenter.class.st | 36 ++++++++++++++++++ .../SpDropDownPresenter.extension.st | 25 ------------- .../SpEasyListViewPresenter.extension.st | 37 ------------------- 4 files changed, 60 insertions(+), 62 deletions(-) delete mode 100644 src/Spec2-Transmission/SpDropDownPresenter.extension.st delete mode 100644 src/Spec2-Transmission/SpEasyListViewPresenter.extension.st diff --git a/src/Spec2-ListView/SpDropDownPresenter.class.st b/src/Spec2-ListView/SpDropDownPresenter.class.st index f212fbdeb..5f2446b69 100644 --- a/src/Spec2-ListView/SpDropDownPresenter.class.st +++ b/src/Spec2-ListView/SpDropDownPresenter.class.st @@ -85,6 +85,18 @@ SpDropDownPresenter >> bindAction [ ^ bindAction ] +{ #category : 'transmission' } +SpDropDownPresenter >> defaultInputPort [ + + ^ self inputItemsPort +] + +{ #category : 'transmission' } +SpDropDownPresenter >> defaultOutputPort [ + + ^ self outputSelectionPort +] + { #category : 'private' } SpDropDownPresenter >> display [ @@ -122,6 +134,12 @@ SpDropDownPresenter >> initializeItemFactory [ aPresenter label: (self display value: anObject) asString ] ] +{ #category : 'transmission' } +SpDropDownPresenter >> inputItemsPort [ + + ^ SpListItemsPort newPresenter: self +] + { #category : 'api' } SpDropDownPresenter >> items [ "Answer the items of the list" @@ -162,6 +180,12 @@ SpDropDownPresenter >> newEmptyModel [ ^ SpCollectionListModel on: #() ] +{ #category : 'transmission' } +SpDropDownPresenter >> outputSelectionPort [ + + ^ SpDropDownSelectionPort newPresenter: self +] + { #category : 'api - selection' } SpDropDownPresenter >> selectFirst [ "Select first element in list. diff --git a/src/Spec2-ListView/SpEasyListViewPresenter.class.st b/src/Spec2-ListView/SpEasyListViewPresenter.class.st index 599153141..426559dc4 100644 --- a/src/Spec2-ListView/SpEasyListViewPresenter.class.st +++ b/src/Spec2-ListView/SpEasyListViewPresenter.class.st @@ -155,6 +155,12 @@ SpEasyListViewPresenter >> deactivateSearch: acceptSelection [ listView takeKeyboardFocus ] +{ #category : 'transmission' } +SpEasyListViewPresenter >> defaultInputPort [ + + ^ self inputItemsPort +] + { #category : 'layout' } SpEasyListViewPresenter >> defaultLayout [ @@ -167,6 +173,12 @@ SpEasyListViewPresenter >> defaultLayout [ yourself ] +{ #category : 'transmission' } +SpEasyListViewPresenter >> defaultOutputPort [ + + ^ self outputSelectionPort +] + { #category : 'api' } SpEasyListViewPresenter >> disable [ @@ -312,6 +324,14 @@ SpEasyListViewPresenter >> initializePresenters [ searchInput hide ] +{ #category : 'transmission' } +SpEasyListViewPresenter >> inputItemsPort [ + + ^ (SpListItemsPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] + { #category : 'api' } SpEasyListViewPresenter >> items [ @@ -341,6 +361,22 @@ SpEasyListViewPresenter >> model [ ^ listView model ] +{ #category : 'transmission' } +SpEasyListViewPresenter >> outputActivationPort [ + + ^ (SpActivationPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] + +{ #category : 'transmission' } +SpEasyListViewPresenter >> outputSelectionPort [ + + ^ (SpSelectionPort newPresenter: self) + delegateTo: [ listView ]; + yourself +] + { #category : 'initialization' } SpEasyListViewPresenter >> registerEvents [ diff --git a/src/Spec2-Transmission/SpDropDownPresenter.extension.st b/src/Spec2-Transmission/SpDropDownPresenter.extension.st deleted file mode 100644 index 0df04f23f..000000000 --- a/src/Spec2-Transmission/SpDropDownPresenter.extension.st +++ /dev/null @@ -1,25 +0,0 @@ -Extension { #name : 'SpDropDownPresenter' } - -{ #category : '*Spec2-Transmission' } -SpDropDownPresenter >> defaultInputPort [ - - ^ self inputItemsPort -] - -{ #category : '*Spec2-Transmission' } -SpDropDownPresenter >> defaultOutputPort [ - - ^ self outputSelectionPort -] - -{ #category : '*Spec2-Transmission' } -SpDropDownPresenter >> inputItemsPort [ - - ^ SpListItemsPort newPresenter: self -] - -{ #category : '*Spec2-Transmission' } -SpDropDownPresenter >> outputSelectionPort [ - - ^ SpDropDownSelectionPort newPresenter: self -] diff --git a/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st b/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st deleted file mode 100644 index 63ea8de16..000000000 --- a/src/Spec2-Transmission/SpEasyListViewPresenter.extension.st +++ /dev/null @@ -1,37 +0,0 @@ -Extension { #name : 'SpEasyListViewPresenter' } - -{ #category : '*Spec2-Transmission' } -SpEasyListViewPresenter >> defaultInputPort [ - - ^ self inputItemsPort -] - -{ #category : '*Spec2-Transmission' } -SpEasyListViewPresenter >> defaultOutputPort [ - - ^ self outputSelectionPort -] - -{ #category : '*Spec2-Transmission' } -SpEasyListViewPresenter >> inputItemsPort [ - - ^ (SpListItemsPort newPresenter: self) - delegateTo: [ listView ]; - yourself -] - -{ #category : '*Spec2-Transmission' } -SpEasyListViewPresenter >> outputActivationPort [ - - ^ (SpActivationPort newPresenter: self) - delegateTo: [ listView ]; - yourself -] - -{ #category : '*Spec2-Transmission' } -SpEasyListViewPresenter >> outputSelectionPort [ - - ^ (SpSelectionPort newPresenter: self) - delegateTo: [ listView ]; - yourself -] From 7e61476b3eb4118f212542c7b78dd637409f2908 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 19 Dec 2023 15:08:48 +0100 Subject: [PATCH 88/88] fix bad message sends #fixes https://github.com/pharo-spec/Spec/issues/1450 --- src/Spec2-Core/SpApplication.class.st | 2 +- src/Spec2-Core/SpApplicationBackend.class.st | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Spec2-Core/SpApplication.class.st b/src/Spec2-Core/SpApplication.class.st index b7709b305..12e58206b 100644 --- a/src/Spec2-Core/SpApplication.class.st +++ b/src/Spec2-Core/SpApplication.class.st @@ -183,7 +183,7 @@ SpApplication >> ensureConfiguration [ configuration ifNotNil: [ ^ configuration ]. self ensureBackend. - configuration ifNil: [ configuration := backend newDefaultConfiguration ]. + configuration ifNil: [ configuration := backend defaultConfigurationFor: self ]. ^ configuration ] diff --git a/src/Spec2-Core/SpApplicationBackend.class.st b/src/Spec2-Core/SpApplicationBackend.class.st index d42ca09a2..840ecab3a 100644 --- a/src/Spec2-Core/SpApplicationBackend.class.st +++ b/src/Spec2-Core/SpApplicationBackend.class.st @@ -68,14 +68,6 @@ SpApplicationBackend >> name [ ^ self class backendName ] -{ #category : 'ui - notifying' } -SpApplicationBackend >> notify: aSpecNotification [ - - aSpecNotification type - notify: aSpecNotification - on: self -] - { #category : 'ui - notifying' } SpApplicationBackend >> notifyError: aSpecNotification [