编写文档编辑器的编程技巧?

发布于 2024-08-27 11:30:27 字数 551 浏览 3 评论 0原文

我问这个问题是因为我正在为我的洛克人引擎编写两个这样的编辑器,一个是图块集编辑器,另一个是关卡编辑器。

当我说文档编辑器时,我指的是图像编辑器和文本编辑器等应用程序类型的超集。所有这些都共享工具栏、菜单选项等内容,对于图像编辑器和我的应用程序来说,还有工具窗格。我们都知道这些应用程序中有大量关于界面设计的建议,但我想知道有关编程的建议。

具体来说,我怀疑我的代码设计有以下几点:

  • 许多菜单选项会切换各种行为。将选项的检查状态与行为状态可靠地联系起来的正确方法是什么?有时情况会更复杂,例如在未加载文档时禁用选项。
  • 越来越多的共识似乎反对使用 MDI,但我应该如何控制工具窗格呢?例如,我不知道如何让面板与主窗口一起最小化和最大化,就像 Photoshop 那样。
  • 当工具面板负责文档的特定部分时,谁真正拥有该部分?主窗口,还是面板类?
  • 工具面板和主窗口之间如何进行通信?目前我的都是基于事件的,但似乎可能有更好的方法。

这似乎是一个常见的 gui 应用程序类,但我从未见过关于它们的代码设计的具体指针。您能提供一下您在写作方面的建议或经验吗?

I'm asking this because I'm in the process of writing two such editors for my Mega Man engine, one a tileset editor, and another a level editor.

When I say document editor, I mean the superset application type for things like image editors and text editors. All of these share things like toolbars, menu options, and in the case of image editors, and my apps, tool panes. We all know there's tons of advice out there for interface design in these apps, but I'm wondering about programming advice.

Specifically, I'm doubting my code designs with the following things:

  • Many menu options toggle various behaviors. What's the proper way to reliably tie the checked state of the option with the status of the behavior? Sometimes it's more complicated, like options being disabled when there's no document loaded.
  • More and more consensus seems to be against using MDI, but how should I control tool panes? For example, I can't figure out how to get the panels to minimize and maximize along with the main window, like Photoshop does.
  • When tool panels are responsible for a particular part of the document, who actually owns that thing? The main window, or the panel class?
  • How do you do communication between the tool panels and the main window? Currently mine is all event based but it seems like there could be a better way.

This seems to be a common class of gui application, but I've never seen specific pointers on code design for them. Could you please offer whatever advice or experience you have for writing them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

飞烟轻若梦 2024-09-03 11:30:27

我猜你的“面板”是 Windows.Forms.Form 的:

如果你将它们的所有者设置为你的主窗口,它们会在你的主窗口最小化时自动最小化。

I guess your "panels" are Windows.Forms.Form's:

If you set their Owner to your main window, they'll automatically minimize when your main window does.

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