Esempio n. 1
0
	void StencilSlider::refresh() {
		_bar->stopAllActions();
		_bar->setPosition(getBarPosition());
		if (_head != nullptr) {
			_head->setPosition(getHeadPosition());
		}
	}
Esempio n. 2
0
	void StencilSlider::refreshWithScroll(float duration, const EaseBuilder& easeBuilder) {
		_bar->stopAllActions();
		_bar->runAction(easeBuilder.build(MoveTo::create(duration, getBarPosition())));
		if (_head != nullptr) {
			_head->stopAllActions();
			_head->runAction(easeBuilder.build(MoveTo::create(duration, getHeadPosition())));
		}
	}
Esempio n. 3
0
bool midiSequencer::mouseMotion(int _x, int _y)
{
	if(mark.pressed()){
		int newPos=_x-x+getBarPosition();
		if(_x<x) newPos=0;
		else if(_x>ofGetWidth()) newPos=ofGetWidth();
		setCursorPosition(newPos);
		mark.x=cursorPos+x;
	}
	else if(bar.mouseMotion(_x, _y));
}
Esempio n. 4
0
void midiSequencer::update()
{
	band->update(-getBarPosition(),OF_HOR);
	if(isPlaying())
		band->checkActives(cursor()+band->w);
	if(loopBut.pressed()&&cursor()>band->farthestPoint()-x)
		reset();
	midiConductor::update();
	double temp=metronome.getElapsedf()*pps-w/2;
	if (bPlaying&&cursorPos>=w/2+bar.getScrollPosition()&&bar.setScrollPosition(temp));
	mark.x=cursor()+x;
	//bar.update();
}
Esempio n. 5
0
bool midiSequencer::clickDown(int _x, int _y)
{
	if(mark.clickDown(_x, _y));
	else if(_y<mark.y+mark.h){
		mark.setPressed(true);
		setCursorPosition(_x-x+getBarPosition());
		mark.x=cursorPos+x;
	}
	else if(bar.clickDown(_x, _y));
	else if(playBut.toggle(_x, _y)){
		bPlaying=!playBut.pressed();
		if(isPlaying()) midiConductor::pause(),band->stopAll();
		else midiConductor::play();
	}
	else if(rewindBut.clickDown(_x, _y)) reset(), setScrollPos(0);
	else if(loopBut.toggle(_x, _y));
		
}
Esempio n. 6
0
pp_int32 PPSlider::handleEvent(PPObject* sender, PPEvent* event)
{

	if (
		(event->getID() == eLMouseUp &&
		sender == reinterpret_cast<PPObject*>(buttonUp)) ||
		(event->getID() == eLMouseRepeat &&
		sender == reinterpret_cast<PPObject*>(buttonUp)) ||
		(event->getID() == eRMouseUp &&
		sender == reinterpret_cast<PPObject*>(buttonUp)) ||
		(event->getID() == eRMouseRepeat &&
		sender == reinterpret_cast<PPObject*>(buttonUp))
		)
	{
		// Call parent event listener
		//PPEvent e(eBarScrollUp);
		//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
		
		if (currentValue > minValue)
			currentValue--;
	
		float f = (float)(currentValue - minValue)/(maxValue - minValue);

		setBarPosition((pp_int32)(f*65536.0f));
		
		parentScreen->paintControl(this);

		PPEvent e(eValueChanged);

		return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
	}
	if (
		(event->getID() == eLMouseUp &&
		sender == reinterpret_cast<PPObject*>(buttonDown)) ||
		(event->getID() == eLMouseRepeat &&
		sender == reinterpret_cast<PPObject*>(buttonDown)) ||
		(event->getID() == eRMouseUp &&
		sender == reinterpret_cast<PPObject*>(buttonDown)) ||
		(event->getID() == eRMouseRepeat &&
		sender == reinterpret_cast<PPObject*>(buttonDown))
		)
	{
		// Call parent event listener
		//PPEvent e(eBarScrollDown);
		//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);

		if (currentValue < maxValue)
			currentValue++;

		float f = (float)(currentValue - minValue)/(maxValue - minValue);

		setBarPosition((pp_int32)(f*65536.0f));

		parentScreen->paintControl(this);
		
		PPEvent e(eValueChanged);

		return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
	}
	else if (/*event->getID() == eLMouseDown &&*/
			 sender == reinterpret_cast<PPObject*>(backgroundButton))
	{
		
		if (horizontal)
		{
			PPPoint* p = (PPPoint*)event->getDataPtr();
			
			if (p->x < buttonBar->getLocation().x)
			{
				pp_int32 bsize = buttonBar->getSize().width;
				pp_int32 entireSize = size.width - SLIDERBUTTONWIDTH*2;

				float f = (float)entireSize/(float)(entireSize - bsize);

				currentBarPosition-=(pp_int32)(currentBarSize*f);
				if (currentBarPosition < 0) currentBarPosition = 0;
				setBarPosition(currentBarPosition);
				
				// Call parent event listener
				//PPEvent e(eBarPosChanged);
				//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
			}
			else if (p->x > buttonBar->getLocation().x + buttonBar->getSize().width)
			{
				pp_int32 bsize = buttonBar->getSize().width;
				pp_int32 entireSize = size.width - SLIDERBUTTONWIDTH*2;

				float f = (float)entireSize/(float)(entireSize - bsize);

				currentBarPosition+=(pp_int32)(currentBarSize*f);
				if (currentBarPosition > 65536) currentBarPosition = 65536;
				setBarPosition(currentBarPosition);
				
				// Call parent event listener
				//PPEvent e(eBarPosChanged);
				//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
			}
		}
		else 
		{
			PPPoint* p = (PPPoint*)event->getDataPtr();
			
			if (p->y < buttonBar->getLocation().y)
			{
				pp_int32 bsize = buttonBar->getSize().height;
				pp_int32 entireSize = size.height - SLIDERBUTTONHEIGHT*2;

				float f = (float)entireSize/(float)(entireSize - bsize);

				currentBarPosition-=(pp_int32)(currentBarSize*f);
				if (currentBarPosition < 0) currentBarPosition = 0;
				setBarPosition(currentBarPosition);
				
				// Call parent event listener
				//PPEvent e(eBarPosChanged);
				//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
			}
			else if (p->y > buttonBar->getLocation().y + buttonBar->getSize().height)
			{
				pp_int32 bsize = buttonBar->getSize().height;
				pp_int32 entireSize = size.height - SLIDERBUTTONHEIGHT*2;

				float f = (float)entireSize/(float)(entireSize - bsize);

				currentBarPosition+=(pp_int32)(currentBarSize*f);
				if (currentBarPosition > 65536) currentBarPosition = 65536;
				setBarPosition(currentBarPosition);
				
				// Call parent event listener
				//PPEvent e(eBarPosChanged);
				//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
			}
		}
				

	}
	else if ((event->getID() == eLMouseDrag && sender == reinterpret_cast<PPObject*>(buttonBar)) ||
			 (event->getID() == eRMouseDrag && sender == reinterpret_cast<PPObject*>(buttonBar)))
	{
		PPPoint* p = (PPPoint*)event->getDataPtr();
	
		pp_int32 pos = 0,dx,nx;

		if (horizontal)
		{

			dx = (p->x - caughtMouseLocation.x);
			
			/*if (dx < 0)
			{
				__asm
				{
					int 3
				}
			}*/
			
			nx = caughtControlLocation.x + dx;
			//if (nx < location.x + SLIDERBUTTONSIZE)
			//	nx = location.x + SLIDERBUTTONSIZE;
			//if (nx > location.x + size.width - SLIDERBUTTONSIZE*2 - buttonBar->getSize().width)
			//	nx = location.x + size.width - SLIDERBUTTONSIZE*2 - buttonBar->getSize().width;
			
			nx-=(location.x + SLIDERBUTTONWIDTH);
			
			pp_int32 d = (size.width - buttonBar->getSize().width - SLIDERBUTTONWIDTH*2);
			
			if (d != 0)
				pos = nx*65536 / d;			
		}
		else
		{
			dx = (p->y - caughtMouseLocation.y);
			
			/*if (dx < 0)
				__asm
			{
				{
					int 3
				}
			}*/
			
			nx = caughtControlLocation.y + dx;
			//if (nx < location.x + SLIDERBUTTONSIZE)
			//	nx = location.x + SLIDERBUTTONSIZE;
			//if (nx > location.x + size.width - SLIDERBUTTONSIZE*2 - buttonBar->getSize().width)
			//	nx = location.x + size.width - SLIDERBUTTONSIZE*2 - buttonBar->getSize().width;
			
			nx-=(location.y + SLIDERBUTTONHEIGHT);
			
			pp_int32 d = (size.height - buttonBar->getSize().height - SLIDERBUTTONHEIGHT*2);
			
			if (d != 0)
				pos = nx*65536 / d;
		}
		
		setBarPosition(pos);
		// Call parent event listener
		//PPEvent e(eBarPosChanged);
		//return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);
	}
	else
	{
		return 0;
	}

	float f = getBarPosition() / 65536.0f;

	currentValue = (pp_int32)((f * (maxValue - minValue)) + minValue);

	parentScreen->paintControl(this);

	PPEvent e(eValueChanged);

	return eventListener->handleEvent(reinterpret_cast<PPObject*>(this), &e);

}
Esempio n. 7
0
double midiSequencer::cursor()
{
	return cursorPos-getBarPosition();
}