1 line
5.2 KiB
JavaScript
1 line
5.2 KiB
JavaScript
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},t=e(require("react")),i=e(require("../../atom-react/components/float-input-view")),n=e(require("./properties/texture-input")),r=e(require("./properties/rgb-input")),a=e(require("./properties/video-input")),o=e(require("./properties/event-input")),s=e(require("./properties/audio-input")),p=e(require("../../atom-react/components/jibo-combo-box")),l=0,d=t.createClass({displayName:"PropertiesView",onPropertyChange:function(e,t){var i={};i[e]=t,this.props.animationModel.updateSelectedLayerProperties(i),this.props.animationModel.addRedoUndoEntry()},onVector2Change:function(e,t,i){var n={};n[e]={},n[e][t]=i,this.props.animationModel.updateSelectedLayerProperties(n),this.props.animationModel.addRedoUndoEntry()},vector2Input:function(e,n,r,a){var o=this,s="Scale"===e?4:1;return t.createElement("div",{style:{"float":"right",display:"flex"}},t.createElement("div",{className:"btn",style:{marginRight:5},onClick:function(){o.onVector2Change(e,"x",a.x),o.onVector2Change(e,"y",a.y)}},t.createElement("i",{className:"fa fa-refresh"})),t.createElement("div",{style:{"float":"left"}},[t.createElement(i,{style:{clear:"both",maxWidth:150},onChange:this.onVector2Change.bind(this,e,"x"),value:n.x,precision:s,tabIndex:r}),t.createElement(i,{style:{clear:"both",maxWidth:150},onChange:this.onVector2Change.bind(this,e,"y"),value:n.y,precision:s,tabIndex:r+1})]))},rgbInput:function(e,t,i,n){return r(e,t,i,n,this.props.animationModel)},floatInput:function(e,n,r){return t.createElement("div",{style:{"float":"right",display:"flex"}},t.createElement("div",{className:"btn",style:{marginRight:5}},t.createElement("i",{className:"fa fa-refresh"})),t.createElement(i,{step:1,style:{clear:"both",maxWidth:150},onChange:this.onPropertyChange.bind(this,e),value:n,precision:2,tabIndex:r}))},textureInput:function(e,t){var i=this;return n(function(t){i.onPropertyChange(e,t),i.props.animationModel.editor.focus()},t,this.props.animationModel.projectRoot,this.props.animationModel.uri)},videoInput:function(e,t){var i=this.onPropertyChange.bind(this,e);return a(i,t,this.props.animationModel.projectRoot,this.props.animationModel.uri)},eventInput:function(e,t){var i=this.onPropertyChange.bind(this,e);return o(i,t,this.props.animationModel.projectRoot,this.props.animationModel.uri)},audioInput:function(e,t){var i=this;return s(function(t){i.onPropertyChange(e,t),i.props.animationModel.editor.focus()},t,this.props.animationModel.projectRoot)},enumInput:function(e,i,n,r,a){var o=this;return t.createElement("div",{style:{"float":"right",marginRight:5}},t.createElement(p,{key:l++,data:n,init:i?i:a,onSelected:function(t){o.onPropertyChange(e,t),o.props.animationModel.editor.focus()}}))},renderProperties:function(){var e=this,i=this.props.animationModel.getKeyframeInfo(),n=this.props.animationModel.getSelectedLayer(),r=i.layerTypes[n.type].getInfo(),a=[],o=1;for(var s in r.properties){var p=r.properties[s].type,l=this.props.animationModel.state.overrides[n.id][s],d=1;l&&(d=Object.keys(l).length?Object.keys(l).length:1);var c=r.properties[s].defaultValue;if("string"==typeof p)try{a.push(t.createElement("h3",{style:{paddingTop:7,marginBottom:7,marginRight:4,clear:"both",textAlign:"right"}},s)),a.push(this[p+"Input"](s,l,o,c))}catch(m){}else"object"==typeof p&&"enum"===p.name&&(a.push(t.createElement("h3",{style:{paddingTop:7,marginBottom:7,marginRight:4,clear:"both",textAlign:"right"}},s)),a.push(this.enumInput(s,l,p.values,o,c)));o+=d}a.push(t.createElement("div",{style:{clear:"both"}})),a.push(t.createElement("div",{style:{"float":"right",marginTop:7},className:"btn",onClick:function(){var t={};for(var i in r.properties)t[i]=r.properties[i].defaultValue;e.props.animationModel.updateSelectedLayerProperties(t),e.props.animationModel.addRedoUndoEntry()}},"Reset All")),a.push(t.createElement("div",{style:{clear:"both"}}));var h=[],u=this.props.animationModel.limits.exceedsVelLimit,y=this.props.animationModel.limits.exceedsAccelLimit;if((u||y)&&"Body"===r.layerType){u?h.push("velocity"):"",y?h.push("acceleration"):"";var g=h.join(" and ");a.push(t.createElement("p",{className:"text-warning",style:{marginTop:7,whiteSpace:"normal",color:"#A83131"}},"Warning: an animation you have created exceeds Jibo's internal motor ",g," limits. Your animation may appear slower on Jibo than in the simulator, or you may hurt Jibo using this animation."))}return a},render:function(){var e={properties:{},panel:{minHeight:this.props.paneHeight-60}},i=this.props.animationModel.getSelectedLayer(),n=void 0;return null===i||i.locked||!i.visible||this.props.animationModel.keyframeSelection.isMultiSelect()?n=t.createElement("div",{style:{height:200}}):(n=[t.createElement("h2",{style:{textAlign:"right"}},i.name)],n=n.concat(this.renderProperties())),t.createElement("div",{style:e.properties,className:"animation-editor-properties native-key-bindings"},t.createElement("atom-panel",{className:"top native-key-bindings"},t.createElement("div",{className:"padded native-key-bindings"},t.createElement("div",{style:e.panel,className:"inset-panel native-key-bindings"},t.createElement("div",{className:"panel-heading native-key-bindings"},"Properties"),t.createElement("div",{className:"panel-body padded native-key-bindings"},n)))))}});module.exports=d; |