-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHyle Panel.jsx
128 lines (113 loc) · 3.75 KB
/
Hyle Panel.jsx
1
// Generated by CoffeeScript 1.7.1#target "aftereffects-13.0";var HylePanel, panel;HylePanel = (function() { function HylePanel() {} HylePanel.prototype.initialize = function() { this.window = {}; this.ui = { elements: {}, sizes: {} }; this.debug = false; if (this.debug) { this.selfBuild("/Applications/Adobe After Effects CC 2014/Scripts/ScriptUI Panels"); } if (this.debug) { this.selfBuild((new File($.fileName)).parent.path); } return this.createWindow(); }; HylePanel.prototype.selfBuild = function(path) { var currentPath; currentPath = (new File($.fileName)).parent.path; log(currentPath); return esy.file.buildExtendScript("" + currentPath + "/lib/Hyle Panel.js", ["" + path + "/Hyle Panel.jsx"]); }; HylePanel.prototype.createWindow = function() { if (panel.container instanceof Panel) { this.window = panel.container; return this.buildUi(); } else { this.window = new Window("window {orientation: 'row'}"); this.buildUi(); return this.window.show(); } }; HylePanel.prototype.buildUi = function() { this.ui = {}; this.ui.sizes = { marginLeft: 10, marginTop: 10, width: 200, heightIncrement: 0 }; this.ui.elements = {}; this.ui.elements.generateButton = this.window.add('button', this.returnGoodUIValues(30, true, [10, 10, -10, 0]), 'Generate'); this.ui.elements.pastePanel = this.window.add('panel', this.returnGoodUIValues(220, false, [0, 10, 0, 0]), 'Direct input'); this.ui.elements.textarea = this.window.add('editText', this.returnGoodUIValues(150, true, [10, 10, -10, 0]), "", { multiline: true }); this.ui.elements.submitButton = this.window.add('button', this.returnGoodUIValues(30, true, [10, 0, -10, 0]), 'Submit'); return this.createEvents(); }; HylePanel.prototype.createEvents = function() { this.ui.elements.submitButton.onClick = (function(_this) { return function(e) { return _this.handleSubmitButtonClick(); }; })(this); return this.ui.elements.generateButton.onClick = (function(_this) { return function(e) { return _this.handleGenerateButtonClick(); }; })(this); }; HylePanel.prototype.returnGoodUIValues = function(height, increment, adaptSizes) { var i, key, sizes, value, values, _ref; if (increment == null) { increment = true; } if (adaptSizes == null) { adaptSizes = [0, 0, 0, 0]; } sizes = []; i = 0; _ref = this.ui.sizes; for (key in _ref) { value = _ref[key]; sizes[key] = value + adaptSizes[i]; i++; } values = [sizes.marginLeft, sizes.marginTop + this.ui.sizes.heightIncrement, sizes.width, sizes.marginTop + this.ui.sizes.heightIncrement + height]; this.ui.sizes.heightIncrement += sizes.marginTop; if (increment) { this.ui.sizes.heightIncrement += height; } return values; }; HylePanel.prototype.handleGenerateButtonClick = function() { return this.ui.elements.textarea.text = hyle.api.compose(); }; HylePanel.prototype.handleSubmitButtonClick = function() { var result; if (this.ui.elements.textarea.text === "") { return hyle.logError("You need to enter some content."); } else { return result = hyle.api.parse(this.ui.elements.textarea.text); } }; HylePanel.prototype.handleUploadButtonClick = function() { var result, uploadDialog, uploadedFileContent; uploadDialog = File.openDialog(); if (uploadDialog) { uploadDialog.open('r'); uploadedFileContent = uploadDialog.read(); return result = hyle.api.parse(this.ui.elements.textarea.text); } }; return HylePanel;})();panel = new HylePanel;panel.container = this;panel.initialize();