DoorKeeper/include/doorkeeper/components/viewport.hpp
2015-08-28 17:31:17 +02:00

95 lines
3 KiB
C++

/* Copyright 2015, Michele Santullo
* This file is part of DoorKeeper.
*
* DoorKeeper is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DoorKeeper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DoorKeeper. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef id0ADBCC15BA574485BF3267254090D99B
#define id0ADBCC15BA574485BF3267254090D99B
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/components/tileiterator.hpp"
#include "doorkeeper/components/layer.hpp"
#include "doorkeeper/components/tilecoords.hpp"
#include <cstdint>
#include <cmath>
#include <boost/functional/hash_fwd.hpp>
namespace dk {
template <uint32_t D>
class Tyler;
template <typename T, uint32_t D>
class Layer;
template <uint32_t D>
struct TileInfo {
typedef Vector<D> coords;
TileInfo ( const LayerBase<D>& parLayer );
coords tile_size;
coords map_size;
};
template <uint32_t D>
std::size_t hash_value ( const TileInfo<D>& parTProps ) noexcept a_pure;
template <uint32_t D>
class Viewport {
public:
typedef Vector<D> coords;
typedef VectorT<CoordinateAccumType, D> coords_f;
Viewport ( const Viewport& parOther ) = default;
Viewport ( Tyler<D>& parTyler, const TileInfo<D>* parTileInfo );
Viewport ( Tyler<D>& parTyler, const TileInfo<D>* parTileInfo, const coords& parPos );
~Viewport ( void ) noexcept = default;
Viewport& operator= ( const Viewport& ) = default;
Viewport& operator+= ( const coords_f& parValue );
Viewport& operator-= ( const coords_f& parValue );
void setFrom ( const coords& parFrom );
coords size ( void ) const;
coords pixel_offset ( void ) const;
template <typename T>
typename Layer<T, D>::iterator begin ( Layer<T, D>& parLayer ) const;
template <typename T>
typename Layer<T, D>::iterator end ( Layer<T, D>& parLayer ) const;
template <typename T> inline
typename Layer<T, D>::const_iterator begin ( const Layer<T, D>& parLayer ) const a_always_inline;
template <typename T> inline
typename Layer<T, D>::const_iterator end ( const Layer<T, D>& parLayer ) const a_always_inline;
template <typename T>
typename Layer<T, D>::const_iterator cbegin ( const Layer<T, D>& parLayer ) const;
template <typename T>
typename Layer<T, D>::const_iterator cend ( const Layer<T, D>& parLayer ) const;
void set_tile_info ( const TileInfo<D>* parTileInfo );
private:
void clip_pixel_offset ( void );
TileCoords<D> m_view;
coords_f m_pixel_offset;
Tyler<D>& m_tyler;
const TileInfo<D>* const m_tile_info;
};
} //namespace dk
#include "doorkeeper/implem/viewport.inl"
#endif