Fix T72128: Overlay: Edge indices stacking on top of edge measurements

Make indices accommodate into the measures of edgelength and edgeangle
so this results in a nice stack of up to three rows.

Maniphest Tasks: T72128

Differential Revision: https://developer.blender.org/D6357
This commit is contained in:
Philipp Oeser 2019-12-04 11:05:02 +01:00
parent 701338d31c
commit e0afee86b3
Notes: blender-bot 2023-02-14 06:46:23 +01:00
Referenced by issue #72128, Edge Length etc overlays stacks on top of each other making them hard to read
1 changed files with 26 additions and 7 deletions

View File

@ -213,14 +213,23 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
float grid = unit->system ? unit->scale_length : v3d->grid;
const bool do_global = (v3d->flag & V3D_GLOBAL_STATS) != 0;
const bool do_moving = (G.moving & G_TRANSFORM_EDIT) != 0;
/* when 2 edge-info options are enabled, space apart */
const bool do_edge_textpair = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) &&
(v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG);
const short edge_texpair_sep = (short)(5.0f * U.dpi_fac);
float clip_planes[4][4];
/* allow for displaying shape keys and deform mods */
BMIter iter;
/* when 2 or more edge-info options are enabled, space apart */
short edge_tex_count = 0;
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN) {
edge_tex_count += 1;
}
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_ANG) {
edge_tex_count += 1;
}
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) && (em->selectmode & SCE_SELECT_EDGE)) {
edge_tex_count += 1;
}
const short edge_tex_sep = (short)((edge_tex_count - 1) * 5.0f * U.dpi_fac);
/* make the precision of the display value proportionate to the gridsize */
if (grid <= 0.01f) {
@ -290,7 +299,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
numstr,
numstr_len,
0,
(do_edge_textpair) ? edge_texpair_sep : 0,
edge_tex_sep,
txt_flag,
col);
}
@ -352,7 +361,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
numstr,
numstr_len,
0,
(do_edge_textpair) ? -edge_texpair_sep : 0,
-edge_tex_sep,
txt_flag,
col);
}
@ -494,6 +503,9 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
if (em->selectmode & SCE_SELECT_EDGE) {
BMEdge *e;
const bool use_edge_tex_sep = (edge_tex_count == 2);
const bool use_edge_tex_len = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGE_LEN);
BM_ITER_MESH_INDEX (e, &iter, em->bm, BM_EDGES_OF_MESH, i) {
if (BM_elem_flag_test(e, BM_ELEM_SELECT)) {
float v1_clip[3], v2_clip[3];
@ -506,7 +518,14 @@ void DRW_text_edit_mesh_measure_stats(ARegion *ar,
mul_m4_v3(ob->obmat, vmid);
numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i);
DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col);
DRW_text_cache_add(dt,
vmid,
numstr,
numstr_len,
0,
(use_edge_tex_sep) ? (use_edge_tex_len) ? -edge_tex_sep : edge_tex_sep : 0,
txt_flag,
col);
}
}
}