diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-04-20 11:16:01 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-04-20 11:16:01 +0300 |
commit | d8bf0900902b2b523bb50a69b9c669c7d5797d72 (patch) | |
tree | e9c35670312b11b2af91eed605d68bb1e2f4a66b /source/blender | |
parent | 462d9e37ea4d4f9aa5344b4a49d9aa95f7692a10 (diff) | |
parent | 6da53e46c9dc81fcbabd49d1db0f88c5e876cf43 (diff) |
Merge branch 'master' into 28
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 4 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/render/render_view.c | 19 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 17 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 17 |
9 files changed, 37 insertions, 49 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 9b5dad3f767..fa58fe368d1 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -84,8 +84,6 @@ void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4]) * \note: * Assumes a unit quaternion? * - * \note: multiplying by 3x3 matrix is ~25% faster. - * * in fact not, but you may want to use a unit quat, read on... * * Shortcut for 'q v q*' when \a v is actually a quaternion. @@ -98,6 +96,8 @@ void mul_qt_qtqt(float q[4], const float q1[4], const float q2[4]) * * For people used to python mathutils, its like: * def mul_qt_v3(q, v): (q * Quaternion((0.0, v[0], v[1], v[2])) * q.conjugated())[1:] + * + * \note: multiplying by 3x3 matrix is ~25% faster. */ void mul_qt_v3(const float q[4], float v[3]) { diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 2bfeebd4d9a..6146632eaf7 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -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) diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 65f0fec50bc..c4a9af79ec2 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -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; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4ba3a534b49..69d13beee48 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3888,22 +3888,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 { diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index a6550b32265..8170ee9b2b3 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3373,7 +3373,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); unsigned int pos; @@ -3407,7 +3406,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, if (do_triple) { immUniformThemeColorShadeAlpha(th_col3, -80, -120); - glLineWidth(4.0f * px_fac); + glLineWidth(4.0f); immBegin(PRIM_LINE_STRIP, (LINK_RESOL + 1)); @@ -3426,7 +3425,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, } } - glLineWidth(1.5f * px_fac); + glLineWidth(1.5f); if (drawarrow) { immUniformThemeColorBlend(th_col1, th_col2, 0.5f); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b80167ce676..adf17117dae 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -7376,19 +7376,16 @@ static void draw_editnurb( vec_a[0] = fac; vec_a[1] = 0.0f; vec_a[2] = 0.0f; + + mul_qt_v3(bevp->quat, vec_a); + madd_v3_v3fl(vec_a, bevp->dir, -fac); - vec_b[0] = -fac; - vec_b[1] = 0.0f; - vec_b[2] = 0.0f; + reflect_v3_v3v3(vec_b, vec_a, bevp->dir); + negate_v3(vec_b); - mul_qt_v3(bevp->quat, vec_a); - mul_qt_v3(bevp->quat, vec_b); add_v3_v3(vec_a, bevp->vec); add_v3_v3(vec_b, bevp->vec); - madd_v3_v3fl(vec_a, bevp->dir, -fac); - madd_v3_v3fl(vec_b, bevp->dir, -fac); - immVertex3fv(pos, vec_a); immVertex3fv(pos, bevp->vec); immVertex3fv(pos, bevp->vec); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1cabb07d556..80170d70dbd 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -110,7 +110,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); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a44d1b60a7b..00fc75eb282 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1830,13 +1830,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); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 2027afef103..3ff323862b3 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -666,14 +666,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); |