Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Keavon opened this issue Jul 30, 2022 · 2 comments
Open
Labels
Web Involves web programming (TypeScript, Svelte, CSS)

Comments

@Keavon
Copy link
Member

Keavon commented Jul 30, 2022

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.

@Keavon Keavon added Feature Web Involves web programming (TypeScript, Svelte, CSS) labels Jul 30, 2022
@Keavon Keavon added this to the Sprint 18 (upcoming) milestone Jul 30, 2022
@Keavon Keavon added P-High and removed P-Medium labels Aug 13, 2022
@Keavon Keavon added P-Medium and removed P-High labels Aug 13, 2022
@0HyperCube 0HyperCube moved this to Longer-Term in Task Board Mar 18, 2023
@Keavon Keavon removed the Available label May 31, 2023
@Keavon Keavon moved this to Longer-Term in Task Board May 31, 2023
@Keavon Keavon removed the P-Medium label May 31, 2023
@TrueDoctor
Copy link
Member

@Keavon Is this still relevant?

@Keavon
Copy link
Member Author

Keavon commented Jan 10, 2024

Yes, eventually. Next time I'm on a code cleanup binge I might even go for it.

@Keavon Keavon removed the Rust label Dec 30, 2024
@Keavon Keavon changed the title Combine the hints and actions systems Refactor the "actions" system into a unified and capable "commands" system Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Web Involves web programming (TypeScript, Svelte, CSS)
Projects
Status: Longer-Term
Development

No branches or pull requests

2 participants