diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 36 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 61 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 22 |
6 files changed, 120 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index d639b881fe6..7f8d6e8e3cb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2376,7 +2376,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short } } - if((block->flag & UI_BLOCK_LOOP) || ELEM7(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU)) + if((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR)) but->flag |= (UI_TEXT_LEFT|UI_ICON_LEFT); else if(but->type==BUT_TOGDUAL) but->flag |= UI_ICON_LEFT; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 2c9d5a8e131..fb0822de677 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -184,11 +184,16 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but); /* ******************** menu navigation helpers ************** */ +static int ui_but_editable(uiBut *but) +{ + return ELEM5(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX, PROGRESSBAR); +} + static uiBut *ui_but_prev(uiBut *but) { while(but->prev) { but= but->prev; - if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but; + if(!ui_but_editable(but)) return but; } return NULL; } @@ -197,7 +202,7 @@ static uiBut *ui_but_next(uiBut *but) { while(but->next) { but= but->next; - if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but; + if(!ui_but_editable(but)) return but; } return NULL; } @@ -208,7 +213,7 @@ static uiBut *ui_but_first(uiBlock *block) but= block->buttons.first; while(but) { - if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but; + if(!ui_but_editable(but)) return but; but= but->next; } return NULL; @@ -220,7 +225,7 @@ static uiBut *ui_but_last(uiBlock *block) but= block->buttons.last; while(but) { - if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but; + if(!ui_but_editable(but)) return but; but= but->prev; } return NULL; @@ -4313,6 +4318,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) case ROW: case LISTROW: case BUT_IMAGE: + case PROGRESSBAR: retval= ui_do_but_EXIT(C, but, data, event); break; case HISTOGRAM: diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 77f18115c73..ecefcf93c28 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -87,7 +87,8 @@ typedef enum { UI_WTYPE_NORMAL, UI_WTYPE_BOX, UI_WTYPE_SCROLL, - UI_WTYPE_LISTITEM + UI_WTYPE_LISTITEM, + UI_WTYPE_PROGRESSBAR, } uiWidgetTypeEnum; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8cf6c2915c2..4183ff49e51 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2423,24 +2423,40 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) wmWindowManager *wm= CTX_wm_manager(C); ScrArea *sa= CTX_wm_area(C); uiBlock *block; - + void *owner; + int handle_event; + block= uiLayoutGetBlock(layout); uiBlockSetCurLayout(block, layout); uiBlockSetHandleFunc(block, do_running_jobs, NULL); if(sa->spacetype==SPACE_NODE) { - if(WM_jobs_test(wm, sa)) - uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Composite", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop composite"); + owner = sa; + handle_event= B_STOPCOMPO; + } else { + owner = scene; + handle_event= B_STOPRENDER; } - else { - if(WM_jobs_test(wm, scene)) - uiDefIconTextBut(block, BUT, B_STOPRENDER, ICON_CANCEL, "Render", 0,0,75,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop rendering"); - if(WM_jobs_test(wm, screen)) - uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Capture", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast"); - if(screen->animtimer) - uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, "Anim Player", 0,0,100,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop animation playback"); + + if(WM_jobs_test(wm, owner)) { + uiLayout *abs; + + abs = uiLayoutAbsolute(layout, 0); + + uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, + 0, UI_UNIT_Y*0.1, UI_UNIT_X*0.8, UI_UNIT_Y*0.8, NULL, 0.0f, 0.0f, 0, 0, "Stop this job"); + uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), + UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, "Progress"); + + uiLayoutRow(layout, 0); } + if(WM_jobs_test(wm, screen)) + uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Capture", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast"); + if(screen->animtimer) + uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, "Anim Player", 0,0,100,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop animation playback"); + + uiItemS(layout); } /************************* Reports for Last Operator Template **************************/ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 558cdb798c2..c419c73c1e0 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1276,6 +1276,19 @@ static struct uiWidgetColors wcol_scroll= { 5, -5 }; +static struct uiWidgetColors wcol_progress= { + {0, 0, 0, 255}, + {190, 190, 190, 255}, + {100, 100, 100, 180}, + {68, 68, 68, 255}, + + {0, 0, 0, 255}, + {255, 255, 255, 255}, + + 0, + 0, 0 +}; + static struct uiWidgetColors wcol_list_item= { {0, 0, 0, 255}, {0, 0, 0, 0}, @@ -1322,6 +1335,7 @@ void ui_widget_color_init(ThemeUI *tui) tui->wcol_box= wcol_box; tui->wcol_scroll= wcol_scroll; tui->wcol_list_item= wcol_list_item; + tui->wcol_progress= wcol_progress; tui->wcol_state= wcol_state; } @@ -1954,6 +1968,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat uiWidgetBase wtb; float rad; int horizontal; + short outline=0; widget_init(&wtb); @@ -1995,6 +2010,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat /* draw */ wtb.emboss= 0; /* only emboss once */ + /* exception for progress bar */ + if (state & UI_SCROLL_NO_OUTLINE) + SWAP(short, outline, wtb.outline); + round_box_edges(&wtb, 15, slider, rad); if(state & UI_SCROLL_ARROWS) { @@ -2013,6 +2032,9 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat } } widgetbase_draw(&wtb, wcol); + + if (state & UI_SCROLL_NO_OUTLINE) + SWAP(short, outline, wtb.outline); } } @@ -2077,9 +2099,35 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat uiWidgetScrollDraw(wcol, rect, &rect1, state); } -static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { + rcti rect_prog = *rect, rect_bar = *rect; + float value = but->a1; + float w, min; + + /* make the progress bar a proportion of the original height */ + /* hardcoded 4px high for now */ + rect_prog.ymax = rect_prog.ymin + 4; + rect_bar.ymax = rect_bar.ymin + 4; + + w = value * (rect_prog.xmax - rect_prog.xmin); + + /* ensure minimium size */ + min= rect_prog.ymax - rect_prog.ymin; + w = MAX2(w, min); + + rect_bar.xmax = rect_bar.xmin + w; + + uiWidgetScrollDraw(wcol, &rect_prog, &rect_bar, UI_SCROLL_NO_OUTLINE); + + /* raise text a bit */ + rect->ymin += 6; + rect->xmin -= 6; +} +static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +{ + if(but->flag & UI_SELECT) { rcti rectlink; @@ -2094,7 +2142,6 @@ static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, } } - static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb, wtb1; @@ -2541,6 +2588,11 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) wt.wcol_theme= &btheme->tui.wcol_list_item; wt.draw= widget_list_itembut; break; + + case UI_WTYPE_PROGRESSBAR: + wt.wcol_theme= &btheme->tui.wcol_progress; + wt.custom= widget_progressbar; + break; } return &wt; @@ -2756,6 +2808,11 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case BUT_CURVE: ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); break; + + case PROGRESSBAR: + wt= widget_type(UI_WTYPE_PROGRESSBAR); + fstyle= &style->widgetlabel; + break; case SCROLL: wt= widget_type(UI_WTYPE_SCROLL); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 82b195fb94a..cf47feb312b 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1463,6 +1463,28 @@ void init_userdef_do_versions(void) SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); } } + if (G.main->versionfile <= 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) { + bTheme *btheme; + + /* interface_widgets.c */ + struct uiWidgetColors wcol_progress= { + {0, 0, 0, 255}, + {190, 190, 190, 255}, + {100, 100, 100, 180}, + {68, 68, 68, 255}, + + {0, 0, 0, 255}, + {255, 255, 255, 255}, + + 0, + 5, -5 + }; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* init progress bar theme */ + btheme->tui.wcol_progress= wcol_progress; + } + } /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { |