本文整理汇总了C++中CTX_wm_area函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_area函数的具体用法?C++ CTX_wm_area怎么用?C++ CTX_wm_area使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTX_wm_area函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pose_slide_init
/* operator init */
static int pose_slide_init(bContext *C, wmOperator *op, short mode)
{
tPoseSlideOp *pso;
bAction *act = NULL;
/* init slide-op data */
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
/* get info from context */
pso->scene = CTX_data_scene(C);
pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
pso->arm = (pso->ob) ? pso->ob->data : NULL;
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
pso->cframe = pso->scene->r.cfra;
pso->mode = mode;
/* set range info from property values - these may get overridden for the invoke() */
pso->percentage = RNA_float_get(op->ptr, "percentage");
pso->prevFrame = RNA_int_get(op->ptr, "prev_frame");
pso->nextFrame = RNA_int_get(op->ptr, "next_frame");
/* check the settings from the context */
if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
return 0;
else
act = pso->ob->adt->action;
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act);
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pso->ob->pose->flag |= POSE_LOCKED;
pso->ob->pose->flag &= ~POSE_DO_UNLOCK;
/* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
* to the caller of this (usually only invoke() will do it, to make things more efficient).
*/
BLI_dlrbTree_init(&pso->keys);
/* initialise numeric input */
initNumInput(&pso->num);
pso->num.idx_max = 0; /* one axis */
pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */
/* return status is whether we've got all the data we were requested to get */
return 1;
}
示例2: file_highlight_invoke
static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
SpaceFile *sfile= CTX_wm_space_file(C);
if(!file_hilight_set(sfile, ar, event->x, event->y))
return OPERATOR_CANCELLED;
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
示例3: render_view3d_do
static void render_view3d_do(RenderEngine *engine, const bContext *C)
{
wmJob *wm_job;
RenderPreview *rp;
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
int width = ar->winx, height = ar->winy;
int divider = 1;
int resolution_threshold = scene->r.preview_start_resolution *
scene->r.preview_start_resolution;
if (CTX_wm_window(C) == NULL)
return;
if (!render_view3d_flag_changed(engine, C))
return;
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_region(C), "Render Preview",
WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW);
rp = MEM_callocN(sizeof(RenderPreview), "render preview");
rp->job = wm_job;
while (width * height > resolution_threshold) {
width = max_ii(1, width / 2);
height = max_ii(1, height / 2);
divider *= 2;
}
/* customdata for preview thread */
rp->scene = scene;
rp->engine = engine;
rp->sa = CTX_wm_area(C);
rp->ar = CTX_wm_region(C);
rp->v3d = rp->sa->spacedata.first;
rp->rv3d = CTX_wm_region_view3d(C);
rp->bmain = CTX_data_main(C);
rp->resolution_divider = divider;
rp->start_resolution_divider = divider;
rp->has_freestyle = (scene->r.mode & R_EDGE_FRS) != 0;
copy_m4_m4(rp->viewmat, rp->rv3d->viewmat);
/* clear info text */
engine->text[0] = '\0';
/* setup job */
WM_jobs_customdata_set(wm_job, rp, render_view3d_free);
WM_jobs_timer(wm_job, 0.1, NC_SPACE | ND_SPACE_VIEW3D, NC_SPACE | ND_SPACE_VIEW3D);
WM_jobs_callbacks(wm_job, render_view3d_startjob, NULL, NULL, NULL);
WM_jobs_start(CTX_wm_manager(C), wm_job);
engine->flag &= ~RE_ENGINE_DO_UPDATE;
}
示例4: change_frame_seq_preview_begin
static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
bScreen *screen = CTX_wm_screen(C);
if (sa && sa->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = sa->spacedata.first;
if (ED_space_sequencer_check_show_strip(sseq)) {
ED_sequencer_special_preview_set(C, event->mval);
}
}
if (screen)
screen->scrubbing = true;
}
示例5: add_feather_vertex_invoke
static int add_feather_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
float co[2];
ED_mask_mouse_pos(sa, ar, event->mval, co);
RNA_float_set_array(op->ptr, "location", co);
return add_feather_vertex_exec(C, op);
}
示例6: change_frame_poll
/* Check if the operator can be run from the current context */
static int change_frame_poll(bContext *C)
{
ScrArea *curarea= CTX_wm_area(C);
/* XXX temp? prevent changes during render */
if(G.rendering) return 0;
/* as long as there is an active area, and it isn't a Graph Editor
* (since the Graph Editor has its own version which does extra stuff),
* we're fine
*/
return ((curarea) && (curarea->spacetype != SPACE_IPO));
}
示例7: CTX_wm_area
/* Temporary wrapper for driver operators for buttons to make it easier to create
* such drivers by rerouting all paths through the active object instead so that
* they will get picked up by the dependency system.
*
* < C: context pointer - for getting active data
* <> ptr: RNA pointer for property's datablock. May be modified as result of path remapping.
* < prop: RNA definition of property to add for
*
* > returns: MEM_alloc'd string representing the path to the property from the given PointerRNA
*/
static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
{
ID *id = (ID *)ptr->id.data;
ScrArea *sa = CTX_wm_area(C);
/* get standard path which may be extended */
char *basepath = RNA_path_from_ID_to_property(ptr, prop);
char *path = basepath; /* in case no remapping is needed */
/* Remapping will only be performed in the Properties Editor, as only this
* restricts the subspace of options to the 'active' data (a manageable state)
*/
// TODO: watch out for pinned context?
if ((sa) && (sa->spacetype == SPACE_BUTS)) {
Object *ob = CTX_data_active_object(C);
if (ob && id) {
/* only id-types which can be remapped to go through objects should be considered */
switch (GS(id->name)) {
case ID_TE: /* textures */
{
Material *ma = give_current_material(ob, ob->actcol);
Tex *tex = give_current_material_texture(ma);
/* assumes: texture will only be shown if it is active material's active texture it's ok */
if ((ID *)tex == id) {
/* create new path */
// TODO: use RNA path functions to construct step by step instead?
// FIXME: maybe this isn't even needed anymore...
path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s",
ma->id.name + 2, tex->id.name + 2, basepath);
/* free old one */
MEM_freeN(basepath);
}
}
break;
}
/* fix RNA pointer, as we've now changed the ID root by changing the paths */
if (basepath != path) {
/* rebase provided pointer so that it starts from object... */
RNA_pointer_create(&ob->id, ptr->type, ptr->data, ptr);
}
}
}
/* the path should now have been corrected for use */
return path;
}
示例8: select_report_pick_exec
static int select_report_pick_exec(bContext *C, wmOperator *op)
{
int report_index = RNA_int_get(op->ptr, "report_index");
Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index);
if (!report)
return OPERATOR_CANCELLED;
report->flag ^= SELECT; /* toggle */
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
示例9: clip_prefetch_modal
static int clip_prefetch_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH))
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
/* running render */
switch (event->type) {
case ESCKEY:
return OPERATOR_RUNNING_MODAL;
}
return OPERATOR_PASS_THROUGH;
}
示例10: ANIM_headerUI_standard_buttons
/* standard header buttons for Animation Editors */
short ANIM_headerUI_standard_buttons (const bContext *C, bDopeSheet *ads, uiBlock *block, short xco, short yco)
{
Main *mainptr= CTX_data_main(C);
ScrArea *sa= CTX_wm_area(C);
short nlaActive= ((sa) && (sa->spacetype==SPACE_NLA));
/* check if the DopeSheet data exists, just in case... */
if (ads) {
/* more 'generic' filtering options */
if (nlaActive) uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOG, ADS_FILTER_ONLYSEL, B_REDR, ICON_RESTRICT_SELECT_OFF, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Only display selected Objects");
if (nlaActive) uiDefIconButBitI(block, TOGN, ADS_FILTER_NLA_NOACT, B_REDR, ICON_ACTION, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Include AnimData blocks with no NLA Data");
if (nlaActive) uiBlockEndAlign(block);
xco += 5;
/* datatype based - only available datatypes are shown */
uiBlockBeginAlign(block);
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSCE, B_REDR, ICON_SCENE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Scene Animation");
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOWOR, B_REDR, ICON_WORLD_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display World Animation");
if (mainptr && mainptr->key.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOSHAPEKEYS, B_REDR, ICON_SHAPEKEY_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display ShapeKeys");
if (mainptr && mainptr->mat.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMAT, B_REDR, ICON_MATERIAL_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Material Data");
if (mainptr && mainptr->lamp.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOLAM, B_REDR, ICON_LAMP_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Lamp Data");
if (mainptr && mainptr->camera.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCAM, B_REDR, ICON_CAMERA_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Camera Data");
if (mainptr && mainptr->curve.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOCUR, B_REDR, ICON_CURVE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Curve Data");
if (mainptr && mainptr->mball.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOMBA, B_REDR, ICON_META_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display MetaBall Data");
if (mainptr && mainptr->armature.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOARM, B_REDR, ICON_ARMATURE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Armature Data");
if (mainptr && mainptr->particle.first)
uiDefIconButBitI(block, TOGN, ADS_FILTER_NOPART, B_REDR, ICON_PARTICLE_DATA, (short)(xco+=XIC),yco,XIC,YIC, &(ads->filterflag), 0, 0, 0, 0, "Display Particle Data");
uiBlockEndAlign(block);
xco += 30;
}
else {
// XXX this case shouldn't happen at all... for now, just pad out same amount of space
printf("ERROR: dopesheet data not available when drawing Animation Editor header \n");
xco += 11*XIC + 30;
}
// TODO: include auto-snapping menu here too...
/* return the width of the buttons */
return xco;
}
示例11: ED_animedit_unlink_action
void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports)
{
ScrArea *sa = CTX_wm_area(C);
/* If the old action only has a single user (that it's about to lose),
* warn user about it
*
* TODO: Maybe we should just save it for them? But then, there's the problem of
* trying to get rid of stuff that's actually unwanted!
*/
if (act->id.us == 1) {
BKE_reportf(reports, RPT_WARNING,
"Action '%s' will not be saved, create Fake User or Stash in NLA Stack to retain",
act->id.name + 2);
}
/* If in Tweak Mode, don't unlink. Instead, this
* becomes a shortcut to exit Tweak Mode instead
*/
if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) {
/* Exit Tweak Mode */
BKE_nla_tweakmode_exit(adt);
/* Flush this to the Action Editor (if that's where this change was initiated) */
if (sa->spacetype == SPACE_ACTION) {
actedit_change_action(C, NULL);
}
}
else {
/* Unlink normally - Setting it to NULL should be enough to get the old one unlinked */
if (sa->spacetype == SPACE_ACTION) {
/* clear action editor -> action */
actedit_change_action(C, NULL);
}
else {
/* clear AnimData -> action */
PointerRNA ptr;
PropertyRNA *prop;
/* create AnimData RNA pointers */
RNA_pointer_create(id, &RNA_AnimData, adt, &ptr);
prop = RNA_struct_find_property(&ptr, "action");
/* clear... */
RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL);
RNA_property_update(C, &ptr, prop);
}
}
}
示例12: toggle_time_exec
static int toggle_time_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *curarea= CTX_wm_area(C);
if (curarea == NULL)
return OPERATOR_CANCELLED;
/* simply toggle draw frames flag in applicable spaces */
// XXX or should relevant spaces define their own version of this?
switch (curarea->spacetype) {
case SPACE_TIME: /* TimeLine */
{
SpaceTime *stime= CTX_wm_space_time(C);
stime->flag ^= TIME_DRAWFRAMES;
}
break;
case SPACE_ACTION: /* Action Editor */
{
SpaceAction *saction= CTX_wm_space_action(C);
saction->flag ^= SACTION_DRAWTIME;
}
break;
case SPACE_IPO: /* Graph Editor */
{
SpaceIpo *sipo= CTX_wm_space_graph(C);
sipo->flag ^= SIPO_DRAWTIME;
}
break;
case SPACE_NLA: /* NLA Editor */
{
SpaceNla *snla= CTX_wm_space_nla(C);
snla->flag ^= SNLA_DRAWTIME;
}
break;
case SPACE_SEQ: /* Sequencer */
{
SpaceSeq *sseq= CTX_wm_space_seq(C);
sseq->flag ^= SEQ_DRAWFRAMES;
}
break;
default: /* editor doesn't show frames */
return OPERATOR_CANCELLED; // XXX or should we pass through instead?
}
ED_area_tag_redraw(curarea);
return OPERATOR_FINISHED;
}
示例13: do_node_add
static void do_node_add(bContext *C, bNodeTemplate *ntemp)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
SpaceNode *snode = CTX_wm_space_node(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar;
bNode *node, *node_new;
/* get location to add node at mouse */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
wmWindow *win = CTX_wm_window(C);
int x = win->eventstate->x - ar->winrct.xmin;
int y = win->eventstate->y - ar->winrct.ymin;
if (y < 60) y += 60;
UI_view2d_region_to_view(&ar->v2d, x, y, &snode->cursor[0], &snode->cursor[1]);
}
}
/* store selection in temp test flag */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_SELECT) node->flag |= NODE_TEST;
else node->flag &= ~NODE_TEST;
}
node_new = node_add_node(snode, bmain, scene, ntemp, snode->cursor[0], snode->cursor[1]);
/* select previous selection before autoconnect */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) node->flag |= NODE_SELECT;
}
/* deselect after autoconnection */
for (node = snode->edittree->nodes.first; node; node = node->next) {
if (node->flag & NODE_TEST) node->flag &= ~NODE_SELECT;
}
/* once this is called from an operator, this should be removed */
if (node_new) {
char undostr[BKE_UNDO_STR_MAX];
BLI_snprintf(undostr, sizeof(undostr), "Add Node %s", nodeLabel(node_new));
BKE_write_undo(C, undostr);
}
snode_notify(C, snode);
snode_dag_update(C, snode);
}
示例14: ED_maskedit_mask_poll
int ED_maskedit_mask_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
if (sa) {
switch (sa->spacetype) {
case SPACE_CLIP:
return ED_space_clip_maskedit_mask_poll(C);
case SPACE_SEQ:
return ED_space_sequencer_maskedit_mask_poll(C);
case SPACE_IMAGE:
return ED_space_image_maskedit_mask_poll(C);
}
}
return FALSE;
}
示例15: ED_mask_draw
void ED_mask_draw(const bContext *C,
const char draw_flag, const char draw_type)
{
ScrArea *sa = CTX_wm_area(C);
Mask *mask = CTX_data_edit_mask(C);
int width, height;
if (!mask)
return;
ED_mask_get_size(sa, &width, &height);
draw_masklays(C, mask, draw_flag, draw_type, width, height);
}