[Bf-blender-cvs] [535e75e] master: Use mono font for metadata

Antony Riakiotakis noreply at git.blender.org
Fri May 1 14:28:00 CEST 2015


Commit: 535e75ea90f31d1d231e39dfdb14634563484679
Author: Antony Riakiotakis
Date:   Fri May 1 14:27:44 2015 +0200
Branches: master
https://developer.blender.org/rB535e75ea90f31d1d231e39dfdb14634563484679

Use mono font for metadata

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

M	source/blender/editors/screen/area.c

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

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4518aad..0bd05b8 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2088,7 +2088,7 @@ BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int off
 	return (IMB_metadata_get_field(ibuf, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) && r_str[0]);
 }
 
-static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool is_top, float factor)
+static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool is_top)
 {
 	char temp_str[MAX_METADATA_STR];
 	int line_width;
@@ -2096,6 +2096,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
 	short i;
 	int len;
 	const float height = BLF_height_max(fontid);
+	const float vertical_offset = height + (0.1f * U.widget_unit);
 
 	if (is_top) {
 		for (i = 0; i < 4; i++) {
@@ -2105,7 +2106,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
 				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 - factor * (1.5f * U.widget_unit - UI_UNIT_Y), 0.0f);
+					             rect.ymax - vertical_offset, 0.0f);
 					BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
 					do_newline = true;
 				}
@@ -2114,21 +2115,21 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
 				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 - factor * (1.5f * U.widget_unit - UI_UNIT_Y), 0.0f);
+					             rect.ymax - vertical_offset, 0.0f);
 					BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
 					do_newline = true;
 				}
 
 				if (do_newline)
-					ofs_y += (height + (0.2f * U.widget_unit));
+					ofs_y += vertical_offset;
 			}
 			else if (i == 1) {
 				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 - factor * (1.5f * U.widget_unit - UI_UNIT_Y) - ofs_y, 0.0f);
+					             rect.ymax - vertical_offset - ofs_y, 0.0f);
 					BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
-					ofs_y += (height + (0.2f * U.widget_unit));
+					ofs_y += vertical_offset;
 				}
 			}
 			else {
@@ -2136,9 +2137,9 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
 				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 - factor * (1.5f * U.widget_unit - UI_UNIT_Y) - ofs_y, 0.0f);
+					             rect.ymax - vertical_offset - ofs_y, 0.0f);
 					BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
-					ofs_y += (height + (0.2f * U.widget_unit));
+					ofs_y += vertical_offset;
 				}
 			}
 		}
@@ -2148,9 +2149,8 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rcti rect, int fontid, const bool i
 		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)) {
-				const int line_height = height;
 				BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit) + ofs_x,
-				             rect.ymin - line_height + factor * (U.widget_unit), 0.0f);
+				             rect.ymin + (0.3f * 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;
@@ -2163,7 +2163,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
 {
 	char str[MAX_METADATA_STR];
 	short i, count = 0;
-	const float height = BLF_height_max(fontid) + 0.2f * U.widget_unit;
+	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)) {
@@ -2184,7 +2184,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
 	}
 
 	if (count) {
-		return (height * count + (0.2f * U.widget_unit));
+		return (height * count + (0.1f * U.widget_unit));
 	}
 
 	return 0;
@@ -2194,11 +2194,10 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
 
 void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float zoomy)
 {
-	uiStyle *style = UI_style_get_dpi();
-	int fontid = style->widget.uifont_id;
 	float box_y;
 	rcti rect;
 	int x, y;
+	uiStyle *style = UI_style_get_dpi();
 
 	if (!ibuf->metadata)
 		return;
@@ -2212,12 +2211,12 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 	glTranslatef(x, y, 0.0f);
 	glScalef(zoomx, zoomy, 1.0f);
 
-	BLF_size(fontid, style->widgetlabel.points, U.dpi * zoomy);
+	BLF_size(blf_mono_font, style->widgetlabel.points * zoomy * 1.5f, U.dpi);
 
 	/* *** upper box*** */
 
 	/* get needed box height */
-	box_y = metadata_box_height_get(ibuf, fontid, true);
+	box_y = metadata_box_height_get(ibuf, blf_mono_font, true);
 
 	if (box_y) {
 		UI_ThemeColor(TH_METADATA_BG);
@@ -2227,19 +2226,19 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		/* draw top box */
 		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 
-		BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
-		BLF_enable(fontid, BLF_CLIPPING);
+		BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+		BLF_enable(blf_mono_font, BLF_CLIPPING);
 
 		UI_ThemeColor(TH_METADATA_TEXT);
-		metadata_draw_imbuf(ibuf, rect, fontid, true, zoomy);
+		metadata_draw_imbuf(ibuf, rect, blf_mono_font, true);
 
-		BLF_disable(fontid, BLF_CLIPPING);
+		BLF_disable(blf_mono_font, BLF_CLIPPING);
 	}
 
 
 	/* *** lower box*** */
 
-	box_y = metadata_box_height_get(ibuf, fontid, false);
+	box_y = metadata_box_height_get(ibuf, blf_mono_font, false);
 
 	if (box_y) {
 		UI_ThemeColor(TH_METADATA_BG);
@@ -2249,13 +2248,13 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		/* draw top box */
 		glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 
-		BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
-		BLF_enable(fontid, BLF_CLIPPING);
+		BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+		BLF_enable(blf_mono_font, BLF_CLIPPING);
 
 		UI_ThemeColor(TH_METADATA_TEXT);
-		metadata_draw_imbuf(ibuf, rect, fontid, false, zoomy);
+		metadata_draw_imbuf(ibuf, rect, blf_mono_font, false);
 
-		BLF_disable(fontid, BLF_CLIPPING);
+		BLF_disable(blf_mono_font, BLF_CLIPPING);
 	}
 
 	glPopMatrix();




More information about the Bf-blender-cvs mailing list