diff --git a/src/NewTools-SettingsBrowser/Color.extension.st b/src/NewTools-SettingsBrowser/Color.extension.st index 4f9754c7..5e4e0e41 100644 --- a/src/NewTools-SettingsBrowser/Color.extension.st +++ b/src/NewTools-SettingsBrowser/Color.extension.st @@ -3,8 +3,19 @@ Extension { #name : 'Color' } { #category : '*NewTools-SettingsBrowser' } Color >> asSettingPresenter: aSettingDeclaration [ - ^ (StSettingSHStyleButtonColorPresenterItem on: aSettingDeclaration) - buttonAction: [ aSettingDeclaration getColor ]; - whenColorChangedDo: [ self updateColor: aSettingDeclaration color ]; + | settingPresenter colorValue | + + colorValue := aSettingDeclaration targetSelector + ifNil: [ aSettingDeclaration realTarget perform: aSettingDeclaration name ] + ifNotNil: [ + | settingsTarget | + settingsTarget := aSettingDeclaration realTarget perform: aSettingDeclaration targetSelector. + settingsTarget perform: aSettingDeclaration getSelector ]. + + settingPresenter := (SpPresenter new instantiate: StSettingSHStyleButtonColorPresenterItem on: aSettingDeclaration). + settingPresenter + buttonAction: [ aSettingDeclaration getColorFor: settingPresenter ]; + buttonColor: colorValue; yourself. + ^ settingPresenter ] diff --git a/src/NewTools-SettingsBrowser/SettingDeclaration.extension.st b/src/NewTools-SettingsBrowser/SettingDeclaration.extension.st index c0b53640..136f1222 100644 --- a/src/NewTools-SettingsBrowser/SettingDeclaration.extension.st +++ b/src/NewTools-SettingsBrowser/SettingDeclaration.extension.st @@ -10,21 +10,23 @@ SettingDeclaration >> asSettingPresenter [ ] { #category : '*NewTools-SettingsBrowser' } -SettingDeclaration >> getColor [ +SettingDeclaration >> getColorFor: aPresenter [ - (SpPresenter new instantiate: SpColorPickerWindow on: self) - whenColorChangedDo: [ : c | + | colorPickerPresenter | + + colorPickerPresenter := aPresenter instantiate: SpColorPickerWindow on: self. + colorPickerPresenter + whenChangedDo: [ : c | | changedAspect | "First we need to get the setter selector, then apply it" "Some settings are built 'customized' configuring its setter in a different way than using #targetSelector (see #customSettingsOn:)" self targetSelector ifNil: [ - self realTarget perform: self name asMutator with: c. + self realTarget perform: self name asMutator with: c value. changedAspect := self realTarget ] ifNotNil: [ changedAspect := self realTarget perform: self targetSelector. - changedAspect perform: self setSelector with: c. ]. - - self announcer announce: (StSettingsChanged new aspect: changedAspect value: c) ]; + changedAspect perform: self setSelector with: c value. ]. + aPresenter updateColor: c value ]; open ] diff --git a/src/NewTools-SettingsBrowser/StSettingSHStyleButtonColorPresenterItem.class.st b/src/NewTools-SettingsBrowser/StSettingSHStyleButtonColorPresenterItem.class.st index f5c95ab9..85ab0b6f 100644 --- a/src/NewTools-SettingsBrowser/StSettingSHStyleButtonColorPresenterItem.class.st +++ b/src/NewTools-SettingsBrowser/StSettingSHStyleButtonColorPresenterItem.class.st @@ -15,16 +15,5 @@ StSettingSHStyleButtonColorPresenterItem >> buttonColor: aColor [ { #category : 'initialization' } StSettingSHStyleButtonColorPresenterItem >> updateColor: aColor [ -] - -{ #category : 'enumerating' } -StSettingSHStyleButtonColorPresenterItem >> whenColorChangedDo: aBlock [ - "Inform when presenter has been displayed. - `aBlock` receives one argument - - an announcement (instance of `SpWidgetDisplayed`)" - - self announcer - when: StSettingsChanged - do: aBlock - for: aBlock receiver + self buttonColor: aColor. ] diff --git a/src/NewTools-SettingsBrowser/StSettingSectionPresenter.class.st b/src/NewTools-SettingsBrowser/StSettingSectionPresenter.class.st index ec35eb6b..c78bfe05 100644 --- a/src/NewTools-SettingsBrowser/StSettingSectionPresenter.class.st +++ b/src/NewTools-SettingsBrowser/StSettingSectionPresenter.class.st @@ -28,10 +28,3 @@ StSettingSectionPresenter >> defaultLayout [ yourself); yourself ] - -{ #category : 'initialization' } -StSettingSectionPresenter >> initializePresenters [ - - super initializePresenters. - self layout: self defaultLayout. -] diff --git a/src/NewTools-SettingsBrowser/StSettingsChanged.class.st b/src/NewTools-SettingsBrowser/StSettingsChanged.class.st index 4e35c32b..c02296d9 100644 --- a/src/NewTools-SettingsBrowser/StSettingsChanged.class.st +++ b/src/NewTools-SettingsBrowser/StSettingsChanged.class.st @@ -16,3 +16,9 @@ StSettingsChanged >> aspect: aThemeSettings value: aColor [ setting := aThemeSettings. value := aColor. ] + +{ #category : 'evaluating' } +StSettingsChanged >> value [ + + ^ value +]