Пример #1
0
void XYView::transform(
    Transformer& t, const Allocation& a, const Allocation& n
) const {
#if 0
    Allotment ax, ay;
    if (view_margin()) {
        const Allotment& alx = a.x_allotment();
        ax.span(alx.span() - 2*view_margin());
        ax.origin(alx.begin() + view_margin());
        ax.alignment(0);
        const Allotment& aly = a.y_allotment();
        ay.span(aly.span() - 2*view_margin());
        ay.origin(aly.begin() + view_margin());
        ay.alignment(0);
    } else {
        ax = a.x_allotment();
        ay = a.y_allotment();
    }
    Allocation al;
    al.allot_x(ax);
    al.allot_y(ay);
    scene2view(al);
#else
    scene2view(a);
    const Allotment& ax = a.x_allotment();
    const Allotment& ay = a.y_allotment();
#endif
    const Allotment& nx = n.x_allotment();
    const Allotment& ny = n.y_allotment();
    XYView* v = (XYView*)this;
    csize(ax.begin(), ax.span(), ay.begin(), ay.span());
    float sx = xsize_/width();
    float sy = ysize_/height();
    XYView* xv = (XYView*)this;
    xv->x_pick_epsilon_ = pick_epsilon/sx;
    xv->y_pick_epsilon_ = pick_epsilon/sy;
    t.translate( -left(), -bottom());
    t.scale(sx, sy);
    t.translate(ax.begin(), ay.begin());
#if 0
    printf("XYView::transform ax origin=%g span=%g alignment=%g begin=%g\n",
           ax.origin(), ax.span(), ax.alignment(), ax.begin());
    printf("XYView::transform ay origin=%g span=%g alignment=%g begin=%g %g\n",
           ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end());
    printf("XYView::transform natx origin=%g span=%g alignment=%g begin=%g\n",
           nx.origin(), nx.span(), nx.alignment(), nx.begin());
    printf("XYView::transform naty origin=%g span=%g alignment=%g begin=%g %g\n",
           ny.origin(), ny.span(), ny.alignment(), ny.begin(), ny.end());
#endif
}
Пример #2
0
void View::transform(
    Transformer& t, const Allocation& a, const Allocation&
) const {
    scene2view(a);
    const Allotment& ax = a.x_allotment();
    const Allotment& ay = a.y_allotment();
    csize(ax.begin(), ax.span(), ay.begin(), ay.span());
    float sx = ax.span()/XYView::width();
    float sy = ay.span()/XYView::height();
//	if (sx > sy) sx = sy;
    t.translate( -x(), -y());
    t.scale(sx, sx);
    View* v = (View*)this;
    v->x_pick_epsilon_ = pick_epsilon/sx;
    v->y_pick_epsilon_ = pick_epsilon/sx;
    t.translate((ax.begin() + ax.end())/2,(ay.begin() + ay.end())/2);
//printf("\nx origin=%g span=%g alignment=%g begin=%g end=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin(), ax.end());
//printf("\ny origin=%g span=%g alignment=%g begin=%g end=%g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end());
    Coord x1,y1;
    t.transform(x() - x_span_/2, y() - y_span_/2, x1, y1);
    if (!Math::equal(ax.begin(), x1, 1) || !Math::equal(ay.begin(), y1, 1)) {
        t.inverse_transform(ax.begin(), ay.begin(), x1, y1);
        v->x_span_ = 2*(x() - x1);
        v->y_span_ = 2*(y() - y1);
        v->size(x1,y1,x1+v->x_span_, y1+v->y_span_);
    }

}
Пример #3
0
void BevelFrame::allocate_body(Glyph* g, Coord t, Allocation& a) const {
    Requisition req;
    g->request(req);
    Coord h = hmargin_ ? t : 0, v = vmargin_ ? t : 0;
    Allotment& ax = a.x_allotment();
    Coord x_span = ax.span() - h - h;
    Coord x_offset = h;
    Coord x_align = ax.alignment();
    const Requirement& rx = req.x_requirement();
    if (rx.defined()) {
	Coord x_usable = rx.natural() + rx.stretch();
	if (x_span > x_usable) {
	    x_offset += xalign_ * (x_span - x_usable);
	    x_span = x_usable;
	}
    }
    ax.span(x_span);
    ax.offset(x_offset * (1 - x_align - x_align));

    Allotment& ay = a.y_allotment();
    Coord y_span = ay.span() - v - v;
    Coord y_offset = v;
    Coord y_align = ay.alignment();
    const Requirement& ry = req.y_requirement();
    if (ry.defined()) {
	Coord y_usable = ry.natural() + ry.stretch();
	if (y_span > y_usable) {
	    y_offset += yalign_ * (y_span - y_usable);
	    y_span = y_usable;
	}
    }
    ay.span(y_span);
    ay.offset(y_offset * (1 - y_align - y_align));
}
Пример #4
0
void TransformFitter::transform(
    Transformer& t, const Allocation& a, const Allocation& natural
) const {
    const Allotment& natural_x = natural.x_allotment();
    const Allotment& natural_y = natural.y_allotment();
    if (!Math::equal(natural_x.span(), Coord(0), float(1e-2)) &&
	!Math::equal(natural_y.span(), Coord(0), float(1e-2))
    ) {
	const Allotment& ax = a.x_allotment();
	const Allotment& ay = a.y_allotment();
	t.scale(
	    a.x_allotment().span() / natural_x.span(),
	    a.y_allotment().span() / natural_y.span()
	);
    }
    t.translate(a.x(), a.y());
}
Пример #5
0
void YSlider::allocate_thumb(const Allocation& a) {
    redraw_thumb();
    Allocation thumb_a;
    allot_thumb_major_axis(
        a, Dimension_Y, adjustable_, minimum_thumb_size(),
        yscale_, thumb_a.y_allotment()
    );
    allot_thumb_minor_axis(a.x_allotment(), thumb_a.x_allotment());
    reallocate_thumb(thumb_a);
}
Пример #6
0
void XYView::allocate(Canvas* c, const Allocation& a, Extension& ext) {
#if defined(WIN32) || defined(CYGWIN)
    if (a.y_allotment().span() <= 0. || a.x_allotment().span() <= 0.) {
        // a bug in mswindows iconify
        return;
    }
#endif
    if (canvas_ == NULL) {
        canvas_ = c;
    }
    c->push_transform();
    TransformSetter::allocate(c, a, ext);
    c->pop_transform();
}
Пример #7
0
void XYView::scene2view(const Allocation& a) const {
    float m00 = width()/a.x_allotment().span();
    float m11 = height()/a.y_allotment().span();

    //takes a canvas transformation from scene to parent glyph coordinates
    // transforms vectors from original to xyview
    XYView* xyv = (XYView*)this;
    xyv->scene2viewparent_ = Transformer(
                                 m00, 0,
                                 0, m11,
                                 left() - a.left()*m00,
                                 bottom() - a.bottom()*m11
                             );
//print_t("scene2view", scene2viewparent_);
}
Пример #8
0
void GLPolygonTest::draw(Canvas*, const Allocation& a) const {
    RGBcolor(255, 255, 255);
    clear();

    Coord x_size = a.x_allotment().span();
    Coord y_size = a.y_allotment().span();
    Coord x_mid = x_size * 0.5;
    Coord y_mid = y_size * 0.5;

    RGBcolor(255, 0, 0);
    triangle(
	0.0, 0.0, 0.0,
	x_mid, y_size, 0.0,
	x_size, 0.0, 0.0
    );
}
Пример #9
0
void TBScrollBoxImpl::reallocate() {
    if (canvas_ == nil) {
	return;
    }
    ScrollBox* s = scrollbox_;
    GlyphIndex n = s->count();
    end_ = n;
    TBScrollBoxList& list = visible_;
    list.remove_all();
    Requisition req;
    TBScrollBoxInfo info;
    Extension e_i;
    const Requirement& r = req.y_requirement();
    Coord p = allocation_.top();
    Coord bottom = allocation_.bottom();
    bool found_start = false;
    for (GlyphIndex i = start_; i < n; i++) {
	Glyph* g = s->component(i);
	if (g != nil) {
	    g->request(req);
	    Coord span = r.natural();
	    if (!Math::equal(span, Coord(0), float(1e-2))) {
		if (!found_start) {
		    start_ = i;
		    found_start = true;
		}
		Coord alignment = r.alignment();
		p -= span;
		if (p < bottom) {
		    end_ = i;
		    break;
		}
		info.glyph_ = g;
		Allotment& ax = info.allocation_.x_allotment();
		ax = allocation_.x_allotment();
		Allotment& ay = info.allocation_.y_allotment();
		ay.span(span);
		ay.origin(p + Coord(alignment * span));
		ay.alignment(alignment);
		list.append(info);
		g->allocate(canvas_, info.allocation_, e_i);
	    }
	}
    }
}