Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
14f9fe27
Commit
14f9fe27
authored
6 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: state tree ui fixes
parent
fae55845
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin/behavior/static/camera.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/behavior/static/camera.ts
src/mol-plugin/ui/state-tree.tsx
+45
-28
45 additions, 28 deletions
src/mol-plugin/ui/state-tree.tsx
with
46 additions
and
29 deletions
src/mol-plugin/behavior/static/camera.ts
+
1
−
1
View file @
14f9fe27
...
@@ -51,6 +51,6 @@ export function Snapshots(ctx: PluginContext) {
...
@@ -51,6 +51,6 @@ export function Snapshots(ctx: PluginContext) {
PluginCommands
.
Camera
.
Snapshots
.
Apply
.
subscribe
(
ctx
,
({
id
})
=>
{
PluginCommands
.
Camera
.
Snapshots
.
Apply
.
subscribe
(
ctx
,
({
id
})
=>
{
const
e
=
ctx
.
state
.
cameraSnapshots
.
getEntry
(
id
);
const
e
=
ctx
.
state
.
cameraSnapshots
.
getEntry
(
id
);
return
PluginCommands
.
Camera
.
SetSnapshot
.
dispatch
(
ctx
,
{
snapshot
:
e
.
snapshot
,
durationMs
:
5
00
});
return
PluginCommands
.
Camera
.
SetSnapshot
.
dispatch
(
ctx
,
{
snapshot
:
e
.
snapshot
,
durationMs
:
2
00
});
});
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/state-tree.tsx
+
45
−
28
View file @
14f9fe27
...
@@ -10,24 +10,14 @@ import { State } from 'mol-state'
...
@@ -10,24 +10,14 @@ import { State } from 'mol-state'
import
{
PluginCommands
}
from
'
mol-plugin/command
'
;
import
{
PluginCommands
}
from
'
mol-plugin/command
'
;
import
{
PluginComponent
}
from
'
./base
'
;
import
{
PluginComponent
}
from
'
./base
'
;
export
class
StateTree
extends
PluginComponent
<
{
state
:
State
},
{
}
>
{
export
class
StateTree
extends
PluginComponent
<
{
state
:
State
}
>
{
componentDidMount
()
{
// this.subscribe(this.props.state.events.changed, () => {
// this.forceUpdate()
// });
}
render
()
{
render
()
{
// const n = this.props.plugin.state.data.tree.nodes.get(this.props.plugin.state.data.tree.rootRef)!;
const
n
=
this
.
props
.
state
.
tree
.
root
.
ref
;
const
n
=
this
.
props
.
state
.
tree
.
root
.
ref
;
return
<
div
>
return
<
StateTreeNode
state
=
{
this
.
props
.
state
}
nodeRef
=
{
n
}
/>;
<
StateTreeNode
state
=
{
this
.
props
.
state
}
nodeRef
=
{
n
}
/>
{
/* n.children.map(c => <StateTreeNode plugin={this.props.plugin} nodeRef={c!} key={c} />) */
}
</
div
>;
}
}
}
}
class
StateTreeNode
extends
PluginComponent
<
{
nodeRef
:
string
,
state
:
State
},
{
}
>
{
class
StateTreeNode
extends
PluginComponent
<
{
nodeRef
:
string
,
state
:
State
},
{
state
:
State
,
isCollapsed
:
boolean
}
>
{
is
(
e
:
State
.
ObjectEvent
)
{
is
(
e
:
State
.
ObjectEvent
)
{
return
e
.
ref
===
this
.
props
.
nodeRef
&&
e
.
state
===
this
.
props
.
state
;
return
e
.
ref
===
this
.
props
.
nodeRef
&&
e
.
state
===
this
.
props
.
state
;
}
}
...
@@ -37,11 +27,9 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
...
@@ -37,11 +27,9 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
}
}
componentDidMount
()
{
componentDidMount
()
{
let
isCollapsed
=
this
.
cellState
.
isCollapsed
;
this
.
subscribe
(
this
.
plugin
.
events
.
state
.
cell
.
stateUpdated
,
e
=>
{
this
.
subscribe
(
this
.
plugin
.
events
.
state
.
cell
.
stateUpdated
,
e
=>
{
if
(
this
.
is
(
e
)
&&
isCollapsed
!==
e
.
cellState
.
isCollapsed
)
{
if
(
this
.
is
(
e
)
&&
e
.
state
.
transforms
.
has
(
this
.
props
.
nodeRef
))
{
isCollapsed
=
e
.
cellState
.
isCollapsed
;
this
.
setState
({
isCollapsed
:
e
.
cellState
.
isCollapsed
});
this
.
forceUpdate
();
}
}
});
});
...
@@ -58,6 +46,19 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
...
@@ -58,6 +46,19 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
});
});
}
}
state
=
{
isCollapsed
:
this
.
props
.
state
.
cellStates
.
get
(
this
.
props
.
nodeRef
).
isCollapsed
,
state
:
this
.
props
.
state
}
static
getDerivedStateFromProps
(
props
:
{
nodeRef
:
string
,
state
:
State
},
state
:
{
state
:
State
,
isCollapsed
:
boolean
})
{
if
(
props
.
state
===
state
.
state
)
return
null
;
return
{
isCollapsed
:
props
.
state
.
cellStates
.
get
(
props
.
nodeRef
).
isCollapsed
,
state
:
props
.
state
};
}
render
()
{
render
()
{
const
cellState
=
this
.
cellState
;
const
cellState
=
this
.
cellState
;
...
@@ -74,7 +75,7 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
...
@@ -74,7 +75,7 @@ class StateTreeNode extends PluginComponent<{ nodeRef: string, state: State }, {
}
}
}
}
class
StateTreeNodeLabel
extends
PluginComponent
<
{
nodeRef
:
string
,
state
:
State
}
>
{
class
StateTreeNodeLabel
extends
PluginComponent
<
{
nodeRef
:
string
,
state
:
State
},
{
state
:
State
,
isCurrent
:
boolean
,
isCollapsed
:
boolean
}
>
{
is
(
e
:
State
.
ObjectEvent
)
{
is
(
e
:
State
.
ObjectEvent
)
{
return
e
.
ref
===
this
.
props
.
nodeRef
&&
e
.
state
===
this
.
props
.
state
;
return
e
.
ref
===
this
.
props
.
nodeRef
&&
e
.
state
===
this
.
props
.
state
;
}
}
...
@@ -84,22 +85,38 @@ class StateTreeNodeLabel extends PluginComponent<{ nodeRef: string, state: State
...
@@ -84,22 +85,38 @@ class StateTreeNodeLabel extends PluginComponent<{ nodeRef: string, state: State
if
(
this
.
is
(
e
))
this
.
forceUpdate
();
if
(
this
.
is
(
e
))
this
.
forceUpdate
();
});
});
let
isCurrent
=
this
.
is
(
this
.
props
.
state
.
behaviors
.
currentObject
.
value
);
this
.
subscribe
(
this
.
plugin
.
state
.
behavior
.
currentObject
,
e
=>
{
this
.
subscribe
(
this
.
plugin
.
state
.
behavior
.
currentObject
,
e
=>
{
if
(
this
.
is
(
e
))
{
if
(
!
this
.
is
(
e
))
{
if
(
!
isCurrent
)
{
if
(
this
.
state
.
isCurrent
&&
e
.
state
.
transforms
.
has
(
this
.
props
.
nodeRef
))
{
isCurrent
=
true
;
this
.
setState
({
isCurrent
:
this
.
props
.
state
.
current
===
this
.
props
.
nodeRef
});
this
.
forceUpdate
();
}
}
}
else
if
(
isCurrent
)
{
return
;
isCurrent
=
false
;
}
// have to check the node wasn't removed
if
(
e
.
state
.
transforms
.
has
(
this
.
props
.
nodeRef
))
this
.
forceUpdate
();
if
(
e
.
state
.
transforms
.
has
(
this
.
props
.
nodeRef
))
{
this
.
setState
({
isCurrent
:
this
.
props
.
state
.
current
===
this
.
props
.
nodeRef
,
isCollapsed
:
this
.
props
.
state
.
cellStates
.
get
(
this
.
props
.
nodeRef
).
isCollapsed
});
}
}
});
});
}
}
state
=
{
isCurrent
:
this
.
props
.
state
.
current
===
this
.
props
.
nodeRef
,
isCollapsed
:
this
.
props
.
state
.
cellStates
.
get
(
this
.
props
.
nodeRef
).
isCollapsed
,
state
:
this
.
props
.
state
}
static
getDerivedStateFromProps
(
props
:
{
nodeRef
:
string
,
state
:
State
},
state
:
{
state
:
State
,
isCurrent
:
boolean
,
isCollapsed
:
boolean
})
{
if
(
props
.
state
===
state
.
state
)
return
null
;
return
{
isCurrent
:
props
.
state
.
current
===
props
.
nodeRef
,
isCollapsed
:
props
.
state
.
cellStates
.
get
(
props
.
nodeRef
).
isCollapsed
,
state
:
props
.
state
};
}
setCurrent
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
setCurrent
=
(
e
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
e
.
preventDefault
();
e
.
preventDefault
();
PluginCommands
.
State
.
SetCurrentObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
PluginCommands
.
State
.
SetCurrentObject
.
dispatch
(
this
.
plugin
,
{
state
:
this
.
props
.
state
,
ref
:
this
.
props
.
nodeRef
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment