image histogram/sample line couldn't show HDR colors. now allow zooming the view...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 26 Jul 2012 09:06:23 +0000 (09:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 26 Jul 2012 09:06:23 +0000 (09:06 +0000)
source/blender/blenkernel/intern/colortools.c
source/blender/editors/interface/interface_draw.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/space_image/image_ops.c

index 31ad4d0..194b41f 100644 (file)
@@ -961,7 +961,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short
        hist->channels = 3;
        hist->x_resolution = 256;
        hist->xmax = 1.0f;
-       hist->ymax = 1.0f;
+       /* hist->ymax = 1.0f; */ /* now do this on the operator _only_ */
 
        if (ibuf->rect == NULL && ibuf->rect_float == NULL) return;
 
index 1d88838..d8eb1b0 100644 (file)
@@ -714,6 +714,8 @@ static void histogram_draw_one(float r, float g, float b, float alpha,
        }
 }
 
+#define HISTOGRAM_TOT_GRID_LINES 4
+
 void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
 {
        Histogram *hist = (Histogram *)but->poin;
@@ -749,9 +751,16 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
 
        glColor4f(1.f, 1.f, 1.f, 0.08f);
        /* draw grid lines here */
-       for (i = 1; i < 4; i++) {
-               fdrawline(rect.xmin, rect.ymin + (i / 4.f) * h, rect.xmax, rect.ymin + (i / 4.f) * h);
-               fdrawline(rect.xmin + (i / 4.f) * w, rect.ymin, rect.xmin + (i / 4.f) * w, rect.ymax);
+       for (i = 1; i < (HISTOGRAM_TOT_GRID_LINES + 1); i++) {
+               const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
+
+               /* so we can tell the 1.0 color point */
+               if (i == HISTOGRAM_TOT_GRID_LINES) {
+                       glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
+               }
+
+               fdrawline(rect.xmin, rect.ymin + fac * h, rect.xmax, rect.ymin + fac * h);
+               fdrawline(rect.xmin + fac * w, rect.ymin, rect.xmin + fac * w, rect.ymax);
        }
        
        if (hist->mode == HISTO_MODE_LUMA) {
@@ -773,6 +782,8 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
        draw_scope_end(&rect, scissor);
 }
 
+#undef HISTOGRAM_TOT_GRID_LINES
+
 void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
 {
        Scopes *scopes = (Scopes *)but->poin;
index 32aef5d..1520276 100644 (file)
@@ -3872,7 +3872,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
                const float yfac = minf(powf(hist->ymax, 2.0f), 1.0f) * 0.5f;
                hist->ymax += dy * yfac;
        
-               CLAMP(hist->ymax, 1.f, 100.f);
+               /* 0.1 allows us to see HDR colors up to 10 */
+               CLAMP(hist->ymax, 0.1f, 100.f);
        }
        
        data->draglastx = mx;
index c204d0d..95e43e2 100644 (file)
@@ -213,6 +213,10 @@ static int space_image_image_sample_poll(bContext *C)
                if (ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt))
                        return 0;
        }
+       else if (sima->mode != SI_MODE_VIEW) {
+               return 0;
+       }
+
        return space_image_main_area_poll(C);
 }
 /********************** view pan operator *********************/
@@ -2152,6 +2156,9 @@ static int image_sample_line_exec(bContext *C, wmOperator *op)
 
        BKE_histogram_update_sample_line(hist, ibuf, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0);
        
+       /* reset y zoom */
+       hist->ymax = 1.0f;
+
        ED_space_image_release_buffer(sima, lock);
        
        ED_area_tag_redraw(CTX_wm_area(C));