GPv3: Show stats in edit mode

GPv3 uses `OB_MODE_EDIT` so it falsely shows empty mesh data in stats.
This worked in legacy gp because it had special edit_mode type.
To show correct grease pencil data in edit mode, rearrange if conditions and
add special check for `OB_GREASE_PENCIL`

Pull Request: https://projects.blender.org/blender/blender/pulls/119689
This commit is contained in:
Pratik Borhade 2024-03-21 01:15:18 +01:00 committed by Harley Acheson
parent 6a937d646b
commit 2df06a05ae
1 changed files with 21 additions and 21 deletions

View File

@ -398,7 +398,7 @@ static void stats_update(Depsgraph *depsgraph,
memset(stats, 0x0, sizeof(*stats));
if (obedit) {
if (obedit && (ob->type != OB_GREASE_PENCIL)) {
/* Edit Mode. */
FOREACH_OBJECT_BEGIN (scene, view_layer, ob_iter) {
if (ob_iter->base_flag & BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT) {
@ -823,7 +823,26 @@ void ED_info_draw_stats(
stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height);
}
if (obedit) {
if (!any_selected) {
if (any_objects) {
/* Show scene totals if nothing is selected. */
stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, nullptr, y, height);
stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, nullptr, y, height);
stats_row(col1, labels[FACES], col2, stats_fmt.totface, nullptr, y, height);
stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, nullptr, y, height);
}
else {
/* No objects in scene. */
stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height);
}
}
else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) {
stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height);
stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height);
stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height);
stats_row(col1, labels[POINTS], col2, stats_fmt.totgppoint, nullptr, y, height);
}
else if (obedit) {
if (obedit->type == OB_MESH) {
stats_row(col1, labels[VERTS], col2, stats_fmt.totvertsel, stats_fmt.totvert, y, height);
stats_row(col1, labels[EDGES], col2, stats_fmt.totedgesel, stats_fmt.totedge, y, height);
@ -848,28 +867,9 @@ void ED_info_draw_stats(
stats_row(col1, labels[FACES], col2, stats_fmt.totfacesculpt, nullptr, y, height);
}
}
else if (!any_selected) {
if (any_objects) {
/* Show scene totals if nothing is selected. */
stats_row(col1, labels[VERTS], col2, stats_fmt.totvert, nullptr, y, height);
stats_row(col1, labels[EDGES], col2, stats_fmt.totedge, nullptr, y, height);
stats_row(col1, labels[FACES], col2, stats_fmt.totface, nullptr, y, height);
stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, nullptr, y, height);
}
else {
/* No objects in scene. */
stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height);
}
}
else if (ob && (object_mode & OB_MODE_POSE)) {
stats_row(col1, labels[BONES], col2, stats_fmt.totbonesel, stats_fmt.totbone, y, height);
}
else if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) {
stats_row(col1, labels[LAYERS], col2, stats_fmt.totgplayer, nullptr, y, height);
stats_row(col1, labels[FRAMES], col2, stats_fmt.totgpframe, nullptr, y, height);
stats_row(col1, labels[STROKES], col2, stats_fmt.totgpstroke, nullptr, y, height);
stats_row(col1, labels[POINTS], col2, stats_fmt.totgppoint, nullptr, y, height);
}
else if ((ob) && (ob->type == OB_LAMP)) {
stats_row(col1, labels[LIGHTS], col2, stats_fmt.totlampsel, stats_fmt.totlamp, y, height);
}