diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-09-18 15:37:11 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-09-18 15:37:11 +0300 |
commit | f5bbaf55ac3dc6f6b2234c3656fd89b526f08dd0 (patch) | |
tree | 512bec75c0bf1ceb180a904b8f3c64bb1fd6b2b8 | |
parent | cac756a92aaec5ccc8ddb95c021dcf79d12cc588 (diff) |
UI: Preference for file browser as fullscreen area
Addes a Preference setting to choose between opening new file browsers
in a maximized area (like with the old file browser) or in a new window
(like the new one).
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 79 |
5 files changed, 70 insertions, 20 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 89b4819eac7..2384cd0fe38 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -282,6 +282,7 @@ class USERPREF_PT_interface_temporary_windows(PreferencePanel, Panel): flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) flow.prop(view, "render_display_type", text="Render in") + flow.prop(view, "filebrowser_display_type", text="File Browser") class USERPREF_PT_interface_menus(Panel): diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index c1c398c32d0..75b87c4f1f0 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -621,6 +621,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) { /* pass */ userdef->render_display_type = USER_RENDER_DISPLAY_WINDOW; + userdef->filebrowser_display_type = USER_TEMP_SPACE_DISPLAY_WINDOW; } if (userdef->pixelsize == 0.0f) { diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 22da2a86054..1110b0fb8b5 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -815,7 +815,8 @@ typedef struct UserDef { char viewport_aa; char render_display_type; /* eUserpref_RenderDisplayType */ - char _pad5[5]; + char filebrowser_display_type; /* eUserpref_TempSpaceDisplayType */ + char _pad5[4]; struct WalkNavigation walk_navigation; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 5b75bca89f3..d61c2399592 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4310,6 +4310,12 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text( prop, "Render Display Type", "Default location where rendered images will be displayed in"); + prop = RNA_def_property(srna, "filebrowser_display_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, temp_space_display_types); + RNA_def_property_ui_text(prop, + "File Browser Display Type", + "Default location where the File Editor will be displayed in"); + static const EnumPropertyItem text_hinting_items[] = { {0, "AUTO", 0, "Auto", ""}, {USER_TEXT_HINTING_NONE, "NONE", 0, "None", ""}, diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 347e26e0ba5..47b77cf435b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2346,15 +2346,16 @@ static int wm_handler_fileselect_do(bContext *C, wmWindow *win = CTX_wm_window(C); const int sizex = 1020 * UI_DPI_FAC; const int sizey = 600 * UI_DPI_FAC; - - if (WM_window_open_temp(C, - IFACE_("Blender File View"), - WM_window_pixels_x(win) / 2, - WM_window_pixels_y(win) / 2, - sizex, - sizey, - SPACE_FILE) != NULL) { - ScrArea *area = CTX_wm_area(C); + ScrArea *area; + + if ((area = ED_screen_temp_space_open(C, + IFACE_("Blender File View"), + WM_window_pixels_x(win) / 2, + WM_window_pixels_y(win) / 2, + sizex, + sizey, + SPACE_FILE, + U.filebrowser_display_type))) { ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); BLI_assert(area->spacetype == SPACE_FILE); @@ -2393,17 +2394,18 @@ static int wm_handler_fileselect_do(bContext *C, } } else { - 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; + wmWindow *temp_win; + ScrArea *ctx_sa = CTX_wm_area(C); - BLI_assert(file_sa->spacetype == SPACE_FILE); + for (temp_win = wm->windows.first; temp_win; temp_win = temp_win->next) { + bScreen *screen = WM_window_get_active_screen(temp_win); + ScrArea *file_sa = screen->areabase.first; + if (screen->temp && (file_sa->spacetype == SPACE_FILE)) { if (BLI_listbase_is_single(&file_sa->spacedata)) { - BLI_assert(ctx_win != win); + BLI_assert(ctx_win != temp_win); - wm_window_close(C, wm, win); + wm_window_close(C, wm, temp_win); CTX_wm_window_set(C, ctx_win); // wm_window_close() NULLs. /* Some operators expect a drawable context (for EVT_FILESELECT_EXEC) */ @@ -2412,7 +2414,7 @@ static int wm_handler_fileselect_do(bContext *C, * opening (UI_BLOCK_MOVEMOUSE_QUIT) */ wm_get_cursor_position(ctx_win, &ctx_win->eventstate->x, &ctx_win->eventstate->y); wm->winactive = ctx_win; /* Reports use this... */ - if (handler->context.win == win) { + if (handler->context.win == temp_win) { handler->context.win = NULL; } } @@ -2426,6 +2428,10 @@ static int wm_handler_fileselect_do(bContext *C, break; } } + + if (!temp_win && ctx_sa->full) { + ED_screen_full_prevspace(C, ctx_sa); + } } wm_handler_op_context(C, handler, ctx_win->eventstate); @@ -3539,15 +3545,50 @@ void WM_event_add_fileselect(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); + const bool is_temp_screen = WM_window_is_temp_screen(win); /* Don't add the file handler to the temporary window, or else it owns the handlers for itself, * causing dangling pointers once it's destructed through a handler. It has a parent which should * hold the handlers itself. */ - ListBase *modalhandlers = WM_window_is_temp_screen(win) ? &win->parent->modalhandlers : - &win->modalhandlers; + ListBase *modalhandlers = is_temp_screen ? &win->parent->modalhandlers : &win->modalhandlers; /* Close any popups, like when opening a file browser from the splash. */ UI_popup_handlers_remove_all(C, modalhandlers); + if (!is_temp_screen) { + /* only allow 1 file selector open per window */ + LISTBASE_FOREACH_MUTABLE (wmEventHandler *, handler_base, modalhandlers) { + if (handler_base->type == WM_HANDLER_TYPE_OP) { + wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base; + if (handler->is_fileselect == false) { + continue; + } + bScreen *screen = CTX_wm_screen(C); + bool cancel_handler = true; + + /* find the area with the file selector for this handler */ + ED_screen_areas_iter(win, screen, sa) + { + if (sa->spacetype == SPACE_FILE) { + SpaceFile *sfile = sa->spacedata.first; + + if (sfile->op == handler->op) { + CTX_wm_area_set(C, sa); + wm_handler_fileselect_do(C, &win->modalhandlers, handler, EVT_FILESELECT_CANCEL); + cancel_handler = false; + break; + } + } + } + + /* if not found we stop the handler without changing the screen */ + if (cancel_handler) { + wm_handler_fileselect_do( + C, &win->modalhandlers, handler, EVT_FILESELECT_EXTERNAL_CANCEL); + } + } + } + } + wmEventHandler_Op *handler = MEM_callocN(sizeof(*handler), __func__); handler->head.type = WM_HANDLER_TYPE_OP; |