Fix and simplify vertical positioning and calculation of metadata
display more.
This commit is contained in:
@@ -42,8 +42,6 @@ void ED_editors_exit(struct bContext *C);
|
||||
|
||||
bool ED_editors_flush_edits(const struct bContext *C, bool for_render);
|
||||
|
||||
void ED_draw_ibuf_meta_data(const bContext *C, struct ImBuf *ibuf);
|
||||
|
||||
/* ************** Undo ************************ */
|
||||
|
||||
/* undo.c */
|
||||
|
||||
@@ -2097,7 +2097,8 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
|
||||
else {
|
||||
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
|
||||
if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
|
||||
BLF_position(fontid, rect.xmax + (0.2f * U.widget_unit),
|
||||
line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
BLF_position(fontid, rect.xmax - line_width - (0.2f * U.widget_unit),
|
||||
rect.ymax - factor * (1.5f * U.widget_unit - UI_UNIT_Y) - ofs_y, 0.0f);
|
||||
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
ofs_y += (height + (0.2f * U.widget_unit));
|
||||
@@ -2112,7 +2113,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
|
||||
if (metadata_is_valid(ibuf, temp_str, i, len)) {
|
||||
const int line_height = height;
|
||||
BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit) + ofs_x,
|
||||
rect.ymin - line_height + factor * (1.5f * U.widget_unit), 0.0f);
|
||||
rect.ymin - line_height + factor * (U.widget_unit), 0.0f);
|
||||
BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
|
||||
|
||||
ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X;
|
||||
@@ -2124,26 +2125,29 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
|
||||
static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
|
||||
{
|
||||
char str[MAX_METADATA_STR];
|
||||
float height = 0;
|
||||
short i;
|
||||
short i, count = 0;
|
||||
const float height = BLF_height_max(fontid) + 0.2f * U.widget_unit;
|
||||
|
||||
if (is_top) {
|
||||
for (i = 0; i < 5 ; i++) {
|
||||
if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
|
||||
count++;
|
||||
}
|
||||
for (i = 2; i < 5; i++) {
|
||||
if (metadata_is_valid(ibuf, str, i, 0)) {
|
||||
height += BLF_height(fontid, str, strlen(str));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 5; i < 10; i++) {
|
||||
if (metadata_is_valid(ibuf, str, i, 0)) {
|
||||
height += BLF_height(fontid, str, strlen(str));
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (height) {
|
||||
return (height + (0.2f * U.widget_unit));
|
||||
if (count) {
|
||||
return (height * count + (0.2f * U.widget_unit));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user