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:
authorMatt Ebb <matt@mke3.net>2009-03-08 20:12:59 +0300
committerMatt Ebb <matt@mke3.net>2009-03-08 20:12:59 +0300
commitf73d7c697cc092fa4e3239f2a3f62ed190509287 (patch)
tree562af12be073a1fdbbf79f90aeaa517c4735fdb0 /source/blender
parent155c1fb49a6f5cc62fa0bf10e6fec6868deee4cf (diff)
* Updated slider design
Still a bit of a work in progress, will look a little weird on non-rounded themes, but will fix that when back home in .au! The slider now fills the entire button, dragging on it changes the value, clicking edits it. You can also ctrl-click on either side of the slider 'edge' to increment or decrement in small amounts. There's one temporarily in the render buttons for testing.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/UI_interface.h1
-rw-r--r--source/blender/editors/interface/interface.c5
-rw-r--r--source/blender/editors/interface/interface_draw.c199
-rw-r--r--source/blender/editors/interface/interface_handlers.c108
-rw-r--r--source/blender/editors/space_buttons/buttons_scene.c12
5 files changed, 135 insertions, 190 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 60d504c21fe..75c78f4a0d2 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -190,6 +190,7 @@ typedef struct uiPopupBlockHandle uiPopupBlockHandle;
void uiEmboss(float x1, float y1, float x2, float y2, int sel);
void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad);
void uiSetRoundBox(int type);
+int uiGetRoundBox(void);
void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index d1c4447f215..a49a20062fd 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1705,10 +1705,7 @@ void ui_check_but(uiBut *but)
/* safety is 4 to enable small number buttons (like 'users') */
- if(but->type==NUMSLI || but->type==HSVSLI)
- okwidth= -4 + (but->x2 - but->x1)/2.0;
- else
- okwidth= -4 + (but->x2 - but->x1);
+ okwidth= -4 + (but->x2 - but->x1);
/* name: */
switch( but->type ) {
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 5be578c4d50..8fba831302b 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -81,6 +81,14 @@ void uiSetRoundBox(int type)
}
+int uiGetRoundBox(void)
+{
+ if (ELEM3(UI_GetThemeValue(TH_BUT_DRAWTYPE), TH_MINIMAL, TH_SHADED, TH_OLDSKOOL))
+ return 0;
+ else
+ return roundboxtype;
+}
+
void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad)
{
float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
@@ -565,36 +573,6 @@ void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad,
glDisable( GL_BLEND );
}
-/* plain antialiased filled box */
-#if 0
-void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
-{
- float color[4];
-
- if(roundboxtype & UI_RB_ALPHA) {
- glGetFloatv(GL_CURRENT_COLOR, color);
- color[3]= 0.5;
- glColor4fv(color);
- glEnable( GL_BLEND );
- }
-
- /* solid part */
- gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad);
-
- /* set antialias line */
- if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) {
- glEnable( GL_LINE_SMOOTH );
- glEnable( GL_BLEND );
- }
-
- gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
-
- glDisable( GL_BLEND );
- glDisable( GL_LINE_SMOOTH );
-}
-#endif
-
-
/* ************** safe rasterpos for pixmap alignment with pixels ************* */
void ui_rasterpos_safe(float x, float y, float aspect)
@@ -1658,83 +1636,6 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1
}
}
-#if 0
-static void ui_default_slider(int colorid, float fac, float aspect, float x1, float y1, float x2, float y2, int flag)
-{
- float ymid, yc;
-
- /* the slider background line */
- ymid= (y1+y2)/2.0;
- //yc= 2.5*aspect; // height of center line
- yc = 2.3; // height of center line
-
- if(flag & UI_SELECT)
- UI_ThemeColorShade(TH_BUT_NUM, -5);
- else {
- if(flag & UI_ACTIVE)
- UI_ThemeColorShade(TH_BUT_NUM, +35);
- else
- UI_ThemeColorShade(TH_BUT_NUM, +25);
- }
-
- glRectf(x1, ymid-yc, x2, ymid+yc);
-
- /* top inner bevel */
- if(flag & UI_SELECT) UI_ThemeColorShade(TH_BUT_NUM, -40);
- else UI_ThemeColorShade(TH_BUT_NUM, -5);
- fdrawline(x1+1, ymid+yc, x2, ymid+yc);
-
- /* bottom inner bevel */
- if(flag & UI_SELECT) UI_ThemeColorShade(TH_BUT_NUM, +15);
- else UI_ThemeColorShade(TH_BUT_NUM, +45);
- fdrawline(x1+1, ymid-yc, x2, ymid-yc);
-
-
- /* the movable slider */
- if(flag & UI_SELECT) UI_ThemeColorShade(TH_BUT_NUM, +80);
- else UI_ThemeColorShade(TH_BUT_NUM, -45);
-
- glShadeModel(GL_SMOOTH);
- glBegin(GL_QUADS);
-
- UI_ThemeColorShade(TH_BUT_NUM, -45);
-
- glVertex2f(x1, y1+2.5);
- glVertex2f(x1+fac, y1+2.5);
-
- UI_ThemeColor(TH_BUT_NUM);
-
- glVertex2f(x1+fac, y2-2.5);
- glVertex2f(x1, y2-2.5);
-
- glEnd();
-
-
- /* slider handle center */
- glShadeModel(GL_SMOOTH);
- glBegin(GL_QUADS);
-
- UI_ThemeColor(TH_BUT_NUM);
- glVertex2f(x1+fac-3, y1+2);
- glVertex2f(x1+fac, y1+4);
- UI_ThemeColorShade(TH_BUT_NUM, +80);
- glVertex2f(x1+fac, y2-2);
- glVertex2f(x1+fac-3, y2-2);
-
- glEnd();
-
- /* slider handle left bevel */
- UI_ThemeColorShade(TH_BUT_NUM, +70);
- fdrawline(x1+fac-3, y2-2, x1+fac-3, y1+2);
-
- /* slider handle right bevel */
- UI_ThemeColorShade(TH_BUT_NUM, -35);
- fdrawline(x1+fac, y2-2, x1+fac, y1+2);
-
- glShadeModel(GL_FLAT);
-}
-#endif
-
/* default theme callback */
static void ui_draw_default(int type, int colorid, float aspect, float x1, float y1, float x2, float y2, int flag)
{
@@ -2078,27 +1979,71 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1
/* fac is the slider handle position between x1 and x2 */
static void ui_draw_slider(int colorid, float fac, float aspect, float x1, float y1, float x2, float y2, int flag)
{
+ int alpha_offs= (flag & UI_BUT_DISABLED)?UI_DISABLED_ALPHA_OFFS:0;
float ymid, yc;
-
+ float maxrad= 10.0;
+ float rad;
+ int origround, round = uiGetRoundBox();
+
+ rad= (y2-y1)/2.0;
+ if (rad>(x2-x1)/2) rad = (x2-x1)/2;
+ if (rad > maxrad) rad = maxrad;
+
/* the slider background line */
ymid= (y1+y2)/2.0;
yc= 1.7*aspect;
- if(flag & UI_ACTIVE)
- UI_ThemeColorShade(colorid, -50);
- else
- UI_ThemeColorShade(colorid, -40);
-
- /* left part */
- glRectf(x1, ymid-2.0*yc, x1+fac, ymid+2.0*yc);
- /* right part */
- glRectf(x1+fac, ymid-yc, x2, ymid+yc);
+ if(flag & UI_ACTIVE) UI_ThemeColorShade(colorid, -50);
+ else UI_ThemeColorShade(colorid, -40);
- /* the movable slider */
+ round &= ~(2|4);
+ uiSetRoundBox(round);
+
+ if (fac < rad) {
+ /* if slider end is in the left end cap */
+ float ofsy;
+ float start_rad;
+
+ start_rad = fac;
+ ofsy = (rad - fac) * 0.5;
+
+ gl_round_box(GL_POLYGON, x1, y1+ofsy, x1+fac, y2-ofsy, start_rad);
+
+ } else if ( (fac >= rad) && (x1+fac < x2 - rad) ) {
+ /* if the slider is in the middle */
+
+ gl_round_box(GL_POLYGON, x1, y1, x1+fac, y2, rad);
+
+ } else if (x1+fac >= x2-rad) {
+ /* if the slider is in the right end cap */
+ float extx, ofsy;
+ float end_rad;
+
+ /* draw the full slider area at 100% */
+ uiSetRoundBox(1+2+4+8);
+ gl_round_box(GL_POLYGON, x1, y1, x2, y2, rad);
+
+ /* tricky hack to trim off right end curve by drawing over it */
+ extx = ((x1 + fac) - (x2 - rad)) * aspect; /* width of extension bit */
+ end_rad = rad - extx - 1.0;
+ ofsy = extx * 0.4;
+
+ if (end_rad > 1.0) {
+
+ if(flag & UI_SELECT) UI_ThemeColorShade(colorid, -20);
+ else UI_ThemeColorShade(colorid, -0);
+
+ uiSetRoundBox(2+4);
+ gl_round_box(GL_POLYGON, x1+fac-1.0, y1+ofsy, x2, y2-ofsy, end_rad);
+ }
+
+ UI_ThemeColorBlendShadeAlpha(TH_BUT_OUTLINE, TH_BACK, 0.1, -30, alpha_offs);
+ uiSetRoundBox(1+2+4+8);
+ uiRoundRectFakeAA(x1, y1, x2, y2, rad, aspect);
+ }
+
+
- UI_ThemeColorShade(colorid, +70);
- glRectf(x1+fac-aspect, ymid-2.0*yc, x1+fac+aspect, ymid+2.0*yc);
-
}
/* ************** STANDARD MENU DRAWING FUNCTION ************* */
@@ -3274,17 +3219,17 @@ void ui_draw_but(ARegion *ar, uiBut *but)
case HSVSLI:
type= (but->editstr)? TEX: but->type;
but->embossfunc(type, but->themecol, but->aspect, but->x1, but->y1, but->x2, but->y2, but->flag);
- ui_draw_text_icon(but);
-
- x1= (but->x1+but->x2)/2;
- x2= but->x2 - 5.0*but->aspect;
- y1= but->y1 + 2.0*but->aspect;
- y2= but->y2 - 2.0*but->aspect;
+
+ x1= but->x1;
+ x2= but->x2;
+ y1= but->y1;
+ y2= but->y2;
value= ui_get_but_val(but);
fac= (value-but->min)*(x2-x1)/(but->max - but->min);
but->sliderfunc(but->themecol, fac, but->aspect, x1, y1, x2, y2, but->flag);
+ ui_draw_text_icon(but);
break;
case SEPR:
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 588615675cf..e4a5ddf75fa 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1851,7 +1851,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
but_clamped_range(but, &butmin, &butmax, &butrange);
- if(but->type==NUMSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
+ if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0*but->aspect);
else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2 - 5.0*but->aspect);
else deler= (but->x2-but->x1- 5.0*but->aspect);
@@ -1916,21 +1916,19 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
ui_window_to_block(data->region, block, &mx, &my);
if(data->state == BUTTON_STATE_HIGHLIGHT) {
- if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
- /* start either dragging as slider, or editing as text */
- if(mx>= -6+(but->x1+but->x2)/2) {
- if(event->type == LEFTMOUSE) {
- data->dragstartx= mx;
- data->draglastx= mx;
- button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- }
- else
- click= 1;
- }
- else
+ if(event->val==KM_PRESS) {
+ if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->shift) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
-
- retval= WM_UI_HANDLER_BREAK;
+ retval= WM_UI_HANDLER_BREAK;
+ }
+ else if(event->type == LEFTMOUSE) {
+ data->dragstartx= mx;
+ data->draglastx= mx;
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+ retval= WM_UI_HANDLER_BREAK;
+ }
+ else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
+ click= 1;
}
}
else if(data->state == BUTTON_STATE_NUM_EDITING) {
@@ -1956,45 +1954,51 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
}
if(click) {
- float f, h;
- float tempf, butmin, butmax, butrange;
- int temp;
-
- button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
-
- but_clamped_range(but, &butmin, &butmax, &butrange);
-
- tempf= data->value;
- temp= (int)data->value;
-
- h= but->y2-but->y1;
-
- if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1-h);
- else f= (float)(mx- (but->x1+but->x2)/2)/((but->x2-but->x1)/2 - h);
-
- f= butmin + f*butrange;
-
- if(!ui_is_but_float(but)) {
- if(f<temp) temp--;
- else temp++;
-
- if(temp>=but->min && temp<=but->max)
- data->value= temp;
- else
- data->cancel= 1;
- }
+ if (event->ctrl) {
+ /* nudge slider to the left or right */
+ float f;
+ float tempf, butmin, butmax, butrange;
+ int temp;
+
+ button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
+
+ but_clamped_range(but, &butmin, &butmax, &butrange);
+
+ tempf= data->value;
+ temp= (int)data->value;
+
+ if(but->type==SLI) f= (float)(mx-but->x1)/(but->x2-but->x1);
+ else f= (float)(mx- but->x1)/(but->x2-but->x1);
+
+ f= butmin + f*butrange;
+
+ if(!ui_is_but_float(but)) {
+ if(f<temp) temp--;
+ else temp++;
+
+ if(temp>=but->min && temp<=but->max)
+ data->value= temp;
+ else
+ data->cancel= 1;
+ }
+ else {
+ if(f<tempf) tempf-=.01;
+ else tempf+=.01;
+
+ if(tempf>=but->min && tempf<=but->max)
+ data->value= tempf;
+ else
+ data->cancel= 1;
+ }
+
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ retval= WM_UI_HANDLER_BREAK;
+ }
else {
- if(f<tempf) tempf-=.01;
- else tempf+=.01;
-
- if(tempf>=but->min && tempf<=but->max)
- data->value= tempf;
- else
- data->cancel= 1;
+ /* edit the value directly */
+ button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
+ retval= WM_UI_HANDLER_BREAK;
}
-
- button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
}
return retval;
diff --git a/source/blender/editors/space_buttons/buttons_scene.c b/source/blender/editors/space_buttons/buttons_scene.c
index e4cff2f4f06..ca645ab1845 100644
--- a/source/blender/editors/space_buttons/buttons_scene.c
+++ b/source/blender/editors/space_buttons/buttons_scene.c
@@ -266,13 +266,11 @@ static void render_panel_render(const bContext *C, ARegion *ar)
uiDefButBitI(block, TOG, R_RADIO, 0,"Radio", 649,142,38,29, &scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
uiBlockEndAlign(block);
- uiBlockBeginAlign(block);
- uiDefButS(block, ROW,0,"100%", 565,109,122,20,&scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size");
- uiDefButS(block, ROW,0,"75%", 565,88,40,20,&scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
- uiDefButS(block, ROW,0,"50%", 606,88,40,20,&scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
- uiDefButS(block, ROW,0,"25%", 647,88,40,20,&scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
- uiBlockEndAlign(block);
-
+ uiDefButS(block, NUMSLI, 0, "Size %: ",
+ 565,109,122,20,
+ &(scene->r.size), 1.0, 100.0, 0, 0,
+ "Render at percentage of frame size");
+
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, R_FIELDS, 0,"Fields", 565,55,60,20,&scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
uiDefButBitI(block, TOG, R_ODDFIELD, 0,"Odd", 627,55,39,20,&scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");