convert functions to methods: goPage(), goHome(), goEnd(), goPageMouse() v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 28 Dec 2023 00:32:23 +0100
branchv_0
changeset 34 7ea796b00538
parent 33 4620bba4fa40
child 35 dcb2ad86e23c
convert functions to methods: goPage(), goHome(), goEnd(), goPageMouse()
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);
+}