Scroll bars for an endless document?
Is there a standard Aqua way to handle an almost infinite document?
For example, imagine a level editor for a tile based game. The level has no fixed size (although it is technically limited by size NSInteger
); tiles can be placed anywhere on the grid. Is there a standard interface for scrolling through such a document?
I can't just restrict scrolling to areas that already have tiles, because the user needs to be able to add tiles outside of that border. Arbitrarily creating the size of the level, even if easily replaceable by the user, also doesn't seem ideal.
Has anyone seen an application that deals with this issue?
a source to share
One option is to dramatically expand the area as the user scrolls it down - anytime the user scrolls inside X units of the edge, add another device in that direction. Basically, you can never scroll "all the way" to the edge, because the closer you get, the more it will expand.
If the user scrolls backward from the edge, squeeze it until it is larger than X units where the content is.
a source to share
Have you seen what Microsoft Excel does for this problem? It should also represent unlimited space with scrollbars.
One solution is to define reasonable space for the original size of the level, and when the user scrolls to one slice from their borders, add another row or column of tiles and adjust the scrollbar accordingly. Thus, the user never reaches the actual boundaries.
If the user chooses to reduce the size of the level, you can also add code that shrinks "reasonable space" as soon as the unused line consists of only empty chunks. This saves the user from getting stuck with the huge level they were scrolling through with no way to reduce it.
Edit: Same as Dove. :)
a source to share