[squeak-dev] The Inbox: MorphicExtras-dtl.214.mcz

H. Hirzel hannes.hirzel at gmail.com
Tue Nov 14 04:13:47 UTC 2017


On 11/14/17, David T. Lewis <lewis at mail.msen.com> wrote:
> Hi Chris,
>
> I did not intend to move all those packages to trunk right after you
> posted this, I had thought that there were no further comments and did
> not see your message while I was doing the moves. The neglect was not
> intentional.
>
> On Mon, Nov 13, 2017 at 07:29:29PM -0600, Chris Muller wrote:
>> Why?  This is a sad move for users who want to program the
>> environment, and it does little or nothing to make it any safer.  Is
>> it because "globals are bad?"  I hope not.
>>
>> Should I assume that you mean to make Display, Processor, and other
>> globals disappear too?  If so, what about classes, as Smalltalkers we
>> like to tell people they're "objects" too, so why make this sort of
>> access "exceptional" to classes only?
>
> No, it is quite specific to the problem of project navigation, as well
> as better support of multiple (possibly concurrent?) project types. The
> idea is to avoid using globals to cache information that is, or should be,
> local to a Project. I have spent some time debugging these things in the
> past, and is quite clear to me that unnecessary use of globals for things
> that are not really global is a Really Bad Idea, especially when you are
> dealing with things that drop you into an emergency evaluator when they
> do not work.

Note the wording 'unnecessary use of globals'

so in a Morph

    self world

is preferred to just

    World

>
> To some extent I am also looking forward to Morphic3 which is being
> developed
> in Cuis. It should in principle be able to host this in Squeak, and I did
> some work a number of years ago
> (http://www.squeaksource.com/SimpleMorphicSqueak)
> on an early proof of concept.

Great to see that you have started preparing to take this on again...

> That proof of concept was "successful" in
> the sense that it worked, but it was also quite clear that some housekeeping
> was was going to be needed in Squeak (specifically around Projects) in order
> for things like this to be sustainable beyond just the proof of concept
> level. So I am not trying to take anything away from Squeak, just trying
> to scratch a long standing itch and maybe tidy up the system a little bit
> in the process.
>
> I hope you understand that "world global elimination" was just a small
> joke, I do not really intend to make any important things disappear ;-)
>
> Dave
>
>>
>> On Sat, Nov 11, 2017 at 3:05 PM,  <commits at source.squeak.org> wrote:
>> > David T. Lewis uploaded a new version of MorphicExtras to project The
>> > Inbox:
>> > http://source.squeak.org/inbox/MorphicExtras-dtl.214.mcz
>> >
>> > ==================== Summary ====================
>> >
>> > Name: MorphicExtras-dtl.214
>> > Author: dtl
>> > Time: 11 November 2017, 4:05:52.716283 pm
>> > UUID: 297c9f00-e80a-4a90-a1aa-5f3a26a835d0
>> > Ancestors: MorphicExtras-pre.213
>> >
>> > World global elimination. Once the current project has been entered,
>> > Project current world == World. Begin eliminating references to the
>> > global variable World in cases where it is not required.
>> >
>> > =============== Diff against MorphicExtras-pre.213 ===============
>> >
>> > Item was changed:
>> >   ----- Method: BookMorph>>loadImagesIntoBook (in category 'menu') -----
>> >   loadImagesIntoBook
>> >         "PowerPoint stores GIF presentations as individual slides named
>> > Slide1, Slide2, etc.
>> >         Load these into the book.  mjg 9/99"
>> >
>> >         | directory filenumber form newpage |
>> >         directory := ((StandardFileMenu oldFileFrom: FileDirectory
>> > default)
>> >                                 ifNil: [^nil]) directory.
>> >         directory isNil ifTrue: [^nil].
>> >
>> >         "Start loading 'em up!!"
>> >         filenumber := 1.
>> >         [directory fileExists: 'Slide' , filenumber asString] whileTrue:
>> >                         [Transcript
>> >                                 show: 'Slide' , filenumber asString;
>> >                                 cr.
>> >                         Smalltalk bytesLeft < 1000000
>> >                                 ifTrue:
>> >                                         ["Make some room"
>> >
>> >                                         (self valueOfProperty: #url)
>> > isNil
>> >                                                 ifTrue: [self
>> > savePagesOnURL]
>> >                                                 ifFalse: [self
>> > saveAsNumberedURLs]].
>> >                         form := Form
>> >                                                 fromFileNamed:
>> > (directory fullNameFor: 'Slide' , filenumber asString).
>> >                         newpage := PasteUpMorph new extent: form extent.
>> > +                       newpage addMorph: (Project current world
>> > drawingClass withForm: form).
>> > -                       newpage addMorph: (World drawingClass withForm:
>> > form).
>> >                         self pages addLast: newpage.
>> >                         filenumber := filenumber + 1].
>> >
>> >         "After adding all, delete the first page."
>> >         self goToPage: 1.
>> >         self deletePageBasic.
>> >
>> >         "Save the book"
>> >         (self valueOfProperty: #url) isNil
>> >                 ifTrue: [self savePagesOnURL]
>> >                 ifFalse: [self saveAsNumberedURLs]!
>> >
>> > Item was changed:
>> >   ----- Method: GraphicalDictionaryMenu>>handMeOne (in category 'menu
>> > commands') -----
>> >   handMeOne
>> > +       self currentHand attachMorph: (Project current world
>> > drawingClass new form: (formChoices at: currentIndex))!
>> > -       self currentHand attachMorph: (World drawingClass new form:
>> > (formChoices at: currentIndex))!
>> >
>> > Item was changed:
>> >   ----- Method: GraphicalDictionaryMenu>>repaintEntry (in category 'menu
>> > commands') -----
>> >   repaintEntry
>> >         "Let the user enter into painting mode to repaint the item and
>> > save it back."
>> >
>> >         | aWorld bnds sketchEditor aPaintBox formToEdit |
>> >
>> >         (aWorld := self world) assureNotPaintingElse: [^ self].
>> >
>> >         aWorld prepareToPaint.
>> >         aWorld displayWorld.
>> >         formToEdit := formChoices at: currentIndex.
>> >         bnds := (submorphs second boundsInWorld origin extent:
>> > formToEdit extent) intersect: aWorld bounds.
>> >         bnds := (aWorld paintingBoundsAround: bnds center) merge: bnds.
>> >         sketchEditor := SketchEditorMorph new.
>> >         aWorld addMorphFront: sketchEditor.
>> > +       sketchEditor initializeFor: ((aWorld drawingClass withForm:
>> > formToEdit) position: submorphs second positionInWorld)  inBounds: bnds
>> > pasteUpMorph: aWorld paintBoxPosition: bnds topRight.
>> > -       sketchEditor initializeFor: ((World drawingClass withForm:
>> > formToEdit) position: submorphs second positionInWorld)  inBounds: bnds
>> > pasteUpMorph: aWorld paintBoxPosition: bnds topRight.
>> >         sketchEditor
>> >                 afterNewPicDo: [:aForm :aRect |
>> >                         formChoices at: currentIndex put: aForm.
>> >                         baseDictionary at: (entryNames at: currentIndex)
>> > put: aForm.
>> >                         self updateThumbnail.
>> >                         (aPaintBox := aWorld paintBoxOrNil) ifNotNil:
>> > [aPaintBox delete]]
>> >                 ifNoBits:
>> >                         [(aPaintBox := aWorld paintBoxOrNil) ifNotNil:
>> > [aPaintBox delete]].
>> >
>> >   !
>> >
>> > Item was changed:
>> >   ----- Method: ProjectSorterMorph>>addControls (in category
>> > 'initialization') -----
>> >   addControls
>> >         "Add the control bar at the top of the tool."
>> >
>> >         | b r partsBinButton newButton aWrapper |
>> > +       newButton := ImageMorph new image: (Project current
>> > makeThumbnail scaledToSize: 48 at 36).
>> > -       newButton := ImageMorph new image: (World project makeThumbnail
>> > scaledToSize: 48 at 36).
>> >         newButton on: #mouseDown send: #insertNewProject: to: self.
>> >         newButton setBalloonText: 'Make a new Project' translated.
>> >         (partsBinButton := UpdatingThreePhaseButtonMorph checkBox)
>> >                 target: self;
>> >                 actionSelector: #togglePartsBinStatus;
>> >                 arguments: #();
>> >                 getSelector: #getPartsBinStatus.
>> >         (r := AlignmentMorph newRow)
>> >                 color: Color transparent;
>> >                 borderWidth: 0;
>> >                 layoutInset: 0;
>> >                 cellInset: 10 at 0;
>> >                 wrapCentering: #center;
>> >                 cellPositioning: #leftCenter;
>> >                 hResizing: #shrinkWrap;
>> >                 vResizing: #shrinkWrap;
>> >                 extent: 5 at 5.
>> >         b := SimpleButtonMorph new target: self; color: self
>> > defaultColor darker;
>> >                         borderColor: Color black.
>> >         r addMorphBack: (self wrapperFor: (b label: 'Okay' translated
>> > font: ScriptingSystem fontForEToyButtons; actionSelector: #acceptSort)).
>> >         b := SimpleButtonMorph new target: self; color: self
>> > defaultColor darker;
>> >                         borderColor: Color black.
>> >         r addMorphBack: (self wrapperFor: (b label: 'Cancel' translated
>> > font: ScriptingSystem fontForEToyButtons; actionSelector: #delete));
>> >                 addTransparentSpacerOfSize: 8 @ 0;
>> >                 addMorphBack: (self wrapperFor: (newButton));
>> >                 addTransparentSpacerOfSize: 8 @ 0.
>> >
>> >         aWrapper := AlignmentMorph newRow beTransparent.
>> >         aWrapper cellInset: 0; layoutInset: 0; borderWidth: 0.
>> >         aWrapper
>> >                 addMorphBack: (self wrapperFor: partsBinButton);
>> >                 addMorphBack: (self wrapperFor: (StringMorph contents:
>> > 'Parts bin' translated font: ScriptingSystem fontForEToyButtons) lock).
>> >         r addMorphBack: aWrapper.
>> >
>> >         self addMorphFront: r.
>> >   !
>> >
>> > Item was changed:
>> >   ----- Method: SpeakerMorph>>addGraphic (in category 'initialization')
>> > -----
>> >   addGraphic
>> >
>> >         | graphic |
>> > +       graphic := Project current world drawingClass withForm: self
>> > speakerGraphic.
>> > -       graphic := World drawingClass withForm: self speakerGraphic.
>> >         graphic position: bounds center - (graphic extent // 2).
>> >         self addMorph: graphic.
>> >   !
>> >
>> > Item was changed:
>> >   ----- Method: SqueakPage>>prePurge (in category 'saving') -----
>> >   prePurge
>> >         "Return self if ready to be purged, or nil if not"
>> >
>> >         self isContentsInMemory ifFalse: [^ nil].
>> >         contentsMorph ifNil: [^ nil].  "out already"
>> >         url ifNil: [^ nil].     "just to be safe"
>> > +       ^ (Project current world ~~ nil and: [contentsMorph world ==
>> > World])
>> > -       ^ (World ~~ nil and: [contentsMorph world == World])
>> >                 ifTrue: [nil "showing now"] ifFalse: [self]!
>> >
>> > Item was changed:
>> >   ----- Method: TabbedPalette class>>authoringPrototype (in category
>> > 'scripting') -----
>> >   authoringPrototype
>> >         | aTabbedPalette aBook aTab |
>> >         aTabbedPalette := self new markAsPartsDonor.
>> >         aTabbedPalette pageSize: 200 @ 300.
>> >         aTabbedPalette tabsMorph highlightColor: Color red regularColor:
>> > Color blue.
>> >         aTabbedPalette addMenuTab.
>> >
>> >         aBook := BookMorph new setNameTo: 'one'; pageSize:
>> > aTabbedPalette pageSize.
>> >         aBook color: Color blue muchLighter.
>> >         aBook removeEverything; insertPage; showPageControls.
>> > +       aBook currentPage addMorphBack: (Project current world
>> > drawingClass withForm: ScriptingSystem squeakyMouseForm).
>> > -       aBook currentPage addMorphBack: (World drawingClass withForm:
>> > ScriptingSystem squeakyMouseForm).
>> >         aTab := aTabbedPalette addTabForBook: aBook.
>> >
>> >         aBook := BookMorph new setNameTo: 'two'; pageSize:
>> > aTabbedPalette pageSize.
>> >         aBook color: Color red muchLighter.
>> >         aBook removeEverything; insertPage; showPageControls.
>> >         aBook currentPage addMorphBack: CurveMorph authoringPrototype.
>> >         aTabbedPalette addTabForBook: aBook.
>> >
>> >         aTabbedPalette selectTab: aTab.
>> >
>> >         aTabbedPalette beSticky.
>> >         aTabbedPalette tabsMorph hResizing: #spaceFill.
>> >         ^ aTabbedPalette!
>> >
>> > Item was changed:
>> >   ----- Method: TabbedPalette>>addMenuTab (in category 'palette menu')
>> > -----
>> >   addMenuTab
>> >         "Add the menu tab.  This is ancient code, not much in the spirit
>> > of anything current"
>> >
>> >         | aMenu aTab aGraphic sk |
>> >         aMenu := MenuMorph new defaultTarget: self.
>> >         aMenu stayUp: true.
>> >         "aMenu add:  'clear' translated action: #showNoPalette."
>> >         aMenu add:  'sort tabs' translated action: #sortTabs:.
>> >         aMenu add:  'choose new colors for tabs' translated action:
>> > #recolorTabs.
>> >         aMenu setProperty: #paletteMenu toValue: true.
>> >         "aMenu add:  'make me the Standard palette' translated action:
>> > #becomeStandardPalette."
>> >         aTab := self addTabForBook: aMenu  withBalloonText: 'a menu of
>> > palette-related controls' translated.
>> >         aTab highlightColor: tabsMorph highlightColor; regularColor:
>> > tabsMorph regularColor.
>> >         tabsMorph laySubpartsOutInOneRow; layoutChanged.
>> >
>> >         aGraphic := ScriptingSystem formAtKey: 'TinyMenu'.
>> >         aGraphic ifNotNil:
>> >                 [aTab removeAllMorphs.
>> > +               aTab addMorph: (sk := Project current world drawingClass
>> > withForm: aGraphic).
>> > -               aTab addMorph: (sk := World drawingClass withForm:
>> > aGraphic).
>> >                 sk position: aTab position.
>> >                 sk lock.
>> >                 aTab fitContents].
>> >         self layoutChanged!
>> >
>> >
>>
>
>


More information about the Squeak-dev mailing list