UIElement* UI::scrollableElementAt(const vec2& pos) { std::list<UIElement*> found_elements; elementsAt(pos, found_elements); for(UIElement* found : found_elements) { //debugLog("scrollable %d", found->zindex); if(found) { //debugLog("element %s (%d) zindex %d", found->getElementName().c_str(), found->getType(), found->zindex); } while(found && !found->isScrollable()) { found = found->parent; } if(found) { //debugLog("scrolling element %s zindex %d", found->getElementName().c_str(), found->zindex); return found; } } return 0; }
void ExampleView::mousePressEvent(QMouseEvent* event) { startMove = imatrix.map(QPointF(event->pos())); QPointF pos(imatrix.map(QPointF(event->pos()))); foreach (Element* e, elementsAt(pos)) { if (e->type() == ElementType::NOTE) { emit noteClicked(static_cast<Note*>(e)); break; } } }
void ExampleView::dropEvent(QDropEvent* event) { QPointF pos(imatrix.map(QPointF(event->pos()))); if (!dragElement) return; if (dragElement->type() != ElementType::ICON) { delete dragElement; dragElement = 0; return; } foreach (Element* e, elementsAt(pos)) { if (e->type() == ElementType::NOTE) { Icon* icon = static_cast<Icon*>(dragElement); Chord* chord = static_cast<Note*>(e)->chord(); emit beamPropertyDropped(chord, icon); switch (icon->iconType()) { case IconType::SBEAM: chord->setBeamMode(Beam::Mode::BEGIN); break; case IconType::MBEAM: chord->setBeamMode(Beam::Mode::AUTO); break; case IconType::BEAM32: chord->setBeamMode(Beam::Mode::BEGIN32); break; case IconType::BEAM64: chord->setBeamMode(Beam::Mode::BEGIN64); break; default: break; } score()->doLayout(); break; } } event->acceptProposedAction(); delete dragElement; dragElement = 0; setDropTarget(0); }
void ExampleView::dragMoveEvent(QDragMoveEvent* event) { event->acceptProposedAction(); if (!dragElement || dragElement->type() != ElementType::ICON) return; QPointF pos(imatrix.map(QPointF(event->pos()))); QList<Element*> el = elementsAt(pos); bool found = false; foreach(const Element* e, el) { if (e->type() == ElementType::NOTE) { setDropTarget(const_cast<Element*>(e)); found = true; break; } } if (!found) setDropTarget(0); dragElement->scanElements(&pos, moveElement, false); _score->update(); return; }
UIElement* UI::selectElementAt(const vec2& pos) { double_click_timer = 0.0f; std::list<UIElement*> found_elements; elementsAt(pos, found_elements); UIElement* found = 0; for(UIElement* e : found_elements) { //debugLog("select %s %d", e->getElementName().c_str(), e->zindex); if(!e->isSelectable()) continue; found = e; break; } if(selectedElement == found) return selectedElement; if(selectedElement != 0) { selectedElement->setSelected(false); } //if(found) debugLog("selected element %s (%d) zindex %d", found->getElementName().c_str(), found->getType(), found->zindex); if(!found) { selectedElement = 0; return 0; } selectedElement = found; selectedElement->setSelected(true); return selectedElement; }