无限文档的滚动条?
是否有标准的 Aqua 方式来处理几乎无限的文档?
例如,想象一个基于图块的游戏的关卡编辑器。该关卡没有预设大小(尽管技术上它受到 NSInteger
大小的限制);瓷砖可以放置在网格上的任何位置。是否有用于滚动浏览此类文档的标准界面?
我不能简单地限制滚动到已经有图块的区域,因为用户需要能够在该边界之外添加图块。任意创建关卡大小,即使用户可以轻松更改,似乎也不理想。
有人见过处理这个问题的应用程序吗?
Is there a standard Aqua way to handle a practically infinite document?
For example, imagine a level editor for a tile-based game. The level has no preset size (though it's technically limited by NSInteger
's size); tiles can be placed anywhere on the grid. Is there a standard interface for scrolling through such a document?
I can't simply limit the scrolling to areas that already have tiles, because the user needs to be able to add tiles outside that boundary. Arbitrarily creating a level size, even if it's easily changeable by the user, doesn't seem ideal either.
Has anyone seen an application that deals with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种选择是在用户滚动时动态扩展该区域 - 每当用户在边缘的 X 单位内滚动时,就在该方向添加另一个单位。从本质上讲,您永远无法“一直”滚动到边缘,因为距离越近,它就会扩展得越远。
如果用户从边缘向后滚动,请将其收缩到实际内容之外不超过 X 个单位。
One option is to essentially dynamically expand the area as the user scrolls through it - any time the user scrolls within X units of an edge, add another unit in that direction. Essentially, you'll never be able to scroll "all the way" to an edge, because the closer you get the farther it will expand.
If the user scrolls back away from the edge, contract it to back to no more than X units beyond where there is actually content.
您是否见过 Microsoft Excel 是如何解决这个问题的?它还必须代表带有滚动条的无限空间。
一种解决方案是为原始关卡大小定义合理的空间,当用户滚动到远离其边界的一个图块时,添加另一行或一列图块,并相应地调整滚动条。这样,用户永远不会达到实际的界限。
如果用户决定缩小关卡大小,您还可以添加代码,在未使用的行仅由空图块组成时缩小“合理空间”。这可以让用户避免被困在滚动浏览的巨大关卡中,而无法缩小它。
编辑:与戴夫的答案相同。 :)
Have you seen what Microsoft Excel does for this problem? It has to represent an unbounded space with scrollbars, as well.
One solution is to define a reasonable space for the original level size, and when the user scrolls to one tile away from its bounds, add another row or column of tiles, and adjust the scrollbar accordingly. This way, the user never reaches the actual bounds.
If the user decides to cut down on the level size, you could also add code that shrinks the "reasonable space" once an unused row consists only of empty tiles. This saves the user from being stuck with a huge level that they scrolled through, with no way to shrink it.
Edit: Same as Dav's answer. :)