Index: source/blender/blenkernel/intern/context.c =================================================================== --- source/blender/blenkernel/intern/context.c (revision 27617) +++ source/blender/blenkernel/intern/context.c (working copy) @@ -317,6 +317,13 @@ return NULL; } +struct SpaceMatcher *CTX_wm_space_matcher(const bContext *C) +{ + if(C->wm.area && C->wm.area->spacetype==SPACE_MATCHER) + return C->wm.area->spacedata.first; + return NULL; +} + struct SpaceNode *CTX_wm_space_node(const bContext *C) { if(C->wm.area && C->wm.area->spacetype==SPACE_NODE) Index: source/blender/blenkernel/BKE_context.h =================================================================== --- source/blender/blenkernel/BKE_context.h (revision 27617) +++ source/blender/blenkernel/BKE_context.h (working copy) @@ -156,6 +156,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C); struct SpaceInfo *CTX_wm_space_info(const bContext *C); struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C); +struct SpaceMatcher *CTX_wm_space_matcher(const bContext *C); //chris stones void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm); void CTX_wm_window_set(bContext *C, struct wmWindow *win); Index: source/blender/makesdna/DNA_space_types.h =================================================================== --- source/blender/makesdna/DNA_space_types.h (revision 27617) +++ source/blender/makesdna/DNA_space_types.h (working copy) @@ -354,6 +354,20 @@ } SpaceTime; +// chris stones +typedef struct SpaceMatcher { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + float blockscale; + + View2D v2d; /* deprecated, copied to region */ + + int flag, redraws; + +} SpaceMatcher; + + typedef struct SpaceNode { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ @@ -889,6 +903,7 @@ SPACE_LOGIC, SPACE_CONSOLE, SPACE_USERPREF, + SPACE_MATCHER, // added my Chris Stones SPACEICONMAX = SPACE_USERPREF }; Index: source/blender/makesrna/intern/rna_userdef.c =================================================================== --- source/blender/makesrna/intern/rna_userdef.c (revision 27617) +++ source/blender/makesrna/intern/rna_userdef.c (working copy) @@ -1682,7 +1682,7 @@ RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "tv3d"); RNA_def_property_struct_type(prop, "ThemeView3D"); - RNA_def_property_ui_text(prop, "3D View", ""); + RNA_def_property_ui_text(prop, "3D View", ""); prop= RNA_def_property(srna, "graph_editor", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); Index: source/blender/makesrna/intern/rna_space.c =================================================================== --- source/blender/makesrna/intern/rna_space.c (revision 27617) +++ source/blender/makesrna/intern/rna_space.c (working copy) @@ -62,6 +62,7 @@ {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, {SPACE_CONSOLE, "CONSOLE", 0, "Console", ""}, {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, + {SPACE_MATCHER, "SPACE_MATCHER", 0, "Motion Matcher", ""}, //chris stones {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_channels_items[] = { @@ -161,6 +162,8 @@ return &RNA_SpaceLogicEditor; case SPACE_CONSOLE: return &RNA_SpaceConsole; + case SPACE_MATCHER: + return &RNA_SpaceMatcher; // chris stones case SPACE_USERPREF: return &RNA_SpaceUserPreferences; default: @@ -1733,6 +1736,19 @@ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); } +/* space matcher rna def */ +static void rna_def_space_matcher(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "SpaceMatcher", "Space"); + RNA_def_struct_sdna(srna, "SpaceMatcher"); + RNA_def_struct_ui_text(srna, "Space Motion Matcher Editor", "Motion Matching editor space data"); + +} + + static void rna_def_console_line(BlenderRNA *brna) { StructRNA *srna; @@ -2052,6 +2068,7 @@ rna_def_space_graph(brna); rna_def_space_nla(brna); rna_def_space_time(brna); + rna_def_space_matcher(brna); // chris stones rna_def_space_console(brna); rna_def_console_line(brna); rna_def_space_info(brna); Index: source/blender/makesrna/RNA_access.h =================================================================== --- source/blender/makesrna/RNA_access.h (revision 27617) +++ source/blender/makesrna/RNA_access.h (working copy) @@ -435,6 +435,7 @@ extern StructRNA RNA_Space; extern StructRNA RNA_Space3DView; extern StructRNA RNA_SpaceConsole; +extern StructRNA RNA_SpaceMatcher; /// chris stones extern StructRNA RNA_SpaceDopeSheetEditor; extern StructRNA RNA_SpaceFileBrowser; extern StructRNA RNA_SpaceGraphEditor; Index: source/blender/windowmanager/WM_types.h =================================================================== --- source/blender/windowmanager/WM_types.h (revision 27617) +++ source/blender/windowmanager/WM_types.h (working copy) @@ -149,6 +149,7 @@ #define NC_NODE (17<<24) #define NC_ID (18<<24) #define NC_LOGIC (19<<24) +#define NC_MATCHER (20<<24) //chris stones /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 @@ -249,6 +250,7 @@ #define ND_SPACE_NLA (14<<16) #define ND_SPACE_SEQUENCER (15<<16) #define ND_SPACE_NODE_VIEW (16<<16) +#define ND_SPACE_MATCHER (18<<16) // chris stones #define ND_SPACE_CHANGED (17<<16) /*sent to a new editor type after it's replaced an old one*/ /* subtype, 256 entries too */ Index: source/blender/editors/screen/screen_ops.c =================================================================== --- source/blender/editors/screen/screen_ops.c (revision 27617) +++ source/blender/editors/screen/screen_ops.c (working copy) @@ -195,6 +195,13 @@ return ed_spacetype_test(C, SPACE_NLA); } +/* chris stones */ +int ED_operator_matcher_active(bContext *C) +{ + return ed_spacetype_test(C, SPACE_MATCHER); +} + + int ED_operator_logic_active(bContext *C) { return ed_spacetype_test(C, SPACE_LOGIC); Index: source/blender/editors/screen/area.c =================================================================== --- source/blender/editors/screen/area.c (revision 27617) +++ source/blender/editors/screen/area.c (working copy) @@ -1160,7 +1160,8 @@ "|%l" "|Console %x18" - ); + "|Match Motion %x20" + ); // chris stones added "|Match Motion %x21" } static void spacefunc(struct bContext *C, void *arg1, void *arg2) Index: source/blender/editors/include/ED_space_api.h =================================================================== --- source/blender/editors/include/ED_space_api.h (revision 27617) +++ source/blender/editors/include/ED_space_api.h (working copy) @@ -53,6 +53,7 @@ void ED_spacetype_logic(void); void ED_spacetype_console(void); void ED_spacetype_userpref(void); +void ED_spacetype_matcher(void); // chris stones /* calls for instancing and freeing spacetype static data called in WM_init_exit */ Index: source/blender/editors/include/ED_screen.h =================================================================== --- source/blender/editors/include/ED_screen.h (revision 27617) +++ source/blender/editors/include/ED_screen.h (working copy) @@ -135,6 +135,7 @@ int ED_operator_image_active(struct bContext *C); int ED_operator_nla_active(struct bContext *C); int ED_operator_logic_active(struct bContext *C); +int ED_operator_matcher_active(struct bContext *C); // chris stones int ED_operator_object_active(struct bContext *C); int ED_operator_object_active_editable(struct bContext *C); Index: source/blender/editors/space_api/spacetypes.c =================================================================== --- source/blender/editors/space_api/spacetypes.c (revision 27617) +++ source/blender/editors/space_api/spacetypes.c (working copy) @@ -56,6 +56,7 @@ #include "ED_sound.h" #include "ED_uvedit.h" #include "ED_mball.h" +#include "/Users/admin/Documents/blender2009/blender/source/blender/editors/space_matcher/space_matcher.h" /* only call once on startup, storage is global in BKE kernel listbase */ void ED_spacetypes_init(void) @@ -82,6 +83,7 @@ ED_spacetype_logic(); ED_spacetype_console(); ED_spacetype_userpref(); + ED_spacetype_matcher(); // chris stones // ... /* register operator types for screen and all spaces */ @@ -101,6 +103,7 @@ ED_operatortypes_metaball(); ED_operatortypes_sound(); ED_operatortypes_render(); + matcher_operatortypes(); //I'll rename with an ED_ later UI_view2d_operatortypes(); UI_buttons_operatortypes(); Index: source/blender/editors/space_matcher/space_matcher.c =================================================================== --- source/blender/editors/space_matcher/space_matcher.c (revision 0) +++ source/blender/editors/space_matcher/space_matcher.c (revision 0) @@ -0,0 +1,475 @@ +/** + * $Id: space_matcher.c + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation, 2008 + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include + +#include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" + +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_windowmanager_types.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "UI_interface.h" +#include "UI_view2d.h" + +#include "BIF_gl.h" + +#include "ED_anim_api.h" +#include "ED_armature.h" +#include "ED_curve.h" +#include "ED_fileselect.h" +#include "ED_gpencil.h" +#include "ED_markers.h" +#include "ED_mesh.h" +#include "ED_node.h" +#include "ED_object.h" +#include "ED_physics.h" +#include "ED_render.h" +#include "ED_screen.h" +#include "ED_sculpt.h" +#include "ED_space_api.h" +#include "ED_sound.h" +#include "ED_uvedit.h" +#include "ED_mball.h" + + +#include "WM_api.h" +#include "WM_types.h" + +// for interface drawin +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + + +/* ********************** custom drawcall api ***************** */ + +typedef struct RegionDrawCB { + struct RegionDrawCB *next, *prev; + + void (*draw)(const struct bContext *, struct ARegion *, void *); + void *customdata; + + int type; + +} RegionDrawCB; + + +/* ********************* space template *********************** */ + +// called any time menu is actived +static void do_viewmenu_matcher(bContext *C, void *arg, int event) +{ + //printf("menu item action \n"); +} + +static void do_test_function(bContext *C, void *arg, int event) +{ + printf("do_test_function item action \n"); +} + +static uiBlock *dummy_viewmenu_matcher(bContext *C, ARegion *ar, void *arg_unused) +{ + ScrArea *curarea= CTX_wm_area(C); + uiBlock *block; + uiBut *but; + short yco= 0, menuwidth=120; + + block= uiBeginBlock(C, ar, "dummy_viewmenu_matcher", UI_EMBOSSP); + uiBlockSetButmFunc(block, do_viewmenu_matcher, NULL); + + // Add the button to the menu and use the button ref to add a handler ICON_BLANK1 + but = uiDefIconTextBut(block, BUTM, 1, ICON_LAMP, "Test Function", 0, yco-=20, + menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + + // We add a handler to the button you select + uiButSetFunc(but, do_test_function, NULL, NULL); + + if(curarea->headertype==HEADERTOP) { + uiBlockSetDirection(block, UI_DOWN); + } + else { + uiBlockSetDirection(block, UI_TOP); + uiBlockFlipOrder(block); + } + + uiTextBoundsBlock(block, 50); + uiEndBlock(C, block); + + return block; +} + + +/* allocate and init some vars */ +static SpaceLink *matcher_new(const bContext *C) +{ + Scene *scene= CTX_data_scene(C); + ARegion *ar; + SpaceMatcher *stime; + + stime= MEM_callocN(sizeof(SpaceMatcher), "initmatcher"); + + stime->spacetype= SPACE_MATCHER; + //stime->redraws= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; + //stime->flag |= TIME_DRAWFRAMES; + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for matcher"); + + BLI_addtail(&stime->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* main area */ + ar= MEM_callocN(sizeof(ARegion), "main area for matcher"); + + BLI_addtail(&stime->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + ar->v2d.tot.xmin= (float)(SFRA - 4); + ar->v2d.tot.ymin= 0.0f; + ar->v2d.tot.xmax= (float)(EFRA + 4); + ar->v2d.tot.ymax= 50.0f; + + ar->v2d.cur= ar->v2d.tot; + + ar->v2d.min[0]= 1.0f; + ar->v2d.min[1]= 50.0f; + + ar->v2d.max[0]= MAXFRAMEF; + ar->v2d.max[1]= 50.0; + + ar->v2d.minzoom= 0.1f; + ar->v2d.maxzoom= 10.0; + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; + ar->v2d.keepofs |= V2D_LOCKOFS_Y; + ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + + + return (SpaceLink*)stime; + +// return NULL; +} + +/* not spacelink itself */ +static void matcher_free(SpaceLink *sl) +{ + +} + +/* spacetype; init callback for usage, should be redoable */ +static void matcher_init(wmWindowManager *wm, ScrArea *sa) +{ + + /* link area to SpaceXXX struct */ + + /* define how many regions, the order and types */ + + /* add types to regions */ +} + +static SpaceLink *matcher_duplicate(SpaceLink *sl) +{ + SpaceNode *snoden= MEM_dupallocN(sl); + + /* clear or remove stuff from old */ + snoden->nodetree= NULL; + + return (SpaceLink *)snoden; + //return NULL; +} + + +/* Op functions */ + +static int matcher_test_function_exec(bContext *C, wmOperator *op) +{ + printf("matcher test function exec called\n"); + return OPERATOR_FINISHED; +} + + +/* Modal Operator init */ +static int matcher_test_function_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + printf("matcher test func invoke\n "); + /* Change to frame that mouse is over before adding modal handler, + * as user could click on a single frame (jump to frame) as well as + * click-dragging over a range (modal scrubbing). + */ + //graphview_cursor_setprops(C, op, event); + + /* apply these changes first */ + //graphview_cursor_apply(C, op); + + /* add temp handler */ + //WM_event_add_modal_handler(C, op); + return OPERATOR_RUNNING_MODAL; +} + +/* Modal event handling of cursor changing */ +static int matcher_test_function_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + printf("matcher_test_function_modal called\n "); + /* execute the events */ +// switch (event->type) { +// case ESCKEY: +// return OPERATOR_FINISHED; +// +// case MOUSEMOVE: +// /* set the new values */ +// graphview_cursor_setprops(C, op, event); +// graphview_cursor_apply(C, op); +// break; +// +// case LEFTMOUSE: +// case RIGHTMOUSE: +// /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init +// * the modal op) doesn't work for some reason +// */ +// if (event->val==KM_RELEASE) +// return OPERATOR_FINISHED; +// break; +// } + + return OPERATOR_RUNNING_MODAL; +} + + +void MATCHER_OT_test_function(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Test Function"; + ot->idname= "MATCHER_OT_test_function"; + ot->description= "Woo! I wrote an operator!"; + + /* api callbacks */ + ot->exec= matcher_test_function_exec; + ot->invoke= matcher_test_function_invoke; + ot->modal= matcher_test_function_modal; + ot->poll= ED_operator_matcher_active; + + /* flags */ + //ot->flag= OPTYPE_BLOCKING; // ????? + + /* rna */ + //RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); + //RNA_def_float(ot->srna, "value", 0, FLT_MIN, FLT_MAX, "Value", "", -100.0f, 100.0f); +} + + +void matcher_operatortypes(void) +{ + /* register operator types for this space */ + WM_operatortype_append(MATCHER_OT_test_function); + +} + +void matcher_keymap(wmKeyConfig *keyconf) +{ + /* add default items to keymap */ + wmKeyMap *keymap = WM_keymap_find(keyconf, "Motion Matcher", SPACE_MATCHER, 0); + WM_keymap_add_item(keymap, "MATCHER_OT_test_function", MKEY, KM_PRESS, KM_SHIFT, 0); +} + + +/* */ +/* add handlers, stuff you only do once or on area/region changes */ +static void matcher_main_area_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymap */ + keymap= WM_keymap_find(wm->defaultconf, "Motion Matcher", SPACE_MATCHER, 0); + WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); +} + +static void matcher_main_area_draw(const bContext *C, ARegion *ar) +{ + /* draw entirely, view changes should be handled here */ + SpaceMatcher *stime= CTX_wm_space_matcher(C); + + //View2D *v2d= &ar->v2d; + float col[3]; + + /* clear and setup matrix */ + UI_GetThemeColor3fv(TH_BACK, col); + glClearColor(col[0], col[1], col[2], 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + +} + +static void matcher_main_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + //printf("listener called"); + switch(wmn->category) { + case NC_SPACE: + if(wmn->data == ND_SPACE_MATCHER) + ED_region_tag_redraw(ar); + break; + + case NC_ANIMATION: + ED_region_tag_redraw(ar); + break; + + case NC_SCENE: + /* any scene change for now */ + ED_region_tag_redraw(ar); + break; + + } +} + +/* ************************ header time area region *********************** */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void matcher_header_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void matcher_header_area_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + case NC_SCREEN: + if(wmn->data==ND_ANIMPLAY) + ED_region_tag_redraw(ar); + break; + + case NC_SCENE: + switch (wmn->data) { + case ND_FRAME: + case ND_KEYINGSET: + case ND_RENDER_OPTIONS: + ED_region_tag_redraw(ar); + break; + } + + case NC_SPACE: + if(wmn->data == ND_SPACE_MATCHER) + ED_region_tag_redraw(ar); + break; + } + +} + +static void matcher_header_area_draw(const bContext *C, ARegion *ar) +{ + uiBlock *block; + float col[3]; + int yco = 3; + int xco;// = 0; + int xmax; + /* clear */ + if(ED_screen_area_active(C)) + UI_GetThemeColor3fv(TH_HEADER, col); + else + UI_GetThemeColor3fv(TH_HEADERDESEL, col); + + glClearColor(col[0], col[1], col[2], 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + + block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS); + //uiBlockSetHandleFunc(block, matcher_header_area_listener, NULL); + + xco = ED_area_header_switchbutton(C,block,yco); + //ED_area_header_standardbuttons(C,block,yco); + + + xmax= GetButStringLength("File"); + uiDefPulldownBut(block, dummy_viewmenu_matcher, CTX_wm_area(C),"File", xco, yco-2, xmax-3, 24, ""); + + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + // ED_region_header(C, ar); +} + + +/* only called once, from screen/spacetypes.c */ +void ED_spacetype_matcher(void) +{ + //static SpaceType st; + SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype matcher"); + ARegionType *art; + + st->spaceid= SPACE_MATCHER; + + strncpy(st->name, "Motion Matcher", BKE_ST_MAXNAME); + + + st->new= matcher_new; + st->free= matcher_free; + st->init= matcher_init; + st->duplicate= matcher_duplicate; + st->operatortypes= matcher_operatortypes; + st->keymap= matcher_keymap; + + + /* prep the location */ + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype matcher region"); + art->regionid = RGN_TYPE_WINDOW; + art->keymapflag= ED_KEYMAP_VIEW2D;//|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + + art->init= matcher_main_area_init; + art->draw= matcher_main_area_draw; + art->listener= matcher_main_area_listener; + art->keymap= matcher_keymap; + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype matcher region"); + art->regionid = RGN_TYPE_HEADER; + art->prefsizey= HEADERY; + art->keymapflag= ED_KEYMAP_UI;//|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + + art->init= matcher_header_area_init; + art->draw= matcher_header_area_draw; + art->listener= matcher_header_area_listener; + BLI_addhead(&st->regiontypes, art); + + + + BKE_spacetype_register(st); // &st +} + +/* ****************************** end template *********************** */ + + + + Index: source/blender/editors/space_matcher/space_matcher.h =================================================================== --- source/blender/editors/space_matcher/space_matcher.h (revision 0) +++ source/blender/editors/space_matcher/space_matcher.h (revision 0) @@ -0,0 +1,25 @@ +/* + * space_matcher.h + * Blender + * + * Created by Admin on 3/24/10. + * Copyright 2010 Chris Stones. All rights reserved. + * + */ + +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" + +#include "BKE_context.h" +#include "BKE_screen.h" + +#include "ED_screen.h" + +//void ED_spacetype_matcher(void); + +void matcher_operatortypes(void); \ No newline at end of file