VerticalToolHandler::VerticalToolHandler(Redrawable* view, PageRef page, double y, double zoom) { XOJ_INIT_TYPE(VerticalToolHandler); this->startY = y; this->endY = y; this->view = view; this->page = page; this->layer = this->page->getSelectedLayer(); this->jumpY = 0; for (Element* e : *this->layer->getElements()) { if (e->getY() >= y) { this->elements.push_back(e); } } for (Element* e : this->elements) { this->layer->removeElement(e, false); this->jumpY = MAX(this->jumpY, e->getY() + e->getElementHeight()); } this->jumpY = this->page->getHeight() - this->jumpY; this->crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, this->page->getWidth() * zoom, (this->page->getHeight() - y) * zoom); cairo_t* cr = cairo_create(this->crBuffer); cairo_scale(cr, zoom, zoom); cairo_translate(cr, 0, -y); DocumentView v; v.drawSelection(cr, this); cairo_destroy(cr); view->rerenderPage(); }
VerticalToolHandler::VerticalToolHandler(Redrawable * view, PageRef page, double y, double zoom) { XOJ_INIT_TYPE(VerticalToolHandler); this->startY = y; this->endY = y; this->view = view; this->page = page; this->layer = this->page.getSelectedLayer(); this->elements = NULL; this->jumpY = 0; ListIterator<Element *> it = this->layer->elementIterator(); while (it.hasNext()) { Element * e = it.next(); if (e->getY() >= y) { this->elements = g_list_append(this->elements, e); } } for (GList * l = this->elements; l != NULL; l = l->next) { Element * e = (Element *) l->data; this->layer->removeElement(e, false); this->jumpY = MAX(this->jumpY, e->getY() + e->getElementHeight()); } this->jumpY = this->page.getHeight() - this->jumpY; this->crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, this->page.getWidth() * zoom, (this->page.getHeight() - y) * zoom); cairo_t * cr = cairo_create(this->crBuffer); cairo_scale(cr, zoom, zoom); cairo_translate(cr, 0, -y); DocumentView v; v.drawSelection(cr, this); cairo_destroy(cr); view->rerenderPage(); }