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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
125ae7c9
Commit
125ae7c9
authored
Mar 5, 2019
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
mol-plugin: isAnimating event
parent
ad91027f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-plugin/context.ts
+11
-1
11 additions, 1 deletion
src/mol-plugin/context.ts
src/mol-plugin/state/animation/manager.ts
+6
-0
6 additions, 0 deletions
src/mol-plugin/state/animation/manager.ts
src/mol-plugin/ui/controls.tsx
+11
-7
11 additions, 7 deletions
src/mol-plugin/ui/controls.tsx
with
28 additions
and
8 deletions
src/mol-plugin/context.ts
+
11
−
1
View file @
125ae7c9
...
@@ -55,7 +55,6 @@ export class PluginContext {
...
@@ -55,7 +55,6 @@ export class PluginContext {
removed
:
merge
(
this
.
state
.
dataState
.
events
.
object
.
removed
,
this
.
state
.
behaviorState
.
events
.
object
.
removed
),
removed
:
merge
(
this
.
state
.
dataState
.
events
.
object
.
removed
,
this
.
state
.
behaviorState
.
events
.
object
.
removed
),
updated
:
merge
(
this
.
state
.
dataState
.
events
.
object
.
updated
,
this
.
state
.
behaviorState
.
events
.
object
.
updated
)
updated
:
merge
(
this
.
state
.
dataState
.
events
.
object
.
updated
,
this
.
state
.
behaviorState
.
events
.
object
.
updated
)
},
},
isUpdating
:
merge
(
this
.
state
.
dataState
.
events
.
isUpdating
,
this
.
state
.
behaviorState
.
events
.
isUpdating
),
cameraSnapshots
:
this
.
state
.
cameraSnapshots
.
events
,
cameraSnapshots
:
this
.
state
.
cameraSnapshots
.
events
,
snapshots
:
this
.
state
.
snapshots
.
events
,
snapshots
:
this
.
state
.
snapshots
.
events
,
},
},
...
@@ -67,6 +66,10 @@ export class PluginContext {
...
@@ -67,6 +66,10 @@ export class PluginContext {
};
};
readonly
behaviors
=
{
readonly
behaviors
=
{
state
:
{
isAnimating
:
this
.
ev
.
behavior
<
boolean
>
(
false
),
isUpdating
:
this
.
ev
.
behavior
<
boolean
>
(
false
)
},
canvas3d
:
{
canvas3d
:
{
highlight
:
this
.
ev
.
behavior
<
Canvas3D
.
HighlightEvent
>
({
current
:
Representation
.
Loci
.
Empty
,
prev
:
Representation
.
Loci
.
Empty
}),
highlight
:
this
.
ev
.
behavior
<
Canvas3D
.
HighlightEvent
>
({
current
:
Representation
.
Loci
.
Empty
,
prev
:
Representation
.
Loci
.
Empty
}),
click
:
this
.
ev
.
behavior
<
Canvas3D
.
ClickEvent
>
({
current
:
Representation
.
Loci
.
Empty
,
modifiers
:
ModifiersKeys
.
None
,
buttons
:
0
})
click
:
this
.
ev
.
behavior
<
Canvas3D
.
ClickEvent
>
({
current
:
Representation
.
Loci
.
Empty
,
modifiers
:
ModifiersKeys
.
None
,
buttons
:
0
})
...
@@ -160,6 +163,12 @@ export class PluginContext {
...
@@ -160,6 +163,12 @@ export class PluginContext {
return
PluginCommands
.
State
.
Update
.
dispatch
(
this
,
{
state
,
tree
});
return
PluginCommands
.
State
.
Update
.
dispatch
(
this
,
{
state
,
tree
});
}
}
private
initBehaviorEvents
()
{
merge
(
this
.
state
.
dataState
.
events
.
isUpdating
,
this
.
state
.
behaviorState
.
events
.
isUpdating
).
subscribe
(
u
=>
{
this
.
behaviors
.
state
.
isUpdating
.
next
(
u
);
});
}
private
initBuiltInBehavior
()
{
private
initBuiltInBehavior
()
{
BuiltInPluginBehaviors
.
State
.
registerDefault
(
this
);
BuiltInPluginBehaviors
.
State
.
registerDefault
(
this
);
BuiltInPluginBehaviors
.
Representation
.
registerDefault
(
this
);
BuiltInPluginBehaviors
.
Representation
.
registerDefault
(
this
);
...
@@ -207,6 +216,7 @@ export class PluginContext {
...
@@ -207,6 +216,7 @@ export class PluginContext {
constructor
(
public
spec
:
PluginSpec
)
{
constructor
(
public
spec
:
PluginSpec
)
{
this
.
events
.
log
.
subscribe
(
e
=>
this
.
log
.
entries
=
this
.
log
.
entries
.
push
(
e
));
this
.
events
.
log
.
subscribe
(
e
=>
this
.
log
.
entries
=
this
.
log
.
entries
.
push
(
e
));
this
.
initBehaviorEvents
();
this
.
initBuiltInBehavior
();
this
.
initBuiltInBehavior
();
this
.
initBehaviors
();
this
.
initBehaviors
();
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/state/animation/manager.ts
+
6
−
0
View file @
125ae7c9
...
@@ -91,6 +91,9 @@ class PluginAnimationManager extends PluginComponent<PluginAnimationManager.Stat
...
@@ -91,6 +91,9 @@ class PluginAnimationManager extends PluginComponent<PluginAnimationManager.Stat
start
()
{
start
()
{
this
.
context
.
canvas3d
.
setSceneAnimating
(
true
);
this
.
context
.
canvas3d
.
setSceneAnimating
(
true
);
this
.
updateState
({
animationState
:
'
playing
'
});
this
.
updateState
({
animationState
:
'
playing
'
});
if
(
!
this
.
context
.
behaviors
.
state
.
isAnimating
.
value
)
{
this
.
context
.
behaviors
.
state
.
isAnimating
.
next
(
true
);
}
this
.
triggerUpdate
();
this
.
triggerUpdate
();
this
.
_current
.
lastTime
=
0
;
this
.
_current
.
lastTime
=
0
;
...
@@ -103,6 +106,9 @@ class PluginAnimationManager extends PluginComponent<PluginAnimationManager.Stat
...
@@ -103,6 +106,9 @@ class PluginAnimationManager extends PluginComponent<PluginAnimationManager.Stat
stop
()
{
stop
()
{
this
.
context
.
canvas3d
.
setSceneAnimating
(
false
);
this
.
context
.
canvas3d
.
setSceneAnimating
(
false
);
if
(
typeof
this
.
_frame
!==
'
undefined
'
)
cancelAnimationFrame
(
this
.
_frame
);
if
(
typeof
this
.
_frame
!==
'
undefined
'
)
cancelAnimationFrame
(
this
.
_frame
);
if
(
this
.
context
.
behaviors
.
state
.
isAnimating
.
value
)
{
this
.
context
.
behaviors
.
state
.
isAnimating
.
next
(
false
);
}
if
(
this
.
state
.
animationState
!==
'
stopped
'
)
{
if
(
this
.
state
.
animationState
!==
'
stopped
'
)
{
this
.
updateState
({
animationState
:
'
stopped
'
});
this
.
updateState
({
animationState
:
'
stopped
'
});
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/ui/controls.tsx
+
11
−
7
View file @
125ae7c9
...
@@ -56,6 +56,7 @@ export class TrajectoryControls extends PluginUIComponent<{}, { show: boolean, l
...
@@ -56,6 +56,7 @@ export class TrajectoryControls extends PluginUIComponent<{}, { show: boolean, l
componentDidMount
()
{
componentDidMount
()
{
this
.
subscribe
(
this
.
plugin
.
state
.
dataState
.
events
.
changed
,
this
.
update
);
this
.
subscribe
(
this
.
plugin
.
state
.
dataState
.
events
.
changed
,
this
.
update
);
this
.
subscribe
(
this
.
plugin
.
behaviors
.
state
.
isAnimating
,
this
.
update
);
}
}
reset
=
()
=>
PluginCommands
.
State
.
ApplyAction
.
dispatch
(
this
.
plugin
,
{
reset
=
()
=>
PluginCommands
.
State
.
ApplyAction
.
dispatch
(
this
.
plugin
,
{
...
@@ -76,22 +77,25 @@ export class TrajectoryControls extends PluginUIComponent<{}, { show: boolean, l
...
@@ -76,22 +77,25 @@ export class TrajectoryControls extends PluginUIComponent<{}, { show: boolean, l
render
()
{
render
()
{
if
(
!
this
.
state
.
show
)
return
null
;
if
(
!
this
.
state
.
show
)
return
null
;
const
isAnimating
=
this
.
plugin
.
behaviors
.
state
.
isAnimating
.
value
;
return
<
div
className
=
'msp-traj-controls'
>
return
<
div
className
=
'msp-traj-controls'
>
<
IconButton
icon
=
'model-first'
title
=
'First Model'
onClick
=
{
this
.
reset
}
/>
<
IconButton
icon
=
'model-first'
title
=
'First Model'
onClick
=
{
this
.
reset
}
disabled
=
{
isAnimating
}
/>
<
IconButton
icon
=
'model-prev'
title
=
'Previous Model'
onClick
=
{
this
.
prev
}
/>
<
IconButton
icon
=
'model-prev'
title
=
'Previous Model'
onClick
=
{
this
.
prev
}
disabled
=
{
isAnimating
}
/>
<
IconButton
icon
=
'model-next'
title
=
'Next Model'
onClick
=
{
this
.
next
}
/>
<
IconButton
icon
=
'model-next'
title
=
'Next Model'
onClick
=
{
this
.
next
}
disabled
=
{
isAnimating
}
/>
{
!!
this
.
state
.
label
&&
<
span
>
{
this
.
state
.
label
}
</
span
>
}
{
!!
this
.
state
.
label
&&
<
span
>
{
this
.
state
.
label
}
</
span
>
}
</
div
>;
</
div
>;
}
}
}
}
export
class
StateSnapshotViewportControls
extends
PluginUIComponent
<
{},
{
isBusy
:
boolean
}
>
{
export
class
StateSnapshotViewportControls
extends
PluginUIComponent
<
{},
{
isBusy
:
boolean
,
show
:
boolean
}
>
{
state
=
{
isBusy
:
false
}
state
=
{
isBusy
:
false
,
show
:
true
}
componentDidMount
()
{
componentDidMount
()
{
// TODO: this needs to be diabled when the state is updating!
// TODO: this needs to be diabled when the state is updating!
this
.
subscribe
(
this
.
plugin
.
state
.
snapshots
.
events
.
changed
,
()
=>
this
.
forceUpdate
());
this
.
subscribe
(
this
.
plugin
.
state
.
snapshots
.
events
.
changed
,
()
=>
this
.
forceUpdate
());
this
.
subscribe
(
this
.
plugin
.
events
.
state
.
isUpdating
,
(
isBusy
)
=>
this
.
setState
({
isBusy
}));
this
.
subscribe
(
this
.
plugin
.
behaviors
.
state
.
isUpdating
,
isBusy
=>
this
.
setState
({
isBusy
}));
this
.
subscribe
(
this
.
plugin
.
behaviors
.
state
.
isAnimating
,
isAnimating
=>
this
.
setState
({
show
:
!
isAnimating
}));
}
}
async
update
(
id
:
string
)
{
async
update
(
id
:
string
)
{
...
@@ -121,7 +125,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
...
@@ -121,7 +125,7 @@ export class StateSnapshotViewportControls extends PluginUIComponent<{}, { isBus
const
snapshots
=
this
.
plugin
.
state
.
snapshots
;
const
snapshots
=
this
.
plugin
.
state
.
snapshots
;
const
count
=
snapshots
.
state
.
entries
.
size
;
const
count
=
snapshots
.
state
.
entries
.
size
;
if
(
count
<
2
)
{
if
(
count
<
2
||
!
this
.
state
.
show
)
{
return
null
;
return
null
;
}
}
...
...
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