display a sample line in the hue correct, handy to sample the image to know what...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 14:37:56 +0000 (14:37 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 21 Jun 2012 14:37:56 +0000 (14:37 +0000)
source/blender/editors/interface/interface_draw.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c

index b797b5377e33062bc9e8729fee8ff5b346a4b685..12c88a42888e43942f59a55d5d698f36b9300be8 100644 (file)
@@ -1346,7 +1346,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
 
        cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin);
        cuma = cumap->cm + cumap->cur;
-       
+
        /* need scissor test, curve can draw outside of boundary */
        glGetIntegerv(GL_VIEWPORT, scissor);
        scissor_new.xmin = ar->winrct.xmin + rect->xmin;
@@ -1424,7 +1424,19 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
        /* sample option */
 
        if (cumap->flag & CUMA_DRAW_SAMPLE) {
-               if (cumap->cur == 3) {
+               if (but->a1 == UI_GRAD_H) {
+                       float tsample[3];
+                       float hsv[3];
+                       linearrgb_to_srgb_v3_v3(tsample, cumap->sample);
+                       rgb_to_hsv_v(tsample, hsv);
+                       glColor3ub(240, 240, 240);
+
+                       glBegin(GL_LINES);
+                       glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymin);
+                       glVertex2f(rect->xmin + zoomx * (hsv[0] - offsx), rect->ymax);
+                       glEnd();
+               }
+               else if (cumap->cur == 3) {
                        float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f;
                        glColor3ub(240, 240, 240);
                        
index 7e67e737cc2bd645336dc8088c174919e285959c..3dc1fbd738fe7f346ecb73779ce1ae4c835ae44e 100644 (file)
@@ -1926,6 +1926,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
        
        if (ibuf == NULL) {
                ED_space_image_release_buffer(sima, lock);
+               info->draw = 0;
                return;
        }
 
@@ -2018,8 +2019,9 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event)
                }
 #endif
        }
-       else
+       else {
                info->draw = 0;
+       }
 
        ED_space_image_release_buffer(sima, lock);
        ED_area_tag_redraw(CTX_wm_area(C));
index 78de45dd219ab16be3e82c7776c4b4fdcfe9a4dd..22017a2d8b921241469c2e098b9b65da63ebaf63 100644 (file)
@@ -2134,6 +2134,17 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS
 
 static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
+       bNode *node = ptr->data;
+       CurveMapping *cumap = node->storage;
+
+       if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
+               cumap->flag |= CUMA_DRAW_SAMPLE;
+               copy_v3_v3(cumap->sample, _sample_col);
+       }
+       else {
+               cumap->flag &= ~CUMA_DRAW_SAMPLE;
+       }
+
        uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
 }
 
index fc7bf473f8f116aa4525c987418e7a98ba685302..48f772e8008cb0722bbb43a8618e4750f8f1fc5a 100644 (file)
@@ -1676,10 +1676,12 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
        Scene *scene = CTX_data_scene(C);
        ImageSampleInfo *info = arg_info;
 
-       ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
-                          info->x, info->y, info->col, info->colf,
-                          NULL, NULL /* zbuf - unused for nodes */
-                          );
+       if (info->draw) {
+               ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
+                                  info->x, info->y, info->col, info->colf,
+                                  NULL, NULL /* zbuf - unused for nodes */
+                                  );
+       }
 }
 
 static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
@@ -1694,8 +1696,10 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
        
        ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
-       if (!ibuf)
+       if (!ibuf) {
+               info->draw = 0;
                return;
+       }
        
        if (!ibuf->rect) {
                if (info->color_manage)