Blender  V2.93
interface_eyedropper_color.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19 
29 #include "MEM_guardedalloc.h"
30 
31 #include "DNA_screen_types.h"
32 #include "DNA_space_types.h"
33 
34 #include "BLI_listbase.h"
35 #include "BLI_math_vector.h"
36 #include "BLI_string.h"
37 
38 #include "BKE_context.h"
39 #include "BKE_cryptomatte.h"
40 #include "BKE_image.h"
41 #include "BKE_main.h"
42 #include "BKE_node.h"
43 #include "BKE_screen.h"
44 
45 #include "RNA_access.h"
46 
47 #include "UI_interface.h"
48 
49 #include "IMB_colormanagement.h"
50 #include "IMB_imbuf_types.h"
51 
52 #include "WM_api.h"
53 #include "WM_types.h"
54 
55 #include "RNA_define.h"
56 
57 #include "interface_intern.h"
58 
59 #include "ED_clip.h"
60 #include "ED_image.h"
61 #include "ED_node.h"
62 #include "ED_screen.h"
63 
64 #include "RE_pipeline.h"
65 
66 #include "RE_pipeline.h"
67 
69 
70 typedef struct Eyedropper {
72 
75  int index;
76  bool is_undo;
77 
78  bool is_set;
79  float init_col[3]; /* for resetting on cancel */
80 
81  bool accum_start; /* has mouse been pressed */
82  float accum_col[3];
83  int accum_tot;
84 
87 
91 
92 static void eyedropper_draw_cb(const wmWindow *window, void *arg)
93 {
94  Eyedropper *eye = arg;
96 }
97 
99 {
100  Eyedropper *eye = MEM_callocN(sizeof(Eyedropper), __func__);
101 
102  uiBut *but = UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
103  const enum PropertySubType prop_subtype = eye->prop ? RNA_property_subtype(eye->prop) : 0;
104 
105  if ((eye->ptr.data == NULL) || (eye->prop == NULL) ||
106  (RNA_property_editable(&eye->ptr, eye->prop) == false) ||
107  (RNA_property_array_length(&eye->ptr, eye->prop) < 3) ||
108  (RNA_property_type(eye->prop) != PROP_FLOAT) ||
109  (ELEM(prop_subtype, PROP_COLOR, PROP_COLOR_GAMMA) == 0)) {
110  MEM_freeN(eye);
111  return false;
112  }
113  op->customdata = eye;
114 
116 
117  float col[4];
120  eye->crypto_node = (bNode *)eye->ptr.data;
122  eye->crypto_node);
124  }
125 
126  if (prop_subtype != PROP_COLOR) {
128  const char *display_device;
129 
130  display_device = scene->display_settings.display_device;
131  eye->display = IMB_colormanagement_display_get_named(display_device);
132 
133  /* store initial color */
134  if (eye->display) {
136  }
137  }
138  copy_v3_v3(eye->init_col, col);
139 
140  return true;
141 }
142 
144 {
145  Eyedropper *eye = op->customdata;
146  wmWindow *window = CTX_wm_window(C);
147  WM_cursor_modal_restore(window);
148 
149  if (eye->draw_handle_sample_text) {
152  }
153 
154  if (eye->cryptomatte_session) {
156  eye->cryptomatte_session = NULL;
157  }
158 
160 }
161 
162 /* *** eyedropper_color_ helper functions *** */
163 
165  const char *prefix,
166  const float fpos[2],
167  float r_col[3])
168 {
169  if (!render_layer) {
170  return false;
171  }
172 
173  const int render_layer_name_len = BLI_strnlen(render_layer->name, sizeof(render_layer->name));
174  if (strncmp(prefix, render_layer->name, render_layer_name_len) != 0) {
175  return false;
176  }
177 
178  const int prefix_len = strlen(prefix);
179  if (prefix_len <= render_layer_name_len + 1) {
180  return false;
181  }
182 
183  /* RenderResult from images can have no render layer name. */
184  const char *render_pass_name_prefix = render_layer_name_len ?
185  prefix + 1 + render_layer_name_len :
186  prefix;
187 
188  LISTBASE_FOREACH (RenderPass *, render_pass, &render_layer->passes) {
189  if (STRPREFIX(render_pass->name, render_pass_name_prefix) &&
190  !STREQLEN(render_pass->name, render_pass_name_prefix, sizeof(render_pass->name))) {
191  BLI_assert(render_pass->channels == 4);
192  const int x = (int)(fpos[0] * render_pass->rectx);
193  const int y = (int)(fpos[1] * render_pass->recty);
194  const int offset = 4 * (y * render_pass->rectx + x);
195  zero_v3(r_col);
196  r_col[0] = render_pass->rect[offset];
197  return true;
198  }
199  }
200 
201  return false;
202 }
204  const char *prefix,
205  const float fpos[2],
206  float r_col[3])
207 {
208  bool success = false;
209  Scene *scene = (Scene *)node->id;
212 
213  if (re) {
215  if (rr) {
216  LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
217  RenderLayer *render_layer = RE_GetRenderLayer(rr, view_layer->name);
218  success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
219  if (success) {
220  break;
221  }
222  }
223  }
224  RE_ReleaseResult(re);
225  }
226  return success;
227 }
228 
230  NodeCryptomatte *crypto,
231  const char *prefix,
232  const float fpos[2],
233  float r_col[3])
234 {
235  bool success = false;
236  Image *image = (Image *)node->id;
237  BLI_assert(GS(image->id.name) == ID_IM);
238  ImageUser *iuser = &crypto->iuser;
239 
240  if (image && image->type == IMA_TYPE_MULTILAYER) {
241  ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, NULL);
242  if (image->rr) {
243  LISTBASE_FOREACH (RenderLayer *, render_layer, &image->rr->layers) {
244  success = eyedropper_cryptomatte_sample_renderlayer_fl(render_layer, prefix, fpos, r_col);
245  if (success) {
246  break;
247  }
248  }
249  }
250  BKE_image_release_ibuf(image, ibuf, NULL);
251  }
252  return success;
253 }
254 
256  bContext *C, Eyedropper *eye, int mx, int my, float r_col[3])
257 {
258  bNode *node = eye->crypto_node;
259  NodeCryptomatte *crypto = node ? ((NodeCryptomatte *)node->storage) : NULL;
260 
261  if (!crypto) {
262  return false;
263  }
264 
265  bScreen *screen = CTX_wm_screen(C);
266  ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
267  if (!sa || !ELEM(sa->spacetype, SPACE_IMAGE, SPACE_NODE, SPACE_CLIP)) {
268  return false;
269  }
270 
272  if (!ar) {
273  return false;
274  }
275 
276  int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin};
277  float fpos[2] = {-1.0f, -1.0};
278  switch (sa->spacetype) {
279  case SPACE_IMAGE: {
280  SpaceImage *sima = sa->spacedata.first;
281  ED_space_image_get_position(sima, ar, mval, fpos);
282  break;
283  }
284  case SPACE_NODE: {
285  Main *bmain = CTX_data_main(C);
286  SpaceNode *snode = sa->spacedata.first;
287  ED_space_node_get_position(bmain, snode, ar, mval, fpos);
288  break;
289  }
290  case SPACE_CLIP: {
291  SpaceClip *sc = sa->spacedata.first;
292  ED_space_clip_get_position(sc, ar, mval, fpos);
293  break;
294  }
295  default: {
296  break;
297  }
298  }
299 
300  if (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f) {
301  return false;
302  }
303 
304  /* CMP_CRYPTOMATTE_SRC_RENDER and CMP_CRYPTOMATTE_SRC_IMAGE require a referenced image/scene to
305  * work properly. */
306  if (!node->id) {
307  return false;
308  }
309 
310  /* TODO(jbakker): Migrate this file to cc and use std::string as return param. */
311  char prefix[MAX_NAME + 1];
312  const Scene *scene = CTX_data_scene(C);
313  ntreeCompositCryptomatteLayerPrefix(scene, node, prefix, sizeof(prefix) - 1);
314  prefix[MAX_NAME] = '\0';
315 
316  if (node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER) {
317  return eyedropper_cryptomatte_sample_render_fl(node, prefix, fpos, r_col);
318  }
319  else if (node->custom1 == CMP_CRYPTOMATTE_SRC_IMAGE) {
320  return eyedropper_cryptomatte_sample_image_fl(node, crypto, prefix, fpos, r_col);
321  }
322  return false;
323 }
324 
332 void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
333 {
334  /* we could use some clever */
335  Main *bmain = CTX_data_main(C);
337  const char *display_device = CTX_data_scene(C)->display_settings.display_device;
338  struct ColorManagedDisplay *display = IMB_colormanagement_display_get_named(display_device);
339 
340  wmWindow *win = CTX_wm_window(C);
341  bScreen *screen = CTX_wm_screen(C);
343  if (area == NULL) {
344  int mval[2] = {mx, my};
345  if (WM_window_find_under_cursor(wm, NULL, win, mval, &win, mval)) {
346  mx = mval[0];
347  my = mval[1];
348  screen = WM_window_get_active_screen(win);
349  area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
350  }
351  else {
352  win = NULL;
353  }
354  }
355 
356  if (area) {
357  if (area->spacetype == SPACE_IMAGE) {
359  if (region) {
360  SpaceImage *sima = area->spacedata.first;
361  int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
362 
363  if (ED_space_image_color_sample(sima, region, mval, r_col, NULL)) {
364  return;
365  }
366  }
367  }
368  else if (area->spacetype == SPACE_NODE) {
370  if (region) {
371  SpaceNode *snode = area->spacedata.first;
372  const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
373 
374  if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) {
375  return;
376  }
377  }
378  }
379  else if (area->spacetype == SPACE_CLIP) {
381  if (region) {
382  SpaceClip *sc = area->spacedata.first;
383  int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin};
384 
385  if (ED_space_clip_color_sample(sc, region, mval, r_col)) {
386  return;
387  }
388  }
389  }
390  }
391 
392  if (win) {
393  /* Fallback to simple opengl picker. */
394  const int mval[2] = {mx, my};
395  WM_window_pixel_sample_read(wm, win, mval, r_col);
397  }
398  else {
399  zero_v3(r_col);
400  }
401 }
402 
403 /* sets the sample color RGB, maintaining A */
404 static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
405 {
406  float col_conv[4];
407 
408  /* to maintain alpha */
409  RNA_property_float_get_array(&eye->ptr, eye->prop, col_conv);
410 
411  /* convert from linear rgb space to display space */
412  if (eye->display) {
413  copy_v3_v3(col_conv, col);
415  }
416  else {
417  copy_v3_v3(col_conv, col);
418  }
419 
420  RNA_property_float_set_array(&eye->ptr, eye->prop, col_conv);
421  eye->is_set = true;
422 
423  RNA_property_update(C, &eye->ptr, eye->prop);
424 }
425 
426 static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
427 {
428  /* Accumulate color. */
429  float col[3];
430  if (eye->crypto_node) {
431  if (!eyedropper_cryptomatte_sample_fl(C, eye, mx, my, col)) {
432  return;
433  }
434  }
435  else {
436  eyedropper_color_sample_fl(C, mx, my, col);
437  }
438 
439  if (!eye->crypto_node) {
440  add_v3_v3(eye->accum_col, col);
441  eye->accum_tot++;
442  }
443  else {
444  copy_v3_v3(eye->accum_col, col);
445  eye->accum_tot = 1;
446  }
447 
448  /* Apply to property. */
449  float accum_col[3];
450  if (eye->accum_tot > 1) {
451  mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot);
452  }
453  else {
454  copy_v3_v3(accum_col, eye->accum_col);
455  }
456  eyedropper_color_set(C, eye, accum_col);
457 }
458 
459 static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, int mx, int my)
460 {
461  float col[3];
462  eye->sample_text[0] = '\0';
463 
464  if (eye->cryptomatte_session) {
465  if (eyedropper_cryptomatte_sample_fl(C, eye, mx, my, col)) {
467  eye->cryptomatte_session, col[0], eye->sample_text, sizeof(eye->sample_text));
468  eye->sample_text[sizeof(eye->sample_text) - 1] = '\0';
469  }
470  }
471 }
472 
474 {
475  Eyedropper *eye = op->customdata;
476  if (eye->is_set) {
477  eyedropper_color_set(C, eye, eye->init_col);
478  }
479  eyedropper_exit(C, op);
480 }
481 
482 /* main modal status check */
483 static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
484 {
485  Eyedropper *eye = (Eyedropper *)op->customdata;
486 
487  /* handle modal keymap */
488  if (event->type == EVT_MODAL_MAP) {
489  switch (event->val) {
490  case EYE_MODAL_CANCEL:
491  eyedropper_cancel(C, op);
492  return OPERATOR_CANCELLED;
494  const bool is_undo = eye->is_undo;
495  if (eye->accum_tot == 0) {
496  eyedropper_color_sample(C, eye, event->x, event->y);
497  }
498  eyedropper_exit(C, op);
499  /* Could support finished & undo-skip. */
500  return is_undo ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
501  }
503  /* enable accum and make first sample */
504  eye->accum_start = true;
505  eyedropper_color_sample(C, eye, event->x, event->y);
506  break;
508  eye->accum_tot = 0;
509  zero_v3(eye->accum_col);
510  eyedropper_color_sample(C, eye, event->x, event->y);
511  break;
512  }
513  }
514  else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
515  if (eye->accum_start) {
516  /* button is pressed so keep sampling */
517  eyedropper_color_sample(C, eye, event->x, event->y);
518  }
519 
520  if (eye->draw_handle_sample_text) {
521  eyedropper_color_sample_text_update(C, eye, event->x, event->y);
523  }
524  }
525 
526  return OPERATOR_RUNNING_MODAL;
527 }
528 
529 /* Modal Operator init */
530 static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
531 {
532  /* init */
533  if (eyedropper_init(C, op)) {
534  wmWindow *win = CTX_wm_window(C);
535  /* Workaround for de-activating the button clearing the cursor, see T76794 */
538 
539  /* add temp handler */
541 
542  return OPERATOR_RUNNING_MODAL;
543  }
544  return OPERATOR_PASS_THROUGH;
545 }
546 
547 /* Repeat operator */
549 {
550  /* init */
551  if (eyedropper_init(C, op)) {
552 
553  /* do something */
554 
555  /* cleanup */
556  eyedropper_exit(C, op);
557 
558  return OPERATOR_FINISHED;
559  }
560  return OPERATOR_PASS_THROUGH;
561 }
562 
564 {
565  /* Actual test for active button happens later, since we don't
566  * know which one is active until mouse over. */
567  return (CTX_wm_window(C) != NULL);
568 }
569 
571 {
572  /* identifiers */
573  ot->name = "Eyedropper";
574  ot->idname = "UI_OT_eyedropper_color";
575  ot->description = "Sample a color from the Blender window to store in a property";
576 
577  /* api callbacks */
583 
584  /* flags */
586 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, const float encoded_hash, char *r_name, int name_len)
void BKE_cryptomatte_free(struct CryptomatteSession *session)
Definition: cryptomatte.cc:166
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
Definition: image.c:5113
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
Definition: image.c:5100
struct CryptomatteSession * ntreeCompositCryptomatteSession(const Scene *scene, bNode *node)
void ntreeCompositCryptomatteLayerPrefix(const Scene *scene, const bNode *node, char *r_prefix, size_t prefix_len)
#define CMP_CRYPTOMATTE_SRC_RENDER
Definition: BKE_node.h:1259
#define CMP_CRYPTOMATTE_SRC_IMAGE
Definition: BKE_node.h:1260
struct ScrArea * BKE_screen_find_area_xy(struct bScreen *screen, const int spacetype, int x, int y)
Definition: screen.c:1018
struct ARegion * BKE_area_find_region_xy(struct ScrArea *area, const int regiontype, int x, int y)
Definition: screen.c:933
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
size_t BLI_strnlen(const char *str, const size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:878
#define STRPREFIX(a, b)
#define STREQLEN(a, b, n)
#define UNUSED(x)
#define ELEM(...)
@ ID_IM
Definition: DNA_ID_enums.h:65
@ ID_SCE
Definition: DNA_ID_enums.h:57
#define MAX_NAME
Definition: DNA_defs.h:62
@ IMA_TYPE_MULTILAYER
@ RGN_TYPE_WINDOW
@ SPACE_CLIP
@ SPACE_NODE
@ SPACE_IMAGE
#define SPACE_TYPE_ANY
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
bool ED_space_clip_color_sample(struct SpaceClip *sc, struct ARegion *region, int mval[2], float r_col[3])
Definition: clip_editor.c:292
bool ED_space_clip_get_position(struct SpaceClip *sc, struct ARegion *ar, int mval[2], float fpos[2])
Definition: clip_editor.c:274
bool ED_space_image_color_sample(struct SpaceImage *sima, struct ARegion *region, int mval[2], float r_col[3], bool *r_is_data)
Definition: image_ops.c:3220
bool ED_space_image_get_position(struct SpaceImage *sima, struct ARegion *region, int mval[2], float fpos[2])
Definition: image_ops.c:3203
bool ED_space_node_color_sample(struct Main *bmain, struct SpaceNode *snode, struct ARegion *region, const int mval[2], float r_col[3])
Definition: node_view.c:475
bool ED_space_node_get_position(struct Main *bmain, struct SpaceNode *snode, struct ARegion *region, const int mval[2], float fpos[2])
Definition: node_view.c:447
void ED_region_tag_redraw(struct ARegion *region)
Definition: area.c:667
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display)
struct ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
StructRNA RNA_CompositorNodeCryptomatteV2
@ PROP_FLOAT
Definition: RNA_types.h:75
PropertySubType
Definition: RNA_types.h:112
@ PROP_COLOR
Definition: RNA_types.h:139
@ PROP_COLOR_GAMMA
Definition: RNA_types.h:151
#define C
Definition: RandGen.cpp:39
@ UI_BUT_UNDO
Definition: UI_interface.h:208
void UI_context_active_but_clear(struct bContext *C, struct wmWindow *win, struct ARegion *region)
uiBut * UI_context_active_but_prop_get(const struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, int *r_index)
bool UI_but_flag_is_set(uiBut *but, int flag)
Definition: interface.c:6087
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_BLOCKING
Definition: WM_types.h:157
@ OPTYPE_UNDO
Definition: WM_types.h:155
short type
struct RenderResult * rr
OperationNode * node
Scene scene
uint col
void eyedropper_draw_cursor_text_window(const struct wmWindow *window, const char *name)
static bool eyedropper_init(bContext *C, wmOperator *op)
static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
static void eyedropper_cancel(bContext *C, wmOperator *op)
static void eyedropper_exit(bContext *C, wmOperator *op)
static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_layer, const char *prefix, const float fpos[2], float r_col[3])
static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, int mx, int my)
void UI_OT_eyedropper_color(wmOperatorType *ot)
struct Eyedropper Eyedropper
void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3])
get the color from the screen.
static void eyedropper_draw_cb(const wmWindow *window, void *arg)
static bool eyedropper_poll(bContext *C)
static bool eyedropper_cryptomatte_sample_image_fl(const bNode *node, NodeCryptomatte *crypto, const char *prefix, const float fpos[2], float r_col[3])
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, int mx, int my, float r_col[3])
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
static int eyedropper_exec(bContext *C, wmOperator *op)
@ EYE_MODAL_SAMPLE_BEGIN
@ EYE_MODAL_SAMPLE_RESET
@ EYE_MODAL_SAMPLE_CONFIRM
#define GS(x)
Definition: iris.c:241
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static void area(int d1, int d2, int e1, int e2, float weights[2])
RenderResult * RE_AcquireResultRead(Render *re)
Definition: pipeline.c:343
Render * RE_GetSceneRender(const Scene *scene)
Definition: pipeline.c:591
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
Definition: pipeline.c:276
void RE_ReleaseResult(Render *re)
Definition: pipeline.c:379
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
Definition: rna_access.c:3033
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1155
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2317
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1218
void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const float *values)
Definition: rna_access.c:3132
PropertySubType RNA_property_subtype(PropertyRNA *prop)
Definition: rna_access.c:1160
bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop_orig)
Definition: rna_access.c:2073
struct ColorManagedDisplay * display
struct CryptomatteSession * cryptomatte_session
char sample_text[MAX_NAME]
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
ListBase passes
Definition: RE_pipeline.h:108
char name[RE_MAXNAME]
Definition: RE_pipeline.h:100
ListBase layers
Definition: RE_pipeline.h:135
ListBase view_layers
ColorManagedDisplaySettings display_settings
ListBase spacedata
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int y
Definition: WM_types.h:581
short val
Definition: WM_types.h:579
int x
Definition: WM_types.h:581
short type
Definition: WM_types.h:577
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:760
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
void WM_cursor_modal_set(wmWindow *win, int val)
Definition: wm_cursors.c:207
void WM_cursor_modal_restore(wmWindow *win)
Definition: wm_cursors.c:216
@ WM_CURSOR_EYEDROPPER
Definition: wm_cursors.h:51
void WM_draw_cb_exit(wmWindow *win, void *handle)
Definition: wm_draw.c:375
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const struct wmWindow *, void *), void *customdata)
Definition: wm_draw.c:362
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
@ EVT_MODAL_MAP
@ MOUSEMOVE
@ INBETWEEN_MOUSEMOVE
wmOperatorType * ot
Definition: wm_files.c:3156
bScreen * WM_window_get_active_screen(const wmWindow *win)
Definition: wm_window.c:2372
bool WM_window_find_under_cursor(const wmWindowManager *wm, const wmWindow *win_ignore, const wmWindow *win, const int mval[2], wmWindow **r_win, int r_mval[2])
Definition: wm_window.c:1922
void WM_window_pixel_sample_read(const wmWindowManager *wm, const wmWindow *win, const int pos[2], float r_col[3])
Definition: wm_window.c:1958