[Bf-blender-cvs] [3091ea4] master: Metadata:

Antony Riakiotakis noreply at git.blender.org
Tue Apr 21 18:37:37 CEST 2015


Commit: 3091ea49fec8b85b602aa94f229992f78c335b7a
Author: Antony Riakiotakis
Date:   Tue Apr 21 17:15:40 2015 +0200
Branches: master
https://developer.blender.org/rB3091ea49fec8b85b602aa94f229992f78c335b7a

Metadata:

* Theme support for metadata display
* Increase text DPI with scaling.

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

M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/screen/area.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 3923c5c..2b19b61 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -294,7 +294,10 @@ enum {
 	TH_INFO_DEBUG_TEXT,
 	TH_VIEW_OVERLAY,
 	
-	TH_V3D_CLIPPING_BORDER
+	TH_V3D_CLIPPING_BORDER,
+
+	TH_METADATA_BG,
+	TH_METADATA_TEXT
 };
 /* XXX WARNING: previous is saved in file, so do not change order! */
 
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 15e742c..b90c1c1 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -569,6 +569,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
 					cp = ts->paint_curve_pivot;
 					break;
 
+				case TH_METADATA_BG:
+					cp =ts->metadatabg;
+					break;
+				case TH_METADATA_TEXT:
+					cp =ts->metadatatext;
+					break;
+
 				case TH_UV_OTHERS:
 					cp = ts->uv_others;
 					break;
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 1c87d95..fff5584 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2046,75 +2046,81 @@ const char *meta_data_list[] =
 	"Scene"
 };
 
-BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index)
+BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int offset)
 {
-	return (IMB_metadata_get_field(ibuf, meta_data_list[index], r_str, MAX_METADATA_STR) && r_str[0]);
+	return (IMB_metadata_get_field(ibuf, meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) && r_str[0]);
 }
 
-static void metadata_draw_lines(ImBuf *ibuf, rcti rect, int fontid, const bool is_top)
+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 ofs_y = 0;
-	short line_index;
 	short i;
+	int len;
 
-	for (line_index = 0; line_index < 4 && is_top == true; line_index++) {
-		/* first line */
-		if (line_index == 0) {
-			int len;
-			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 + len, 0)) {
-				BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit),
-				             rect.ymax - (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));
-			}
+	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)) {
+					BLF_position(fontid, rect.xmin + (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 = BLF_height(fontid, temp_str, strlen(temp_str));
+				}
 
-			BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]);
-			len = strlen(temp_str);
-			if (metadata_is_valid(ibuf, temp_str + len, 1)) {
+				BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]);
 				len = strlen(temp_str);
-				line_width = BLF_width(fontid, temp_str, len);
-				BLF_position(fontid, rect.xmax - line_width - (0.2f * U.widget_unit),
-				             rect.ymax - (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 (metadata_is_valid(ibuf, temp_str, 1, len)) {
+					len = strlen(temp_str);
+					line_width = BLF_width(fontid, temp_str, len);
+					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)
-				ofs_y += (height + (0.2f * U.widget_unit));
-		}
-		else if (line_index == 1) {
-			if (metadata_is_valid(ibuf, temp_str, line_index + 1)) {
-				BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit),
-				             rect.ymax - (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));
+				if (do_newline)
+					ofs_y += (height + (0.2f * U.widget_unit));
 			}
-		}
-		else {
-			if (metadata_is_valid(ibuf, temp_str, line_index + 1)) {
-				BLF_position(fontid, rect.xmax + (0.2f * U.widget_unit),
-				             rect.ymax - (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));
+			else if (i == 1) {
+				BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+				len = strlen(temp_str);
+				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);
+					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));
+				}
+			}
+			else {
+				BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
+				len = strlen(temp_str);
+				if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
+					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));
+				}
 			}
 		}
 	}
-
-	if (is_top == false) {
+	else {
 		int ofs_x = 0;
 		for (i = 5; i < 10; i++) {
-			if (metadata_is_valid(ibuf, temp_str, 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));
 				BLF_position(fontid, rect.xmin + (0.2f * U.widget_unit) + ofs_x,
-				             rect.ymin - line_height + (1.5f * U.widget_unit), 0.0f);
+				             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;
@@ -2131,14 +2137,14 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
 
 	if (is_top) {
 		for (i = 0; i < 5 ; i++) {
-			if (metadata_is_valid(ibuf, str, i)) {
+			if (metadata_is_valid(ibuf, str, i, 0)) {
 				height += BLF_height(fontid, str, strlen(str));
 			}
 		}
 	}
 	else {
 		for (i = 5; i < 10; i++) {
-			if (metadata_is_valid(ibuf, str, i)) {
+			if (metadata_is_valid(ibuf, str, i, 0)) {
 				height += BLF_height(fontid, str, strlen(str));
 			}
 		}
@@ -2173,14 +2179,15 @@ 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);
+
 	/* *** upper box*** */
 
 	/* get needed box height */
 	box_y = metadata_box_height_get(ibuf, fontid, true);
 
 	if (box_y) {
-		glColor3f(0.1f, 0.1f, 0.1f);
-		//glColor3f(1.0f, 0.15f, 0.8f); /* Pinkyfied version for Pablo */
+		UI_ThemeColor(TH_METADATA_BG);
 
 		/* set up rect */
 		BLI_rcti_init(&rect, 0, ibuf->x, ibuf->y, ibuf->y + box_y);
@@ -2190,9 +2197,8 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 		BLF_enable(fontid, BLF_CLIPPING);
 
-		glColor3f(1.0f, 1.0f, 1.0f);
-
-		metadata_draw_lines(ibuf, rect, fontid, true);
+		UI_ThemeColor(TH_TEXT_HI);
+		metadata_draw_imbuf(ibuf, rect, fontid, true, zoomy);
 
 		BLF_disable(fontid, BLF_CLIPPING);
 	}
@@ -2203,8 +2209,7 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 	box_y = metadata_box_height_get(ibuf, fontid, false);
 
 	if (box_y) {
-		glColor3f(0.1f, 0.1f, 0.1f);
-		//glColor3f(1.0f, 0.15f, 0.8f); /* Pinkyfied version for Pablo */
+		UI_ThemeColor(TH_METADATA_BG);
 
 		/* set up box rect */
 		BLI_rcti_init(&rect, 0, ibuf->x, -box_y, 0);
@@ -2214,9 +2219,8 @@ void ED_region_image_metadata_draw(ARegion *ar, ImBuf *ibuf, float zoomx, float
 		BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
 		BLF_enable(fontid, BLF_CLIPPING);
 
-		glColor3f(1.0f, 1.0f, 1.0f);
-
-		metadata_draw_lines(ibuf, rect, fontid, false);
+		UI_ThemeColor(TH_TEXT_HI);
+		metadata_draw_imbuf(ibuf, rect, fontid, false, zoomy);
 
 		BLF_disable(fontid, BLF_CLIPPING);
 	}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index afa1f03..e0b51a1 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -338,6 +338,9 @@ typedef struct ThemeSpace {
 
 	char paint_curve_pivot[4];
 	char paint_curve_handle[4];
+
+	char metadatabg[4];
+	char metadatatext[4];
 } ThemeSpace;
 
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index b5ce031..58f355b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2386,6 +2386,18 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Current Frame", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 
+	prop = RNA_def_property(srna, "metadatabg", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_float_sdna(prop, NULL, "me

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list