Made sf::Input and events more consistent / synchronized
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1405 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
8a1a6bbfab
commit
d89d721b96
12 changed files with 120 additions and 213 deletions
|
@ -36,7 +36,6 @@
|
|||
#include <SFML/Window/Input.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <SFML/Window/WindowListener.hpp>
|
||||
#include <SFML/Window/WindowStyle.hpp>
|
||||
|
||||
|
||||
|
|
|
@ -31,17 +31,18 @@
|
|||
#include <SFML/Config.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <SFML/Window/Event.hpp>
|
||||
#include <SFML/Window/WindowListener.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
class Window;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time states of keyboard,
|
||||
/// mouse and joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Input : public WindowListener, NonCopyable
|
||||
class SFML_API Input : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
|
@ -120,13 +121,18 @@ public :
|
|||
|
||||
private :
|
||||
|
||||
friend class Window;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called each time an event is received from the attached window
|
||||
/// \brief Notifies the input of a new event
|
||||
///
|
||||
/// This function is for internal use only, it is called by
|
||||
/// the owner window every time a new event has been triggered.
|
||||
///
|
||||
/// \param event Event received
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnEvent(const Event& event);
|
||||
void OnEvent(const Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Reset all the states
|
||||
|
|
|
@ -28,16 +28,13 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/Event.hpp>
|
||||
#include <SFML/Window/Input.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/WindowHandle.hpp>
|
||||
#include <SFML/Window/WindowListener.hpp>
|
||||
#include <SFML/Window/ContextSettings.hpp>
|
||||
#include <SFML/Window/WindowStyle.hpp>
|
||||
#include <SFML/System/Clock.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
@ -49,11 +46,13 @@ namespace priv
|
|||
class ContextGL;
|
||||
}
|
||||
|
||||
class Event;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Window that serves as a target for OpenGL rendering
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API Window : public WindowListener, NonCopyable
|
||||
class SFML_API Window : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
|
@ -448,12 +447,18 @@ private :
|
|||
virtual void OnResize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called each time an event is received from the internal window
|
||||
/// \brief Processes an event before it is sent to the user
|
||||
///
|
||||
/// \param event Event received
|
||||
/// This function is called every time an event is received
|
||||
/// from the internal window (through GetEvent or WaitEvent).
|
||||
/// It filters out unwanted events, and performs whatever internal
|
||||
/// stuff the window needs before the event is returned to the
|
||||
/// user.
|
||||
///
|
||||
/// \param event Event to filter
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnEvent(const Event& event);
|
||||
bool FilterEvent(const Event& event);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform some common internal initializations
|
||||
|
@ -466,7 +471,6 @@ private :
|
|||
////////////////////////////////////////////////////////////
|
||||
priv::WindowImpl* myWindow; ///< Platform-specific implementation of the window
|
||||
priv::ContextGL* myContext; ///< Platform-specific implementation of the OpenGL context
|
||||
std::queue<Event> myEvents; ///< Queue of received events
|
||||
Input myInput; ///< Input manager connected to window
|
||||
Clock myClock; ///< Clock for measuring the elapsed time between frames
|
||||
float myLastFrameTime; ///< Time elapsed since last frame
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_WINDOWLISTENER_HPP
|
||||
#define SFML_WINDOWLISTENER_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
class Event;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Base class for classes that want to receive events
|
||||
/// from a window (for internal use only)
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_API WindowListener
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Called each time an event is received from the attached window
|
||||
///
|
||||
/// \param event Event received
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnEvent(const Event& event) = 0;
|
||||
|
||||
protected :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual ~WindowListener() {}
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_WINDOWLISTENER_HPP
|
Loading…
Add table
Add a link
Reference in a new issue