当前位置: 首页>>代码示例>>C++>>正文


C++ CTX_wm_screen函数代码示例

本文整理汇总了C++中CTX_wm_screen函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_screen函数的具体用法?C++ CTX_wm_screen怎么用?C++ CTX_wm_screen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CTX_wm_screen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ED_view3d_context_activate

bool ED_view3d_context_activate(bContext *C)
{
	bScreen *sc = CTX_wm_screen(C);
	ScrArea *sa = CTX_wm_area(C);
	ARegion *ar;

	/* sa can be NULL when called from python */
	if (sa == NULL || sa->spacetype != SPACE_VIEW3D) {
		sa = BKE_screen_find_big_area(sc, SPACE_VIEW3D, 0);
	}

	if (sa == NULL) {
		return false;
	}
	
	ar = BKE_area_find_region_active_win(sa);
	if (ar == NULL) {
		return false;
	}
	
	/* bad context switch .. */
	CTX_wm_area_set(C, sa);
	CTX_wm_region_set(C, ar);

	return true;
}
开发者ID:pawkoz,项目名称:dyplom,代码行数:26,代码来源:view3d_view.c

示例2: graph_panel_view

/* Graph Editor View Settings */
static void graph_panel_view(const bContext *C, Panel *pa)
{
	bScreen *sc = CTX_wm_screen(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	Scene *scene = CTX_data_scene(C);
	PointerRNA spaceptr, sceneptr;
	uiLayout *col, *sub, *row;
	
	/* get RNA pointers for use when creating the UI elements */
	RNA_id_pointer_create(&scene->id, &sceneptr);
	RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);

	/* 2D-Cursor */
	col = uiLayoutColumn(pa->layout, FALSE);
	uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
		
	sub = uiLayoutColumn(col, TRUE);
	uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
	uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");

	sub = uiLayoutColumn(col, TRUE);
	uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
	row = uiLayoutSplit(sub, 0.7f, TRUE);
	uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
	uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
	row = uiLayoutSplit(sub, 0.7f, TRUE);
	uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
	uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:30,代码来源:graph_buttons.c

示例3: depthdropper_depth_sample_pt

/**
 * \brief get the ID from the screen.
 */
static void depthdropper_depth_sample_pt(
    bContext *C, DepthDropper *ddr, int mx, int my, float *r_depth)
{
  /* we could use some clever */
  bScreen *screen = CTX_wm_screen(C);
  ScrArea *sa = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, mx, my);
  Scene *scene = CTX_data_scene(C);

  ScrArea *area_prev = CTX_wm_area(C);
  ARegion *ar_prev = CTX_wm_region(C);

  ddr->name[0] = '\0';

  if (sa) {
    if (sa->spacetype == SPACE_VIEW3D) {
      ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
      if (ar) {
        struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
        View3D *v3d = sa->spacedata.first;
        RegionView3D *rv3d = ar->regiondata;
        /* weak, we could pass in some reference point */
        const float *view_co = v3d->camera ? v3d->camera->obmat[3] : rv3d->viewinv[3];
        const int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin};
        float co[3];

        CTX_wm_area_set(C, sa);
        CTX_wm_region_set(C, ar);

        /* grr, always draw else we leave stale text */
        ED_region_tag_redraw(ar);

        view3d_operator_needs_opengl(C);

        if (ED_view3d_autodist(depsgraph, ar, v3d, mval, co, true, NULL)) {
          const float mval_center_fl[2] = {(float)ar->winx / 2, (float)ar->winy / 2};
          float co_align[3];

          /* quick way to get view-center aligned point */
          ED_view3d_win_to_3d(v3d, ar, co, mval_center_fl, co_align);

          *r_depth = len_v3v3(view_co, co_align);

          bUnit_AsString2(ddr->name,
                          sizeof(ddr->name),
                          (double)*r_depth,
                          4,
                          B_UNIT_LENGTH,
                          &scene->unit,
                          false);
        }
        else {
          BLI_strncpy(ddr->name, "Nothing under cursor", sizeof(ddr->name));
        }
      }
    }
  }

  CTX_wm_area_set(C, area_prev);
  CTX_wm_region_set(C, ar_prev);
}
开发者ID:dfelinto,项目名称:blender,代码行数:63,代码来源:interface_eyedropper_depth.c

示例4: CTX_wm_screen

/* would use BKE_screen_find_big_area(...) but this is too specific            */
static ScrArea *biggest_non_image_area(bContext *C)
{
	bScreen *sc = CTX_wm_screen(C);
	ScrArea *sa, *big = NULL;
	int size, maxsize = 0, bwmaxsize = 0;
	short foundwin = 0;

	for (sa = sc->areabase.first; sa; sa = sa->next) {
		if (sa->winx > 30 && sa->winy > 30) {
			size = sa->winx * sa->winy;
			if (sa->spacetype == SPACE_BUTS) {
				if (foundwin == 0 && size > bwmaxsize) {
					bwmaxsize = size;
					big = sa;
				}
			}
			else if (sa->spacetype != SPACE_IMAGE && size > maxsize) {
				maxsize = size;
				big = sa;
				foundwin = 1;
			}
		}
	}

	return big;
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:27,代码来源:render_view.c

示例5: uilist_draw_item

static void uilist_draw_item(uiList *ui_list, bContext *C, uiLayout *layout, PointerRNA *dataptr, PointerRNA *itemptr,
                             int icon, PointerRNA *active_dataptr, const char *active_propname, int index, int flt_flag)
{
	extern FunctionRNA rna_UIList_draw_item_func;

	PointerRNA ul_ptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
	func = &rna_UIList_draw_item_func; /* RNA_struct_find_function(&ul_ptr, "draw_item"); */

	RNA_parameter_list_create(&list, &ul_ptr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	RNA_parameter_set_lookup(&list, "layout", &layout);
	RNA_parameter_set_lookup(&list, "data", dataptr);
	RNA_parameter_set_lookup(&list, "item", itemptr);
	RNA_parameter_set_lookup(&list, "icon", &icon);
	RNA_parameter_set_lookup(&list, "active_data", active_dataptr);
	RNA_parameter_set_lookup(&list, "active_property", &active_propname);
	RNA_parameter_set_lookup(&list, "index", &index);
	RNA_parameter_set_lookup(&list, "flt_flag", &flt_flag);
	ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);

	RNA_parameter_list_free(&list);
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:26,代码来源:rna_ui.c

示例6: ED_view3d_context_activate

bool ED_view3d_context_activate(bContext *C)
{
	bScreen *sc = CTX_wm_screen(C);
	ScrArea *sa = CTX_wm_area(C);
	ARegion *ar;

	/* sa can be NULL when called from python */
	if (sa == NULL || sa->spacetype != SPACE_VIEW3D)
		for (sa = sc->areabase.first; sa; sa = sa->next)
			if (sa->spacetype == SPACE_VIEW3D)
				break;

	if (!sa)
		return false;
	
	for (ar = sa->regionbase.first; ar; ar = ar->next)
		if (ar->regiontype == RGN_TYPE_WINDOW)
			break;
	
	if (!ar)
		return false;
	
	/* bad context switch .. */
	CTX_wm_area_set(C, sa);
	CTX_wm_region_set(C, ar);

	return true;
}
开发者ID:greg100795,项目名称:blender-git,代码行数:28,代码来源:view3d_view.c

示例7: tree_element_active_world

static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
{
	TreeElement *tep;
	TreeStoreElem *tselem = NULL;
	Scene *sce = NULL;
	
	tep = te->parent;
	if (tep) {
		tselem = TREESTORE(tep);
		if (tselem->type == 0)
			sce = (Scene *)tselem->id;
	}
	
	if (set) {  // make new scene active
		if (sce && scene != sce) {
			ED_screen_set_scene(C, CTX_wm_screen(C), sce);
		}
	}
	
	if (tep == NULL || tselem->id == (ID *)scene) {
		if (set) {
// XXX			extern_set_butspace(F8KEY, 0);
		}
		else {
			return 1;
		}
	}
	return 0;
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:29,代码来源:outliner_select.c

示例8: read_undosave

static int read_undosave(bContext *C, UndoElem *uel)
{
	char mainstr[sizeof(G.main->name)];
	int success = 0, fileflags;
	
	/* This is needed so undoing/redoing doesn't crash with threaded previews going */
	WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));

	BLI_strncpy(mainstr, G.main->name, sizeof(mainstr));    /* temporal store */

	fileflags = G.fileflags;
	G.fileflags |= G_FILE_NO_UI;

	if (UNDO_DISK) 
		success = (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL);
	else
		success = BKE_read_file_from_memfile(C, &uel->memfile, NULL);

	/* restore */
	BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
	G.fileflags = fileflags;

	if (success) {
		/* important not to update time here, else non keyed tranforms are lost */
		DAG_on_visible_update(G.main, false);
	}

	return success;
}
开发者ID:akonneker,项目名称:blensor,代码行数:29,代码来源:blender.c

示例9: gpencil_panel_standard_header

void gpencil_panel_standard_header(const bContext *C, Panel *pa)
{
	PointerRNA ptr;
	RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, CTX_wm_space_data(C), &ptr);

	uiItemR(pa->layout, &ptr, "show_grease_pencil", 0, "", ICON_NONE);
}
开发者ID:244xiao,项目名称:blender,代码行数:7,代码来源:gpencil_buttons.c

示例10: outliner_do_object_operation

void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, 
                                  void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
                                                       TreeStoreElem *, TreeStoreElem *))
{
	TreeElement *te;
	TreeStoreElem *tselem;
	
	for (te = lb->first; te; te = te->next) {
		tselem = TREESTORE(te);
		if (tselem->flag & TSE_SELECTED) {
			if (tselem->type == 0 && te->idcode == ID_OB) {
				// when objects selected in other scenes... dunno if that should be allowed
				Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE);
				if (scene_owner && scene_act != scene_owner) {
					ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner);
				}
				/* important to use 'scene_owner' not scene_act else deleting objects can crash.
				 * only use 'scene_act' when 'scene_owner' is NULL, which can happen when the
				 * outliner isn't showing scenes: Visible Layer draw mode for eg. */
				operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem);
			}
		}
		if (TSELEM_OPEN(tselem, soops)) {
			outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb);
		}
	}
}
开发者ID:244xiao,项目名称:blender,代码行数:27,代码来源:outliner_tools.c

示例11: ed_marker_move_apply

/* note, init has to be called succesfully */
static void ed_marker_move_apply(bContext *C, wmOperator *op)
{
#ifdef DURIAN_CAMERA_SWITCH
	bScreen *sc = CTX_wm_screen(C);
	Scene *scene = CTX_data_scene(C);
	Object *camera = scene->camera;
#endif
	MarkerMove *mm = op->customdata;
	TimeMarker *marker;
	int a, offs;
	
	offs = RNA_int_get(op->ptr, "frames");
	for (a = 0, marker = mm->markers->first; marker; marker = marker->next) {
		if (marker->flag & SELECT) {
			marker->frame = mm->oldframe[a] + offs;
			a++;
		}
	}

	WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL);
	WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL);
	
#ifdef DURIAN_CAMERA_SWITCH
	/* so we get view3d redraws */
	BKE_scene_camera_switch_update(scene);

	if (camera != scene->camera) {
		BKE_screen_view3d_scene_sync(sc);
		WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
	}
#endif
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:33,代码来源:anim_markers.c

示例12: ED_screen_do_listen

void ED_screen_do_listen(bContext *C, wmNotifier *note)
{
  wmWindow *win = CTX_wm_window(C);
  bScreen *screen = CTX_wm_screen(C);

  /* generic notes */
  switch (note->category) {
    case NC_WM:
      if (note->data == ND_FILEREAD) {
        screen->do_draw = true;
      }
      break;
    case NC_WINDOW:
      screen->do_draw = true;
      break;
    case NC_SCREEN:
      if (note->action == NA_EDITED) {
        screen->do_draw = screen->do_refresh = true;
      }
      break;
    case NC_SCENE:
      if (note->data == ND_MODE) {
        region_cursor_set(win, true);
      }
      break;
  }
}
开发者ID:dfelinto,项目名称:blender,代码行数:27,代码来源:screen_edit.c

示例13: actkeys_viewall

static int actkeys_viewall(bContext *C, const short onlySel)
{
	bAnimContext ac;
	View2D *v2d;
	float extra;
	
	/* get editor data */
	if (ANIM_animdata_get_context(C, &ac) == 0)
		return OPERATOR_CANCELLED;
	v2d= &ac.ar->v2d;
	
	/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
	get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel);
	
	extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
	v2d->cur.xmin -= extra;
	v2d->cur.xmax += extra;
	
	/* set vertical range */
	v2d->cur.ymax= 0.0f;
	v2d->cur.ymin= (float)-(v2d->mask.ymax - v2d->mask.ymin);
	
	/* do View2D syncing */
	UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
	
	/* just redraw this view */
	ED_area_tag_redraw(CTX_wm_area(C));
	
	return OPERATOR_FINISHED;
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:30,代码来源:action_edit.c

示例14: editsource_exec

static int editsource_exec(bContext *C, wmOperator *op)
{
  uiBut *but = UI_context_active_but_get(C);

  if (but) {
    GHashIterator ghi;
    struct uiEditSourceButStore *but_store = NULL;

    ARegion *ar = CTX_wm_region(C);
    int ret;

    /* needed else the active button does not get tested */
    UI_screen_free_active_but(C, CTX_wm_screen(C));

    // printf("%s: begin\n", __func__);

    /* take care not to return before calling ui_editsource_active_but_clear */
    ui_editsource_active_but_set(but);

    /* redraw and get active button python info */
    ED_region_do_layout(C, ar);
    ED_region_do_draw(C, ar);
    ar->do_draw = false;

    for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash);
         BLI_ghashIterator_done(&ghi) == false;
         BLI_ghashIterator_step(&ghi)) {
      uiBut *but_key = BLI_ghashIterator_getKey(&ghi);
      if (but_key && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but_key)) {
        but_store = BLI_ghashIterator_getValue(&ghi);
        break;
      }
    }

    if (but_store) {
      if (but_store->py_dbg_ln != -1) {
        ret = editsource_text_edit(C, op, but_store->py_dbg_fn, but_store->py_dbg_ln);
      }
      else {
        BKE_report(
            op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source");
        ret = OPERATOR_CANCELLED;
      }
    }
    else {
      BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found");
      ret = OPERATOR_CANCELLED;
    }

    ui_editsource_active_but_clear();

    // printf("%s: end\n", __func__);

    return ret;
  }
  else {
    BKE_report(op->reports, RPT_ERROR, "Active button not found");
    return OPERATOR_CANCELLED;
  }
}
开发者ID:dfelinto,项目名称:blender,代码行数:60,代码来源:interface_ops.c

示例15: datadropper_id_sample_pt

/**
 * \brief get the ID from the screen.
 */
static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int my, ID **r_id)
{
  /* we could use some clever */
  bScreen *screen = CTX_wm_screen(C);
  ScrArea *sa = BKE_screen_find_area_xy(screen, -1, mx, my);

  ScrArea *area_prev = CTX_wm_area(C);
  ARegion *ar_prev = CTX_wm_region(C);

  ddr->name[0] = '\0';

  if (sa) {
    if (sa->spacetype == SPACE_VIEW3D) {
      ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
      if (ar) {
        const int mval[2] = {mx - ar->winrct.xmin, my - ar->winrct.ymin};
        Base *base;

        CTX_wm_area_set(C, sa);
        CTX_wm_region_set(C, ar);

        /* grr, always draw else we leave stale text */
        ED_region_tag_redraw(ar);

        base = ED_view3d_give_base_under_cursor(C, mval);
        if (base) {
          Object *ob = base->object;
          ID *id = NULL;
          if (ddr->idcode == ID_OB) {
            id = (ID *)ob;
          }
          else if (ob->data) {
            if (GS(((ID *)ob->data)->name) == ddr->idcode) {
              id = (ID *)ob->data;
            }
            else {
              BLI_snprintf(
                  ddr->name, sizeof(ddr->name), "Incompatible, expected a %s", ddr->idcode_name);
            }
          }

          PointerRNA idptr;
          RNA_id_pointer_create(id, &idptr);

          if (id && RNA_property_pointer_poll(&ddr->ptr, ddr->prop, &idptr)) {
            BLI_snprintf(ddr->name, sizeof(ddr->name), "%s: %s", ddr->idcode_name, id->name + 2);
            *r_id = id;
          }
        }
      }
    }
  }

  CTX_wm_area_set(C, area_prev);
  CTX_wm_region_set(C, ar_prev);
}
开发者ID:dfelinto,项目名称:blender,代码行数:59,代码来源:interface_eyedropper_datablock.c


注:本文中的CTX_wm_screen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。