Skip to content

Commit

Permalink
Fill GDControl tree with React objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Feb 6, 2024
1 parent 7a02489 commit 5b0e408
Showing 1 changed file with 36 additions and 39 deletions.
75 changes: 36 additions & 39 deletions GReaSe-Tools/ComponentBrowserDworph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,36 @@ ComponentBrowserDworph >> fontSize [
^ 30
]

{ #category : #'as yet unclassified' }
ComponentBrowserDworph >> generateUIForFiber: aCMFFiber inTree: aGDTree withRoot: aGDTreeItem [

| currentItem |

aGDTreeItem ifNil: [currentItem := aGDTree createItem] ifNotNil: [currentItem := aGDTree createItemParent: aGDTreeItem].
currentItem
setTextColumn: 0 text: (aCMFFiber node asString copyWithRegex: '[\<\/\>]' matchesReplacedWith: '').

^ {
currentItem.
aCMFFiber sibling ifNotNil: [self generateUIForFiber: aCMFFiber sibling inTree: aGDTree withRoot: aGDTreeItem].
aCMFFiber child ifNotNil: [self generateUIForFiber: aCMFFiber child inTree: aGDTree withRoot: currentItem].
}
]

{ #category : #'as yet unclassified' }
ComponentBrowserDworph >> hashTree: aCMFFiber [

| sum |

sum := 0.

^ sum
]

{ #category : #'as yet unclassified' }
ComponentBrowserDworph >> render: props [

| viewportTransform viewport spatial raycastPosStart raycastPosEnd world movingButton |
| viewportTransform viewport spatial raycastPosStart raycastPosEnd world movingButton rootFiber treeRef |

"---Only needed for debug---"
world := self useWorldPortal.
Expand All @@ -31,18 +57,22 @@ ComponentBrowserDworph >> render: props [
viewportTransform := self useState: nil.
viewport := self useGodotRef.
spatial := self useGodotRef.
rootFiber := (((GRReact current instVarNamed: #sessions) associations first value) instVarNamed: #react) currentRoot.
treeRef := self useGodotRef.
self useEffect: [
treeRef get ifNotNil: [:tree |
tree clear.
self generateUIForFiber: rootFiber inTree: tree withRoot: nil]]
dependencies: {treeRef get ifNotNil: [:node | node objectId]. self hashTree: rootFiber }.

^ GRViewportTexture new
getViewport: [:vp | viewport set: vp];
extent: self resolution;
children: (GDControl new
rectSize: self resolution;
children: {
GDButton new
text: 'Test';
rectSize: 100@100;
onButtonDown: [Transcript showln: 'Button pressed.', DateAndTime now asString];
ref: movingButton.
GDTree new
ref: treeRef
});
meshDo: [:material |
GRGrabbableArea new children: {
Expand Down Expand Up @@ -139,39 +169,6 @@ ComponentBrowserDworph >> render: props [
}]
]

{ #category : #'as yet unclassified' }
ComponentBrowserDworph >> renderTreeUI [

"
generateUIForFiber: aCMFFiber inTree: aGDTree withRoot: aGDTreeItem
| currentItem |
currentItem := aGDTree createItemParent: aGDTreeItem.
currentItem
setTextColumn: 0 text: (aCMFFiber node asString copyWithRegex: '[\<\/\>]' matchesReplacedWith: '').
^ {
currentItem.
aCMFFiber sibling ifNotNil: [self generateUIForFiber: aCMFFiber sibling inTree: aGDTree withRoot: aGDTreeItem].
aCMFFiber child ifNotNil: [self generateUIForFiber: aCMFFiber child inTree: aGDTree withRoot: aCMFFiber].
}
render: props
| rootFiber tree |
rootFiber := ((GRReact current instVarNamed: #sessions) associations first) react currentRoot node.
tree := GDTree new.
self generateUIForFiber: rootFiber inTree: tree withRoot: nil.
^ GDControl new
rectSize: (1500@1000);
children: {
tree
}
"
]

{ #category : #'as yet unclassified' }
ComponentBrowserDworph >> resolution [

Expand Down

0 comments on commit 5b0e408

Please sign in to comment.