/* draw info text on a sequence strip */ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3]) { rctf rect; char str[32 + FILE_MAX]; const char *name = seq->name + 2; char col[4]; /* note, all strings should include 'name' */ if (name[0] == '\0') name = BKE_sequence_give_name(seq); if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene) { if (seq->scene_camera) { BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d", name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len); } else { BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->scene->id.name + 2, seq->len); } } else { BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) { BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->clip->id.name + 2, seq->len); } else { BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MASK) { if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) { BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->mask->id.name + 2, seq->len); } else { BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MULTICAM) { BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source); } else if (seq->type == SEQ_TYPE_IMAGE) { BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else if (seq->type & SEQ_TYPE_EFFECT) { BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->sound) BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->sound->name, seq->len); else BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_MOVIE) { BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } if (seq->flag & SELECT) { col[0] = col[1] = col[2] = 255; } else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) { col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */ } else { col[0] = col[1] = col[2] = 0; } col[3] = 255; rect.xmin = x1; rect.ymin = y1; rect.xmax = x2; rect.ymax = y2; UI_view2d_text_cache_rectf(v2d, &rect, str, col); }
/* draw info text on a sequence strip */ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float y1, float y2, const unsigned char background_col[3]) { rctf rect; char str[32 + FILE_MAX]; size_t str_len; const char *name = seq->name + 2; char col[4]; /* note, all strings should include 'name' */ if (name[0] == '\0') name = BKE_sequence_give_name(seq); if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { if (seq->scene) { if (seq->scene_camera) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s (%s) | %d", name, seq->scene->id.name + 2, ((ID *)seq->scene_camera)->name + 2, seq->len); } else { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->scene->id.name + 2, seq->len); } } else { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { if (seq->clip && !STREQ(name, seq->clip->id.name + 2)) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->clip->id.name + 2, seq->len); } else { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MASK) { if (seq->mask && !STREQ(name, seq->mask->id.name + 2)) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->mask->id.name + 2, seq->len); } else { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MULTICAM) { str_len = BLI_snprintf(str, sizeof(str), "Cam %s: %d", name, seq->multicam_source); } else if (seq->type == SEQ_TYPE_IMAGE) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else if (seq->type == SEQ_TYPE_TEXT) { TextVars *textdata = seq->effectdata; str_len = BLI_snprintf(str, sizeof(str), "%s | %d", textdata->text, seq->startdisp); } else if (seq->type & SEQ_TYPE_EFFECT) { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SOUND_RAM) { if (seq->sound) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->sound->name, seq->len); } else { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } } else if (seq->type == SEQ_TYPE_MOVIE) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s%s | %d", name, seq->strip->dir, seq->strip->stripdata->name, seq->len); } else { /* should never get here!, but might with files from future */ BLI_assert(0); str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } if (seq->flag & SELECT) { col[0] = col[1] = col[2] = 255; } else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) { col[0] = col[1] = col[2] = 80; /* use lighter text color for dark background */ } else { col[0] = col[1] = col[2] = 0; } col[3] = 255; rect.xmin = x1; rect.ymin = y1; rect.xmax = x2; rect.ymax = y2; UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col); }