mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 05:26:13 +01:00
Updated to the new Mouse functions
This commit is contained in:
1 parent
45d3b05d65
commit
56df80a7d3
6 files changed
+38
-71
No files matched your search
@@ -152,16 +152,6 @@ CSFML_API void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, s
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show);
|
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.
|
/// Change the position of a window on screen.
|
||||||
/// Only works for top-level windows
|
/// Only works for top-level windows
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.h>
|
#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
|
/// \brief Get the current position of the mouse
|
||||||
///
|
///
|
||||||
/// This function returns the current position of the mouse
|
/// This function returns the current position of the mouse
|
||||||
/// cursor.
|
/// cursor relative to the given window, or desktop if NULL is passed.
|
||||||
/// If the cursor is over a SFML window, the returned position
|
|
||||||
/// is relative to this window. Otherwise, the returned position
|
|
||||||
/// is in desktop coordinates.
|
|
||||||
///
|
///
|
||||||
/// \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
|
#endif // SFML_MOUSE_H
|
||||||
@@ -177,26 +177,6 @@ CSFML_API void sfWindow_EnableVerticalSync(sfWindow* window, sfBool enabled);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
|
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.
|
/// Change the position of a window on screen.
|
||||||
/// Only works for top-level windows
|
/// Only works for top-level windows
|
||||||
|
|||||||
@@ -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.
|
/// Change the position of a window on screen.
|
||||||
/// Only works for top-level windows
|
/// Only works for top-level windows
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Window/Mouse.h>
|
#include <SFML/Window/Mouse.h>
|
||||||
|
#include <SFML/Window/WindowStruct.h>
|
||||||
#include <SFML/Window/Mouse.hpp>
|
#include <SFML/Window/Mouse.hpp>
|
||||||
#include <SFML/Internal.h>
|
#include <SFML/Internal.h>
|
||||||
|
|
||||||
@@ -42,12 +43,28 @@ sfBool sfMouse_IsButtonPressed(sfMouseButton button)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Get the current position of the mouse
|
/// 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)
|
if (x)
|
||||||
*x = position.x;
|
*x = position.x;
|
||||||
if (y)
|
if (y)
|
||||||
*y = position.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));
|
||||||
|
}
|
||||||
@@ -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.
|
/// Change the position of a window on screen.
|
||||||
/// Only works for top-level windows
|
/// Only works for top-level windows
|
||||||
|
|||||||
Reference in new issue
Block a user