/* add the relevant text to the cache of text-strings to draw in pixelspace */ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float xminc, float xmaxc, float yminc, float ymaxc) { const bool non_solo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); char str[256]; size_t str_len; char col[4]; /* just print the name and the range */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { str_len = BLI_snprintf_rlen(str, sizeof(str), "%d) Temp-Meta", index); } else { str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str)); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) { col[0] = col[1] = col[2] = 0; } else { col[0] = col[1] = col[2] = 255; } /* text opacity depends on whether if there's a solo'd track, this isn't it */ if (non_solo == 0) { col[3] = 255; } else { col[3] = 128; } /* set bounding-box for text * - padding of 2 'units' on either side */ /* TODO: make this centered? */ rctf rect = { .xmin = xminc, .ymin = yminc, .xmax = xmaxc, .ymax = ymaxc, }; /* add this string to the cache of texts to draw */ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col); }
/* add the relevant text to the cache of text-strings to draw in pixelspace */ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) { short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); char str[256]; size_t str_len; char col[4]; float xofs; rctf rect; /* just print the name and the range */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { str_len = BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index); } else { str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str)); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) { col[0] = col[1] = col[2] = 0; } else { col[0] = col[1] = col[2] = 255; } /* text opacity depends on whether if there's a solo'd track, this isn't it */ if (notSolo == 0) col[3] = 255; else col[3] = 128; /* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */ if ((strip->end - strip->start) <= 5.0f) xofs = 0.5f; else xofs = 1.0f; /* set bounding-box for text * - padding of 2 'units' on either side */ // TODO: make this centered? rect.xmin = strip->start + xofs; rect.ymin = yminc; rect.xmax = strip->end - xofs; rect.ymax = ymaxc; /* add this string to the cache of texts to draw */ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, 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); }