webamp icon indicating copy to clipboard operation
webamp copied to clipboard

How do you programatically adjust the window layout/sizes?

Open ryanpcmcquen opened this issue 6 years ago • 7 comments

For instance, I'd like to load Webamp with this layout: preview

I can't find anything about window sizes in the usage docs.

ryanpcmcquen avatar May 10 '19 15:05 ryanpcmcquen

Found it!

            __initialWindowLayout: {
                main: { position: { x: 0, y: 0 } },
                equalizer: { position: { x: 0, y: 116 } },
                playlist: { position: { x: 275, y: 0 }, size: [0, 4] }
            }

ryanpcmcquen avatar May 10 '19 15:05 ryanpcmcquen

Has anyone figured out the wizardry that is involved in placing the windows where? It's kinda like the numbers that you put into the position spots are used as a seed in a pseudorandom number gen. And it places the windows like that.

divSelector avatar Aug 25 '23 14:08 divSelector

It's kinda weird how this thing can do literally anything, but if you want to place the element at a specific position, that is just out of the question. Top left corner only bruh.

divSelector avatar Aug 25 '23 15:08 divSelector

I tried changing the element's top and left properties but, if it doesn't render at farthest top left corner, it think that it cant go any further left or up.

divSelector avatar Aug 25 '23 15:08 divSelector

Well, I figured it out.

 useEffect(() => {
    let intervalId;

    const positionElement = (elem) => {
      let x, y
      for (const [index, each] of Array.from(elem.children).entries()) {
        x = 400
        y = 100 + (index+1) * 116;
        elem.style.transform = `translate(${x}px, ${y}px)`
      }
      elem.parentElement.parentElement.style.visibility = 'visible'
    }

    const checkElement = () => {
      const elem = document.querySelector('#webamp > div > div');
      if (elem) {
        clearInterval(intervalId);
        positionElement(elem)
      }
    };

    if (isOpen) {
      intervalId = setInterval(checkElement, 100);
    }

    return () => {
      clearInterval(intervalId);
    };
  }, [isOpen]);

One of the hackiest things I've ever done but it works.

divSelector avatar Aug 25 '23 15:08 divSelector

And that doesn't work either. If I manually set the position in any way, it thinks that where ever i place it is 0, 0. So it just can't be done haha.

divSelector avatar Aug 25 '23 15:08 divSelector

And that doesn't work either. If I manually set the position in any way, it thinks that where ever i place it is 0, 0. So it just can't be done haha.

Did you check this out?

https://github.com/captbaritone/webamp/issues/1215

ryanpcmcquen avatar Aug 26 '23 17:08 ryanpcmcquen