-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.h
27 lines (24 loc) · 813 Bytes
/
slider.h
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
#ifndef _SLIDER_H_
#define _SLIDER_H_
#include <SFML/Graphics.hpp>
#include <functional>
#include "boid.h"
class Slider {
private:
sf::RectangleShape slider;
sf::CircleShape knob;
float minValue;
float maxValue;
float value;
bool dragging;
std::vector<Boid>& boids;
std::function<void(float, std::vector<Boid>&)> valueChangedCallback;
public:
Slider(float minValue, float maxValue, float defaultValue, sf::Vector2f position, float width, std::vector<Boid>& boids);
float getValue() const;
void setValueChangedCallback(std::function<void(float, std::vector<Boid>&)> callback);
void handleEvent(sf::Event event);
void updateKnobPosition();
void draw(sf::RenderWindow& window) const;
};
#endif