diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 7066e2e7d66..8d1fa237754 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -294,6 +294,7 @@ class USERPREF_PT_interface_statusbar(InterfacePanel, CenterAlignMixIn, Panel): col = layout.column(heading="Show") col.prop(view, "show_statusbar_stats", text="Scene Statistics") + col.prop(view, "show_statusbar_scene_duration", text="Scene Duration") col.prop(view, "show_statusbar_memory", text="System Memory") col.prop(view, "show_statusbar_vram", text="Video Memory") col.prop(view, "show_statusbar_version", text="Blender Version") diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ca1f190001b..f1a84a16d14 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4342,6 +4342,7 @@ static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg) RNA_pointer_create(NULL, &RNA_PreferencesView, &U, &ptr); uiItemR(layout, &ptr, "show_statusbar_stats", 0, IFACE_("Scene Statistics"), ICON_NONE); + uiItemR(layout, &ptr, "show_statusbar_scene_duration", 0, IFACE_("Scene Duration"), ICON_NONE); uiItemR(layout, &ptr, "show_statusbar_memory", 0, IFACE_("System Memory"), ICON_NONE); if (GPU_mem_stats_supported()) { uiItemR(layout, &ptr, "show_statusbar_vram", 0, IFACE_("Video Memory"), ICON_NONE); diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index baf12a0f81b..56e98aa7625 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -25,6 +25,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_string.h" +#include "BLI_timecode.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -616,6 +617,24 @@ static const char *info_statusbar_string(Main *bmain, } } + /* Scene Duration. */ + if (statusbar_flag & STATUSBAR_SHOW_SCENE_DURATION) { + if (info[0]) { + ofs += BLI_snprintf_rlen(info + ofs, len - ofs, " | "); + } + const int relative_current_frame = (scene->r.cfra - scene->r.sfra) + 1; + const int frame_count = (scene->r.efra - scene->r.sfra) + 1; + char timecode[32]; + BLI_timecode_string_from_time( + timecode, sizeof(timecode), -2, FRA2TIME(frame_count), FPS, U.timecode_style); + ofs += BLI_snprintf_rlen(info + ofs, + len - ofs, + TIP_("Duration: %s (Frame %i/%i)"), + timecode, + relative_current_frame, + frame_count); + } + /* Memory status. */ if (statusbar_flag & STATUSBAR_SHOW_MEMORY) { if (info[0]) { @@ -668,7 +687,8 @@ const char *ED_info_statistics_string(Main *bmain, Scene *scene, ViewLayer *view { const eUserpref_StatusBar_Flag statistics_status_bar_flag = STATUSBAR_SHOW_STATS | STATUSBAR_SHOW_MEMORY | - STATUSBAR_SHOW_VERSION; + STATUSBAR_SHOW_VERSION | + STATUSBAR_SHOW_SCENE_DURATION; return info_statusbar_string(bmain, scene, view_layer, statistics_status_bar_flag); } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 5b0e9c166df..1d8cb6f7baa 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1180,6 +1180,7 @@ typedef enum eUserpref_StatusBar_Flag { STATUSBAR_SHOW_VRAM = (1 << 1), STATUSBAR_SHOW_STATS = (1 << 2), STATUSBAR_SHOW_VERSION = (1 << 3), + STATUSBAR_SHOW_SCENE_DURATION = (1 << 4), } eUserpref_StatusBar_Flag; /** diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index fb625758ced..0f59f94070f 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4972,6 +4972,11 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "statusbar_flag", STATUSBAR_SHOW_STATS); RNA_def_property_ui_text(prop, "Show Statistics", "Show scene statistics"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, "rna_userdef_update"); + + prop = RNA_def_property(srna, "show_statusbar_scene_duration", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "statusbar_flag", STATUSBAR_SHOW_SCENE_DURATION); + RNA_def_property_ui_text(prop, "Show Scene Duration", "Show scene duration"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, "rna_userdef_update"); } static void rna_def_userdef_edit(BlenderRNA *brna)