Skip to content
Snippets Groups Projects
Commit 5ad983e9 authored by Alexander Rose's avatar Alexander Rose
Browse files

canvas ui weaks

parent acd59b65
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,9 @@ import { Params } from 'mol-view/parameter'; ...@@ -11,6 +11,9 @@ import { Params } from 'mol-view/parameter';
import { Representation } from 'mol-geo/representation'; import { Representation } from 'mol-geo/representation';
import { ParametersComponent } from 'mol-app/component/parameters'; import { ParametersComponent } from 'mol-app/component/parameters';
import { Progress } from 'mol-task'; import { Progress } from 'mol-task';
import { ColorTheme } from 'mol-view/theme/color';
import { getColorThemeProps } from 'mol-geo/geometry/color-data';
import { ColorThemeComponent } from 'mol-app/component/color-theme';
export interface RepresentationComponentProps { export interface RepresentationComponentProps {
app: App app: App
...@@ -19,34 +22,53 @@ export interface RepresentationComponentProps { ...@@ -19,34 +22,53 @@ export interface RepresentationComponentProps {
} }
export interface RepresentationComponentState { export interface RepresentationComponentState {
label: string
reprParams: Params
reprProps: Readonly<{}>
} }
export class RepresentationComponent extends React.Component<RepresentationComponentProps, RepresentationComponentState> { export class RepresentationComponent extends React.Component<RepresentationComponentProps, RepresentationComponentState> {
private stateFromRepr(repr: Representation<Params>) {
return {
label: this.props.repr.label,
reprParams: this.props.repr.params,
reprProps: this.props.repr.props
}
}
componentWillMount() {
this.setState(this.stateFromRepr(this.props.repr))
}
async onChange(k: string, v: any) { async onChange(k: string, v: any) {
await this.props.app.runTask(this.props.repr.createOrUpdate({ [k]: v }).run( await this.props.app.runTask(this.props.repr.createOrUpdate({ [k]: v }).run(
progress => console.log(Progress.format(progress)) progress => console.log(Progress.format(progress))
), 'Representation Update') ), 'Representation Update')
this.props.viewer.add(this.props.repr) this.props.viewer.add(this.props.repr)
this.props.viewer.requestDraw(true) this.props.viewer.requestDraw(true)
this.setState(this.stateFromRepr(this.props.repr))
} }
render() { render() {
const { repr } = this.props const { label, reprParams, reprProps } = this.state
// const ct = ColorTheme(colorTheme) let colorTheme: ColorTheme | undefined = undefined
if ('colorTheme' in reprProps) {
colorTheme = ColorTheme(getColorThemeProps(reprProps))
}
return <div> return <div>
<div> <div>
<h4>{repr.label}</h4> <h4>{label}</h4>
</div> </div>
<div> <div>
<ParametersComponent <ParametersComponent
params={repr.params} params={reprParams}
values={repr.props} values={reprProps}
onChange={(k, v) => this.onChange(k as string, v)} onChange={(k, v) => this.onChange(k as string, v)}
/> />
</div> </div>
{ colorTheme !== undefined ? <ColorThemeComponent colorTheme={colorTheme} /> : '' }
</div>; </div>;
} }
} }
\ No newline at end of file
...@@ -13,12 +13,12 @@ export interface ColorThemeComponentProps { ...@@ -13,12 +13,12 @@ export interface ColorThemeComponentProps {
} }
export interface ColorThemeComponentState { export interface ColorThemeComponentState {
} }
export class ColorThemeComponent extends React.Component<ColorThemeComponentProps, ColorThemeComponentState> { export class ColorThemeComponent extends React.Component<ColorThemeComponentProps, ColorThemeComponentState> {
state = { state = {
} }
render() { render() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment