Ejemplo n.º 1
0
void Viewer::Align (GraphicComp* comp, Alignment a) {
    Graphic* g = comp->GetGraphic();
    float cl, cb, cr, ct;
    g->GetBounds(cl, cb, cr, ct);

    Perspective* p = GetPerspective();
    float mag = GetMagnification();
    float vl = float(p->curx - p->x0) / mag;
    float vb = float(p->cury - p->y0) / mag;
    float vr = float(p->curx - p->x0 + p->curwidth - 1) / mag;
    float vt = float(p->cury - p->y0 + p->curheight - 1) / mag;

    float dx, dy;

    switch (a) {
    case TopLeft:
    case CenterLeft:
    case BottomLeft:
    case Left:
        dx = vl - cl;
        break;

    case TopCenter:
    case Center:
    case BottomCenter:
        dx = (vr + vl - cr - cl) / 2;
        break;

    case TopRight:
    case CenterRight:
    case BottomRight:
    case Right:
        dx = vr - cr;
        break;
    }
    
    switch (a) {
    case TopLeft:
    case TopCenter:
    case TopRight:
    case Top:
        dy = vt - ct;
        break;

    case CenterLeft:
    case Center:
    case CenterRight:
        dy = (vt + vb - ct - cb) / 2;
        break;

    case BottomLeft:
    case BottomCenter:
    case BottomRight:
    case Bottom:
        dy = vb - cb;
        break;
    }
    MoveCmd mvcmd(GetEditor(), dx, dy);
    comp->Interpret(&mvcmd);
}
Ejemplo n.º 2
0
void View::Move (Graphic* g, Event& e) {
    Coord l, b, r, t, newl, newb;
    float dx, dy, mag = GetMagnification();
    
    damage->Incur(g);
    g->GetBox(l, b, r, t);
    SlidingRect sr(output, canvas, l, b, r, t, e.x, e.y);

    Track(e, sr);
    sr.GetCurrent(newl, newb, r, t);
    dx = (newl - l) / mag;  // get distance moved, corrected to reflect
    dy = (newb - b) / mag;  // current magnification
    g->Translate(dx, dy);
    g->Touch();		    // so that new position will be written out
    damage->Incur(g);
    Update();
}
Ejemplo n.º 3
0
void Viewer::UpdateMagnifVar () {
    MagnifVar* magnifVar = (MagnifVar*) _editor->GetState("MagnifVar");
    if (magnifVar != nil) magnifVar->SetMagnif(GetMagnification());
}