webamp
webamp copied to clipboard
Add API to control which windows are showing
One often requested feature (e.g. #1023) is the ability to control which windows are visible. There are a lot of things this might end up including, and I'm not 100% sure how it should work.
- Control initial set of open windows.
- Control initial position of windows.
- Control the initial size of windows.
- Imperatively control the position of a window in a running instance of Webamp.
- Imperatively open/close windows in a running instance of Webamp.
- Imperatively control the size or windows in a running instance of Webamp.
If we wanted to simplify things to just one API, we could skip 1-3 and just implement 4-6 (or even a subset to start with) since users could construct a Webamp instance and then imperatively set the window positions before rendering.
This is all further complicated by the auto-layout we do to ensure Webamp gets centered within the element you render it into. Currently we have internal APIs that let us position the windows but they end up only being relative to each other since we center the windows relative to the space they take up rather than relative to some 0,0 (I think).
One other question I have is should we have separate methods for controlling each window, or should we have a single enum which gets passed an identifier for which window the user wants to act on.
A frustratingly large number of decisions to make.
Next Steps
Document how we might achieve these effects using the Redux actions directly. That will help unblock #1023 and perhaps give us some insights.
Here's an initial sketch of open/close windows methods: https://github.com/captbaritone/webamp/pull/new/open-close-window
Another option, would be to only do 1-3. This would feel more intuitive and probably solves most people's problems. We already have most of the code for this in the demo app. The down side is that if people do need to imperatively update things (4-6) then we'll need two APIs. That's probably worth having.
Open questions for this approach:
- How would user's describe window size? Internally we do a width/height tuple where each value is a number of sprites. We can switch to an object to make it a little clearer, but we should clarify via API/docs that these are sprites and not pixels.
- How do users describe which windows are open/closed? Should they be able to just omit closed windows? That would prevent them for specifying the position a window should have if/when it gets opened. Another option would be an optional
closedproperty for each window. This leaves open the question of what should happen if a window layout option is omitted entirely. Should that be an error? Or should you be allowed to specify only the windows you want to override default for?