diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-21 21:43:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-21 21:43:13 +0300 |
commit | b47892e9f5e279bb8d9ee2e0ea6f31cff099103a (patch) | |
tree | b1a937e8f303ab98e03036dbaa7b7da456f3d1d2 | |
parent | e1ce83f7629750a5900e0c0e83c6aa2860160aec (diff) |
Minor edits to metadata commit
No need to calculate height of each line, just use height of font.
-rw-r--r-- | source/blender/editors/interface/resources.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 17 |
2 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 76985331568..8e003e50df3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -570,10 +570,10 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo break; case TH_METADATA_BG: - cp =ts->metadatabg; + cp = ts->metadatabg; break; case TH_METADATA_TEXT: - cp =ts->metadatatext; + cp = ts->metadatatext; break; case TH_UV_OTHERS: diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 63eaf7d0296..4b0d1d02198 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2054,17 +2054,17 @@ BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int off static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool is_top, float factor) { char temp_str[MAX_METADATA_STR]; - int line_width, line_height; + int line_width; int ofs_y = 0; short i; int len; + const float height = BLF_height_max(fontid); if (is_top) { for (i = 0; i < 4; i++) { /* first line */ if (i == 0) { bool do_newline = false; - float height = 0.0; BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]); len = strlen(temp_str); if (metadata_is_valid(ibuf, temp_str, 0, len)) { @@ -2072,19 +2072,16 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i rect.ymax - factor * (1.5f * U.widget_unit - UI_UNIT_Y), 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); do_newline = true; - height = BLF_height(fontid, temp_str, strlen(temp_str)); } BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]); len = strlen(temp_str); if (metadata_is_valid(ibuf, temp_str, 1, len)) { - len = strlen(temp_str); - line_width = BLF_width(fontid, temp_str, 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 - factor * (1.5f * U.widget_unit - UI_UNIT_Y), 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); do_newline = true; - height = max_ff(BLF_height(fontid, temp_str, len), height); } if (do_newline) @@ -2097,7 +2094,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i BLF_position(fontid, rect.xmin + (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 += (BLF_height(fontid, temp_str, strlen(temp_str)) + (0.2f * U.widget_unit)); + ofs_y += (height + (0.2f * U.widget_unit)); } } else { @@ -2107,7 +2104,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i BLF_position(fontid, rect.xmax + (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 += (BLF_height(fontid, temp_str, strlen(temp_str)) + (0.2f * U.widget_unit)); + ofs_y += (height + (0.2f * U.widget_unit)); } } } @@ -2118,12 +2115,12 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]); len = strlen(temp_str); if (metadata_is_valid(ibuf, temp_str, i, len)) { - line_height = BLF_height(fontid, temp_str, strlen(temp_str)); + 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); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); - ofs_x += BLF_width(fontid, temp_str, strlen(temp_str)) + UI_UNIT_X; + ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X; } } } |