- Tooltips now respect view2d view (rna viewer).
- Bugfix in viewd.c UI_view2d_view_to_region() (typo)
This commit is contained in:
Ton Roosendaal
2008-12-03 17:11:50 +00:00
parent 880710cfb0
commit 4e6b6dd3f9
2 changed files with 24 additions and 6 deletions

View File

@@ -5,6 +5,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_screen_types.h"
#include "DNA_view2d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
@@ -21,8 +22,9 @@
#include "BIF_gl.h"
#include "UI_text.h"
#include "UI_interface.h"
#include "UI_text.h"
#include "UI_view2d.h"
#include "ED_screen.h"
@@ -309,6 +311,15 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
x2 += 4;
if(butregion) {
/* XXX temp, region v2ds can be empty still */
if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
short tx, ty;
UI_view2d_to_region_no_clip(&butregion->v2d, x1, y1, &tx, &ty);
x1= (int)tx; y1= (int)ty;
UI_view2d_to_region_no_clip(&butregion->v2d, x2, y2, &tx, &ty);
x2= (int)tx; y2= (int)ty;
}
x1 += butregion->winrct.xmin;
x2 += butregion->winrct.xmin;
y1 += butregion->winrct.ymin;
@@ -318,14 +329,21 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
wm_window_get_size(C->window, &winx, &winy);
if(x2 > winx) {
x1 -= x2-winx;
x2= winx;
/* super size */
if(x2 > winx + x1) {
x2= winx;
x1= 0;
}
else {
x1 -= x2-winx;
x2= winx;
}
}
if(y1 < 0) {
y1 += 36;
y2 += 36;
}
ar->winrct.xmin= x1;
ar->winrct.ymin= y1;
ar->winrct.xmax= x2;

View File

@@ -786,7 +786,7 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, short *regionx, sho
/* express given coordinates as proportional values */
x= (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
y= (x - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
y= (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
/* check if values are within bounds */
if ((x>=0.0f) && (x<=1.0f) && (y>=0.0f) && (y<=1.0f)) {
@@ -807,7 +807,7 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx,
{
/* step 1: express given coordinates as proportional values */
x= (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
y= (x - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
y= (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
/* step 2: convert proportional distances to screen coordinates */
x= v2d->mask.xmin + x*(v2d->mask.xmax - v2d->mask.xmin);