[Bf-blender-cvs] [d50091024c1] filebrowser_redesign: Use temporary window for file browsing
Julian Eisel
noreply at git.blender.org
Fri May 24 20:22:52 CEST 2019
Commit: d50091024c1b80e9b3d754a54884c01213dd801e
Author: Julian Eisel
Date: Fri May 24 00:09:58 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rBd50091024c1b80e9b3d754a54884c01213dd801e
Use temporary window for file browsing
===================================================================
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/intern/wm_window.c
===================================================================
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 4a7953d7a24..a82772d8ea2 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -159,7 +159,7 @@ enum {
WM_WINDOW_RENDER = 1,
WM_WINDOW_USERPREFS,
WM_WINDOW_DRIVERS,
- // WM_WINDOW_FILESEL // UNUSED
+ WM_WINDOW_FILESEL,
};
struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 07d5f4b0d59..b61e36b7736 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2305,46 +2305,24 @@ static int wm_handler_fileselect_do(bContext *C,
switch (val) {
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
- * in this case, open file select in original window A. Also don't
- * use global areas. */
- if (handler->context.area == NULL || ED_area_is_global(handler->context.area)) {
- bScreen *screen = CTX_wm_screen(C);
- sa = (ScrArea *)screen->areabase.first;
- }
- else {
- sa = handler->context.area;
- }
+ if (WM_window_open_temp(C, win->eventstate->x, win->eventstate->y, sizex, sizey, WM_WINDOW_FILESEL) != NULL) {
+ BLI_assert(CTX_wm_area(C)->spacetype == SPACE_FILE);
- if (sa->full) {
- /* 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);
+ /* settings for filebrowser, sfile is not operator owner but sends events */
+ sfile = (SpaceFile *)CTX_wm_area(C)->spacedata.first;
+ sfile->op = handler->op;
+
+ ED_fileselect_set_params(sfile);
}
else {
- sa = ED_screen_full_newspace(C, sa, SPACE_FILE); /* sets context */
+ BKE_report(&wm->reports, RPT_ERROR, "Failed to open window!");
+ return OPERATOR_CANCELLED;
}
- /* note, getting the 'sa' back from the context causes a nasty bug where the newly created
- * 'sa' != CTX_wm_area(C). removed the line below and set 'sa' in the 'if' above */
- /* sa = CTX_wm_area(C); */
-
- /* settings for filebrowser, sfile is not operator owner but sends events */
- sfile = (SpaceFile *)sa->spacedata.first;
- sfile->op = handler->op;
-
- ED_fileselect_set_params(sfile);
-
action = WM_HANDLER_BREAK;
break;
}
@@ -2356,14 +2334,27 @@ static int wm_handler_fileselect_do(bContext *C,
BLI_remlink(handlers, handler);
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) {
- ED_screen_full_prevspace(C, sa);
- }
- /* user may have left fullscreen */
- else {
- ED_area_prevspace(C, sa);
+ BLI_assert(file_sa->spacetype == SPACE_FILE);
+
+ 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);
+ }
+ else {
+ ED_area_prevspace(C, file_sa);
+ }
+
+ break;
+ }
}
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 7ae572e5685..d6c1f8e7cca 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -796,6 +796,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
ScrArea *sa;
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
+ eSpace_Type space_type = SPACE_EMPTY;
const char *title;
/* convert to native OS window coordinates */
@@ -877,14 +878,21 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
CTX_wm_area_set(C, sa);
if (type == WM_WINDOW_RENDER) {
- ED_area_newspace(C, sa, SPACE_IMAGE, false);
+ space_type = SPACE_IMAGE;
}
else if (type == WM_WINDOW_DRIVERS) {
- ED_area_newspace(C, sa, SPACE_GRAPH, false);
+ 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 {
- ED_area_newspace(C, sa, SPACE_USERPREF, false);
+ BLI_assert(false);
}
+ ED_area_newspace(C, sa, space_type, false);
ED_screen_change(C, screen);
ED_screen_refresh(CTX_wm_manager(C), win); /* test scale */
More information about the Bf-blender-cvs
mailing list