Eyedropper Color Preview
Needs ReviewPublic

Authored by Marcelo Mutzbauer (1xundoredo) on Sep 9 2015, 2:08 PM.



The color property gets set on mouse movement when the p key is pressed. When the p key gets released or the operator gets cancelled, the color will be reset to the state before the operator ran.
This helps choosing a color because you do not have to 'guess' what color your mouse cursor is on.

Diff Detail

rB Blender

This is a nice little feature @Marcelo Mutzbauer (1xundoredo). It works quite well from the user side (I cannot speak to the code side).

However, it has the same issue that many of our modal operators have, in that it has very low discoverability. This is not so much of an issue since it's a non-essential feature, but it's still less than optimal for the sake of actually helping people use it.

Until we have a better way to present additional user information within a modal the best way to give more feedback is through the Eyedropper tool tip. Currently the eye dropper tool tip is pretty poor: Sample a data-block from the 3D View. This is poor because many users won't know what a "data-block" is in this context and because the eyedropper works on any color element (even the UI).

You could utilize the tooltip to introduce the CTRL key concept. We already do this with 3D View Layers:

  • Change tooltip to 'Sample a data-block from this window - Hold Ctrl to preview color'
  • Fix some updating problems in user prefs
  • Code Style: no cuddled else
  • Fix problem with alpha channel
  • Change tooltip to 'Sample a color from this window - Hold Ctrl for preview'

Looking good, just two minor suggestions.


Would cast here: (Eyedropper *)op->customdata


Maybe pack this into own function eyedropper_color_reset which can be called from here and eyedropper_cancel.

This revision is now accepted and ready to land.Sep 27 2015, 2:53 AM
  • Moved reset to separate function
  • op->customdata casted (in the arguments for the reset function)

We like to use doxygen style comments which could be used here, too:

 * blahblah
  • Use Doxygen-style comment for reset function
  • Invoke eyedropper via Ctrl+E
Julian Eisel (Severin) requested changes to this revision.EditedMar 5 2016, 9:05 PM

Noticed it would be preferable to have a configurable key for activating the preview. Committed support for customizable eyedropper keymap (rBc1d05faa24af02e50). @Marcelo Mutzbauer (1xundoredo), would you mind updating the patch so this is used?

Note, for the operator description you can use WM_modalkeymap_operator_items_to_string to get a string for the final keymap item.

This revision now requires changes to proceed.Mar 5 2016, 9:05 PM
  • Update for customizable keymap

It seems that keymaps are only being initialized once operator types have been, which makes it difficult to introduce those shortcuts in the tooltip(Keys not available yet in init func).
Alternatively, it would be possible to place hints below the cursor during operator execution(below the sampled pixel).

@Julian Eisel (Severin) if we're able to address the issue of showing the keymap in the tooltip then this can probably get committed. I'd like to give it a run through again, though, just need to pull down and compile when I've got a moment.