diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-09-18 15:21:32 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-09-18 15:22:50 +0300 |
commit | 95373e274908615df2e5dbf6243b055ff2c39518 (patch) | |
tree | 0721772da52667ab5cbefa8e9f7dea55ca4710ef | |
parent | e2cbf8b1174d512170f490f701c43213c874a717 (diff) |
Refactor temp-space opening for optional fullscreen mode
Will be put to use in followup commits.
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 8 | ||||
-rw-r--r-- | source/blender/editors/render/render_view.c | 5 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 33 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 14 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 11 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 51 |
9 files changed, 84 insertions, 62 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index d0fab134dcc..dbd5e74da5c 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -238,6 +238,14 @@ struct ScrArea *ED_screen_state_toggle(struct bContext *C, struct wmWindow *win, struct ScrArea *sa, const short state); +ScrArea *ED_screen_temp_space_open(struct bContext *C, + const char *title, + int x, + int y, + int sizex, + int sizey, + eSpace_Type space_type, + int display_type); void ED_screens_header_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg); void ED_screens_footer_tools_menu_create(struct bContext *C, struct uiLayout *layout, void *arg); void ED_screens_navigation_bar_tools_menu_create(struct bContext *C, diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 3154d5d0985..d92cd13628b 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -36,6 +36,8 @@ #include "BKE_screen.h" #include "BKE_report.h" +#include "BLT_translation.h" + #include "WM_api.h" #include "WM_types.h" @@ -154,7 +156,8 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) } /* changes context! */ - if (WM_window_open_temp(C, mx, my, sizex, sizey, WM_WINDOW_RENDER) == NULL) { + if (WM_window_open_temp(C, IFACE_("Blender Render"), mx, my, sizex, sizey, SPACE_IMAGE) == + NULL) { BKE_report(reports, RPT_ERROR, "Failed to open window!"); return NULL; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b37aa47aba6..20920dc6f84 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1346,6 +1346,39 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s return sc->areabase.first; } +/** + * Wrapper to open a temporary space either as fullscreen space, or as separate window, as defined + * by \a display_type. + * + * \param title: Title to set for the window, if a window is spawned. + * \param x, y: Position of the window, if a window is spawned. + * \param sizex, sizey: Dimensions of the window, if a window is spawned. + */ +ScrArea *ED_screen_temp_space_open(bContext *C, + const char *title, + int x, + int y, + int sizex, + int sizey, + eSpace_Type space_type, + int display_type) +{ + ScrArea *sa = NULL; + + switch (display_type) { + case USER_TEMP_SPACE_DISPLAY_WINDOW: + if (WM_window_open_temp(C, title, x, y, sizex, sizey, (int)space_type)) { + sa = CTX_wm_area(C); + } + break; + case USER_TEMP_SPACE_DISPLAY_FULLSCREEN: + sa = ED_screen_full_newspace(C, CTX_wm_area(C), (int)space_type); + break; + } + + return sa; +} + /* update frame rate info for viewport drawing */ void ED_refresh_viewport_fps(bContext *C) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f29535a7f0b..53b30373ec3 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4833,7 +4833,9 @@ static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *even int sizey = 520 * UI_DPI_FAC; /* changes context! */ - if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) { + if (WM_window_open_temp( + C, IFACE_("Blender Preferences"), event->x, event->y, sizex, sizey, SPACE_USERPREF) != + NULL) { /* The header only contains the editor switcher and looks empty. * So hiding in the temp window makes sense. */ ScrArea *area = CTX_wm_area(C); @@ -4882,7 +4884,11 @@ static int drivers_editor_show_invoke(bContext *C, wmOperator *op, const wmEvent but = UI_context_active_but_prop_get(C, &ptr, &prop, &index); /* changes context! */ - if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_DRIVERS) != NULL) { + if (WM_window_open_temp( + C, IFACE_("Blender Drivers Editor"), event->x, event->y, sizex, sizey, SPACE_GRAPH) != + NULL) { + ED_drivers_editor_init(C, CTX_wm_area(C)); + /* activate driver F-Curve for the property under the cursor */ if (but) { FCurve *fcu; @@ -4938,7 +4944,9 @@ static int info_log_show_invoke(bContext *C, wmOperator *op, const wmEvent *even int shift_y = 480; /* changes context! */ - if (WM_window_open_temp(C, event->x, event->y + shift_y, sizex, sizey, WM_WINDOW_INFO) != NULL) { + if (WM_window_open_temp( + C, IFACE_("Blender Info Log"), event->x, event->y + shift_y, sizex, sizey, SPACE_INFO) != + NULL) { return OPERATOR_FINISHED; } else { diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 6e44c51970d..86c2b2f09a8 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1202,6 +1202,11 @@ typedef enum eUserpref_FactorDisplay { USER_FACTOR_AS_PERCENTAGE = 1, } eUserpref_FactorDisplay; +typedef enum eUserpref_TempSpaceDisplayType { + USER_TEMP_SPACE_DISPLAY_FULLSCREEN, + USER_TEMP_SPACE_DISPLAY_WINDOW, +} eUserpref_TempSpaceDisplayType; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 548111500ad..94f800c82a9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4044,6 +4044,20 @@ static void rna_def_userdef_view(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem temp_space_display_types[] = { + {USER_TEMP_SPACE_DISPLAY_FULLSCREEN, + "SCREEN", /* Could be FULLSCREEN, but keeping it consistent with render_display_types */ + 0, + "Full Screen", + "Open the temporary editor in a maximized screen"}, + {USER_TEMP_SPACE_DISPLAY_WINDOW, + "WINDOW", + 0, + "New Window", + "Open the temporary editor in a new window"}, + {0, NULL, 0, NULL, NULL}, + }; + PropertyRNA *prop; StructRNA *srna; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 455a30b6ff5..568b904dcb7 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -153,18 +153,9 @@ void WM_opengl_context_dispose(void *context); void WM_opengl_context_activate(void *context); void WM_opengl_context_release(void *context); -/* defines for 'type' WM_window_open_temp */ -enum { - WM_WINDOW_RENDER = 1, - WM_WINDOW_USERPREFS, - WM_WINDOW_DRIVERS, - WM_WINDOW_INFO, - WM_WINDOW_FILESEL, -}; - struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect); struct wmWindow *WM_window_open_temp( - struct bContext *C, int x, int y, int sizex, int sizey, int type); + struct bContext *C, const char *title, int x, int y, int sizex, int sizey, int space_type); void WM_window_set_dpi(wmWindow *win); bool WM_stereo3d_enabled(struct wmWindow *win, bool only_fullscreen_test); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 77672e04030..347e26e0ba5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -58,6 +58,8 @@ #include "BKE_sound.h" +#include "BLT_translation.h" + #include "ED_fileselect.h" #include "ED_info.h" #include "ED_screen.h" @@ -2346,11 +2348,12 @@ static int wm_handler_fileselect_do(bContext *C, 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, - WM_WINDOW_FILESEL) != NULL) { + SPACE_FILE) != NULL) { ScrArea *area = CTX_wm_area(C); ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 7437001cdfc..081797542f2 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -792,10 +792,11 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect) * 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. + * \param space_type: SPACE_VIEW3D, SPACE_INFO, ... (eSpace_Type) + * \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); wmWindow *win_prev = CTX_wm_window(C); @@ -804,8 +805,6 @@ 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 */ const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin); @@ -885,53 +884,11 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i sa = screen->areabase.first; 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_screen_change(C, screen); 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) { GHOST_SetTitle(win->ghostwin, title); return win; |