# HG changeset patch # User František Kučera # Date 1703719943 -3600 # Node ID 7ea796b005385c2fddc4d4db30a80905d84e3535 # Parent 4620bba4fa403d3a582f73dfa4608fb12976c882 convert functions to methods: goPage(), goHome(), goEnd(), goPageMouse() diff -r 4620bba4fa40 -r 7ea796b00538 OHP3D.cpp --- a/OHP3D.cpp Wed Dec 27 23:25:06 2023 +0100 +++ b/OHP3D.cpp Thu Dec 28 00:32:23 2023 +0100 @@ -198,6 +198,10 @@ void setTitle(const std::string& suffix = ""); static const std::string getDefaultFile(const std::string& relativePath); + void goPage(int count); + void goHome(); + void goEnd(); + void goPageMouse(XButtonEvent ev); }; OHP3D::OHP3D(const Configuration& configuration) : @@ -309,36 +313,6 @@ runShaders(); glXSwapBuffers(dpy, win); - auto goPage = [&](int count) { - // TODO: support pages with different ratios - ctx.moveRight(count * 1.8 * textures[0]->getRatio()); - }; - - auto goHome = [&]() { - ctx.cameraFront = initialCtx.cameraFront; - ctx.cameraPos = initialCtx.cameraPos; - ctx.cameraUp = initialCtx.cameraUp; - }; - - auto goEnd = [&]() { - goHome(); - goPage(textures.size() - 1); - }; - - auto goPageMouse = [&](XButtonEvent ev) { - XWindowAttributes gwa; - XGetWindowAttributes(dpy, win, &gwa); - - bool top = ev.y < gwa.height / 2, bottom = !top; - bool left = ev.x < gwa.width / 2, right = !left; - - if (top && left) goHome(); - else if (top && right) goEnd(); - else if (bottom && left) goPage(-1); - else if (bottom && right) goPage(+1); - }; - - for (XEvent xev; keepRunningX11;) { int epollEventCount = epoll.wait(); //std::cout << "trace: epoll.wait() = " << epollEventCount << std::endl; @@ -728,3 +702,32 @@ } return false; } + +void OHP3D::Impl::goPage(int count) { + // TODO: support pages with different ratios + ctx.moveRight(count * 1.8 * textures[0]->getRatio()); +} + +void OHP3D::Impl::goHome() { + ctx.cameraFront = initialCtx.cameraFront; + ctx.cameraPos = initialCtx.cameraPos; + ctx.cameraUp = initialCtx.cameraUp; +} + +void OHP3D::Impl::goEnd() { + goHome(); + goPage(textures.size() - 1); +} + +void OHP3D::Impl::goPageMouse(XButtonEvent ev) { + XWindowAttributes gwa; + XGetWindowAttributes(dpy, win, &gwa); + + bool top = ev.y < gwa.height / 2, bottom = !top; + bool left = ev.x < gwa.width / 2, right = !left; + + if (top && left) goHome(); + else if (top && right) goEnd(); + else if (bottom && left) goPage(-1); + else if (bottom && right) goPage(+1); +}