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-06-10 16:09:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-10 16:09:25 +0400
commit5e29381825bb7e84b6e3535bd6ca6a53c8079e2a (patch)
treef39204624c80ff68c24910d1db817afb75a654f2 /source/blender/editors/interface/interface_draw.c
parent6ba5650428390158208cf4369e0cc6a2baad2fbd (diff)
mango request
- optionally display the histogram as lines (not filled areas). - expand the enum for faster access. - keep the sample line displayed after doing the line sample (running again clears).
Diffstat (limited to 'source/blender/editors/interface/interface_draw.c')
-rw-r--r--source/blender/editors/interface/interface_draw.c83
1 files changed, 53 insertions, 30 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index a0b418c1a9a..1300c1d266c 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -658,37 +658,59 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
}
static void histogram_draw_one(float r, float g, float b, float alpha,
- float x, float y, float w, float h, float *data, int res)
+ float x, float y, float w, float h, float *data, int res, const short is_line)
{
int i;
- /* under the curve */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glColor4f(r, g, b, alpha);
-
- glShadeModel(GL_FLAT);
- glBegin(GL_QUAD_STRIP);
- glVertex2f(x, y);
- glVertex2f(x, y + (data[0] * h));
- for (i = 1; i < res; i++) {
- float x2 = x + i * (w / (float)res);
- glVertex2f(x2, y + (data[i] * h));
- glVertex2f(x2, y);
+ if (is_line) {
+
+ glLineWidth(1.5);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glColor4f(r, g, b, alpha);
+
+ /* curve outline */
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glEnable(GL_LINE_SMOOTH);
+ glBegin(GL_LINE_STRIP);
+ for (i = 0; i < res; i++) {
+ float x2 = x + i * (w / (float)res);
+ glVertex2f(x2, y + (data[i] * h));
+ }
+ glEnd();
+ glDisable(GL_LINE_SMOOTH);
+
+ glLineWidth(1.0);
}
- glEnd();
-
- /* curve outline */
- glColor4f(0.f, 0.f, 0.f, 0.25f);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_STRIP);
- for (i = 0; i < res; i++) {
- float x2 = x + i * (w / (float)res);
- glVertex2f(x2, y + (data[i] * h));
+ else {
+ /* under the curve */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ glColor4f(r, g, b, alpha);
+
+ glShadeModel(GL_FLAT);
+ glBegin(GL_QUAD_STRIP);
+ glVertex2f(x, y);
+ glVertex2f(x, y + (data[0] * h));
+ for (i = 1; i < res; i++) {
+ float x2 = x + i * (w / (float)res);
+ glVertex2f(x2, y + (data[i] * h));
+ glVertex2f(x2, y);
+ }
+ glEnd();
+
+ /* curve outline */
+ glColor4f(0.f, 0.f, 0.f, 0.25f);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+ glBegin(GL_LINE_STRIP);
+ for (i = 0; i < res; i++) {
+ float x2 = x + i * (w / (float)res);
+ glVertex2f(x2, y + (data[i] * h));
+ }
+ glEnd();
+ glDisable(GL_LINE_SMOOTH);
}
- glEnd();
- glDisable(GL_LINE_SMOOTH);
}
void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
@@ -698,6 +720,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
rctf rect;
int i;
float w, h;
+ const short is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
//float alpha;
GLint scissor[4];
@@ -731,14 +754,14 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
}
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);
+ 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_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);
+ 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);
+ 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);
+ 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 */