lxgui
Loading...
Searching...
No Matches
input_sfml_source.hpp
1#ifndef LXGUI_INPUT_SFML_SOURCE_HPP
2#define LXGUI_INPUT_SFML_SOURCE_HPP
3
4#include "lxgui/gui_vector2.hpp"
5#include "lxgui/input_source.hpp"
6#include "lxgui/utils.hpp"
7
8#include <SFML/Window/Cursor.hpp>
9#include <memory>
10#include <unordered_map>
11
14namespace sf {
15
16class Window;
17class Event;
18
19} // namespace sf
23namespace lxgui::input { namespace sfml {
24
26class source final : public input::source {
27public:
32 explicit source(sf::Window& win);
33
34 source(const source&) = delete;
35 source& operator=(const source&) = delete;
36
37 utils::ustring get_clipboard_content() override;
38 void set_clipboard_content(const utils::ustring& content) override;
39
40 void on_sfml_event(const sf::Event& event);
41
42 void set_mouse_cursor(const std::string& file_name, const gui::vector2i& hot_spot) override;
43 void reset_mouse_cursor() override;
44
45private:
46 input::key from_sfml_(int sf_key) const;
47
48 sf::Window& window_;
49
50 gui::vector2i old_mouse_pos_;
51 bool first_mouse_move_ = true;
52
53 std::unordered_map<std::string, std::unique_ptr<sf::Cursor>> cursor_map_;
54};
55
56}} // namespace lxgui::input::sfml
57
58#endif
SFML implementation of input::source.
void set_mouse_cursor(const std::string &file_name, const gui::vector2i &hot_spot) override
Sets the mouse cursor to a given image on disk.
void set_clipboard_content(const utils::ustring &content) override
Replace the content of the clipboard.
source & operator=(const source &)=delete
source(sf::Window &win)
Initializes this input source.
void reset_mouse_cursor() override
Sets the mouse cursor back to the default (arrow).
void on_sfml_event(const sf::Event &event)
utils::ustring get_clipboard_content() override
Retrieve a copy of the clipboard content.
source(const source &)=delete
The base class for input source implementation.
Holds 2D coordinates.