You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
project-kyoku/src/gui/widgets/bpmcalculatorwidget.cpp

61 lines
1.5 KiB
C++

#include "bpmcalculatorwidget.h"
#include "tools/bpmcalculator.h"
BPMCalculatorWidget::BPMCalculatorWidget(const std::shared_ptr<BPMCalculator>& bpm_calculator, const std::shared_ptr<sf::Font>& font) :
Window("BPM Calculation", font),
_bpm_calculator(bpm_calculator),
_slider(std::make_shared<BPMSlider>())
{
}
void BPMCalculatorWidget::input(const sf::Event& event)
{
switch (event.type)
{
default:
break;
case sf::Event::KeyPressed:
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space)
{
_bpm_calculator->click();
}
break;
}
Window::input(event);
}
void BPMCalculatorWidget::update(const sf::Time& dt)
{
Window::update(dt);
}
void BPMCalculatorWidget::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
Window::draw(target, states);
if (_is_visible)
_slider->draw(target, states);
}
void BPMCalculatorWidget::setRect(const sf::FloatRect& rect)
{
Window::setRect(rect);
_slider->setRect(sf::FloatRect{0, 0, rect.width / 8 * 6, 100});
_slider->setPosition({_window_content.getGlobalBounds().left + rect.width / 8,
_window_content.getGlobalBounds().top + rect.height / 8 * 3});
}
void BPMCalculatorWidget::move(const sf::Vector2f &delta)
{
Window::move(delta);
_slider->move(delta);
}
void BPMCalculatorWidget::setPosition(const sf::Vector2f &position)
{
Window::setPosition(position);
_slider->setPosition(position);
}