예제 #1
0
void CGUIInputText::processLogic()
{
	if(!mEnabled)
		return;

	// process the typing here!
	if(mTyping)
	{

		if(gInput.getPressedIsTypingKey())
		{
			std::string c = gInput.getPressedTypingKey();

			mText.append(c);
		}

		if(gInput.getPulsedKey(KBCKSPCE, 5) && (mText.length() > 0))
		{
			mText.erase(mText.length()-1);
		}
	}
	else
	{
		mPressed = false;
		mReleased = false;
	}

    processPointingState();

    // If Input Text control was clicked
    if(mReleased)
    {
        mTyping = !mTyping;
    }
}
예제 #2
0
void GsScrollbar::processLogic()
{
    // Here we check if the mouse-cursor/Touch entry clicked on something!!
    const float fx = mRect.x;
    const float fw = mRect.w;
    const float fy = mRect.y;
    const float fh = mRect.h;

    const float y_innerbound_max = fy+fh;

    //const float x_innerbound_min = fx + static_cast<float>(TEXT_HEIGHT)/bw;

    GsRect<float> rRect(fx, fy, fw, fh);
    GsRect<float> parRect(mpParent->mRect);

    rRect.transform(parRect);

    GsPointingState &pointingState = gPointDevice.mPointingState;

    processPointingState(rRect);

    Vector2D<float> MousePos = pointingState.mPos;

    const bool scrollAction = mReleased || mPressed;

    if( rRect.HasPoint(MousePos) )
    {
        if( MousePos.y > fy && MousePos.y < y_innerbound_max )
        {
            if(scrollAction) // If clicked or pressed on scroll bar
            {
                float relPos = float(mScrollPos) / float(mMaxScrollAmt);

                const float scrollAreaY1 = rRect.y + mArrowHeight + mSliderHeight*0.5f;
                const float scrollAreaY2 = rRect.y + rRect.h - mArrowHeight - mSliderHeight*0.5f;
                const float scrollHeight = scrollAreaY2-scrollAreaY1;

                const float midPart_y = scrollAreaY1+(scrollHeight*relPos);

                if(mPressed)
                {
                   if(MousePos.y < scrollAreaY1 || MousePos.y > scrollAreaY2)
                       return;
                }

                // The tolerance will remove the jitter effect in scrolling
                const float tolerance = scrollHeight/float(mMaxScrollAmt);

                if(MousePos.y < midPart_y-tolerance) // Go up!
                {
                    scrollUp();
                }
                else if(MousePos.y > midPart_y+tolerance) // Go down!
                {
                    scrollDown();
                }
            }
        }
    }
}
void CGUITextSelectionList::processLogic()
{
	// Here we check if the mouse-cursor/Touch entry clicked on something!!

    const float bw = gVideoDriver.getGameResolution().w;
	const float bh = gVideoDriver.getGameResolution().h;

	const float fx = mRect.x;
	const float fw = mRect.w;
	const float fy = mRect.y;
	const float fh = mRect.h;

    const float y_innerbound_min = fy + static_cast<float>(TEXT_SIZE)/bh;
	const float y_innerbound_max = y_innerbound_min +
            static_cast<float>( mItemList.size()*TEXT_SIZE )/bh;

    const float x_innerbound_min = fx + static_cast<float>(TEXT_SIZE)/bw;


    GsRect<float> rRect(fx, fy, fw, fh);

    GsPointingState &pointingState = gPointDevice.mPointingState;

    processPointingState();        

    Vector2D<float> mousePos = pointingState.mPos;

    if( rRect.HasPoint(mousePos) )
    {
        // Let scrollbar do it's work
        mScrollbar.processLogic();

        if( mousePos.y > fy && mousePos.y < y_innerbound_max )
        {
            int newselection = ((mousePos.y-fy)*bh/TEXT_SIZE) - 1 + mScrollbar.scrollPos();

            if( mousePos.x > x_innerbound_min && mousePos.y > y_innerbound_min)
            {
                if(mHovered)
                    mHoverSelection = newselection;
                if(mPressed)
                    mPressedSelection = newselection;
                if(mReleased)
                    mReleasedSelection = newselection;
            }
        }
    }
    else
    {
        mHoverSelection = -1;
        mPressedSelection = -1;
    }
}