예제 #1
0
파일: GUI.cpp 프로젝트: SinYocto/Zee
void Slider::GetButtonState()
{
	Input* input = gEngine->GetInput();
	POINT cursorPos = input->GetCursorPos();

	if(state == Active && input->GetLeftButton())
		return;

	float offset = ((value - minValue)/(maxValue - minValue)) * 
		(screenRect.right - style->sliderBarSize*(screenRect.bottom - screenRect.top) - screenRect.left);
	float width = style->sliderBarSize * (screenRect.bottom - screenRect.top);

	if(cursorPos.x > screenRect.left && cursorPos.x < screenRect.right &&
		cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom && input->GetLeftButton())
	{
		state = Active;
		return;
	}

	if(cursorPos.x > screenRect.left + offset && cursorPos.x < screenRect.left + offset + width &&
		cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom)
	{
		state = Hover;
	}
	else
		state = Normal;
}
예제 #2
0
파일: GUI.cpp 프로젝트: SinYocto/Zee
void Toggle::GetButtonState()
{
	Input* input = gEngine->GetInput();

	POINT cursorPos = input->GetCursorPos();
	if(cursorPos.x > screenRect.left && cursorPos.x < screenRect.right &&
		cursorPos.y > screenRect.top && cursorPos.y < screenRect.bottom)
	{
		if(input->GetLeftButton())
			state = Active;
		else
			state = Hover;
	}
	else
		state = Normal;
}