Dope Sheet: remove many hard-coded color and alpha constants.
authorAlexander Gavrilov <angavrilov@gmail.com>
Thu, 18 Oct 2018 20:48:06 +0000 (23:48 +0300)
committerAlexander Gavrilov <angavrilov@gmail.com>
Fri, 19 Oct 2018 15:30:24 +0000 (18:30 +0300)
Add the necessary colors and/or alpha components to the theme instead.
Also switch the background for ordinary channels to use the likely
intended theme option, instead of the window background color.

The general rule is that the channel color is drawn full strength in the
channel list on the left, and with alpha in the actual key frame area on
the right. This alpha is also reused with bone group colors.

Reviewers: brecht, billreynish

Differential Revision: https://developer.blender.org/D3813

release/datafiles/userdef/userdef_default_theme.c
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenloader/intern/versioning_userdef.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/include/UI_resources.h
source/blender/editors/interface/resources.c
source/blender/editors/space_action/action_draw.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 0a5ac909c319c0e02e0d70fd43d06d21d5db9511..daf4b1eb1bc8a32ea808cb2a53502974bad2659f 100644 (file)
@@ -502,24 +502,26 @@ const bTheme U_theme_default = {
                        .sub_back = RGBA(0x0000003e),
                },
                .shade1 = RGBA(0xc0c0c000),
-               .shade2 = RGBA(0x70707064),
-               .hilite = RGBA(0x60c040ff),
+               .shade2 = RGBA(0x7e7e7e10),
+               .hilite = RGBA(0x60c04044),
                .grid = RGBA(0x2a2a2aff),
-               .group = RGBA(0x44992eff),
-               .group_active = RGBA(0x5ccd3eff),
+               .group = RGBA(0x3b8c2837),
+               .group_active = RGBA(0x439e2d55),
                .strip = RGBA(0x1a151580),
-               .strip_select = RGBA(0xff8c00ff),
+               .strip_select = RGBA(0xff8c00cc),
                .cframe = RGBA(0x5680c2ff),
-               .ds_channel = RGBA(0x5a85b2ff),
-               .ds_subchannel = RGBA(0x7d98b3ff),
+               .ds_channel = RGBA(0x547ca624),
+               .ds_subchannel = RGBA(0x748da624),
                .keytype_keyframe = RGBA(0xe8e8e8ff),
                .keytype_extreme = RGBA(0xe8b3ccff),
                .keytype_breakdown = RGBA(0xb3dbe8ff),
                .keytype_jitter = RGBA(0x94e575ff),
+               .keytype_movehold = RGBA(0x5c5656ff),
                .keytype_keyframe_select = RGBA(0xffbe33ff),
                .keytype_extreme_select = RGBA(0xf28080ff),
                .keytype_breakdown_select = RGBA(0x54bfedff),
                .keytype_jitter_select = RGBA(0x61c042ff),
+               .keytype_movehold_select = RGBA(0xffaf23ff),
                .keyborder = RGBA(0x000000ff),
                .keyborder_select = RGBA(0x000000ff),
                .vertex_size = 3,
index d4b5b4c7d47fc8f38ffdb6cfc70ba81fea994b5f..b5e20671cac16b02d1009bafb3d0fe106d2374f2 100644 (file)
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      26
+#define BLENDER_SUBVERSION      27
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
index b04acf6016c3d03f6133fe2edf3e470c7e8da40b..2f98d068e7d1c39f2fcc72a99ccce630862b8de0 100644 (file)
@@ -65,6 +65,18 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
                copy_v4_v4_char(btheme->tui.icon_modifier, U_theme_default.tui.icon_modifier);
                copy_v4_v4_char(btheme->tui.icon_shading, U_theme_default.tui.icon_shading);
        }
+
+       if (!USER_VERSION_ATLEAST(280, 27)) {
+               copy_v4_v4_char(btheme->tact.shade2, U_theme_default.tact.shade2);
+               copy_v4_v4_char(btheme->tact.hilite, U_theme_default.tact.hilite);
+               copy_v4_v4_char(btheme->tact.group, U_theme_default.tact.group);
+               copy_v4_v4_char(btheme->tact.group_active, U_theme_default.tact.group_active);
+               copy_v4_v4_char(btheme->tact.strip_select, U_theme_default.tact.strip_select);
+               copy_v4_v4_char(btheme->tact.ds_channel, U_theme_default.tact.ds_channel);
+               copy_v4_v4_char(btheme->tact.ds_subchannel, U_theme_default.tact.ds_subchannel);
+               copy_v4_v4_char(btheme->tact.keytype_movehold, U_theme_default.tact.keytype_movehold);
+               copy_v4_v4_char(btheme->tact.keytype_movehold_select, U_theme_default.tact.keytype_movehold_select);
+       }
 #undef USER_VERSION_ATLEAST
 
 }
index 1495ca50870aad9d37a257cb6f754542420fe2d2..b80667a011ae705209380d7280a240b88cecf5ac 100644 (file)
@@ -223,8 +223,8 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa
        }
        else {
                // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)?
-               int colOfs = 20 - 20 * indent;
-               UI_GetThemeColorShade3fv(TH_DOPESHEET_CHANNELSUBOB, colOfs, r_color);
+               int colOfs = 10 - 10 * indent;
+               UI_GetThemeColorShade3fv(TH_SHADE2, colOfs, r_color);
        }
 }
 
@@ -817,9 +817,9 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
        else {
                /* highlight only for active */
                if (ale->flag & AGRP_ACTIVE)
-                       UI_GetThemeColorShade3fv(TH_GROUP_ACTIVE, 10, r_color);
+                       UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
                else
-                       UI_GetThemeColorShade3fv(TH_GROUP, 20, r_color);
+                       UI_GetThemeColor3fv(TH_GROUP, r_color);
        }
 }
 
index 046bf2a310682120b818dd5d823314c908fce00e..33e2a11f4c5a69844eb5f86885af4bb92a7cae1f 100644 (file)
@@ -471,10 +471,7 @@ void draw_keyframe_shape(float x, float y, float size, bool sel, short key_type,
                                UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_JITTER_SELECT : TH_KEYTYPE_JITTER, fill_col);
                                break;
                        case BEZT_KEYTYPE_MOVEHOLD: /* similar to traditional keyframes, but different... */
-                               /* XXX: Should these get their own theme options instead? */
-                               if (sel) UI_GetThemeColorShade3ubv(TH_STRIP_SELECT, 35, fill_col);
-                               else UI_GetThemeColorShade3ubv(TH_STRIP, 50, fill_col);
-                               fill_col[3] = 255; /* full opacity, to avoid problems with visual glitches */
+                               UI_GetThemeColor4ubv(sel ? TH_KEYTYPE_MOVEHOLD_SELECT : TH_KEYTYPE_MOVEHOLD, fill_col);
                                break;
                        case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames (default theme) */
                        default:
index 1a8b7bb12af96c2057f5d356641a4514b10f0bec..fd6fa3add30bb90a310fdd9c4c0ea2869a286bff 100644 (file)
@@ -156,6 +156,8 @@ typedef enum ThemeColorID {
        TH_KEYTYPE_BREAKDOWN_SELECT,
        TH_KEYTYPE_JITTER,
        TH_KEYTYPE_JITTER_SELECT,
+       TH_KEYTYPE_MOVEHOLD,
+       TH_KEYTYPE_MOVEHOLD_SELECT,
 
        TH_KEYBORDER,
        TH_KEYBORDER_SELECT,
index 33a8a2ec5fa0a184c79f039a311972331874c05f..220d7064a5de15b654b61d05e640f268b955ccd3 100644 (file)
@@ -381,6 +381,10 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
                                        cp = ts->keytype_jitter; break;
                                case TH_KEYTYPE_JITTER_SELECT:
                                        cp = ts->keytype_jitter_select; break;
+                               case TH_KEYTYPE_MOVEHOLD:
+                                       cp = ts->keytype_movehold; break;
+                               case TH_KEYTYPE_MOVEHOLD_SELECT:
+                                       cp = ts->keytype_movehold_select; break;
                                case TH_KEYBORDER:
                                        cp = ts->keyborder; break;
                                case TH_KEYBORDER_SELECT:
index e679688f88777d83578816b341e113db8f8b7838..9da128469cda9111860d7d6af9495a38b9de3b15 100644 (file)
@@ -171,22 +171,22 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
 
        float act_start, act_end, y;
 
-       unsigned char col1[3], col2[3];
-       unsigned char col1a[3], col2a[3];
-       unsigned char col1b[3], col2b[3];
+       unsigned char col1[4], col2[4];
+       unsigned char col1a[4], col2a[4];
+       unsigned char col1b[4], col2b[4];
 
        const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS);
 
 
        /* get theme colors */
-       UI_GetThemeColor3ubv(TH_BACK, col2);
-       UI_GetThemeColor3ubv(TH_HILITE, col1);
+       UI_GetThemeColor4ubv(TH_SHADE2, col2);
+       UI_GetThemeColor4ubv(TH_HILITE, col1);
 
-       UI_GetThemeColor3ubv(TH_GROUP, col2a);
-       UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a);
+       UI_GetThemeColor4ubv(TH_GROUP, col2a);
+       UI_GetThemeColor4ubv(TH_GROUP_ACTIVE, col1a);
 
-       UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b);
-       UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
+       UI_GetThemeColor4ubv(TH_DOPESHEET_CHANNELOB, col1b);
+       UI_GetThemeColor4ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
 
        /* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */
 
@@ -246,14 +246,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                case ANIMTYPE_SCENE:
                                                case ANIMTYPE_OBJECT:
                                                {
-                                                       immUniformColor3ubvAlpha(col1b, sel ? 0x45 : 0x22);
+                                                       immUniformColor3ubvAlpha(col1b, sel ? col1[3] : col1b[3]);
                                                        break;
                                                }
                                                case ANIMTYPE_FILLACTD:
                                                case ANIMTYPE_DSSKEY:
                                                case ANIMTYPE_DSWOR:
                                                {
-                                                       immUniformColor3ubvAlpha(col2b, sel ? 0x45 : 0x22);
+                                                       immUniformColor3ubvAlpha(col2b, sel ? col1[3] : col2b[3]);
                                                        break;
                                                }
                                                case ANIMTYPE_GROUP:
@@ -261,14 +261,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                        bActionGroup *agrp = ale->data;
                                                        if (show_group_colors && agrp->customCol) {
                                                                if (sel) {
-                                                                       immUniformColor3ubvAlpha((unsigned char *)agrp->cs.select, 0x45);
+                                                                       immUniformColor3ubvAlpha((unsigned char *)agrp->cs.select, col1a[3]);
                                                                }
                                                                else {
-                                                                       immUniformColor3ubvAlpha((unsigned char *)agrp->cs.solid, 0x1D);
+                                                                       immUniformColor3ubvAlpha((unsigned char *)agrp->cs.solid, col2a[3]);
                                                                }
                                                        }
                                                        else {
-                                                               immUniformColor3ubvAlpha(sel ? col1a : col2a, 0x22);
+                                                               immUniformColor4ubv(sel ? col1a : col2a);
                                                        }
                                                        break;
                                                }
@@ -276,16 +276,16 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                                {
                                                        FCurve *fcu = ale->data;
                                                        if (show_group_colors && fcu->grp && fcu->grp->customCol) {
-                                                               immUniformColor3ubvAlpha((unsigned char *)fcu->grp->cs.active, sel ? 0x65 : 0x0B);
+                                                               immUniformColor3ubvAlpha((unsigned char *)fcu->grp->cs.active, sel ? col1[3] : col2[3]);
                                                        }
                                                        else {
-                                                               immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
+                                                               immUniformColor4ubv(sel ? col1 : col2);
                                                        }
                                                        break;
                                                }
                                                default:
                                                {
-                                                       immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
+                                                       immUniformColor4ubv(sel ? col1 : col2);
                                                }
                                        }
 
@@ -297,21 +297,23 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
                                }
                                else if (ac->datatype == ANIMCONT_GPENCIL) {
                                        /* frames less than one get less saturated background */
-                                       immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
+                                       unsigned char *color = sel ? col1 : col2;
+                                       immUniformColor4ubv(color);
                                        immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
 
                                        /* frames one and higher get a saturated background */
-                                       immUniformColor3ubvAlpha(sel ? col1 : col2, 0x44);
+                                       immUniformColor3ubvAlpha(color, MIN2(255, color[3]*2));
                                        immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
                                else if (ac->datatype == ANIMCONT_MASK) {
                                        /* TODO --- this is a copy of gpencil */
                                        /* frames less than one get less saturated background */
-                                       immUniformColor3ubvAlpha(sel ? col1 : col2, 0x22);
+                                       unsigned char *color = sel ? col1 : col2;
+                                       immUniformColor4ubv(color);
                                        immRectf(pos, 0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac));
 
                                        /* frames one and higher get a saturated background */
-                                       immUniformColor3ubvAlpha(sel ? col1 : col2, 0x44);
+                                       immUniformColor3ubvAlpha(color, MIN2(255, color[3]*2));
                                        immRectf(pos, v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD,  (float)y + ACHANNEL_HEIGHT_HALF(ac));
                                }
                        }
index 75811ad536960b4d6bc52562fcd1ea47269fe1d8..3fd6fff932b8b20ec64dcf9acab45788c133da10 100644 (file)
@@ -287,8 +287,8 @@ typedef struct ThemeSpace {
        char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4];
 
        char ds_channel[4], ds_subchannel[4]; /* dopesheet */
-       char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4]; /* keytypes */
-       char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], keytype_jitter_select[4]; /* keytypes */
+       char keytype_keyframe[4], keytype_extreme[4], keytype_breakdown[4], keytype_jitter[4], keytype_movehold[4]; /* keytypes */
+       char keytype_keyframe_select[4], keytype_extreme_select[4], keytype_breakdown_select[4], keytype_jitter_select[4], keytype_movehold_select[4]; /* keytypes */
        char keyborder[4], keyborder_select[4];
 
        char console_output[4], console_input[4], console_info[4], console_error[4];
index 5783e9252edb9b0f3e869172da2484c1d1a35491..1acba55549ab7adf3a4749e5d0dd390a035ee90a 100644 (file)
@@ -2709,51 +2709,51 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
 
        prop = RNA_def_property(srna, "dopesheet_channel", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "ds_channel");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Dope Sheet Channel", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
        prop = RNA_def_property(srna, "dopesheet_subchannel", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "ds_subchannel");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Dope Sheet Sub-Channel", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
 
        prop = RNA_def_property(srna, "channels", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "shade2");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Channels", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
        prop = RNA_def_property(srna, "channels_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "hilite");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Channels Selected", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
        prop = RNA_def_property(srna, "channel_group", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "group");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Channel Group", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
        prop = RNA_def_property(srna, "active_channels_group", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "group_active");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Active Channel Group", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
 
        prop = RNA_def_property(srna, "long_key", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "strip");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Long Key", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
        prop = RNA_def_property(srna, "long_key_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "strip_select");
-       RNA_def_property_array(prop, 3);
+       RNA_def_property_array(prop, 4);
        RNA_def_property_ui_text(prop, "Long Key Selected", "");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
@@ -2807,6 +2807,18 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Jitter Keyframe Selected", "Color of selected jitter keyframe");
        RNA_def_property_update(prop, 0, "rna_userdef_update");
 
+       prop = RNA_def_property(srna, "keyframe_movehold", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "keytype_movehold");
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Moving Hold Keyframe", "Color of moving hold keyframe");
+       RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+       prop = RNA_def_property(srna, "keyframe_movehold_selected", PROP_FLOAT, PROP_COLOR_GAMMA);
+       RNA_def_property_float_sdna(prop, NULL, "keytype_movehold_select");
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_ui_text(prop, "Moving Hold Keyframe Selected", "Color of selected moving hold keyframe");
+       RNA_def_property_update(prop, 0, "rna_userdef_update");
+
        prop = RNA_def_property(srna, "keyframe_border", PROP_FLOAT, PROP_COLOR_GAMMA);
        RNA_def_property_float_sdna(prop, NULL, "keyborder");
        RNA_def_property_array(prop, 4);