diff options
author | Martin Felke <martin.felke@googlemail.com> | 2016-02-21 15:27:17 +0300 |
---|---|---|
committer | Martin Felke <martin.felke@googlemail.com> | 2016-02-21 15:27:17 +0300 |
commit | 1c09344dbaaff3e54cf436c40a3008ac7c81f8c1 (patch) | |
tree | e1485dfea2b49bbf573d76621cee81a73ff74c2e /source/blender/editors/interface/interface_templates.c | |
parent | eca5449a29766f52f6eff2eb066409aef508cf64 (diff) | |
parent | f6c11062bc500df2b7d9ed9e83283ef5648716cb (diff) |
Merge remote-tracking branch 'refs/remotes/origin/master' into fracture_modifier
Conflicts:
CMakeLists.txt
SConstruct
build_files/build_environment/install_deps.sh
build_files/scons/tools/Blender.py
build_files/scons/tools/btools.py
extern/CMakeLists.txt
extern/SConscript
extern/bullet2/CMakeLists.txt
intern/cycles/blender/blender_camera.cpp
intern/cycles/blender/blender_texture.cpp
intern/cycles/kernel/geom/geom_triangle_intersect.h
intern/cycles/kernel/kernel_compat_cpu.h
intern/cycles/kernel/svm/svm_voxel.h
intern/cycles/util/util_path.cpp
intern/ghost/intern/GHOST_ContextGLX.cpp
intern/iksolver/intern/IK_Solver.cpp
release/datafiles/locale
release/scripts/addons
release/scripts/startup/bl_ui/space_userpref.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_bvhutils.h
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/mesh_remap.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/rigidbody.c
source/blender/blenlib/intern/string.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/object/object_bake_api.c
source/blender/editors/space_graph/graph_ops.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_input.c
source/blender/editors/transform/transform_snap.c
source/blender/makesdna/intern/makesdna.c
source/blender/makesrna/SConscript
source/blender/makesrna/intern/SConscript
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_nodetree.c
source/blender/makesrna/intern/rna_rigidbody.c
source/blender/modifiers/SConscript
source/blender/python/mathutils/mathutils_geometry.c
source/blender/render/extern/include/RE_render_ext.h
source/blender/render/intern/source/bake_api.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/renderdatabase.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_files.c
source/blenderplayer/bad_level_call_stubs/stubs.c
source/gameengine/Ketsji/BL_Action.cpp
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 130 |
1 files changed, 109 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index bd8ff61dad8..40d4c535427 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_fnmatch.h" +#include "BLI_timecode.h" #include "BLF_api.h" #include "BLT_translation.h" @@ -81,6 +82,8 @@ #include "UI_interface_icons.h" #include "interface_intern.h" +#include "PIL_time.h" + void UI_template_fix_linking(void) { } @@ -148,11 +151,11 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str, continue; if (*str == '\0' || BLI_strcasestr(id->name + 2, str)) { - /* +1 is needed because name_uiprefix_id used 3 letter prefix + /* +1 is needed because BKE_id_ui_prefix used 3 letter prefix * followed by ID_NAME-2 characters from id->name */ char name_ui[MAX_ID_NAME + 1]; - name_uiprefix_id(name_ui, id); + BKE_id_ui_prefix(name_ui, id); iconid = ui_id_icon_get(C, id, template->preview); @@ -275,7 +278,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) if (id && CTX_wm_window(C)->eventstate->shift) { /* only way to force-remove data (on save) */ - id->flag &= ~LIB_FAKEUSER; + id_fake_user_clear(id); id->us = 0; } @@ -436,7 +439,7 @@ static void template_ID( if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); if (id->lib) { - if (id->flag & LIB_INDIRECT) { + if (id->tag & LIB_TAG_INDIRECT) { but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change")); UI_but_flag_enable(but, UI_BUT_DISABLED); @@ -1636,7 +1639,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) h = UI_UNIT_X * (args.icon_scale + args.show_labels); block = UI_block_begin(C, ar, "_popup", UI_EMBOSS_PULLDOWN); - UI_block_flag_enable(block, UI_BLOCK_LOOP); + UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NO_FLIP); RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free); @@ -1644,7 +1647,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) int x, y; x = (a % 8) * w; - y = (a / 8) * h; + y = -(a / 8) * h; icon = item[a].icon; value = item[a].value; @@ -2418,15 +2421,15 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, uiLayoutRow(col, true); for (; color; color = color->next) { - PointerRNA ptr; + PointerRNA color_ptr; if (row_cols >= cols_per_row) { uiLayoutRow(col, true); row_cols = 0; } - RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr); - uiDefButR(block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color", -1, 0.0, 1.0, + RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &color_ptr); + uiDefButR(block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &color_ptr, "color", -1, 0.0, 1.0, UI_PALETTE_COLOR, col_id, ""); row_cols++; col_id++; @@ -3376,6 +3379,36 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event) } } +struct ProgressTooltip_Store { + wmWindowManager *wm; + void *owner; +}; + +static char *progress_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip)) +{ + struct ProgressTooltip_Store *arg = argN; + wmWindowManager *wm = arg->wm; + void *owner = arg->owner; + + const float progress = WM_jobs_progress(wm, owner); + + /* create tooltip text and associate it with the job */ + char elapsed_str[32]; + char remaining_str[32] = "Unknown"; + const double elapsed = PIL_check_seconds_timer() - WM_jobs_starttime(wm, owner); + BLI_timecode_string_from_time_simple(elapsed_str, sizeof(elapsed_str), elapsed); + + if (progress) { + const double remaining = (elapsed / (double)progress) - elapsed; + BLI_timecode_string_from_time_simple(remaining_str, sizeof(remaining_str), remaining); + } + + return BLI_sprintfN( + "Time Remaining: %s\n" + "Time Elapsed: %s", + remaining_str, elapsed_str); +} + void uiTemplateRunningJobs(uiLayout *layout, bContext *C) { bScreen *screen = CTX_wm_screen(C); @@ -3383,7 +3416,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) ScrArea *sa = CTX_wm_area(C); uiBlock *block; void *owner = NULL; - int handle_event; + int handle_event, icon = 0; block = uiLayoutGetBlock(layout); UI_block_layout_set_current(block, layout); @@ -3394,17 +3427,20 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) owner = sa; handle_event = B_STOPSEQ; + icon = ICON_SEQUENCE; } else if (sa->spacetype == SPACE_CLIP) { if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) owner = sa; handle_event = B_STOPCLIP; + icon = ICON_CLIP; } else if (sa->spacetype == SPACE_FILE) { if (WM_jobs_test(wm, sa, WM_JOB_TYPE_FILESEL_READDIR)) { owner = sa; } handle_event = B_STOPFILE; + icon = ICON_FILESEL; } else { Scene *scene; @@ -3412,10 +3448,12 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next) { if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) { handle_event = B_STOPRENDER; + icon = ICON_SCENE; break; } else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_COMPOSITE)) { handle_event = B_STOPCOMPO; + icon = ICON_RENDERLAYERS; break; } else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE) || @@ -3427,11 +3465,33 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) */ if (sa->spacetype != SPACE_NODE) { handle_event = B_STOPOTHER; + icon = ICON_IMAGE_COL; break; } } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_DPAINT_BAKE)) { + handle_event = B_STOPOTHER; + icon = ICON_MOD_DYNAMICPAINT; + break; + } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_POINTCACHE)) { + handle_event = B_STOPOTHER; + icon = ICON_PHYSICS; + break; + } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_FLUID)) { + handle_event = B_STOPOTHER; + icon = ICON_MOD_FLUIDSIM; + break; + } + else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_OBJECT_SIM_OCEAN)) { + handle_event = B_STOPOTHER; + icon = ICON_MOD_OCEAN; + break; + } else if (WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY)) { handle_event = B_STOPOTHER; + icon = ICON_NONE; break; } } @@ -3439,18 +3499,45 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) } if (owner) { - uiLayout *ui_abs; - - ui_abs = uiLayoutAbsolute(layout, false); - (void)ui_abs; /* UNUSED */ + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + bool active = !(G.is_break || WM_jobs_is_stopped(wm, owner)); - uiDefIconBut(block, UI_BTYPE_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, TIP_("Stop this job")); - uiDefBut(block, UI_BTYPE_PROGRESS_BAR, 0, WM_jobs_name(wm, owner), - UI_UNIT_X, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); - - uiLayoutRow(layout, false); + uiLayout *row = uiLayoutRow(layout, false); + block = uiLayoutGetBlock(row); + + /* get percentage done and set it as the UI text */ + const float progress = WM_jobs_progress(wm, owner); + char text[8]; + BLI_snprintf(text, 8, "%d%%", (int)(progress * 100)); + + const char *name = active ? WM_jobs_name(wm, owner) : "Canceling..."; + + /* job name and icon */ + const int textwidth = UI_fontstyle_string_width(fstyle, name); + uiDefIconTextBut(block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, + textwidth + UI_UNIT_X * 1.5f, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0.0f, 0.0f, ""); + + /* stick progress bar and cancel button together */ + row = uiLayoutRow(layout, true); + uiLayoutSetActive(row, active); + block = uiLayoutGetBlock(row); + + { + struct ProgressTooltip_Store *tip_arg = MEM_mallocN(sizeof(*tip_arg), __func__); + tip_arg->wm = wm; + tip_arg->owner = owner; + uiBut *but_progress = uiDefIconTextBut( + block, UI_BTYPE_PROGRESS_BAR, 0, 0, text, + UI_UNIT_X, 0, UI_UNIT_X * 6.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, + progress, 0, NULL); + UI_but_func_tooltip_set(but_progress, progress_tooltip_func, tip_arg); + } + + uiDefIconTextBut(block, UI_BTYPE_BUT, handle_event, ICON_PANEL_CLOSE, + "", 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); } + if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, UI_UNIT_X * 4.25f, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); @@ -3484,7 +3571,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) ui_abs = uiLayoutAbsolute(layout, false); block = uiLayoutGetBlock(ui_abs); - width = BLF_width(style->widget.uifont_id, report->message, report->len); + UI_fontstyle_set(&style->widgetlabel); + width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len); width = min_ii((int)(rti->widthfac * width), width); width = max_ii(width, 10); |