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 | |
parent | 50bfc4bfa0eabb68fcb5b5e82f80281fbaddcfeb (diff) |
Metadata:
* Theme support for metadata display
* Increase text DPI with scaling.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 7 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 126 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 12 |
5 files changed, 91 insertions, 62 deletions
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 3923c5c4432..2b19b6180e5 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 15e742c930a..b90c1c10093 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 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); } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index afa1f03a8ca..e0b51a1b25b 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 b5ce031dd80..58f355bdf52 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, "metadatabg"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Metadata Background", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "metadatatext", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "metadatatext"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Metadata Text", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + rna_def_userdef_theme_spaces_curves(srna, false, false, false, true); rna_def_userdef_theme_spaces_paint_curves(srna); |