forked from NaiJi/project-kyoku
Implement BPMCalculatorWidget, add sf::Time dt to all update() functions
parent
788cd090f2
commit
80bc47e425
@ -0,0 +1,38 @@
|
||||
#include "bpmslider.h"
|
||||
|
||||
BPMSlider::BPMSlider(const std::shared_ptr<sf::Font> &font)
|
||||
{
|
||||
_bpm_value.setFont(*font);
|
||||
}
|
||||
|
||||
void BPMSlider::input(const sf::Event& event)
|
||||
{
|
||||
Widget::input(event);
|
||||
}
|
||||
|
||||
void BPMSlider::update(const sf::Time& dt)
|
||||
{
|
||||
Widget::update(dt);
|
||||
}
|
||||
|
||||
void BPMSlider::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
Widget::draw(target, states);
|
||||
}
|
||||
|
||||
void BPMSlider::setRect(const sf::FloatRect& rect)
|
||||
{
|
||||
_slider_background.setPosition(rect.left, rect.top);
|
||||
_slider_background.setSize({rect.width, rect.height});
|
||||
}
|
||||
|
||||
void BPMSlider::setPosition(const sf::Vector2f& position)
|
||||
{
|
||||
_slider_background.setPosition(position);
|
||||
}
|
||||
|
||||
bool BPMSlider::isUnderMouse(int mouse_x, int mouse_y) const
|
||||
{
|
||||
return mouse_x == mouse_y; // just to compile
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "widget.h"
|
||||
|
||||
#include <SFML/Graphics/RectangleShape.hpp>
|
||||
#include <SFML/Graphics/Text.hpp>
|
||||
|
||||
class BPMSlider : public Widget
|
||||
{
|
||||
public:
|
||||
explicit BPMSlider(const std::shared_ptr<sf::Font> &font);
|
||||
|
||||
virtual void input(const sf::Event& event) override;
|
||||
virtual void update(const sf::Time& dt) override;
|
||||
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;
|
||||
virtual bool isUnderMouse(int mouse_x, int mouse_y) const override;
|
||||
|
||||
private:
|
||||
sf::RectangleShape _slider_background;
|
||||
sf::RectangleShape _slider_tick;
|
||||
sf::Text _bpm_value;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue