예제 #1
0
	void TPopupMenu::processEvent(Event* event) {
		switch (event->getType()) {
			case MouseEvent::MOUSE_MOVED:
				{
					MouseEvent* me = (MouseEvent*)event;
					TMenuItem* m = (TMenuItem*)getComponentAt(getX() + me->getX(), getY() + me->getY());
					if (m) {
						for (int ii = 0; ii < items.size(); ii++) {
							TMenuItem* c = (TMenuItem*)items.get(ii);
							if (c != m && c->getEnabled() && c->getFocused() && c->getType() == TMenuItem::TYPE_ITEM) {
								c->setFocused(false);
								repaint();

							}
						}
						if (m->getEnabled() && !m->getFocused() && m->getType() == TMenuItem::TYPE_ITEM) {
							m->setFocused(true);
							repaint();
						}
					} else {
						for (int ii = 0; ii < items.size(); ii++) {
							TMenuItem* c = (TMenuItem*)items.get(ii);
							if (c->getEnabled() && c->getFocused() && c->getType() == TMenuItem::TYPE_ITEM) {
								c->setFocused(false);
								repaint();
							}
						}
					}
				}
				break;
			case MouseEvent::MOUSE_PRESSED:
				{
					MouseEvent* me = (MouseEvent*)event;
					TMenuItem* m = (TMenuItem*)getComponentAt(getX() + me->getX(), getY() + me->getY());
					if (m && m->getEnabled()) {
						TActionEvent* ae = new TActionEvent();
						ae->setSource(m);
						ae->setActionCommand(m->getActionCommand());
						m->processEvent(ae);
						delete ae;
						hide();
					}
				}
				break;
			default:
				break;
		}
	}
예제 #2
0
void TrackComponent::mouseDrag(const MouseEvent &e)
{
    int posX;
    if(_regionComponents.size() != 0)
    {
        MouseEvent ev = e.getEventRelativeTo(this);
        posX = ev.x;
        for (std::size_t i = 0; i != _regionComponents.size(); ++i)
        {
            _regionComponents.at(i)->toFront(true);
            
            int distance = ev.getDistanceFromDragStartX();
            Rectangle<int> r = _regionComponents.at(i)->getBounds();
            if(_regionComponents.at(i)->getPositionX() < posX && posX < (_regionComponents.at(i)->getPositionX() + _regionComponents.at(i)->getRegionWidth()))
            {
                int newPos = r.getX() + distance;
                int newEnd = r.getX() + distance + r.getWidth();
                _posX.at(i) = newPos;
                _regionComponents.at(i)->setBounds(newPos, 0, newEnd - newPos, getHeight());
                resized();
                
                int64 samplesRange = secondsToSamples(static_cast<double>(_numberOfClips), _sampleRate);
                int64 positionSamples = pixelsToSamples(newPos - _mixerOffset, _numberOfClips * _pixelsPerClip, samplesRange);
                int64 widthInSamples = pixelsToSamples(newEnd - _mixerOffset, _numberOfClips * _pixelsPerClip, samplesRange);
                _track->setTotalLength(widthInSamples);
                _track->move(_regionComponents.at(i)->getRegion(), positionSamples);
                
                if(_posX.at(i) < _mixerOffset)
                {
                    _posX.at(i) = getX() + _mixerOffset ;
                    _track->move(_regionComponents.at(i)->getRegion(), 0);
                    resized();
                }
            }
            else if((getComponentAt(e.x, e.y ) == _regionComponents.at(i)))
            {
                if(ev.x > _mixerOffset)
                {
                    int newPos = r.getX() + distance;
                    int newEnd = r.getX() + distance + r.getWidth();
                    _posX.at(i) = newPos;
                    resized();
                    Region* region = _regionComponents.at(i)->getRegion();
                    region->setNextReadPosition(0);
                    int64 samplesRange = secondsToSamples((double)_numberOfClips, _sampleRate);
                    int64 positionSamples = pixelsToSamples(newPos - _mixerOffset, _numberOfClips * _pixelsPerClip, samplesRange);
                    int64 widthInSamples = pixelsToSamples(newEnd - _mixerOffset, _numberOfClips * _pixelsPerClip, samplesRange);
                    _track->setTotalLength(widthInSamples);
                    _track->move(region, positionSamples);
                    if(_posX.at(i) < _mixerOffset)
                    {
                        _posX.at(i) = getX() + _mixerOffset ;
                        _track->move(region, 0);
                        resized();
                    }
                 }
            }
        }
    }
}
void SequencerComponent::handleMouseEvent (const MouseEvent& e, bool alwaysToggle)
{
	Component *c = getComponentAt (e.getEventRelativeTo(this).getPosition());
	CellComponent *cellComponent = dynamic_cast<CellComponent*> (c);
	
	if (cellComponent != 0) {
		if ((!alwaysToggle) && 
			(cellComponent == lastToggledCellComponent)) {
			return;
		}
		cellComponent->toggleNote();
		lastToggledCellComponent = cellComponent;
	}	
}
예제 #4
0
void
TimelineComponent::mouseDown (const MouseEvent &ev)
{
    dragX = ev.x; dragY = ev.y;

    if (this == getComponentAt (ev.getPosition()))
    {
        if (ev.x > mTrackWidth)
            timelineBodyClicked (ev, heights.trackAtY (ev.y));

        if (ev.x < mTrackWidth)
            timelineTrackHeadersClicked (ev, heights.trackAtY (ev.y));
    }
}
예제 #5
0
 void RootWindow::processEvent(Event* event) {
     if (IsPopuped()) {
         switch (event->getType()) {
             case MouseEvent::MOUSE_PRESSED:
                 if (popupMenu != getComponentAt(getX(), getY())) {
                     HidePopupMenu();
                     if (menuBar) {
                         menuBar->setSelected(false);
                     }
                 }
                 break;
             default:
                 break;
         }
     }
     if (listener) {
         listener->processEvent(event);
     }
 }
예제 #6
0
void Dock::itemDropped (const SourceDetails& dragSourceDetails)
{
    int sourcePanelIndex = -1, sourcePanelSubIndex = -1,
        targetPanelIndex = -1, targetPanelSubIndex = -1;

	Point<int> p (dragSourceDetails.localPosition);
    Component* targetComponent = getComponentAt (p);

    if (findComponent (dragSourceDetails.sourceComponent, sourcePanelIndex, sourcePanelSubIndex)
        && findComponent (targetComponent, targetPanelIndex, targetPanelSubIndex))
    {
        panels.getUnchecked (sourcePanelIndex)->swapComponent (sourcePanelSubIndex,
                                                               panels.getUnchecked (targetPanelIndex),
                                                               targetPanelSubIndex);

        resized();
    }

    somethingIsBeingDraggedOver = false;
    repaint();
}