algorithmpackingtiling

Algorithm to fit windows on desktop (like tile)


I searching algorithm to solve problem like this:

I have few windows, each window can be moved and re sized but with specified ratio between width and height, eg. 2:1 (height:width).

Each window can't be on other window and all windows must be fully visible. Free area (desktop wallpaper visibility) must be minimal.

Can anyone tell me what algorithm i need for this type of problem?

Greetings,


Solution

  • Another approach, which might be simpler to implement than packing, would be to subdivide your screen size into the required number of panes, then fit a window which satisfies your other requirements inside the pane. Since you'll probably have a small number of windows open at any time, and since your screen doesn't change its size dynamically, you can probably pre-compute all the arrangements you need for 1 up to O(100) open windows.