[Bf-blender-cvs] [1044dfd] master: Fix and simplify vertical positioning and calculation of metadata display more.

Antony Riakiotakis noreply at git.blender.org
Wed Apr 22 13:20:12 CEST 2015


Commit: 1044dfd965a8a0b85095ce51b34eb3876701d967
Author: Antony Riakiotakis
Date:   Wed Apr 22 13:19:58 2015 +0200
Branches: master
https://developer.blender.org/rB1044dfd965a8a0b85095ce51b34eb3876701d967

Fix and simplify vertical positioning and calculation of metadata
display more.

===================================================================

M	source/blender/editors/include/ED_util.h
M	source/blender/editors/screen/area.c

===================================================================

diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 96d7828..9556c60 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -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 */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index c6de4e5..8844f34 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.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;




More information about the Bf-blender-cvs mailing list