KeyingSets: More work on preparing the UI
KeyingSets can now be added/removed. Next up, the code for the operators to add items to Keying Sets.
This commit is contained in:
@@ -877,23 +877,32 @@ enum {
|
||||
/* Build menu-string of available keying-sets (allocates memory for string)
|
||||
* NOTE: mode must not be longer than 64 chars
|
||||
*/
|
||||
char *ANIM_build_keyingsets_menu (ListBase *list)
|
||||
char *ANIM_build_keyingsets_menu (ListBase *list, short for_edit)
|
||||
{
|
||||
DynStr *pupds= BLI_dynstr_new();
|
||||
KeyingSet *ks;
|
||||
char buf[64];
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
/* add title first */
|
||||
BLI_dynstr_append(pupds, "Keying Sets%t|");
|
||||
|
||||
/* add dummy entry for none-active */
|
||||
BLI_dynstr_append(pupds, "<No Keying Set Active>%x0|");
|
||||
/* add dummy entries for none-active */
|
||||
if (for_edit) {
|
||||
BLI_dynstr_append(pupds, "Add New%x-1|");
|
||||
BLI_dynstr_append(pupds, " %x0|");
|
||||
}
|
||||
else
|
||||
BLI_dynstr_append(pupds, "<No Keying Set Active>%x0|");
|
||||
|
||||
/* loop through keyingsets, adding them */
|
||||
for (ks= list->first; ks; ks= ks->next) {
|
||||
for (ks=list->first, i=1; ks; ks=ks->next, i++) {
|
||||
if (for_edit == 0)
|
||||
BLI_dynstr_append(pupds, "KS: ");
|
||||
|
||||
BLI_dynstr_append(pupds, ks->name);
|
||||
BLI_snprintf( buf, 64, "%s", ((ks->next)?"|":"") );
|
||||
BLI_snprintf( buf, 64, "%%x%d%s", i, ((ks->next)?"|":"") );
|
||||
BLI_dynstr_append(pupds, buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ short deletekey(struct ID *id, const char group[], const char rna_path[], int ar
|
||||
|
||||
|
||||
/* Generate menu of KeyingSets */
|
||||
char *ANIM_build_keyingsets_menu(struct ListBase *list);
|
||||
char *ANIM_build_keyingsets_menu(struct ListBase *list, short for_edit);
|
||||
|
||||
/* Main Keyframe Management operators:
|
||||
* These handle keyframes management from various spaces. They will handle the menus
|
||||
|
||||
@@ -3105,8 +3105,10 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add)
|
||||
|
||||
/* add if none found */
|
||||
// XXX the default settings have yet to evolve
|
||||
if ((add) && (ks==NULL))
|
||||
if ((add) && (ks==NULL)) {
|
||||
ks= BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0);
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
||||
return ks;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
@@ -39,6 +40,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
@@ -159,15 +161,51 @@ static uiBlock *outliner_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
|
||||
return block;
|
||||
}
|
||||
|
||||
#define B_REDR 1
|
||||
enum {
|
||||
B_REDR = 1,
|
||||
|
||||
B_KEYINGSET_CHANGE,
|
||||
B_KEYINGSET_REMOVE,
|
||||
} eOutlinerHeader_Events;
|
||||
|
||||
static void do_outliner_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
||||
switch(event) {
|
||||
case B_REDR:
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
|
||||
case B_KEYINGSET_CHANGE:
|
||||
/* add a new KeyingSet if active is -1 */
|
||||
if (scene->active_keyingset == -1) {
|
||||
// XXX the default settings have yet to evolve... need to keep this in sync with the
|
||||
BKE_keyingset_add(&scene->keyingsets, "KeyingSet", KEYINGSET_ABSOLUTE, 0);
|
||||
scene->active_keyingset= BLI_countlist(&scene->keyingsets);
|
||||
}
|
||||
|
||||
/* redraw regions with KeyingSet info */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
|
||||
break;
|
||||
|
||||
case B_KEYINGSET_REMOVE:
|
||||
/* remove the active KeyingSet */
|
||||
if (scene->active_keyingset) {
|
||||
KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
|
||||
/* firstly free KeyingSet's data, then free the KeyingSet itself */
|
||||
if (ks) {
|
||||
BKE_keyingset_free(ks);
|
||||
BLI_freelinkN(&scene->keyingsets, ks);
|
||||
scene->active_keyingset= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* redraw regions with KeyingSet info */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, scene);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +213,7 @@ static void do_outliner_buttons(bContext *C, void *arg, int event)
|
||||
void outliner_header_buttons(const bContext *C, ARegion *ar)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
|
||||
uiBlock *block;
|
||||
int xco, yco= 3, xmax;
|
||||
@@ -201,13 +240,63 @@ void outliner_header_buttons(const bContext *C, ARegion *ar)
|
||||
}
|
||||
|
||||
//if (outliner->type==SO_OUTLINER) {
|
||||
/* data selector*/
|
||||
if(G.main->library.first)
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|Libraries %x7|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
else
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
uiDefButS(block, MENU, B_REDR, "Outliner Display%t|All Scenes %x0|Current Scene %x1|Visible Layers %x2|Groups %x6|Same Types %x5|Selected %x3|Active %x4|Sequence %x10|Datablocks %x11|User Preferences %x12", xco, yco, 120, 20, &soutliner->outlinevis, 0, 0, 0, 0, "");
|
||||
xco += 120;
|
||||
|
||||
/* KeyingSet editing buttons */
|
||||
if ((soutliner->flag & SO_HIDE_KEYINGSETINFO)==0 && (soutliner->outlinevis==SO_DATABLOCKS)) {
|
||||
KeyingSet *ks= NULL;
|
||||
char *menustr= NULL;
|
||||
|
||||
xco+= (int)(XIC*1.5);
|
||||
|
||||
if (scene->active_keyingset)
|
||||
ks= (KeyingSet *)BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
/* currently 'active' KeyingSet */
|
||||
menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 1);
|
||||
uiDefButI(block, MENU, B_KEYINGSET_CHANGE, menustr, xco,yco, 18,20, &scene->active_keyingset, 0, 0, 0, 0, "Browse Keying Sets");
|
||||
MEM_freeN(menustr);
|
||||
xco += 18;
|
||||
|
||||
/* currently 'active' KeyingSet - change name */
|
||||
if (ks) {
|
||||
/* active KeyingSet */
|
||||
uiDefBut(block, TEX, B_KEYINGSET_CHANGE,"", xco,yco,120,20, ks->name, 0, 63, 0, 0, "Name of Active Keying Set");
|
||||
xco += 120;
|
||||
uiDefIconBut(block, BUT, B_KEYINGSET_REMOVE, VICON_X, xco, yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove this Keying Set");
|
||||
xco += 20;
|
||||
}
|
||||
else {
|
||||
/* no active KeyingSet... so placeholder instead */
|
||||
uiDefBut(block, LABEL, 0,"<No Keying Set Active>", xco,yco,140,20, NULL, 0, 63, 0, 0, "Name of Active Keying Set");
|
||||
xco += 140;
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
/* current 'active' KeyingSet */
|
||||
if (ks) {
|
||||
xco += 5;
|
||||
|
||||
/* operator buttons to add/remove selected items from set */
|
||||
uiBlockBeginAlign(block);
|
||||
// XXX the icons here are temporary
|
||||
uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_remove_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMOUT, xco,yco,XIC,YIC, "Remove selected properties from active Keying Set (Alt-K)");
|
||||
xco += XIC;
|
||||
uiDefIconButO(block, BUT, "OUTLINER_OT_keyingset_add_selected", WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, xco,yco,XIC,YIC, "Add selected properties to active Keying Set (K)");
|
||||
xco += XIC;
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
xco += XIC*2;
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
/* always as last */
|
||||
UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
case ND_OB_ACTIVE:
|
||||
case ND_OB_SELECT:
|
||||
case ND_MODE:
|
||||
case ND_KEYINGSET:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
@@ -170,6 +171,17 @@ static void outliner_header_area_free(ARegion *ar)
|
||||
{
|
||||
}
|
||||
|
||||
static void outliner_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_SCENE:
|
||||
if(wmn->data == ND_KEYINGSET)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for outliner space ***************** */
|
||||
|
||||
static SpaceLink *outliner_new(const bContext *C)
|
||||
@@ -289,6 +301,7 @@ void ED_spacetype_outliner(void)
|
||||
art->init= outliner_header_area_init;
|
||||
art->draw= outliner_header_area_draw;
|
||||
art->free= outliner_header_area_free;
|
||||
art->listener= outliner_header_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
|
||||
@@ -207,11 +207,13 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
|
||||
case NC_SCENE:
|
||||
if(wmn->data==ND_FRAME)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
switch (wmn->data) {
|
||||
case ND_FRAME:
|
||||
case ND_KEYINGSET:
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -542,7 +542,7 @@ void time_header_buttons(const bContext *C, ARegion *ar)
|
||||
xco+= 16;
|
||||
|
||||
|
||||
menustr= ANIM_build_keyingsets_menu(&scene->keyingsets);
|
||||
menustr= ANIM_build_keyingsets_menu(&scene->keyingsets, 0);
|
||||
uiDefButI(block, MENU, B_DIFF,
|
||||
menustr,
|
||||
xco, yco, (int)5.5*XIC, YIC, &(scene->active_keyingset), 0, 1, 0, 0,
|
||||
|
||||
@@ -619,6 +619,7 @@ enum {
|
||||
#define SO_TESTBLOCKS 1
|
||||
#define SO_NEWSELECTED 2
|
||||
#define SO_HIDE_RESTRICTCOLS 4
|
||||
#define SO_HIDE_KEYINGSETINFO 8
|
||||
|
||||
/* SpaceOops->visiflag */
|
||||
#define OOPS_SCE 1
|
||||
|
||||
@@ -176,6 +176,7 @@ typedef struct wmNotifier {
|
||||
#define ND_MODE (9<<16)
|
||||
#define ND_RENDER_RESULT (10<<16)
|
||||
#define ND_COMPO_RESULT (11<<16)
|
||||
#define ND_KEYINGSET (12<<16)
|
||||
|
||||
/* NC_OBJECT Object */
|
||||
#define ND_TRANSFORM (16<<16)
|
||||
|
||||
Reference in New Issue
Block a user