From 76deebdf6ada5749ec8a02ea6b500ae0265c86a8 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Fri, 16 Jun 2017 21:12:48 +0200 Subject: [PATCH] Aligning controls in neat columns --- extras/AdobeAfterEffects/rhubarb.jsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/extras/AdobeAfterEffects/rhubarb.jsx b/extras/AdobeAfterEffects/rhubarb.jsx index da11080..dd0e97e 100644 --- a/extras/AdobeAfterEffects/rhubarb.jsx +++ b/extras/AdobeAfterEffects/rhubarb.jsx @@ -139,6 +139,31 @@ function createDialogWindow() { cancelButton: window.buttons.cancel }; + // Align controls + window.onShow = function() { + // Give uniform width to all labels + var groups = toArray(window.settings.children); + var labelWidths = groups.map(function(group) { return group.children[0].size.width; }); + var maxLabelWidth = Math.max.apply(Math, labelWidths); + groups.forEach(function (group) { + group.children[0].size.width = maxLabelWidth; + }); + + // Give uniform width to inputs + var valueWidths = groups.map(function(group) { + return last(group.children).bounds.right - group.children[1].bounds.left; + }); + var maxValueWidth = Math.max.apply(Math, valueWidths); + groups.forEach(function (group) { + var multipleControls = group.children.length > 2; + if (!multipleControls) { + group.children[1].size.width = maxValueWidth; + } + }); + + window.layout.layout(true); + }; + // Handle animation controls.animateButton.onClick = function() { // TODO: validate