Movatterモバイル変換


[0]ホーム

URL:


Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2025 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
32#include <SFML/Window/Mouse.hpp>
34
36
37#include <type_traits>
38#include <variant>
39
40
41namespacesf
42{
48{
49public:
54structClosed
55 {
56 };
57
63 {
65 };
66
72 {
73 };
74
80 {
81 };
82
88 {
89char32_tunicode{};
90 };
91
105
119
130
140
150
159
192
198 {
199 };
200
206 {
207 };
208
214 {
215unsignedintjoystickId{};
216unsignedintbutton{};
217 };
218
224 {
225unsignedintjoystickId{};
226unsignedintbutton{};
227 };
228
234 {
235unsignedintjoystickId{};
237floatposition{};
238 };
239
245 {
246unsignedintjoystickId{};
247 };
248
254 {
255unsignedintjoystickId{};
256 };
257
263 {
264unsignedintfinger{};
266 };
267
273 {
274unsignedintfinger{};
276 };
277
283 {
284unsignedintfinger{};
286 };
287
297
306template <typename TEventSubtype>
307Event(const TEventSubtype& eventSubtype);
308
317template <typename TEventSubtype>
318 [[nodiscard]]boolis()const;
319
328template <typename TEventSubtype>
329 [[nodiscard]]const TEventSubtype*getIf()const;
330
339template <typename Visitor>
340decltype(auto)visit(Visitor&& visitor)const;
341
342private:
344// Member data
346 std::variant<Closed,
347Resized,
369 m_data;
370
372// Helper functions
374template <typename T,typename... Ts>
375 [[nodiscard]]staticconstexprbool isInParameterPack(const std::variant<Ts...>*)
376 {
377return std::disjunction_v<std::is_same<T, Ts>...>;
378 }
379
380template <typename T>
381staticconstexprbool isEventSubtype = isInParameterPack<T>(decltype (&m_data)(nullptr));
382
383friendclassWindowBase;
384
385template <typename Handler,typename... Ts>
386 [[nodiscard]]staticconstexprbool isInvocableWithEventSubtype(const std::variant<Ts...>*)
387 {
388return std::disjunction_v<std::is_invocable<Handler&, Ts&>...>;
389 }
390
391template <typename Handler>
392staticconstexprbool isEventHandler = isInvocableWithEventSubtype<Handler>(decltype (&m_data)(nullptr));
393};
394
395}// namespace sf
396
397#include <SFML/Window/Event.inl>
398
399
friend class WindowBase
DefinitionEvent.hpp:383
const TEventSubtype * getIf() const
Attempt to get specified event subtype.
bool is() const
Check current event subtype.
Event(const TEventSubtype &eventSubtype)
Construct from a given sf::Event subtype.
decltype(auto) visit(Visitor &&visitor) const
Apply a visitor to the event.
Axis
Axes supported by SFML joysticks.
DefinitionJoystick.hpp:55
Key
Key codes.
DefinitionKeyboard.hpp:52
Button
Mouse buttons.
DefinitionMouse.hpp:50
Wheel
Mouse wheels.
DefinitionMouse.hpp:66
Type
Sensor type.
DefinitionSensor.hpp:45
Vector3< float > Vector3f
DefinitionVector3.hpp:306
Vector2< unsigned int > Vector2u
DefinitionVector2.hpp:209
Vector2< int > Vector2i
DefinitionVector2.hpp:208
Closed event subtype.
DefinitionEvent.hpp:55
Gained focus event subtype.
DefinitionEvent.hpp:80
Lost focus event subtype.
DefinitionEvent.hpp:72
Joystick button pressed event subtype.
DefinitionEvent.hpp:214
unsigned int button
Index of the button that has been pressed (in range [0 .. Joystick::ButtonCount - 1])
DefinitionEvent.hpp:216
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
DefinitionEvent.hpp:215
Joystick button released event subtype.
DefinitionEvent.hpp:224
unsigned int button
Index of the button that has been released (in range [0 .. Joystick::ButtonCount - 1])
DefinitionEvent.hpp:226
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
DefinitionEvent.hpp:225
Joystick connected event subtype.
DefinitionEvent.hpp:245
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
DefinitionEvent.hpp:246
Joystick disconnected event subtype.
DefinitionEvent.hpp:254
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
DefinitionEvent.hpp:255
Joystick axis move event subtype.
DefinitionEvent.hpp:234
unsigned int joystickId
Index of the joystick (in range [0 .. Joystick::Count - 1])
DefinitionEvent.hpp:235
Joystick::Axis axis
Axis on which the joystick moved.
DefinitionEvent.hpp:236
float position
New position on the axis (in range [-100 .. 100])
DefinitionEvent.hpp:237
Key pressed event subtype.
DefinitionEvent.hpp:97
bool system
Is the System key pressed?
DefinitionEvent.hpp:103
bool control
Is the Control key pressed?
DefinitionEvent.hpp:101
bool shift
Is the Shift key pressed?
DefinitionEvent.hpp:102
bool alt
Is the Alt key pressed?
DefinitionEvent.hpp:100
Keyboard::Key code
Code of the key that has been pressed.
DefinitionEvent.hpp:98
Keyboard::Scancode scancode
Physical code of the key that has been pressed.
DefinitionEvent.hpp:99
Key released event subtype.
DefinitionEvent.hpp:111
bool alt
Is the Alt key pressed?
DefinitionEvent.hpp:114
bool control
Is the Control key pressed?
DefinitionEvent.hpp:115
bool shift
Is the Shift key pressed?
DefinitionEvent.hpp:116
bool system
Is the System key pressed?
DefinitionEvent.hpp:117
Keyboard::Key code
Code of the key that has been released.
DefinitionEvent.hpp:112
Keyboard::Scancode scancode
Physical code of the key that has been released.
DefinitionEvent.hpp:113
Mouse button pressed event subtype.
DefinitionEvent.hpp:136
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
DefinitionEvent.hpp:138
Mouse::Button button
Code of the button that has been pressed.
DefinitionEvent.hpp:137
Mouse button released event subtype.
DefinitionEvent.hpp:146
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
DefinitionEvent.hpp:148
Mouse::Button button
Code of the button that has been released.
DefinitionEvent.hpp:147
Mouse entered event subtype.
DefinitionEvent.hpp:198
Mouse left event subtype.
DefinitionEvent.hpp:206
Mouse move raw event subtype.
DefinitionEvent.hpp:189
Vector2i delta
Delta movement of the mouse since the last event.
DefinitionEvent.hpp:190
Mouse move event subtype.
DefinitionEvent.hpp:156
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
DefinitionEvent.hpp:157
Mouse wheel scrolled event subtype.
DefinitionEvent.hpp:125
Mouse::Wheel wheel
Which wheel (for mice with multiple ones)
DefinitionEvent.hpp:126
Vector2i position
Position of the mouse pointer, relative to the top left of the owner window.
DefinitionEvent.hpp:128
float delta
Wheel offset (positive is up/left, negative is down/right). High-precision mice may use non-integral ...
DefinitionEvent.hpp:127
Resized event subtype.
DefinitionEvent.hpp:63
Vector2u size
New size, in pixels.
DefinitionEvent.hpp:64
Sensor event subtype.
DefinitionEvent.hpp:293
Sensor::Type type
Type of the sensor.
DefinitionEvent.hpp:294
Vector3f value
Current value of the sensor on the X, Y, and Z axes.
DefinitionEvent.hpp:295
Text event subtype.
DefinitionEvent.hpp:88
char32_t unicode
UTF-32 Unicode value of the character.
DefinitionEvent.hpp:89
Touch began event subtype.
DefinitionEvent.hpp:263
Vector2i position
Start position of the touch, relative to the top left of the owner window.
DefinitionEvent.hpp:265
unsigned int finger
Index of the finger in case of multi-touch events.
DefinitionEvent.hpp:264
Touch ended event subtype.
DefinitionEvent.hpp:283
Vector2i position
Final position of the touch, relative to the top left of the owner window.
DefinitionEvent.hpp:285
unsigned int finger
Index of the finger in case of multi-touch events.
DefinitionEvent.hpp:284
Touch moved event subtype.
DefinitionEvent.hpp:273
Vector2i position
Current position of the touch, relative to the top left of the owner window.
DefinitionEvent.hpp:275
unsigned int finger
Index of the finger in case of multi-touch events.
DefinitionEvent.hpp:274

[8]ページ先頭

©2009-2025 Movatter.jp