diff options
-rw-r--r-- | source/blender/editors/screen/area.c | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 9899779fc06..574ae57b159 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2083,9 +2083,9 @@ static const char *meta_data_list[] = { "File", "Strip", - "Note", "Date", "RenderTime", + "Note", "Marker", "Time", "Frame", @@ -2106,7 +2106,15 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const short i; int len; const float height = BLF_height_max(fontid); - const float vertical_offset = height + (0.1f * U.widget_unit); + const float margin = height / 8; + const float vertical_offset = (height + margin); + + /* values taking margins into account */ + const float descender = BLF_descender(fontid); + const float xmin = (rect->xmin + margin); + const float xmax = (rect->xmax - margin); + const float ymin = (rect->ymin + margin) - descender; + const float ymax = (rect->ymax - margin) - descender; if (is_top) { for (i = 0; i < 4; i++) { @@ -2115,8 +2123,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool do_newline = false; len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]); if (metadata_is_valid(ibuf, temp_str, 0, len)) { - BLF_position(fontid, rect->xmin + (0.2f * U.widget_unit), - rect->ymax - vertical_offset, 0.0f); + BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); do_newline = true; } @@ -2124,30 +2131,40 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]); if (metadata_is_valid(ibuf, temp_str, 1, len)) { 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 - vertical_offset, 0.0f); + BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); do_newline = true; } if (do_newline) ofs_y += vertical_offset; - } - else if (i == 1) { + } /* Strip */ + else if (i == 1 || i == 2) { 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->xmin + (0.2f * U.widget_unit), - rect->ymax - vertical_offset - ofs_y, 0.0f); + BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); ofs_y += vertical_offset; } + } /* Note (wrapped) */ + else if (i == 3) { + 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)) { + struct ResultBLF info; + BLF_enable(fontid, BLF_WORD_WRAP); + BLF_wordwrap(fontid, ibuf->x - (margin * 2)); + BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f); + BLF_draw_ex(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX, &info); + BLF_wordwrap(fontid, 0); + BLF_disable(fontid, BLF_WORD_WRAP); + ofs_y += vertical_offset * info.lines; + } } 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)) { 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 - vertical_offset - ofs_y, 0.0f); + BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); ofs_y += vertical_offset; } @@ -2159,8 +2176,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const for (i = 5; i < 10; i++) { len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]); if (metadata_is_valid(ibuf, temp_str, i, len)) { - BLF_position(fontid, rect->xmin + (0.2f * U.widget_unit) + ofs_x, - rect->ymin + (0.3f * U.widget_unit), 0.0f); + BLF_position(fontid, xmin + ofs_x, ymin, 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; @@ -2171,9 +2187,10 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) { + const float height = BLF_height_max(fontid); + const float margin = (height / 8); char str[MAX_METADATA_STR] = ""; short i, count = 0; - const float height = BLF_height_max(fontid) + 0.1f * U.widget_unit; if (is_top) { if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) { @@ -2181,7 +2198,23 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) } for (i = 2; i < 5; i++) { if (metadata_is_valid(ibuf, str, i, 0)) { - count++; + if (i == 4) { + struct { + struct ResultBLF info; + rctf rect; + } wrap; + + BLF_enable(fontid, BLF_WORD_WRAP); + BLF_wordwrap(fontid, ibuf->x - (margin * 2)); + BLF_boundbox_ex(fontid, str, sizeof(str), &wrap.rect, &wrap.info); + BLF_wordwrap(fontid, 0); + BLF_disable(fontid, BLF_WORD_WRAP); + + count += wrap.info.lines; + } + else { + count++; + } } } } @@ -2194,7 +2227,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) } if (count) { - return (height * count + (0.1f * U.widget_unit)); + return (height + margin) * count; } return 0; @@ -2218,7 +2251,7 @@ void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); - BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f, U.dpi); + BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi); /* *** upper box*** */ |