UI: Status Bar Statistics and Other Options
Status Bar can show scene statistics, memory usage, version, etc set by context menu. Part two of T75672. Differential Revision: https://developer.blender.org/D7557 Reviewed by Julian Eisel
This commit is contained in:
@@ -229,6 +229,8 @@ const UserDef U_default = {
|
|||||||
|
|
||||||
.collection_instance_empty_size = 1.0f,
|
.collection_instance_empty_size = 1.0f,
|
||||||
|
|
||||||
|
.statusbar_flag = STATUSBAR_SHOW_VERSION,
|
||||||
|
|
||||||
.runtime =
|
.runtime =
|
||||||
{
|
{
|
||||||
.is_dirty = 0,
|
.is_dirty = 0,
|
||||||
|
|||||||
@@ -31,17 +31,20 @@ class STATUSBAR_HT_header(Header):
|
|||||||
|
|
||||||
layout.separator_spacer()
|
layout.separator_spacer()
|
||||||
|
|
||||||
# messages
|
# Nothing in the center.
|
||||||
layout.template_reports_banner()
|
|
||||||
layout.template_running_jobs()
|
|
||||||
|
|
||||||
layout.separator_spacer()
|
layout.separator_spacer()
|
||||||
|
|
||||||
# stats
|
row = layout.row()
|
||||||
scene = context.scene
|
row.alignment = 'RIGHT'
|
||||||
view_layer = context.view_layer
|
|
||||||
|
|
||||||
layout.label(text=scene.statistics(view_layer), translate=False)
|
# Stats & Info
|
||||||
|
row.label(text=context.screen.statusbar_info(), translate=False)
|
||||||
|
|
||||||
|
# Messages
|
||||||
|
row.template_reports_banner()
|
||||||
|
|
||||||
|
# Progress Bar
|
||||||
|
row.template_running_jobs()
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
|
|||||||
@@ -283,6 +283,22 @@ class USERPREF_PT_interface_temporary_windows(InterfacePanel, CenterAlignMixIn,
|
|||||||
col.prop(view, "filebrowser_display_type", text="File Browser")
|
col.prop(view, "filebrowser_display_type", text="File Browser")
|
||||||
|
|
||||||
|
|
||||||
|
class USERPREF_PT_interface_statusbar(InterfacePanel, CenterAlignMixIn, Panel):
|
||||||
|
bl_label = "Status Bar"
|
||||||
|
bl_parent_id = "USERPREF_PT_interface_editors"
|
||||||
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
|
|
||||||
|
def draw_centered(self, context, layout):
|
||||||
|
prefs = context.preferences
|
||||||
|
view = prefs.view
|
||||||
|
|
||||||
|
col = layout.column(heading="Show")
|
||||||
|
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")
|
||||||
|
|
||||||
|
|
||||||
class USERPREF_PT_interface_menus(InterfacePanel, Panel):
|
class USERPREF_PT_interface_menus(InterfacePanel, Panel):
|
||||||
bl_label = "Menus"
|
bl_label = "Menus"
|
||||||
bl_options = {'DEFAULT_CLOSED'}
|
bl_options = {'DEFAULT_CLOSED'}
|
||||||
@@ -2189,6 +2205,7 @@ classes = (
|
|||||||
USERPREF_PT_interface_display,
|
USERPREF_PT_interface_display,
|
||||||
USERPREF_PT_interface_editors,
|
USERPREF_PT_interface_editors,
|
||||||
USERPREF_PT_interface_temporary_windows,
|
USERPREF_PT_interface_temporary_windows,
|
||||||
|
USERPREF_PT_interface_statusbar,
|
||||||
USERPREF_PT_interface_translation,
|
USERPREF_PT_interface_translation,
|
||||||
USERPREF_PT_interface_text,
|
USERPREF_PT_interface_text,
|
||||||
USERPREF_PT_interface_menus,
|
USERPREF_PT_interface_menus,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ extern "C" {
|
|||||||
/* Blender major and minor version. */
|
/* Blender major and minor version. */
|
||||||
#define BLENDER_VERSION 290
|
#define BLENDER_VERSION 290
|
||||||
/* Blender patch version for bugfix releases. */
|
/* Blender patch version for bugfix releases. */
|
||||||
#define BLENDER_VERSION_PATCH 0
|
#define BLENDER_VERSION_PATCH 1
|
||||||
/** Blender release cycle stage: alpha/beta/rc/release. */
|
/** Blender release cycle stage: alpha/beta/rc/release. */
|
||||||
#define BLENDER_VERSION_CYCLE alpha
|
#define BLENDER_VERSION_CYCLE alpha
|
||||||
|
|
||||||
|
|||||||
@@ -753,6 +753,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
|||||||
userdef->transopts &= ~USER_DOTRANSLATE_DEPRECATED;
|
userdef->transopts &= ~USER_DOTRANSLATE_DEPRECATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!USER_VERSION_ATLEAST(290, 1)) {
|
||||||
|
userdef->statusbar_flag = STATUSBAR_SHOW_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Versioning code until next subversion bump goes here.
|
* Versioning code until next subversion bump goes here.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -31,9 +31,11 @@ struct Main;
|
|||||||
|
|
||||||
/* info_stats.c */
|
/* info_stats.c */
|
||||||
void ED_info_stats_clear(struct ViewLayer *view_layer);
|
void ED_info_stats_clear(struct ViewLayer *view_layer);
|
||||||
const char *ED_info_footer_string(struct ViewLayer *view_layer);
|
const char *ED_info_statusbar_string(struct Main *bmain,
|
||||||
|
struct bScreen *screen,
|
||||||
|
struct bContext *C);
|
||||||
void ED_info_draw_stats(
|
void ED_info_draw_stats(
|
||||||
Main *bmain, Scene *scene, ViewLayer *view_layer, int x, int *y, int height);
|
struct Main *bmain, Scene *scene, ViewLayer *view_layer, int x, int *y, int height);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,8 @@
|
|||||||
#include "UI_resources.h"
|
#include "UI_resources.h"
|
||||||
#include "UI_view2d.h"
|
#include "UI_view2d.h"
|
||||||
|
|
||||||
|
#include "GPU_extensions.h"
|
||||||
|
|
||||||
#include "screen_intern.h" /* own module include */
|
#include "screen_intern.h" /* own module include */
|
||||||
|
|
||||||
#define KM_MODAL_CANCEL 1
|
#define KM_MODAL_CANCEL 1
|
||||||
@@ -4127,12 +4129,6 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot)
|
|||||||
/** \name Region Context Menu Operator (Header/Footer/Navbar)
|
/** \name Region Context Menu Operator (Header/Footer/Navbar)
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
static bool screen_region_context_menu_poll(bContext *C)
|
|
||||||
{
|
|
||||||
ScrArea *area = CTX_wm_area(C);
|
|
||||||
return (area && area->spacetype != SPACE_STATUSBAR);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
|
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
|
||||||
{
|
{
|
||||||
ScrArea *area = CTX_wm_area(C);
|
ScrArea *area = CTX_wm_area(C);
|
||||||
@@ -4221,15 +4217,35 @@ void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout,
|
|||||||
uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
|
uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ED_screens_statusbar_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg))
|
||||||
|
{
|
||||||
|
PointerRNA ptr;
|
||||||
|
|
||||||
|
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_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_version", 0, IFACE_("Blender Version"), ICON_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
static int screen_context_menu_invoke(bContext *C,
|
static int screen_context_menu_invoke(bContext *C,
|
||||||
wmOperator *UNUSED(op),
|
wmOperator *UNUSED(op),
|
||||||
const wmEvent *UNUSED(event))
|
const wmEvent *UNUSED(event))
|
||||||
{
|
{
|
||||||
uiPopupMenu *pup;
|
uiPopupMenu *pup;
|
||||||
uiLayout *layout;
|
uiLayout *layout;
|
||||||
|
const ScrArea *area = CTX_wm_area(C);
|
||||||
const ARegion *region = CTX_wm_region(C);
|
const ARegion *region = CTX_wm_region(C);
|
||||||
|
|
||||||
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
|
if (area && area->spacetype == SPACE_STATUSBAR) {
|
||||||
|
pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE);
|
||||||
|
layout = UI_popup_menu_layout(pup);
|
||||||
|
ED_screens_statusbar_menu_create(C, layout, NULL);
|
||||||
|
UI_popup_menu_end(C, pup);
|
||||||
|
}
|
||||||
|
else if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
|
||||||
pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
|
pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE);
|
||||||
layout = UI_popup_menu_layout(pup);
|
layout = UI_popup_menu_layout(pup);
|
||||||
ED_screens_header_tools_menu_create(C, layout, NULL);
|
ED_screens_header_tools_menu_create(C, layout, NULL);
|
||||||
@@ -4259,7 +4275,6 @@ static void SCREEN_OT_region_context_menu(wmOperatorType *ot)
|
|||||||
ot->idname = "SCREEN_OT_region_context_menu";
|
ot->idname = "SCREEN_OT_region_context_menu";
|
||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
ot->poll = screen_region_context_menu_poll;
|
|
||||||
ot->invoke = screen_context_menu_invoke;
|
ot->invoke = screen_context_menu_invoke;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "BLT_translation.h"
|
#include "BLT_translation.h"
|
||||||
|
|
||||||
#include "BKE_blender_version.h"
|
#include "BKE_blender_version.h"
|
||||||
|
#include "BKE_context.h"
|
||||||
#include "BKE_curve.h"
|
#include "BKE_curve.h"
|
||||||
#include "BKE_displist.h"
|
#include "BKE_displist.h"
|
||||||
#include "BKE_editmesh.h"
|
#include "BKE_editmesh.h"
|
||||||
@@ -405,46 +406,6 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer)
|
|||||||
*(view_layer->stats) = stats;
|
*(view_layer->stats) = stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *footer_string(ViewLayer *view_layer)
|
|
||||||
{
|
|
||||||
#define MAX_INFO_MEM_LEN 64
|
|
||||||
char memstr[MAX_INFO_MEM_LEN];
|
|
||||||
char gpumemstr[MAX_INFO_MEM_LEN] = "";
|
|
||||||
char formatted_mem[15];
|
|
||||||
size_t ofs = 0;
|
|
||||||
|
|
||||||
uintptr_t mem_in_use = MEM_get_memory_in_use();
|
|
||||||
|
|
||||||
/* get memory statistics */
|
|
||||||
BLI_str_format_byte_unit(formatted_mem, mem_in_use, false);
|
|
||||||
ofs = BLI_snprintf(memstr, MAX_INFO_MEM_LEN, TIP_("Mem: %s"), formatted_mem);
|
|
||||||
|
|
||||||
if (GPU_mem_stats_supported()) {
|
|
||||||
int gpu_free_mem, gpu_tot_memory;
|
|
||||||
|
|
||||||
GPU_mem_stats_get(&gpu_tot_memory, &gpu_free_mem);
|
|
||||||
|
|
||||||
BLI_str_format_byte_unit(formatted_mem, gpu_free_mem, false);
|
|
||||||
ofs = BLI_snprintf(gpumemstr, MAX_INFO_MEM_LEN, TIP_(" | Free GPU Mem: %s"), formatted_mem);
|
|
||||||
|
|
||||||
if (gpu_tot_memory) {
|
|
||||||
BLI_str_format_byte_unit(formatted_mem, gpu_tot_memory, false);
|
|
||||||
BLI_snprintf(gpumemstr + ofs, MAX_INFO_MEM_LEN - ofs, TIP_("/%s"), formatted_mem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BLI_snprintf(view_layer->footer_str,
|
|
||||||
sizeof(view_layer->footer_str),
|
|
||||||
"%s%s | %s",
|
|
||||||
memstr,
|
|
||||||
gpumemstr,
|
|
||||||
BKE_blender_version_string());
|
|
||||||
|
|
||||||
return view_layer->footer_str;
|
|
||||||
|
|
||||||
#undef MAX_INFO_MEM_LEN
|
|
||||||
}
|
|
||||||
|
|
||||||
void ED_info_stats_clear(ViewLayer *view_layer)
|
void ED_info_stats_clear(ViewLayer *view_layer)
|
||||||
{
|
{
|
||||||
if (view_layer->stats) {
|
if (view_layer->stats) {
|
||||||
@@ -453,45 +414,26 @@ void ED_info_stats_clear(ViewLayer *view_layer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ED_info_footer_string(ViewLayer *view_layer)
|
static bool format_stats(Main *bmain,
|
||||||
{
|
Scene *scene,
|
||||||
return footer_string(view_layer);
|
ViewLayer *view_layer,
|
||||||
}
|
SceneStatsFmt *stats_fmt)
|
||||||
|
|
||||||
static void stats_row(int col1,
|
|
||||||
const char *key,
|
|
||||||
int col2,
|
|
||||||
const char *value1,
|
|
||||||
const char *value2,
|
|
||||||
int *y,
|
|
||||||
int height)
|
|
||||||
{
|
|
||||||
*y -= height;
|
|
||||||
BLF_draw_default(col1, *y, 0.0f, key, 128);
|
|
||||||
char values[128];
|
|
||||||
BLI_snprintf(values, sizeof(values), (value2) ? "%s / %s" : "%s", value1, value2);
|
|
||||||
BLF_draw_default(col2, *y, 0.0f, values, sizeof(values));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ED_info_draw_stats(
|
|
||||||
Main *bmain, Scene *scene, ViewLayer *view_layer, int x, int *y, int height)
|
|
||||||
{
|
{
|
||||||
/* Create stats if they don't already exist. */
|
/* Create stats if they don't already exist. */
|
||||||
if (!view_layer->stats) {
|
if (!view_layer->stats) {
|
||||||
/* Do not not access dependency graph if interface is marked as locked. */
|
/* Do not not access dependency graph if interface is marked as locked. */
|
||||||
wmWindowManager *wm = bmain->wm.first;
|
wmWindowManager *wm = bmain->wm.first;
|
||||||
if (wm->is_interface_locked) {
|
if (wm->is_interface_locked) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
|
Depsgraph *depsgraph = BKE_scene_get_depsgraph(bmain, scene, view_layer, true);
|
||||||
stats_update(depsgraph, view_layer);
|
stats_update(depsgraph, view_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneStats *stats = view_layer->stats;
|
SceneStats *stats = view_layer->stats;
|
||||||
SceneStatsFmt stats_fmt;
|
|
||||||
|
|
||||||
/* Generate formatted numbers. */
|
/* Generate formatted numbers. */
|
||||||
#define SCENE_STATS_FMT_INT(_id) BLI_str_format_uint64_grouped(stats_fmt._id, stats->_id)
|
#define SCENE_STATS_FMT_INT(_id) BLI_str_format_uint64_grouped(stats_fmt->_id, stats->_id)
|
||||||
|
|
||||||
SCENE_STATS_FMT_INT(totvert);
|
SCENE_STATS_FMT_INT(totvert);
|
||||||
SCENE_STATS_FMT_INT(totvertsel);
|
SCENE_STATS_FMT_INT(totvertsel);
|
||||||
@@ -519,6 +461,176 @@ void ED_info_draw_stats(
|
|||||||
SCENE_STATS_FMT_INT(totgppoint);
|
SCENE_STATS_FMT_INT(totgppoint);
|
||||||
|
|
||||||
#undef SCENE_STATS_FMT_INT
|
#undef SCENE_STATS_FMT_INT
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void get_stats_string(
|
||||||
|
char *info, int len, size_t *ofs, ViewLayer *view_layer, SceneStatsFmt *stats_fmt)
|
||||||
|
{
|
||||||
|
Object *ob = OBACT(view_layer);
|
||||||
|
Object *obedit = OBEDIT_FROM_OBACT(ob);
|
||||||
|
eObjectMode object_mode = ob ? ob->mode : OB_MODE_OBJECT;
|
||||||
|
LayerCollection *layer_collection = view_layer->active_collection;
|
||||||
|
|
||||||
|
if (object_mode == OB_MODE_OBJECT) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
"%s | ",
|
||||||
|
BKE_collection_ui_name_get(layer_collection->collection));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ob) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs, len - *ofs, "%s | ", ob->id.name + 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obedit) {
|
||||||
|
if (BKE_keyblock_from_object(obedit)) {
|
||||||
|
*ofs += BLI_strncpy_rlen(info + *ofs, TIP_("(Key) "), len - *ofs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obedit->type == OB_MESH) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
TIP_("Verts:%s/%s | Edges:%s/%s | Faces:%s/%s | Tris:%s"),
|
||||||
|
stats_fmt->totvertsel,
|
||||||
|
stats_fmt->totvert,
|
||||||
|
stats_fmt->totedgesel,
|
||||||
|
stats_fmt->totedge,
|
||||||
|
stats_fmt->totfacesel,
|
||||||
|
stats_fmt->totface,
|
||||||
|
stats_fmt->tottri);
|
||||||
|
}
|
||||||
|
else if (obedit->type == OB_ARMATURE) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
TIP_("Verts:%s/%s | Bones:%s/%s"),
|
||||||
|
stats_fmt->totvertsel,
|
||||||
|
stats_fmt->totvert,
|
||||||
|
stats_fmt->totbonesel,
|
||||||
|
stats_fmt->totbone);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*ofs += BLI_snprintf(
|
||||||
|
info + *ofs, len - *ofs, TIP_("Verts:%s/%s"), stats_fmt->totvertsel, stats_fmt->totvert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ob && (object_mode & OB_MODE_POSE)) {
|
||||||
|
*ofs += BLI_snprintf(
|
||||||
|
info + *ofs, len - *ofs, TIP_("Bones:%s/%s"), stats_fmt->totbonesel, stats_fmt->totbone);
|
||||||
|
}
|
||||||
|
else if ((ob) && (ob->type == OB_GPENCIL)) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
TIP_("Layers:%s | Frames:%s | Strokes:%s | Points:%s"),
|
||||||
|
stats_fmt->totgplayer,
|
||||||
|
stats_fmt->totgpframe,
|
||||||
|
stats_fmt->totgpstroke,
|
||||||
|
stats_fmt->totgppoint);
|
||||||
|
}
|
||||||
|
else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
TIP_("Verts:%s | Tris:%s"),
|
||||||
|
stats_fmt->totvert,
|
||||||
|
stats_fmt->tottri);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*ofs += BLI_snprintf(info + *ofs,
|
||||||
|
len - *ofs,
|
||||||
|
TIP_("Verts:%s | Faces:%s | Tris:%s"),
|
||||||
|
stats_fmt->totvert,
|
||||||
|
stats_fmt->totface,
|
||||||
|
stats_fmt->tottri);
|
||||||
|
}
|
||||||
|
|
||||||
|
*ofs += BLI_snprintf(
|
||||||
|
info + *ofs, len - *ofs, TIP_(" | Objects:%s/%s"), stats_fmt->totobjsel, stats_fmt->totobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ED_info_statusbar_string(Main *bmain, bScreen *screen, bContext *C)
|
||||||
|
{
|
||||||
|
char formatted_mem[15];
|
||||||
|
size_t ofs = 0;
|
||||||
|
char *info = screen->statusbar_info;
|
||||||
|
int len = sizeof(screen->statusbar_info);
|
||||||
|
|
||||||
|
info[0] = '\0';
|
||||||
|
|
||||||
|
/* Scene statistics. */
|
||||||
|
if (U.statusbar_flag & STATUSBAR_SHOW_STATS) {
|
||||||
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||||
|
Scene *scene = CTX_data_scene(C);
|
||||||
|
SceneStatsFmt stats_fmt;
|
||||||
|
if (format_stats(bmain, scene, view_layer, &stats_fmt)) {
|
||||||
|
get_stats_string(info + ofs, len, &ofs, view_layer, &stats_fmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Memory status. */
|
||||||
|
if (U.statusbar_flag & STATUSBAR_SHOW_MEMORY) {
|
||||||
|
if (info[0]) {
|
||||||
|
ofs += BLI_snprintf(info + ofs, len - ofs, " | ");
|
||||||
|
}
|
||||||
|
uintptr_t mem_in_use = MEM_get_memory_in_use();
|
||||||
|
BLI_str_format_byte_unit(formatted_mem, mem_in_use, false);
|
||||||
|
ofs += BLI_snprintf(info + ofs, len, TIP_("Memory: %s"), formatted_mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GPU VRAM status. */
|
||||||
|
if ((U.statusbar_flag & STATUSBAR_SHOW_VRAM) && (GPU_mem_stats_supported())) {
|
||||||
|
int gpu_free_mem_kb, gpu_tot_mem_kb;
|
||||||
|
GPU_mem_stats_get(&gpu_tot_mem_kb, &gpu_free_mem_kb);
|
||||||
|
float gpu_total_gb = gpu_tot_mem_kb / 1048576.0f;
|
||||||
|
float gpu_free_gb = gpu_free_mem_kb / 1048576.0f;
|
||||||
|
if (info[0]) {
|
||||||
|
ofs += BLI_snprintf(info + ofs, len - ofs, " | ");
|
||||||
|
}
|
||||||
|
if (gpu_free_mem_kb && gpu_tot_mem_kb) {
|
||||||
|
ofs += BLI_snprintf(info + ofs,
|
||||||
|
len - ofs,
|
||||||
|
TIP_("VRAM: %.1f/%.1f GiB"),
|
||||||
|
gpu_total_gb - gpu_free_gb,
|
||||||
|
gpu_total_gb);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Can only show amount of GPU VRAM available. */
|
||||||
|
ofs += BLI_snprintf(info + ofs, len - ofs, TIP_("VRAM: %.1f GiB Free"), gpu_free_gb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Blender version. */
|
||||||
|
if (U.statusbar_flag & STATUSBAR_SHOW_VERSION) {
|
||||||
|
if (info[0]) {
|
||||||
|
ofs += BLI_snprintf(info + ofs, len - ofs, " | ");
|
||||||
|
}
|
||||||
|
ofs += BLI_snprintf(info + ofs, len - ofs, TIP_("%s"), BKE_blender_version_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stats_row(int col1,
|
||||||
|
const char *key,
|
||||||
|
int col2,
|
||||||
|
const char *value1,
|
||||||
|
const char *value2,
|
||||||
|
int *y,
|
||||||
|
int height)
|
||||||
|
{
|
||||||
|
*y -= height;
|
||||||
|
BLF_draw_default(col1, *y, 0.0f, key, 128);
|
||||||
|
char values[128];
|
||||||
|
BLI_snprintf(values, sizeof(values), (value2) ? "%s / %s" : "%s", value1, value2);
|
||||||
|
BLF_draw_default(col2, *y, 0.0f, values, sizeof(values));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ED_info_draw_stats(
|
||||||
|
Main *bmain, Scene *scene, ViewLayer *view_layer, int x, int *y, int height)
|
||||||
|
{
|
||||||
|
SceneStatsFmt stats_fmt;
|
||||||
|
if (!format_stats(bmain, scene, view_layer, &stats_fmt)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Object *ob = OBACT(view_layer);
|
Object *ob = OBACT(view_layer);
|
||||||
Object *obedit = OBEDIT_FROM_OBACT(ob);
|
Object *obedit = OBEDIT_FROM_OBACT(ob);
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ void gpu_extensions_exit(void)
|
|||||||
bool GPU_mem_stats_supported(void)
|
bool GPU_mem_stats_supported(void)
|
||||||
{
|
{
|
||||||
#ifndef GPU_STANDALONE
|
#ifndef GPU_STANDALONE
|
||||||
return (GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo) && (G.debug & G_DEBUG_GPU_MEM);
|
return (GLEW_NVX_gpu_memory_info || GLEW_ATI_meminfo);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ typedef struct ViewLayer {
|
|||||||
ListBase object_bases;
|
ListBase object_bases;
|
||||||
/** Default allocated now. */
|
/** Default allocated now. */
|
||||||
struct SceneStats *stats;
|
struct SceneStats *stats;
|
||||||
char footer_str[128];
|
|
||||||
struct Base *basact;
|
struct Base *basact;
|
||||||
|
|
||||||
/** A view layer has one top level layer collection, because a scene has only one top level
|
/** A view layer has one top level layer collection, because a scene has only one top level
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ typedef struct bScreen {
|
|||||||
/** User-setting for which editors get redrawn during anim playback. */
|
/** User-setting for which editors get redrawn during anim playback. */
|
||||||
short redraws_flag;
|
short redraws_flag;
|
||||||
|
|
||||||
|
char statusbar_info[256];
|
||||||
|
|
||||||
/** Temp screen in a temp window, don't save (like user prefs). */
|
/** Temp screen in a temp window, don't save (like user prefs). */
|
||||||
char temp;
|
char temp;
|
||||||
/** Temp screen for image render display or fileselect. */
|
/** Temp screen for image render display or fileselect. */
|
||||||
|
|||||||
@@ -880,7 +880,9 @@ typedef struct UserDef {
|
|||||||
char _pad5[2];
|
char _pad5[2];
|
||||||
|
|
||||||
float collection_instance_empty_size;
|
float collection_instance_empty_size;
|
||||||
char _pad10[4];
|
char _pad10[3];
|
||||||
|
|
||||||
|
char statusbar_flag; /* eUserpref_StatusBar_Flag */
|
||||||
|
|
||||||
struct WalkNavigation walk_navigation;
|
struct WalkNavigation walk_navigation;
|
||||||
|
|
||||||
@@ -1079,6 +1081,14 @@ typedef enum eUserpref_APP_Flag {
|
|||||||
USER_APP_LOCK_UI_LAYOUT = (1 << 0),
|
USER_APP_LOCK_UI_LAYOUT = (1 << 0),
|
||||||
} eUserpref_APP_Flag;
|
} eUserpref_APP_Flag;
|
||||||
|
|
||||||
|
/** #UserDef.statusbar_flag */
|
||||||
|
typedef enum eUserpref_StatusBar_Flag {
|
||||||
|
STATUSBAR_SHOW_MEMORY = (1 << 0),
|
||||||
|
STATUSBAR_SHOW_VRAM = (1 << 1),
|
||||||
|
STATUSBAR_SHOW_STATS = (1 << 2),
|
||||||
|
STATUSBAR_SHOW_VERSION = (1 << 3),
|
||||||
|
} eUserpref_StatusBar_Flag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto-Keying mode.
|
* Auto-Keying mode.
|
||||||
* #UserDef.autokey_mode
|
* #UserDef.autokey_mode
|
||||||
|
|||||||
@@ -924,13 +924,6 @@ static void rna_Scene_volume_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
|
|||||||
DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO_VOLUME | ID_RECALC_SEQUENCER_STRIPS);
|
DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO_VOLUME | ID_RECALC_SEQUENCER_STRIPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *rna_Scene_statistics_string_get(Scene *UNUSED(scene),
|
|
||||||
Main *UNUSED(bmain),
|
|
||||||
ViewLayer *view_layer)
|
|
||||||
{
|
|
||||||
return ED_info_footer_string(view_layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
|
static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
|
||||||
{
|
{
|
||||||
scene->r.framelen = (float)scene->r.framapto / (float)scene->r.images;
|
scene->r.framelen = (float)scene->r.framapto / (float)scene->r.images;
|
||||||
@@ -7275,9 +7268,6 @@ void RNA_def_scene(BlenderRNA *brna)
|
|||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
FunctionRNA *func;
|
|
||||||
PropertyRNA *parm;
|
|
||||||
|
|
||||||
static const EnumPropertyItem audio_distance_model_items[] = {
|
static const EnumPropertyItem audio_distance_model_items[] = {
|
||||||
{0, "NONE", 0, "None", "No distance attenuation"},
|
{0, "NONE", 0, "None", "No distance attenuation"},
|
||||||
{1, "INVERSE", 0, "Inverse", "Inverse distance model"},
|
{1, "INVERSE", 0, "Inverse", "Inverse distance model"},
|
||||||
@@ -7669,14 +7659,6 @@ void RNA_def_scene(BlenderRNA *brna)
|
|||||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||||
RNA_def_property_update(prop, NC_SCENE, "rna_Scene_volume_update");
|
RNA_def_property_update(prop, NC_SCENE, "rna_Scene_volume_update");
|
||||||
|
|
||||||
/* Statistics */
|
|
||||||
func = RNA_def_function(srna, "statistics", "rna_Scene_statistics_string_get");
|
|
||||||
RNA_def_function_flag(func, FUNC_USE_MAIN);
|
|
||||||
parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", "Active layer");
|
|
||||||
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
|
|
||||||
parm = RNA_def_string(func, "statistics", NULL, 0, "Statistics", "");
|
|
||||||
RNA_def_function_return(func, parm);
|
|
||||||
|
|
||||||
/* Grease Pencil */
|
/* Grease Pencil */
|
||||||
prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
|
prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
|
||||||
RNA_def_property_pointer_sdna(prop, NULL, "gpd");
|
RNA_def_property_pointer_sdna(prop, NULL, "gpd");
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
#include "DNA_workspace_types.h"
|
#include "DNA_workspace_types.h"
|
||||||
|
|
||||||
|
#include "ED_info.h"
|
||||||
|
|
||||||
const EnumPropertyItem rna_enum_region_type_items[] = {
|
const EnumPropertyItem rna_enum_region_type_items[] = {
|
||||||
{RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""},
|
{RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""},
|
||||||
{RGN_TYPE_HEADER, "HEADER", 0, "Header", ""},
|
{RGN_TYPE_HEADER, "HEADER", 0, "Header", ""},
|
||||||
@@ -286,6 +288,11 @@ static void rna_View2D_view_to_region(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *rna_Screen_statusbar_info_get(struct bScreen *screen, Main *bmain, bContext *C)
|
||||||
|
{
|
||||||
|
return ED_info_statusbar_string(bmain, screen, C);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Area.spaces */
|
/* Area.spaces */
|
||||||
@@ -536,6 +543,9 @@ static void rna_def_screen(BlenderRNA *brna)
|
|||||||
StructRNA *srna;
|
StructRNA *srna;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
|
FunctionRNA *func;
|
||||||
|
PropertyRNA *parm;
|
||||||
|
|
||||||
srna = RNA_def_struct(brna, "Screen", "ID");
|
srna = RNA_def_struct(brna, "Screen", "ID");
|
||||||
RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */
|
RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */
|
||||||
RNA_def_struct_ui_text(
|
RNA_def_struct_ui_text(
|
||||||
@@ -570,11 +580,18 @@ static void rna_def_screen(BlenderRNA *brna)
|
|||||||
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
|
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
|
||||||
RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
|
RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
|
||||||
|
|
||||||
|
/* Status Bar. */
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_STATUSBAR);
|
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_STATUSBAR);
|
||||||
RNA_def_property_ui_text(prop, "Show Status Bar", "Show status bar");
|
RNA_def_property_ui_text(prop, "Show Status Bar", "Show Status Bar");
|
||||||
RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
|
RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
|
||||||
|
|
||||||
|
func = RNA_def_function(srna, "statusbar_info", "rna_Screen_statusbar_info_get");
|
||||||
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT);
|
||||||
|
parm = RNA_def_string(func, "statusbar_info", NULL, 0, "Status Bar Info", "");
|
||||||
|
RNA_def_function_return(func, parm);
|
||||||
|
|
||||||
/* Define Anim Playback Areas */
|
/* Define Anim Playback Areas */
|
||||||
prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
|
RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ static const EnumPropertyItem rna_enum_userdef_viewport_aa_items[] = {
|
|||||||
# include "DEG_depsgraph.h"
|
# include "DEG_depsgraph.h"
|
||||||
|
|
||||||
# include "GPU_draw.h"
|
# include "GPU_draw.h"
|
||||||
|
# include "GPU_extensions.h"
|
||||||
# include "GPU_select.h"
|
# include "GPU_select.h"
|
||||||
|
|
||||||
# include "BLF_api.h"
|
# include "BLF_api.h"
|
||||||
@@ -1066,6 +1067,11 @@ static void rna_UserDef_studiolight_light_ambient_get(PointerRNA *ptr, float *va
|
|||||||
copy_v3_v3(values, sl->light_ambient);
|
copy_v3_v3(values, sl->light_ambient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rna_show_statusbar_vram_editable(struct PointerRNA *UNUSED(ptr), const char **UNUSED(r_info))
|
||||||
|
{
|
||||||
|
return GPU_mem_stats_supported() ? PROP_EDITABLE : 0;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define USERDEF_TAG_DIRTY_PROPERTY_UPDATE_ENABLE \
|
# define USERDEF_TAG_DIRTY_PROPERTY_UPDATE_ENABLE \
|
||||||
@@ -4771,6 +4777,29 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
|||||||
"Translate New Names",
|
"Translate New Names",
|
||||||
"Translate the names of new data-blocks (objects, materials...)");
|
"Translate the names of new data-blocks (objects, materials...)");
|
||||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||||
|
|
||||||
|
/* Statusbar. */
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "show_statusbar_memory", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_sdna(prop, NULL, "statusbar_flag", STATUSBAR_SHOW_MEMORY);
|
||||||
|
RNA_def_property_ui_text(prop, "Show Memory", "Show Blender memory usage");
|
||||||
|
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, "rna_userdef_update");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "show_statusbar_vram", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_sdna(prop, NULL, "statusbar_flag", STATUSBAR_SHOW_VRAM);
|
||||||
|
RNA_def_property_ui_text(prop, "Show VRAM", "Show GPU video memory usage");
|
||||||
|
RNA_def_property_editable_func(prop, "rna_show_statusbar_vram_editable");
|
||||||
|
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, "rna_userdef_update");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "show_statusbar_version", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_sdna(prop, NULL, "statusbar_flag", STATUSBAR_SHOW_VERSION);
|
||||||
|
RNA_def_property_ui_text(prop, "Show Version", "Show Blender version string");
|
||||||
|
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_INFO, "rna_userdef_update");
|
||||||
|
|
||||||
|
prop = RNA_def_property(srna, "show_statusbar_stats", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rna_def_userdef_edit(BlenderRNA *brna)
|
static void rna_def_userdef_edit(BlenderRNA *brna)
|
||||||
|
|||||||
Reference in New Issue
Block a user