Skip to content

Commit

Permalink
Start of refactor to not rely on colorAll: in outliner code
Browse files Browse the repository at this point in the history
  • Loading branch information
russellallen committed Jan 8, 2015
1 parent 08e3b30 commit 7aef6e8
Show file tree
Hide file tree
Showing 15 changed files with 464 additions and 115 deletions.
62 changes: 62 additions & 0 deletions objects/ui2/desktop.self
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,68 @@ SlotsToOmit: comment directory fileInTimeString myComment postFileIn revision su
subpartNames <- ''.
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> () From: ( | {
'Category: ui2\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

desktop = bootstrap setObjectAnnotationOf: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( |
{} = 'ModuleInfo: Creator: globals preferences desktop.
'.
| ) .
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Comment: At the moment, all worlds are the same color.\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

backgroundColor = ( |
| backgroundColor: raw. raw).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'ModuleInfo: Module: desktop InitialContents: FollowSlot'

backgroundColor: aPaint = ( |
| desktop worldsDo: [|:w| w color: aPaint]. raw: aPaint).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Category: example colors\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

gray44 = ( |
| (paint named: 'gray') copyBrightness: 0.93).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Category: example colors\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

offWhite = ( |
|
paint copyRed: 16rF6 / 16rFF asFloat
Green: 16rF6 / 16rFF asFloat
Blue: 16rF6 / 16rFF asFloat).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Category: private\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

p* = bootstrap stub -> 'traits' -> 'oddball' -> ().
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Category: private\x7fModuleInfo: Module: desktop InitialContents: InitializeToExpression: (paint named: \'white\')'

raw <- paint named: 'white'.
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'preferences' -> 'desktop' -> () From: ( | {
'Category: example colors\x7fModuleInfo: Module: desktop InitialContents: FollowSlot'

warmWhite = ( |
|
paint copyRed: 16rFD asFloat / 16rFF asFloat
Green: 16rFD asFloat / 16rFF asFloat
Blue: 16rF0 asFloat / 16rFF asFloat).
} | )



'-- Side effects'
Expand Down
14 changes: 10 additions & 4 deletions objects/ui2/morph.self
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'Sun-$Revision: 30.17 $'
'
Copyright 1992-2012 AUTHORS.
See the LICENSE file for license information.
Copyright 1992-2011 AUTHORS.
See the legal/LICENSE file for license information and legal/AUTHORS for authors.
'


Expand Down Expand Up @@ -1448,7 +1448,6 @@ by the change.\x7fModuleInfo: Module: morph InitialContents: FollowSlot\x7fVisib
anyway. The layout of such a morph will be computed if
and when it is first added to the world or to some morph
that is already in the world."

flushLayoutCaches.

"base case: not in the world; just flush layout caches"
Expand Down Expand Up @@ -1906,6 +1905,13 @@ old owner.\x7fModuleInfo: Module: morph InitialContents: FollowSlot\x7fVisibilit
vector copyAddLast: (resizingPropsMorph copyTarget: self)).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'morph' -> () From: ( | {
'Category: basics\x7fComment: Like colorAll: but allows morphs to choose their own suitable colors\x7fModuleInfo: Module: morph InitialContents: FollowSlot'

recolor = ( |
| morphsDo: [|:m| m recolor]. self).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'morph' -> () From: ( | {
'Category: structure\x7fComment: Remove all morphs from this morph.\x7fModuleInfo: Module: morph InitialContents: FollowSlot\x7fVisibility: public'

Expand Down Expand Up @@ -2191,7 +2197,7 @@ and rawOwner.\x7fModuleInfo: Module: morph InitialContents: FollowSlot\x7fVisibi
bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'morph' -> () From: ( | {
'Category: drawing\x7fModuleInfo: Module: morph InitialContents: FollowSlot\x7fVisibility: public'

shadowColor <- paint named: 'black'.
shadowColor <- paint named: 'transparent'.
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'morph' -> () From: ( | {
Expand Down
8 changes: 4 additions & 4 deletions objects/ui2/morphLib.self
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'$Revision: 30.18 $'
'
Copyright 1992-2012 AUTHORS.
See the LICENSE file for license information.
Copyright 1992-2011 AUTHORS.
See the legal/LICENSE file for license information and legal/AUTHORS for authors.
'


Expand Down Expand Up @@ -640,9 +640,9 @@ SlotsToOmit: parent prototype.
|
"See comment in traits morph for general idea.
Here, for readability, do not change color."

morphsDo: [| :m | m colorAll: newC ].
color: newC textColorForBackground.
"color: newC textColorForBackground."
" - disabled Aug13 rca to stop outliners coloring wrong"
self).
} | )

Expand Down
11 changes: 2 additions & 9 deletions objects/ui2/morphSaving.self
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'$Revision: 30.9 $'
'
Copyright 1992-2012 AUTHORS.
See the LICENSE file for license information.
Copyright 1992-2011 AUTHORS.
See the legal/LICENSE file for license information and legal/AUTHORS for authors.
'


Expand Down Expand Up @@ -1283,13 +1283,6 @@ SlotsToOmit: comment directory fileInTimeString myComment postFileIn revision su
slotsInModuleMorph).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'smallEditorMorph' -> () From: ( | {
'Category: filing out\x7fModuleInfo: Module: morphSaving InitialContents: FollowSlot\x7fVisibility: public'

prototype = ( |
| smallEditorMorph).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'spacerMorph' -> () From: ( | {
'Category: filing out\x7fModuleInfo: Module: morphSaving InitialContents: FollowSlot\x7fVisibility: public'

Expand Down
20 changes: 4 additions & 16 deletions objects/ui2/outliner/generalLeafModel.self
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'$Revision: 30.7 $'
'
Copyright 1992-2012 AUTHORS.
See the LICENSE file for license information.
Copyright 1992-2011 AUTHORS.
See the legal/LICENSE file for license information and legal/AUTHORS for authors.
'


Expand Down Expand Up @@ -82,8 +82,8 @@ SlotsToOmit: parent.
' ' &
' ' ) asVector
Colors: (
(paint named: 'black') &
(paint named: 'black')) asVector] value) From: ( |
(paint named: 'transparent') &
(paint named: 'transparent')) asVector] value) From: ( |
{} = 'ModuleInfo: Creator: globals generalLeafModel parent buttonIcon.
\x7fIsComplete: '.
| ) .
Expand Down Expand Up @@ -149,18 +149,6 @@ I am also immutable.\x7fModuleInfo: Creator: globals generalLeafModel parent con
parent* = bootstrap stub -> 'globals' -> 'generalModel' -> 'parent' -> ().
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalLeafModel' -> 'parent' -> () From: ( | {
'Category: appearance\x7fModuleInfo: Module: generalLeafModel InitialContents: FollowSlot\x7fVisibility: public'

preferredColor = ( |
o.
|
o: myOutliner owner.
o isNil || [o isHandMorph] "don't change color when being carried"
ifTrue: [myOutliner color]
False: [o color]).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalLeafModel' -> 'parent' -> () From: ( | {
'Category: finding the slot in situ\x7fModuleInfo: Module: generalLeafModel InitialContents: FollowSlot\x7fVisibility: public'

Expand Down
30 changes: 15 additions & 15 deletions objects/ui2/outliner/generalModel.self
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ Index outliner should probably use something else.\x7fModuleInfo: Module: genera
|
myOutliner expander:
expanderMorph copyTarget: self Action: expanderAction.
myOutliner expander color:
preferredTitleColor.
myOutliner expander).
} | )

Expand All @@ -589,7 +591,8 @@ update the object\'s title\x7fModuleInfo: Module: generalModel InitialContents:
Target: myOutliner
Accept: acceptNameChange
Cancel: cancelNameChange
Style: titleStyle.
Style: titleStyle
LabelColor: preferredTitleColor.
titleEditor isAsynchronous: true.
myOutliner titleEditor: titleEditor.
titleEditor).
Expand Down Expand Up @@ -1578,7 +1581,8 @@ May cause me to expand if doExpand is true. -- dmu 10/04\x7fModuleInfo: Module:
bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalModel' -> 'parent' -> () From: ( | {
'Category: appearance\x7fModuleInfo: Module: generalModel InitialContents: FollowSlot\x7fVisibility: public'

preferredColor = paint named: 'gray'.
preferredColor = ( |
| preferences outliner currentColorScheme generalModel).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalModel' -> 'parent' -> () From: ( | {
Expand All @@ -1597,20 +1601,16 @@ May cause me to expand if doExpand is true. -- dmu 10/04\x7fModuleInfo: Module:
'Category: appearance\x7fModuleInfo: Module: generalModel InitialContents: FollowSlot'

preferredHeaderColor = ( |
s.
|
s: preferences outliner currentColorScheme.
((reflect: referrent) includesKey: 'mirror') ifTrue: [| m |
m: referrent mirror.
m isReflecteeFloat ifTrue: [^ s float].
m isReflecteeInteger ifTrue: [^ s integer].
m isReflecteeString ifTrue: [^ s string].
m creatorPathIfPresent: [|:p|
p first = 'traits' ifTrue: [^ s traits].
p first = 'mixins' ifTrue: [^ s mixins]]
IfAbsent: [ ^ s unnamed ].
^ s named]
False: [ ^ s unusual ]).
preferences outliner currentColorScheme headerColorFor: referrent).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalModel' -> 'parent' -> () From: ( | {
'Category: appearance\x7fModuleInfo: Module: generalModel InitialContents: FollowSlot'

preferredTitleColor = ( |
|
preferences outliner currentColorScheme titleColorFor: referrent).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'globals' -> 'generalModel' -> 'parent' -> () From: ( | {
Expand Down
59 changes: 52 additions & 7 deletions objects/ui2/outliner/outliner.self
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ Items are typically those shown when I am expanded.\x7fModuleInfo: Creator: trai
bs isEmpty ifFalse: [
header addMorphLast: flexibleSpacer copy.
header addAllMorphs: bs.
header colorAll: color.
].
self).
} | )
Expand Down Expand Up @@ -185,11 +184,12 @@ Items are typically those shown when I am expanded.\x7fModuleInfo: Creator: trai

buildButtonLabeled: lbl Script: s IsAsync: isa = ( |
|
(((ui2Button copy label: lbl
((((ui2Button copy label: lbl
FontSpec: headerButtonFontSpec
FontColor: ui2Button defaultFontColor)
FontColor: preferredTitleColor)
script: s)
isAsynchronous: isa)
color: preferredHeaderColor)
target: self).
} | )

Expand Down Expand Up @@ -222,7 +222,7 @@ Based on headerButtonContents\x7fModuleInfo: Module: outliner InitialContents: F

buildItemsHolder = ( |
|
items: columnMorph copy color: color.
items: columnMorph copy color: (paint named: 'transparent').
items borderWidth: 0.
items leftJustify.
items beFlexible.
Expand Down Expand Up @@ -266,6 +266,16 @@ such as annotations, comments, etc.\x7fModuleInfo: Module: outliner InitialConte
collapse: evt).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: initializing\x7fModuleInfo: Module: outliner InitialContents: FollowSlot'

colorForTag = ( |
|
"Go via lobby to make sure we don't interfere with
old preferences code"
lobby preferences outliner currentColorScheme tagColorFor: self).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: expanding and collapsing\x7fCategory: intended to be overriden\x7fComment: Override to add (boxed) items
to me when expanding.
Expand Down Expand Up @@ -391,12 +401,23 @@ Hack for asynchronous buttons: start script with an \"A\"\x7fModuleInfo: Module:
'Category: initializing\x7fModuleInfo: Module: outliner InitialContents: FollowSlot\x7fVisibility: private'

initialize = ( |
cm.
rm.
|
color: preferredColor.
removeAllMorphs.
rm: rowMorph copy beFlexible borderWidth: 0.

rm addMorphFirst:
(spacerMorph copyH: 3 Color: colorForTag).

cm: columnMorph copy beFlexible borderWidth: 0.
columnUnderHeader: newColumnUnderHeader.
addMorphLast: columnUnderHeader.
addMorphFirst: buildHeader.
color: preferredColor.
cm addMorphLast: columnUnderHeader.
cm addMorphFirst: buildHeader.
rm addMorphLast: cm.

addMorphLast: rm.
self).
} | )

Expand Down Expand Up @@ -458,6 +479,14 @@ outliner has non-items that might be counterfactual.\x7fModuleInfo: Module: outl
isSlotsOutliner = bootstrap stub -> 'globals' -> 'false' -> ().
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: color\x7fModuleInfo: Module: outliner InitialContents: FollowSlot'

layoutChanged = ( |
|
recolor. resend.layoutChanged).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: copying (part of morph copying frameword)\x7fModuleInfo: Module: outliner InitialContents: FollowSlot\x7fVisibility: public'

Expand Down Expand Up @@ -517,6 +546,22 @@ outliner has non-items that might be counterfactual.\x7fModuleInfo: Module: outl
preferences = bootstrap stub -> 'globals' -> 'outlinerPreferences' -> ().
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: building\x7fCategory: should be overridden\x7fModuleInfo: Module: outliner InitialContents: FollowSlot'

preferredTitleColor = paint named: 'transparent'.
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: color\x7fModuleInfo: Module: outliner InitialContents: FollowSlot'

recolor = ( |
|
color: paint named: 'blue'.
morphsDo: [|:m| m recolor].
self).
} | )

bootstrap addSlotsTo: bootstrap stub -> 'traits' -> 'outliner' -> () From: ( | {
'Category: adding & removing items in my expansion (called by children)\x7fModuleInfo: Module: outliner InitialContents: FollowSlot\x7fVisibility: private'

Expand Down
Loading

0 comments on commit 7aef6e8

Please sign in to comment.