无限文档的滚动条?

发布于 2024-08-30 15:43:55 字数 247 浏览 3 评论 0原文

是否有标准的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎的声音 2024-09-06 15:43:55

一种选择是在用户滚动时动态扩展该区域 - 每当用户在边缘的 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.

踏雪无痕 2024-09-06 15:43:55

您是否见过 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. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文