示例#1
0
	// ------------------------------------------------------------------
	void GUIComboBox::onMouseDown(GUIEvent& evt)
	{
		Vec2 mousePos = evt.getMousePos() - mPos;
		mousePos.setX(mousePos.getX() - mSize.getX() + 30);
		mousePos.setY(mousePos.getY() - mSize.getY() / 2);

		mExpandDown = (2 <= mousePos.getX() && mousePos.getX() <= 22 && -3 <= mousePos.getY() && mousePos.getY() <= 6);
	}
示例#2
0
	// ------------------------------------------------------------------
	void GUIComboBox::onMouseMove(GUIEvent& evt)
	{
		Vec2 mousePos = evt.getMousePos() - mPos;
		mousePos.setX(mousePos.getX() - mSize.getX() + 30);
		mousePos.setY(mousePos.getY() - mSize.getY() / 2);

		if (2 <= mousePos.getX() && mousePos.getX() <= 22 && -3 <= mousePos.getY() && mousePos.getY() <= 6) {
			mExpandOver = true;
		} else {
			mExpandOver = mExpandDown = false;
		}
		
		mousePos = evt.getMousePos() - mPos;

		if (mExpand && mousePos.getY() >= mSize.getY()) {
			Font* ft = Resources::inst().get<Font> (mFontName);
			float y = evt.getMousePos().getY() - mPos.getY() - mSize.getY();
			mHoverItem = y / (ft->getHeight() + 3);
			mOverItem = 0 <= mHoverItem && mHoverItem < mItems.size();
		} else {
			mOverItem = false;
		}
	}
示例#3
0
	// ------------------------------------------------------------------
	void GUIComboBox::onMouseUp(GUIEvent& evt)
	{
		Vec2 mousePos = evt.getMousePos() - mPos;
		mousePos.setX(mousePos.getX() - mSize.getX() + 30);
		mousePos.setY(mousePos.getY() - mSize.getY() / 2);

		if (2 <= mousePos.getX() && mousePos.getX() <= 22 && -3 <= mousePos.getY() && mousePos.getY() <= 6) {
			mExpandDown = false;
			mExpand = !mExpand;
		}

		if (mOverItem) {
			mSelectedItem = mHoverItem;
		}
	}