/* 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 . */ namespace dk { template LayeredViewport::LayeredViewport (Tyler& parTyler) : m_tyler(parTyler) { for (const auto& layer : m_tyler) { const TileInfo tinfo(layer); auto it_found = m_views.find(tinfo); if (m_views.end() == it_found) { auto it_new = m_views.insert(it_found, Viewport(m_tyler, nullptr)); it_new->second.set_tile_info(&it_new->first); } } m_tyler.register_for_layeradd(this); } template LayeredViewport::~LayeredViewport() noexcept { m_tyler.unregister_for_layeradd(this); } template LayeredViewport& LayeredViewport::operator+= (const coords_f& parValue) { for (auto& view : m_views) { view.second += parValue; } return *this; } template LayeredViewport& LayeredViewport::operator-= (const coords_f& parValue) { for (auto& view : m_views) { view.second -= parValue; } return *this; } template void LayeredViewport::on_layer_added (const LayerBase* parLayer) { } template void LayeredViewport::on_layer_removed (const LayerBase* parLayer) { } template auto LayeredViewport::begin() -> iterator { return iterator(m_view.begin(), std::bind(&LayeredViewport::viewport, this, std::placeholders::_1)); template auto LayeredViewport::begin() const -> const_iterator { return const_iterator(m_view.begin(), std::bind(&LayeredViewport::viewport, this, std::placeholders::_1)); } template auto LayeredViewport::end() -> iterator { return iterator(m_view.end(), std::bind(&LayeredViewport::viewport, this, std::placeholders::_1)); template auto LayeredViewport::end() const -> const_iterator { return const_iterator(m_view.end(), std::bind(&LayeredViewport::viewport, this, std::placeholders::_1)); } template Viewport& LayeredViewport::viewport (const LayerBase& parLayer) { return const_cast&>(const_cast*>(this)->viewport(parLayer)); template const Viewport& LayeredViewport::viewport (const LayerBase& parLayer) const { const TileInfo tinfo { parLayer.tile_size(), parLayer.map_size() }; return m_views[tinfo]; } } //namespace dk