示例#1
0
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
    mouseD.set((float)x - mouseP.x, (float)y - mouseP.y);
    target = targetTemp - 0.01f*mouseD.x*getScreenX(targetTemp) + 0.01f*mouseD.y*getScreenY(targetTemp);

    cout<<"X:"<<target.x<<endl;
    cout<<"Y:"<<target.y<<endl;
}
示例#2
0
void Plotter::showAxes(float x, float y) {
	axes = true;
	axesX = x;
	axesY = y;
	tft.drawFastHLine(xo, getScreenY(y), width, PLOTTER_BORDER);	// x-axis
	tft.drawFastVLine(getScreenX(x), yo, height, PLOTTER_BORDER);	// y-axis
}
//==============================================================================
void VstPluginWindow::moved()
{
    DialogWindow::moved();

    if (plugin)
    {
        if (externalEditor)
        {
            externalEditor->updateWindowPosition (getScreenX (),
                                                  getScreenY ());
        }

        plugin->setValue (PROP_WINDOWXPOS, getScreenX ());
        plugin->setValue (PROP_WINDOWYPOS, getScreenY ());
    }
}
示例#4
0
void phdGuiVerSlider::draw(float _x, float _y) {

	if(!isVisible() || getManager() == NULL) return;

	ofPushStyle();
	ofPushMatrix();
	ofTranslate(getScreenX(), getScreenY(), 0);

	ofColor _border = getManager()->getBorderColor(this);

	drawFilledBorderRectangle(0,0,getWidth(),getHeight(), getManager()->getFillColor(this), _border);

	float _pos = (1.0-value) * getHeight();
	ofLine(0.0, _pos, getWidth(), _pos); 
	drawFilledBorderRectangle(0.0, _pos, getWidth(), getHeight()-_pos, _border, _border);

	ofSetColor(getManager()->getTextColor(this));
	//ofDrawBitmapString(caption, (getWidth()-(caption.size()*8.0))/2.0, getHeight() / 2.0 + 4.0);
	//ofDrawBitmapString(caption, (getWidth()-(caption.size()*8.0))/2.0, 12.0);

	string _str = "";
	for(int i = 0; i < caption.size(); i++) _str += caption.substr(i,1) + "\n";
	ofDrawBitmapString(_str, (getWidth()-(8.0))/2.0, 12.0);

	ofPopMatrix();
	ofPopStyle();

	drawChildren(_x, _y);
}
void EnveloppeAbstract::mouseUp (const MouseEvent &event)  {
    if (draggingPointIndex != -1) {
        Desktop::setMousePosition(Point<int>(getScreenX() + pointList[draggingPointIndex].get()->getPositionOnScreenX(),
                getScreenY() + pointList[draggingPointIndex].get()->getPositionOnScreenY()));
        draggingPointIndex = -1;
    }
    setMouseCursor(MouseCursor::NormalCursor);
    repaint();
}
void EnvelopeHandleComponent::mouseDown(const MouseEvent& e)
{
#ifdef MYDEBUG
	printf("MyEnvelopeHandleComponent::mouseDown (%d, %d)\n", e.x, e.y);
#endif
	
	setMouseCursor(MouseCursor::NoCursor);
	
	if(e.mods.isShiftDown()) {
		
        if(!shouldLockTime && !shouldLockValue)
        {
            getParentComponent()->setLegendTextToDefault();
            removeThisHandle();
		}
        
        return; // dont send drag msg
		
	} 
	else if(e.mods.isCtrlDown())
	{
		if(getParentComponent()->getAllowNodeEditing())
		{
			ignoreDrag = true;
			
			if(PopupComponent::getActivePopups() < 1)
			{
				EnvelopeNodePopup::create(this, getScreenX()+e.x, getScreenY()+e.y);
			}
		}
	}
	else 
	{
		
		offsetX = e.x;
		offsetY = e.y;
		
		resizeLimits.setMinimumOnscreenAmounts(HANDLESIZE,HANDLESIZE,HANDLESIZE,HANDLESIZE);
		
		EnvelopeHandleComponent* previousHandle = getPreviousHandle();
		EnvelopeHandleComponent* nextHandle = getNextHandle();
		
		int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX()+2;
		int rightLimit = nextHandle == 0 ? getParentWidth()-HANDLESIZE : nextHandle->getX()-2;
//		int leftLimit = previousHandle == 0 ? 0 : previousHandle->getX();
//		int rightLimit = nextHandle == 0 ? getParentWidth()-HANDLESIZE : nextHandle->getX();

		
		resizeLimits.setAdjacentHandleLimits(leftLimit, rightLimit);

		dragger.startDraggingComponent(this, e);//&resizeLimits);
	
	}
    
    getParentComponent()->sendStartDrag();
}
示例#7
0
// sample configured channels and plot them
// this function is called from the sampling timer - there should be no y-axis showing
void Plotter::sample() {
	float xValue;									// x coordinate, value
	uint16_t xVal;									// x coordinate, screen pixels
	uint8_t eraseWidth;
	uint16_t xAxisPosition, yAxisPosition;

	switch (style) {
		case scan:
			xValue = millis() - startTime + xMin;		// ms elapsed since capture began
			if (xValue >= xMax) {					// if the time-axis has filled up
				startTime = millis();				// and reset the x-axis timer
				xValue = xMin;						// should wrap
			}
			xVal = getScreenX(xValue);
			eraseWidth = min(5,xo+width-xVal-1);						// clearing out previous data just ahead
			xAxisPosition = getScreenY(axesY);							// height of x-axis
			yAxisPosition = getScreenX(axesX);							// position of y-axis
			tft.fillRect(xVal+1, yo, eraseWidth, height, PLOTTER_BACKGROUND);
			if (axes) {
				tft.drawFastHLine(xVal+1, xAxisPosition, eraseWidth, PLOTTER_BORDER);			// replace possibly-erased x-axis segment
				if (yAxisPosition >= xVal && yAxisPosition < xVal + eraseWidth ) {tft.drawFastVLine(yAxisPosition, yo, height, PLOTTER_BORDER);}		// replace erased y-axis
			}
			break;
		case track:
			trackCounter++;
			if (trackCounter >= xo + width) {
				trackCounter = xo;
				clear();							// OK to take the time to clear the screen
				if (axes) { showAxes(); }			// tracking is not meant to be fast anyway
			}
			xVal = trackCounter;
			break;
		default:
			xVal = xo;
	}

	for (int i=0; i<nChannels; i++) {
		float yValue = channels[i].sample();
		tft.drawPixel(xVal, getScreenY(yValue), channels[i].getColor());
	}

	sampleTimer.reset();					// reset the timer for the next sample
}
void EnvelopeComponent::mouseDown(const MouseEvent& e)
{
#ifdef MYDEBUG
	printf("MyEnvelopeComponent::mouseDown(%d, %d)\n", e.x, e.y);
#endif
	
	if(e.mods.isShiftDown()) 
	{
		
		// not needed ?
				
	}
	else if(e.mods.isCtrlDown())
	{
		if(getAllowCurveEditing())
		{
			float timeAtClick = convertPixelsToDomain(e.x);
			
			int i;
			EnvelopeHandleComponent* handle = 0;
			
			for(i = 0; i < handles.size(); i++) {
				handle = handles.getUnchecked(i);
				if(handle->getTime() > timeAtClick)
					break;
			}
			
			if(PopupComponent::getActivePopups() < 1)
			{
				EnvelopeHandleComponent* prev = handle->getPreviousHandle();
				
				if(!prev)
				{
					EnvelopeCurvePopup::create(handle, getScreenX()+e.x, getScreenY()+e.y);
				}
				else
				{
					EnvelopeCurvePopup::create(handle, 
											   (handle->getScreenX() + prev->getScreenX())/2, 
											   jmax(handle->getScreenY(), prev->getScreenY())+10);
				}
			}
		}
	}
	else 
	{
		draggingHandle = addHandle(e.x,e.y, EnvCurve::Linear);
		
		if(draggingHandle != 0) {
			setMouseCursor(MouseCursor::NoCursor);
			draggingHandle->mouseDown(e.getEventRelativeTo(draggingHandle));
			draggingHandle->updateLegend();
		}
	}
}
示例#9
0
void phdGuiVerFader::draw(float _x, float _y) {

	if(!isVisible() || getManager() == NULL) return;

	if(fader != NULL) { value = fader->getValue(); }

	ofPushStyle();
	ofPushMatrix();
	ofTranslate(getScreenX(), getScreenY(), 0);

	if(fader != NULL) {
		fader->setCoords(getScreenX(), getScreenY(), getWidth(), getHeight());
		fader->draw(getManager()->getFillColor(this), getManager()->getBorderColor(this), getManager()->getTextColor(this));
	}

	ofSetColor(getManager()->getTextColor(this));
	string _str = "";
	for(int i = 0; i < caption.size(); i++) _str += caption.substr(i,1) + "\n";
	ofDrawBitmapString(_str, (getWidth()-(8.0))/2.0, 28.0);

	ofPopMatrix();
	ofPopStyle();
}
//==============================================================================
void Joystick::restoreMouseIfHidden()
{
    if (mouseWasHidden)
    {
        mouseWasHidden = false;

        Component* c = Component::getComponentUnderMouse();
        if (c == 0)
            c = this;
        c->enableUnboundedMouseMovement (false);

        Desktop::setMousePosition (getScreenX() + draw_x,
                                   getScreenY() + draw_y);
    }
}
示例#11
0
void HadronLabel::mouseDoubleClick(const MouseEvent& e) 
{
    if (use_modal_editor_) {
        
        if (isEditableOnDoubleClick() && ! e.mods.isPopupMenu()) {
            
            ModalComponentManager::Callback* userCallback = 0;
            ScopedPointer<ModalComponentManager::Callback> userCallbackDeleter (userCallback);
            Component::SafePointer<Component> prevFocused (Component::getCurrentlyFocusedComponent());
            Component::SafePointer<Component> prevTopLevel ((prevFocused != 0) ? prevFocused->getTopLevelComponent() : 0);
            
            ScopedPointer <TextEditor> texteditor (createEditorComponent());
            texteditor->setColour(TextEditor::backgroundColourId, Colours::white);
            texteditor->setWantsKeyboardFocus (true);
            texteditor->setAlwaysOnTop (true);
            
            // Find screen position
            Rectangle<int> sr (getBounds ());
            sr.setPosition (getScreenX(), getScreenY());
            int fontheight = static_cast<int>(texteditor->getFont().getHeight()) + 4;
            if (sr.getHeight() > fontheight) {
                sr.translate (0, (sr.getHeight() - fontheight)/2);
                sr.setHeight (fontheight);
            }
            texteditor->setBounds(sr);
            
            texteditor->setText(getText(),false);
            texteditor->setHighlightedRegion (Range <int> (0, getText().length ()));
            texteditor->setVisible (true);
            texteditor->grabKeyboardFocus();
            texteditor->addToDesktop (ComponentPeer::windowIsTemporary, 0);
            
            texteditor->addListener (this);
            texteditor->enterModalState (false);
            texteditor->grabKeyboardFocus();
            
            texteditor->runModalLoop();
            
            if (prevTopLevel != 0)
                prevTopLevel->toFront (true);
            if (prevFocused != 0)
                prevFocused->grabKeyboardFocus();
        }
    }
    else {
        Label::mouseDoubleClick(e);
    }
}
示例#12
0
void phdGuiLabel::draw(float _x, float _y) {

	if(!isVisible() || getManager() == NULL) return;

	ofPushStyle();
	ofPushMatrix();
	ofTranslate(getScreenX(), getScreenY(), 0);

	ofSetColor(getManager()->getTextColor(this));
	ofDrawBitmapString(caption, 1.0, 11.0);

	ofPopMatrix();
	ofPopStyle();

	drawChildren(_x, _y);
}
bool ApplicationWin32Imp::createWindow()
{
    if( isWindowCreated() ) return false;

    hInstance_ = ( HINSTANCE )GetModuleHandle( NULL );

    if( false == MyRegisterClass( hInstance_ ) )
        return false;

    const int x = getScreenX();
    const int y = getScreenY();
    const int width = getScreenWidth();
    const int height = getScreenHeight();
    hWnd_ = InitInstance( hInstance_, SW_SHOW, x, y, width, height );

    return NULL != hWnd_;
}
void EnvelopeHandleComponent::mouseDrag(const MouseEvent& e)
{
	if(ignoreDrag == true) return;
	
	if(e.mods.isAltDown()) {

		int moveX = e.x-offsetX;
		int moveY = offsetY-e.y;
		
		offsetTimeAndValue(moveX * FINETUNE, moveY * FINETUNE, FINETUNE);
		ignoreDrag = true;
		setMousePositionToThisHandle();
		ignoreDrag = false;
		
	} else {
				
		dragger.dragComponent(this, e, &resizeLimits);
	}
	
	updateLegend();
	getParentComponent()->repaint();
	getParentComponent()->sendChangeMessage();
	
	if(lastX == getX() && lastY == getY()) {	
		setMousePositionToThisHandle();
#ifdef MYDEBUG
		int x, y;
		Desktop::getMousePosition(x, y);	
		printf("screen pos (and mouse pos): %d (%d) %d (%d)\n", getScreenX(), x, getScreenY(), y);
#endif	
	}

	lastX = getX();
	lastY = getY();
	
#ifdef MYDEBUG
	double domain = getParentComponent()->convertPixelsToDomain(getX());
	double value = getParentComponent()->convertPixelsToValue(getY());
	printf("MyEnvelopeHandleComponent::mouseDrag(%d, %d) [%f, %f] (%d, %d)\n", e.x, e.y, 
		   domain,
		   value,
		   getParentComponent()->convertDomainToPixels(domain),
		   getParentComponent()->convertValueToPixels(value));
#endif
	
}
示例#15
0
void phdGuiTitleBar::draw(float _x, float _y) {

	if(!isVisible() || getManager() == NULL) return;

	ofPushStyle();
	ofPushMatrix();
	ofTranslate(getScreenX(), getScreenY(), 0);

	drawFilledBorderRectangle(0, 0, getWidth(), getHeight(),  getManager()->getFillColor(this),  getManager()->getBorderColor(this));

	ofSetColor( getManager()->getTextColor(this));
	ofDrawBitmapString(caption, (getWidth()-(caption.size()*8.0))/2.0, getHeight() / 2.0 + 4.0);

	ofPopMatrix();
	ofPopStyle();

	drawChildren(_x, _y);
}
示例#16
0
void phdGuiStringField::draw(float _x, float _y) {

    if(!isVisible() || getManager() == NULL) return;

    ofPushStyle();
    ofPushMatrix();
    ofTranslate(getScreenX(), getScreenY(), 0);

    drawFilledBorderRectangle(0,0,getWidth(),getHeight(),  getManager()->getFillColor(this),  getManager()->getBorderColor(this));

    ofSetColor( getManager()->getTextColor(this));
    ofDrawBitmapString(value, 4, 12);

    ofPopMatrix();
    ofPopStyle();

    drawChildren(_x, _y);
}
示例#17
0
//--------------------------------------------------------------
void testApp::draw(){

    myCam.begin();

    ofSetColor(0, 0, 250);
    scrX = getScreenX(target);
    scrY = getScreenY(target);
    float l = 100.0f;
    for(int i = 0; i < 100; i++){
        ofLine(camPos.x + l*(sin(i*PI*2.0f/100.0f)*scrY.x + cos(i*PI*2.0f/100.0f)*scrX.x+target.x),
               camPos.y + l*(sin(i*PI*2.0f/100.0f)*scrY.y + cos(i*PI*2.0f/100.0f)*scrX.y+target.y),
               camPos.z + l*(sin(i*PI*2.0f/100.0f)*scrY.z + cos(i*PI*2.0f/100.0f)*scrX.z+target.z),
               camPos.x + l*(target.x),
               camPos.y + l*(target.y),
               camPos.z + l*(target.z)
               );
    }
    ofSetColor(255, 255, 200);
    float r = 5000.0f;
    for(int i = 0; i < 100; i++){
            ofLine(0.0f, -500.0f, 0.0f, r*sin(i*2.0f*PI/100.0f), -200.0f, r*cos(i*2.0f*PI/100.0f));
    }
    ofPushMatrix();
    ofTranslate(point);

    //繧ェ繝悶ず繧ァ繧ッ繝郁・菴薙・蝗櫁サ「
    //ofRotateY(ofGetElapsedTimef() * 10);

    //Aachan
    if (isAachan) {
        //ofTranslate(ofGetWidth()/3, 0);

        ofSetColor(200+ofRandom(55), 200, 200);
        aachan.drawWireframe();
        ofSetColor(200+ofRandom(55), 200, 200);
        aachan.drawFaces();
        //aachan.drawWireframe();
        //aachan.drawVertices();
    }

    //NOCCHi
    if (isNOCCHi) {
        //ofTranslate(ofGetWidth()/2, -ofGetHeight()/2);


        //ofSetColor(30, 30, 30);
        ofSetColor(200, 200, 200+ofRandom(55));
        nocchi.drawWireframe();
        ofSetColor(200, 200, 200+ofRandom(55));
        nocchi.drawFaces();
        //nocchi.drawVertices();
        ofSetColor(0, 0, 0);
        nocchi.drawWireframe();

    }

    //Kashiyuka
    if (isKashiyuka) {

        //ofSetColor(70, 70, 70);
        ofSetColor(200, 200+ofRandom(55), 200);
        kashiyuka.drawWireframe();
        ofSetColor(200, 200+ofRandom(55), 200);
        kashiyuka.drawFaces();
        //kashiyuka.drawWireframe();
        //kashiyuka.drawVertices();
    }


    ofPopMatrix();

    myCam.end();
}
示例#18
0
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
    mouseD.set((float)x - mouseP.x, (float)y - mouseP.y);
    target = targetTemp - 0.01f*mouseD.x*getScreenX(targetTemp) + 0.01f*mouseD.y*getScreenY(targetTemp);
}
void EnvelopeHandleComponent::setMousePositionToThisHandle()
{
	Desktop::setMousePosition(Point<int>(getScreenX()+offsetX, getScreenY()+offsetY));
}
示例#20
0
// plot a point to the screen, color uses default value if not specified
void Plotter::plot(float x, float y, uint16_t aColor) {
	tft.drawPixel(getScreenX(x), getScreenY(y), aColor);
}
示例#21
0
    void paint (Graphics& g)
    {
        const TwindyTabbedComponent* const t = (const TwindyTabbedComponent*) getParentComponent();

        if (t != 0)
        {
#if JUCE_NEW
            const Rectangle<int> thisBounds (0, 0, getWidth(), getHeight());
#else
            const Rectangle thisBounds (0, 0, getWidth(), getHeight());
#endif

            int i;
            for (i = 0; i < getNumChildComponents(); ++i)
            {
                TwindyTabbedComponentBasicTab* const c = (TwindyTabbedComponentBasicTab*) getChildComponent (i);

                if (c != (TwindyTabbedComponentBasicTab*)t->tabList [t->currentTab])
                {
                    const float indent = 2.0f;

                    float x1 = (float)c->getX();
                    float y1 = (float)c->getY();
                    float x2 = x1 + c->getWidth();
                    float y2 = y1 + c->getHeight();

                    if (c->getBounds().intersects (thisBounds))
                    {
                        if (t->orientation == TwindyTabbedComponent::TabsAtTop)
                        {
                            y1 += indent;
                            y2 += 100.0f;
                        }
                        else if (t->orientation == TwindyTabbedComponent::TabsAtBottom)
                        {
                            y2 -= indent;
                            y1 -= 100.0f;
                        }
                        else if (t->orientation == TwindyTabbedComponent::TabsAtLeft)
                        {
                            x1 += indent;
                            x2 += 100.0f;
                        }
                        else if (t->orientation == TwindyTabbedComponent::TabsAtRight)
                        {
                            x2 -= indent;
                            x1 -= 100.0f;
                        }

                        Path p;
                        p.addRoundedRectangle (x1 + t->normalOutlineThickness,
                                               y1 + t->normalOutlineThickness,
                                               x2 - x1 - t->normalOutlineThickness* 2.0f,
                                               y2 - y1 - t->normalOutlineThickness * 2.0f,
                                               t->cornerSize);

                        g.setColour (t->deselectedTabCol);
                        g.fillPath (p);

                        g.setColour (t->normalOutlineCol);
                        g.strokePath (p, PathStrokeType (t->normalOutlineThickness));
                    }
                }
            }

            AffineTransform trans;
            trans = trans.translated ((float)t->getScreenX() - getScreenX(),
                                      (float)t->getScreenY() - getScreenY());

            g.setColour (t->fillCol);
            g.fillPath (t->outlineShape, trans);

            g.setColour (t->selectedOutlineCol);
            g.fillPath (t->strokedOutline, trans);
        }
    }
/** Return screen x */
int fbapp_get_screen_y(int hardwareId) {
    (void)hardwareId;
    return getScreenY(reverse_orientation);
}
示例#23
0
void phdGuiStringField::onMouseReleased(ofMouseEventArgs & args) {
    if(!compareMouseEventArgs(argsPress, argsDrag)) { // drag != press => has a click
        getManager()->getInputField().editString(getScreenX(), getScreenY(), getWidth(), getHeight(), this, 0, 30);
        //masterInputField().editString(getScreenX(), getScreenY(), getWidth(), getHeight(), value, 30);
    }
}