[squeak-dev] The Inbox: Morphic-ct.1692.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Oct 1 01:27:28 UTC 2020


Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1692.mcz

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

Name: Morphic-ct.1692
Author: ct
Time: 1 October 2020, 3:27:15.197807 am
UUID: 80889aa8-2990-634d-b8f0-b73c6b7f3a02
Ancestors: Morphic-eem.1686

Second version of NewColorPickerMorph rework. Replaces Morphic-ct.1634 which can be moved to the treated inbox.

Changelog:
- Add pick button to NewColorPickerMorph that allows to pick a color from the Display. With this enhancement, NCPM is finally superior to the old ColorPickerMorph and could now replace the latter by the default preferences.
- The color picker keeps live and non-modal; if the picking button is pressed, you can modally choose a color from anywhere on the screen. Press escape, yellow button, or click into the color picker morph to revert to cancel the color picking.
- Make the color picker hi-dpi-sensitive.
- Remove the pixel-costly 'Current selection:' label (it still survives in the balloon text of the color presenter).
- Enable Shout styling in the color expression pane.

Thanks for all your feedback on my first attempt! For the full discussion, see http://forum.world.st/The-Inbox-Morphic-ct-1634-mcz-td5112623.html.

=============== Diff against Morphic-eem.1686 ===============

Item was changed:
  Morph subclass: #NewColorPickerMorph
+ 	instanceVariableNames: 'target setColorSelector hsvaMorph colorPresenter isPicking'
- 	instanceVariableNames: 'target setColorSelector hsvaMorph colorPresenter'
  	classVariableNames: 'UseIt'
  	poolDictionaries: ''
  	category: 'Morphic-Widgets'!
  
  !NewColorPickerMorph commentStamp: 'cmm 12/3/2010 13:36' prior: 0!
  A NewColorPickerMorph is a new widget for choosing colors in Morphic.  Instantiate a NewColorPickerMorph:
  
  	(NewColorPickerMorph
  		on: objectToHaveItsColorSet
  		getColorSelector: itsColorGetterSymbol
  		setColorSelector: itsColorSetterSymbol) openInWorld
  
  !

Item was added:
+ ----- Method: NewColorPickerMorph>>aboutToStyle:requestor: (in category 'styling') -----
+ aboutToStyle: styler requestor: requestor
+ 
+ 	^ true!

Item was changed:
+ ----- Method: NewColorPickerMorph>>closeButtonLabel (in category 'accessing - labels') -----
- ----- Method: NewColorPickerMorph>>closeButtonLabel (in category 'initialize-release') -----
  closeButtonLabel
  	^ 'Close' translated!

Item was added:
+ ----- Method: NewColorPickerMorph>>colorPresenterLabel (in category 'accessing - labels') -----
+ colorPresenterLabel
+ 
+ 	^ 'Current selection' translated!

Item was changed:
  ----- Method: NewColorPickerMorph>>initialize (in category 'initialize-release') -----
  initialize
+ 
  	super initialize.
+ 	isPicking := false.
+ 	self initializeHsvaMorph.!
- 	self initializeHsvaMorph!

Item was added:
+ ----- Method: NewColorPickerMorph>>isPicking (in category 'accessing') -----
+ isPicking
+ 
+ 	^ isPicking!

Item was added:
+ ----- Method: NewColorPickerMorph>>isPicking: (in category 'picking') -----
+ isPicking: aBoolean
+ 
+ 	isPicking := aBoolean.
+ 	self changed: #isPicking.
+ 	aBoolean ifTrue: [self pickColor].!

Item was changed:
  ----- Method: NewColorPickerMorph>>newBottomRow (in category 'initialize-release') -----
  newBottomRow
+ 
  	^ Morph new
+ 		color: Color transparent;
+ 		changeTableLayout;
+ 		listDirection: #leftToRight;
+ 		hResizing: #spaceFill; vResizing: #shrinkWrap;
+ 		height: Preferences standardButtonFont height * 1.5;
+ 		cellGap: 4;
+ 		addMorphBack: self newPickButton;
+ 		addMorphBack: self newColorPresenterMorph;
+ 		addMorphBack: self newCloseButton;
+ 		yourself!
- 		 color: Color transparent ;
- 		 changeTableLayout ;
- 		 listDirection: #leftToRight ;
- 		 hResizing: #spaceFill; vResizing: #shrinkWrap ;
- 		 height: 20 ;
- 		 cellGap: 4 ;
- 		 addMorph: (StringMorph contents: 'Current selection:' translated) ;
- 		 addMorphBack: self newColorPresenterMorph ;
- 		 addMorphBack: self newCloseButton!

Item was changed:
  ----- Method: NewColorPickerMorph>>newCloseButton (in category 'initialize-release') -----
  newCloseButton
+ 
  	^ (PluggableButtonMorph
  		on: self
  		getState: nil
  		action: #delete
  		label: #closeButtonLabel)
+ 			vResizing: #spaceFill;
+ 			hResizing: #spaceFill;
+ 			yourself!
- 		 vResizing: #spaceFill ;
- 		hResizing: #spaceFill;
- 		 yourself!

Item was changed:
  ----- Method: NewColorPickerMorph>>newColorExpressionMorph (in category 'initialize-release') -----
  newColorExpressionMorph
+ 
  	| inputField builder |
  	builder := ToolBuilder default.
+ 	inputField := builder build: (builder pluggableInputFieldSpec new
- 	inputField := (builder build: (builder pluggableInputFieldSpec new
  		model: self;
  		getText: #colorExpression;
+ 		setText: #colorExpression:).
- 		setText: #colorExpression:)).
  	inputField
+ 		hResizing: #spaceFill;
+ 		vResizing: #rigid;
+ 		height: Preferences standardButtonFont height * 1.5;
+ 		useDefaultStyler.
+ 	self changed: #colorExpression. "Necessary to trigger the styler"
- 		 hResizing: #spaceFill ;
- 		 vResizing: #rigid ;
- 		 height: (Preferences standardDefaultTextFont height * 3/2).
  	^ inputField!

Item was changed:
  ----- Method: NewColorPickerMorph>>newColorPresenterMorph (in category 'initialize-release') -----
  newColorPresenterMorph
+ 
  	^ (ColorPresenterMorph
  		on: hsvaMorph
  		color: #selectedColor)
+ 			vResizing: #spaceFill;
+ 			hResizing: #spaceFill;
+ 			balloonText: self colorPresenterLabel;
+ 		 	yourself!
- 		 vResizing: #rigid ; height: 20 ;
- 		 hResizing: #spaceFill ;
- 		 yourself!

Item was added:
+ ----- Method: NewColorPickerMorph>>newPickButton (in category 'initialize-release') -----
+ newPickButton
+ 
+ 	^ (PluggableButtonMorph
+ 		on: self
+ 		getState: #isPicking
+ 		action: #togglePicking
+ 		label: #pickingButtonLabel)
+ 			vResizing: #spaceFill;
+ 			hResizing: #spaceFill;
+ 			yourself!

Item was added:
+ ----- Method: NewColorPickerMorph>>pickColor (in category 'picking') -----
+ pickColor
+ 	
+ 	| selectedColor |
+ 	[
+ 		| previousColor |
+ 		previousColor := self selectedColor.
+ 		selectedColor := self pickColorFromDisplay.
+ 		selectedColor ifNil: [^ self selectedColor: previousColor].
+ 	] ensure: [
+ 		self isPicking: false].
+ 	self selectedColor: selectedColor.!

Item was added:
+ ----- Method: NewColorPickerMorph>>pickColorFromDisplay (in category 'picking') -----
+ pickColorFromDisplay
+ 
+ 	Cursor target showWhile: [
+ 		| previousColor |
+ 		previousColor := self selectedColor.
+ 		[Sensor anyButtonPressed]
+ 			whileTrue;
+ 			whileFalse: [
+ 				| frontMorph |
+ 				Sensor peekKeyboard = Character escape ifTrue: [
+ 					^ nil].
+ 				frontMorph := (self currentWorld morphsAt: Sensor cursorPoint) at: 1 ifAbsent: [nil].
+ 				self selectedColor: ((frontMorph isNil or: [(frontMorph == self or: [frontMorph hasOwner: self]) not])
+ 					ifTrue: [Display colorAt: Sensor cursorPoint]
+ 					ifFalse: [previousColor]).
+ 				self world runStepMethods; displayWorldSafely]].
+ 	Sensor yellowButtonPressed
+ 		ifTrue: [^ nil].
+ 	^ self selectedColor!

Item was added:
+ ----- Method: NewColorPickerMorph>>pickingButtonLabel (in category 'accessing - labels') -----
+ pickingButtonLabel
+ 
+ 	^ 'Picking' translated!

Item was changed:
  ----- Method: NewColorPickerMorph>>setup (in category 'initialize-release') -----
  setup
+ 
  	self
+ 		color: Color white darker;
+ 		cornerStyle: #rounded;
+ 		changeTableLayout;
+ 		hResizing: #shrinkWrap;
+ 		vResizing: #shrinkWrap;
+ 		extent: (240 @ 240) * RealEstateAgent scaleFactor;
+ 		addMorphBack: hsvaMorph;
+ 		addMorphBack: self newColorExpressionMorph;
+ 		addMorphBack: self newBottomRow;
+ 		layoutInset: 4;
+ 		cellGap: 2.
+ 	
+ 	Preferences menuAppearance3d
+ 		ifTrue: [self addDropShadow].!
- 		 color: (Color white darker) ;
- 		 cornerStyle: #rounded ;
- 		 changeTableLayout ;
- 		 hResizing: #shrinkWrap ;
- 		 vResizing: #shrinkWrap ;
- 		 extent: 240 at 240 ;
- 		 addMorphBack: hsvaMorph ;
- 		 addMorphBack: self newColorExpressionMorph ;
- 		 addMorphBack: self newBottomRow ;
- 		 layoutInset: 4 ;
- 		 cellGap: 2.
- 		
- 		Preferences menuAppearance3d
- 		ifTrue: [self addDropShadow].
- 	!

Item was changed:
  ----- Method: NewColorPickerMorph>>setupForProperties (in category 'initialize-release') -----
  setupForProperties
+ 
  	self
+ 		color: Color white darker;
+ 		changeTableLayout;
+ 		hResizing: #shrinkWrap;
+ 		vResizing: #shrinkWrap;
+ 		extent: 240 at 240;
+ 		addMorphBack: hsvaMorph;
+ 		layoutInset: 4;
+ 		cellGap: 2.!
- 		 color: (Color white darker) ;
- 		 changeTableLayout ;
- 		 hResizing: #shrinkWrap ;
- 		 vResizing: #shrinkWrap ;
- 		 extent: 240 at 240 ;
- 		 addMorphBack: hsvaMorph ;
- 		 layoutInset: 4 ;
- 		 cellGap: 2.!

Item was added:
+ ----- Method: NewColorPickerMorph>>togglePicking (in category 'picking') -----
+ togglePicking
+ 	self isPicking: self isPicking not!



More information about the Squeak-dev mailing list