extendscript after effects 2022 调整按钮大小

extendscript after effects 2022 resize the buttons

我需要调整按钮的大小,因为它正在占用 space。

我在原始图像上绘制了一个自定义的 6 按钮模拟图像。我希望所有按钮的布局都像每行 3 个按钮一样。

var w = new Window('dialog', "ALL IN ONE TOOLBOX 2022", u);
    w.orientation = 'column';
    // w.margins = 5;
    // w.spacing = 10;
    w.alignChildren = ['fill', 'fill'];
myButton =  w.add( "button", undefined, "Create Solid", { name: "ok" } );
myButton0 =  w.add("button", undefined, "Create Null", {name:"ok"});
myButton1 =  w.add("button", undefined, "Create shape", {name:"ok"});
myButton2 =  w.add("button", undefined, "Parallel light", {name:"ok"});
myButton3 =  w.add("button", undefined, "Spot Light", {name:"ok"});
myButton4 =  w.add("button", undefined, "Point Light", {name:"ok"});
myButton5 =  w.add("button", undefined, "Ambient Light", {name:"ok"});
myButton6 =  w.add("button", undefined, "Regular Light", {name:"ok"});
myButton7 =  w.add("button", undefined, "Create Camera", {name:"ok"});
myButton8 =  w.add("button", undefined, "Create Ajustment", {name:"ok"})

我什至添加了这个不起作用仍然保持不变

myButton =  w.add("button", [50, 30, 150, 60], "Create Solid", {name:"ok"});
myButton0 =  w.add("button", [50, 30, 150, 60], "Create Null", {name:"ok"});
myButton1 =  w.add("button", [50, 30, 150, 60], "Create shape", {name:"ok"});
myButton2 =  w.add("button", [50, 30, 150, 60], "Parallel light", {name:"ok"});
myButton3 =  w.add("button", [50, 30, 150, 60], "Spot Light", {name:"ok"});
myButton4 =  w.add("button", [50, 30, 150, 60], "Point Light", {name:"ok"});
myButton5 =  w.add("button", [50, 30, 150, 60], "Ambient Light", {name:"ok"});
myButton6 =  w.add("button", [50, 30, 150, 60], "Regular Light", {name:"ok"});
myButton7 =  w.add("button", [50, 30, 150, 60], "Create Camera", {name:"ok"});
myButton8 =  w.add("button", [50, 30, 150, 60], "Create Ajustment", {name:"ok"});

我相信您正在寻找的是'groups'。下面的代码给了我以下布局:

var btnWidth = 116;

// BTNGRP
// ======
var btnGrp = w.add("group", undefined, {name: "btnGrp"}); 
    btnGrp.orientation = "column"; 
    btnGrp.alignChildren = ["center","center"]; 
    btnGrp.spacing = 10; 
    btnGrp.margins = 0; 

// R1GRP
// =====
var r1Grp = btnGrp.add("group", undefined, {name: "r1Grp"}); 
    r1Grp.orientation = "row"; 
    r1Grp.alignChildren = ["left","center"]; 
    r1Grp.spacing = 10; 
    r1Grp.margins = 0; 

var btn1 = r1Grp.add("button", undefined, undefined, {name: "btn1"}); 
    btn1.text = "Create Solid"; 
    btn1.preferredSize.width = btnWidth; 

var btn2 = r1Grp.add("button", undefined, undefined, {name: "btn2"}); 
    btn2.text = "Create Null"; 
    btn2.preferredSize.width = btnWidth; 

var btn3 = r1Grp.add("button", undefined, undefined, {name: "btn3"}); 
    btn3.text = "Create Shape"; 
    btn3.preferredSize.width = btnWidth; 

// R2GRP
// =====
var r2Grp = btnGrp.add("group", undefined, {name: "r2Grp"}); 
    r2Grp.orientation = "row"; 
    r2Grp.alignChildren = ["left","center"]; 
    r2Grp.spacing = 10; 
    r2Grp.margins = 0; 

var btn4 = r2Grp.add("button", undefined, undefined, {name: "btn4"}); 
    btn4.text = "Parallel Light"; 
    btn4.preferredSize.width = btnWidth; 

var btn5 = r2Grp.add("button", undefined, undefined, {name: "btn5"}); 
    btn5.text = "Spot Light"; 
    btn5.preferredSize.width = btnWidth; 

var btn6 = r2Grp.add("button", undefined, undefined, {name: "btn6"}); 
    btn6.text = "Point Light"; 
    btn6.preferredSize.width = btnWidth; 

// R3GRP
// =====
var r3Grp = btnGrp.add("group", undefined, {name: "r3Grp"}); 
    r3Grp.orientation = "row"; 
    r3Grp.alignChildren = ["left","center"]; 
    r3Grp.spacing = 10; 
    r3Grp.margins = 0; 

var btn7 = r3Grp.add("button", undefined, undefined, {name: "btn7"}); 
    btn7.text = "Ambient Light"; 
    btn7.preferredSize.width = btnWidth; 

var btn8 = r3Grp.add("button", undefined, undefined, {name: "btn8"}); 
    btn8.text = "Regular Light"; 
    btn8.preferredSize.width = btnWidth; 

var btn9 = r3Grp.add("button", undefined, undefined, {name: "btn9"}); 
    btn9.text = "Create Camera"; 
    btn9.preferredSize.width = btnWidth; 

// R4GRP
// =====
var r4Grp = btnGrp.add("group", undefined, {name: "r4Grp"}); 
    r4Grp.orientation = "row"; 
    r4Grp.alignChildren = ["left","center"]; 
    r4Grp.spacing = 10; 
    r4Grp.margins = 0; 

var btn10 = r4Grp.add("button", undefined, undefined, {name: "btn10"}); 
    btn10.text = "Create Adjustment"; 
    btn10.preferredSize.width = btnWidth; 

第一组设置为 columns 以允许堆叠后续组。所有其他组都设置为 row 以允许对齐三个按钮。

将顶部组的 alignCenter 设置为 ["center","center"] 以使行居中对齐。

为了使按钮大小相同,我将它们的 preferredSize.width 设置得足够大,以便 space 用于文本量最大的按钮,恰好是“创建调整”,其值恰好为 116。我将其放在 btnWidth 变量中。如果您添加更多按钮并需要容纳一个更大文本的按钮,则可能需要更改此设置。

希望这足以让您朝着正确的方向前进!