diff options
author | Jason Hays <jason_hays22@mymail.eku.edu> | 2011-08-12 19:48:08 +0400 |
---|---|---|
committer | Jason Hays <jason_hays22@mymail.eku.edu> | 2011-08-12 19:48:08 +0400 |
commit | c57d64468bc9009a11cafdbf0cc66e83cdaa6841 (patch) | |
tree | 8f6544778c565b3c85042c976b6f12660f8af6d0 /source/blender | |
parent | c536a708f545d6ee212defc5fa8110b4c48a4da3 (diff) | |
parent | b374ab919a4b46d377d88ad0f1f1eced06621eca (diff) |
Merged 39257-39338
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 141 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 92 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 7 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 433 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_intern.h | 6 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_ops.c | 6 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Vector.c | 16 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_keymap.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 7 |
12 files changed, 382 insertions, 352 deletions
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index dcc71fa1258..e4afc6ad79b 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -53,14 +53,14 @@ typedef void (*GHashValFreeFP) (void *val); typedef struct Entry { struct Entry *next; - + void *key, *val; } Entry; typedef struct GHash { GHashHashFP hashfp; GHashCmpFP cmpfp; - + Entry **buckets; struct BLI_mempool *entrypool; int nbuckets, nentries, cursize; @@ -72,15 +72,15 @@ typedef struct GHashIterator { struct Entry *curEntry; } GHashIterator; -GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); -void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); - -//BM_INLINE void BLI_ghash_insert (GHash *gh, void *key, void *val); -//BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); -//BM_INLINE void* BLI_ghash_lookup (GHash *gh, void *key); -//BM_INLINE int BLI_ghash_haskey (GHash *gh, void *key); +/* *** */ -int BLI_ghash_size (GHash *gh); +GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info); +void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +void BLI_ghash_insert(GHash *gh, void *key, void *val); +void * BLI_ghash_lookup(GHash *gh, const void *key); +int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +int BLI_ghash_haskey(GHash *gh, void *key); +int BLI_ghash_size (GHash *gh); /* *** */ @@ -149,127 +149,10 @@ unsigned int BLI_ghashutil_strhash (const void *key); int BLI_ghashutil_strcmp (const void *a, const void *b); unsigned int BLI_ghashutil_inthash (const void *ptr); -int BLI_ghashutil_intcmp(const void *a, const void *b); - -/*begin of macro-inlined functions*/ -extern unsigned int hashsizes[]; - -#if 0 -#define BLI_ghash_insert(gh, _k, _v){\ - unsigned int _hash= (gh)->hashfp(_k)%gh->nbuckets;\ - Entry *_e= BLI_mempool_alloc((gh)->entrypool);\ - _e->key= _k;\ - _e->val= _v;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - if (++(gh)->nentries>(gh)->nbuckets*3) {\ - Entry *_e, **_old= (gh)->buckets;\ - int _i, _nold= (gh)->nbuckets;\ - (gh)->nbuckets= hashsizes[++(gh)->cursize];\ - (gh)->buckets= malloc((gh)->nbuckets*sizeof(*(gh)->buckets));\ - memset((gh)->buckets, 0, (gh)->nbuckets*sizeof(*(gh)->buckets));\ - for (_i=0; _i<_nold; _i++) {\ - for (_e= _old[_i]; _e;) {\ - Entry *_n= _e->next;\ - _hash= (gh)->hashfp(_e->key)%(gh)->nbuckets;\ - _e->next= (gh)->buckets[_hash];\ - (gh)->buckets[_hash]= _e;\ - _e= _n;\ - }\ - }\ - free(_old); } } -#endif - -/*---------inlined functions---------*/ -BM_INLINE void BLI_ghash_insert(GHash *gh, void *key, void *val) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool); - - e->key= key; - e->val= val; - e->next= gh->buckets[hash]; - gh->buckets[hash]= e; - - if (++gh->nentries>(float)gh->nbuckets/2) { - Entry **old= gh->buckets; - int i, nold= gh->nbuckets; - - gh->nbuckets= hashsizes[++gh->cursize]; - gh->buckets= (Entry**)MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets"); - memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets)); - - for (i=0; i<nold; i++) { - for (e= old[i]; e;) { - Entry *n= e->next; - - hash= gh->hashfp(e->key)%gh->nbuckets; - e->next= gh->buckets[hash]; - gh->buckets[hash]= e; - - e= n; - } - } - - MEM_freeN(old); - } -} - -BM_INLINE void* BLI_ghash_lookup(GHash *gh, const void *key) -{ - if(gh) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - - for (e= gh->buckets[hash]; e; e= e->next) - if (gh->cmpfp(key, e->key)==0) - return e->val; - } - return NULL; -} - -BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) -{ - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - Entry *p = NULL; - - for (e= gh->buckets[hash]; e; e= e->next) { - if (gh->cmpfp(key, e->key)==0) { - Entry *n= e->next; - - if (keyfreefp) keyfreefp(e->key); - if (valfreefp) valfreefp(e->val); - BLI_mempool_free(gh->entrypool, e); - - - e= n; - if (p) - p->next = n; - else - gh->buckets[hash] = n; - - --gh->nentries; - return 1; - } - p = e; - } - - return 0; -} - -BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) { - unsigned int hash= gh->hashfp(key)%gh->nbuckets; - Entry *e; - - for (e= gh->buckets[hash]; e; e= e->next) - if (gh->cmpfp(key, e->key)==0) - return 1; - - return 0; -} +int BLI_ghashutil_intcmp (const void *a, const void *b); #ifdef __cplusplus } #endif -#endif +#endif /* BLI_GHASH_H */ diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index ff08ef4dba9..3c6a20b8ad6 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -49,8 +49,6 @@ unsigned int hashsizes[]= { /***/ -/***/ - GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) { GHash *gh= MEM_mallocN(sizeof(*gh), info); gh->hashfp= hashfp; @@ -67,14 +65,96 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) { return gh; } -#ifdef BLI_ghash_insert -#undef BLI_ghash_insert -#endif - int BLI_ghash_size(GHash *gh) { return gh->nentries; } +void BLI_ghash_insert(GHash *gh, void *key, void *val) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e= (Entry*) BLI_mempool_alloc(gh->entrypool); + + e->key= key; + e->val= val; + e->next= gh->buckets[hash]; + gh->buckets[hash]= e; + + if (++gh->nentries>(float)gh->nbuckets/2) { + Entry **old= gh->buckets; + int i, nold= gh->nbuckets; + + gh->nbuckets= hashsizes[++gh->cursize]; + gh->buckets= (Entry**)MEM_mallocN(gh->nbuckets*sizeof(*gh->buckets), "buckets"); + memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets)); + + for (i=0; i<nold; i++) { + for (e= old[i]; e;) { + Entry *n= e->next; + + hash= gh->hashfp(e->key)%gh->nbuckets; + e->next= gh->buckets[hash]; + gh->buckets[hash]= e; + + e= n; + } + } + + MEM_freeN(old); + } +} + +void *BLI_ghash_lookup(GHash *gh, const void *key) { + if(gh) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + + for (e= gh->buckets[hash]; e; e= e->next) + if (gh->cmpfp(key, e->key)==0) + return e->val; + } + return NULL; +} + +int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) +{ + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + Entry *p = NULL; + + for (e= gh->buckets[hash]; e; e= e->next) { + if (gh->cmpfp(key, e->key)==0) { + Entry *n= e->next; + + if (keyfreefp) keyfreefp(e->key); + if (valfreefp) valfreefp(e->val); + BLI_mempool_free(gh->entrypool, e); + + + e= n; + if (p) + p->next = n; + else + gh->buckets[hash] = n; + + --gh->nentries; + return 1; + } + p = e; + } + + return 0; +} + +int BLI_ghash_haskey(GHash *gh, void *key) { + unsigned int hash= gh->hashfp(key)%gh->nbuckets; + Entry *e; + + for (e= gh->buckets[hash]; e; e= e->next) + if (gh->cmpfp(key, e->key)==0) + return 1; + + return 0; +} + void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) { int i; diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2311f4a3a64..169443d855f 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1615,7 +1615,12 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest) static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p= op->customdata; - int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ + //int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ + /* currently, grease pencil conflicts with such operators as undo and set object mode + which makes behavior of operator totally unpredictable and crash for some cases. + the only way to solve this proper is to ger rid of pointers to data which can + chage stored in operator custom data (sergey) */ + int estate = OPERATOR_RUNNING_MODAL; // if (event->type == NDOF_MOTION) // return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f5f97c6a5f6..cd42661f320 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -182,7 +182,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) } RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location for the newly added object", -FLT_MAX, FLT_MAX); - RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -FLT_MAX, FLT_MAX); + RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", "Rotation for the newly added object", -M_PI * 2.0f, M_PI * 2.0f); prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index b105b2507ab..14004e7fbba 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -83,9 +83,8 @@ /* avoid passing multiple args and be more verbose */ #define SEQPROP_STARTFRAME (1<<0) #define SEQPROP_ENDFRAME (1<<1) -#define SEQPROP_FILES (1<<2) -#define SEQPROP_NOPATHS (1<<3) -#define SEQPROP_NOCHAN (1<<4) +#define SEQPROP_NOPATHS (1<<2) +#define SEQPROP_NOCHAN (1<<3) #define SELECT 1 @@ -102,9 +101,6 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection"); RNA_def_boolean(ot->srna, "overlap", 0, "Allow Overlap", "Don't correct overlap on new sequence strips"); - - if(flag & SEQPROP_FILES) - RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier) @@ -411,8 +407,8 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } @@ -466,8 +462,8 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } @@ -573,8 +569,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); - sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 6a69d32d307..a58bec9eeb9 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -392,205 +392,6 @@ void recurs_sel_seq(Sequence *seqm) } } -int event_to_efftype(int event) -{ - if(event==2) return SEQ_CROSS; - if(event==3) return SEQ_GAMCROSS; - if(event==4) return SEQ_ADD; - if(event==5) return SEQ_SUB; - if(event==6) return SEQ_MUL; - if(event==7) return SEQ_ALPHAOVER; - if(event==8) return SEQ_ALPHAUNDER; - if(event==9) return SEQ_OVERDROP; - if(event==10) return SEQ_PLUGIN; - if(event==13) return SEQ_WIPE; - if(event==14) return SEQ_GLOW; - if(event==15) return SEQ_TRANSFORM; - if(event==16) return SEQ_COLOR; - if(event==17) return SEQ_SPEED; - if(event==18) return SEQ_ADJUSTMENT; - return 0; -} - -#if 0 -static void reload_sound_strip(Scene *scene, char *name) -{ - Editing *ed; - Sequence *seq, *seqact; - SpaceFile *sfile; - Sequence *last_seq= seq_active_get(scene); - - ed= scene->ed; - - if(last_seq==0 || last_seq->type!=SEQ_SOUND) return; - seqact= last_seq; /* last_seq changes in alloc_sequence */ - - /* search sfile */ -// sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); - if(sfile==0) return; - - waitcursor(1); - - seq = sfile_to_snd_sequence(sfile, seqact->start, seqact->machine); - printf("seq->type: %i\n", seq->type); - if(seq && seq!=seqact) { - /* i'm not sure about this one, seems to work without it -- sgefant */ - seq_free_strip(seqact->strip); - - seqact->strip= seq->strip; - - seqact->len= seq->len; - calc_sequence(scene, seqact); - - seq->strip= 0; - seq_free_sequence(scene, seq); - BLI_remlink(ed->seqbasep, seq); - - seq= ed->seqbasep->first; - - } - - waitcursor(0); - -} -#endif - -static void reload_image_strip(Scene *scene, char *UNUSED(name)) -{ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq=NULL, *seqact; - SpaceFile *sfile=NULL; - Sequence *last_seq= seq_active_get(scene); - - - - if(last_seq==NULL || last_seq->type!=SEQ_IMAGE) return; - seqact= last_seq; /* last_seq changes in alloc_sequence */ - - /* search sfile */ -// sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); - if(sfile == NULL) return; - - waitcursor(1); - -// seq= sfile_to_sequence(scene, sfile, seqact->start, seqact->machine, 1); // XXX ADD BACK - if(seq && seq!=seqact) { - seq_free_strip(seqact->strip); - - seqact->strip= seq->strip; - - seqact->len= seq->len; - calc_sequence(scene, seqact); - - seq->strip= NULL; - seq_free_sequence(scene, seq); - BLI_remlink(ed->seqbasep, seq); - - update_changed_seq_and_deps(scene, seqact, 1, 1); - } - waitcursor(0); - -} - - -static void change_sequence(Scene *scene) -{ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *last_seq= seq_active_get(scene); - Scene *sce; - short event; - - if(last_seq == NULL) return; - - if(last_seq->type & SEQ_EFFECT) { - event = pupmenu("Change Effect%t" - "|Switch A <-> B %x1" - "|Switch B <-> C %x10" - "|Plugin%x11" - "|Recalculate%x12" - "|Cross%x2" - "|Gamma Cross%x3" - "|Add%x4" - "|Sub%x5" - "|Mul%x6" - "|Alpha Over%x7" - "|Alpha Under%x8" - "|Alpha Over Drop%x9" - "|Wipe%x13" - "|Glow%x14" - "|Transform%x15" - "|Color Generator%x16" - "|Speed Control%x17" - "|Adjustment Layer%x18"); - if(event > 0) { - if(event==1) { - SWAP(Sequence *,last_seq->seq1,last_seq->seq2); - } - else if(event==10) { - SWAP(Sequence *,last_seq->seq2,last_seq->seq3); - } - else if(event==11) { - activate_fileselect( - FILE_SPECIAL, "Select Plugin", - U.plugseqdir, change_plugin_seq); - } - else if(event==12); - /* recalculate: only new_stripdata */ - else { - /* free previous effect and init new effect */ - struct SeqEffectHandle sh; - - if (get_sequence_effect_num_inputs( - last_seq->type) - < get_sequence_effect_num_inputs( - event_to_efftype(event))) { - error("New effect needs more " - "input strips!"); - } else { - sh = get_sequence_effect(last_seq); - sh.free(last_seq); - - last_seq->type - = event_to_efftype(event); - - sh = get_sequence_effect(last_seq); - sh.init(last_seq); - } - } - - update_changed_seq_and_deps(scene, last_seq, 0, 1); - } - } - else if(last_seq->type == SEQ_IMAGE) { - if(okee("Change images")) { - activate_fileselect(FILE_SPECIAL, - "Select Images", - ed->act_imagedir, - reload_image_strip); - } - } - else if(last_seq->type == SEQ_MOVIE) { - ; - } - else if(last_seq->type == SEQ_SCENE) { - event= pupmenu("Change Scene%t|Update Start and End"); - - if(event==1) { - sce= last_seq->scene; - - last_seq->len= sce->r.efra - sce->r.sfra + 1; - last_seq->sfra= sce->r.sfra; - - /* bad code to change seq->len? update_changed_seq_and_deps() expects the strip->len to be OK */ - new_tstripdata(last_seq); - - update_changed_seq_and_deps(scene, last_seq, 1, 1); - - } - } - -} - int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { Editing *ed = seq_give_editing(scene, FALSE); @@ -1103,6 +904,19 @@ int sequencer_edit_poll(bContext *C) return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL); } +int sequencer_strip_poll(bContext *C) +{ + Editing *ed; + return (((ed= seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); +} + +int sequencer_strip_has_path_poll(bContext *C) +{ + Editing *ed; + Sequence *seq; + return (((ed= seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && ((seq= ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); +} + int sequencer_view_poll(bContext *C) { SpaceSeq *sseq= CTX_wm_space_seq(C); @@ -2830,3 +2644,224 @@ void SEQUENCER_OT_view_ghost_border(wmOperatorType *ot) /* rna */ WM_operator_properties_gesture_border(ot, FALSE); } + + +/* change ops */ + +static EnumPropertyItem prop_change_effect_input_types[] = { + {0, "A_B", 0, "A -> B", ""}, + {1, "B_C", 0, "B -> C", ""}, + {2, "A_C", 0, "A -> C", ""}, + {0, NULL, 0, NULL, NULL} +}; + +static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + + Sequence **seq_1, **seq_2; + + switch(RNA_enum_get(op->ptr, "swap")) { + case 0: + seq_1= &seq->seq1; + seq_2= &seq->seq2; + break; + case 1: + seq_1= &seq->seq2; + seq_2= &seq->seq3; + break; + default: /* 2 */ + seq_1= &seq->seq1; + seq_2= &seq->seq3; + break; + } + + if(*seq_1 == NULL || *seq_2 == NULL) { + BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap"); + return OPERATOR_CANCELLED; + } + else { + SWAP(Sequence *, *seq_1, *seq_2); + } + + update_changed_seq_and_deps(scene, seq, 0, 1); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Effect Input"; + ot->idname= "SEQUENCER_OT_change_effect_input"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_effect_input_exec; + ot->poll= sequencer_effect_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ot->prop= RNA_def_enum(ot->srna, "swap", prop_change_effect_input_types, 0, "Swap", "The effect inputs to swap"); +} + +static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + const int new_type= RNA_enum_get(op->ptr, "type"); + + /* free previous effect and init new effect */ + struct SeqEffectHandle sh; + + if ((seq->type & SEQ_EFFECT) == 0) { + return OPERATOR_CANCELLED; + } + + /* can someone explain the logic behind only allowing to increse this, + * copied from 2.4x - campbell */ + if (get_sequence_effect_num_inputs(seq->type) < + get_sequence_effect_num_inputs(new_type) + ) { + BKE_report(op->reports, RPT_ERROR, "New effect needs more input strips"); + return OPERATOR_CANCELLED; + } + else { + sh = get_sequence_effect(seq); + sh.free(seq); + + seq->type= new_type; + + sh = get_sequence_effect(seq); + sh.init(seq); + } + + /* update */ + update_changed_seq_and_deps(scene, seq, 0, 1); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Effect Type"; + ot->idname= "SEQUENCER_OT_change_effect_type"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_effect_type_exec; + ot->poll= sequencer_effect_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + ot->prop= RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); +} + +static int sequencer_change_path_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq= seq_active_get(scene); + + if(seq->type == SEQ_IMAGE) { + char directory[FILE_MAX]; + const int len= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + StripElem *se; + + if(len==0) + return OPERATOR_CANCELLED; + + RNA_string_get(op->ptr, "directory", directory); + BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir)); + + if(seq->strip->stripdata) { + MEM_freeN(seq->strip->stripdata); + } + seq->strip->stripdata= se= MEM_callocN(len*sizeof(StripElem), "stripelem"); + + RNA_BEGIN(op->ptr, itemptr, "files") { + char *filename= RNA_string_get_alloc(&itemptr, "name", NULL, 0); + BLI_strncpy(se->name, filename, sizeof(se->name)); + MEM_freeN(filename); + se++; + } + RNA_END; + + /* correct start/end frames so we dont move + * important not to set seq->len= len; allow the function to handle it */ + reload_sequence_new_file(scene, seq, TRUE); + + calc_sequence(scene, seq); + + /* important else we dont get the imbuf cache flushed */ + free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); + } + else { + /* lame, set rna filepath */ + PointerRNA seq_ptr; + char filepath[FILE_MAX]; + + RNA_pointer_create(&scene->id, &RNA_Sequence, seq, &seq_ptr); + + RNA_string_get(op->ptr, "filepath", filepath); + RNA_string_set(&seq_ptr, "filepath", filepath); + } + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + +static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + Scene *scene= CTX_data_scene(C); + Sequence *seq= seq_active_get(scene); + + RNA_string_set(op->ptr, "directory", seq->strip->dir); + + /* set default display depending on seq type */ + if(seq->type == SEQ_IMAGE) { + RNA_boolean_set(op->ptr, "filter_movie", 0); + } + else { + RNA_boolean_set(op->ptr, "filter_image", 0); + } + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +void SEQUENCER_OT_change_path(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Change Data/Files"; + ot->idname= "SEQUENCER_OT_change_path"; + ot->description=""; + + /* api callbacks */ + ot->exec= sequencer_change_path_exec; + ot->invoke= sequencer_change_path_invoke; + ot->poll= sequencer_strip_has_path_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES); +} diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 209b39662aa..6eef2bb8361 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -70,6 +70,8 @@ int seq_effect_find_selected(struct Scene *scene, struct Sequence *activeseq, in /* operator helpers */ int sequencer_edit_poll(struct bContext *C); +int sequencer_strip_poll(struct bContext *C); +int sequencer_strip_has_path_poll(struct bContext *C); int sequencer_view_poll(struct bContext *C); /* externs */ @@ -108,6 +110,10 @@ void SEQUENCER_OT_view_selected(struct wmOperatorType *ot); void SEQUENCER_OT_view_zoom_ratio(struct wmOperatorType *ot); void SEQUENCER_OT_view_ghost_border(struct wmOperatorType *ot); +void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot); +void SEQUENCER_OT_change_effect_type(struct wmOperatorType *ot); +void SEQUENCER_OT_change_path(struct wmOperatorType *ot); + void SEQUENCER_OT_copy(struct wmOperatorType *ot); void SEQUENCER_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index f5c26cb17d3..ebf400ad5ff 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -86,6 +86,10 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio); WM_operatortype_append(SEQUENCER_OT_view_ghost_border); + WM_operatortype_append(SEQUENCER_OT_change_effect_input); + WM_operatortype_append(SEQUENCER_OT_change_effect_type); + WM_operatortype_append(SEQUENCER_OT_change_path); + /* sequencer_select.c */ WM_operatortype_append(SEQUENCER_OT_select_all_toggle); WM_operatortype_append(SEQUENCER_OT_select_inverse); @@ -240,6 +244,8 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); + + WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0); kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame"); diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index a954c07c98d..9d52f45665f 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1728,6 +1728,21 @@ static int Vector_setLength(VectorObject *self, PyObject *value) return 0; } +/* vector.length_squared */ +static PyObject *Vector_getLengthSquared(VectorObject *self, void *UNUSED(closure)) +{ + double dot = 0.0f; + int i; + + if(BaseMath_ReadCallback(self) == -1) + return NULL; + + for(i = 0; i < self->size; i++){ + dot += (double)(self->vec[i] * self->vec[i]); + } + return PyFloat_FromDouble(dot); +} + /* Get a new Vector according to the provided swizzle. This function has little error checking, as we are in control of the inputs: the closure is set by us in Vector_createSwizzleGetSeter. */ @@ -1851,6 +1866,7 @@ static PyGetSetDef Vector_getseters[] = { {(char *)"z", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector Z axis (3D Vectors only).\n\n:type: float", (void *)2}, {(char *)"w", (getter)Vector_getAxis, (setter)Vector_setAxis, (char *)"Vector W axis (4D Vectors only).\n\n:type: float", (void *)3}, {(char *)"length", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, + {(char *)"length_squared", (getter)Vector_getLengthSquared, (setter)NULL, (char *)"Vector length squared (v.dot(v)).\n\n:type: float", NULL}, {(char *)"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, (char *)"Vector Length.\n\n:type: float", NULL}, {(char *)"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, (char *)BaseMathObject_Wrapped_doc, NULL}, {(char *)"owner", (getter)BaseMathObject_getOwner, (setter)NULL, (char *)BaseMathObject_Owner_doc, NULL}, diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d8c6933a93d..e1b8cefca4b 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -222,6 +222,7 @@ wmOperator *WM_operator_last_redo(const struct bContext *C); #define WM_FILESEL_DIRECTORY (1 << 1) #define WM_FILESEL_FILENAME (1 << 2) #define WM_FILESEL_FILEPATH (1 << 3) +#define WM_FILESEL_FILES (1 << 4) /* operator as a python command (resultuing string must be free'd) */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 2fb0a1b2ab9..2dfe4d8ccdc 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1009,7 +1009,8 @@ void WM_keyconfig_update(wmWindowManager *wm) addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid); /* diff */ - wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km); + if(defaultmap) + wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km); } } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 66467b310ee..105b2e8189a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -811,6 +811,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, if(flag & WM_FILESEL_FILENAME) RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file"); + if(flag & WM_FILESEL_FILES) + RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); + if (action == FILE_SAVE) { prop= RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -1748,14 +1751,12 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->flag |= OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending"); RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects"); RNA_def_boolean(ot->srna, "active_layer", 1, "Active Layer", "Put the linked objects on the active layer"); RNA_def_boolean(ot->srna, "instance_groups", 1, "Instance Groups", "Create instances for each group as a DupliGroup"); - - RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", ""); } /* *************** recover last session **************** */ |