Ejemplo n.º 1
0
    void calcContextButtonPosition(mgvector<float>& pos, int n, const Box2d& box)
    {
        Box2d selbox(box);

        selbox.inflate(12, 18);
        if (box.height() < (n < 7 ? 40 : 80)) {
            selbox.deflate(0, (box.height() - (n < 7 ? 40 : 80)) / 2);
        }
        if (box.width() < (n == 3 || n > 4 ? 120 : 40)) {
            selbox.deflate((box.width() - (n==3||n>4 ? 120 : 40)) / 2, 0);
        }

        Box2d rect(calcButtonPosition(pos, n, selbox));
        Vector2d off(moveActionsInView(rect));

        for (int i = 0; i < n; i++) {
            pos.set(2 * i, pos.get(2 * i) + off.x, pos.get(2 * i + 1) + off.y);
        }
    }
Ejemplo n.º 2
0
Archivo: line.c Proyecto: kahrs/cda
selpt(Line *dl,Point p)
{
	int s,m,prop;
	Rectangle r;
	Line *l=dl;
	for (m = 0; l; l = l->next) {
		r = l->r;
		prop = 0;
		switch (l->type) {
		case LINE:
			if (EQ(p,P))
				l->sel = 3;
			else if (EQ(p,Q))
				l->sel = 12;
			else if (Y == p.y && Y == V && (p.x-X)*(U-p.x) > 0)
				prop = 1;
			else if (X == p.x && X == U && (p.y-Y)*(V-p.y) > 0)
				prop = 1;
			else
				continue;
			m |= (l->mod |= LINEHIT);
			if (prop) {
				l->sel = 15;
				m |= selbox(dl,canon(r));
			}
			break;
		case BOX:
		case MACRO:
			if (EQ(p,ul(r)))
				selborder(dl,l->sel=3,r);
			else if (EQ(p,lr(r)))
				selborder(dl,l->sel=12,r);
			else if (EQ(p,ll(r)))
				selborder(dl,l->sel=9,r);
			else if (EQ(p,ur(r)))
				selborder(dl,l->sel=6,r);
			else if (l->type == BOX && IN(p,r)) {
				l->sel = 15;
				m |= selbox(dl,r);
			}
			else
				continue;
			m |= (l->mod |= BOXHIT);
			break;
		case INST:
			if (WITHIN(p,r)) {
				l->sel = 15;
				m |= (l->mod |= BOXHIT) | selbox(dl,r);
			}
			break;	
		case DOTS:
			if (EQ(p,ul(r)))
				l->sel=3;
			else if (EQ(p,lr(r)))
				l->sel=12;
			else if (EQ(p,ll(r)))
				l->sel=9;
			else if (EQ(p,ur(r)))
				l->sel=6;
			else if (IN(p,r))
				l->sel = 15;
			else
				continue;
			m |= (l->mod |= DOTHIT);
			break;
		case STRING:
			if (EQ(p,P)) {
				l->sel = 3;
				m |= (l->mod |= STRHIT);
			}
			break;
		}
	}
	return m;
}