diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-04-21 18:15:40 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-04-21 19:37:06 +0300 |
commit | 3091ea49fec8b85b602aa94f229992f78c335b7a (patch) | |
tree | 882cdfbc6b43fee4490f06639d1f9486ad24f4c6 /source/blender/editors/screen | |
parent | 50bfc4bfa0eabb68fcb5b5e82f80281fbaddcfeb (diff) |
Metadata:
* Theme support for metadata display
* Increase text DPI with scaling.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 1c87d959dc4..fff55842f71 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); } |