Fix T51248: user preferences window size not adapted to DPI.
This commit is contained in:
parent
1873ea337c
commit
6c26911c3d
@ -217,7 +217,6 @@ enum {
|
||||
/* scale fixed button widths by this to account for DPI */
|
||||
|
||||
#define UI_DPI_FAC ((U.pixelsize * (float)U.dpi) / 72.0f)
|
||||
#define UI_DPI_WINDOW_FAC (((float)U.dpi) / 72.0f)
|
||||
/* 16 to copy ICON_DEFAULT_HEIGHT */
|
||||
#define UI_DPI_ICON_SIZE ((float)16 * UI_DPI_FAC)
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "UI_interface.h"
|
||||
|
||||
#include "wm_window.h"
|
||||
|
||||
@ -128,8 +129,8 @@ static ScrArea *find_area_image_empty(bContext *C)
|
||||
/* new window uses x,y to set position */
|
||||
ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
wmWindow *win = NULL;
|
||||
ScrArea *sa = NULL;
|
||||
SpaceImage *sima;
|
||||
bool area_was_image = false;
|
||||
@ -138,25 +139,15 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
|
||||
return NULL;
|
||||
|
||||
if (scene->r.displaymode == R_OUTPUT_WINDOW) {
|
||||
rcti rect;
|
||||
int sizex, sizey;
|
||||
|
||||
sizex = 10 + (scene->r.xsch * scene->r.size) / 100;
|
||||
sizey = 40 + (scene->r.ysch * scene->r.size) / 100;
|
||||
int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100;
|
||||
int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100;
|
||||
|
||||
/* arbitrary... miniature image window views don't make much sense */
|
||||
if (sizex < 320) sizex = 320;
|
||||
if (sizey < 256) sizey = 256;
|
||||
|
||||
/* some magic to calculate postition */
|
||||
/* pixelsize: mouse coords are in U.pixelsize units :/ */
|
||||
rect.xmin = (mx / U.pixelsize) + win->posx - sizex / 2;
|
||||
rect.ymin = (my / U.pixelsize) + win->posy - sizey / 2;
|
||||
rect.xmax = rect.xmin + sizex;
|
||||
rect.ymax = rect.ymin + sizey;
|
||||
|
||||
/* changes context! */
|
||||
if (WM_window_open_temp(C, &rect, WM_WINDOW_RENDER) == NULL) {
|
||||
if (WM_window_open_temp(C, mx, my, sizex, sizey, WM_WINDOW_RENDER) == NULL) {
|
||||
BKE_report(reports, RPT_ERROR, "Failed to open window!");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3883,22 +3883,11 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
|
||||
|
||||
static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
rcti rect;
|
||||
int sizex, sizey;
|
||||
|
||||
sizex = 800 * UI_DPI_WINDOW_FAC;
|
||||
sizey = 480 * UI_DPI_WINDOW_FAC;
|
||||
|
||||
/* some magic to calculate postition */
|
||||
/* pixelsize: mouse coords are in U.pixelsize units :/ */
|
||||
rect.xmin = (event->x / U.pixelsize) + win->posx - sizex / 2;
|
||||
rect.ymin = (event->y / U.pixelsize) + win->posy - sizey / 2;
|
||||
rect.xmax = rect.xmin + sizex;
|
||||
rect.ymax = rect.ymin + sizey;
|
||||
int sizex = 800 * UI_DPI_FAC;
|
||||
int sizey = 480 * UI_DPI_FAC;
|
||||
|
||||
/* changes context! */
|
||||
if (WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS) != NULL) {
|
||||
if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) {
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
|
@ -3425,7 +3425,6 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
|
||||
/* store current linewidth */
|
||||
float linew;
|
||||
float arrow[2], arrow1[2], arrow2[2];
|
||||
const float px_fac = UI_DPI_WINDOW_FAC;
|
||||
glGetFloatv(GL_LINE_WIDTH, &linew);
|
||||
|
||||
/* we can reuse the dist variable here to increment the GL curve eval amount*/
|
||||
@ -3452,7 +3451,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
|
||||
}
|
||||
if (do_triple) {
|
||||
UI_ThemeColorShadeAlpha(th_col3, -80, -120);
|
||||
glLineWidth(4.0f * px_fac);
|
||||
glLineWidth(4.0f);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i <= LINK_RESOL; i++) {
|
||||
@ -3472,7 +3471,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
|
||||
* for Intel hardware, this breaks with GL_LINE_STRIP and
|
||||
* changing color in begin/end blocks.
|
||||
*/
|
||||
glLineWidth(1.5f * px_fac);
|
||||
glLineWidth(1.5f);
|
||||
if (do_shaded) {
|
||||
glBegin(GL_LINES);
|
||||
for (i = 0; i < LINK_RESOL; i++) {
|
||||
|
@ -102,7 +102,7 @@ enum {
|
||||
};
|
||||
|
||||
struct wmWindow *WM_window_open(struct bContext *C, const struct rcti *rect);
|
||||
struct wmWindow *WM_window_open_temp(struct bContext *C, const struct rcti *rect_init, int type);
|
||||
struct wmWindow *WM_window_open_temp(struct bContext *C, int x, int y, int sizex, int sizey, int type);
|
||||
|
||||
/* returns true if draw method is triple buffer */
|
||||
bool WM_is_draw_triple(struct wmWindow *win);
|
||||
|
@ -1799,13 +1799,13 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
|
||||
if (version_suffix != NULL && version_suffix[0]) {
|
||||
/* placed after the version number in the image,
|
||||
* placing y is tricky to match baseline */
|
||||
int x = 260 - (2 * UI_DPI_WINDOW_FAC);
|
||||
int y = 242 + (4 * UI_DPI_WINDOW_FAC);
|
||||
int w = 240;
|
||||
int x = 260 * U.pixelsize - (2 * UI_DPI_FAC);
|
||||
int y = 242 * U.pixelsize + (4 * UI_DPI_FAC);
|
||||
int w = 240 * U.pixelsize;
|
||||
|
||||
/* hack to have text draw 'text_sel' */
|
||||
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
||||
but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x * U.pixelsize, y * U.pixelsize, w * U.pixelsize, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
but = uiDefBut(block, UI_BTYPE_LABEL, 0, version_suffix, x, y, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
|
||||
/* XXX, set internal flag - UI_SELECT */
|
||||
UI_but_flag_enable(but, 1);
|
||||
UI_block_emboss_set(block, UI_EMBOSS);
|
||||
|
@ -642,14 +642,27 @@ wmWindow *WM_window_open(bContext *C, const rcti *rect)
|
||||
* \param type: WM_WINDOW_RENDER, WM_WINDOW_USERPREFS...
|
||||
* \return the window or NULL.
|
||||
*/
|
||||
wmWindow *WM_window_open_temp(bContext *C, const rcti *rect_init, int type)
|
||||
wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, int type)
|
||||
{
|
||||
wmWindow *win_prev = CTX_wm_window(C);
|
||||
wmWindow *win;
|
||||
ScrArea *sa;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
const char *title;
|
||||
rcti rect = *rect_init;
|
||||
|
||||
/* convert to native OS window coordinates */
|
||||
const float native_pixel_size = GHOST_GetNativePixelSize(win_prev->ghostwin);
|
||||
x /= native_pixel_size;
|
||||
y /= native_pixel_size;
|
||||
sizex /= native_pixel_size;
|
||||
sizey /= native_pixel_size;
|
||||
|
||||
/* calculate postition */
|
||||
rcti rect;
|
||||
rect.xmin = x + win_prev->posx - sizex / 2;
|
||||
rect.ymin = y + win_prev->posy - sizey / 2;
|
||||
rect.xmax = rect.xmin + sizex;
|
||||
rect.ymax = rect.ymin + sizey;
|
||||
|
||||
/* changes rect to fit within desktop */
|
||||
wm_window_check_position(&rect);
|
||||
|
Loading…
Reference in New Issue
Block a user