A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-ct.1236.mcz ==================== Summary ==================== Name: System-ct.1236 Author: ct Time: 15 June 2021, 4:00:40.522222 pm UUID: f7bb410f-d6de-b242-b769-a558aa5a4254 Ancestors: System-dtl.1235 Fixes RealEstateAgent intolerance with a nil world which must be handled according to senders. Document the fact that world can be nil in all relevant senders. I struggled about this when I encountered a recursive project error. See StandardSystemView >> #initialFrame. =============== Diff against System-dtl.1235 =============== Item was changed: ----- Method: RealEstateAgent class>>initialFrameAtPointerFor:initialExtent:world: (in category 'framing - private') ----- + initialFrameAtPointerFor: aView initialExtent: scaledExtent world: aWorldOrNil + ^((aWorldOrNil ifNil: [0 @ 0] ifNotNil: [aWorldOrNil cursorPoint - (50@10) "puts use with the mouse ptr just to the right of the menu button"]) - initialFrameAtPointerFor: aView initialExtent: scaledExtent world: aWorld - ^(aWorld cursorPoint - (50@10) "puts use with the mouse ptr just to the right of the menu button" extent: scaledExtent) + translatedAndSquishedToBeWithin: (self maximumUsableAreaInWorld: aWorldOrNil)! - translatedAndSquishedToBeWithin: (self maximumUsableAreaInWorld: aWorld)! Item was changed: ----- Method: RealEstateAgent class>>initialFrameFor:initialExtent:world: (in category 'framing') ----- + initialFrameFor: aView initialExtent: initialExtent world: aWorldOrNil - initialFrameFor: aView initialExtent: initialExtent world: aWorld | scaledExtent | scaledExtent := (initialExtent * self scaleFactor) rounded. self placeWindowsAtPointer ifTrue: + [^self initialFrameAtPointerFor: aView initialExtent: scaledExtent world: aWorldOrNil]. - [^self initialFrameAtPointerFor: aView initialExtent: scaledExtent world: aWorld]. ^ Preferences reverseWindowStagger + ifTrue: [self strictlyStaggeredInitialFrameFor: aView initialExtent: scaledExtent world: aWorldOrNil] + ifFalse: [self normalInitialFrameFor: aView initialExtent: scaledExtent world: aWorldOrNil]! - ifTrue: [self strictlyStaggeredInitialFrameFor: aView initialExtent: scaledExtent world: aWorld] - ifFalse: [self normalInitialFrameFor: aView initialExtent: scaledExtent world: aWorld]! Item was changed: ----- Method: RealEstateAgent class>>initialFrameFor:world: (in category 'framing') ----- + initialFrameFor: aView world: aWorldOrNil - initialFrameFor: aView world: aWorld "Find a plausible initial screen area for the supplied view. See called method." + ^ self initialFrameFor: aView initialExtent: aView initialExtent world: aWorldOrNil! - ^ self initialFrameFor: aView initialExtent: aView initialExtent world: aWorld! Item was changed: ----- Method: RealEstateAgent class>>normalInitialFrameFor:initialExtent:world: (in category 'framing - private') ----- + normalInitialFrameFor: aView initialExtent: initialExtent world: aWorldOrNil - normalInitialFrameFor: aView initialExtent: initialExtent world: aWorld "Find a plausible initial screen area for the supplied view, which should be a StandardSystemView, taking into account the 'reverseWindowStagger' Preference, the size needed, and other windows currently on the screen." | allOrigins screenRight screenBottom putativeOrigin putativeFrame allowedArea staggerOrigin otherFrames | + allowedArea := self maximumUsableAreaInWorld: aWorldOrNil. - allowedArea := self maximumUsableAreaInWorld: aWorld. screenRight := allowedArea right. screenBottom := allowedArea bottom. otherFrames := Smalltalk isMorphic + ifTrue: [(SystemWindow windowsIn: aWorldOrNil satisfying: [:w | w isCollapsed not]) - ifTrue: [(SystemWindow windowsIn: aWorld satisfying: [:w | w isCollapsed not]) collect: [:w | w bounds]] ifFalse: [ScheduledControllers scheduledWindowControllers select: [:aController | aController view ~~ nil] thenCollect: [:aController | aController view isCollapsed ifTrue: [aController view expandedFrame] ifFalse: [aController view displayBox]]]. allOrigins := otherFrames collect: [:f | f origin]. + (self standardPositionsInWorld: aWorldOrNil) do: "First see if one of the standard positions is free" - (self standardPositionsInWorld: aWorld) do: "First see if one of the standard positions is free" [:aPosition | (allOrigins includes: aPosition) ifFalse: [^ (aPosition extent: initialExtent) translatedAndSquishedToBeWithin: allowedArea]]. + staggerOrigin := (self standardPositionsInWorld: aWorldOrNil) first. "Fallback: try offsetting from top left" - staggerOrigin := (self standardPositionsInWorld: aWorld) first. "Fallback: try offsetting from top left" putativeOrigin := staggerOrigin. [putativeOrigin := putativeOrigin + StaggerOffset. putativeFrame := putativeOrigin extent: initialExtent. (putativeFrame bottom < screenBottom) and: [putativeFrame right < screenRight]] whileTrue: [(allOrigins includes: putativeOrigin) ifFalse: [^ (putativeOrigin extent: initialExtent) translatedAndSquishedToBeWithin: allowedArea]]. ^ (self scrollBarSetback @ self screenTopSetback extent: initialExtent) translatedAndSquishedToBeWithin: allowedArea! Item was changed: ----- Method: RealEstateAgent class>>strictlyStaggeredInitialFrameFor:initialExtent:world: (in category 'framing - private') ----- + strictlyStaggeredInitialFrameFor: aStandardSystemView initialExtent: initialExtent world: aWorldOrNil - strictlyStaggeredInitialFrameFor: aStandardSystemView initialExtent: initialExtent world: aWorld "This method implements a staggered window placement policy that I (di) like. Basically it provides for up to 4 windows, staggered from each of the 4 corners. The windows are staggered so that there will always be a corner visible." | allowedArea grid initialFrame otherFrames cornerSel corner delta putativeCorner free maxLevel | + allowedArea :=(self maximumUsableAreaInWorld: aWorldOrNil) - allowedArea :=(self maximumUsableAreaInWorld: aWorld) insetBy: (self scrollBarSetback @ self screenTopSetback extent: 0@0). "Number to be staggered at each corner (less on small screens)" maxLevel := allowedArea area > 300000 ifTrue: [3] ifFalse: [2]. "Amount by which to stagger (less on small screens)" grid := allowedArea area > 500000 ifTrue: [40] ifFalse: [20]. initialFrame := 0@0 extent: ((initialExtent "min: (allowedArea extent - (grid*(maxLevel+1*2) + (grid//2)))) min: 600@400")). otherFrames := Smalltalk isMorphic + ifTrue: [(SystemWindow windowsIn: aWorldOrNil satisfying: [:w | w isCollapsed not]) - ifTrue: [(SystemWindow windowsIn: aWorld satisfying: [:w | w isCollapsed not]) collect: [:w | w bounds]] ifFalse: [ScheduledControllers scheduledWindowControllers select: [:aController | aController view ~~ nil] thenCollect: [:aController | aController view isCollapsed ifTrue: [aController view expandedFrame] ifFalse: [aController view displayBox]]]. 0 to: maxLevel do: [:level | 1 to: 4 do: [:ci | cornerSel := #(topLeft topRight bottomRight bottomLeft) at: ci. corner := allowedArea perform: cornerSel. "The extra grid//2 in delta helps to keep title tabs distinct" delta := (maxLevel-level*grid+(grid//2)) @ (level*grid). 1 to: ci-1 do: [:i | delta := delta rotateBy: #right centerAt: 0@0]. "slow way" putativeCorner := corner + delta. free := true. otherFrames do: [:w | free := free & ((w perform: cornerSel) ~= putativeCorner)]. free ifTrue: [^ (initialFrame align: (initialFrame perform: cornerSel) with: putativeCorner) translatedAndSquishedToBeWithin: allowedArea]]]. "If all else fails..." ^ (self scrollBarSetback @ self screenTopSetback extent: initialFrame extent) translatedAndSquishedToBeWithin: allowedArea! |
-1 It makes no sense to officially support a "nil" argument in this protocol. Best, Marcel
|
Hi Marcel,
> -1 > > It makes no sense to officially support a "nil" argument in this protocol. partially it was already supported officially before (some parameters already were named "aWorldOrNil"). Do you think we should instead modify StandardSystemView >> #initialFrame to use #currentWorld instead of "nil" or are there any semantic differences? Best, Christoph
Carpe Squeak!
|
Hi Christoph. > Do you think we should instead modify StandardSystemView >> #initialFrame to use #currentWorld instead of "nil" or are there any semantic differences? Yes, I think we should fill those "nil" cases with "self currentWorld". Well, there are of course protocols that work with a morph not being in any world. Yet, there are some protocols that expect a world where "self currentWorld" should be good enough. We should just be careful to not put such morphs into the currentWorld by accident. Best, Marcel
|
Free forum by Nabble | Edit this page |