Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_window.c
| Show First 20 Lines • Show All 789 Lines • ▼ Show 20 Lines | else { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Uses `screen->temp` tag to define what to do, currently it limits | * Uses `screen->temp` tag to define what to do, currently it limits | ||||
| * to only one "temp" window for render out, preferences, filewindow, etc... | * to only one "temp" window for render out, preferences, filewindow, etc... | ||||
| * | * | ||||
| * \param type: WM_WINDOW_RENDER, WM_WINDOW_USERPREFS... | * \param space_type: SPACE_VIEW3D, SPACE_INFO, ... (eSpace_Type) | ||||
| * \return the window or NULL. | * \return the window or NULL in case of failure. | ||||
| */ | */ | ||||
| wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, int type) | wmWindow *WM_window_open_temp( | ||||
| bContext *C, const char *title, int x, int y, int sizex, int sizey, int space_type) | |||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| wmWindow *win_prev = CTX_wm_window(C); | wmWindow *win_prev = CTX_wm_window(C); | ||||
| wmWindow *win; | wmWindow *win; | ||||
| bScreen *screen; | bScreen *screen; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| eSpace_Type space_type = SPACE_EMPTY; | |||||
| const char *title; | |||||
| /* convert to native OS window coordinates */ | /* convert to native OS window coordinates */ | ||||
| const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin); | const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin); | ||||
| x /= native_pixel_size; | x /= native_pixel_size; | ||||
| y /= native_pixel_size; | y /= native_pixel_size; | ||||
| sizex /= native_pixel_size; | sizex /= native_pixel_size; | ||||
| sizey /= native_pixel_size; | sizey /= native_pixel_size; | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | wmWindow *WM_window_open_temp( | ||||
| * finish setting up the screen, then free it at the end of the function, | * 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. | * to avoid having to take into account a partially-created window. | ||||
| */ | */ | ||||
| /* ensure it shows the right spacetype editor */ | /* ensure it shows the right spacetype editor */ | ||||
| sa = screen->areabase.first; | sa = screen->areabase.first; | ||||
| CTX_wm_area_set(C, sa); | CTX_wm_area_set(C, sa); | ||||
| if (type == WM_WINDOW_RENDER) { | |||||
| space_type = SPACE_IMAGE; | |||||
| } | |||||
| else if (type == WM_WINDOW_DRIVERS) { | |||||
| space_type = SPACE_GRAPH; | |||||
| } | |||||
| else if (type == WM_WINDOW_USERPREFS) { | |||||
| space_type = SPACE_USERPREF; | |||||
| } | |||||
| else if (type == WM_WINDOW_FILESEL) { | |||||
| space_type = SPACE_FILE; | |||||
| } | |||||
| else if (type == WM_WINDOW_INFO) { | |||||
| space_type = SPACE_INFO; | |||||
| } | |||||
| else { | |||||
| BLI_assert(false); | |||||
| } | |||||
| ED_area_newspace(C, sa, space_type, false); | ED_area_newspace(C, sa, space_type, false); | ||||
| ED_screen_change(C, screen); | ED_screen_change(C, screen); | ||||
| ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */ | ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */ | ||||
| /* do additional setup for specific editor type */ | |||||
| if (type == WM_WINDOW_DRIVERS) { | |||||
| ED_drivers_editor_init(C, sa); | |||||
| } | |||||
| if (sa->spacetype == SPACE_IMAGE) { | |||||
| title = IFACE_("Blender Render"); | |||||
| } | |||||
| else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF)) { | |||||
| title = IFACE_("Blender Preferences"); | |||||
| } | |||||
| else if (sa->spacetype == SPACE_FILE) { | |||||
| title = IFACE_("Blender File View"); | |||||
| } | |||||
| else if (sa->spacetype == SPACE_GRAPH) { | |||||
| title = IFACE_("Blender Drivers Editor"); | |||||
| } | |||||
| else if (sa->spacetype == SPACE_INFO) { | |||||
| title = IFACE_("Blender Info Log"); | |||||
| } | |||||
| else { | |||||
| title = "Blender"; | |||||
| } | |||||
| if (win->ghostwin) { | if (win->ghostwin) { | ||||
| GHOST_SetTitle(win->ghostwin, title); | GHOST_SetTitle(win->ghostwin, title); | ||||
| return win; | return win; | ||||
| } | } | ||||
| else { | else { | ||||
| /* very unlikely! but opening a new window can fail */ | /* very unlikely! but opening a new window can fail */ | ||||
| wm_window_close(C, CTX_wm_manager(C), win); | wm_window_close(C, CTX_wm_manager(C), win); | ||||
| CTX_wm_window_set(C, win_prev); | CTX_wm_window_set(C, win_prev); | ||||
| ▲ Show 20 Lines • Show All 1,498 Lines • Show Last 20 Lines | |||||