diff --git a/source/blender/include/BIF_editaction.h b/source/blender/include/BIF_editaction.h index 2d751f56fc5..7e0f703681b 100644 --- a/source/blender/include/BIF_editaction.h +++ b/source/blender/include/BIF_editaction.h @@ -141,6 +141,7 @@ void paste_actdata(void); /* Group/Channel Operations */ struct bActionGroup *get_active_actiongroup(struct bAction *act); void set_active_actiongroup(struct bAction *act, struct bActionGroup *agrp, short select); +void actionbone_group_copycolors(struct bActionGroup *grp, short init_new); void verify_pchan2achan_grouping(struct bAction *act, struct bPose *pose, char name[]); void sync_pchan2achan_grouping(void); void action_groups_group(short add_group); @@ -166,6 +167,7 @@ void deselect_action_channels(short mode); void deselect_actionchannels(struct bAction *act, short mode); int select_channel(struct bAction *act, struct bActionChannel *achan, int selectmode); void select_actionchannel_by_name(struct bAction *act, char *name, int select); +void select_action_group_channels(struct bAction *act, struct bActionGroup *agrp); void selectkeys_leftright (short leftright, short select_mode); /* Action Markers */ diff --git a/source/blender/include/BIF_resources.h b/source/blender/include/BIF_resources.h index e6cbe7bb69a..df514190270 100644 --- a/source/blender/include/BIF_resources.h +++ b/source/blender/include/BIF_resources.h @@ -591,6 +591,9 @@ void BIF_load_ui_colors (void); char *BIF_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); char *BIF_ThemeColorsPup(int spacetype); +/* only for Bone Color sets */ +char *BIF_ThemeColorSetsPup(short inc_custom); + void BIF_def_color (BIFColorID colorid, unsigned char r, unsigned char g, unsigned char b); diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index a798224b35b..6f8b94d7cd1 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -409,6 +409,12 @@ #define B_ACTCOPYKEYS 710 #define B_ACTPASTEKEYS 711 +#define B_ACTCUSTCOLORS 712 +#define B_ACTCOLSSELECTOR 713 +#define B_ACTGRP_SELALL 714 +#define B_ACTGRP_ADDTOSELF 715 +#define B_ACTGRP_UNGROUP 716 + /* TIME: 751 - 800 */ #define B_TL_REW 751 #define B_TL_PLAY 752 diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 3de5b0ff5ba..cd1c047dac9 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -116,6 +116,7 @@ typedef struct ThemeWireColor { /* flags for ThemeWireColor */ #define TH_WIRECOLOR_CONSTCOLS (1<<0) +#define TH_WIRECOLOR_TEXTCOLS (1<<1) /* A theme */ typedef struct bTheme { diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 7eff79fec88..3863161017f 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -5153,32 +5153,6 @@ static void verify_posegroup_groupname(void *arg1, void *arg2) BLI_uniquename(&pose->agroups, grp, "Group", offsetof(bActionGroup, name), 32); } -static char *build_colorsets_menustr () -{ - DynStr *pupds= BLI_dynstr_new(); - char *str; - char buf[48]; - int i; - - /* add title first (and the "default" entry) */ - BLI_dynstr_append(pupds, "Bone Color Set%t|Default Colors%x0|"); - - /* loop through set indices, adding them */ - for (i=1; i<21; i++) { - sprintf(buf, "%d - Theme Color Set%%x%d|", i, i); - BLI_dynstr_append(pupds, buf); - } - - /* add the 'custom' entry */ - BLI_dynstr_append(pupds, "Custom Set %x-1"); - - /* convert to normal MEM_malloc'd string */ - str= BLI_dynstr_get_cstring(pupds); - BLI_dynstr_free(pupds); - - return str; -} - static void editing_panel_links(Object *ob) { uiBlock *block; @@ -5338,32 +5312,14 @@ static void editing_panel_links(Object *ob) /* color set for 'active' group */ if (pose->active_group && grp) { uiBlockBeginAlign(block); - menustr= build_colorsets_menustr(); + menustr= BIF_ThemeColorSetsPup(1); uiDefButI(block, MENU,B_POSEGRP_RECALC, menustr, xco,85,140,19, &grp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme"); MEM_freeN(menustr); /* show color-selection/preview */ if (grp->customCol) { - if (grp->customCol > 0) { - /* copy theme colors on-to group's custom color in case user tries to edit color */ - bTheme *btheme= U.themes.first; - ThemeWireColor *col_set= &btheme->tarm[(grp->customCol - 1)]; - - memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); - } - else { - /* init custom colors with a generic multi-color rgb set, if not initialised already */ - if (grp->cs.solid[0] == 0) { - /* define for setting colors in theme below */ - #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; - - SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255); - SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255); - SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255); - - #undef SETCOL - } - } + /* do color copying/init (to stay up to date) */ + actionbone_group_copycolors(grp, 1); /* color changing */ uiDefButC(block, COL, B_POSEGRP_MCUSTOM, "", xco, 65, 30, 19, grp->cs.solid, 0, 0, 0, 0, "Color to use for surface of bones"); diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 89466151a39..6fe37c1c6e5 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -32,6 +32,7 @@ #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -56,6 +57,7 @@ #include "DNA_space_types.h" #include "DNA_constraint_types.h" #include "DNA_key_types.h" +#include "DNA_userdef_types.h" #include "BKE_action.h" #include "BKE_depsgraph.h" @@ -928,12 +930,55 @@ static void draw_channel_strips(void) void do_actionbuts(unsigned short event) { switch(event) { + /* general */ case REDRAWVIEW3D: allqueue(REDRAWVIEW3D, 0); break; case B_REDR: allqueue(REDRAWACTION, 0); break; + + /* action-groups */ + case B_ACTCUSTCOLORS: /* only when of the color wells is edited */ + { + bActionGroup *agrp= get_active_actiongroup(G.saction->action); + + if (agrp) + agrp->customCol= -1; + + allqueue(REDRAWACTION, 0); + } + break; + case B_ACTCOLSSELECTOR: /* sync color set after using selector */ + { + bActionGroup *agrp= get_active_actiongroup(G.saction->action); + + if (agrp) + actionbone_group_copycolors(agrp, 1); + + allqueue(REDRAWACTION, 0); + } + break; + case B_ACTGRP_SELALL: /* select all grouped channels */ + { + bAction *act= G.saction->action; + bActionGroup *agrp= get_active_actiongroup(act); + + /* select all in group, then reselect/activate group as the previous operation clears that */ + select_action_group_channels(act, agrp); + agrp->flag |= (AGRP_ACTIVE|AGRP_SELECTED); + + allqueue(REDRAWACTION, 0); + } + break; + case B_ACTGRP_ADDTOSELF: /* add all selected action channels to self */ + action_groups_group(0); + break; + case B_ACTGRP_UNGROUP: /* remove channels from active group */ + // FIXME: todo... + printf("FIXME: remove achans from active Action-Group not implemented yet! \n"); + break; + } } @@ -941,14 +986,68 @@ void do_actionbuts(unsigned short event) static void action_panel_properties(short cntrl) // ACTION_HANDLER_PROPERTIES { uiBlock *block; - + void *data; + short datatype; + block= uiNewBlock(&curarea->uiblocks, "action_panel_properties", UI_EMBOSS, UI_HELV, curarea->win); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(ACTION_HANDLER_PROPERTIES); // for close and esc - if (uiNewPanel(curarea, block, "Transform Properties", "Action", 10, 230, 318, 204)==0) + + /* get datatype */ + data= get_action_context(&datatype); + //if (data == NULL) return; + + if (uiNewPanel(curarea, block, "Active Channel Properties", "Action", 10, 230, 318, 204)==0) return; - - uiDefBut(block, LABEL, 0, "test text", 10,180,300,19, 0, 0, 0, 0, 0, ""); + + /* currently, only show data for actions */ + if (datatype == ACTCONT_ACTION) { + bActionGroup *agrp= get_active_actiongroup(data); + //bActionChannel *achan= get_hilighted_action_channel(data); + char *menustr; + + /* only for action-groups */ + if (agrp) { + /* general stuff */ + uiDefBut(block, LABEL, 1, "Action Group:", 10, 180, 150, 19, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefBut(block, TEX, B_REDR, "Name: ", 10,160,150,20, agrp->name, 0.0, 31.0, 0, 0, ""); + uiBlockBeginAlign(block); + uiDefButBitI(block, TOG, AGRP_EXPANDED, B_REDR, "Expanded", 170, 160, 75, 20, &agrp->flag, 0, 0, 0, 0, "Action Group is expanded"); + uiDefButBitI(block, TOG, AGRP_PROTECTED, B_REDR, "Protected", 245, 160, 75, 20, &agrp->flag, 0, 0, 0, 0, "Action Group is protected"); + uiBlockEndAlign(block); + + /* color stuff */ + uiDefBut(block, LABEL, 1, "Group Colors:", 10, 107, 150, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiBlockBeginAlign(block); + menustr= BIF_ThemeColorSetsPup(1); + uiDefButI(block, MENU,B_ACTCOLSSELECTOR, menustr, 10,85,150,19, &agrp->customCol, -1, 20, 0.0, 0.0, "Index of set of Custom Colors to shade Group's bones with. 0 = Use Default Color Scheme, -1 = Use Custom Color Scheme"); + MEM_freeN(menustr); + + /* show color-selection/preview */ + if (agrp->customCol) { + /* do color copying/init (to stay up to date) */ + actionbone_group_copycolors(agrp, 1); + + /* color changing */ + uiDefButC(block, COL, B_ACTCUSTCOLORS, "", 10, 65, 50, 19, agrp->cs.active, 0, 0, 0, 0, "Color to use for 'top-level' channels"); + uiDefButC(block, COL, B_ACTCUSTCOLORS, "", 60, 65, 50, 19, agrp->cs.select, 0, 0, 0, 0, "Color to use for '2nd-level' channels"); + uiDefButC(block, COL, B_ACTCUSTCOLORS, "", 110, 65, 50, 19, agrp->cs.solid, 0, 0, 0, 0, "Color to use for '3rd-level' channels"); + } + uiBlockEndAlign(block); + + /* commands for active group */ + uiDefBut(block, BUT, B_ACTGRP_SELALL, "Select Grouped", 170,85,150,20, 0, 21, 0, 0, 0, "Select all action-channels belonging to this group (same as doing Ctrl-Shift-LMB)"); + + uiBlockBeginAlign(block); + uiDefBut(block, BUT, B_ACTGRP_ADDTOSELF, "Add to Group", 170,60,150,20, 0, 21, 0, 0, 0, "Add selected action-channels to this group"); + uiDefBut(block, BUT, B_ACTGRP_UNGROUP, "Un-Group", 170,40,150,20, 0, 21, 0, 0, 0, "Remove selected action-channels from this group (unimplemented)"); + uiBlockEndAlign(block); + } + } + else { + /* Currently, there isn't anything to display for these types ... */ + } } static void action_blockhandlers(ScrArea *sa) diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index f93a1526e3c..4cc0e52ce3f 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1114,6 +1114,38 @@ void action_groups_ungroup (void) allqueue(REDRAWACTION, 0); } +/* Copy colors from a specified theme's color set to an Action/Bone Group */ +void actionbone_group_copycolors (bActionGroup *grp, short init_new) +{ + /* error checking */ + if (grp == NULL) + return; + + /* only do color copying if using a custom color */ + if (grp->customCol) { + if (grp->customCol > 0) { + /* copy theme colors on-to group's custom color in case user tries to edit color */ + bTheme *btheme= U.themes.first; + ThemeWireColor *col_set= &btheme->tarm[(grp->customCol - 1)]; + + memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); + } + else if (init_new) { + /* init custom colors with a generic multi-color rgb set, if not initialised already (and allowed to do so) */ + if (grp->cs.solid[0] == 0) { + /* define for setting colors in theme below */ + #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; + + SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255); + SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255); + SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255); + + #undef SETCOL + } + } + } +} + /* This function is used when inserting keyframes for pose-channels. It assigns the * action-channel with the nominated name to a group with the same name as that of * the pose-channel with the nominated name. @@ -1160,34 +1192,9 @@ void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[]) /* copy name */ sprintf(grp->name, agrp->name); - /* deal with group-color copying */ - if (agrp->customCol) { - if (agrp->customCol > 0) { - /* copy theme colors on-to group's custom color in case user tries to edit color */ - bTheme *btheme= U.themes.first; - ThemeWireColor *col_set= &btheme->tarm[(agrp->customCol - 1)]; - - memcpy(&grp->cs, col_set, sizeof(ThemeWireColor)); - } - else { - /* init custom colors with a generic multi-color rgb set, if not initialised already */ - if (agrp->cs.solid[0] == 0) { - /* define for setting colors in theme below */ - #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; - - SETCOL(grp->cs.solid, 0xff, 0x00, 0x00, 255); - SETCOL(grp->cs.select, 0x81, 0xe6, 0x14, 255); - SETCOL(grp->cs.active, 0x18, 0xb6, 0xe0, 255); - - #undef SETCOL - } - else { - /* just copy color set specified */ - memcpy(&grp->cs, &agrp->cs, sizeof(ThemeWireColor)); - } - } - } - grp->customCol= agrp->customCol; + /* deal with group-color copying (grp is destination, agrp is source) */ + memcpy(grp, agrp, sizeof(bActionGroup)); + actionbone_group_copycolors(grp, 1); BLI_addtail(&act->groups, grp); } @@ -2697,6 +2704,28 @@ int select_icu_channel(bAction *act, IpoCurve *icu, int selectmode) return flag; } + +/* select only the active action-group's action channels */ +void select_action_group_channels (bAction *act, bActionGroup *agrp) +{ + bActionChannel *achan; + + /* error checking */ + if (ELEM(NULL, act, agrp)) + return; + + /* deselect all other channels */ + deselect_actionchannels(act, 0); + + /* only select channels in group */ + for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) { + select_channel(act, achan, SELECT_ADD); + + /* messy... set active bone */ + select_poseelement_by_name(achan->name, 1); + } +} + /* ----------------------------------------- */ /* De-selects or inverts the selection of Channels in a given Action @@ -3672,17 +3701,8 @@ static void mouse_actionchannels (short mval[]) select_action_group(act, agrp, SELECT_INVERT); } else if (G.qual == (LR_CTRLKEY|LR_SHIFTKEY)) { - bActionChannel *achan; - /* select all in group (and deselect everthing else) */ - deselect_actionchannels(act, 0); - - for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) { - select_channel(act, achan, SELECT_ADD); - - /* messy... set active bone */ - select_poseelement_by_name(achan->name, 1); - } + select_action_group_channels(act, agrp); select_action_group(act, agrp, SELECT_ADD); } else { @@ -4682,11 +4702,13 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt) case NKEY: if (G.qual==0) { - numbuts_action(); - - /* no panel (yet). current numbuts are not easy to put in panel... */ - //add_blockhandler(curarea, ACTION_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE); - //scrarea_queue_winredraw(curarea); + /* panel will not always show useful info! */ + if (mval[0] > ACTWIDTH) { + add_blockhandler(curarea, ACTION_HANDLER_PROPERTIES, UI_PNL_TO_MOUSE); + scrarea_queue_winredraw(curarea); + } + else + numbuts_action(); } break; diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c index 046d14c990d..f47f14a605c 100644 --- a/source/blender/src/resources.c +++ b/source/blender/src/resources.c @@ -52,6 +52,7 @@ #include "BIF_interface_icons.h" #include "BLI_blenlib.h" +#include "BLI_dynstr.h" #include "blendef.h" // CLAMP #include "datatoc.h" @@ -784,6 +785,33 @@ char *BIF_ThemeColorsPup(int spacetype) return cp; } +char *BIF_ThemeColorSetsPup (short inc_custom) +{ + DynStr *pupds= BLI_dynstr_new(); + char *str; + char buf[48]; + int i; + + /* add title first (and the "default" entry) */ + BLI_dynstr_append(pupds, "Bone Color Set%t|Default Colors%x0|"); + + /* loop through set indices, adding them */ + for (i=1; i<21; i++) { + sprintf(buf, "%d - Theme Color Set%%x%d|", i, i); + BLI_dynstr_append(pupds, buf); + } + + /* add the 'custom' entry */ + if (inc_custom) + BLI_dynstr_append(pupds, "Custom Set %x-1"); + + /* convert to normal MEM_malloc'd string */ + str= BLI_dynstr_get_cstring(pupds); + BLI_dynstr_free(pupds); + + return str; +} + void BIF_SetTheme(ScrArea *sa) { if(sa==NULL) { // called for safety, when delete themes