/* -*- c++ -*- * Copyright ©2008 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "xfview_translate.h" #include "magellan/plugininfo_viewport.h" extern "C" PluginInfo* getmodules(int i) { if(i == 0) { PluginInfo_Viewport* pi = new PluginInfo_Viewport(); pi->name = "Translating Viewport"; pi->author = "Hugo Mills"; pi->version = 0x10001; pi->parser = XfView_Translate::parse; return pi; } else return NULL; } XfView* XfView_Translate::parse(ConfigLexer*, const std::string&, const std::string&) { return NULL; } XfView_Translate::XfView_Translate(XfView* vp, int xoff, int yoff) : XfView(ivec2(0), ivec2(0), ivec2(0), vp->scaling()), view(vp), xoffset(xoff), yoffset(yoff) { } XfView_Translate::~XfView_Translate() { } bool XfView_Translate::f(ivec2& result, const dvec2& pre) const { bool rv = view->f(result, pre); result[0] += xoffset; result[1] += yoffset; return rv; } bool XfView_Translate::g(dvec2& result, const ivec2& post) const { ivec2 xy = post; xy[0] -= xoffset; xy[1] -= yoffset; return view->g(result, xy); }