Updated to the new Mouse functions

This commit is contained in:
Laurent Gomila committed 2011-07-08 08:34:43 +02:00
1 parent 45d3b05d65
commit 56df80a7d3
6 files changed
+38 -71

No files matched your search

-10
View File
@@ -152,16 +152,6 @@ CSFML_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, s
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
///
/// \param renderWindow : Renderwindow object
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_SetCursorPosition(sfRenderWindow* renderWindow, unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
+19 -6
View File
@@ -28,6 +28,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Window/Types.h>
////////////////////////////////////////////////////////////
@@ -60,15 +61,27 @@ CSFML_API sfBool sfMouse_IsButtonPressed(sfMouseButton button);
/// \brief Get the current position of the mouse
///
/// This function returns the current position of the mouse
/// cursor.
/// If the cursor is over a SFML window, the returned position
/// is relative to this window. Otherwise, the returned position
/// is in desktop coordinates.
/// cursor relative to the given window, or desktop if NULL is passed.
///
/// \return Current position of the mouse
/// \param x Variable to fill with the current X position of the mouse
/// \param y Variable to fill with the current Y position of the mouse
/// \param relativeTo Reference window
///
////////////////////////////////////////////////////////////
CSFML_API void sfMouse_GetPosition(int* x, int* y);
CSFML_API void sfMouse_GetPosition(int* x, int* y, const sfWindow* relativeTo);
////////////////////////////////////////////////////////////
/// \brief Set the current position of the mouse
///
/// This function sets the current position of the mouse
/// cursor relative to the given window, or desktop if NULL is passed.
///
/// \param x New X position of the mouse
/// \param y New Y position of the mouse
/// \param relativeTo Reference window
///
////////////////////////////////////////////////////////////
CSFML_API void sfMouse_SetPosition(int x, int y, const sfWindow* relativeTo);
#endif // SFML_MOUSE_H
-20
View File
@@ -177,26 +177,6 @@ CSFML_API void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled);
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
///
/// \param window : Window object
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// Get the position of the mouse cursor on a window
///
/// \param window : Window object
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
-9
View File
@@ -217,15 +217,6 @@ void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show)
}
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
////////////////////////////////////////////////////////////
void sfRenderWindow_SetCursorPosition(sfRenderWindow* renderWindow, unsigned int left, unsigned int top)
{
CSFML_CALL(renderWindow, SetCursorPosition(left, top));
}
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
+19 -2
View File
@@ -26,6 +26,7 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Mouse.h>
#include <SFML/Window/WindowStruct.h>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Internal.h>
@@ -42,12 +43,28 @@ sfBool sfMouse_IsButtonPressed(sfMouseButton button)
////////////////////////////////////////////////////////////
/// Get the current position of the mouse
////////////////////////////////////////////////////////////
void sfMouse_GetPosition(int* x, int* y)
void sfMouse_GetPosition(int* x, int* y, const sfWindow* relativeTo)
{
sf::Vector2i position = sf::Mouse::GetPosition();
sf::Vector2i position;
if (relativeTo)
position = sf::Mouse::GetPosition(relativeTo->This);
else
position = sf::Mouse::GetPosition();
if (x)
*x = position.x;
if (y)
*y = position.y;
}
////////////////////////////////////////////////////////////
/// Get the current position of the mouse
////////////////////////////////////////////////////////////
void sfMouse_SetPosition(int x, int y, const sfWindow* relativeTo)
{
if (relativeTo)
sf::Mouse::SetPosition(sf::Vector2i(x, y), relativeTo->This);
else
sf::Mouse::SetPosition(sf::Vector2i(x, y));
}
-24
View File
@@ -209,30 +209,6 @@ void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show)
}
////////////////////////////////////////////////////////////
/// Change the position of the mouse cursor on a window
////////////////////////////////////////////////////////////
void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top)
{
CSFML_CALL(window, SetCursorPosition(left, top))
}
////////////////////////////////////////////////////////////
/// Get the position of the mouse cursor on a window
////////////////////////////////////////////////////////////
void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top)
{
CSFML_CHECK(window);
sf::Vector2i position = window->This.GetCursorPosition();
if (left)
*left = position.x;
if (top)
*top = position.y;
}
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows