[squeak-dev] The Trunk: Morphic-mt.741.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Aug 12 07:42:52 UTC 2014
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.741.mcz
==================== Summary ====================
Name: Morphic-mt.741
Author: mt
Time: 12 August 2014, 9:41:14.858 am
UUID: 9d4c5a48-0e25-9f40-b973-d743955f6e31
Ancestors: Morphic-eem.740, Morphic-mt.721
Fixed implementation for adding multiple morphs at once. Made API of addMorph* and addAllMorphs* more consistent w.r.t. index handling. (merged from inbox Morphic-mt.721)
=============== Diff against Morphic-eem.740 ===============
Item was changed:
----- Method: Morph>>addAllMorphs: (in category 'submorphs-add/remove') -----
addAllMorphs: aCollection
+ ^self addAllMorphsBack: aCollection!
- ^self privateAddAllMorphs: aCollection atIndex: submorphs size!
Item was changed:
----- Method: Morph>>addAllMorphs:after: (in category 'submorphs-add/remove') -----
addAllMorphs: aCollection after: anotherMorph
+ ^self addAllMorphs: aCollection behind: anotherMorph!
- ^self privateAddAllMorphs: aCollection
- atIndex: (submorphs indexOf: anotherMorph ifAbsent: [submorphs size])!
Item was added:
+ ----- Method: Morph>>addAllMorphs:behind: (in category 'submorphs-add/remove') -----
+ addAllMorphs: aCollection behind: anotherMorph
+ ^self privateAddAllMorphs: aCollection
+ atIndex: (submorphs indexOf: anotherMorph) + 1!
Item was added:
+ ----- Method: Morph>>addAllMorphs:inFrontOf: (in category 'submorphs-add/remove') -----
+ addAllMorphs: aCollection inFrontOf: anotherMorph
+ ^self privateAddAllMorphs: aCollection
+ atIndex: ((submorphs indexOf: anotherMorph) max: 1)!
Item was added:
+ ----- Method: Morph>>addAllMorphsBack: (in category 'submorphs-add/remove') -----
+ addAllMorphsBack: aCollection
+ ^self privateAddAllMorphs: aCollection atIndex: submorphs size + 1!
Item was added:
+ ----- Method: Morph>>addAllMorphsFront: (in category 'submorphs-add/remove') -----
+ addAllMorphsFront: aCollection
+ ^self privateAddAllMorphs: aCollection atIndex: 1!
Item was changed:
----- Method: Morph>>addMorph:after: (in category 'submorphs-add/remove') -----
addMorph: newMorph after: aMorph
+ ^self addMorph: newMorph behind: aMorph!
- "Add the given morph as one of my submorphs, inserting it after anotherMorph"
- ^self privateAddMorph: newMorph atIndex: (submorphs indexOf: aMorph)+1!
Item was changed:
----- Method: Morph>>privateAddAllMorphs:atIndex: (in category 'private') -----
privateAddAllMorphs: aCollection atIndex: index
"Private. Add aCollection of morphs to the receiver"
+ | myWorld otherSubmorphs offset |
+ (index between: 1 and: submorphs size+1)
+ ifFalse: [^ self error: 'index out of range'].
- | myWorld otherSubmorphs |
myWorld := self world.
otherSubmorphs := submorphs copyWithoutAll: aCollection.
+ offset := aCollection count: [:m | (submorphs indexOf: m) between: 1 and: index - 1].
+ submorphs := otherSubmorphs copyReplaceFrom: index-offset to: index-offset-1 with: aCollection.
- (index between: 0 and: otherSubmorphs size)
- ifFalse: [^ self error: 'index out of range'].
- index = 0
- ifTrue:[ submorphs := aCollection asArray, otherSubmorphs]
- ifFalse:[ index = otherSubmorphs size
- ifTrue:[ submorphs := otherSubmorphs, aCollection]
- ifFalse:[ submorphs := otherSubmorphs copyReplaceFrom: index + 1 to: index with: aCollection ]].
aCollection do: [:m | | itsOwner itsWorld |
itsOwner := m owner.
itsOwner ifNotNil: [
itsWorld := m world.
(itsWorld == myWorld) ifFalse: [
itsWorld ifNotNil: [self privateInvalidateMorph: m].
m outOfWorld: itsWorld].
(itsOwner ~~ self) ifTrue: [
m owner privateRemove: m.
m owner removedMorph: m ]].
m privateOwner: self.
myWorld ifNotNil: [self privateInvalidateMorph: m].
(myWorld == itsWorld) ifFalse: [m intoWorld: myWorld].
itsOwner == self ifFalse: [
self addedMorph: m.
m noteNewOwner: self ].
].
self layoutChanged.
!
More information about the Squeak-dev
mailing list
|