Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_event_system.c
| Show First 20 Lines • Show All 2,333 Lines • ▼ Show 20 Lines | static int wm_handler_fileselect_do(bContext *C, | ||||
| int val) | int val) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile; | SpaceFile *sfile; | ||||
| int action = WM_HANDLER_CONTINUE; | int action = WM_HANDLER_CONTINUE; | ||||
| switch (val) { | switch (val) { | ||||
| case EVT_FILESELECT_FULL_OPEN: { | case EVT_FILESELECT_FULL_OPEN: { | ||||
| ScrArea *sa; | wmWindow *win = CTX_wm_window(C); | ||||
| const int sizex = 1020 * UI_DPI_FAC; | |||||
| const int sizey = 600 * UI_DPI_FAC; | |||||
| /* sa can be null when window A is active, but mouse is over window B | if (WM_window_open_temp( | ||||
| * in this case, open file select in original window A. Also don't | C, win->sizex / 2, win->sizey / 2, sizex, sizey, WM_WINDOW_FILESEL) != NULL) { | ||||
| * use global areas. */ | ScrArea *area = CTX_wm_area(C); | ||||
| if (handler->context.area == NULL || ED_area_is_global(handler->context.area)) { | ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); | ||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| sa = (ScrArea *)screen->areabase.first; | |||||
| } | |||||
| else { | |||||
| sa = handler->context.area; | |||||
| } | |||||
| if (sa->full) { | BLI_assert(area->spacetype == SPACE_FILE); | ||||
| /* ensure the first area becomes the file browser, because the second one is the small | |||||
| * top (info-)area which might be too small (in fullscreens we have max two areas) */ | |||||
| if (sa->prev) { | |||||
| sa = sa->prev; | |||||
| } | |||||
| ED_area_newspace(C, sa, SPACE_FILE, true); /* 'sa' is modified in-place */ | |||||
| /* we already had a fullscreen here -> mark new space as a stacked fullscreen */ | |||||
| sa->flag |= (AREA_FLAG_STACKED_FULLSCREEN | AREA_FLAG_TEMP_TYPE); | |||||
| } | |||||
| else if (sa->spacetype == SPACE_FILE) { | |||||
| sa = ED_screen_state_toggle(C, CTX_wm_window(C), sa, SCREENMAXIMIZED); | |||||
| } | |||||
| else { | |||||
| sa = ED_screen_full_newspace(C, sa, SPACE_FILE); /* sets context */ | |||||
| } | |||||
| /* note, getting the 'sa' back from the context causes a nasty bug where the newly created | region_header->flag |= RGN_FLAG_HIDDEN; | ||||
| * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */ | /* Header on bottom, AZone triangle to toggle header looks misplaced at the top */ | ||||
| /* sa = CTX_wm_area(C); */ | region_header->alignment = RGN_ALIGN_BOTTOM; | ||||
| /* settings for filebrowser, sfile is not operator owner but sends events */ | /* settings for filebrowser, sfile is not operator owner but sends events */ | ||||
| sfile = (SpaceFile *)sa->spacedata.first; | sfile = (SpaceFile *)area->spacedata.first; | ||||
| sfile->op = handler->op; | sfile->op = handler->op; | ||||
| ED_fileselect_set_params(sfile); | ED_fileselect_set_params(sfile); | ||||
| } | |||||
| else { | |||||
| BKE_report(&wm->reports, RPT_ERROR, "Failed to open window!"); | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| action = WM_HANDLER_BREAK; | action = WM_HANDLER_BREAK; | ||||
| break; | break; | ||||
| } | } | ||||
| case EVT_FILESELECT_EXEC: | case EVT_FILESELECT_EXEC: | ||||
| case EVT_FILESELECT_CANCEL: | case EVT_FILESELECT_CANCEL: | ||||
| case EVT_FILESELECT_EXTERNAL_CANCEL: { | case EVT_FILESELECT_EXTERNAL_CANCEL: { | ||||
| /* remlink now, for load file case before removing*/ | /* remlink now, for load file case before removing*/ | ||||
| BLI_remlink(handlers, handler); | BLI_remlink(handlers, handler); | ||||
| if (val != EVT_FILESELECT_EXTERNAL_CANCEL) { | if (val != EVT_FILESELECT_EXTERNAL_CANCEL) { | ||||
| ScrArea *sa = CTX_wm_area(C); | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| if (WM_window_is_temp_screen(win)) { | |||||
| bScreen *screen = WM_window_get_active_screen(win); | |||||
| ScrArea *file_sa = screen->areabase.first; | |||||
| if (sa->full) { | BLI_assert(file_sa->spacetype == SPACE_FILE); | ||||
| ED_screen_full_prevspace(C, sa); | |||||
| if (BLI_listbase_is_single(&file_sa->spacedata)) { | |||||
| wmWindow *ctx_win = CTX_wm_window(C); | |||||
| wm_window_close(C, wm, win); | |||||
| CTX_wm_window_set(C, ctx_win); // wm_window_close() NULLs. | |||||
| } | |||||
| else if (file_sa->full) { | |||||
| ED_screen_full_prevspace(C, file_sa); | |||||
| } | } | ||||
| /* user may have left fullscreen */ | |||||
| else { | else { | ||||
| ED_area_prevspace(C, sa); | ED_area_prevspace(C, file_sa); | ||||
| } | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| wm_handler_op_context(C, handler, CTX_wm_window(C)->eventstate); | wm_handler_op_context(C, handler, CTX_wm_window(C)->eventstate); | ||||
| /* needed for UI_popup_menu_reports */ | /* needed for UI_popup_menu_reports */ | ||||
| if (val == EVT_FILESELECT_EXEC) { | if (val == EVT_FILESELECT_EXEC) { | ||||
| ▲ Show 20 Lines • Show All 2,916 Lines • Show Last 20 Lines | |||||