Esempio n. 1
0
void
ControlPainter::handleLeftButtonPress(const ControlMouseEvent *e)
{
    if (e->itemList.size()) {
        ControllerEventsRuler *ruler = static_cast <ControllerEventsRuler*> (m_ruler);
        std::vector <ControlItem*>::const_iterator it = e->itemList.begin();
        ruler->clearSelectedItems();
        ruler->addToSelection(*it);
        ruler->eraseControllerEvent();

        m_ruler->setCursor(Qt::CrossCursor);
    }
    else {
        // Make new control event here
        // This tool should not be applied to a PropertyControlRuler but in case it is
        ControllerEventsRuler* ruler = dynamic_cast <ControllerEventsRuler*>(m_ruler);
        //if (ruler) ruler->insertControllerEvent(e->x,e->y);
        if (ruler) {

            // If shift was pressed, draw a line of controllers between the new
            // control event and the previous one
            if (e->modifiers & Qt::ShiftModifier) {

                // if Ctrl was pressed, do not erase existing controllers
                bool eraseExistingControllers = !(e->modifiers & Qt::ControlModifier);

                // if no origin point was set, do not draw a line
                if (m_controlLineOrigin.first != -1 && m_controlLineOrigin.second != -1) {
                    ruler->addControlLine(m_controlLineOrigin.first,
                                          m_controlLineOrigin.second,
                                          e->x,
                                          e->y,
                                          eraseExistingControllers);
                }
            } else {

                ControlItem *item = ruler->addControlItem(e->x,e->y);
                ControlMouseEvent *newevent = new ControlMouseEvent(e);
                newevent->itemList.push_back(item);
                m_overItem = true;
                ControlMover::handleLeftButtonPress(newevent);
            }

            // Save these coordinates for next time
            m_controlLineOrigin.first = e->x;
            m_controlLineOrigin.second = e->y;
        }
    }
 
}
Esempio n. 2
0
void
ControlEraser::handleLeftButtonPress(const ControlMouseEvent *e)
{
    if (!e->itemList.size()) return;

    ControllerEventsRuler *ruler = static_cast <ControllerEventsRuler*> (m_ruler);
    std::vector <ControlItem*>::const_iterator it;
    // If any of the covered items is selected, delete entire selection
    for (it = e->itemList.begin(); it != e->itemList.end(); ++it) {
        if ((*it)->isSelected()) {
            ruler->eraseControllerEvent();
            break;
        }
    }

    if (it == e->itemList.end()) {
        it = e->itemList.begin();
        ruler->clearSelectedItems();
        ruler->addToSelection(*it);
        ruler->eraseControllerEvent();
    }
}