Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/interface/interface.c8
-rw-r--r--source/blender/editors/interface/interface_regions.c2
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c10
-rw-r--r--source/blender/windowmanager/intern/wm_subwindow.c68
-rw-r--r--source/blender/windowmanager/wm_subwindow.h14
6 files changed, 64 insertions, 42 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e6d5703f5b5..530f529f345 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2430,8 +2430,8 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
/* window matrix and aspect */
if (region && region->swinid) {
- wm_subwindow_getmatrix(window, region->swinid, block->winmat);
- wm_subwindow_getsize(window, region->swinid, &getsizex, &getsizey);
+ wm_subwindow_matrix_get(window, region->swinid, block->winmat);
+ wm_subwindow_size_get(window, region->swinid, &getsizex, &getsizey);
block->aspect = 2.0f / fabsf(getsizex * block->winmat[0][0]);
}
@@ -2439,8 +2439,8 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
/* no subwindow created yet, for menus for example, so we
* use the main window instead, since buttons are created
* there anyway */
- wm_subwindow_getmatrix(window, window->screen->mainwin, block->winmat);
- wm_subwindow_getsize(window, window->screen->mainwin, &getsizex, &getsizey);
+ wm_subwindow_matrix_get(window, window->screen->mainwin, block->winmat);
+ wm_subwindow_size_get(window, window->screen->mainwin, &getsizex, &getsizey);
block->aspect = 2.0f / fabsf(getsizex * block->winmat[0][0]);
block->auto_open = true;
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c6d9769d918..ec7fc592f2d 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1606,7 +1606,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
/* get winmat now that we actually have the subwindow */
wmSubWindowSet(window, ar->swinid);
- wm_subwindow_getmatrix(window, ar->swinid, block->winmat);
+ wm_subwindow_matrix_get(window, ar->swinid, block->winmat);
/* notify change and redraw */
ED_region_tag_redraw(ar);
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index f0b468145e3..9a00e709d85 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -72,7 +72,7 @@ wmGesture *WM_gesture_new(bContext *C, const wmEvent *event, int type)
gesture->event_type = event->type;
gesture->swinid = ar->swinid; /* means only in area-region context! */
- wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(window, gesture->swinid, &sx, &sy);
if (ELEM5(type, WM_GESTURE_RECT, WM_GESTURE_CROSS_RECT, WM_GESTURE_TWEAK,
WM_GESTURE_CIRCLE, WM_GESTURE_STRAIGHTLINE))
@@ -261,7 +261,7 @@ static void draw_filled_lasso(wmWindow *win, wmGesture *gt)
BLI_lasso_boundbox(&rect, (const int (*)[2])moves, tot);
- wm_subwindow_getrect(win, gt->swinid, &rect_win);
+ wm_subwindow_rect_get(win, gt->swinid, &rect_win);
BLI_rcti_translate(&rect, rect_win.xmin, rect_win.ymin);
BLI_rcti_isect(&rect_win, &rect, &rect);
BLI_rcti_translate(&rect, -rect_win.xmin, -rect_win.ymin);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 06e08aaf939..747366b6e8e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3036,7 +3036,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
int sx, sy;
if (event->type == MOUSEMOVE) {
- wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
if (gesture->type == WM_GESTURE_CROSS_RECT && gesture->mode == 0) {
rect->xmin = rect->xmax = event->x - sx;
@@ -3137,7 +3137,7 @@ int WM_gesture_circle_modal(bContext *C, wmOperator *op, const wmEvent *event)
int sx, sy;
if (event->type == MOUSEMOVE) {
- wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
rect->xmin = event->x - sx;
rect->ymin = event->y - sy;
@@ -3236,7 +3236,7 @@ static void tweak_gesture_modal(bContext *C, const wmEvent *event)
case MOUSEMOVE:
case INBETWEEN_MOUSEMOVE:
- wm_subwindow_getorigin(window, gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(window, gesture->swinid, &sx, &sy);
rect->xmax = event->x - sx;
rect->ymax = event->y - sy;
@@ -3376,7 +3376,7 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
wm_gesture_tag_redraw(C);
- wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
if (gesture->points == gesture->size) {
short *old_lasso = gesture->customdata;
@@ -3559,7 +3559,7 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
int sx, sy;
if (event->type == MOUSEMOVE) {
- wm_subwindow_getorigin(CTX_wm_window(C), gesture->swinid, &sx, &sy);
+ wm_subwindow_origin_get(CTX_wm_window(C), gesture->swinid, &sx, &sy);
if (gesture->mode == 0) {
rect->xmin = rect->xmax = event->x - sx;
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 10a24338b35..1c20fe34a90 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -95,7 +95,7 @@ void wm_subwindows_free(wmWindow *win)
}
-int wm_subwindow_get(wmWindow *win)
+int wm_subwindow_get_id(wmWindow *win)
{
if (win->curswin)
return win->curswin->swinid;
@@ -112,55 +112,77 @@ static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
return swin;
}
-void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y)
+
+static void wm_swin_size_get(wmSubWindow *swin, int *x, int *y)
+{
+ *x = BLI_rcti_size_x(&swin->winrct) + 1;
+ *y = BLI_rcti_size_y(&swin->winrct) + 1;
+}
+void wm_subwindow_size_get(wmWindow *win, int swinid, int *x, int *y)
{
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- *x = BLI_rcti_size_x(&swin->winrct) + 1;
- *y = BLI_rcti_size_y(&swin->winrct) + 1;
+ wm_swin_size_get(swin, x, y);
}
}
-void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y)
+
+static void wm_swin_origin_get(wmSubWindow *swin, int *x, int *y)
+{
+ *x = swin->winrct.xmin;
+ *y = swin->winrct.ymin;
+}
+void wm_subwindow_origin_get(wmWindow *win, int swinid, int *x, int *y)
{
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- *x = swin->winrct.xmin;
- *y = swin->winrct.ymin;
+ wm_swin_origin_get(swin, x, y);
}
}
-void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[4][4])
+
+static void wm_swin_matrix_get(wmWindow *win, wmSubWindow *swin, float mat[4][4])
+{
+ /* used by UI, should find a better way to get the matrix there */
+ if (swin->swinid == win->screen->mainwin) {
+ int width, height;
+
+ wm_swin_size_get(swin, &width, &height);
+ orthographic_m4(mat, -GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS, -100, 100);
+ }
+ else {
+ glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat);
+ }
+}
+void wm_subwindow_matrix_get(wmWindow *win, int swinid, float mat[4][4])
{
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- /* used by UI, should find a better way to get the matrix there */
- if (swinid == win->screen->mainwin) {
- int width, height;
-
- wm_subwindow_getsize(win, swin->swinid, &width, &height);
- orthographic_m4(mat, -GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS, -100, 100);
- }
- else
- glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat);
+ wm_swin_matrix_get(win, swin, mat);
}
}
-void wm_subwindow_getrect(wmWindow *win, int swinid, rcti *r_rect)
+
+static void wm_swin_rect_get(wmSubWindow *swin, rcti *r_rect)
+{
+ *r_rect = swin->winrct;
+}
+void wm_subwindow_rect_get(wmWindow *win, int swinid, rcti *r_rect)
{
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
- *r_rect = swin->winrct;
+ wm_swin_rect_get(swin, r_rect);
}
}
+
/* always sets pixel-precise 2D window/view matrices */
/* coords is in whole pixels. xmin = 15, xmax = 16: means window is 2 pix big */
-int wm_subwindow_open(wmWindow *win, rcti *winrct)
+int wm_subwindow_open(wmWindow *win, const rcti *winrct)
{
wmSubWindow *swin;
int width, height;
@@ -180,7 +202,7 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
wmSubWindowSet(win, swin->swinid);
/* extra service */
- wm_subwindow_getsize(win, swin->swinid, &width, &height);
+ wm_swin_size_get(swin, &width, &height);
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
glLoadIdentity();
@@ -205,7 +227,7 @@ void wm_subwindow_close(wmWindow *win, int swinid)
}
/* pixels go from 0-99 for a 100 pixel window */
-void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
+void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct)
{
wmSubWindow *swin = swin_from_swinid(win, swinid);
@@ -237,7 +259,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
/* extra service */
wmSubWindowSet(win, swinid);
- wm_subwindow_getsize(win, swinid, &width, &height);
+ wm_swin_size_get(swin, &width, &height);
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
}
else {
diff --git a/source/blender/windowmanager/wm_subwindow.h b/source/blender/windowmanager/wm_subwindow.h
index a70e7765ecf..c1d0f9a9cac 100644
--- a/source/blender/windowmanager/wm_subwindow.h
+++ b/source/blender/windowmanager/wm_subwindow.h
@@ -36,16 +36,16 @@
/* *************** internal api ************** */
void wm_subwindows_free(wmWindow *win);
-int wm_subwindow_open(wmWindow *win, rcti *winrct);
+int wm_subwindow_open(wmWindow *win, const rcti *winrct);
void wm_subwindow_close(wmWindow *win, int swinid);
-int wm_subwindow_get(wmWindow *win); /* returns id */
+int wm_subwindow_get_id(wmWindow *win); /* returns id */
-void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct);
+void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct);
-void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y);
-void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y);
-void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[4][4]);
-void wm_subwindow_getrect(wmWindow *win, int swinid, struct rcti *r_rect);
+void wm_subwindow_size_get(wmWindow *win, int swinid, int *x, int *y);
+void wm_subwindow_origin_get(wmWindow *win, int swinid, int *x, int *y);
+void wm_subwindow_matrix_get(wmWindow *win, int swinid, float mat[4][4]);
+void wm_subwindow_rect_get(wmWindow *win, int swinid, struct rcti *r_rect);
unsigned int index_to_framebuffer(int index);