|
@@ -82,11 +82,13 @@ export class AnimationListTree extends React.Component<
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set the animation list if has changed properties
|
|
|
+ * @param prevProps previous properties
|
|
|
+ */
|
|
|
componentDidUpdate(prevProps: IAnimationListTreeProps) {
|
|
|
if (this.props.entity instanceof TargetedAnimation) {
|
|
|
- if (
|
|
|
- (this.props.entity as TargetedAnimation).animation !== (prevProps.entity as TargetedAnimation).animation
|
|
|
- ) {
|
|
|
+ if ((this.props.entity as TargetedAnimation).animation !== (prevProps.entity as TargetedAnimation).animation) {
|
|
|
this.setState({
|
|
|
animationList: this.generateList(),
|
|
|
animations: (this.props.entity as TargetedAnimation).animation,
|
|
@@ -102,6 +104,9 @@ export class AnimationListTree extends React.Component<
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Delete animation from list
|
|
|
+ */
|
|
|
deleteAnimation = () => {
|
|
|
let currentSelected = this.props.selected;
|
|
|
if (this.props.entity instanceof TargetedAnimation) {
|
|
@@ -134,6 +139,11 @@ export class AnimationListTree extends React.Component<
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * Update the animations collection
|
|
|
+ * @param newValue new animation list
|
|
|
+ * @param previousValue previous animation list
|
|
|
+ */
|
|
|
raiseOnPropertyChanged(newValue: Animation[], previousValue: Animation[]) {
|
|
|
if (!this.props.onPropertyChangedObservable) {
|
|
|
return;
|
|
@@ -147,6 +157,9 @@ export class AnimationListTree extends React.Component<
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Renders the animation list
|
|
|
+ */
|
|
|
generateList() {
|
|
|
let animationList =
|
|
|
(this.props.entity as IAnimatable).animations &&
|
|
@@ -165,6 +178,10 @@ export class AnimationListTree extends React.Component<
|
|
|
return animationList ?? null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Open or closes the animation to show its coordinate animations
|
|
|
+ * @param index Animation index
|
|
|
+ */
|
|
|
toggleProperty(index: number) {
|
|
|
if (this.state.animationList) {
|
|
|
const updated = this.state.animationList.map((a) => {
|
|
@@ -177,79 +194,75 @@ export class AnimationListTree extends React.Component<
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Select the animation to render
|
|
|
+ * @param animation Selected animation
|
|
|
+ * @param coordinate Selected coordinate (x, y, z)
|
|
|
+ * @param index Index
|
|
|
+ */
|
|
|
setSelectedCoordinate(animation: Animation, coordinate: SelectedCoordinate, index: number) {
|
|
|
this.setState({ selectedCoordinate: coordinate, selectedAnimation: index });
|
|
|
this.props.selectAnimation(animation, coordinate);
|
|
|
}
|
|
|
|
|
|
- coordinateItem(
|
|
|
- i: number,
|
|
|
- animation: Animation,
|
|
|
- coordinate: string,
|
|
|
- color: string,
|
|
|
- selectedCoordinate: SelectedCoordinate
|
|
|
- ) {
|
|
|
+ /**
|
|
|
+ * Renders the coordinate belonging to an animation
|
|
|
+ * @param i Index
|
|
|
+ * @param animation Selected animation
|
|
|
+ * @param coordinate Coordinate name
|
|
|
+ * @param color Color identifier
|
|
|
+ * @param selectedCoordinate Selected coordinate (x, y, z)
|
|
|
+ */
|
|
|
+ coordinateItem(i: number, animation: Animation, coordinate: string, color: string, selectedCoordinate: SelectedCoordinate) {
|
|
|
const setSelectedCoordinate = () => this.setSelectedCoordinate(animation, selectedCoordinate, i);
|
|
|
const handleClass = `handle-indicator ${
|
|
|
this.state.selectedCoordinate === selectedCoordinate && this.state.selectedAnimation === i ? "show" : "hide"
|
|
|
}`;
|
|
|
return (
|
|
|
- <li
|
|
|
- key={`${i}_${coordinate}`}
|
|
|
- id={`${i}_${coordinate}`}
|
|
|
- className="property"
|
|
|
- style={{ color: color }}
|
|
|
- onClick={setSelectedCoordinate}
|
|
|
- >
|
|
|
+ <li key={`${i}_${coordinate}`} id={`${i}_${coordinate}`} className="property" style={{ color: color }} onClick={setSelectedCoordinate}>
|
|
|
<div className={handleClass}></div>
|
|
|
{animation.targetProperty} {coordinate.toUpperCase()}
|
|
|
</li>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Render animation
|
|
|
+ * @param animation selected animations
|
|
|
+ * @param i index
|
|
|
+ * @param childrenElements its coordinate (x,y,z) animations
|
|
|
+ */
|
|
|
typeAnimationItem(animation: Animation, i: number, childrenElements: ItemCoordinate[]) {
|
|
|
const editAnimation = () => this.props.editAnimation(animation);
|
|
|
const selectAnimation = () => this.props.selectAnimation(animation);
|
|
|
const toggle = () => this.toggleProperty(i);
|
|
|
return (
|
|
|
- <li
|
|
|
- className={
|
|
|
- this.props.selected && this.props.selected.name === animation.name
|
|
|
- ? "property sub active"
|
|
|
- : "property sub"
|
|
|
- }
|
|
|
- key={i}
|
|
|
- >
|
|
|
+ <li className={this.props.selected && this.props.selected.name === animation.name ? "property sub active" : "property sub"} key={i}>
|
|
|
<div
|
|
|
- className={`animation-arrow ${
|
|
|
- this.state.animationList && this.state.animationList[i].open ? "" : "flip"
|
|
|
- }`}
|
|
|
+ className={`animation-arrow ${this.state.animationList && this.state.animationList[i].open ? "" : "flip"}`}
|
|
|
onClick={toggle}
|
|
|
></div>
|
|
|
<p onClick={selectAnimation}>{animation.targetProperty}</p>
|
|
|
<IconButtonLineComponent tooltip="Options" icon="small animation-options" onClick={editAnimation} />
|
|
|
{!((this.props.entity as TargetedAnimation).getClassName() === "TargetedAnimation") ? (
|
|
|
this.props.selected && this.props.selected.name === animation.name ? (
|
|
|
- <IconButtonLineComponent
|
|
|
- tooltip="Remove"
|
|
|
- icon="small animation-delete"
|
|
|
- onClick={this.deleteAnimation}
|
|
|
- />
|
|
|
+ <IconButtonLineComponent tooltip="Remove" icon="small animation-delete" onClick={this.deleteAnimation} />
|
|
|
) : (
|
|
|
<div className="spacer"></div>
|
|
|
)
|
|
|
) : null}
|
|
|
- <ul
|
|
|
- className={`sub-list ${
|
|
|
- this.state.animationList && this.state.animationList[i].open ? "" : "hidden"
|
|
|
- }`}
|
|
|
- >
|
|
|
+ <ul className={`sub-list ${this.state.animationList && this.state.animationList[i].open ? "" : "hidden"}`}>
|
|
|
{childrenElements.map((c) => this.coordinateItem(i, animation, c.id, c.color, c.coordinate))}
|
|
|
</ul>
|
|
|
</li>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Render animation item
|
|
|
+ * @param animation Selected aniamtion
|
|
|
+ * @param i index
|
|
|
+ */
|
|
|
setListItem(animation: Animation, i: number) {
|
|
|
switch (animation.dataType) {
|
|
|
case Animation.ANIMATIONTYPE_FLOAT:
|
|
@@ -257,28 +270,16 @@ export class AnimationListTree extends React.Component<
|
|
|
const selectAnimation = () => this.props.selectAnimation(animation, 0);
|
|
|
return (
|
|
|
<li
|
|
|
- className={
|
|
|
- this.props.selected && this.props.selected.name === animation.name
|
|
|
- ? "property active"
|
|
|
- : "property"
|
|
|
- }
|
|
|
+ className={this.props.selected && this.props.selected.name === animation.name ? "property active" : "property"}
|
|
|
key={i}
|
|
|
onClick={selectAnimation}
|
|
|
>
|
|
|
<div className={`animation-bullet`}></div>
|
|
|
<p>{animation.targetProperty}</p>
|
|
|
- <IconButtonLineComponent
|
|
|
- tooltip="Options"
|
|
|
- icon="small animation-options"
|
|
|
- onClick={editAnimation}
|
|
|
- />
|
|
|
+ <IconButtonLineComponent tooltip="Options" icon="small animation-options" onClick={editAnimation} />
|
|
|
{!(this.props.entity instanceof TargetedAnimation) ? (
|
|
|
this.props.selected && this.props.selected.name === animation.name ? (
|
|
|
- <IconButtonLineComponent
|
|
|
- tooltip="Remove"
|
|
|
- icon="small animation-delete"
|
|
|
- onClick={this.deleteAnimation}
|
|
|
- />
|
|
|
+ <IconButtonLineComponent tooltip="Remove" icon="small animation-delete" onClick={this.deleteAnimation} />
|
|
|
) : (
|
|
|
<div className="spacer"></div>
|
|
|
)
|