[Bf-blender-cvs] [b5b9b2d04db] blender2.8: Draw Manager: Combine multiple engines info texts

Dalai Felinto noreply at git.blender.org
Thu May 4 19:38:30 CEST 2017


Commit: b5b9b2d04db4b3cf08d219d00e5f7d1d82725ad1
Author: Dalai Felinto
Date:   Thu May 4 19:35:53 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBb5b9b2d04db4b3cf08d219d00e5f7d1d82725ad1

Draw Manager: Combine multiple engines info texts

This join them with \n separators.(right now they clash on top of each
other).

Note: We still need to change "ED_region_info_draw" to accept multi-line strings.

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

M	source/blender/draw/intern/draw_manager.c

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

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 2610f97e662..2a9e7770b2f 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2061,16 +2061,23 @@ static void DRW_engines_draw_text(void)
  */
 int DRW_draw_region_engine_info_offset()
 {
-	int offset = 0;
+	int lines = 0;
 	for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
 		DrawEngineType *engine = link->data;
 		ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
 
+		/* Count the number of lines. */
 		if (data->info[0] != '\0') {
-			offset += UI_UNIT_Y;
+			lines++;
+			char *c = data->info;
+			while (*c++ != '\0') {
+				if (*c == '\n') {
+					lines++;
+				}
+			}
 		}
 	}
-	return offset;
+	return lines * UI_UNIT_Y;
 }
 
 /**
@@ -2078,6 +2085,9 @@ int DRW_draw_region_engine_info_offset()
  */
 void DRW_draw_region_engine_info()
 {
+	char info[GPU_INFO_SIZE * 5] = {0}; /* This should be maxium number of engines running at the same time. */
+	char *str_start = info;
+
 	const DRWContextState *draw_ctx = DRW_context_state_get();
 	ARegion *ar = draw_ctx->ar;
 	float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f};
@@ -2090,8 +2100,17 @@ void DRW_draw_region_engine_info()
 		ViewportEngineData *data = DRW_viewport_engine_data_get(engine);
 
 		if (data->info[0] != '\0') {
-			ED_region_info_draw(ar, data->info, fill_color, true);
+			BLI_strncpy(str_start, data->info, sizeof(info) - (str_start - info));
+			str_start += BLI_strnlen(data->info, sizeof(data->info));
+			*str_start++ = '\n';
+		}
+	}
+
+	if (info[0] != '\0') {
+		if (str_start != info) {
+			*(str_start - 1) = '\0';
 		}
+		ED_region_info_draw(ar, info, fill_color, true);
 	}
 }




More information about the Bf-blender-cvs mailing list