Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r--source/blender/editors/screen/area.c197
1 files changed, 197 insertions, 0 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index d786c0cfc36..1c87d959dc4 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -61,6 +61,9 @@
#include "BIF_glutil.h"
#include "BLF_api.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
#include "UI_interface.h"
#include "UI_interface_icons.h"
#include "UI_resources.h"
@@ -2027,6 +2030,200 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float fill_co
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
}
+#define MAX_METADATA_STR 1024
+
+const char *meta_data_list[] =
+{
+ "File",
+ "Strip",
+ "Note",
+ "Date",
+ "RenderTime",
+ "Marker",
+ "Time",
+ "Frame",
+ "Camera",
+ "Scene"
+};
+
+BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index)
+{
+ return (IMB_metadata_get_field(ibuf, meta_data_list[index], r_str, MAX_METADATA_STR) && r_str[0]);
+}
+
+static void metadata_draw_lines(ImBuf *ibuf, rcti rect, int fontid, const bool is_top)
+{
+ char temp_str[MAX_METADATA_STR];
+ int line_width, line_height;
+ int ofs_y = 0;
+ short line_index;
+ short i;
+
+ 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));
+ }
+
+ 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)) {
+ 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 (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));
+ }
+ }
+ 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));
+ }
+ }
+ }
+
+ if (is_top == false) {
+ int ofs_x = 0;
+ for (i = 5; i < 10; i++) {
+ if (metadata_is_valid(ibuf, temp_str, i)) {
+ 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);
+ BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX);
+
+ ofs_x += BLF_width(fontid, temp_str, strlen(temp_str)) + UI_UNIT_X;
+ }
+ }
+ }
+}
+
+static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
+{
+ char str[MAX_METADATA_STR];
+ float height = 0;
+ short i;
+
+ if (is_top) {
+ for (i = 0; i < 5 ; i++) {
+ if (metadata_is_valid(ibuf, str, i)) {
+ height += BLF_height(fontid, str, strlen(str));
+ }
+ }
+ }
+ else {
+ for (i = 5; i < 10; i++) {
+ if (metadata_is_valid(ibuf, str, i)) {
+ height += BLF_height(fontid, str, strlen(str));
+ }
+ }
+ }
+
+ if (height) {
+ return (height + (0.2f * U.widget_unit));
+ }
+
+ return 0;
+}
+
+#undef MAX_METADATA_STR
+
+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;
+
+ if (!ibuf->metadata)
+ return;
+
+ /* find window pixel coordinates of origin */
+ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y);
+
+ glPushMatrix();
+
+ /* offset and zoom using ogl */
+ glTranslatef(x, y, 0.0f);
+ glScalef(zoomx, zoomy, 1.0f);
+
+ /* *** 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 */
+
+ /* set up rect */
+ BLI_rcti_init(&rect, 0, ibuf->x, ibuf->y, ibuf->y + box_y);
+ /* 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);
+
+ glColor3f(1.0f, 1.0f, 1.0f);
+
+ metadata_draw_lines(ibuf, rect, fontid, true);
+
+ BLF_disable(fontid, BLF_CLIPPING);
+ }
+
+
+ /* *** lower box*** */
+
+ 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 */
+
+ /* set up box rect */
+ BLI_rcti_init(&rect, 0, ibuf->x, -box_y, 0);
+ /* 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);
+
+ glColor3f(1.0f, 1.0f, 1.0f);
+
+ metadata_draw_lines(ibuf, rect, fontid, false);
+
+ BLF_disable(fontid, BLF_CLIPPING);
+ }
+
+ glPopMatrix();
+}
+
void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
{
float gridsize, gridstep = 1.0f / 32.0f;