Amethyst icon indicating copy to clipboard operation
Amethyst copied to clipboard

[Custom Layout] How to extend Two Pane to have the main pane width an exact number

Open thewinger opened this issue 2 years ago • 2 comments
trafficstars

As the title says, I'm trying to extend the Two Pane layout, but making the main pane a width of 2560px.

This is the code I have that doesn't work:

function layout() {
  return {
    name: "presentation",
    extends: "two-pane",
    getFrameAssignments: (windows, screenFrame, extendedFrames) => {
      const mainWidth = 2560;

      return extendedFrames.reduce((frames, extendedFrame) => {
        let frame;
        if (index === 0) {
          frame = {
            x: extendedFrame.x,
            y: extendedFrame.y,
            width: mainWidth,
            height: extendedFrame.height,
          };
        } else {
          frame = {
            x: extendedFrame.x,
            y: extendedFrame.y,
            width: extendedFrame.width,
            height: extendedFrame.height,
          };
        }
        return { ...frames, [extendedFrame.id]: frame };
      }, {});
    },
  };
}

thewinger avatar Oct 27 '23 09:10 thewinger

Sorry, I'm a billion years late on this, but it doesn't look like index is actually defined anywhere?

ianyh avatar Mar 14 '24 23:03 ianyh

Thanks for the reply. I used extended.js and static-ratio-tall.js as inspirations but no luck.

function layout() {
  return {
    name: "Presentation",
    extends: "two-pane",
    getFrameAssignments: (windows, extendedFrames) => {
      const mainWidth = 2560;

      return extendedFrames.reduce((frames, extendedFrame, index) => {
        let frame;
        if (index === 0) {
          frame = {
            x: extendedFrame.frame.x,
            y: extendedFrame.frame.y,
            width: mainWidth,
            height: extendedFrame.frame.height,
          };
        } else {
          frame = {
            x: extendedFrame.frame.x,
            y: extendedFrame.frame.y,
            width: extendedFrame.frame.width - mainWidth,
            height: extendedFrame.frame.height,
          };
        }
        return { ...frames, [extendedFrame.id]: frame };
      }, {});
    },
  };
}

thewinger avatar Mar 15 '24 07:03 thewinger