GraphiteEditor / GraphiteEditor/Graphite

Refactor the "actions" system into a unified and capable "commands" system

未关闭
#741 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Web
主要语言
Rust
星标
27.2k
派生
1.3k
平均合并
20 小时 5 分钟
30 天内合并 PR
57

描述

Essentially, commands are a user-facing concept for translating user interaction into graph update messages. They are states of interaction that can be entered, canceled (aborted), committed, or replaced with another ongoing command.

## Rename from actions to commands

The current approach based on the message system uses the term "actions". This refactor will instead use the term "commands" to distinguish it from the current approach, and because that is the preferable terminology.

## Separation from message system

Currently, the message system is (ab)used for actions, which imposes some limitations. The whole action is a write-only event that must be dispatched instantaneously with known parameters. We need more flexibility for dynamically updating the parameters (like Blender's bottom left command parameters menu that can adjust the values after a command was run). Commands also need to report their current validity and status based on state and configurations. So it needs to be able to determine if it's valid to be run in the current state, and can report itself as grayed out if not. It also needs to know its current keyboard shortcuts so it can report that. Also, it needs to know its canonical organization within the menu bar's menus to tell the user where to look. It should also present a tooltip for the command definition, shown anywhere it's presented. These changes will also make it easier to break up document editing into discrete command steps, enabling the repeating of an action (#1979), showing in the *File* > *Undo*/*Redo* menu listings a name of the command that will be undone/redone, or even a whole history panel showing each editing step that changed the document.

## Quick access menus and custom hotkey bindings

Any command should be able to be bound to a keyboard shortcut (#1544) or quick favorites, just like in Blender, by right clicking on it from any menu. Commands need to be standardized enough for display in different locations that any menu can utilize the reusable concept, whether that's in the menu bar entries, command palette (#384), any right click context menu (#138), and many dropdown menus that display a list of commands similar to a context menu.

## Breaking out tool behavior into commands

Currently, the tools perform the actual interaction states. The state machine for a tool dictates what behavior the tool is engaging in at that time. We'd like to instead move towards a model where the tools aren't engaging in the behavior themselves, but just managing the transitions between states which run the commands that perform the behavior. That way many tools can reuse the same behavior. A good example is the Tilt command, which in its current (action) form, exists in three places: (1) from any tool by holding Alt + MMB and moving the cursor, (2) with the Navigate tool by holding Alt + LMB and moving the cursor, or (3) clicking the *View* > *Tilt* menu command (action) and moving the cursor (without any key held down).

## Combine with the hints system

This lets us avoid redundantly specifying both the presently available actions (which are currently valid hotkeys) and curated hints (which are drawn for the user). By combining them, it forces us to be comprehensive about our hint list. We still need to provide the human-curated list of hints where a name and grouping is provided to render neatly for human consumption, but the attached actions would thus become part of the hints instead of being a separate system. Pulling off this change requires that we increase the capabilities of the input mapper for specifying how mouse interaction works with keys, and avoiding our current way of telling some messages to check for the status of certain modifier keys in the handler (those which use `refresh_keys` in the input mapper). We need to make changes to the system in order to be able to accurately derive the mouse and keyboard icons from the input mapper entry.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先梳理当前的操作和消息系统,然后跟踪工具、提示系统和输入映射器如何处理交互状态和修饰键。查看 issues #1979、#1544、#384 和 #138 中的相关问题。完成的标准是形成一份经过 соглас? 的迁移设计,涵盖命令状态、菜单、快捷键、提示和工具行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
rust
领域
tooling
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。