void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti) { Histogram *hist = (Histogram *)but->poin; int res = hist->x_resolution; rctf rect; int i; float w, h; //float alpha; GLint scissor[4]; rect.xmin = (float)recti->xmin+1; rect.xmax = (float)recti->xmax-1; rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2; rect.ymax = (float)recti->ymax-1; w = rect.xmax - rect.xmin; h = (rect.ymax - rect.ymin) * hist->ymax; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); /* need scissor test, histogram can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); 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); } if (hist->mode == HISTO_MODE_LUMA) histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res); else { if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) histogram_draw_one(1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res); if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) histogram_draw_one(0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res); if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res); } /* outline, scale gripper */ draw_scope_end(&rect, scissor); }
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti) { Histogram *hist = (Histogram *)but->poin; int res = hist->x_resolution; rctf rect; int i; float w, h; const short is_line = (hist->flag & HISTO_FLAG_LINE) != 0; //float alpha; GLint scissor[4]; rect.xmin = (float)recti->xmin + 1; rect.xmax = (float)recti->xmax - 1; rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; w = BLI_rctf_size_x(&rect); h = BLI_rctf_size_y(&rect) * hist->ymax; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f); /* need scissor test, histogram can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ for (i = 1; i <= HISTOGRAM_TOT_GRID_LINES; 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) { histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res, is_line); } else if (hist->mode == HISTO_MODE_ALPHA) { histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line); } else { if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) histogram_draw_one(1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line); if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) histogram_draw_one(0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line); if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) histogram_draw_one(0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line); } /* outline, scale gripper */ draw_scope_end(&rect, scissor); }