'From etoys4.0 of 9 October 2008 [latest update: #2233] on 16 July 2009 at 3:02:39 pm'! "Change Set: navBar-sw-mz-yo Date: 16 July 2009 Author: Scott Wallace, Milan Zimmermann, Yoshiki Oshima Adds a control at topright of screen/window to govern visibility of the full nav bar. When opening 'old' projects, the nav bar will now appear in its collapsed form, at the top-right corner of the screen, to minimize the chance of obscuring essential content. The criterion for oldness is: any project lacking a 'manifest' is considered old, as is any project whose manifest indicates a version code that is not 'etoys'. This update is derived from work done under the following two JIRA items: SQ-154 Make it simple to show and hide the toolbar SQ-280 Detect the version of a loading project and hide nav bar if desirable."! !FlapTab methodsFor: 'positioning' stamp: 'sw 5/29/2009 18:47'! adjustPositionVisAVisFlap "If appropriate, adjust the receiver's position vis-a-vis the flap." | sideToAlignTo opposite | (#(left right top bottom) includes: edgeToAdhereTo) ifTrue: [opposite _ Utilities oppositeSideTo: edgeToAdhereTo. sideToAlignTo _ inboard ifTrue: [opposite] ifFalse: [edgeToAdhereTo]. self perform: (Utilities simpleSetterFor: sideToAlignTo) with: (referent perform: opposite)]! ! !PasteUpMorph methodsFor: 'menu & halo' stamp: 'sw 7/6/2009 15:48'! addWorldHaloMenuItemsTo: aMenu hand: aHandMorph "Add the standard items to the aMenu which will serve as the World's halo menu." aMenu add: 'about this system...' translated target: SmalltalkImage current selector: #aboutThisSystem. aMenu addLine. aMenu add: 'redraw screen (r)' translated action: #restoreMorphicDisplay. aMenu add: 'preferences...' translated target: Preferences selector: #openPreferencesInspector. aMenu add: 'authoring tools...' translated target: (TheWorldMenu new adaptToWorld: self) selector: #scriptingDo. aMenu addLine. self addWorldToggleItemsToHaloMenu: aMenu. Preferences eToyFriendly ifFalse: [Preferences sugarNavigator ifFalse: [self addExportMenuItems: aMenu hand: aHandMorph]]. self addLockingItemsTo: aMenu. aMenu addLine. self addFillStyleMenuItems: aMenu hand: aHandMorph. self addPenMenuItems: aMenu hand: aHandMorph. self addPlayfieldMenuItems: aMenu hand: aHandMorph. (owner isKindOf: BOBTransformationMorph) ifTrue: "wow, blast from the past" [self addScalingMenuItems: aMenu hand: aHandMorph]. Preferences eToyFriendly ifFalse: [aMenu addLine. aMenu add: 'world menu...' translated target: self action: #putUpDesktopMenu:]! ! !PasteUpMorph methodsFor: 'menu & halo' stamp: 'sw 7/6/2009 15:47'! addWorldToggleItemsToHaloMenu: aMenu "Add toggle items for the world to the halo menu .... July 2009: no longer in world halo menu" "aMenu addUpdating: #showTabsString target: CurrentProjectRefactoring action: #currentToggleFlapsSuppressed "! ! !PasteUpMorph methodsFor: '*green' stamp: 'sw 5/30/2009 02:22'! toggleFullScreen "Toggle the full-screenness; we simply flip the global flaps-suppressed setting." | tab | (Preferences navControlInNavBar and: [(tab := self findA: SugarNavTab) notNil]) ifTrue: [tab collapsedMode ifTrue: [tab showNavBar] ifFalse: [tab hideNavBar]] ifFalse: [CurrentProjectRefactoring currentToggleFlapsSuppressed]! ! !PasteUpMorph class methodsFor: 'scripting' stamp: 'sw 6/5/2009 14:43'! additionsToViewerCategoryDisplay "Answer display additions" ^ #(display( (command showNavigationBar 'Show the navigation bar at the top of the screen') (command hideNavigationBar 'Hide the navigation bar at the top of the screen') (command useBlueprintCanvas 'Display the world as a blueprint' ) (command useNormalCanvas 'Display the world normally' Boolean)))! ! !Player methodsFor: 'misc' stamp: 'sw 6/5/2009 14:44'! hideNavigationBar "Hide the navigation bar at the top of the screen" | tab | ((tab := costume world findA: SugarNavTab) notNil) ifTrue: [tab collapsedMode ifFalse: [tab hideNavBar]]! ! !Player methodsFor: 'misc' stamp: 'sw 6/5/2009 14:43'! showNavigationBar "Show the navigation bar at the top of the screen" | tab | ((tab := costume world findA: SugarNavTab) notNil) ifTrue: [tab collapsedMode ifTrue: [tab showNavBar]]! ! !Project methodsFor: 'menu messages' stamp: 'sw 7/14/2009 17:10'! finalEnterActions "Perform the final actions necessary as the receiver project is entered" | navigator armsLengthCmd navType thingsToUnhibernate | self projectParameters at: #projectsToBeDeleted ifPresent: [ :projectsToBeDeleted | self removeParameter: #projectsToBeDeleted. projectsToBeDeleted do: [ :each | Project deletingProject: each. each removeChangeSetIfPossible]]. Preferences preserveProjectLocale ifTrue: [Locale switchAndInstallFontToID: self localeID gently: true] ifFalse: [self localeID = LocaleID current ifFalse: [self localeChanged]]. (self projectParameterAt: #oldProject ifAbsent: [false]) ifTrue: [(self isFlapIDEnabled: 'Sugar Navigator Flap' translated) ifTrue: [(world findA: SugarNavTab) ifNotNilDo: [:tab | tab hideNavBar]]] ifFalse: [(self isFlapIDEnabled: 'Sugar Navigator Flap' translated) ifFalse: [Flaps enableGlobalFlapWithID: 'Sugar Navigator Flap' translated]]. self removeParameter: #oldProject. thingsToUnhibernate _ world valueOfProperty: #thingsToUnhibernate ifAbsent: [#()]. thingsToUnhibernate do: [:each | each unhibernate]. world removeProperty: #thingsToUnhibernate. (self projectParameterAt: #substitutedFont) ifNotNil: [ self removeParameter: #substitutedFont. self world presenter allPlayersWithUniclasses do: [:uni | uni allScriptEditors do: [:scr | scr setProperty: #needsLayoutFixed toValue: true ]]. ]. navType _ ProjectNavigationMorph preferredNavigator. armsLengthCmd _ self parameterAt: #armsLengthCmd ifAbsent: [nil]. navigator _ world findA: navType. (Preferences classicNavigatorEnabled and: [Preferences showProjectNavigator and: [navigator isNil]]) ifTrue: [(navigator _ navType new addButtons) bottomLeft: world bottomLeft; openInWorld: world]. navigator notNil & armsLengthCmd notNil ifTrue: [navigator color: Color lightBlue]. armsLengthCmd ifNotNil: [armsLengthCmd openInWorld: world]. Smalltalk isMorphic ifTrue: [world reformulateUpdatingMenus. world presenter positionStandardPlayer]. WorldState addDeferredUIMessage: [self startResourceLoading].! ! !ProjectLoading class methodsFor: 'public' stamp: 'yo 7/14/2009 11:23'! loadName: aFileName stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView "Reconstitute a Morph from the selected file, presumed to be represent a Morph saved via the SmartRefStream mechanism, and open it in an appropriate Morphic world." | morphOrList archive mgr substituteFont numberOfFontSubstitutes resultArray anObject project manifests dict oldProject | (self checkStream: preStream) ifTrue: [^ self]. ProgressNotification signal: '0.2'. archive _ preStream isZipArchive ifTrue:[ZipArchive new readFrom: preStream] ifFalse:[nil]. manifests _ (archive membersMatching: '*manifest'). (manifests size = 1 and: [((dict _ self parseManifest: manifests first contents) at: 'Project-Format' ifAbsent: []) = 'S-Expression']) ifTrue: [^ self loadSexpProjectDict: dict stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView]. morphOrList _ self morphOrList: aFileName stream: preStream fromDirectory: aDirectoryOrNil archive: archive. morphOrList ifNil: [^ self]. ProgressNotification signal: '0.4'. resultArray _ self fileInName: aFileName archive: archive morphOrList: morphOrList. anObject _ resultArray first. numberOfFontSubstitutes _ resultArray second. substituteFont _ resultArray third. mgr _ resultArray fourth. preStream close. ProgressNotification signal: '0.7'. "the hard part is over" (anObject isKindOf: ImageSegment) ifTrue: [ project _ self loadImageSegment: anObject fromDirectory: aDirectoryOrNil withProjectView: existingView numberOfFontSubstitutes: numberOfFontSubstitutes substituteFont: substituteFont mgr: mgr. oldProject := manifests isEmpty or: [((dict at: 'Squeak-Version') beginsWith: 'etoys') not]. project projectParameterAt: #oldProject put: oldProject. ProgressNotification signal: '0.8'. ^ project ].! ! !ProjectLoading class methodsFor: 'public' stamp: 'yo 7/13/2009 13:29'! openName: aFileName stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView "Reconstitute a Morph from the selected file, presumed to be represent a Morph saved via the SmartRefStream mechanism, and open it in an appropriate Morphic world." | morphOrList archive mgr substituteFont numberOfFontSubstitutes resultArray anObject project manifests dict oldProject | (self checkStream: preStream) ifTrue: [^ self]. ProgressNotification signal: '0.2'. archive _ preStream isZipArchive ifTrue:[ZipArchive new readFrom: preStream] ifFalse:[nil]. archive ifNotNil:[ manifests _ (archive membersMatching: '*manifest'). (manifests size = 1 and: [((dict _ self parseManifest: manifests first contents) at: 'Project-Format' ifAbsent: []) = 'S-Expression']) ifTrue: [^ self openSexpProjectDict: dict stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView]]. morphOrList _ self morphOrList: aFileName stream: preStream fromDirectory: aDirectoryOrNil archive: archive. morphOrList ifNil: [^ self]. ProgressNotification signal: '0.4'. resultArray _ self fileInName: aFileName archive: archive morphOrList: morphOrList. anObject _ resultArray first. numberOfFontSubstitutes _ resultArray second. substituteFont _ resultArray third. mgr _ resultArray fourth. preStream close. ProgressNotification signal: '0.7'. "the hard part is over" (anObject isKindOf: ImageSegment) ifTrue: [ project _ self loadImageSegment: anObject fromDirectory: aDirectoryOrNil withProjectView: existingView numberOfFontSubstitutes: numberOfFontSubstitutes substituteFont: substituteFont mgr: mgr.]. (anObject isKindOf: ImageSegment) ifTrue: [ oldProject := manifests isEmpty or: [((dict at: 'Squeak-Version') beginsWith: 'etoys') not]. project projectParameterAt: #oldProject put: oldProject. ProgressNotification signal: '0.8'. ^ project ifNil: [self inform: 'No project found in this file' translated] ifNotNil: [ProjectEntryNotification signal: project]]. self loadSqueakPage: anObject! ! !SugarLibrary methodsFor: 'icon images' stamp: 'sw 5/30/2009 01:12'! iconAt: aName ifAbsent: aBlock "If the IconDictionary has entry filed under the first argument, answer that entry; if not (e.g. during development) then answer the result of evaluating the block provided" ^ iconDictionary at: aName ifAbsent: [aBlock value]! ! !SugarLibrary methodsFor: 'icon images' stamp: 'sw 5/30/2009 01:13'! imageFor: aString color: aColor grayOutColor: grayOutColor "Answer an image corresponding to the given string, using the specified color scheme." | icon g h orig w height ret f | icon _ self iconAt: aString ifAbsent: [self iconAt: #missingIcon]. icon unhibernate. grayOutColor ifNotNil: [ f _ Form extent: icon extent depth: 32. f fillColor: grayOutColor. icon displayOn: f at: 0@0 rule: 37. icon _ f. ]. orig _ Form new hackBits: icon bits. height _ icon width * icon height. g _ Form extent: icon extent depth: 32. h _ Form new hackBits: g bits. w _ WarpBlt current toForm: h. w sourceForm: orig. w cellSize: 1. w combinationRule: Form over. w copyQuad: {1@0. 1@height. 2@height. 2@0} toRect: (0@0 corner: 4@(height + 1)). ret _ (Form extent: icon extent depth: 32) fillColor: aColor. g displayOn: ret at: 0 rule: 34. ^ ret asFormOfDepth: 16! ! !SugarLibrary methodsFor: 'icon images' stamp: 'sw 7/16/2009 14:59'! makeButton: aString balloonText: anotherString for: aSymbol target: target baseColor: baseColor highLightColor: highLightColor "Answer a SugarButton constructed from the arguments." | s keyString img | keyString _ aSymbol asString. s _ SugarButton new. img _ self iconAt: aString ifAbsent: [self iconAt: #missingIcon]. self recolorButton: s for: keyString baseColor: baseColor highLightColor: highLightColor. s extent: img extent + (25@25). s target: target. s actionSelector: aSymbol. s setBalloonText: anotherString. ^ s! ! !SugarLibrary class methodsFor: 'singleton management' stamp: 'mz 7/6/2009 01:07'! newDefault "Answer a new instance of SugarLibrary." | i | i _ SugarLibrary new. "i loadFrom: (FileDirectory on: 'C:\tmp\SugarEtoysIcon\SugarEtoysIcon\32x32')." i iconAt: 'new' put: self newIcon. i iconAt: 'prev' put: self prevIcon. i iconAt: 'next' put: self nextIcon. i iconAt: 'save' put: self saveIcon. i iconAt: 'open' put: self openIcon. i iconAt: 'paint' put: self paintIcon. i iconAt: 'language' put: self languageIcon. i iconAt: 'undo' put: self undoIcon. i iconAt: 'close' put: self closeIcon. i iconAt: 'share' put: self shareIcon. i iconAt: 'miniShare' put: self miniShareIcon. i iconAt: 'supplies' put: self suppliesIcon. i iconAt: 'stop' put: self stopIcon. i iconAt: 'zoom' put: self zoomIcon. i iconAt: 'help' put: self helpIcon. i iconAt: 'miniPrivate' put: self miniPrivateIcon. i iconAt: 'private' put: self privateIcon. i iconAt: 'hideNavBar' put: self hideNavBarIcon. i iconAt: 'showNavBar' put: self showNavBarIcon. i iconAt: 'newProject' put: (i iconAt: 'new'). i iconAt: 'previousProject' put: (i iconAt: 'prev'). i iconAt: 'nextProject' put: (i iconAt: 'next'). i iconAt: 'publishProject' put: (i iconAt: 'save'). i iconAt: 'findAProjectSimple' put: (i iconAt: 'open'). i iconAt: 'chooseObject' put: (i iconAt: 'open'). i iconAt: 'doNewPainting' put: (i iconAt: 'paint'). i iconAt: 'chooseLanguage' put: (i iconAt: 'language'). i iconAt: 'undoOrRedoLastCommand' put: (i iconAt: 'undo'). i iconAt: 'toggleSupplies' put: (i iconAt: 'supplies'). i iconAt: 'quitSqueak' put: (i iconAt: 'close'). i iconAt: 'shareThisWorld' put: (i iconAt: 'share'). i iconAt: 'shareMenu' put: (i iconAt: 'private'). i iconAt: 'chooseScreenSetting' put: (i iconAt: 'zoom'). i iconAt: 'stopSqueak' put: (i iconAt: 'stop'). i iconAt: 'toggleHelp' put: (i iconAt: 'help'). i iconAt: 'missingIcon' put: (i iconAt: 'private'). ^ i ! ! !SugarLibrary class methodsFor: 'icons' stamp: 'mz 7/11/2009 00:29'! hideNavBarIcon "Answer a form with the hideNavBar picture" ^ Form extent: 50@50 depth: 32 bits: (Base64MimeConverter mimeDecodeToBytes: '6cThmQC5/xEAuf8RALn/EQC5/xEAuf8RALn/EQC5/xEAuf8RAGn/MQAh/xEAaf8xACH/EQBp /zEAIf8RAIH/GQAh/xEAff8dACH/EQB5/yEAIf8RAHX/FQAF/w0AIf8RAHH/FQAJ/w0AIf8R AG3/FQAN/w0AIf8RAGn/FQAR/w0AIf8RAGX/FQAV/w0AIf8RAGX/EQAZ/w0AIf8RAGX/DQBJ /xEAuf8RALn/EQC5/xEAuf8RACH/DQAd/w0AZf8RACH/DQAZ/xEAZf8RACH/DQAV/xUAZf8R ACH/DQAR/xUAaf8RACH/DQAN/xUAbf8RACH/DQAJ/xUAcf8RACH/DQAF/xUAdf8RACH/IQB5 /xEAIf8dAH3/EQAh/xkAgf8RACH/NQBl/xEAIf81AGX/EQAh/zUAZf8RALn/EQC5/xEAuf8R ALn/EQC5/xEAuf8RALn/EQC5/+GZAA==' readStream) contents. ! ! !SugarLibrary class methodsFor: 'icons' stamp: 'mz 7/6/2009 01:13'! showNavBarIcon "Answer a form with the showNavBar picture" ^ Form extent: 50@50 depth: 32 bits: (Base64MimeConverter mimeDecodeToBytes: '6cThmQC1/xUAtf8VALX/FQC1/xUAtf8VALX/FQC1/xUAtf8VAI3/DQAd/xUAYf8NAB3/EQAd /xUAYf8NABn/FQAd/xUAYf8NABX/FQAh/xUAYf8NABH/FQAl/xUAYf8NAA3/FQAp/xUAYf8N AAn/FQAt/xUAYf8NAAX/FQAx/xUAYf8hADX/FQBh/x0AOf8VAGH/GQA9/xUAYf81ACH/FQBh /zUAIf8VAGH/NQAh/xUAtf8VALX/FQC1/xUAIf81AGH/FQAh/zUAYf8VACH/NQBh/xUAPf8Z AGH/FQA5/x0AYf8VADX/IQBh/xUAMf8VAAX/DQBh/xUALf8VAAn/DQBh/xUAKf8VAA3/DQBh /xUAJf8VABH/DQBh/xUAIf8VABX/DQBh/xUAIf8RABn/DQBh/xUAIf8FAAsE////AAAAAB3/ DQBh/xUAtf8VALX/FQC1/xUAtf8VALX/FQC1/xUAtf8VALX/4Z0A' readStream) contents! ! !SugarNavigatorBar methodsFor: 'initialization' stamp: 'sw 7/7/2009 08:55'! configureForSqueakland "Formerly -- have a narrow, green bar. Now: just use the standard." "self naviHeight: 40. self color: Color green muchDarker highLightColor: Color green darker."! ! !SugarNavigatorBar methodsFor: 'initialization' stamp: 'sw 7/6/2009 16:09'! makeTheSimpleButtons "Add the buttons for use in normal kids' mode." ^ {self buttonHelp}, ( true "SugarLauncher current isRunningInSugar" ifTrue: [{self makeProjectNameLabel}] ifFalse: [#()] ), { "self buttonNewProject." self buttonPrev. "self buttonNext." "self buttonFind." self buttonPaint. self buttonSupplies. }, " ( Preferences includeSoundControlInNavigator ifTrue: [{self buttonSound}] ifFalse: [#()] )," { self buttonUndo. self buttonLanguage. self buttonShare. }, (((DisplayScreen actualScreenSize = OLPCVirtualScreen virtualScreenExtent) ifFalse: [{self buttonZoom}] ifTrue: [#()])), { #spacer. self buttonFind. self buttonPublish. self buttonStop. }, (Preferences navControlInNavBar ifTrue: [{self buttonHideNavBar}] ifFalse: [#()])! ! !SugarNavigatorBar methodsFor: 'initialization' stamp: 'sw 7/16/2009 14:50'! makeTheSimpleButtonsSqueakland "Add the buttons for use in normal kids' mode." ^ {self buttonHelp}, { self makeProjectNameLabel. self buttonNewProject. self buttonPrev. self buttonNext. self buttonPaint. self buttonSupplies. }, " ( Preferences includeSoundControlInNavigator ifTrue: [{self buttonSound}] ifFalse: [#()] )," { self buttonUndo. self buttonLanguage. "self buttonShare." }, (((DisplayScreen actualScreenSize = OLPCVirtualScreen virtualScreenExtent) ifFalse: [{self buttonZoom}] ifTrue: [#()])), { #spacer. self buttonFind. self buttonPublish. self buttonStop. }, (Preferences navControlInNavBar ifTrue: [{self buttonHideNavBar}] ifFalse: [#()]) ! ! !SugarNavigatorBar methodsFor: 'morphic interaction' stamp: 'sw 7/16/2009 15:02'! checkForResize "Check to see if the receiver needs to be reconfigured because of a world resize." | shouldResize h worldBounds inset | (owner isKindOf: SugarNavTab) ifFalse: [^ self]. "e.g. being held by hand." owner edgeToAdhereTo = #topRight ifTrue: [^ owner occupyTopRightCorner]. shouldResize _ false. worldBounds _ self world bounds. (self layoutInset ~= (inset _ SugarLauncher isRunningInSugar ifTrue: [75@0] ifFalse: [0@0])) ifTrue: [self layoutInset: inset]. worldBounds width ~= self width ifTrue: [shouldResize _ true]. Preferences useArtificialSweetenerBar ifTrue: [ h _ submorphs first submorphs first height. (worldBounds extent x >= 1200 and: [worldBounds extent y >= 900]) ifTrue: [ h = 40 ifTrue: [self naviHeight: 75. shouldResize _ true]] ifFalse: [h = 75 ifTrue: [self naviHeight: 40. shouldResize _ true]]]. (h _ submorphs first submorphs first height) ~= self height ifTrue: [shouldResize _ true]. (owner notNil and: [owner isFlapTab]) ifTrue: [ owner edgeToAdhereTo == #top ifTrue: [ self topLeft ~= worldBounds topLeft ifTrue: [shouldResize _ true]. ]. owner edgeToAdhereTo == #bottom ifTrue: [ self bottomLeft ~= worldBounds bottomLeft ifTrue: [shouldResize _ true]. ]. shouldResize ifTrue: [ owner edgeToAdhereTo == #top ifTrue: [ self bounds: (0@0 corner: (worldBounds width@h)). ]. owner edgeToAdhereTo == #bottom ifTrue: [ self bounds: (0@(worldBounds height - h) corner: (worldBounds bottomRight)). ]. self resizeProjectNameField. owner layoutChanged. ]. ].! ! !SugarNavigatorBar methodsFor: 'morphic interaction' stamp: 'sw 5/30/2009 02:46'! resizeButtonsAndTabTo: newDim "Resize the receiver's buttons and containing tab to conform to the given dimension." | frame | submorphs ifNotEmpty: [frame := submorphs first. frame submorphs do: [:e | e naviHeight: newDim]. frame height: newDim. supplies ifNotNil: [supplies naviHeight: newDim]]! ! !SugarNavigatorBar methodsFor: 'morphic interaction' stamp: 'sw 5/30/2009 01:23'! showOnlyShowNavBarButton "Reconfigure the receiver such that it only shows the show-nav-bar button" self removeAllMorphs. self addMorph: (self inARow: {self buttonShowNavBar}). self hResizing: #shrinkWrap. Preferences useArtificialSweetenerBar ifTrue: [self configureForSqueakland].! ! !SugarNavigatorBar methodsFor: 'buttons creation' stamp: 'sw 7/8/2009 11:21'! buttonHideNavBar "Build and return a fresh HideNavBarButton" ^ self makeButton: 'hideNavBar' balloonText: 'hide the tool bar' translated for: #hideNavBar ! ! !SugarNavigatorBar methodsFor: 'buttons creation' stamp: 'sw 7/8/2009 11:21'! buttonShowNavBar "Build and return a fresh button for showing the nav-bar." ^ self makeButton: 'showNavBar' balloonText: 'show the tool bar' translated for: #showNavBar ! ! !SugarNavigatorBar methodsFor: 'button actions' stamp: 'sw 5/29/2009 16:52'! hideNavBar "Reconfigure the nav-bar such that it only shows the 'show nav bar' icon at right edge" owner hideNavBar! ! !SugarNavigatorBar methodsFor: 'event handling' stamp: 'sw 5/29/2009 17:14'! showNavBar "Show the full sugar nav bar." owner showNavBar! ! !SugarNavTab methodsFor: 'initialization' stamp: 'sw 5/30/2009 02:26'! hideNavBar "Hide the nav bar." self setProperty: #collapsedMode toValue: true. referent delete. referent showOnlyShowNavBarButton. self hResizing: #shrinkWrap. self edgeToAdhereTo: #topRight. self occupyTopRightCorner. self addMorphBack: referent! ! !SugarNavTab methodsFor: 'initialization' stamp: 'sw 5/29/2009 18:38'! showNavBar "Show the full nav-bar across the top of the screen." self removeProperty: #collapsedMode. referent delete. referent removeAllMorphs; addButtons; hResizing: #spaceFill. Preferences useArtificialSweetenerBar ifTrue: [referent configureForSqueakland]. self hResizing: #spaceFill. self edgeToAdhereTo: #top. self position: 0@0. self addMorph: referent! ! !SugarNavTab methodsFor: 'positioning' stamp: 'sw 5/29/2009 18:36'! collapsedMode "Answer whether the receiver is currently showing only as a single open-nav-bar button at top-right of the screen." ^ self hasProperty: #collapsedMode! ! !SugarNavTab methodsFor: 'positioning' stamp: 'sw 6/5/2009 14:46'! occupyTopRightCorner "Make the receiver be the correct size, and occupy the top-right corner of the screen." | worldBounds toUse | worldBounds := ActiveWorld bounds. " toUse := Preferences useArtificialSweetenerBar ifFalse: [75] ifTrue: [(ActiveWorld extent >= (1200 @ 900)) ifTrue: [75] ifFalse: [40]]." toUse := 40. "Trying for the moment to use the smaller icon always when in this mode." referent height: toUse; resizeButtonsAndTabTo: toUse. self extent: toUse @ toUse. self topRight: worldBounds topRight! ! !SugarNavTab methodsFor: 'positioning' stamp: 'sw 5/30/2009 02:07'! spanWorld "Make the receiver's height or width commensurate with that of the container." | container | self collapsedMode ifTrue: [^ self occupyTopRightCorner]. container _ self pasteUpMorph ifNil: [self currentWorld]. (self orientation == #vertical) ifTrue: [ referent vResizing == #rigid ifTrue:[referent spanContainerVertically: container height]. referent hResizing == #rigid ifTrue:[referent width: (referent width min: container width - self width)]. referent top: container top + self referentMargin y. ] ifFalse: [ referent hResizing == #rigid ifTrue:[referent width: container width]. referent vResizing == #rigid ifTrue:[referent height: (referent height min: container height - self height)]. referent left: container left + self referentMargin x. ] ! ! "Postscript:" SugarLibrary clearDefault. SugarNavigatorBar allInstancesDo: [:m | m sugarLib: nil]. Preferences addPreference: #navControlInNavBar category: 'flaps' default: true balloonHelp: 'if true, a control will always be present at the top-right corner of the screen, to toggle the presence/absence of the nav bar itself'. (ActiveWorld findA: SugarNavTab) ifNotNilDo: [:aTab | aTab hideNavBar; showNavBar]. !