aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/InputSystem.h
blob: db6b3748ef6eaecdef1400aa3d3a3cb469cf9fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <utility>

#include "System.h"

#include "../api/Event.h"
#include "../api/Button.h"
#include "../api/Transform.h"

namespace crepe {

class InputSystem : public System {
public:
	using System::System;
	void update() override;
	void process_events();
	
private:
	std::pair<int, int> last_mouse_down_position{-1, -1};
    MouseButton last_mouse_button = MouseButton::NONE;
	const int click_tolerance = 5;
	void handle_click(const MouseReleaseEvent);

    Transform* find_transform_for_button(Button &button, std::vector<std::reference_wrapper<Transform>> &transforms);

    bool is_mouse_inside_button(const MouseReleaseEvent &event, const Button &button, const Transform &transform);

    void handle_button_press(Button &button, const MouseReleaseEvent &event);
};

} // namespace crepe