Beispiel #1
0
void BoxImpl::full_allocate(AllocationInfo& info) {
    Canvas* c = info.canvas();
    GlyphIndex n = box_->count();
    Allocation* a = info.component_allocations();
    Requisition* r = new Requisition[n];
    GlyphIndex i;
    for (i = 0; i < n; i++) {
        Glyph* g = box_->component(i);
        if (g != nil) {
            g->request(r[i]);
        }
    }
    layout_->allocate(info.allocation(), n, r, a);
    delete [] r;

    Extension& box = info.extension();
    Extension child;
    for (i = 0; i < n; i++) {
        Glyph* g = box_->component(i);
        if (g != nil) {
            child.clear();
            g->allocate(c, a[i], child);
            box.merge(child);
        }
    }
}
Beispiel #2
0
void Slider::reallocate_thumb(const Allocation& a) {
    Patch& thumb = *impl_->thumb_patch_;
    Extension ext;
    ext.clear();
    thumb.allocate(canvas(), a, ext);
    thumb.redraw();
}
Beispiel #3
0
void Slider::reallocate_thumb(const Allocation& a) {
    Patch& thumb = *impl_->thumb_patch_;
    Canvas* c = canvas();
    c->push_transform();
    c->transformer(transformer());
    Extension ext;
    ext.clear();
    thumb.allocate(c, a, ext);
    c->pop_transform();
    thumb.redraw();
}
Beispiel #4
0
void Slider::drag(const Event& e) {
    SliderImpl& s = *impl_;
    if (!s.aborted_ && s.dragging_) {
        if (!s.showing_old_thumb_ && s.old_thumb_ != nil) {
            s.showing_old_thumb_ = true;
            Extension ext;
            ext.clear();
            s.old_thumb_->allocate(
                canvas(), s.thumb_patch_->allocation(), ext
            );
        }
        move_to(e.pointer_x() - s.xoffset_, e.pointer_y() - s.yoffset_);
    }
}
Beispiel #5
0
void Box::print(Printer* p, const Allocation& allocation) const {
    BoxImpl* b = impl_;
    Extension ext;
    ext.clear();
    AllocationInfo& info = b->info(p, allocation, ext);
    if (p->damaged(ext)) {
        Allocation* a = info.component_allocations();
        GlyphIndex n = count();
        for (GlyphIndex i = 0; i < n; i++) {
            Glyph* g = component(i);
            if (g != nil) {
                g->print(p, a[i]);
            }
        }
    }
}
Beispiel #6
0
void Slider::drag(const Event& e) {
    SliderImpl& s = *impl_;
    if (!s.aborted_ && s.dragging_) {
        if (!s.showing_old_thumb_ && s.old_thumb_ != nil) {
            s.showing_old_thumb_ = true;
            Patch* p = s.thumb_patch_;
            Canvas* c = canvas();
            c->push_transform();
            c->transformer(transformer());
            Extension ext;
            ext.clear();
            s.old_thumb_->allocate(c, p->allocation(), ext);
            c->pop_transform();
        }
        Coord x, y;
        s.get_position(this, e, x, y);
        move_to(x - s.xoffset_, y - s.yoffset_);
    }
}
Beispiel #7
0
void BoxImpl::offset_allocate(AllocationInfo& info, Coord dx, Coord dy) {
    Canvas* c = info.canvas();
    Allocation* a = info.component_allocations();
    Extension& box = info.extension();
    Extension child;
    GlyphIndex n = box_->count();
    for (GlyphIndex i = 0; i < n; i++) {
        Glyph* g = box_->component(i);
        if (g != nil) {
            Allocation& a_i = a[i];
            Allotment& ax = a_i.x_allotment();
            Allotment& ay = a_i.y_allotment();
            ax.offset(dx);
            ay.offset(dy);
            child.clear();
            g->allocate(c, a_i, child);
            box.merge(child);
        }
    }
}
Beispiel #8
0
void Box::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (h.right() >= a.left() && h.left() < a.right() &&
            h.top() >= a.bottom() && h.bottom() < a.top()
       ) {
        BoxImpl* b = impl_;
        Extension ext;
        ext.clear();
        AllocationInfo& info = b->info(c, a, ext);
        Allocation* aa = info.component_allocations();
        GlyphIndex n = count();
        for (GlyphIndex i = 0; i < n; i++) {
            Glyph* g = component(i);
            if (g != nil) {
                h.begin(depth, this, i);
                g->pick(c, aa[i], depth + 1, h);
                h.end();
            }
        }
    }
}
Beispiel #9
0
void DragZoneDemo::reallocate() {
    extension_.clear();
    allocate(canvas_, allocation_, extension_);
    canvas_->damage(extension_);
}