Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-08-16 18:47:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-16 18:47:14 +0400
commit81dd80f1d3da6db3227abafe431ac0e92c4e7197 (patch)
tree6130beb4db65bb8bf7bc5872ce565d4de9e45e16 /source/blender/editors/interface/interface_ops.c
parent6fb4bbdbd963eb0f9626d6bd784b22c65bd5cd44 (diff)
support fro HDR color picking (values over 1.0) when color picking in the image editor or node space.
Diffstat (limited to 'source/blender/editors/interface/interface_ops.c')
-rw-r--r--source/blender/editors/interface/interface_ops.c56
1 files changed, 48 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index b76907bc3ba..b3b48cb3a46 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -69,6 +69,8 @@
#include "BKE_main.h"
#include "BLI_ghash.h"
+#include "ED_image.h" /* for HDR color sampling */
+#include "ED_node.h" /* for HDR color sampling */
/* ********************************************************** */
@@ -126,9 +128,47 @@ static int eyedropper_cancel(bContext *C, wmOperator *op)
/* *** eyedropper_color_ helper functions *** */
-/* simply get the color from the screen */
-static void eyedropper_color_sample_fl(Eyedropper *UNUSED(eye), int mx, int my, float r_col[3])
+/**
+ * \brief get the color from the screen.
+ *
+ * Special check for image or nodes where we MAY have HDR pixels which don't display.
+ */
+static void eyedropper_color_sample_fl(bContext *C, Eyedropper *UNUSED(eye), int mx, int my, float r_col[3])
{
+
+ /* we could use some clever */
+ wmWindow *win = CTX_wm_window(C);
+ ScrArea *sa;
+ for (sa = win->screen->areabase.first; sa; sa = sa->next) {
+ if (BLI_in_rcti(&sa->totrct, mx, my)) {
+ if (sa->spacetype == SPACE_IMAGE) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (BLI_in_rcti(&ar->winrct, mx, my)) {
+ SpaceImage *sima = sa->spacedata.first;
+ int mval[2] = {mx - ar->winrct.xmin,
+ my - ar->winrct.ymin};
+
+ if (ED_space_image_color_sample(sima, ar, mval, r_col)) {
+ return;
+ }
+ }
+ }
+ else if (sa->spacetype == SPACE_NODE) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (BLI_in_rcti(&ar->winrct, mx, my)) {
+ SpaceNode *snode = sa->spacedata.first;
+ int mval[2] = {mx - ar->winrct.xmin,
+ my - ar->winrct.ymin};
+
+ if (ED_space_node_color_sample(snode, ar, mval, r_col)) {
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ /* fallback to simple opengl picker */
glReadBuffer(GL_FRONT);
glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, r_col);
glReadBuffer(GL_BACK);
@@ -167,14 +207,14 @@ static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye)
static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my)
{
float col[3];
- eyedropper_color_sample_fl(eye, mx, my, col);
+ eyedropper_color_sample_fl(C, eye, mx, my, col);
eyedropper_color_set(C, eye, col);
}
-static void eyedropper_color_sample_accum(Eyedropper *eye, int mx, int my)
+static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my)
{
float col[3];
- eyedropper_color_sample_fl(eye, mx, my, col);
+ eyedropper_color_sample_fl(C, eye, mx, my, col);
/* delay linear conversion */
add_v3_v3(eye->accum_col, col);
eye->accum_tot++;
@@ -203,13 +243,13 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event)
else if (event->val == KM_PRESS) {
/* enable accum and make first sample */
eye->accum_start = TRUE;
- eyedropper_color_sample_accum(eye, event->x, event->y);
+ eyedropper_color_sample_accum(C, eye, event->x, event->y);
}
break;
case MOUSEMOVE:
if (eye->accum_start) {
/* button is pressed so keep sampling */
- eyedropper_color_sample_accum(eye, event->x, event->y);
+ eyedropper_color_sample_accum(C, eye, event->x, event->y);
eyedropper_color_set_accum(C, eye);
}
break;
@@ -217,7 +257,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event)
if (event->val == KM_RELEASE) {
eye->accum_tot = 0;
zero_v3(eye->accum_col);
- eyedropper_color_sample_accum(eye, event->x, event->y);
+ eyedropper_color_sample_accum(C, eye, event->x, event->y);
eyedropper_color_set_accum(C, eye);
}
break;