The Trunk: Morphic-mt.1731.mcz

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

The Trunk: Morphic-mt.1731.mcz

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

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

Name: Morphic-mt.1731
Author: mt
Time: 2 March 2021, 11:44:21.476687 am
UUID: d06129c7-0def-1645-9066-c8a5720bf5d2
Ancestors: Morphic-mt.1730

Adds the possibility to handle #ownerChanged through composition (instead of subclassing/overwriting). Note that #cull: also works with symbols and message sends, not just blocks. :-) Got inspired by #eventHandler and how #mouseDown: (etc.) is implemented in Morph.

Use it to extract Etoys-specific background morph and grid.

=============== Diff against Morphic-mt.1730 ===============

Item was changed:
+ ----- Method: Morph>>ownerChanged (in category 'layout') -----
- ----- Method: Morph>>ownerChanged (in category 'change reporting') -----
  ownerChanged
  "This morph's owner has changed its geometry and is about to update its layout. This is a simple layout hook to update this morph's geometry according to its owner.
 
  For more advanced strategies, use a LayoutPolicy with some LayoutProperties. See #layoutPolicy: and maybe also #doLayoutIn:."
 
+ self snapToEdgeIfAppropriate.
+
+ self ownerChangedHandler
+ ifNotNil: [:handler | handler cull: self].!
- self snapToEdgeIfAppropriate.!

Item was added:
+ ----- Method: Morph>>ownerChangedHandler (in category 'layout') -----
+ ownerChangedHandler
+
+ ^ self valueOfProperty: #ownerChangedHandler!

Item was added:
+ ----- Method: Morph>>ownerChangedHandler: (in category 'layout') -----
+ ownerChangedHandler: aHandler
+
+ self
+ setProperty: #ownerChangedHandler
+ toValue: aHandler.
+
+ self layoutChanged.!

Item was changed:
  ----- Method: MorphicProject class>>applyUserInterfaceTheme (in category 'preferences') -----
  applyUserInterfaceTheme
 
  self current addDeferredUIMessage: [
  "After all immediate changes where applied, we can reset to values that match the current world configuration:"
  self worldGridOrigin: nil.
  self worldGridModulus: nil.
+ self worldGridEnabled
- self current world griddingOn
  ifTrue: [self current world firstHand turnOnGridding]].!

Item was changed:
  ----- Method: MorphicProject class>>worldGridEnabled (in category 'preferences') -----
  worldGridEnabled
  <preference: 'Snap Morphs to World Grid'
  categoryList: #('Morphic' 'Tools')
  description: 'When true, morphs placed in the world will align with a regular grid. This includes tool windows.'
  type: #Boolean>
+
+ | world |
+ world := self current world.
+ ^ self current isMorphic and: [world layoutPolicy notNil and: [world layoutPolicy isGridLayout]]!
- ^ self current isMorphic and: [self current world griddingOn]!

Item was changed:
  ----- Method: MorphicProject class>>worldGridEnabled: (in category 'preferences') -----
  worldGridEnabled: aBooleanOrNil
 
+ (aBooleanOrNil ifNil: [false])
+ ifTrue: [self current world layoutPolicy: GridLayout new]
+ ifFalse: [self current world layoutPolicy: nil].
- (aBooleanOrNil ifNil: [false]) = self current world griddingOn
- ifFalse: [self current world griddingOnOff].
 
  "Auto-configure origin and modulus to match world properties."
  self worldGridOrigin: nil.
  self worldGridModulus: nil.
 
  "Snap to grid when dragging something."
+ self worldGridEnabled
- self current world griddingOn
  ifTrue: [self current world firstHand turnOnGridding]
  ifFalse: [self current world firstHand turnOffGridding].!

Item was changed:
  BorderedMorph subclass: #PasteUpMorph
+ instanceVariableNames: 'presenter model cursor padding turtleTrailsForm turtlePen lastTurtlePositions isPartsBin indicateCursor wantsMouseOverHalos worldState'
- instanceVariableNames: 'presenter model cursor padding backgroundMorph turtleTrailsForm turtlePen lastTurtlePositions isPartsBin indicateCursor wantsMouseOverHalos worldState'
  classVariableNames: 'GlobalCommandKeysEnabled WindowEventHandler'
  poolDictionaries: ''
  category: 'Morphic-Worlds'!
 
  !PasteUpMorph commentStamp: '<historical>' prior: 0!
  A morph whose submorphs comprise a paste-up of rectangular subparts which "show through".  Anything called a 'Playfield' is a PasteUpMorph.
 
  Facilities commonly needed on pages of graphical presentations and on simulation playfields, such as the painting of new objects, turtle trails, gradient fills, background paintings, parts-bin behavior, collision-detection, etc., are (or will be) provided.
 
  A World, the entire Smalltalk screen, is a PasteUpMorph.  A World responds true to isWorld.  Morph subclasses that have specialized menus (BookMorph) build them in the message addBookMenuItemsTo:hand:.  A PasteUpMorph that is a world, builds its menu in HandMorph buildWorldMenu.
 
  presenter A Presenter in charge of stopButton stepButton and goButton,
  mouseOverHalosEnabled soundsEnabled fenceEnabled coloredTilesEnabled.
  model <not used>
  cursor ??
  padding ??
  backgroundMorph A Form that covers the background.
  turtleTrailsForm Moving submorphs may leave trails on this form.
  turtlePen Draws the trails.
  lastTurtlePositions A Dictionary of (aPlayer -> aPoint) so turtle trails can be drawn
  only once each step cycle.  The point is the start of the current stroke.
  isPartsBin If true, every object dragged out is copied.
  autoLineLayout ??
  indicateCursor ??
  resizeToFit ??
  wantsMouseOverHalos If true, simply moving the cursor over a submorph brings up its halo.
  worldState If I am also a World, keeps the hands, damageRecorder, stepList etc.
  griddingOn If true, submorphs are on a grid
 
  !

Item was changed:
  ----- Method: PasteUpMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas
  "Draw in order:
  - background color
- - grid, if any
- - background sketch, if any
  - Update and draw the turtleTrails form. See the comment in updateTrailsForm.
  - cursor box if any
 
  Later (in drawSubmorphsOn:) I will skip drawing the background sketch."
 
  "draw background fill"
  super drawOn: aCanvas.
 
- "draw grid"
- (self griddingOn and: [self gridVisible])
- ifTrue:
- [aCanvas fillRectangle: self bounds
- fillStyle: (self
- gridFormOrigin: self gridOrigin
- grid: self gridModulus
- background: nil
- line: Color lightGray)].
-
- "draw background sketch."
- backgroundMorph ifNotNil: [
- self clipSubmorphs ifTrue: [
- aCanvas clipBy: self clippingBounds
- during: [ :canvas | canvas fullDrawMorph: backgroundMorph ]]
- ifFalse: [ aCanvas fullDrawMorph: backgroundMorph ]].
-
  "draw turtle trails"
  (lastTurtlePositions isNil or: [lastTurtlePositions isEmpty]) ifFalse:[
  self updateTrailsForm.
  ].
  turtleTrailsForm
  ifNotNil: [aCanvas paintImage: turtleTrailsForm at: self position].
 
  "draw cursor"
  (submorphs notEmpty and: [self indicateCursor])
  ifTrue:
  [aCanvas
  frameRectangle: self selectedRect
  width: 2
  color: Color black]!

Item was removed:
- ----- Method: PasteUpMorph>>drawSubmorphsOn: (in category 'painting') -----
- drawSubmorphsOn: aCanvas
- "Display submorphs back to front, but skip my background sketch."
-
- | drawBlock |
- submorphs isEmpty ifTrue: [^self].
- drawBlock := [:canvas | submorphs reverseDo: [:m | m ~~ backgroundMorph ifTrue: [ canvas fullDrawMorph: m ]]].
- self clipSubmorphs
- ifTrue: [aCanvas clipBy: self clippingBounds during: drawBlock]
- ifFalse: [drawBlock value: aCanvas]!

Item was removed:
- ----- Method: PasteUpMorph>>gridVisible (in category 'gridding') -----
- gridVisible
-
- ^ self hasProperty: #gridVisible!

Item was removed:
- ----- Method: PasteUpMorph>>gridVisibleOnOff (in category 'gridding') -----
- gridVisibleOnOff
-
- self setProperty: #gridVisible toValue: self gridVisible not.
- self changed!

Item was removed:
- ----- Method: PasteUpMorph>>gridVisibleString (in category 'gridding') -----
- gridVisibleString
- "Answer a string to be used in a menu offering the opportunity
- to show or hide the grid"
- ^ (self gridVisible
- ifTrue: ['<yes>']
- ifFalse: ['<no>'])
- , 'grid visible when gridding' translated!

Item was removed:
- ----- Method: PasteUpMorph>>griddingOn (in category 'gridding') -----
- griddingOn
-
- ^ self layoutPolicy notNil and: [self layoutPolicy isGridLayout]!

Item was removed:
- ----- Method: PasteUpMorph>>griddingOnOff (in category 'gridding') -----
- griddingOnOff
- "Change grid layout. Consider the #clearArea to ignore docking bars and other adhereing morphs."
-
- self layoutPolicy: (self griddingOn ifFalse: [GridLayout new]).!

Item was removed:
- ----- Method: PasteUpMorph>>griddingString (in category 'gridding') -----
- griddingString
- "Answer a string to use in a menu offering the user the
- opportunity to start or stop using gridding"
- ^ (self griddingOn
- ifTrue: ['<yes>']
- ifFalse: ['<no>'])
- , 'use gridding' translated!

Item was removed:
- ----- Method: PasteUpMorph>>privateRemoveMorph: (in category 'private') -----
- privateRemoveMorph: aMorph
- backgroundMorph == aMorph ifTrue: [ backgroundMorph := nil ].
- ^super privateRemoveMorph: aMorph.
- !

Item was removed:
- ----- Method: PasteUpMorph>>setGridSpec (in category 'gridding') -----
- setGridSpec
- "Gridding rectangle provides origin and modulus"
- | response result |
- response := UIManager default
- request: 'New grid origin (usually 0@0):' translated
- initialAnswer: self gridOrigin printString.
- response isEmpty ifTrue: [^ self].
- result := [Compiler evaluate: response] ifError: [^ self].
- (result isPoint and: [(result >= (0@0))])
- ifTrue: [self gridOrigin: result]
- ifFalse: [self inform: ('Must be a Point with coordinates (for example 10@10)' translated )].
-
- response := UIManager default
- request: 'New grid spacing:' translated
- initialAnswer: self gridModulus printString.
- response isEmpty ifTrue: [^ self].
- result := [Compiler evaluate: response] ifError: [^ self].
- (result isPoint and: [(result > (0@0)) ])
- ifTrue: [self gridModulus: result]
- ifFalse: [self inform: ('Must be a Point with coordinates (for example 10@10)' translated )].
-
- !