/* (de)select operator */ static int sequencer_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; int desel = 0; for(seq= ed->seqbasep->first; seq; seq=seq->next) { if(seq->flag & SEQ_ALLSEL) { desel= 1; break; } } for(seq= ed->seqbasep->first; seq; seq=seq->next) { if (desel) { seq->flag &= ~SEQ_ALLSEL; } else { seq->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); seq->flag |= SELECT; } } WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER|NA_SELECTED, scene); return OPERATOR_FINISHED; }
static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq, *p; Editing *ed= seq_give_editing(scene, FALSE); seq= (Sequence*)te->directdata; if(set==0) { if(seq->flag & SELECT) return(1); return(0); } // XXX select_single_seq(seq, 1); p= ed->seqbasep->first; while(p) { if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->next; continue; } // if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); p= p->next; } return(0); }
static void UNUSED_FUNCTION(select_single_seq)(Scene *scene, Sequence *seq, int deselect_all) /* BRING BACK */ { Editing *ed= seq_give_editing(scene, FALSE); if(deselect_all) deselect_all_seq(scene); seq_active_set(scene, seq); if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) { if(seq->strip) BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } else if(seq->type==SEQ_SOUND) { if(seq->strip) BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); } seq->flag|= SELECT; recurs_sel_seq(seq); }
/* (de)select operator */ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); Scene *scene = CTX_data_scene(C); Editing *ed = seq_give_editing(scene, FALSE); Sequence *seq; if (action == SEL_TOGGLE) { action = SEL_SELECT; for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SEQ_ALLSEL) { action = SEL_DESELECT; break; } } } for (seq = ed->seqbasep->first; seq; seq = seq->next) { switch (action) { case SEL_SELECT: seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL); seq->flag |= SELECT; break; case SEL_DESELECT: seq->flag &= ~SEQ_ALLSEL; break; case SEL_INVERT: if (seq->flag & SEQ_ALLSEL) { seq->flag &= ~SEQ_ALLSEL; } else { seq->flag &= ~(SEQ_LEFTSEL + SEQ_RIGHTSEL); seq->flag |= SELECT; } break; } } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); return OPERATOR_FINISHED; }
int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { bScreen *sc= CTX_wm_screen(C); Scene *scene= sc->scene; Base *base; unsigned int lay = scene->lay; #if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */ Object *obact= CTX_data_active_object(C); Object *obedit= CTX_data_edit_object(C); base= CTX_data_active_base(C); #else Object *obedit= scene->obedit; Object *obact= OBACT; base= BASACT; #endif if(CTX_data_dir(member)) { CTX_data_dir_set(result, screen_context_dir); return 1; } else if(CTX_data_equals(member, "scene")) { CTX_data_id_pointer_set(result, &scene->id); return 1; } else if(CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { int visible_objects= CTX_data_equals(member, "visible_objects"); for(base=scene->base.first; base; base=base->next) { if(((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & scene->lay)) { if(visible_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { int selectable_objects= CTX_data_equals(member, "selectable_objects"); for(base=scene->base.first; base; base=base->next) { if(base->lay & lay) { if((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { if(selectable_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } else if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { int selected_objects= CTX_data_equals(member, "selected_objects"); for(base=scene->base.first; base; base=base->next) { if((base->flag & SELECT) && (base->lay & scene->lay)) { if(selected_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } else if(CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { int selected_editable_objects= CTX_data_equals(member, "selected_editable_objects"); for(base=scene->base.first; base; base=base->next) { if((base->flag & SELECT) && (base->lay & scene->lay)) { if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { if(0==object_is_libdata(base->object)) { if(selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); } } } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } else if(CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone=NULL; int editable_bones= CTX_data_equals(member, "editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled * so that most users of this data don't need to explicitly check for it themselves. * * We need to make sure that these mirrored copies are not selected, otherwise some * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (editable_bones) { /* only selected + editable */ if (EBONE_EDITABLE(ebone)) { CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } else { /* only include bones if visible */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone=NULL; int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled * so that most users of this data don't need to explicitly check for it themselves. * * We need to make sure that these mirrored copies are not selected, otherwise some * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (selected_editable_bones) { /* only selected + editable */ if (EBONE_EDITABLE(ebone)) { CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } else { /* only include bones if selected */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "visible_pose_bones")) { Object *obpose= ED_object_pose_armature(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "selected_pose_bones")) { Object *obpose= ED_object_pose_armature(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "active_bone")) { if(obact && obact->type == OB_ARMATURE) { bArmature *arm= obact->data; if(arm->edbo) { if(arm->act_edbone) { CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone); return 1; } } else { if(arm->act_bone) { CTX_data_pointer_set(result, &arm->id, &RNA_Bone, arm->act_bone); return 1; } } } } else if(CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; Object *obpose= ED_object_pose_armature(obact); pchan= get_active_posechannel(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); return 1; } } else if(CTX_data_equals(member, "active_base")) { if(base) CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, base); return 1; } else if(CTX_data_equals(member, "active_object")) { if(obact) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "object")) { if(obact) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "edit_object")) { /* convenience for now, 1 object per scene in editmode */ if(obedit) CTX_data_id_pointer_set(result, &obedit->id); return 1; } else if(CTX_data_equals(member, "sculpt_object")) { if(obact && (obact->mode & OB_MODE_SCULPT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "vertex_paint_object")) { if(obact && (obact->mode & OB_MODE_VERTEX_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "weight_paint_object")) { if(obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "image_paint_object")) { if(obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "particle_edit_object")) { if(obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } else if(CTX_data_equals(member, "sequences")) { Editing *ed= seq_give_editing(scene, FALSE); if(ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "selected_sequences")) { Editing *ed= seq_give_editing(scene, FALSE); if(ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else if(CTX_data_equals(member, "selected_editable_sequences")) { Editing *ed= seq_give_editing(scene, FALSE); if(ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } } else { return 0; /* not found */ } return -1; /* found but not available */ }
/* perform syncing updates for F-Curves */ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) { FCurve *fcu= (FCurve *)ale->data; ID *owner_id= ale->id; /* major priority is selection status, so refer to the checks done in anim_filter.c * skip_fcurve_selected_data() for reference about what's going on here... */ if (ELEM3(NULL, fcu, fcu->rna_path, owner_id)) return; if (GS(owner_id->name) == ID_OB) { Object *ob= (Object *)owner_id; /* only affect if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { bPoseChannel *pchan; char *bone_name; /* get bone-name, and check if this bone is selected */ bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); pchan= get_pose_channel(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* F-Curve selection depends on whether the bone is selected */ if ((pchan) && (pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; } } } else if (GS(owner_id->name) == ID_SCE) { Scene *scene = (Scene *)owner_id; /* only affect if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; char *seq_name; /* get strip name, and check if this strip is selected */ seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); /* can only add this F-Curve if it is selected */ if (seq) { if (seq->flag & SELECT) fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; } } } else if (GS(owner_id->name) == ID_NT) { bNodeTree *ntree = (bNodeTree *)owner_id; /* check for selected nodes */ if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) { bNode *node; char *node_name; /* get strip name, and check if this strip is selected */ node_name= BLI_getQuotedStr(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); /* can only add this F-Curve if it is selected */ if (node) { if (node->flag & NODE_SELECT) fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; } } } }
/* Draw Timeline/Strip Editor Mode for Sequencer */ void draw_timeline_seq(const bContext *C, ARegion *ar) { Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); SpaceSeq *sseq= CTX_wm_space_seq(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; short unit=0, flag=0; float col[3]; /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); if (ed && ed->metastack.first) glClearColor(col[0], col[1], col[2]-0.1f, 0.0f); else glClearColor(col[0], col[1], col[2], 0.0f); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); /* calculate extents of sequencer strips/data * NOTE: needed for the scrollers later */ boundbox_seq(scene, &v2d->tot); /* draw backdrop */ draw_seq_backdrop(v2d); /* regular grid-pattern over the rest of the view (i.e. 25-frame grid lines) */ // NOTE: the gridlines are currently spaced every 25 frames, which is only fine for 25 fps, but maybe not for 30... UI_view2d_constant_grid_draw(v2d); seq_draw_sfra_efra(scene, v2d); /* sequence strips (if there is data available to be drawn) */ if (ed) { /* draw the data */ draw_seq_strips(C, ed, ar); /* text draw cached (for sequence names), in pixelspace now */ UI_view2d_text_cache_draw(ar); } /* current frame */ UI_view2d_view_ortho(v2d); if ((sseq->flag & SEQ_DRAWFRAMES)==0) flag |= DRAWCFRA_UNIT_SECONDS; if ((sseq->flag & SEQ_NO_DRAW_CFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); draw_markers_time(C, DRAW_MARKERS_LINES); /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d); /* overlap playhead */ if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over= (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs; glColor3f(0.2, 0.2, 0.2); // glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax); glBegin(GL_LINES); glVertex2f(cfra_over, v2d->cur.ymin); glVertex2f(cfra_over, v2d->cur.ymax); glEnd(); } /* reset view matrix */ UI_view2d_view_restore(C); /* scrollers */ unit= (sseq->flag & SEQ_DRAWFRAMES)? V2D_UNIT_FRAMES : V2D_UNIT_SECONDSSEQ; scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); }
static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { View2D *v2d= UI_view2d_fromcontext(C); Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); short extend= RNA_boolean_get(op->ptr, "extend"); short linked_handle= RNA_boolean_get(op->ptr, "linked_handle"); short left_right= RNA_boolean_get(op->ptr, "left_right"); short linked_time= RNA_boolean_get(op->ptr, "linked_time"); Sequence *seq,*neighbor, *act_orig; int hand,sel_side; TimeMarker *marker; if(ed==NULL) return OPERATOR_CANCELLED; marker=find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now seq= find_nearest_seq(scene, v2d, &hand, event->mval); // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip if(seq && linked_time && left_right) left_right= FALSE; if (marker) { int oldflag; /* select timeline marker */ if (extend) { oldflag= marker->flag; if (oldflag & SELECT) marker->flag &= ~SELECT; else marker->flag |= SELECT; } else { /* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */ marker->flag |= SELECT; } } else if (left_right) { /* use different logic for this */ float x; deselect_all_seq(scene); UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); SEQP_BEGIN(ed, seq) { if (x < CFRA) { if(seq->enddisp < CFRA) { seq->flag |= SELECT; recurs_sel_seq(seq); } } else { if(seq->startdisp > CFRA) { seq->flag |= SELECT; recurs_sel_seq(seq); } } } SEQ_END { SpaceSeq *sseq= CTX_wm_space_seq(C); if (sseq && sseq->flag & SEQ_MARKER_TRANS) { TimeMarker *tmarker; for (tmarker= scene->markers.first; tmarker; tmarker= tmarker->next) { if( ((x < CFRA) && tmarker->frame < CFRA) || ((x >= CFRA) && tmarker->frame >= CFRA) ) { tmarker->flag |= SELECT; } else { tmarker->flag &= ~SELECT; } } } } } else {