Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with creating custom layouts? #1415

Open
EttVenter opened this issue Feb 9, 2023 · 6 comments
Open

Help with creating custom layouts? #1415

EttVenter opened this issue Feb 9, 2023 · 6 comments

Comments

@EttVenter
Copy link

I'd like to create a custom layout. I had a look at the examples, but I'm not a developer, so I don't really understand them.

Anyone willing to help me figure this out? I need to create a layout that holds a single window in the center of the screen, NOT full screen. I've got a larger monitor, so some windows (like finder, for example) are wildly inefficient when they're taking up the whole display. So I'd like to be able to limit the space to a single window, and any other windows to "stack" under that one.

Anyone willing to help? Thanks!

@ianyh
Copy link
Owner

ianyh commented Feb 9, 2023

You may be able to replicate this with window margins and the fullscreen layout instead of making a whole custom layout.

@EttVenter
Copy link
Author

You may be able to replicate this with window margins and the fullscreen layout instead of making a whole custom layout.

Yeah I did consider this, but I do use the fullscreen layout as it is with some apps, so I don't want to lose it.

Is there some way for me to learn how to make custom layouts?

@ianyh
Copy link
Owner

ianyh commented Feb 9, 2023

Ah, so it depends on what application the currently focused window belongs to? I can create a custom layout template to make it easier to modify so you would be able to just do the frame manipulations, but regardless custom layouts intentionally don't know what applications are running and which windows belong to which.

@EttVenter
Copy link
Author

Ah, so it depends on what application the currently focused window belongs to? I can create a custom layout template to make it easier to modify so you would be able to just do the frame manipulations, but regardless custom layouts intentionally don't know what applications are running and which windows belong to which.

Oh! Sorry, I must've miscommunicated.

I don't need amethyst to detect what app the window belongs to. Here's my situation:

The fullscreen layout works great in some situations, like with my browser. Other apps, like Finder, or Things 3, become very inefficient to use what the windows are that size. So I want to be able to have a layout that only got space for 1 window, and the size/placement of that "space for a window" would be something I can predefine.

Does that make sense?

@EttVenter
Copy link
Author

Still wondering if someone could offer up a custom file or help me learn how to make my own?

@niemes
Copy link

niemes commented Apr 8, 2024

Just saw this message : Here we go. If you still need that layout. It's not a complex layout, but I can see that the current documentation is not super easy x).

function layout() {
    return {
        name: "One for All",
        initialState: {
            mainPaneCount: 1
        },
        getFrameAssignments: (windows, screenFrame) => {
            const mainPaneWidth = Math.round(screenFrame.width - 300);
            const mainPaneWindowHeight = Math.round((screenFrame.height - 150));

            const marginTop = 50;
            const marginLeft = 0;

            let frames = {};
            
            windows.forEach((window) => {
                const windowFrame = {
                    x: ((screenFrame.width + marginLeft) / 2) - (mainPaneWidth / 2),
                    y: ((screenFrame.height / 2) - (mainPaneWindowHeight / 2)) + marginTop,
                    width: mainPaneWidth,
                    height: mainPaneWindowHeight
                };
                frames[window.id] = windowFrame;
            });

            return frames;
        }
    };
}

You can tweak the margin to offset the center or change the size of the single window.
Hope this help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants