Beispiel #1
0
void ComboBox::valueChanged (Value&)
{
    if (lastCurrentId != (int) currentId.getValue())
        setSelectedId (currentId.getValue(), false);
}
Beispiel #2
0
void ComboBox::setSelectedItemIndex (const int index, const bool dontSendChangeMessage)
{
    setSelectedId (getItemId (index), dontSendChangeMessage);
}
void ComboBox::setSelectedId (const int newItemId, const bool dontSendChange)    { setSelectedId (newItemId, dontSendChange ? dontSendNotification : sendNotification); }
Beispiel #4
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;
}
void ComboBox::setSelectedItemIndex (const int index, const NotificationType notification)
{
    setSelectedId (getItemId (index), notification);
}