-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTileGridView.h
44 lines (40 loc) · 1.12 KB
/
TileGridView.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <math.h>
#include <SFML/Graphics.hpp>
#include "GuiElement.h"
#include "TileGrid.h"
//Contains an sf::View which displays one TileGrid.
//TileGridView's view rectangle and Viewport are maintained to be the same size to avoid skewing/changing scale.
//Its centering and scrolling are dependent on the size of the TileGrid.
class TileGridView : public GuiElement
{
public:
TileGrid* grid;
sf::View view;
sf::Vector2f w_size;
//float full_zoom;
float z;
sf::Vector2f s;
TileGridView(const sf::FloatRect& rect, sf::Vector2f w_size, TileGrid* grid);
void zoom(int delta);
void scroll(sf::Keyboard::Key key);
void resize(float w, float h);
void reset(const sf::FloatRect& rect);
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
void fitToScreen();
void centerOnGrid();
void initZoom(float in_zoom);
void handleResize();
void handleZoom();
void updateWindow(sf::Vector2f w_size);
private:
bool init_zoom = false;
float max_scroll_x;
float max_scroll_y;
//float init_s;
float s_delta;
float default_zoom;
float full_zoom;
const float min_zoom = 0.01;
const float max_zoom = 4.0;
};