コード例 #1
0
ファイル: Button.cpp プロジェクト: IGotWood/Sparky
	bool Button::OnMouseMoved(events::MouseMovedEvent& e)
	{
		// TODO: Remove these hard coded mouse maths throughout the engine
		vec2 mouse(e.GetX() * (32.0f / Window::GetWindowClass(nullptr)->GetWidth()), 18.0f - e.GetY() * (18.0f / Window::GetWindowClass(nullptr)->GetHeight()));
		if (m_State == ButtonState::PRESSED && !m_Bounds.Contains(mouse))
  			m_State = ButtonState::UNPRESSED;

		return false;
	}
コード例 #2
0
ファイル: Slider.cpp プロジェクト: Antranilan/Sparky
	bool Slider::OnMouseMoved(events::MouseMovedEvent& e)
	{
		// TODO: Remove these hard coded mouse maths throughout the engine
		vec2 mouse(e.GetX() * (32.0f / Window::GetWindowClass(nullptr)->GetWidth()), 18.0f - e.GetY() * (18.0f / Window::GetWindowClass(nullptr)->GetHeight()));
		if (m_State == SliderState::PRESSEDHEAD)
		{
			if (m_Vertical)
				SetValue((mouse.y - m_Bounds.y - m_HeadOffset) / (m_Bounds.size.y - m_HeadBounds.size.y));
			else
				SetValue((mouse.x - m_Bounds.x - m_HeadOffset) / (m_Bounds.size.x - m_HeadBounds.size.x));
		}

		return false;
	}