From 9ff959739fcd90a7329d17efec2f505eeb73129e Mon Sep 17 00:00:00 2001 From: Guille Polito Date: Fri, 9 Aug 2019 09:58:25 +0200 Subject: [PATCH] Cleaning class names, comments, method formatting of Spec2-PolyWidgets --- .../SpIconListPresenter.class.st | 17 ++- .../SpInputTextDropListTest.class.st | 2 +- .../SpLabelledContainerTest.class.st | 2 +- .../SpLabelledDropListTest.class.st | 2 +- .../SpLabelledListTest.class.st | 2 +- .../SpLabelledSliderInputTest.class.st | 2 +- .../SpLabelledTextInputTest.class.st | 2 +- .../SpSliderInputTest.class.st | 2 +- .../SpInputTextDropList.class.st | 130 +--------------- .../SpInputTextDropListPresenter.class.st | 131 ++++++++++++++++ .../SpLabelledContainer.class.st | 104 +------------ .../SpLabelledContainerPrestenter.class.st | 105 +++++++++++++ .../SpLabelledDropList.class.st | 80 +--------- .../SpLabelledDropListPresenter.class.st | 81 ++++++++++ src/Spec2-PolyWidgets/SpLabelledList.class.st | 80 +--------- .../SpLabelledListPresenter.class.st | 81 ++++++++++ .../SpLabelledPresenter.class.st | 19 ++- .../SpLabelledSliderInput.class.st | 80 +--------- .../SpLabelledSliderInputPresenter.class.st | 81 ++++++++++ .../SpLabelledTextInput.class.st | 95 +----------- .../SpLabelledTextInputPresenter.class.st | 96 ++++++++++++ src/Spec2-PolyWidgets/SpRGBSliders.class.st | 16 +- src/Spec2-PolyWidgets/SpRGBWidget.class.st | 4 +- src/Spec2-PolyWidgets/SpSliderInput.class.st | 143 +---------------- .../SpSliderInputPresenter.class.st | 144 ++++++++++++++++++ .../SpToolBarItemPosition.class.st | 8 +- .../SpToolBarItemPositionLeft.class.st | 2 +- .../SpToolBarItemPositionRight.class.st | 2 +- src/Spec2-PolyWidgets/SpToolBarMorph.class.st | 2 +- 29 files changed, 778 insertions(+), 737 deletions(-) create mode 100644 src/Spec2-PolyWidgets/SpInputTextDropListPresenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpLabelledContainerPrestenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpLabelledDropListPresenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpLabelledListPresenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpLabelledSliderInputPresenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpLabelledTextInputPresenter.class.st create mode 100644 src/Spec2-PolyWidgets/SpSliderInputPresenter.class.st diff --git a/src/Spec2-Deprecated/SpIconListPresenter.class.st b/src/Spec2-Deprecated/SpIconListPresenter.class.st index ed3f01075c1..abe04e8b925 100644 --- a/src/Spec2-Deprecated/SpIconListPresenter.class.st +++ b/src/Spec2-Deprecated/SpIconListPresenter.class.st @@ -1,15 +1,16 @@ " -An IconListPresenter is a spec presenter for icon list. -See AbstractWidgetPresenter +Better use -self example +| iconList | + iconList := SpListPresenter new. + iconList + items: Smalltalk ui icons icons associations; + displayBlock: [ :assoc | assoc key ]; + sortingBlock: [ :assocA :assocB | assocA key < assocB key ]; + icons: [ :elem | elem value ]. + iconList openWithSpec -You can also have a look at ExampleListPresenter >> exampleIconList for another example. -I provide the following variables icons and its accessors, it is a block that convert an item in the icon to display near the item. - -todo -- getIconFor: " Class { #name : #SpIconListPresenter, diff --git a/src/Spec2-PolyWidgets-Tests/SpInputTextDropListTest.class.st b/src/Spec2-PolyWidgets-Tests/SpInputTextDropListTest.class.st index c15628c2de7..cc4712e77cf 100644 --- a/src/Spec2-PolyWidgets-Tests/SpInputTextDropListTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpInputTextDropListTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpInputTextDropListTest >> classToTest [ - ^ SpInputTextDropList + ^ SpInputTextDropListPresenter ] diff --git a/src/Spec2-PolyWidgets-Tests/SpLabelledContainerTest.class.st b/src/Spec2-PolyWidgets-Tests/SpLabelledContainerTest.class.st index 009a1431a77..b94751b5a8b 100644 --- a/src/Spec2-PolyWidgets-Tests/SpLabelledContainerTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpLabelledContainerTest.class.st @@ -6,7 +6,7 @@ Class { { #category : #running } SpLabelledContainerTest >> classToTest [ - ^ SpLabelledContainer + ^ SpLabelledContainerPrestenter ] { #category : #running } diff --git a/src/Spec2-PolyWidgets-Tests/SpLabelledDropListTest.class.st b/src/Spec2-PolyWidgets-Tests/SpLabelledDropListTest.class.st index ebce93bf850..0cf1f3d96ad 100644 --- a/src/Spec2-PolyWidgets-Tests/SpLabelledDropListTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpLabelledDropListTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpLabelledDropListTest >> classToTest [ - ^ SpLabelledDropList + ^ SpLabelledDropListPresenter ] diff --git a/src/Spec2-PolyWidgets-Tests/SpLabelledListTest.class.st b/src/Spec2-PolyWidgets-Tests/SpLabelledListTest.class.st index 996d4c461d6..022f236370b 100644 --- a/src/Spec2-PolyWidgets-Tests/SpLabelledListTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpLabelledListTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpLabelledListTest >> classToTest [ - ^ SpLabelledList + ^ SpLabelledListPresenter ] diff --git a/src/Spec2-PolyWidgets-Tests/SpLabelledSliderInputTest.class.st b/src/Spec2-PolyWidgets-Tests/SpLabelledSliderInputTest.class.st index 55fcd76061a..97a8caa7f84 100644 --- a/src/Spec2-PolyWidgets-Tests/SpLabelledSliderInputTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpLabelledSliderInputTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpLabelledSliderInputTest >> classToTest [ - ^ SpLabelledSliderInput + ^ SpLabelledSliderInputPresenter ] diff --git a/src/Spec2-PolyWidgets-Tests/SpLabelledTextInputTest.class.st b/src/Spec2-PolyWidgets-Tests/SpLabelledTextInputTest.class.st index af984420741..2f5ed5552b7 100644 --- a/src/Spec2-PolyWidgets-Tests/SpLabelledTextInputTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpLabelledTextInputTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpLabelledTextInputTest >> classToTest [ - ^ SpLabelledTextInput + ^ SpLabelledTextInputPresenter ] diff --git a/src/Spec2-PolyWidgets-Tests/SpSliderInputTest.class.st b/src/Spec2-PolyWidgets-Tests/SpSliderInputTest.class.st index 432d0a5613d..24e8437533b 100644 --- a/src/Spec2-PolyWidgets-Tests/SpSliderInputTest.class.st +++ b/src/Spec2-PolyWidgets-Tests/SpSliderInputTest.class.st @@ -6,5 +6,5 @@ Class { { #category : #running } SpSliderInputTest >> classToTest [ - ^ SpSliderInput + ^ SpSliderInputPresenter ] diff --git a/src/Spec2-PolyWidgets/SpInputTextDropList.class.st b/src/Spec2-PolyWidgets/SpInputTextDropList.class.st index af17ccd5504..2a1010ec781 100644 --- a/src/Spec2-PolyWidgets/SpInputTextDropList.class.st +++ b/src/Spec2-PolyWidgets/SpInputTextDropList.class.st @@ -1,131 +1,5 @@ -" -I am an elementary Spec widget that associates an TextInputField and a DropListPresenter. - -self example - -I provide accessors dropList and input and shortcuts for the most common methods of their api. -" Class { #name : #SpInputTextDropList, - #superclass : #SpPresenter, - #instVars : [ - 'dropList', - 'input' - ], - #category : #'Spec2-PolyWidgets-Elementary' + #superclass : #SpInputTextDropListPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #specs } -SpInputTextDropList class >> defaultSpec [ - - ^ SpLayout composed - newRow: [ :row | - row - add: #input origin: 0 @ 0 corner: 0.3 @ 1; - add: #dropList origin: 0.3 @ 0 corner: 1 @ 1 ]; - yourself -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> acceptOnCR: aBoolean [ - self input acceptOnCR: aBoolean -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> beEncrypted [ - self input beEncrypted -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> displayBlock: aBlock [ - self dropList displayBlock: aBlock -] - -{ #category : #accessing } -SpInputTextDropList >> dropList [ - ^ dropList -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> emptyList [ - self dropList emptyList -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> encrypted: aBoolean [ - self input encrypted: aBoolean -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> entryCompletion: anEntryCompletion [ - self input entryCompletion: anEntryCompletion -] - -{ #category : #initialization } -SpInputTextDropList >> initializeWidgets [ - input := self instantiate: SpTextInputFieldPresenter. - dropList := self instantiate: SpDropListPresenter. - self focusOrder - add: input; - add: dropList -] - -{ #category : #accessing } -SpInputTextDropList >> input [ - ^ input -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> items: aList [ - self dropList items: aList -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> listSize [ - self dropList listSize -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> placeholder: aText [ - self input placeholder: aText -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> resetSelection [ - self dropList resetSelection -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> selectedItem [ - self dropList selectedItem -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> setIndex: anIndex [ - self dropList setIndex: anIndex -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> text [ - self input text -] - -{ #category : #'api-shortcuts' } -SpInputTextDropList >> text: aText [ - self input text: aText -] - -{ #category : #'events-shortcuts' } -SpInputTextDropList >> whenSelectedItemChanged: aBlock [ - self dropList whenSelectedItemChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpInputTextDropList >> whenSelectionChanged: aBlock [ - self dropList whenSelectionChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpInputTextDropList >> whenSelectionIndexChanged: aBlock [ - self dropList whenSelectionIndexChanged: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpInputTextDropListPresenter.class.st b/src/Spec2-PolyWidgets/SpInputTextDropListPresenter.class.st new file mode 100644 index 00000000000..5bf29cab914 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpInputTextDropListPresenter.class.st @@ -0,0 +1,131 @@ +" +I am an elementary Spec widget that associates an TextInputField and a DropListPresenter. + +self example + +I provide accessors dropList and input and shortcuts for the most common methods of their api. +" +Class { + #name : #SpInputTextDropListPresenter, + #superclass : #SpPresenter, + #instVars : [ + 'dropList', + 'input' + ], + #category : #'Spec2-PolyWidgets-Elementary' +} + +{ #category : #specs } +SpInputTextDropListPresenter class >> defaultSpec [ + + ^ SpLayout composed + newRow: [ :row | + row + add: #input origin: 0 @ 0 corner: 0.3 @ 1; + add: #dropList origin: 0.3 @ 0 corner: 1 @ 1 ]; + yourself +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> acceptOnCR: aBoolean [ + self input acceptOnCR: aBoolean +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> beEncrypted [ + self input beEncrypted +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> displayBlock: aBlock [ + self dropList displayBlock: aBlock +] + +{ #category : #accessing } +SpInputTextDropListPresenter >> dropList [ + ^ dropList +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> emptyList [ + self dropList emptyList +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> encrypted: aBoolean [ + self input encrypted: aBoolean +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> entryCompletion: anEntryCompletion [ + self input entryCompletion: anEntryCompletion +] + +{ #category : #initialization } +SpInputTextDropListPresenter >> initializeWidgets [ + input := self instantiate: SpTextInputFieldPresenter. + dropList := self instantiate: SpDropListPresenter. + self focusOrder + add: input; + add: dropList +] + +{ #category : #accessing } +SpInputTextDropListPresenter >> input [ + ^ input +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> items: aList [ + self dropList items: aList +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> listSize [ + self dropList listSize +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> placeholder: aText [ + self input placeholder: aText +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> resetSelection [ + self dropList resetSelection +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> selectedItem [ + self dropList selectedItem +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> setIndex: anIndex [ + self dropList setIndex: anIndex +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> text [ + self input text +] + +{ #category : #'api-shortcuts' } +SpInputTextDropListPresenter >> text: aText [ + self input text: aText +] + +{ #category : #'events-shortcuts' } +SpInputTextDropListPresenter >> whenSelectedItemChanged: aBlock [ + self dropList whenSelectedItemChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpInputTextDropListPresenter >> whenSelectionChanged: aBlock [ + self dropList whenSelectionChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpInputTextDropListPresenter >> whenSelectionIndexChanged: aBlock [ + self dropList whenSelectionIndexChanged: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpLabelledContainer.class.st b/src/Spec2-PolyWidgets/SpLabelledContainer.class.st index a2a5b3023bb..07bcbccbe11 100644 --- a/src/Spec2-PolyWidgets/SpLabelledContainer.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledContainer.class.st @@ -1,105 +1,5 @@ -" -I am an elementary Spec widget that adds a LabelPresenter at another widget. - -self example - -I provide the method content: that take a class in parameter, it instantiates it in the variable subwidget and add it at the focusOrder. Note it does not reset the focusOrder. - -I provide accessors for the label and the subwidget, but I specialize doesNotUnderstand: to send the message at the subwidget. - -I provide four layouts on my class side, to chose the position of the label. -" Class { #name : #SpLabelledContainer, - #superclass : #SpPresenter, - #instVars : [ - 'label', - 'subwidget' - ], - #category : #'Spec2-PolyWidgets-Labelled' + #superclass : #SpLabelledContainerPrestenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #specs } -SpLabelledContainer class >> defaultSpec [ - ^ self labelTop -] - -{ #category : #specs } -SpLabelledContainer class >> labelBottom [ - - ^ SpLayout composed - newColumn: [ :column | - column - add: #subwidget origin: 0 @ 0 corner: 1 @ 0.9; - add: #label origin: 0 @ 0.9 corner: 1 @ 1 ]; - yourself -] - -{ #category : #specs } -SpLabelledContainer class >> labelLeft [ - - ^ SpLayout composed - newRow: [ :row | - row - add: #label origin: 0 @ 0 corner: 0.2 @ 1; - add: #subwidget origin: 0.2 @ 0 corner: 1 @ 1 ]; - yourself -] - -{ #category : #specs } -SpLabelledContainer class >> labelRight [ - - ^ SpLayout composed - newRow: [ :row | - row - add: #subwidget origin: 0 @ 0 corner: 0.8 @ 1; - add: #label origin: 0.8 @ 0 corner: 1 @ 1 ]; - yourself -] - -{ #category : #specs } -SpLabelledContainer class >> labelTop [ - - ^ SpLayout composed - newColumn: [ :column | - column - add: #label origin: 0 @ 0 corner: 1 @ 0.1; - add: #subwidget origin: 0 @ 0.1 corner: 1 @ 1 ]; - yourself -] - -{ #category : #initialization } -SpLabelledContainer >> content: aWidgetClass [ - subwidget := self instantiate: aWidgetClass. - self focusOrder add: subwidget -] - -{ #category : #'error handling' } -SpLabelledContainer >> doesNotUnderstand: aMessage [ - ^ aMessage sendTo: subwidget -] - -{ #category : #initialization } -SpLabelledContainer >> initializeWidgets [ - label := self instantiate: SpLabelPresenter. -] - -{ #category : #accessing } -SpLabelledContainer >> label [ - ^ label -] - -{ #category : #accessing } -SpLabelledContainer >> label: aString [ - label label: aString -] - -{ #category : #accessing } -SpLabelledContainer >> subwidget [ - ^ subwidget -] - -{ #category : #accessing } -SpLabelledContainer >> subwidget: anObject [ - subwidget := anObject -] diff --git a/src/Spec2-PolyWidgets/SpLabelledContainerPrestenter.class.st b/src/Spec2-PolyWidgets/SpLabelledContainerPrestenter.class.st new file mode 100644 index 00000000000..78995a6b0c4 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpLabelledContainerPrestenter.class.st @@ -0,0 +1,105 @@ +" +I am an elementary Spec widget that adds a LabelPresenter at another widget. + +self example + +I provide the method content: that take a class in parameter, it instantiates it in the variable subwidget and add it at the focusOrder. Note it does not reset the focusOrder. + +I provide accessors for the label and the subwidget, but I specialize doesNotUnderstand: to send the message at the subwidget. + +I provide four layouts on my class side, to chose the position of the label. +" +Class { + #name : #SpLabelledContainerPrestenter, + #superclass : #SpPresenter, + #instVars : [ + 'label', + 'subwidget' + ], + #category : #'Spec2-PolyWidgets-Labelled' +} + +{ #category : #specs } +SpLabelledContainerPrestenter class >> defaultSpec [ + ^ self labelTop +] + +{ #category : #specs } +SpLabelledContainerPrestenter class >> labelBottom [ + + ^ SpLayout composed + newColumn: [ :column | + column + add: #subwidget origin: 0 @ 0 corner: 1 @ 0.9; + add: #label origin: 0 @ 0.9 corner: 1 @ 1 ]; + yourself +] + +{ #category : #specs } +SpLabelledContainerPrestenter class >> labelLeft [ + + ^ SpLayout composed + newRow: [ :row | + row + add: #label origin: 0 @ 0 corner: 0.2 @ 1; + add: #subwidget origin: 0.2 @ 0 corner: 1 @ 1 ]; + yourself +] + +{ #category : #specs } +SpLabelledContainerPrestenter class >> labelRight [ + + ^ SpLayout composed + newRow: [ :row | + row + add: #subwidget origin: 0 @ 0 corner: 0.8 @ 1; + add: #label origin: 0.8 @ 0 corner: 1 @ 1 ]; + yourself +] + +{ #category : #specs } +SpLabelledContainerPrestenter class >> labelTop [ + + ^ SpLayout composed + newColumn: [ :column | + column + add: #label origin: 0 @ 0 corner: 1 @ 0.1; + add: #subwidget origin: 0 @ 0.1 corner: 1 @ 1 ]; + yourself +] + +{ #category : #initialization } +SpLabelledContainerPrestenter >> content: aWidgetClass [ + subwidget := self instantiate: aWidgetClass. + self focusOrder add: subwidget +] + +{ #category : #'error handling' } +SpLabelledContainerPrestenter >> doesNotUnderstand: aMessage [ + ^ aMessage sendTo: subwidget +] + +{ #category : #initialization } +SpLabelledContainerPrestenter >> initializeWidgets [ + label := self instantiate: SpLabelPresenter. +] + +{ #category : #accessing } +SpLabelledContainerPrestenter >> label [ + ^ label +] + +{ #category : #accessing } +SpLabelledContainerPrestenter >> label: aString [ + label label: aString +] + +{ #category : #accessing } +SpLabelledContainerPrestenter >> subwidget [ + ^ subwidget +] + +{ #category : #accessing } +SpLabelledContainerPrestenter >> subwidget: anObject [ + subwidget := anObject +] diff --git a/src/Spec2-PolyWidgets/SpLabelledDropList.class.st b/src/Spec2-PolyWidgets/SpLabelledDropList.class.st index b255593f7ce..b5ac1c71075 100644 --- a/src/Spec2-PolyWidgets/SpLabelledDropList.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledDropList.class.st @@ -1,81 +1,5 @@ -" -I am a LabelledContainer specialized to manage a DropListPresenter. -See LabelledContainer - -self example - -I provide the accessor dropList to be more intuitive than subwidget. - -I provide shortcuts for the most common methods of the droplist api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. -" Class { #name : #SpLabelledDropList, - #superclass : #SpLabelledContainer, - #category : #'Spec2-PolyWidgets-Labelled' + #superclass : #SpLabelledDropListPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #specs } -SpLabelledDropList class >> defaultSpec [ - ^ self labelLeft -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> displayBlock: aBlock [ - ^self dropList displayBlock: aBlock -] - -{ #category : #accessing } -SpLabelledDropList >> dropList [ - ^ self subwidget -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> emptyList [ - ^self dropList emptyList -] - -{ #category : #initialization } -SpLabelledDropList >> initializeWidgets [ -super initializeWidgets. - self content: SpDropListPresenter -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> items: aList [ - ^self dropList items: aList -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> listSize [ - ^self dropList listSize -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> resetSelection [ - ^self dropList resetSelection -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> selectedItem [ - ^self dropList selectedItem -] - -{ #category : #'api-shortcuts' } -SpLabelledDropList >> setIndex: anIndex [ - ^self dropList setIndex: anIndex -] - -{ #category : #'events-shortcuts' } -SpLabelledDropList >> whenSelectedItemChanged: aBlock [ - self dropList whenSelectedItemChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledDropList >> whenSelectionChanged: aBlock [ - self dropList whenSelectionChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledDropList >> whenSelectionIndexChanged: aBlock [ - self dropList whenSelectionIndexChanged: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpLabelledDropListPresenter.class.st b/src/Spec2-PolyWidgets/SpLabelledDropListPresenter.class.st new file mode 100644 index 00000000000..e9520d319a2 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpLabelledDropListPresenter.class.st @@ -0,0 +1,81 @@ +" +I am a LabelledContainer specialized to manage a DropListPresenter. +See LabelledContainer + +self example + +I provide the accessor dropList to be more intuitive than subwidget. + +I provide shortcuts for the most common methods of the droplist api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. +" +Class { + #name : #SpLabelledDropListPresenter, + #superclass : #SpLabelledContainerPrestenter, + #category : #'Spec2-PolyWidgets-Labelled' +} + +{ #category : #specs } +SpLabelledDropListPresenter class >> defaultSpec [ + ^ self labelLeft +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> displayBlock: aBlock [ + ^self dropList displayBlock: aBlock +] + +{ #category : #accessing } +SpLabelledDropListPresenter >> dropList [ + ^ self subwidget +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> emptyList [ + ^self dropList emptyList +] + +{ #category : #initialization } +SpLabelledDropListPresenter >> initializeWidgets [ +super initializeWidgets. + self content: SpDropListPresenter +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> items: aList [ + ^self dropList items: aList +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> listSize [ + ^self dropList listSize +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> resetSelection [ + ^self dropList resetSelection +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> selectedItem [ + ^self dropList selectedItem +] + +{ #category : #'api-shortcuts' } +SpLabelledDropListPresenter >> setIndex: anIndex [ + ^self dropList setIndex: anIndex +] + +{ #category : #'events-shortcuts' } +SpLabelledDropListPresenter >> whenSelectedItemChanged: aBlock [ + self dropList whenSelectedItemChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledDropListPresenter >> whenSelectionChanged: aBlock [ + self dropList whenSelectionChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledDropListPresenter >> whenSelectionIndexChanged: aBlock [ + self dropList whenSelectionIndexChanged: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpLabelledList.class.st b/src/Spec2-PolyWidgets/SpLabelledList.class.st index 7b9cb5176e8..61e7f02697d 100644 --- a/src/Spec2-PolyWidgets/SpLabelledList.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledList.class.st @@ -1,81 +1,5 @@ -" -I am a LabelledContainer specialized to manage a ListPresenter. -See LabelledContainer - -self example - -I provide the accessor list to be more intuitive than subwidget. - -I provide shortcuts for the most common methods of the list api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. -" Class { #name : #SpLabelledList, - #superclass : #SpLabelledContainer, - #category : #'Spec2-PolyWidgets-Labelled' + #superclass : #SpLabelledListPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #'api-shortcuts' } -SpLabelledList >> beMultipleSelection [ - ^ self list beMultipleSelection -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> displayBlock: aBlock [ - ^self list displayBlock: aBlock -] - -{ #category : #initialization } -SpLabelledList >> initializeWidgets [ -super initializeWidgets. - self content: SpListPresenter -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> items: aList [ - ^ self list items: aList -] - -{ #category : #accessing } -SpLabelledList >> list [ - ^ self subwidget -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> listSize [ - ^ self list listSize -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> selectAll [ - ^ self list selectAll -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> selectedItem [ - ^ self list selectedItem -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> selectedItems [ - ^ self list selectedItems -] - -{ #category : #'api-shortcuts' } -SpLabelledList >> sortingBlock: aBlock [ - ^self list sortingBlock: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledList >> whenSelectedItemChanged: aBlock [ -self list whenSelectedItemChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledList >> whenSelectionChanged: aBlock [ - self list whenSelectionChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledList >> whenSelectionIndexChanged: aBlock [ - self list whenSelectionIndexChanged: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpLabelledListPresenter.class.st b/src/Spec2-PolyWidgets/SpLabelledListPresenter.class.st new file mode 100644 index 00000000000..2471c9c2f13 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpLabelledListPresenter.class.st @@ -0,0 +1,81 @@ +" +I am a LabelledContainer specialized to manage a ListPresenter. +See LabelledContainer + +self example + +I provide the accessor list to be more intuitive than subwidget. + +I provide shortcuts for the most common methods of the list api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. +" +Class { + #name : #SpLabelledListPresenter, + #superclass : #SpLabelledContainerPrestenter, + #category : #'Spec2-PolyWidgets-Labelled' +} + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> beMultipleSelection [ + ^ self list beMultipleSelection +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> displayBlock: aBlock [ + ^self list displayBlock: aBlock +] + +{ #category : #initialization } +SpLabelledListPresenter >> initializeWidgets [ +super initializeWidgets. + self content: SpListPresenter +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> items: aList [ + ^ self list items: aList +] + +{ #category : #accessing } +SpLabelledListPresenter >> list [ + ^ self subwidget +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> listSize [ + ^ self list listSize +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> selectAll [ + ^ self list selectAll +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> selectedItem [ + ^ self list selectedItem +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> selectedItems [ + ^ self list selectedItems +] + +{ #category : #'api-shortcuts' } +SpLabelledListPresenter >> sortingBlock: aBlock [ + ^self list sortingBlock: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledListPresenter >> whenSelectedItemChanged: aBlock [ +self list whenSelectedItemChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledListPresenter >> whenSelectionChanged: aBlock [ + self list whenSelectionChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledListPresenter >> whenSelectionIndexChanged: aBlock [ + self list whenSelectionIndexChanged: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpLabelledPresenter.class.st b/src/Spec2-PolyWidgets/SpLabelledPresenter.class.st index 27a85eb8eb3..fa0e1f1e467 100644 --- a/src/Spec2-PolyWidgets/SpLabelledPresenter.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledPresenter.class.st @@ -1,12 +1,9 @@ " -Description --------------------- - A LabelledPresenter is a simple presenter to display an input with a label and optionnaly a description. -Example: +self example. - self instantiate: (LabelledPresenter label: 'Email' input: self newTextInput description: 'Email adress to use to send activation and informations emails.') + " Class { #name : #SpLabelledPresenter, @@ -30,6 +27,18 @@ SpLabelledPresenter class >> defaultSpec [ yourself ] +{ #category : #specs } +SpLabelledPresenter class >> example [ + | inputPresenter | + inputPresenter := SpTextInputFieldPresenter new. + (SpLabelledPresenter + label: 'Email' + input: inputPresenter + description: 'Email adress to use to send activation and informations emails.') + openWithSpec + +] + { #category : #'instance creation' } SpLabelledPresenter class >> label: aString input: aPresenter [ ^ self label: aString input: aPresenter description: nil diff --git a/src/Spec2-PolyWidgets/SpLabelledSliderInput.class.st b/src/Spec2-PolyWidgets/SpLabelledSliderInput.class.st index 20474579407..468f29f3315 100644 --- a/src/Spec2-PolyWidgets/SpLabelledSliderInput.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledSliderInput.class.st @@ -1,81 +1,5 @@ -" -I am a LabelledContainer specialized to manage a SliderInput. -See LabelledContainer - -self example - -I provide the accessors sliderInput to be more intuitive than subwidget, and the shortcuts input and slider. - -I provide shortcuts for the most common methods to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. -" Class { #name : #SpLabelledSliderInput, - #superclass : #SpLabelledContainer, - #category : #'Spec2-PolyWidgets-Labelled' + #superclass : #SpLabelledSliderInputPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> absoluteValue [ - ^ self sliderInput absoluteValue -] - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> absoluteValue: aBoolean [ - ^ self sliderInput absoluteValue: aBoolean -] - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> autoAccept [ - ^ self sliderInput autoAccept -] - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> autoAccept: aBoolean [ - ^ self sliderInput autoAccept: aBoolean -] - -{ #category : #initialization } -SpLabelledSliderInput >> initializeWidgets [ - super initializeWidgets. - self content: SpSliderInput -] - -{ #category : #accessing } -SpLabelledSliderInput >> input [ - ^ subwidget input -] - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> max: aNumber [ - ^ self sliderInput max: aNumber -] - -{ #category : #'api-shortcuts' } -SpLabelledSliderInput >> min: aNumber [ - ^ self sliderInput min: aNumber -] - -{ #category : #accessing } -SpLabelledSliderInput >> slider [ - ^ subwidget slider -] - -{ #category : #accessing } -SpLabelledSliderInput >> sliderInput [ - ^ subwidget -] - -{ #category : #accessing } -SpLabelledSliderInput >> value [ - ^ self sliderInput value -] - -{ #category : #accessing } -SpLabelledSliderInput >> value: aNumber [ - ^ self sliderInput value: aNumber -] - -{ #category : #'api-events' } -SpLabelledSliderInput >> whenValueChangedDo: aBlock [ - self sliderInput whenValueChangedDo: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpLabelledSliderInputPresenter.class.st b/src/Spec2-PolyWidgets/SpLabelledSliderInputPresenter.class.st new file mode 100644 index 00000000000..98a98772f25 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpLabelledSliderInputPresenter.class.st @@ -0,0 +1,81 @@ +" +I am a LabelledContainer specialized to manage a SliderInput. +See LabelledContainer + +self example + +I provide the accessors sliderInput to be more intuitive than subwidget, and the shortcuts input and slider. + +I provide shortcuts for the most common methods to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. +" +Class { + #name : #SpLabelledSliderInputPresenter, + #superclass : #SpLabelledContainerPrestenter, + #category : #'Spec2-PolyWidgets-Labelled' +} + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> absoluteValue [ + ^ self sliderInput absoluteValue +] + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> absoluteValue: aBoolean [ + ^ self sliderInput absoluteValue: aBoolean +] + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> autoAccept [ + ^ self sliderInput autoAccept +] + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> autoAccept: aBoolean [ + ^ self sliderInput autoAccept: aBoolean +] + +{ #category : #initialization } +SpLabelledSliderInputPresenter >> initializeWidgets [ + super initializeWidgets. + self content: SpSliderInputPresenter +] + +{ #category : #accessing } +SpLabelledSliderInputPresenter >> input [ + ^ subwidget input +] + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> max: aNumber [ + ^ self sliderInput max: aNumber +] + +{ #category : #'api-shortcuts' } +SpLabelledSliderInputPresenter >> min: aNumber [ + ^ self sliderInput min: aNumber +] + +{ #category : #accessing } +SpLabelledSliderInputPresenter >> slider [ + ^ subwidget slider +] + +{ #category : #accessing } +SpLabelledSliderInputPresenter >> sliderInput [ + ^ subwidget +] + +{ #category : #accessing } +SpLabelledSliderInputPresenter >> value [ + ^ self sliderInput value +] + +{ #category : #accessing } +SpLabelledSliderInputPresenter >> value: aNumber [ + ^ self sliderInput value: aNumber +] + +{ #category : #'api-events' } +SpLabelledSliderInputPresenter >> whenValueChangedDo: aBlock [ + self sliderInput whenValueChangedDo: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpLabelledTextInput.class.st b/src/Spec2-PolyWidgets/SpLabelledTextInput.class.st index b05a16fe98a..bb3f568c964 100644 --- a/src/Spec2-PolyWidgets/SpLabelledTextInput.class.st +++ b/src/Spec2-PolyWidgets/SpLabelledTextInput.class.st @@ -1,96 +1,5 @@ -" -I am a LabelledContainer specialized to manage a TextInputFieldPresenter. -See LabelledContainer - -self example - -I provide the accessor input to be more intuitive than subwidget. - -I provide shortcuts for the most common methods of the TextInputFieldPresenter api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. -" Class { #name : #SpLabelledTextInput, - #superclass : #SpLabelledContainer, - #category : #'Spec2-PolyWidgets-Labelled' + #superclass : #SpLabelledTextInputPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #specs } -SpLabelledTextInput class >> defaultSpec [ - ^ self labelLeft -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> acceptBlock: aBlockWithOneArgument [ - ^ self input acceptBlock: aBlockWithOneArgument -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> acceptOnCR: aBoolean [ - ^ self input acceptOnCR: aBoolean -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> autoAccept: aBoolean [ - ^ self input autoAccept: aBoolean -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> beEncrypted [ - ^ self input beEncrypted -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> encrypted: aBoolean [ - ^self input encrypted: aBoolean -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> entryCompletion: anEntryCompletion [ - ^self input entryCompletion: anEntryCompletion -] - -{ #category : #initialization } -SpLabelledTextInput >> initializeWidgets [ - super initializeWidgets. - self content: SpTextInputFieldPresenter. -] - -{ #category : #accessing } -SpLabelledTextInput >> input [ - ^ self subwidget -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> placeholder: aText [ - ^ self input placeholder: aText -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> removeEntryCompletion [ - ^self input removeEntryCompletion -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> selectAll [ - ^self input selectAll -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> text [ - ^self input text -] - -{ #category : #'api-shortcuts' } -SpLabelledTextInput >> text: aText [ - self input text: aText -] - -{ #category : #'events-shortcuts' } -SpLabelledTextInput >> whenTextChanged: aBlock [ - self input whenTextChanged: aBlock -] - -{ #category : #'events-shortcuts' } -SpLabelledTextInput >> whenTextIsAccepted: aBlock [ - self input whenTextIsAccepted: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpLabelledTextInputPresenter.class.st b/src/Spec2-PolyWidgets/SpLabelledTextInputPresenter.class.st new file mode 100644 index 00000000000..be187305d67 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpLabelledTextInputPresenter.class.st @@ -0,0 +1,96 @@ +" +I am a LabelledContainer specialized to manage a TextInputFieldPresenter. +See LabelledContainer + +self example + +I provide the accessor input to be more intuitive than subwidget. + +I provide shortcuts for the most common methods of the TextInputFieldPresenter api to avoid the use of the DoesNotUnderstand or the writing of long chain of accessors. +" +Class { + #name : #SpLabelledTextInputPresenter, + #superclass : #SpLabelledContainerPrestenter, + #category : #'Spec2-PolyWidgets-Labelled' +} + +{ #category : #specs } +SpLabelledTextInputPresenter class >> defaultSpec [ + ^ self labelLeft +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> acceptBlock: aBlockWithOneArgument [ + ^ self input acceptBlock: aBlockWithOneArgument +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> acceptOnCR: aBoolean [ + ^ self input acceptOnCR: aBoolean +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> autoAccept: aBoolean [ + ^ self input autoAccept: aBoolean +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> beEncrypted [ + ^ self input beEncrypted +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> encrypted: aBoolean [ + ^self input encrypted: aBoolean +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> entryCompletion: anEntryCompletion [ + ^self input entryCompletion: anEntryCompletion +] + +{ #category : #initialization } +SpLabelledTextInputPresenter >> initializeWidgets [ + super initializeWidgets. + self content: SpTextInputFieldPresenter. +] + +{ #category : #accessing } +SpLabelledTextInputPresenter >> input [ + ^ self subwidget +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> placeholder: aText [ + ^ self input placeholder: aText +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> removeEntryCompletion [ + ^self input removeEntryCompletion +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> selectAll [ + ^self input selectAll +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> text [ + ^self input text +] + +{ #category : #'api-shortcuts' } +SpLabelledTextInputPresenter >> text: aText [ + self input text: aText +] + +{ #category : #'events-shortcuts' } +SpLabelledTextInputPresenter >> whenTextChanged: aBlock [ + self input whenTextChanged: aBlock +] + +{ #category : #'events-shortcuts' } +SpLabelledTextInputPresenter >> whenTextIsAccepted: aBlock [ + self input whenTextIsAccepted: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpRGBSliders.class.st b/src/Spec2-PolyWidgets/SpRGBSliders.class.st index 0527977c69e..25b72bdc3cf 100644 --- a/src/Spec2-PolyWidgets/SpRGBSliders.class.st +++ b/src/Spec2-PolyWidgets/SpRGBSliders.class.st @@ -3,7 +3,7 @@ I am an elementary Spec widget allowing a user to choose a Color by its RGB valu self example -I manage three SliderInput. +I manage three SliderInputs. I set their min at 0 and their max at 255. I provide the methods color that calculate the Color obtains with the current value of the sliders. @@ -36,10 +36,10 @@ SpRGBSliders >> blueSlider [ { #category : #accessing } SpRGBSliders >> color [ ^ (Color - r: redSlider value - g: greenSlider value - b: blueSlider value - range: 255) + r: redSlider value + g: greenSlider value + b: blueSlider value + range: 255) ] { #category : #accessing } @@ -49,9 +49,9 @@ SpRGBSliders >> greenSlider [ { #category : #initialization } SpRGBSliders >> initializeWidgets [ - redSlider := self instantiate: SpSliderInput. - greenSlider := self instantiate: SpSliderInput. - blueSlider := self instantiate: SpSliderInput. + redSlider := self instantiate: SpSliderInputPresenter. + greenSlider := self instantiate: SpSliderInputPresenter. + blueSlider := self instantiate: SpSliderInputPresenter. redSlider min: 0; max: 255; label: 'Red' translated. diff --git a/src/Spec2-PolyWidgets/SpRGBWidget.class.st b/src/Spec2-PolyWidgets/SpRGBWidget.class.st index 7e05c9c759f..69ba168636a 100644 --- a/src/Spec2-PolyWidgets/SpRGBWidget.class.st +++ b/src/Spec2-PolyWidgets/SpRGBWidget.class.st @@ -32,7 +32,7 @@ SpRGBWidget class >> defaultSpec [ { #category : #api } SpRGBWidget >> color [ - ^ sliders color + ^ sliders color ] { #category : #initialization } @@ -66,5 +66,5 @@ SpRGBWidget >> sliders [ { #category : #'api-events' } SpRGBWidget >> whenExtentForPreviewChanged: aBlock [ - extentForPreview whenChangedDo: aBlock + extentForPreview whenChangedDo: aBlock ] diff --git a/src/Spec2-PolyWidgets/SpSliderInput.class.st b/src/Spec2-PolyWidgets/SpSliderInput.class.st index 76b035cb09f..0a8099b889d 100644 --- a/src/Spec2-PolyWidgets/SpSliderInput.class.st +++ b/src/Spec2-PolyWidgets/SpSliderInput.class.st @@ -1,144 +1,5 @@ -" -I am an elementary Spec Widget managing a slider and an input. - -Self example - -Between the bounds min and max of the slider, I ensure that the value of the input on the accept and the value of the slider are the same. - -Note -==== -- min and max must be set before use me. -- if autoAccept is true, the character '-' could create problems -" Class { #name : #SpSliderInput, - #superclass : #SpPresenter, - #instVars : [ - 'slider', - 'input' - ], - #category : #'Spec2-PolyWidgets-Elementary' + #superclass : #SpSliderInputPresenter, + #category : #'Spec2-PolyWidgets-ToRemoveBeforerelease' } - -{ #category : #specs } -SpSliderInput class >> defaultSpec [ - ^ self sliderLeft -] - -{ #category : #specs } -SpSliderInput class >> sliderBottom [ - - ^ SpBoxLayout newVertical - add: #input withConstraints: [ :constraints | constraints height: self buttonHeight ]; - add: #slider; - yourself -] - -{ #category : #specs } -SpSliderInput class >> sliderLeft [ - - ^ SpPanedLayout newHorizontal - position: 85 percent; - add: #slider withConstraints: [ :constraints | constraints beNotResizable ]; - add: #input; - yourself -] - -{ #category : #specs } -SpSliderInput class >> sliderRight [ - - ^ SpPanedLayout newHorizontal - position: 15 percent; - add: #input; - add: #slider; - yourself -] - -{ #category : #specs } -SpSliderInput class >> sliderTop [ - - ^ SpBoxLayout newVertical - add: #slider; - add: #input withConstraints: [ :constraints | constraints height: self buttonHeight ]; - yourself -] - -{ #category : #accessing } -SpSliderInput >> autoAccept [ - ^ input autoAccept -] - -{ #category : #accessing } -SpSliderInput >> autoAccept: aBoolean [ - - input autoAccept: aBoolean -] - -{ #category : #initialization } -SpSliderInput >> initializePresenter [ - slider - whenValueChangedDo: [ :sliderValue | - | inputValue | - inputValue := input text asNumber. " ifNotNil: [ :text | text asNumber ]" - sliderValue == inputValue - ifFalse: [ input text: sliderValue asString ] ]. - input - whenTextChangedDo: [ :text | - | inputValue | - inputValue := text asNumber. - slider value == inputValue - ifFalse: [ slider value: inputValue ] ] -] - -{ #category : #initialization } -SpSliderInput >> initializeWidgets [ - slider := self instantiate: SpSliderPresenter. - input := self instantiate: SpTextInputFieldPresenter. - self focusOrder add: input -] - -{ #category : #accessing } -SpSliderInput >> input [ - ^ input -] - -{ #category : #accessing } -SpSliderInput >> label [ - ^ slider label -] - -{ #category : #accessing } -SpSliderInput >> label: aString [ - slider label: aString -] - -{ #category : #accessing } -SpSliderInput >> max: aNumber [ - slider max: aNumber -] - -{ #category : #accessing } -SpSliderInput >> min: aNumber [ - slider min: aNumber. - input text: aNumber asString -] - -{ #category : #accessing } -SpSliderInput >> slider [ - ^ slider -] - -{ #category : #accessing } -SpSliderInput >> value [ - ^ slider value -] - -{ #category : #accessing } -SpSliderInput >> value: aNumber [ - slider value: aNumber -] - -{ #category : #'api-events' } -SpSliderInput >> whenValueChangedDo: aBlock [ - slider whenValueChangedDo: aBlock -] diff --git a/src/Spec2-PolyWidgets/SpSliderInputPresenter.class.st b/src/Spec2-PolyWidgets/SpSliderInputPresenter.class.st new file mode 100644 index 00000000000..3beafd6f193 --- /dev/null +++ b/src/Spec2-PolyWidgets/SpSliderInputPresenter.class.st @@ -0,0 +1,144 @@ +" +I am an elementary Spec Widget managing a slider and an input. + +Self example + +Between the bounds min and max of the slider, I ensure that the value of the input on the accept and the value of the slider are the same. + +Note +==== +- min and max must be set before use me. +- if autoAccept is true, the character '-' could create problems +" +Class { + #name : #SpSliderInputPresenter, + #superclass : #SpPresenter, + #instVars : [ + 'slider', + 'input' + ], + #category : #'Spec2-PolyWidgets-Elementary' +} + +{ #category : #specs } +SpSliderInputPresenter class >> defaultSpec [ + ^ self sliderLeft +] + +{ #category : #specs } +SpSliderInputPresenter class >> sliderBottom [ + + ^ SpBoxLayout newVertical + add: #input withConstraints: [ :constraints | constraints height: self buttonHeight ]; + add: #slider; + yourself +] + +{ #category : #specs } +SpSliderInputPresenter class >> sliderLeft [ + + ^ SpPanedLayout newHorizontal + position: 85 percent; + add: #slider withConstraints: [ :constraints | constraints beNotResizable ]; + add: #input; + yourself +] + +{ #category : #specs } +SpSliderInputPresenter class >> sliderRight [ + + ^ SpPanedLayout newHorizontal + position: 15 percent; + add: #input; + add: #slider; + yourself +] + +{ #category : #specs } +SpSliderInputPresenter class >> sliderTop [ + + ^ SpBoxLayout newVertical + add: #slider; + add: #input withConstraints: [ :constraints | constraints height: self buttonHeight ]; + yourself +] + +{ #category : #accessing } +SpSliderInputPresenter >> autoAccept [ + ^ input autoAccept +] + +{ #category : #accessing } +SpSliderInputPresenter >> autoAccept: aBoolean [ + + input autoAccept: aBoolean +] + +{ #category : #initialization } +SpSliderInputPresenter >> initializePresenter [ + slider + whenValueChangedDo: [ :sliderValue | + | inputValue | + inputValue := input text asNumber. " ifNotNil: [ :text | text asNumber ]" + sliderValue == inputValue + ifFalse: [ input text: sliderValue asString ] ]. + input + whenTextChangedDo: [ :text | + | inputValue | + inputValue := text asNumber. + slider value == inputValue + ifFalse: [ slider value: inputValue ] ] +] + +{ #category : #initialization } +SpSliderInputPresenter >> initializeWidgets [ + slider := self instantiate: SpSliderPresenter. + input := self instantiate: SpTextInputFieldPresenter. + self focusOrder add: input +] + +{ #category : #accessing } +SpSliderInputPresenter >> input [ + ^ input +] + +{ #category : #accessing } +SpSliderInputPresenter >> label [ + ^ slider label +] + +{ #category : #accessing } +SpSliderInputPresenter >> label: aString [ + slider label: aString +] + +{ #category : #accessing } +SpSliderInputPresenter >> max: aNumber [ + slider max: aNumber +] + +{ #category : #accessing } +SpSliderInputPresenter >> min: aNumber [ + slider min: aNumber. + input text: aNumber asString +] + +{ #category : #accessing } +SpSliderInputPresenter >> slider [ + ^ slider +] + +{ #category : #accessing } +SpSliderInputPresenter >> value [ + ^ slider value +] + +{ #category : #accessing } +SpSliderInputPresenter >> value: aNumber [ + slider value: aNumber +] + +{ #category : #'api-events' } +SpSliderInputPresenter >> whenValueChangedDo: aBlock [ + slider whenValueChangedDo: aBlock +] diff --git a/src/Spec2-PolyWidgets/SpToolBarItemPosition.class.st b/src/Spec2-PolyWidgets/SpToolBarItemPosition.class.st index caab8938754..9badffc4958 100644 --- a/src/Spec2-PolyWidgets/SpToolBarItemPosition.class.st +++ b/src/Spec2-PolyWidgets/SpToolBarItemPosition.class.st @@ -1,11 +1,7 @@ " -Abstract superclass for item positioning. Each subclass should only have one instance. +I'm a class responsible for item positioning. My subclass have only have one instance responsible for the different behavior depending on direction. My users should not refer to my subclasses but to myself e.g, -The default item positioning is left. - - ITItemPosition default - ITItemPosition right - ITItemPosition left +SpToolBarItemPosition left or SpToolBarItemPosition right " Class { #name : #SpToolBarItemPosition, diff --git a/src/Spec2-PolyWidgets/SpToolBarItemPositionLeft.class.st b/src/Spec2-PolyWidgets/SpToolBarItemPositionLeft.class.st index eab823a49b3..f214bd3d287 100644 --- a/src/Spec2-PolyWidgets/SpToolBarItemPositionLeft.class.st +++ b/src/Spec2-PolyWidgets/SpToolBarItemPositionLeft.class.st @@ -3,7 +3,7 @@ This class has a single instance representing a left item position. Do not use the class directly, instead use: - ITItemPosition left + SpToolBarItemPosition left " Class { #name : #SpToolBarItemPositionLeft, diff --git a/src/Spec2-PolyWidgets/SpToolBarItemPositionRight.class.st b/src/Spec2-PolyWidgets/SpToolBarItemPositionRight.class.st index 82e219a1ce3..f00f80886d4 100644 --- a/src/Spec2-PolyWidgets/SpToolBarItemPositionRight.class.st +++ b/src/Spec2-PolyWidgets/SpToolBarItemPositionRight.class.st @@ -3,7 +3,7 @@ This class has a single instance representing a right item position. Do not use the class directly, instead use: - ITItemPosition right + SpToolBarItemPosition right " Class { #name : #SpToolBarItemPositionRight, diff --git a/src/Spec2-PolyWidgets/SpToolBarMorph.class.st b/src/Spec2-PolyWidgets/SpToolBarMorph.class.st index 7ff6b9e570b..23bbecdc745 100644 --- a/src/Spec2-PolyWidgets/SpToolBarMorph.class.st +++ b/src/Spec2-PolyWidgets/SpToolBarMorph.class.st @@ -74,7 +74,7 @@ SpToolBarMorph >> addItemRight: aMorph [ yourself) ] -{ #category : #'as yet unclassified' } +{ #category : #addition } SpToolBarMorph >> addItemsFromContext: aContext [ self flag: #TODO.