The Trunk: PreferenceBrowser-mt.55.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: PreferenceBrowser-mt.55.mcz

commits-2
Marcel Taeumel uploaded a new version of PreferenceBrowser to project The Trunk:
http://source.squeak.org/trunk/PreferenceBrowser-mt.55.mcz

==================== Summary ====================

Name: PreferenceBrowser-mt.55
Author: mt
Time: 28 August 2015, 10:39:02.545 am
UUID: 7a5295ca-614d-3a44-b69e-c8a9b69ec92b
Ancestors: PreferenceBrowser-mt.54

Adds color preference views (moved from EToys package).

=============== Diff against PreferenceBrowser-mt.54 ===============

Item was added:
+ PBPreferenceView subclass: #PBColorPreferenceView
+ instanceVariableNames: 'button'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'PreferenceBrowser'!

Item was added:
+ ----- Method: PBColorPreferenceView class>>initialize (in category 'class initialization') -----
+ initialize
+ PreferenceViewRegistry ofColorPreferences register: self.!

Item was added:
+ ----- Method: PBColorPreferenceView class>>unload (in category 'class initialization') -----
+ unload
+ "Unload order is not guaranteed so guard against failure"
+ [PreferenceViewRegistry ofColorPreferences unregister: self] on: Error do:[]!

Item was added:
+ ----- Method: PBColorPreferenceView>>adjustLabelColor (in category 'user interface') -----
+ adjustLabelColor
+ | textColor |
+ (self preference preferenceValue luminance < 0.5)
+ ifTrue:[ textColor := Color white]
+ ifFalse:[ textColor := Color black].
+ button allMorphsDo: [:m | (m isKindOf: StringMorph) ifTrue: [ m color: textColor]]. !

Item was added:
+ ----- Method: PBColorPreferenceView>>borderStyleMenu (in category 'user interface') -----
+ borderStyleMenu
+ "Add border-style menu items"
+
+ |  aMenu |
+ aMenu := MenuMorph new defaultTarget: self.
+
+ aMenu addStayUpItemSpecial.
+ aMenu add: 'border color...' translated target: self selector:#changeColor: argument: button.
+ aMenu addLine.
+ BorderStyle borderStyleChoices do:
+ [:sym | (aMenu borderStyleForSymbol: sym)
+ ifNotNil:
+ [aMenu add: sym translated target: self selector: #setBorderStyle: argument: sym]].
+ ^aMenu openNear: ActiveHand bounds.
+ !

Item was added:
+ ----- Method: PBColorPreferenceView>>changeColor: (in category 'user interface') -----
+ changeColor: aButton
+ aButton changeColor.
+ self preference preferenceValue: aButton fillStyle.
+ button label: self preference preferenceValue asString.
+ self adjustLabelColor !

Item was added:
+ ----- Method: PBColorPreferenceView>>colorMenuButton (in category 'user interface') -----
+ colorMenuButton
+ | selector name |
+ name := self preference name.
+ (name includesSubstring: 'border' caseSensitive: false)
+ ifTrue: [ selector := #borderStyleMenu]
+ ifFalse:[ selector := #fillStyleMenu].
+ button := SimpleButtonMorph new
+ label: self preference preferenceValue asString;
+ actionSelector: selector;
+ target: self.
+ name = #menuBorderColor
+ ifTrue:[ ^button borderColor: MenuMorph menuBorderColor; borderWidth: MenuMorph menuBorderWidth].
+ name = #menuTitleBorderColor
+ ifTrue:[ ^button borderColor: MenuMorph menuTitleBorderColor; borderWidth: MenuMorph menuTitleBorderWidth].
+ self adjustLabelColor.
+ ^button color: self preference preferenceValue
+
+
+ "UpdatingRectangleMorph new
+ target: self preference;
+ getSelector: #preferenceValue;
+ putSelector: #preferenceValue:;
+ extent: 22@22;
+ setBalloonText: 'click here to change the color' translated;
+ yourself."!

Item was added:
+ ----- Method: PBColorPreferenceView>>colorSwatch (in category 'user interface') -----
+ colorSwatch
+ ^UpdatingRectangleMorph new
+ target: self preference;
+ getSelector: #preferenceValue;
+ putSelector: #preferenceValue:;
+ extent: 22@22;
+ setBalloonText: 'click here to change the color' translated;
+ yourself.!

Item was added:
+ ----- Method: PBColorPreferenceView>>fillStyleMenu (in category 'user interface') -----
+ fillStyleMenu
+ "Add the items for changing the current fill style of the Morph"
+ |  aMenu |
+ "self canHaveFillStyles ifFalse:[^aMenu add: 'change color...' translated target: self action: #changeColor]."
+ aMenu := MenuMorph new defaultTarget: self.
+ "self preference preferenceValue addFillStyleMenuItems: aMenu hand: nil from: self."
+ aMenu add: 'change color...' translated target: self selector:#changeColor: argument: button.
+ aMenu addLine.
+ aMenu add: 'solid fill' translated action: #useSolidFill.
+ "aMenu add: 'gradient fill' translated action: #useGradientFill.
+ aMenu add: 'bitmap fill' translated action: #useBitmapFill.
+ aMenu add: 'default fill' translated action: #useDefaultFill."
+ ^aMenu openNear: ActiveHand bounds.
+ !

Item was added:
+ ----- Method: PBColorPreferenceView>>representativeButtonWithColor:inPanel: (in category 'user interface') -----
+ representativeButtonWithColor: aColor inPanel: aPreferenceBrowser
+ ^self horizontalPanel
+ layoutInset: 2;
+ color: aColor;
+ cellInset: 20;
+ cellPositioning: #center;
+ addMorphBack: (StringMorph contents: self preference name);
+ addMorphBack: self horizontalFiller;
+ addMorphBack: self colorMenuButton;
+ yourself!

Item was added:
+ ----- Method: PBColorPreferenceView>>setBorderStyle: (in category 'user interface') -----
+ setBorderStyle: aBorderStyle
+ self preference name = #menuBorderColor
+ ifTrue: [button color: MenuMorph menuColor;
+ borderWidth: MenuMorph menuBorderWidth].
+ self preference name = #menuTitleBorderColor
+ ifTrue: [button color: MenuMorph menuTitleColor;
+ borderWidth: MenuMorph menuTitleBorderWidth].
+ self preference preferenceValue: aBorderStyle.
+ button label: self preference preferenceValue asString;
+ borderColor: aBorderStyle.
+ !

Item was added:
+ ----- Method: PBColorPreferenceView>>useGradientFill (in category 'user interface') -----
+ useGradientFill
+
+ "Make receiver use a solid fill style (e.g., a simple color)"
+
+
+ | color1 color2 fill |
+ self preference preferenceValue isGradientFill ifTrue:[^self]. "Already done"
+ color1 := Color white darker.
+ color2 := self preference preferenceValue asColor.
+ fill := GradientFillStyle ramp: {0.0 -> color1. 1.0 -> color2}.
+ fill origin: ActiveWorld topLeft.
+ fill direction: 0 @ ActiveWorld bounds extent y.
+ fill normal: ActiveWorld bounds extent x @ 0.
+ fill radial: false.
+ self preference preferenceValue: fill.
+ button label: self preference preferenceValue asString;
+ color: self preference preferenceValue!

Item was added:
+ ----- Method: PBColorPreferenceView>>useSolidFill (in category 'user interface') -----
+ useSolidFill
+ "Make receiver use a solid fill style (e.g., a simple color)"
+ self preference preferenceValue isSolidFill ifTrue:[^self]. "Already done"
+ self preference preferenceValue: self preference preferenceValue asColor. "Try minimizing changes"
+
+ button label: self preference preferenceValue asString;
+ color: self preference preferenceValue
+ !

Item was added:
+ PBColorPreferenceView subclass: #PBWindowColorPreferenceView
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'PreferenceBrowser'!

Item was added:
+ ----- Method: PBWindowColorPreferenceView class>>initialize (in category 'class initialization') -----
+ initialize
+ self viewRegistry register: self.!

Item was added:
+ ----- Method: PBWindowColorPreferenceView class>>unload (in category 'class initialization') -----
+ unload
+ "Unload order is not guaranteed so guard against failure"
+ [self viewRegistry unregister: self] on: Error do:[]!

Item was added:
+ ----- Method: PBWindowColorPreferenceView class>>viewRegistry (in category 'class initialization') -----
+ viewRegistry
+ ^(PreferenceViewRegistry registryOf: #windowColorPreferences)
+ viewOrder: 6;
+ yourself.!

Item was added:
+ ----- Method: PBWindowColorPreferenceView>>initialize (in category 'initialization') -----
+ initialize
+ super initialize.
+ self addActionTitled: 'Bright' target: Preferences selector: #installBrightWindowColors arguments: {} balloonText: 'Use standard bright colors for all windows' translated.
+ self addActionTitled: 'Pastel' target: Preferences selector: #installPastelWindowColors arguments: {} balloonText: 'Use standard pastel colors for all windows' translated.
+ self addActionTitled: 'Gray' target: Preferences selector: #installUniformWindowColors arguments: {} balloonText: 'Use gray backgrounds for all standard windows' translated.!