Aligning controls in neat columns

This commit is contained in:
Daniel Wolf 2017-06-16 21:12:48 +02:00
parent 308ee7202e
commit 76deebdf6a
1 changed files with 25 additions and 0 deletions

View File

@ -139,6 +139,31 @@ function createDialogWindow() {
cancelButton: window.buttons.cancel 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 // Handle animation
controls.animateButton.onClick = function() { controls.animateButton.onClick = function() {
// TODO: validate // TODO: validate