40#include "RNA_prototypes.hh"
93 Eyedropper *eye = MEM_new<Eyedropper>(__func__);
98 if (prop_data_path.empty()) {
112 if (but !=
nullptr) {
120 if ((eye->
ptr.
data ==
nullptr) || (eye->
prop ==
nullptr) ||
133 if (eye->
ptr.
type == &RNA_CompositorNodeCryptomatteV2) {
142 const char *display_device;
187 const char *type_name,
191 int material_slot = 0;
197 const ID *
id =
nullptr;
213 const char *
name = &
id->name[2];
229 const int render_layer_name_len =
STRNLEN(render_layer->
name);
230 if (strncmp(prefix, render_layer->
name, render_layer_name_len) != 0) {
234 const int prefix_len = strlen(prefix);
235 if (prefix_len <= render_layer_name_len + 1) {
240 const char *render_pass_name_prefix = render_layer_name_len ?
241 prefix + 1 + render_layer_name_len :
245 if (
STRPREFIX(render_pass->name, render_pass_name_prefix) &&
246 !
STREQLEN(render_pass->name, render_pass_name_prefix,
sizeof(render_pass->name)))
251 if (!render_pass->ibuf) {
255 const int x = int(fpos[0] * render_pass->rectx);
256 const int y = int(fpos[1] * render_pass->recty);
257 const int offset = 4 * (
y * render_pass->rectx +
x);
259 r_col[0] = render_pass->ibuf->float_buffer.data[offset];
272 bool success =
false;
300 bool success =
false;
326 const int event_xy[2],
365 const int mval[2] = {
369 float fpos[2] = {-1.0f, -1.0};
393 (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f))
439 const int event_xy[2],
454 const int mval[2] = {
482 eye->
viewport_session = MEM_new<ViewportColorSampleSession>(
"viewport_session");
575 const int event_xy[2])
605 switch (event->
val) {
610 const bool is_undo = eye->
is_undo;
635 status.item(
TIP_(
"Drag to continue sampling, release when done"), ICON_MOUSE_MOVE);
642 status.item(
TIP_(
"Press 'Enter' to sample outside of a Blender window"), ICON_INFO);
698 ot->name =
"Eyedropper";
699 ot->idname =
"UI_OT_eyedropper_color";
700 ot->description =
"Sample a color from the Blender window to store in a property";
719 "Path of property to be set with the depth");
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
uint32_t BKE_cryptomatte_hash(const char *name, int name_len)
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, float encoded_hash, char *r_name, int name_maxncpy)
void BKE_cryptomatte_free(struct CryptomatteSession *session)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
General operations, lookup, etc. for materials.
Material * BKE_object_material_get(Object *ob, short act)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
ARegion * BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
#define LISTBASE_FOREACH(type, var, list)
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])
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STREQLEN(a, b, n)
@ CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
#define RE_PASSNAME_CRYPTOMATTE_MATERIAL
#define RE_PASSNAME_CRYPTOMATTE_OBJECT
bool ED_space_clip_get_position(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_clip_color_sample(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_col[3])
bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, const int mval[2], float r_fpos[2])
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
void ED_workspace_status_text(bContext *C, const char *str)
void ED_region_tag_redraw(ARegion *region)
Object * ED_view3d_give_material_slot_under_cursor(bContext *C, const int mval[2], int *r_material_slot)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display, const ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], const ColorManagedDisplay *display, const ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
Read Guarded memory(de)allocation.
uiBut * UI_context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
void UI_context_active_but_clear(bContext *C, wmWindow *win, ARegion *region)
bool UI_but_flag_is_set(uiBut *but, int flag)
blender::ocio::Display ColorManagedDisplay
@ WM_CAPABILITY_DESKTOP_SAMPLE
bool init(ARegion *region)
bool sample(const int mval[2], float r_col[3])
static wmOperatorStatus eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int event_xy[2])
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 void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
static bool eyedropper_cryptomatte_sample_image_fl(bContext *C, const bNode *node, NodeCryptomatte *crypto, const char *prefix, const float fpos[2], float r_col[3])
bool eyedropper_color_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static wmOperatorStatus eyedropper_exec(bContext *C, wmOperator *op)
static void eyedropper_draw_cb(const wmWindow *, void *arg)
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
void UI_OT_eyedropper_color(wmOperatorType *ot)
static bool eyedropper_poll(bContext *C)
static wmOperatorStatus eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool eyedropper_cryptomatte_sample_view3d_fl(bContext *C, const char *type_name, const int mval[2], float r_col[3])
@ EYE_MODAL_SAMPLE_CONFIRM
void eyedropper_draw_cursor_text_region(const int xy[2], const char *name)
void ntreeCompositCryptomatteLayerPrefix(const bNode *node, char *r_prefix, size_t prefix_maxncpy)
CryptomatteSession * ntreeCompositCryptomatteSession(bNode *node)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyType RNA_property_type(PropertyRNA *prop)
void RNA_property_float_get_array_at_most(PointerRNA *ptr, PropertyRNA *prop, float *values, int values_num)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_float_set_array_at_most(PointerRNA *ptr, PropertyRNA *prop, const float *values, int values_num)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
RenderResult * RE_AcquireResultRead(Render *re)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void RE_ReleaseResult(Render *re)
Render * RE_GetSceneRender(const Scene *scene)
char sample_text[MAX_NAME]
const ColorManagedDisplay * display
ViewportColorSampleSession * viewport_session
CryptomatteSession * cryptomatte_session
void * draw_handle_sample_text
ColorManagedDisplaySettings display_settings
struct ReportList * reports
struct wmOperatorType * type
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
void WM_draw_cb_exit(wmWindow *win, void *handle)
bool WM_desktop_cursor_sample_read(float r_col[3])
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
#define ISMOUSE_MOTION(event_type)
wmWindow * WM_window_find_under_cursor(wmWindow *win, const int event_xy[2], int r_event_xy_other[2])
eWM_CapabilitiesFlag WM_capabilities_flag()
bScreen * WM_window_get_active_screen(const wmWindow *win)