Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Add modal tool states with the eyedropper, and implement pixel sampling in the color picker popover

Open Keavon opened this issue 3 years ago • 1 comments

A "modal tool state" is a temporary state where a tool can present a simple mouse-based interaction, which takes precedence over the active tool. It shows hints, a custom cursor, and can direct messages on the different events (mousedown, mousemove, mouseup, keyboard modifiers, and keyboard events).

The first example, which this issue covers, is the eyedropper modal tool state. This should be activated by clicking the eyedropper icon in the ColorPicker.vue popover. Also, the existing Eyedropper tool (accessible in the tool shelf as a full-blown tool) should, upon clicking with LMB or RMB, activate this modal tool to reuse its code. The modal tool state will need the current mouse position every frame it's moved (mousemove event) so it can send a FrontendMessage::UpdateEyedropperSamplingState message with the canvas position and other details. For this one, hitting Escape should exit the modal tool state and return back to whatever viewport tool the user was doing, in whatever state it was in.

Other future modal tool states, to provide some examples to understand how this feature will be used:

  • "Pick a layer to reference" (in the Properties panel for a particular node that needs the input of another node/layer as a reference, Blender has something similar for picking a specific 3D object to reference when setting up shader nodes or other things)
  • "Quick export" where you press a hotkey and drag a rectangle to instantly download a "screenshot" of that part of the canvas
  • "Paste style" where you right click an object, click Copy/Paste Style from the context menu, and your cursor becomes a paste modal where you click on an object to paste the copied style on it as a target
  • Other things where you hit a hotkey to enter the mode briefly and can use your mouse to interact on a temporary basis, usually where Escape exits the mode and returns to whatever actual tool you were using

Keavon avatar Oct 29 '22 01:10 Keavon

Blocking #805

Keavon avatar Nov 04 '22 10:11 Keavon