Refactor: Refactor nla_strip_get_color_inside method

Cleanup `nla_strip_get_color_inside` in `nla_draw.cc`.

Pull Request: https://projects.blender.org/blender/blender/pulls/115870
This commit is contained in:
Nate Rupsis
2023-12-07 19:23:22 +01:00
committed by Nate Rupsis
parent 3c476979b1
commit f4bc01b6b7

View File

@@ -240,65 +240,55 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
/* Strips (Proper) ---------------------- */
/* get colors for drawing NLA-Strips */
/* Get colors for drawing NLA Strips. */
static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float color[3])
{
if (strip->type == NLASTRIP_TYPE_TRANSITION) {
/* Transition Clip */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected - use a bright blue color */
UI_GetThemeColor3fv(TH_NLA_TRANSITION_SEL, color);
}
else {
/* normal, unselected strip - use (hardly noticeable) blue tinge */
UI_GetThemeColor3fv(TH_NLA_TRANSITION, color);
}
}
else if (strip->type == NLASTRIP_TYPE_META) {
/* Meta Clip */
/* TODO: should temporary meta-strips get different colors too? */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected - use a bold purple color */
UI_GetThemeColor3fv(TH_NLA_META_SEL, color);
}
else {
/* normal, unselected strip - use (hardly noticeable) dark purple tinge */
UI_GetThemeColor3fv(TH_NLA_META, color);
}
}
else if (strip->type == NLASTRIP_TYPE_SOUND) {
/* Sound Clip */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected - use a bright teal color */
UI_GetThemeColor3fv(TH_NLA_SOUND_SEL, color);
}
else {
/* normal, unselected strip - use (hardly noticeable) teal tinge */
UI_GetThemeColor3fv(TH_NLA_SOUND, color);
}
}
else {
/* Action Clip (default/normal type of strip) */
if (adt && (adt->flag & ADT_NLA_EDIT_ON) && (adt->actstrip == strip)) {
/* active strip should be drawn green when it is acting as the tweaking strip.
* however, this case should be skipped for when not in EditMode...
*/
UI_GetThemeColor3fv(TH_NLA_TWEAK, color);
}
else if (strip->flag & NLASTRIP_FLAG_TWEAKUSER) {
/* alert user that this strip is also used by the tweaking track (this is set when going into
* 'editmode' for that strip), since the edits made here may not be what the user anticipated
*/
UI_GetThemeColor3fv(TH_NLA_TWEAK_DUPLI, color);
}
else if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected strip - use theme color for selected */
UI_GetThemeColor3fv(TH_STRIP_SELECT, color);
}
else {
/* normal, unselected strip - use standard strip theme color */
const bool is_selected = strip->flag & NLASTRIP_FLAG_SELECT;
switch (strip->type) {
case NLASTRIP_TYPE_CLIP:
/* Action Strip. */
if (adt && (adt->flag & ADT_NLA_EDIT_ON) && (adt->actstrip == strip)) {
/* Active strip tweak - tweak theme is applied only to active edit strip,
* not linked-duplicates.
*/
UI_GetThemeColor3fv(TH_NLA_TWEAK, color);
break;
}
if (strip->flag & NLASTRIP_FLAG_TWEAKUSER) {
/* Non-active strip tweak - display warning theme
* for non active linked-duplicates.
*/
UI_GetThemeColor3fv(TH_NLA_TWEAK_DUPLI, color);
break;
}
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* selected. */
UI_GetThemeColor3fv(TH_STRIP_SELECT, color);
break;
}
/* unselected - use standard strip theme. */
UI_GetThemeColor3fv(TH_STRIP, color);
break;
case NLASTRIP_TYPE_META:
/* Meta Strip. */
UI_GetThemeColor3fv(is_selected ? TH_NLA_META_SEL : TH_NLA_META, color);
break;
case NLASTRIP_TYPE_TRANSITION: {
/* Transition Strip. */
UI_GetThemeColor3fv(is_selected ? TH_NLA_TRANSITION_SEL : TH_NLA_TRANSITION, color);
break;
}
case NLASTRIP_TYPE_SOUND:
/* Sound Strip. */
UI_GetThemeColor3fv(is_selected ? TH_NLA_SOUND_SEL : TH_NLA_SOUND, color);
break;
default: {
/* default to unselected theme. */
UI_GetThemeColor3fv(TH_STRIP, color);
} break;
}
}
@@ -820,7 +810,8 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region)
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax))
{
/* data to draw depends on the type of track */
switch (ale->type) {
case ANIMTYPE_NLATRACK: {
@@ -957,7 +948,8 @@ void draw_nla_track_list(const bContext *C, bAnimContext *ac, ARegion *region)
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax))
{
/* draw all tracks using standard channel-drawing API */
ANIM_channel_draw(ac, ale, ymin, ymax, track_index);
}
@@ -979,7 +971,8 @@ void draw_nla_track_list(const bContext *C, bAnimContext *ac, ARegion *region)
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) {
IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax))
{
/* draw all tracks using standard channel-drawing API */
rctf track_rect;
BLI_rctf_init(&track_rect, 0, v2d->cur.xmax, ymin, ymax);