mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 13:36:12 +01:00
Merge pull request #68 from zsbzsb/update/touch_get_position_renderwindow
Added sfTouch_getPositionRenderWindow(...) function
This commit is contained in:
commit
caf9aba55e
2 files changed
+32
-3
No files matched your search
@@ -511,20 +511,20 @@ CSFML_GRAPHICS_API void sfRenderWindow_resetGLStates(sfRenderWindow* renderWindo
|
|||||||
CSFML_GRAPHICS_API sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow);
|
CSFML_GRAPHICS_API sfImage* sfRenderWindow_capture(const sfRenderWindow* renderWindow);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the current position of the mouse relatively to a render-window
|
/// \brief Get the current position of the mouse relative to a render-window
|
||||||
///
|
///
|
||||||
/// This function returns the current position of the mouse
|
/// This function returns the current position of the mouse
|
||||||
/// cursor relative to the given render-window, or desktop if NULL is passed.
|
/// cursor relative to the given render-window, or desktop if NULL is passed.
|
||||||
///
|
///
|
||||||
/// \param relativeTo Reference window
|
/// \param relativeTo Reference window
|
||||||
///
|
///
|
||||||
/// \return Position of the mouse cursor, relative to the given render-window
|
/// \return Position of the mouse cursor, relative to the given render window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API sfVector2i sfMouse_getPositionRenderWindow(const sfRenderWindow* relativeTo);
|
CSFML_GRAPHICS_API sfVector2i sfMouse_getPositionRenderWindow(const sfRenderWindow* relativeTo);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Set the current position of the mouse relatively to a render-window
|
/// \brief Set the current position of the mouse relative to a render window
|
||||||
///
|
///
|
||||||
/// This function sets the current position of the mouse
|
/// This function sets the current position of the mouse
|
||||||
/// cursor relative to the given render-window, or desktop if NULL is passed.
|
/// cursor relative to the given render-window, or desktop if NULL is passed.
|
||||||
@@ -535,5 +535,19 @@ CSFML_GRAPHICS_API sfVector2i sfMouse_getPositionRenderWindow(const sfRenderWind
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow(sfVector2i position, const sfRenderWindow* relativeTo);
|
CSFML_GRAPHICS_API void sfMouse_setPositionRenderWindow(sfVector2i position, const sfRenderWindow* relativeTo);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get the current position of a touch in window coordinates
|
||||||
|
///
|
||||||
|
/// This function returns the current touch position
|
||||||
|
/// relative to the given render window, or desktop if NULL is passed.
|
||||||
|
///
|
||||||
|
/// \param finger Finger index
|
||||||
|
/// \param relativeTo Reference window
|
||||||
|
///
|
||||||
|
/// \return Current position of \a finger, or undefined if it's not down
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWindow* relativeTo);
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_RENDERWINDOW_H
|
#endif // SFML_RENDERWINDOW_H
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <SFML/Graphics/RectangleShapeStruct.h>
|
#include <SFML/Graphics/RectangleShapeStruct.h>
|
||||||
#include <SFML/Graphics/VertexArrayStruct.h>
|
#include <SFML/Graphics/VertexArrayStruct.h>
|
||||||
#include <SFML/Graphics/ConvertRenderStates.hpp>
|
#include <SFML/Graphics/ConvertRenderStates.hpp>
|
||||||
|
#include <SFML/Window/Touch.hpp>
|
||||||
#include <SFML/Internal.h>
|
#include <SFML/Internal.h>
|
||||||
#include <SFML/ConvertEvent.h>
|
#include <SFML/ConvertEvent.h>
|
||||||
|
|
||||||
@@ -533,3 +534,17 @@ void sfMouse_setPositionRenderWindow(sfVector2i position, const sfRenderWindow*
|
|||||||
else
|
else
|
||||||
sf::Mouse::setPosition(sf::Vector2i(position.x, position.y));
|
sf::Mouse::setPosition(sf::Vector2i(position.x, position.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
sfVector2i sfTouch_getPositionRenderWindow(unsigned int finger, const sfRenderWindow* relativeTo)
|
||||||
|
{
|
||||||
|
sf::Vector2i sfmlPosition;
|
||||||
|
|
||||||
|
if (relativeTo)
|
||||||
|
sfmlPosition = sf::Touch::getPosition(finger, relativeTo->This);
|
||||||
|
else
|
||||||
|
sfmlPosition = sf::Touch::getPosition(finger);
|
||||||
|
|
||||||
|
sfVector2i position = { sfmlPosition.x, sfmlPosition.y };
|
||||||
|
return position;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user