diff options
author | Matt Ebb <matt@mke3.net> | 2010-04-04 06:37:22 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-04-04 06:37:22 +0400 |
commit | 5de041c51f2a3d9969a8523c953157e69a0c8d24 (patch) | |
tree | 151c6e25292836dd81c27ed5007d241d0942f160 /source/blender/editors/interface | |
parent | f7977ab8ccb85b3c5d2a4a1221184d2174915c17 (diff) |
Histogram and line sample can now be resized vertically
Diffstat (limited to 'source/blender/editors/interface')
4 files changed, 44 insertions, 11 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); |