Animation: Add duration display to frame range settings #104882

Merged
Christoph Lendenfeld merged 13 commits from ChrisLend/blender:scene_frame_count into main 2023-03-23 10:18:50 +01:00
5 changed files with 29 additions and 1 deletions

View File

@ -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")

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
/**

View File

@ -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)