Esempio n. 1
0
bool ofxGuiKnob::mousePressed(int x, int y, int button)
{
	ofxPoint2f point	= mouseToLocal(x, y);
	mMouseIsDown		= isPointInsideMe(point);
	
	if (mMouseIsDown)
	{
		mFirstHit = point;
		mouseDragged(x, y, button);
	}
	
	return mMouseIsDown;
}
Esempio n. 2
0
bool ofxGuiColor::mouseDragged(int x, int y, int button)
{
	if(mMouseIsDown)
	{
		//	int value = mValue.toInt(mDisplay);
		mValue.setChanel(mSlider, mouseToFraction(mouseToLocal(x, y)).x);
		
		//	if(mValue.toInt(mDisplay) != value)
			mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Color, &mValue, sizeof(ofRGBA));
	}
	
	return mMouseIsDown;
}
Esempio n. 3
0
bool ofxGuiFiles::mousePressed(int x, int y, int button)
{
	mMouseIsDown = isPointInsideMe(mouseToLocal(x, y));
	
	if(mMouseIsDown)
	{
		mSelected = !mSelected;
		mMemory = mValue;
		mouseDragged(x, y, button);
		mState = (mState + 1) % num_states;
	}
	
	return mMouseIsDown;
}
Esempio n. 4
0
bool ofxGuiGrid::mouseReleased( int x, int y, int button ) {
	if ( !mIsActive ) {		//! This control is not active now
		return false;
	}
	bool handled = mMouseIsDown;

	if ( mMouseIsDown ) {
		mMouseIsDown = false;

		//! Check the Double Click Mode first
		if ( bDblClickMode ) {
			return true;
		}

		//! Handle the controls
		bool handled2 = false;
		for ( int i = 0; i < mObjects.size(); ++i ) {
			if ( (ofxGuiObject*)mObjects[i]->mouseReleased( x, y, button ) ) {
				return true;
			}
		}
	}

	if ( mDisplayMode == kofxGui_Grid_Display && mDraggingRawIndex != -1) {
		ofxPoint2f inside = mouseToLocal( x, y );
		if ( isPointInsideMe( inside ) ) {
			int id = mouseToGridId( inside );
			if ( id < mXGrid * mYGrid && id != -1 ) {
				printf( "\nofxGuiGrid::mouseReleased()\tid=%d\n", id );
				printf( "\nofxGuiGrid::mouseReleased()\tmDraggingRawIndex=%d\n", mDraggingRawIndex );
				if ( !utils->isUsed( id ) ) {
					utils->setCam( id, utils->getRawCam(mDraggingRawIndex) );
					utils->setSelected( mDraggingRawIndex );
					setImages();

					//! Save the info for reset
					rawIdArray[id] = mDraggingRawIndex;

					mGlobals->mListener->handleGui( mParamId, kofxGui_Set_Grid_Released, &mDraggingRawIndex, sizeof(int) );

				}
			}
			//! reset the index
			mDraggingRawIndex = -1;
		}
	}

	return handled;
}
Esempio n. 5
0
bool ofxGuiRadar::mouseDragged(int x, int y, int button)
{
	if(mMouseIsDown)
	{
		float value = fractionToValue(mouseToFraction(mouseToLocal(x, y)).x);
		
		if(value != mValue)
		{
			setValue(value);
			//mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Float, &mValue, sizeof(float));
		}
	}
	
	return mMouseIsDown;
}
Esempio n. 6
0
bool ofxGuiFiles::mouseReleased(int x, int y, int button)
{
    bool handled = mMouseIsDown;

    if(mMouseIsDown)
    {
        if(isPointInsideMe(mouseToLocal(x, y)))
            mGlobals->mListener->handleGui(mParamId, kofxGui_Set_String, &mValue, sizeof(string));
        else
            mValue = mMemory;

        mMouseIsDown = false;
    }

    return handled;
}
Esempio n. 7
0
bool ofxGuiButton::mousePressed(int x, int y, int button)
{
	mMouseIsDown = isPointInsideMe(mouseToLocal(x, y));
	
	if(mMouseIsDown)
	{
		if(mDisplay == kofxGui_Button_Trigger)
			setValue(true);
		else
			setValue(!mValue);
		
		mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Bool, &mValue, sizeof(bool));
	}

	return mMouseIsDown;
}
Esempio n. 8
0
bool ofxGuiPoints::mouseDragged(int x, int y, int button)
{
	if(mMouseIsDown)
	{
		ofxPoint2f	value	= mValue;
		ofxPoint2f	point	= fractionToValue(mouseToFraction(mouseToLocal(x, y)));

		if(mList.activePoint > -1)
		{
			if(mList.activePoint == 0)
			{
				point.x = mMinVal.x;
				mList.points[mList.activePoint] = point;
			}
			else if(mList.activePoint == mList.points.size() - 1)
			{
				point.x = mMaxVal.x;
				mList.points[mList.activePoint] = point;
			}
			else
			{
				if(point.x < mList.points[mList.activePoint - 1].x)
					point.x = mList.points[mList.activePoint - 1].x;
				else if(point.x > mList.points[mList.activePoint + 1].x)
					point.x = mList.points[mList.activePoint + 1].x;

				mList.points[mList.activePoint] = point;
			}
		}

		setValue(point);

		if(value != mValue)
		{
			mOutVal = mList.positionToValue(point);
			//mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Point, &mOutVal, sizeof(ofxPoint2f));
			//mGlobals->mListener->handleGui(mParamId, kofxGui_Set_PointArray, &mList.points, sizeof(vector<ofxPoint2f>));
		}
	}

	return mMouseIsDown;
}
Esempio n. 9
0
bool ofxGuiPanel::mouseReleased(int x, int y, int button)
{
	bool		handled	= false;
	ofxPoint2f	inside	= mouseToLocal(x, y);
	
	ofxGuiObject* tmpObj;
	
	for(int i = 0; i < mObjects.size(); i++)
	{
		tmpObj	= (ofxGuiObject*)mObjects.at(i);
		handled	= tmpObj->mouseReleased(inside.x, inside.y, button);
		
		if(handled)
			break;
	}
	
	mMouseIsDown = false;
	
	return handled;
}
Esempio n. 10
0
bool ofxGuiMatrix::mousePressed(int x, int y, int button)
{
	ofPoint inside = mouseToLocal(x, y);
	mMouseIsDown = isPointInsideMe(inside);
	
	if(mMouseIsDown)
	{
		int id = mouseToPadId(mouseToFraction(inside));
		
		if (mDisplay == kofxGui_Button_Trigger)
			mBuffer[id]	|= kofxGui_Matrix_Set;	// = 1;
		else
			mBuffer[id]	^= kofxGui_Matrix_Set;	// !mBuffer[id];
		
		setValue(id);
		
		ofCell outVal = ofCell(mValue, mBuffer[mValue]);
		mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Cell, &outVal, sizeof(ofCell));
	}
	
	return mMouseIsDown;
}
Esempio n. 11
0
bool ofxGuiKnob::mouseDragged(int x, int y, int button)
{
	if(mMouseIsDown)
	{
		ofxPoint2f point	= mouseToLocal(x, y);
		
		float	deltaX		= point.x - mFirstHit.x;
		float	deltaY		= point.y - mFirstHit.y;
		float	delta		= deltaX - deltaY;
		float	value		= CLAMP(mValue + delta * (mValDlt / 100.0f), mMinVal, mMaxVal);
		
		if(value != mValue)
		{
			setValue(value);
			mGlobals->mListener->handleGui(mParamId, kofxGui_Set_Float, &mValue, sizeof(float));
			
			mFirstHit = point;
		}
	}
	
	return mMouseIsDown;
}
bool ofxGuiPanel::mousePressed(int x, int y, int button)
{
    bool		handled	= false;
    ofxPoint2f	inside	= mouseToLocal(x, y);

    if(isPointInsideMe(inside, alignRight))
    {
        ofxGuiObject* tmpObj;

        for(int i = 0; i < mObjects.size(); i++)
        {
            tmpObj	= (ofxGuiObject*)mObjects.at(i);
            handled	= tmpObj->mousePressed(inside.x, inside.y, button);

            if(handled)
                break;
        }

        mMouseIsDown = true;
    }

    return handled;
}
Esempio n. 13
0
bool ofxGuiGrid::mousePressed( int x, int y, int button ) {
	if ( !mIsActive ) {		//! This control is not active now
		return false;
	}

	ofxPoint2f inside = mouseToLocal( x, y );
	mMouseIsDown = isPointInsideMe( inside );

	if ( mMouseIsDown ) {

		// -----------------------
		if ( bDblClickMode ) {
			// TODO
			mNowClickTime = ofGetSystemTime();
			if ( mNowClickTime - mPrevClickTime <= OFXGUI_DBLCLICK_INTERVAL ) {
				mPrevClickTime = 0;	// reset
				switchDblClickMode( false );
				return true;
			}
			mPrevClickTime = mNowClickTime;
			return true;
		}

		// -----------------------
		//! Check the controls first
		bool handled = false;
		for ( int i = 0; i < mObjects.size(); i++ ) {
			handled = (ofxGuiObject*)mObjects[i]->mousePressed( x, y, button );

			if ( handled ) {
				return true;	// we got the result
			}
		}

		// -----------------------
		int id = mouseToGridId( inside );
		
		setSelectedId( id );
		mGlobals->mListener->handleGui( mParamId, kofxGui_Set_Int, &mCamIndex, sizeof(int) );

		mDragging = false;	//! reset the value

		if ( id != -1 ) {
			clickingPoint = inside;
			mValidSelection = true;
		} else {
			mValidSelection = false;
		}

		// -----------------------
		//! Double click check
		mNowClickTime = ofGetSystemTime();
		if ( id != -1
			&& utils->isUsed( id )
			&& mNowClickTime - mPrevClickTime <= OFXGUI_DBLCLICK_INTERVAL ) {
			mPrevClickTime = 0;	// reset the time
			switchDblClickMode( true );
			return true;
		}

		mPrevClickTime = mNowClickTime;

		// ------------------------
		//! ----- Add controls -----

		//! Control temp values
		int x, y, textWidth;
		string btnText = "";
		ofxGuiButton* btn;

		//! The reset button
		if ( bShowResetBtn ) {
			removeControl( mResetBtnId );

			if ( id != -1 && utils->isUsed( id )) {
				//! The position is relate with the panel
				x = mObjX + getGridX( id % mXGrid ) + 5;
				y = mObjY + getGridY( id / mXGrid ) + getGridHeight() - 5 - OFXGUI_BUTTON_HEIGHT;

				//! If the grid is too small, we remove the text
				btnText = "Reset";
				textWidth = mGlobals->mParamFont.stringWidth( btnText );
				if ( getGridWidth() < textWidth + 5 + OFXGUI_BUTTON_HEIGHT ) {
					btnText = "";
				}

				btn = (ofxGuiButton*)addButton( mResetBtnId, btnText, x, y,
					OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
					kofxGui_Button_Off, kofxGui_Button_Trigger );
				btn->setHighlightMode( true );
			}
		}

		//! The setting button
		if ( bShowSettingBtn ) {
			removeControl( mSettingBtnId );

			if ( id != -1 && utils->isUsed( id ) ) {
				y -= 15;

				btnText = "Setting";
				textWidth = mGlobals->mParamFont.stringWidth( btnText );
				if ( getGridWidth() < textWidth + 5 + OFXGUI_BUTTON_HEIGHT ) {
					btnText = "";
				}

				btn = (ofxGuiButton*)addButton( mSettingBtnId, btnText, x, y,
					OFXGUI_BUTTON_HEIGHT, OFXGUI_BUTTON_HEIGHT,
					kofxGui_Button_Off, kofxGui_Button_Trigger );
				btn->setHighlightMode( true );				
			}
		}
	}

	return mMouseIsDown;
}