UI: Allow Eyedropper Outside of Blender #105324

Merged
Harley Acheson merged 3 commits from Harley/blender:Eyedropper into main 2023-08-16 01:14:43 +02:00
5 changed files with 20 additions and 18 deletions
Showing only changes of commit d6307ed222 - Show all commits

View File

@ -766,7 +766,7 @@ extern void GHOST_SetTabletAPI(GHOST_SystemHandle systemhandle, GHOST_TTabletAPI
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned RGB float colors
* \param r_color: returned sRGB float colors
Harley marked this conversation as resolved Outdated

Can you change RGB -> sRGB to clarify the color space. Here and a few other places that repeat the same comment.

Can you change RGB -> sRGB to clarify the color space. Here and a few other places that repeat the same comment.
* \return Success value (true == successful and supported by platform)
*/
extern GHOST_TSuccess GHOST_GetPixelAtCursor(float r_color[3]);

View File

@ -443,7 +443,7 @@ class GHOST_ISystem {
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned RGB float colors
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
virtual GHOST_TSuccess getPixelAtCursor(float r_color[3]) const = 0;

View File

@ -258,7 +258,7 @@ class GHOST_System : public GHOST_ISystem {
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned RGB float colors
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const;

View File

@ -184,7 +184,7 @@ class GHOST_SystemWin32 : public GHOST_System {
/**
* Get the color of the pixel at the current mouse cursor location
* \param r_color: returned RGB float colors
* \param r_color: returned sRGB float colors
* \return Success value (true == successful and supported by platform)
*/
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const;

View File

@ -351,22 +351,24 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
}
}
if (!(WM_capabilities_flag() & WM_CAPABILITY_DESKTOP_SAMPLE &&
WM_desktop_cursor_sample_read(r_col)))
{
if (win) {
if (!WM_window_pixels_read_sample(C, win, mval, r_col)) {
WM_window_pixels_read_sample_from_offscreen(C, win, mval, r_col);
}
}
else {
zero_v3(r_col);
if (win) {
/* Other areas within a Blender window. */
if (!WM_window_pixels_read_sample(C, win, mval, r_col)) {
WM_window_pixels_read_sample_from_offscreen(C, win, mval, r_col);
}
const char *display_device = CTX_data_scene(C)->display_settings.display_device;
ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
IMB_colormanagement_display_to_scene_linear_v3(r_col, display);
}
else if ((WM_capabilities_flag() & WM_CAPABILITY_DESKTOP_SAMPLE) &&
WM_desktop_cursor_sample_read(r_col))
{
/* Outside of the Blender window if we support it. */
IMB_colormanagement_srgb_to_scene_linear_v3(r_col, r_col);
}
else {
Harley marked this conversation as resolved Outdated

Use IMB_colormanagement_srgb_to_scene_linear_v3 instead if the color came from another window.

When doing color picker of for a 3D viewport or render that Blender displays then taking into account the view transform makes sense. But from another window, it seems wrong to me.

Use `IMB_colormanagement_srgb_to_scene_linear_v3` instead if the color came from another window. When doing color picker of for a 3D viewport or render that Blender displays then taking into account the view transform makes sense. But from another window, it seems wrong to me.
zero_v3(r_col);
}
const char *display_device = CTX_data_scene(C)->display_settings.display_device;
ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
IMB_colormanagement_display_to_scene_linear_v3(r_col, display);
}
/* sets the sample color RGB, maintaining A */