Ejemplo n.º 1
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_);
    }
}
Ejemplo n.º 2
0
int SliderImpl::hit_thumb(Slider* s, const Event& event) {
    Coord x = event.pointer_x();
    Coord y = event.pointer_y();
    const Extension& e = thumb_patch_->extension();
    if (x >= e.left() && x < e.right() && y >= e.bottom() && y < e.top()) {
        Canvas* c = s->canvas();
        const Transformer& t = s->transformer();
        Hit hit(&event);
        hit.transform(t);
        c->push_transform();
        c->transformer(t);
        thumb_patch_->pick(c, thumb_patch_->allocation(), 0, hit);
        c->pop_transform();
        return hit.any() ? 0 : 1;
    }
    if (x < e.left() || y < e.bottom()) {
        return -1;
    }
    return 1;
}