41#include "RNA_prototypes.hh"
96 Eyedropper *eye = MEM_new<Eyedropper>(__func__);
101 if (prop_data_path.empty()) {
115 if (but !=
nullptr) {
123 if (!eye->
ptr || (eye->
prop ==
nullptr) ||
136 if (eye->
ptr.
type == RNA_CompositorNodeCryptomatteV2) {
146 const char *display_device;
191 const char *type_name,
195 int material_slot = 0;
201 const ID *
id =
nullptr;
217 const char *name = &
id->
name[2];
233 const int render_layer_name_len =
STRNLEN(render_layer->
name);
234 if (strncmp(prefix, render_layer->
name, render_layer_name_len) != 0) {
238 const int prefix_len = strlen(prefix);
239 if (prefix_len <= render_layer_name_len + 1) {
244 const char *render_pass_name_prefix = render_layer_name_len ?
245 prefix + 1 + render_layer_name_len :
250 !
STREQLEN(render_pass.
name, render_pass_name_prefix,
sizeof(render_pass.
name)))
255 if (!render_pass.
ibuf) {
259 const int x = int(fpos[0] * render_pass.
rectx);
260 const int y = int(fpos[1] * render_pass.
recty);
261 const int offset = 4 * (
y * render_pass.
rectx +
x);
276 bool success =
false;
277 Scene *scene = id_cast<Scene *>(
node->id);
304 bool success =
false;
330 const int event_xy[2],
369 const int mval[2] = {
373 float fpos[2] = {-1.0f, -1.0};
397 (fpos[0] < 0.0f || fpos[1] < 0.0f || fpos[0] >= 1.0f || fpos[1] >= 1.0f))
443 const int event_xy[2],
458 const int mval[2] = {
486 eye->
viewport_session = MEM_new<ViewportColorSampleSession>(
"viewport_session");
579 const int event_xy[2])
609 switch (event->
val) {
614 const bool is_undo = eye->
is_undo;
639 status.
item(
TIP_(
"Drag to continue sampling, release when done"), ICON_MOUSE_MOVE);
646 status.
item(
TIP_(
"Press 'Enter' to sample outside of a Blender window"), ICON_STATUS_INFO);
702 ot->
name =
"Eyedropper";
703 ot->
idname =
"UI_OT_eyedropper_color";
704 ot->
description =
"Sample a color from the Blender window to store in a property";
723 "Path of property to be set with the depth");
General operations, lookup, etc. for materials.
#define RE_PASSNAME_CRYPTOMATTE_MATERIAL
#define RE_PASSNAME_CRYPTOMATTE_OBJECT
Read Blender memory allocation and freeing.
#define STREQLEN(a, b, n)
bool init(ARegion *region)
bool sample(const int mval[2], float r_col[3])
void item(std::string text, int icon1, int icon2=0)
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
static void eyedropper_color_sample_text_update(bContext *C, Eyedropper *eye, const int event_xy[2])
@ EYE_MODAL_SAMPLE_CONFIRM
bool eyedropper_color_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
get the color from the screen.
static bool eyedropper_cryptomatte_sample_view3d_fl(bContext *C, const char *type_name, const int mval[2], float r_col[3])
static bool eyedropper_poll(bContext *C)
static wmOperatorStatus eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event)
bool button_flag_is_set(Button *but, int64_t flag)
static bool eyedropper_init(bContext *C, wmOperator *op)
static wmOperatorStatus eyedropper_exec(bContext *C, wmOperator *op)
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, const int event_xy[2])
void eyedropper_draw_cursor_text_region(const int xy[2], const char *name)
static void eyedropper_exit(bContext *C, wmOperator *op)
static wmOperatorStatus eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *)
Button * context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
static void eyedropper_cancel(bContext *C, wmOperator *op)
void UI_OT_eyedropper_color(wmOperatorType *ot)
static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3])
static bool eyedropper_cryptomatte_sample_fl(bContext *C, Eyedropper *eye, const int event_xy[2], float r_col[3])
static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *render_layer, const char *prefix, const float fpos[2], float r_col[3])
static void eyedropper_draw_cb(const wmWindow *, void *arg)
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])
static bool eyedropper_cryptomatte_sample_render_fl(const bNode *node, const char *prefix, const float fpos[2], float r_col[3])
void context_active_but_clear(bContext *C, wmWindow *win, ARegion *region)
void BKE_image_user_frame_calc(Image *ima, ImageUser *iuser, int cfra)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool BKE_cryptomatte_find_name(const struct CryptomatteSession *session, float encoded_hash, char *r_name, int name_maxncpy)
ScrArea * CTX_wm_area(const bContext *C)
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_property_float_get_array_at_most(PointerRNA *ptr, PropertyRNA *prop, float *values, int values_num)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
MINLINE void copy_v3_v3(float r[3], const float a[3])
bool ED_space_clip_get_position(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_fpos[2])
bool RNA_path_resolve(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Material * BKE_object_material_get(Object *ob, short act)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Object * ED_view3d_give_material_slot_under_cursor(bContext *C, const int mval[2], int *r_material_slot)
wmWindow * WM_window_find_under_cursor(wmWindow *win, const int event_xy[2], int r_event_xy_other[2])
void WM_cursor_modal_set(wmWindow *win, int val)
wmWindow * CTX_wm_window(const bContext *C)
bool WM_window_pixels_read_sample_from_offscreen(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
bool ED_space_image_get_position(SpaceImage *sima, ARegion *region, const int mval[2], float r_fpos[2])
void ED_region_tag_redraw(ARegion *region)
uint32_t BKE_cryptomatte_hash(const char *name, int name_len)
void WM_draw_cb_exit(wmWindow *win, void *handle)
CryptomatteSession * ntreeCompositCryptomatteSession(bNode *node)
PropertyType RNA_property_type(PropertyRNA *prop)
Render * RE_GetSceneRender(const Scene *scene)
bool WM_window_pixels_read_sample(bContext *C, wmWindow *win, const int pos[2], float r_col[3])
bool WM_desktop_cursor_sample_read(float r_col[3])
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
bool ED_space_clip_color_sample(const SpaceClip *sc, const ARegion *region, const int mval[2], float r_col[3])
bool BKE_main_view_layers_synced_ensure(const Main *bmain)
void WM_cursor_modal_restore(wmWindow *win)
void ntreeCompositCryptomatteLayerPrefix(const bNode *node, char *r_prefix, size_t prefix_maxncpy)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_property_float_set_array_at_most(PointerRNA *ptr, PropertyRNA *prop, const float *values, int values_num)
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
MINLINE void zero_v3(float r[3])
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
RenderResult * RE_AcquireResultRead(Render *re)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
@ WM_CAPABILITY_DESKTOP_SAMPLE
PropertySubType RNA_property_subtype(PropertyRNA *prop)
MINLINE void add_v3_v3(float r[3], const float a[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], const ColorManagedDisplay *display, ColorManagedDisplaySpace display_space=DISPLAY_SPACE_DRAW)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Main * CTX_data_main(const bContext *C)
eWM_CapabilitiesFlag WM_capabilities_flag()
ID_Type GS(const char *name)
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash)
void RE_ReleaseResult(Render *re)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
@ CMP_NODE_CRYPTOMATTE_SOURCE_IMAGE
@ CMP_NODE_CRYPTOMATTE_SOURCE_RENDER
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
bScreen * WM_window_get_active_screen(const wmWindow *win)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
void BKE_cryptomatte_free(struct CryptomatteSession *session)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bool ED_space_image_color_sample(SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
ocio::Display ColorManagedDisplay
void CTX_wm_area_set(bContext *C, ScrArea *area)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
ARegion * BKE_area_find_region_xy(const ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
const float * float_data() const
ListBaseT< RenderPass > passes
ListBaseT< ViewLayer > view_layers
ColorManagedDisplaySettings display_settings
ListBaseT< SpaceLink > spacedata
void * draw_handle_sample_text
CryptomatteSession * cryptomatte_session
const ColorManagedDisplay * display
char sample_text[MAX_NAME]
ViewportColorSampleSession * viewport_session
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(*) cancel(bContext *C, wmOperator *op)
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
#define ISMOUSE_MOTION(event_type)