'From etoys4.0 of 9 October 2008 [latest update: #2216] on 18 May 2009 at 1:57:44 am'! "Change Set: categoryFullyVisible-sw Date: 18 May 2009 Author: Scott Wallace When the user adds a new category-viewer to a viewer using the + button at the top of the viewer, make certain that all the contents of the category are fully visible, even that requires deleting another category viewer above the one in question. Similarly, when the user retargets a category viewer to show a new category, make certain that the newly-chosen category is fully visible, deleting a category-viewer above the one in question if necessary."! !CategoryViewer methodsFor: 'categories' stamp: 'sw 5/16/2009 05:48'! assureCategoryFullyVisible "Keep deleting categoryviewers other than the receiver until the receiver is fully visible." | ready toDelete | ready := false. [(self bounds bottom > ActiveWorld bottom) and: [ready not]] whileTrue: [owner submorphs size > 2 ifTrue: [toDelete :=owner submorphs allButFirst reversed detect: [:cv | cv ~~ self] ifNone: [^ self]. toDelete delete. ActiveWorld doOneCycleNow] ifFalse: [ready := true]]! ! !CategoryViewer methodsFor: 'categories' stamp: 'sw 5/16/2009 05:36'! chooseCategory "The mouse went down on my category-list control; pop up a list of category choices" | aList aMenu reply aLinePosition lineList special | Cursor wait showWhile: [ aList _ (scriptedPlayer categoriesForViewer: self) asOrderedCollection. special := {ScriptingSystem nameForScriptsCategory. ScriptingSystem nameForInstanceVariablesCategory}. aList removeAllFoundIn: special. aList := special, aList. aLinePosition _ aList indexOf: #miscellaneous ifAbsent: [nil]. aList _ aList collect: [:aCatSymbol | self currentVocabulary categoryWordingAt: aCatSymbol]. lineList _ aLinePosition ifNil: [#(2)] ifNotNil: [Array with: 2 with: aLinePosition]. aMenu _ CustomMenu labels: aList lines: lineList selections: aList. reply _ aMenu startUpWithCaption: 'category' translated. reply ifNil: [^ self]. self chooseCategoryWhoseTranslatedWordingIs: reply asSymbol. self assureCategoryFullyVisible ]! ! !StandardViewer methodsFor: 'categories' stamp: 'sw 5/16/2009 05:38'! addCategoryViewerFor: categoryInfo atEnd: atEnd "Add a category viewer for the given category info. If atEnd is true, add it at the end, else add it just after the header morph" | aViewer | Cursor wait showWhile: [ aViewer _ self categoryViewerFor: categoryInfo. atEnd ifTrue: [self addMorphBack: aViewer] ifFalse: [self addMorph: aViewer after: submorphs first]. aViewer establishContents. self world ifNotNil: [self world startSteppingSubmorphsOf: aViewer]. self fitFlap. aViewer assureCategoryFullyVisible ]. ! !