From e3e89d2741fb35ea01abce79bd03fef6716f596a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Mar 2023 15:12:36 +0100 Subject: [PATCH 1/8] add scene info --- scripts/startup/bl_ui/space_userpref.py | 1 + source/blender/editors/screen/screen_ops.c | 1 + .../blender/editors/space_info/info_stats.cc | 22 +++++++++++++++++-- source/blender/makesdna/DNA_userdef_types.h | 1 + source/blender/makesrna/intern/rna_userdef.c | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index f0dedc42c54..6a9fc8f9a5a 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -297,6 +297,7 @@ class USERPREF_PT_interface_statusbar(InterfacePanel, CenterAlignMixIn, Panel): 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") + col.prop(view, "show_statusbar_scene_duration", text="Scene Duration") class USERPREF_PT_interface_menus(InterfacePanel, Panel): diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8b0f9154ed5..8a1b45dc1c1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4347,6 +4347,7 @@ static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg) uiItemR(layout, &ptr, "show_statusbar_vram", 0, IFACE_("Video Memory"), ICON_NONE); } uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); + uiItemR(layout, &ptr, "show_statusbar_scene_duration", 0, IFACE_("Scene Duration"), ICON_NONE); } static int screen_context_menu_invoke(bContext *C, diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index f7163c03a57..5ec8e1515f0 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -603,7 +603,7 @@ static const char *info_statusbar_string(Main *bmain, { char formatted_mem[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE]; size_t ofs = 0; - static char info[256]; + static char info[512]; int len = sizeof(info); info[0] = '\0'; @@ -648,6 +648,23 @@ static const char *info_statusbar_string(Main *bmain, } } + if (statusbar_flag & STATUSBAR_SHOW_SCENE_DURATION) { + if (info[0]) { + ofs += BLI_snprintf_rlen(info + ofs, len - ofs, " | "); + } + const int frame_count = (scene->r.efra - scene->r.sfra) + 1; + const float fps = (((float)scene->r.frs_sec) / (float)scene->r.frs_sec_base); + const float duration = frame_count / fps; + const int duration_mins = (int)(duration / 60); + const float duration_secs = duration - (duration_mins * 60); + ofs += BLI_snprintf_rlen(info + ofs, + len - ofs, + TIP_("Frame Count: %i Duration: %i:%05.2f"), + frame_count, + duration_mins, + duration_secs); + } + /* Blender version. */ if (statusbar_flag & STATUSBAR_SHOW_VERSION) { if (info[0]) { @@ -668,7 +685,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 16fc0989282..c17f9f7e671 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1166,6 +1166,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 55da02286a3..67e8b2e8927 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) -- 2.30.2 From 81ee0b6628de56545ef0b0634bd02fc35b0d16ac Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Mar 2023 15:14:39 +0100 Subject: [PATCH 2/8] back to 256 str len and add | --- source/blender/editors/space_info/info_stats.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 5ec8e1515f0..ee8696c033b 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -603,7 +603,7 @@ static const char *info_statusbar_string(Main *bmain, { char formatted_mem[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE]; size_t ofs = 0; - static char info[512]; + static char info[256]; int len = sizeof(info); info[0] = '\0'; @@ -659,7 +659,7 @@ static const char *info_statusbar_string(Main *bmain, const float duration_secs = duration - (duration_mins * 60); ofs += BLI_snprintf_rlen(info + ofs, len - ofs, - TIP_("Frame Count: %i Duration: %i:%05.2f"), + TIP_("Frame Count: %i | Duration: %i:%05.2f"), frame_count, duration_mins, duration_secs); -- 2.30.2 From 746d0d76bc17234d1deae9a7088b56352eb35361 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Mar 2023 15:17:48 +0100 Subject: [PATCH 3/8] change order of info --- scripts/startup/bl_ui/space_userpref.py | 2 +- source/blender/editors/screen/screen_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 6a9fc8f9a5a..6a5f2baf58d 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -296,8 +296,8 @@ class USERPREF_PT_interface_statusbar(InterfacePanel, CenterAlignMixIn, Panel): col.prop(view, "show_statusbar_stats", text="Scene Statistics") 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") col.prop(view, "show_statusbar_scene_duration", text="Scene Duration") + col.prop(view, "show_statusbar_version", text="Blender Version") class USERPREF_PT_interface_menus(InterfacePanel, Panel): diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8a1b45dc1c1..c8b7193142d 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4346,8 +4346,8 @@ static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg) if (GPU_mem_stats_supported()) { uiItemR(layout, &ptr, "show_statusbar_vram", 0, IFACE_("Video Memory"), ICON_NONE); } - uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); uiItemR(layout, &ptr, "show_statusbar_scene_duration", 0, IFACE_("Scene Duration"), ICON_NONE); + uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); } static int screen_context_menu_invoke(bContext *C, -- 2.30.2 From bf35318fdb6dfa8a3e919af75ebb063978c51531 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Sat, 4 Mar 2023 15:39:22 +0100 Subject: [PATCH 4/8] change order --- source/blender/editors/space_info/info_stats.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index ee8696c033b..d14466c9d9d 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -659,10 +659,10 @@ static const char *info_statusbar_string(Main *bmain, const float duration_secs = duration - (duration_mins * 60); ofs += BLI_snprintf_rlen(info + ofs, len - ofs, - TIP_("Frame Count: %i | Duration: %i:%05.2f"), - frame_count, + TIP_("Scene Duration: %i:%05.2f | Frame Count: %i"), duration_mins, - duration_secs); + duration_secs, + frame_count); } /* Blender version. */ -- 2.30.2 From baa780ecccb6a3f55b290680161273a2133a25c7 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Mar 2023 11:24:46 +0100 Subject: [PATCH 5/8] use user defined timecode style and shorten text --- source/blender/editors/space_info/info_stats.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index d14466c9d9d..5187d4aa0c0 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" @@ -652,16 +653,16 @@ static const char *info_statusbar_string(Main *bmain, 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; - const float fps = (((float)scene->r.frs_sec) / (float)scene->r.frs_sec_base); - const float duration = frame_count / fps; - const int duration_mins = (int)(duration / 60); - const float duration_secs = duration - (duration_mins * 60); + 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_("Scene Duration: %i:%05.2f | Frame Count: %i"), - duration_mins, - duration_secs, + TIP_("Duration: %s (Frame %i/%i)"), + timecode, + relative_current_frame, frame_count); } -- 2.30.2 From 5ad1655486f7a1c2479f0abd21fa207ef4940276 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Mar 2023 11:52:22 +0100 Subject: [PATCH 6/8] move scene duration menu location --- scripts/startup/bl_ui/space_userpref.py | 2 +- source/blender/editors/screen/screen_ops.c | 2 +- .../blender/editors/space_info/info_stats.cc | 35 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 6a5f2baf58d..f89f5d7cdf6 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -294,9 +294,9 @@ 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_scene_duration", text="Scene Duration") 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 43e862269eb..1c2b9e4698a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4342,11 +4342,11 @@ 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); } - uiItemR(layout, &ptr, "show_statusbar_scene_duration", 0, IFACE_("Scene Duration"), ICON_NONE); uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); } diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index b7a5cf62535..248c19aa750 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -617,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]) { @@ -649,23 +667,6 @@ static const char *info_statusbar_string(Main *bmain, } } - 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); - } - /* Blender version. */ if (statusbar_flag & STATUSBAR_SHOW_VERSION) { if (info[0]) { -- 2.30.2 From 87bd8eedf819d0c1898ba999fd6c5414753b2611 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 10 Mar 2023 11:38:33 +0100 Subject: [PATCH 7/8] add space between current and total frames --- source/blender/editors/space_info/info_stats.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 248c19aa750..b8bc2fc436c 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -629,7 +629,7 @@ static const char *info_statusbar_string(Main *bmain, 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)"), + TIP_("Duration: %s (Frame %i / %i)"), timecode, relative_current_frame, frame_count); -- 2.30.2 From b4265d775f911a8d8b3eee36cba933b35fdc1717 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 16 Mar 2023 09:26:31 +0100 Subject: [PATCH 8/8] remove spaces again --- source/blender/editors/space_info/info_stats.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index 39865efaa29..56e98aa7625 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -629,7 +629,7 @@ static const char *info_statusbar_string(Main *bmain, 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)"), + TIP_("Duration: %s (Frame %i/%i)"), timecode, relative_current_frame, frame_count); -- 2.30.2