forked from desromech/sysmel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I am making progress with the tree view morph.
- Loading branch information
Showing
19 changed files
with
319 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
package-sources/Morphic.Core/BasicDevelopmentEnvironment.sysmel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
public class BasicDevelopmentEnvironment superclass: PanelMorph; definition: { | ||
public override method initialize => Void := { | ||
super initialize. | ||
|
||
let workspaceButton := SimpleButtonMorph new | ||
label: "Workspace"; | ||
when: MorphActivatedAnnouncement do: {:: Void | Workspace new openInWindowSystem}; | ||
yourself. | ||
|
||
let systemBrowserButton := SimpleButtonMorph new | ||
label: "System Browser"; | ||
when: MorphActivatedAnnouncement do: {:: Void | SystemBrowser new openInWindowSystem}; | ||
yourself. | ||
|
||
self | ||
addMorph: workspaceButton; | ||
addMorph: systemBrowserButton; | ||
layout: (MorphVerticalBoxLayout new | ||
add: workspaceButton; | ||
add: systemBrowserButton; | ||
yourself | ||
) | ||
}. | ||
|
||
public override method defaultExtent => Float32x2 := 150f32@100f32. | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
public abstract class DataSource definition: { | ||
public field onUpdate => (() => Void). | ||
|
||
public abstract method numberOfElements => Size | ||
:= self subclassResponsibility. | ||
|
||
public abstract method elementModelAtRow: (rowIndex: Size) ::=> AnyValue | ||
:= self subclassResponsibility. | ||
|
||
public abstract method elementAtRow: (rowIndex: Size) ::=> AnyValue | ||
:= self subclassResponsibility. | ||
|
||
public virtual method depthOfRow: (rowIndex: Size) ::=> UInt32 | ||
:= 0u32. | ||
|
||
public method notifyUpdates => Void := { | ||
onUpdate ifNotNil: { | ||
onUpdate() | ||
} | ||
}. | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public class PanelMorph superclass: BorderedMorph; definition: { | ||
public override method defaultColor => Color := Color transparent. | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
package-sources/Morphic.Core/SimpleTreeDataSource.sysmel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
public class SimpleTreeDataSource superclass: DataSource. | ||
|
||
public class SimpleTreeDataSourceElement definition: { | ||
public field depth => UInt32. | ||
public field dataSource => SimpleTreeDataSource. | ||
public field value => AnyValue. | ||
public field isExpanded => Boolean. | ||
public field children => OrderedCollection. | ||
|
||
public method validExpandedChildrenWithBlock: (childrenBlock: (AnyValue) => Collection) ::=> OrderedCollection := { | ||
children ifNotNil: {return: children}. | ||
|
||
children := OrderedCollection new. | ||
let childrenCollection := childrenBlock(value). | ||
childrenCollection ifNotNil: { | ||
childrenCollection do: {:eachChild :: Void | | ||
children add: (SimpleTreeDataSourceElement new | ||
depth: depth + 1u32; | ||
dataSource: dataSource; | ||
value: eachChild; | ||
yourself) | ||
} | ||
}. | ||
|
||
children | ||
}. | ||
|
||
public method expand => Void := { | ||
isExpanded ifTrue: {return: void}. | ||
|
||
isExpanded := true. | ||
dataSource elementExpansionChanged: self. | ||
}. | ||
|
||
public method collapse => Void := { | ||
isExpanded ifFalse: {return: void}. | ||
|
||
isExpanded := false. | ||
dataSource elementExpansionChanged: self. | ||
}. | ||
|
||
public method toggleExpansion => Void := { | ||
isExpanded := isExpanded not. | ||
dataSource elementExpansionChanged: self. | ||
}. | ||
|
||
public method hasChildren => Boolean | ||
:= children isNil || children isNotEmpty. | ||
}. | ||
|
||
SimpleTreeDataSource definition: { | ||
let ChildrenBlock := (AnyValue) => Collection. | ||
|
||
protected field roots => OrderedCollection. | ||
protected field expandedItems => OrderedCollection. | ||
public field childrenBlock => ChildrenBlock. | ||
|
||
public override method initialize => Void := { | ||
super initialize. | ||
roots := OrderedCollection new. | ||
expandedItems := OrderedCollection new. | ||
}. | ||
|
||
public override method numberOfElements => Size | ||
:= expandedItems size. | ||
|
||
public override method elementModelAtRow: (rowIndex: Size) ::=> AnyValue | ||
:= rowIndex < expandedItems size | ||
ifTrue: (expandedItems at: rowIndex) | ||
ifFalse: nil. | ||
|
||
public override method elementAtRow: (rowIndex: Size) ::=> AnyValue | ||
:= rowIndex < expandedItems size | ||
ifTrue: (expandedItems at: rowIndex) value | ||
ifFalse: nil. | ||
|
||
public override method depthOfRow: (rowIndex: Size) ::=> UInt32 | ||
:= rowIndex < expandedItems size | ||
ifTrue: (expandedItems at: rowIndex) depth | ||
ifFalse: 0u32. | ||
|
||
public method roots: (newRoots: Collection) ::=> Void := { | ||
roots := OrderedCollection new. | ||
newRoots do: {:element :: Void | | ||
roots add: (SimpleTreeDataSourceElement new | ||
depth: 0u32; | ||
dataSource: self; | ||
value: element; | ||
yourself) | ||
}. | ||
|
||
self recomputeExpandedElements. | ||
}. | ||
|
||
public method recomputeExpandedElements => Void := { | ||
expandedItems := OrderedCollection new. | ||
roots do: {:(SimpleTreeDataSourceElement)each :: Void | | ||
self addElementWithExpandedChildrenFrom: each | ||
}. | ||
|
||
self notifyUpdates | ||
}. | ||
|
||
public method elementExpansionChanged: (element: SimpleTreeDataSourceElement) ::=> Void := { | ||
self recomputeExpandedElements | ||
}. | ||
|
||
public method addElementWithExpandedChildrenFrom: (element: SimpleTreeDataSourceElement) ::=> Void := { | ||
expandedItems add: element. | ||
element isExpanded ifFalse: {return: void}. | ||
|
||
(element validExpandedChildrenWithBlock: childrenBlock) do: {:(SimpleTreeDataSourceElement)eachChild :: Void | | ||
self addElementWithExpandedChildrenFrom: eachChild | ||
} | ||
}. | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
public class SystemBrowser superclass: PanelMorph; definition: { | ||
protected field sourceCodeEditor => SourceCodeEditorMorph. | ||
|
||
public override method initialize => Void := { | ||
super initialize. | ||
}. | ||
|
||
public override method defaultExtent => Float32x2 := 600f32@400f32. | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.