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
path: root/source
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2010-04-04 06:37:22 +0400
committerMatt Ebb <matt@mke3.net>2010-04-04 06:37:22 +0400
commit5de041c51f2a3d9969a8523c953157e69a0c8d24 (patch)
tree151c6e25292836dd81c27ed5007d241d0942f160 /source
parentf7977ab8ccb85b3c5d2a4a1221184d2174915c17 (diff)
Histogram and line sample can now be resized vertically
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_draw.c27
-rw-r--r--source/blender/editors/interface/interface_handlers.c21
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/editors/space_image/image_draw.c11
-rw-r--r--source/blender/makesdna/DNA_color_types.h2
6 files changed, 46 insertions, 22 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index b3380d91a44..893c479c7e9 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -694,15 +694,16 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
int i;
int rgb;
float w, h;
+ float scaler_x1, scaler_x2;
float alpha;
GLint scissor[4];
if (hist==NULL) { printf("hist is null \n"); return; }
- rect.xmin = (float)recti->xmin;
- rect.xmax = (float)recti->xmax;
- rect.ymin = (float)recti->ymin;
- rect.ymax = (float)recti->ymax;
+ 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;
@@ -763,14 +764,28 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *
glDisable(GL_LINE_SMOOTH);
}
+
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+
+ /* height scaling widget */
+ scaler_x1 = rect.xmin + w/2 - SCOPE_RESIZE_PAD;
+ scaler_x2 = rect.xmin + w/2 + SCOPE_RESIZE_PAD;
+
+ glColor4f(0.f, 0.f, 0.f, 0.25f);
+ fdrawline(scaler_x1, rect.ymin-4, scaler_x2, rect.ymin-4);
+ fdrawline(scaler_x1, rect.ymin-7, scaler_x2, rect.ymin-7);
+ glColor4f(1.f, 1.f, 1.f, 0.25f);
+ fdrawline(scaler_x1, rect.ymin-5, scaler_x2, rect.ymin-5);
+ fdrawline(scaler_x1, rect.ymin-8, scaler_x2, rect.ymin-8);
+
+
glColor4f(0.f, 0.f, 0.f, 0.5f);
uiSetRoundBox(15);
- gl_round_box(GL_LINE_LOOP, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
-
+ gl_round_box(GL_LINE_LOOP, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
+
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 2869009aa1a..fc69fc6fafa 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3460,6 +3460,12 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
return WM_UI_HANDLER_CONTINUE;
}
+static int in_histogram_resize_zone(uiBut *but, int x, int y)
+{
+ // bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD);
+ return (y < but->y1 + SCOPE_RESIZE_PAD);
+}
+
static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx, int my)
{
Histogram *hist = (Histogram *)but->poin;
@@ -3473,10 +3479,17 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
dx = mx - data->draglastx;
dy = my - data->draglasty;
- yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5;
- hist->ymax += dy * yfac;
- CLAMP(hist->ymax, 1.f, 100.f);
+ if (in_histogram_resize_zone(but, data->dragstartx, data->dragstarty)) {
+ /* resize histogram widget itself */
+ hist->height = (but->y2 - but->y1) + (data->dragstarty - my);
+ } else {
+ /* scale histogram values */
+ yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5;
+ hist->ymax += dy * yfac;
+
+ CLAMP(hist->ymax, 1.f, 100.f);
+ }
data->draglastx= mx;
data->draglasty= my;
@@ -4432,7 +4445,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
but->flag |= UI_SELECT;
button_timers_tooltip_remove(C, but);
}
-
+
/* text editing */
if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING)
ui_textedit_begin(C, but, data);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index b4d93365d3c..f90b711cc09 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -127,6 +127,9 @@ typedef enum {
#define EXTEND_LEFT 1
#define EXTEND_RIGHT 2
+/* for scope resize zone */
+#define SCOPE_RESIZE_PAD 9
+
typedef struct {
short xim, yim;
unsigned int *rect;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 73ac123f964..2bbabf66ffe 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1589,7 +1589,9 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, char *propname, int
hist = (Histogram *)cptr.data;
- bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, 100.0f, hist, 0, 0, 0, 0, "");
+ hist->height= (hist->height==0)?100:hist->height;
+
+ bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index a611ee6f32f..bcd37d97dcf 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -154,17 +154,6 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f
UI_DrawString(10, 10, str);
}
-void draw_image_line(struct ARegion *ar, int x1, int y1, int x2, int y2)
-{
- glColor3ub(0,0,0);
- glBegin(GL_LINES);
-
- glVertex2i(x1, y1);
- glVertex2i(x2, y2);
-
- glEnd();
-}
-
/* image drawing */
static void draw_image_grid(ARegion *ar, float zoomx, float zoomy)
diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h
index 5b4786c0be2..2a6dcfcb64e 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -97,8 +97,10 @@ typedef struct Histogram {
float data_g[256];
float data_b[256];
float xmax, ymax;
+ int height;
int ok;
int flag;
+ int pad;
} Histogram;
#endif