/* part of wm_window.c api */ wmWindow *wm_window_copy(bContext *C, wmWindow *win_src) { wmWindow *win_dst = wm_window_new(C); win_dst->posx = win_src->posx + 10; win_dst->posy = win_src->posy; win_dst->sizex = win_src->sizex; win_dst->sizey = win_src->sizey; /* duplicate assigns to window */ win_dst->screen = ED_screen_duplicate(win_dst, win_src->screen); BLI_strncpy(win_dst->screenname, win_dst->screen->id.name + 2, sizeof(win_dst->screenname)); win_dst->screen->winid = win_dst->winid; win_dst->screen->do_refresh = true; win_dst->screen->do_draw = true; win_dst->drawmethod = U.wmdrawmethod; BLI_listbase_clear(&win_dst->drawdata); *win_dst->stereo3d_format = *win_src->stereo3d_format; return win_dst; }
void WM_window_open_temp(bContext *C, rcti *position, int type) { wmWindow *win; ScrArea *sa; /* changes rect to fit within desktop */ wm_window_check_position(position); /* test if we have a temp screen already */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) if (win->screen->temp) break; /* add new window? */ if (win == NULL) { win = wm_window_new(C); win->posx = position->xmin; win->posy = position->ymin; } win->sizex = position->xmax - position->xmin; win->sizey = position->ymax - position->ymin; if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); wm_window_raise(win); } /* add new screen? */ if (win->screen == NULL) win->screen = ED_screen_add(win, CTX_data_scene(C), "temp"); win->screen->temp = 1; /* make window active, and validate/resize */ CTX_wm_window_set(C, win); WM_check(C); /* ensure it shows the right spacetype editor */ sa = win->screen->areabase.first; CTX_wm_area_set(C, sa); if (type == WM_WINDOW_RENDER) { ED_area_newspace(C, sa, SPACE_IMAGE); } else { ED_area_newspace(C, sa, SPACE_USERPREF); } ED_screen_set(C, win->screen); if (sa->spacetype == SPACE_IMAGE) GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render")); else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) GHOST_SetTitle(win->ghostwin, IFACE_("Blender User Preferences")); else if (sa->spacetype == SPACE_FILE) GHOST_SetTitle(win->ghostwin, IFACE_("Blender File View")); else GHOST_SetTitle(win->ghostwin, "Blender"); }
/* area-rip calls this */ wmWindow *WM_window_open(bContext *C, const rcti *rect) { wmWindow *win = wm_window_new(C); win->posx = rect->xmin; win->posy = rect->ymin; win->sizex = BLI_rcti_size_x(rect); win->sizey = BLI_rcti_size_y(rect); win->drawmethod = U.wmdrawmethod; WM_check(C); return win; }
/* on startup, it adds all data, for matching */ void wm_add_default(bContext *C) { wmWindowManager *wm= alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); wmWindow *win; bScreen *screen= CTX_wm_screen(C); /* XXX from file read hrmf */ CTX_wm_manager_set(C, wm); win= wm_window_new(C); win->screen= screen; screen->winid= win->winid; BLI_strncpy(win->screenname, screen->id.name+2, sizeof(win->screenname)); wm->winactive= win; wm->file_saved= 1; wm_window_make_drawable(C, win); }
/* area-rip calls this */ wmWindow *WM_window_open(bContext *C, rcti *rect) { wmWindow *win = wm_window_new(C); win->posx = rect->xmin; win->posy = rect->ymin; win->sizex = rect->xmax - rect->xmin; win->sizey = rect->ymax - rect->ymin; win->drawmethod = -1; win->drawdata = NULL; WM_check(C); return win; }
/* part of wm_window.c api */ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) { wmWindow *win = wm_window_new(C); win->posx = winorig->posx + 10; win->posy = winorig->posy; win->sizex = winorig->sizex; win->sizey = winorig->sizey; /* duplicate assigns to window */ win->screen = ED_screen_duplicate(win, winorig->screen); BLI_strncpy(win->screenname, win->screen->id.name + 2, sizeof(win->screenname)); win->screen->winid = win->winid; win->screen->do_refresh = TRUE; win->screen->do_draw = TRUE; win->drawmethod = -1; win->drawdata = NULL; return win; }
/** * new window, no screen yet, but we open ghostwindow for it, * also gets the window level handlers * \note area-rip calls this. * \return the window or NULL. */ wmWindow *WM_window_open(bContext *C, const rcti *rect) { wmWindow *win_prev = CTX_wm_window(C); wmWindow *win = wm_window_new(C); win->posx = rect->xmin; win->posy = rect->ymin; win->sizex = BLI_rcti_size_x(rect); win->sizey = BLI_rcti_size_y(rect); win->drawmethod = U.wmdrawmethod; WM_check(C); if (win->ghostwin) { return win; } else { wm_window_close(C, CTX_wm_manager(C), win); CTX_wm_window_set(C, win_prev); return NULL; } }
/** * Uses `screen->temp` tag to define what to do, currently it limits * to only one "temp" window for render out, preferences, filewindow, etc... * * \param type: WM_WINDOW_RENDER, WM_WINDOW_USERPREFS... * \return the window or NULL. */ wmWindow *WM_window_open_temp(bContext *C, const rcti *rect_init, int type) { wmWindow *win_prev = CTX_wm_window(C); wmWindow *win; ScrArea *sa; Scene *scene = CTX_data_scene(C); const char *title; rcti rect = *rect_init; const short px_virtual = (short)wm_window_get_virtual_pixelsize(); /* changes rect to fit within desktop */ wm_window_check_position(&rect); /* test if we have a temp screen already */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) if (win->screen->temp) break; /* add new window? */ if (win == NULL) { win = wm_window_new(C); win->posx = rect.xmin; win->posy = rect.ymin; } /* multiply with virtual pixelsize, ghost handles native one (e.g. for retina) */ win->sizex = BLI_rcti_size_x(&rect) * px_virtual; win->sizey = BLI_rcti_size_y(&rect) * px_virtual; if (win->ghostwin) { wm_window_set_size(win, win->sizex, win->sizey); wm_window_raise(win); } if (win->screen == NULL) { /* add new screen */ win->screen = ED_screen_add(win, scene, "temp"); } else { /* switch scene for rendering */ if (win->screen->scene != scene) ED_screen_set_scene(C, win->screen, scene); } win->screen->temp = 1; /* make window active, and validate/resize */ CTX_wm_window_set(C, win); WM_check(C); /* It's possible `win->ghostwin == NULL`. * instead of attempting to cleanup here (in a half finished state), * finish setting up the screen, then free it at the end of the function, * to avoid having to take into account a partially-created window. */ /* ensure it shows the right spacetype editor */ sa = win->screen->areabase.first; CTX_wm_area_set(C, sa); if (type == WM_WINDOW_RENDER) { ED_area_newspace(C, sa, SPACE_IMAGE); } else { ED_area_newspace(C, sa, SPACE_USERPREF); } ED_screen_set(C, win->screen); ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */ if (sa->spacetype == SPACE_IMAGE) title = IFACE_("Blender Render"); else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) title = IFACE_("Blender User Preferences"); else if (sa->spacetype == SPACE_FILE) title = IFACE_("Blender File View"); else title = "Blender"; if (win->ghostwin) { GHOST_SetTitle(win->ghostwin, title); return win; } else { /* very unlikely! but opening a new window can fail */ wm_window_close(C, CTX_wm_manager(C), win); CTX_wm_window_set(C, win_prev); return NULL; } }