Cleanup: pass rcti to WM_window_open & ED_screen_temp_space_open

Pass a single rcti instead of 4 int arguments.
This commit is contained in:
Campbell Barton
2023-07-20 16:36:04 +10:00
parent 6400190836
commit ecd729433d
7 changed files with 82 additions and 67 deletions

View File

@@ -361,18 +361,14 @@ struct ScrArea *ED_screen_state_toggle(struct bContext *C,
* 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.
* \param rect_unscaled: Position & size of the window, if a window is spawned.
*/
ScrArea *ED_screen_temp_space_open(struct bContext *C,
const char *title,
int x,
int y,
int sizex,
int sizey,
const struct rcti *rect_unscaled,
eSpace_Type space_type,
int display_type,
bool dialog);
bool dialog) ATTR_NONNULL(1, 2, 3);
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_region_flip_menu_create(struct bContext *C, struct uiLayout *layout, void *arg);

View File

@@ -146,13 +146,17 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
sizey = 256;
}
const rcti window_rect = {
/*xmin*/ mx,
/*xmax*/ mx + sizex,
/*ymin*/ my,
/*ymax*/ my + sizey,
};
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Render"),
mx,
my,
sizex,
sizey,
&window_rect,
SPACE_IMAGE,
true,
false,

View File

@@ -1631,10 +1631,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
ScrArea *ED_screen_temp_space_open(bContext *C,
const char *title,
int x,
int y,
int sizex,
int sizey,
const rcti *rect_unscaled,
eSpace_Type space_type,
int display_type,
bool dialog)
@@ -1645,10 +1642,7 @@ ScrArea *ED_screen_temp_space_open(bContext *C,
case USER_TEMP_SPACE_DISPLAY_WINDOW:
if (WM_window_open(C,
title,
x,
y,
sizex,
sizey,
rect_unscaled,
int(space_type),
false,
dialog,

View File

@@ -1441,18 +1441,16 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
area = sad->sa1;
}
const rcti window_rect = {
/*xmin*/ area->totrct.xmin,
/*xmax*/ area->totrct.xmin + area->winx,
/*ymin*/ area->totrct.ymin,
/*ymax*/ area->totrct.ymin + area->winy,
};
/* Create new window. No need to set space_type since it will be copied over. */
wmWindow *newwin = WM_window_open(C,
"Blender",
area->totrct.xmin,
area->totrct.ymin,
area->winx,
area->winy,
SPACE_EMPTY,
false,
false,
false,
WIN_ALIGN_ABSOLUTE);
wmWindow *newwin = WM_window_open(
C, "Blender", &window_rect, SPACE_EMPTY, false, false, false, WIN_ALIGN_ABSOLUTE);
if (newwin) {
/* copy area to new screen */
@@ -5148,13 +5146,17 @@ static int userpref_show_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &pref_ptr, active_section_prop);
}
const rcti window_rect = {
/*xmin*/ event->xy[0],
/*xmax*/ event->xy[0] + sizex,
/*ymin*/ event->xy[1],
/*ymax*/ event->xy[1] + sizey,
};
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Preferences"),
event->xy[0],
event->xy[1],
sizex,
sizey,
&window_rect,
SPACE_USERPREF,
false,
false,
@@ -5221,13 +5223,17 @@ static int drivers_editor_show_exec(bContext *C, wmOperator *op)
PropertyRNA *prop;
uiBut *but = UI_context_active_but_prop_get(C, &ptr, &prop, &index);
const rcti window_rect = {
/*xmin*/ event->xy[0],
/*xmax*/ event->xy[0] + sizex,
/*ymin*/ event->xy[1],
/*ymax*/ event->xy[1] + sizey,
};
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Drivers Editor"),
event->xy[0],
event->xy[1],
sizex,
sizey,
&window_rect,
SPACE_GRAPH,
false,
false,
@@ -5292,17 +5298,23 @@ static int info_log_show_exec(bContext *C, wmOperator *op)
wmWindow *win_cur = CTX_wm_window(C);
/* Use eventstate, not event from _invoke, so this can be called through exec(). */
const wmEvent *event = win_cur->eventstate;
const int shift_y = 480;
const int mx = event->xy[0];
const int my = event->xy[1] + shift_y;
int sizex = 900 * UI_SCALE_FAC;
int sizey = 580 * UI_SCALE_FAC;
int shift_y = 480;
const rcti window_rect = {
/*xmin*/ mx,
/*xmax*/ mx + sizex,
/*ymin*/ my,
/*ymax*/ my + sizey,
};
/* changes context! */
if (WM_window_open(C,
IFACE_("Blender Info Log"),
event->xy[0],
event->xy[1] + shift_y,
sizex,
sizey,
&window_rect,
SPACE_INFO,
false,
false,

View File

@@ -330,7 +330,8 @@ typedef enum eWindowAlignment {
} eWindowAlignment;
/**
* \param space_type: SPACE_VIEW3D, SPACE_INFO, ... (eSpace_Type)
* \param rect: Position & size of the window.
* \param space_type: #SPACE_VIEW3D, #SPACE_INFO, ... (#eSpace_Type).
* \param toplevel: Not a child owned by other windows. A peer of main window.
* \param dialog: whether this should be made as a dialog-style window
* \param temp: whether this is considered a short-lived window
@@ -339,15 +340,12 @@ typedef enum eWindowAlignment {
*/
struct wmWindow *WM_window_open(struct bContext *C,
const char *title,
int x,
int y,
int sizex,
int sizey,
const struct rcti *rect_unscaled,
int space_type,
bool toplevel,
bool dialog,
bool temp,
eWindowAlignment alignment);
eWindowAlignment alignment) ATTR_NONNULL(1, 2, 3);
void WM_window_set_dpi(const wmWindow *win);

View File

@@ -2647,17 +2647,24 @@ static eHandlerActionFlag wm_handler_fileselect_do(bContext *C,
switch (val) {
case EVT_FILESELECT_FULL_OPEN: {
wmWindow *win = CTX_wm_window(C);
ScrArea *area;
const int window_center[2] = {
WM_window_pixels_x(win) / 2,
WM_window_pixels_y(win) / 2,
};
if ((area = ED_screen_temp_space_open(C,
IFACE_("Blender File View"),
WM_window_pixels_x(win) / 2,
WM_window_pixels_y(win) / 2,
U.file_space_data.temp_win_sizex * UI_SCALE_FAC,
U.file_space_data.temp_win_sizey * UI_SCALE_FAC,
SPACE_FILE,
U.filebrowser_display_type,
true)))
const rcti window_rect = {
/*xmin*/ window_center[0],
/*xmax*/ window_center[0] + int(U.file_space_data.temp_win_sizex * UI_SCALE_FAC),
/*ymin*/ window_center[1],
/*ymax*/ window_center[1] + int(U.file_space_data.temp_win_sizey * UI_SCALE_FAC),
};
if (ScrArea *area = ED_screen_temp_space_open(C,
IFACE_("Blender File View"),
&window_rect,
SPACE_FILE,
U.filebrowser_display_type,
true))
{
ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER);

View File

@@ -875,10 +875,7 @@ static bool wm_window_update_size_position(wmWindow *win)
wmWindow *WM_window_open(bContext *C,
const char *title,
int x,
int y,
int sizex,
int sizey,
const rcti *rect_unscaled,
int space_type,
bool toplevel,
bool dialog,
@@ -890,6 +887,10 @@ wmWindow *WM_window_open(bContext *C,
wmWindow *win_prev = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
int x = rect_unscaled->xmin;
int y = rect_unscaled->ymin;
int sizex = BLI_rcti_size_x(rect_unscaled);
int sizey = BLI_rcti_size_y(rect_unscaled);
rcti rect;
const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin);
@@ -1033,13 +1034,16 @@ int wm_window_new_exec(bContext *C, wmOperator *op)
{
wmWindow *win_src = CTX_wm_window(C);
ScrArea *area = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TYPE_ANY, 0);
const rcti window_rect = {
/*xmin*/ 0,
/*xmax*/ win_src->sizex * 0.95f,
/*ymin*/ 0,
/*ymax*/ win_src->sizey * 0.9f,
};
bool ok = (WM_window_open(C,
IFACE_("Blender"),
0,
0,
win_src->sizex * 0.95f,
win_src->sizey * 0.9f,
&window_rect,
area->spacetype,
false,
false,