Small fixes for UI;

- Add UV Sphere now aligns with view, as do all primitives
- Small drawing error in edges between blender areas (black lines were 2
  pixels too short)
- Replaced the heuristics in opening sublevel menus, to be less frustrating.
  It now keeps sublevel open while mouse moves within the triangle defined
  by original mouse location (before moving) and the closest vertical edge
  of the new sub menu. Works nice for toolbox and pulldowns.
This commit is contained in:
Ton Roosendaal 2004-12-14 18:18:31 +00:00
parent f3106212e8
commit b5d9b1e72d
4 changed files with 47 additions and 40 deletions

@ -501,7 +501,7 @@ void add_primitiveMesh(int type)
cent[1]-= G.obedit->obmat[3][1];
cent[2]-= G.obedit->obmat[3][2];
if(type!= 11) {
if(type!= 31) {
Mat3CpyMat4(imat, G.vd->viewmat);
Mat3MulVecfl(imat, cent);
Mat3MulMat3(cmat, imat, mat);
@ -727,7 +727,6 @@ void add_primitiveMesh(int type)
recalc_editnormals(); // does face centers too
}
else if(type==11) { /* UVsphere */
float tmat[3][3];
/* clear all flags */
eve= em->verts.first;
@ -740,10 +739,9 @@ void add_primitiveMesh(int type)
phi= 0;
phid/=2;
for(a=0; a<=tot; a++) {
vec[0]= cent[0]+dia*sin(phi);
vec[1]= cent[1];
vec[2]= cent[2]+dia*cos(phi);
Mat3MulVecfl(imat,vec);
vec[0]= dia*sin(phi);
vec[1]= 0.0;
vec[2]= dia*cos(phi);
eve= addvertlist(vec);
eve->f= 1+2+4;
if(a==0) v1= eve;
@ -757,14 +755,23 @@ void add_primitiveMesh(int type)
q[3]= sin(phi);
q[1]=q[2]= 0;
QuatToMat3(q, cmat);
Mat3MulMat3(tmat, cmat, mat);
Mat3MulMat3(cmat, imat, tmat);
for(a=0; a<seg; a++) {
extrudeflag_vert(2);
rotateflag(2, v1->co, cmat);
}
removedoublesflag(4, 0.0001);
/* and now do imat */
eve= em->verts.first;
while(eve) {
if(eve->f & SELECT) {
VecAddf(eve->co,eve->co,cent);
Mat3MulVecfl(imat,eve->co);
}
eve= eve->next;
}
}
else if(type==12) { /* Icosphere */
EditVert *eva[12];

@ -3036,11 +3036,11 @@ void drawscredge_area(ScrArea *sa)
else sdrawline(x1, y1, x1, y2);
}
/* top border area */
if(sa->headertype==HEADERTOP) sdrawline(x1+SCR_ROUND, y2, x2-SCR_ROUND+1, y2);
if(sa->headertype==HEADERTOP) sdrawline(x1+SCR_ROUND-3, y2, x2-SCR_ROUND+3, y2);
else sdrawline(x1, y2, x2, y2);
/* bottom border area */
if(sa->headertype==HEADERDOWN) sdrawline(x1+SCR_ROUND, y1, x2-SCR_ROUND+1, y1);
if(sa->headertype==HEADERDOWN) sdrawline(x1+SCR_ROUND-3, y1, x2-SCR_ROUND+3, y1);
else sdrawline(x1, y1, x2, y1);
}

@ -2975,18 +2975,16 @@ static void ui_do_active_linklines(uiBlock *block, short *mval)
/* only to be used to prevent an 'outside' event when using nested pulldowns */
/* four checks:
- while mouse moves in good x direction
- while mouse motion x is bigger than y motion
- while distance to center block diminishes
/* only one checks:
- while mouse moves in triangular area defined old mouse position and left/right side of new menu
- only for 1 second
return 0: check outside
*/
static int ui_mouse_motion_towards_block(uiBlock *block, uiEvent *uevent)
{
short mvalo[2], dx, dy, domx, domy, x1, y1;
int disto, dist, counter=0;
short mvalo[2], dx, dy, domx, domy;
int counter=0;
if((block->direction & UI_TOP) || (block->direction & UI_DOWN)) return 0;
if(uevent->event!= MOUSEX && uevent->event!= MOUSEY) return 0;
@ -2997,9 +2995,6 @@ static int ui_mouse_motion_towards_block(uiBlock *block, uiEvent *uevent)
/* we need some accuracy */
if( abs(domx)<4 ) return 0;
/* calculte old dist */
disto= domx*domx + domy*domy;
uiGetMouse(mywinget(), mvalo);
while(TRUE) {
@ -3017,35 +3012,40 @@ static int ui_mouse_motion_towards_block(uiBlock *block, uiEvent *uevent)
dy= uevent->mval[1] - mvalo[1];
if( abs(dx)+abs(dy)>4 ) { // threshold
if( abs(dy) > abs(dx) ) {
//printf("left because y>x direction\n");
return 0;
/* menu to right */
if(domx>0) {
int fac= (uevent->mval[0] - mvalo[0])*(mvalo[1] - (short)(block->maxy +20)) + (uevent->mval[1] - mvalo[1])*(-mvalo[0] + (short)block->minx);
if( (fac>0)) {
// printf("Left outside 1, Fac %d\n", fac);
return 0;
}
fac= (uevent->mval[0] - mvalo[0])*(mvalo[1] - (short)(block->miny-20)) + (uevent->mval[1] - mvalo[1])*(-mvalo[0] + (short)block->minx);
if( (fac<0)) {
//printf("Left outside 2, Fac %d\n", fac);
return 0;
}
}
if( dx>0 && domx>0);
else if(dx<0 && domx<0);
else {
//printf("left because dominant direction\n");
return 0;
int fac= (uevent->mval[0] - mvalo[0])*(mvalo[1] - (short)(block->maxy+20)) + (uevent->mval[1] - mvalo[1])*(-mvalo[0] + (short)block->maxx);
if( (fac<0)) {
// printf("Left outside 1, Fac %d\n", fac);
return 0;
}
fac= (uevent->mval[0] - mvalo[0])*(mvalo[1] - (short)(block->miny-20)) + (uevent->mval[1] - mvalo[1])*(-mvalo[0] + (short)block->maxx);
if( (fac>0)) {
// printf("Left outside 2, Fac %d\n", fac);
return 0;
}
}
}
/* check dist */
x1= ( -uevent->mval[0] + (block->maxx+block->minx)/2 );
y1= ( -uevent->mval[1] + (block->maxy+block->miny)/2 );
dist= x1*x1 + y1*y1;
if(dist > disto) {
//printf("left because distance\n");
return 0;
}
else disto= dist;
/* idle for this poor code */
PIL_sleep_ms(10);
counter++;
if(counter > 100) {
// printf("left because of timer (1 sec)\n");
//printf("left because of timer (1 sec)\n");
return 0;
}
}

@ -364,7 +364,7 @@ void uiRoundBoxEmboss(float minx, float miny, float maxx, float maxy, float rad,
gl_round_box_topshade(minx+1, miny+1, maxx-1, maxy-1, rad);
/* total outline */
if(roundboxtype & UI_RB_ALPHA) glColor4ub(0,0,0, 128); else glColor4ub(0,0,0, 255);
if(roundboxtype & UI_RB_ALPHA) glColor4ub(0,0,0, 128); else glColor4ub(0,0,0, 200);
gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
glDisable( GL_LINE_SMOOTH );