2021-08-16 20:54:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
2021-08-31 21:09:34 +02:00
|
|
|
#include "window.h"
|
2021-08-27 19:40:48 +02:00
|
|
|
#include "bpmslider.h"
|
2021-08-31 21:09:34 +02:00
|
|
|
#include "pushbutton.h"
|
2021-08-16 20:54:03 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <SFML/Graphics/RectangleShape.hpp>
|
|
|
|
#include <SFML/Graphics/Text.hpp>
|
2021-09-10 20:35:48 +02:00
|
|
|
#include <SFML/Audio/Sound.hpp>
|
|
|
|
#include <SFML/Audio/SoundBuffer.hpp>
|
2021-12-03 20:21:27 +01:00
|
|
|
#include "tools/mathutils.h"
|
2021-08-16 20:54:03 +02:00
|
|
|
|
2021-08-27 19:40:48 +02:00
|
|
|
class BPMCalculator;
|
2021-12-02 17:02:13 +01:00
|
|
|
class Editor;
|
2021-08-27 19:40:48 +02:00
|
|
|
|
2021-08-31 21:09:34 +02:00
|
|
|
class BPMCalculatorWidget : public Window
|
2021-08-16 20:54:03 +02:00
|
|
|
{
|
|
|
|
public:
|
2021-12-03 20:21:27 +01:00
|
|
|
|
|
|
|
struct Init
|
|
|
|
{
|
|
|
|
std::shared_ptr<PushButton> start;
|
|
|
|
std::shared_ptr<PushButton> stop;
|
|
|
|
std::shared_ptr<PushButton> apply;
|
|
|
|
std::function<microsec(void)> current_time;
|
|
|
|
};
|
|
|
|
|
2021-08-27 19:40:48 +02:00
|
|
|
explicit BPMCalculatorWidget(const std::shared_ptr<BPMCalculator>& bpm_calculator, const std::shared_ptr<sf::Font> &font);
|
2021-08-16 20:54:03 +02:00
|
|
|
|
|
|
|
virtual void input(const sf::Event& event) override;
|
2021-08-27 19:40:48 +02:00
|
|
|
virtual void update(const sf::Time& dt) override;
|
2021-08-16 20:54:03 +02:00
|
|
|
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
|
|
|
virtual void setRect(const sf::FloatRect& rect) override;
|
|
|
|
virtual void setPosition(const sf::Vector2f& position) override;
|
2021-08-31 21:09:34 +02:00
|
|
|
virtual void move(const sf::Vector2f& delta) override;
|
2021-08-16 20:54:03 +02:00
|
|
|
|
2021-09-13 20:50:39 +02:00
|
|
|
virtual void setVisibility(bool is_visible = true) override;
|
|
|
|
|
2021-12-03 20:21:27 +01:00
|
|
|
void init(Init&& init);
|
2021-09-01 21:04:18 +02:00
|
|
|
|
2021-08-16 20:54:03 +02:00
|
|
|
private:
|
2021-09-01 21:04:18 +02:00
|
|
|
std::shared_ptr<PushButton> _button_start;
|
2021-09-13 20:50:39 +02:00
|
|
|
std::shared_ptr<PushButton> _button_stop;
|
2021-12-02 17:02:13 +01:00
|
|
|
std::shared_ptr<PushButton> _button_apply;
|
|
|
|
|
2021-08-27 19:40:48 +02:00
|
|
|
std::shared_ptr<BPMCalculator> _bpm_calculator;
|
|
|
|
std::shared_ptr<BPMSlider> _slider;
|
2021-09-01 21:04:18 +02:00
|
|
|
|
2021-09-10 20:35:48 +02:00
|
|
|
sf::SoundBuffer _slap_buffer;
|
|
|
|
sf::Sound _slap;
|
|
|
|
bool _ticked;
|
|
|
|
|
2021-09-01 21:04:18 +02:00
|
|
|
sf::Text _bpm_value;
|
2021-12-03 20:21:27 +01:00
|
|
|
std::function<microsec(void)> _current_time;
|
2021-08-16 20:54:03 +02:00
|
|
|
};
|
|
|
|
|