Simplify signature of updateRenderPreferences

Tue, 11 Apr 2023 20:27:04 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Tue, 11 Apr 2023 20:27:04 +0300
changeset 375
21a5ecbe34e4
parent 374
75efc3ba5a56
child 376
3cef3b016330

Simplify signature of updateRenderPreferences

src/main.cpp file | annotate | diff | comparison | revisions
--- a/src/main.cpp	Tue Apr 11 11:11:28 2023 +0300
+++ b/src/main.cpp	Tue Apr 11 20:27:04 2023 +0300
@@ -176,20 +176,17 @@
 	});
 }
 
-static void updateRenderPreferences(
-	MainWindow* ui,
-	const gl::RenderPreferences* renderPreferences,
-	const DocumentManager* documents)
+static void updateRenderPreferences(MainState* state)
 {
-	forEachModel(documents, [&renderPreferences](const void*, const ModelData* data){
+	forEachModel(&state->documents, [state](const void*, const ModelData* data){
 		if (data->canvas != nullptr) {
-			data->canvas->setRenderPreferences(*renderPreferences);
-			data->canvas->setLayerEnabled(data->axesLayer.get(), renderPreferences->drawAxes);
+			data->canvas->setRenderPreferences(state->renderPreferences);
+			data->canvas->setLayerEnabled(data->axesLayer.get(), state->renderPreferences.drawAxes);
 		}
 	});
-	ui->setRenderStyle(renderPreferences->style);
-	ui->actionDrawAxes->setChecked(renderPreferences->drawAxes);
-	ui->actionWireframe->setChecked(renderPreferences->wireframe);
+	state->mainWindow.setRenderStyle(state->renderPreferences.style);
+	state->mainWindow.actionDrawAxes->setChecked(state->renderPreferences.drawAxes);
+	state->mainWindow.actionWireframe->setChecked(state->renderPreferences.wireframe);
 }
 
 static gl::RenderPreferences loadRenderPreferences()
@@ -394,7 +391,7 @@
 	state->libraries.restoreFromSettings();
 	updateRecentlyOpenedDocumentsMenu(state);
 	state->colorTable = loadColors(&state->libraries);
-	updateRenderPreferences(&state->mainWindow, &state->renderPreferences, &state->documents);
+	updateRenderPreferences(state);
 	state->mainWindow.mdiArea->setViewMode(setting<Setting::ViewMode>());
 	state->mainWindow.retranslateUi(&state->mainWindow);
 	state->mainWindow.setToolButtonStyle(setting<Setting::ToolButtonStyle>());
@@ -599,21 +596,21 @@
 	{
 		state.renderPreferences.drawAxes = drawAxes;
 		saveSettings(&state);
-		updateRenderPreferences(&state.mainWindow, &state.renderPreferences, &state.documents);
+		updateRenderPreferences(&state);
 	});
 	QObject::connect(state.mainWindow.actionWireframe, &QAction::triggered, [&state]
 		(bool enabled)
 	{
 		state.renderPreferences.wireframe = enabled;
 		saveSettings(&state);
-		updateRenderPreferences(&state.mainWindow, &state.renderPreferences, &state.documents);
+		updateRenderPreferences(&state);
 	});
 	QObject::connect(&state.mainWindow, &MainWindow::renderStyleSelected, [&state]
 		(gl::RenderStyle newStyle)
 	{
 		state.renderPreferences.style = newStyle;
 		saveSettings(&state);
-		updateRenderPreferences(&state.mainWindow, &state.renderPreferences, &state.documents);
+		updateRenderPreferences(&state);
 	});
 	initializeTools(&state.mainWindow, &state.toolWidgets, &state.mainWindow);
 	for (QAction* action : state.mainWindow.editingModesToolBar->actions()) {
@@ -734,7 +731,7 @@
 		}
 	);
 	restoreSettings(&state);
-	updateRenderPreferences(&state.mainWindow, &state.renderPreferences, &state.documents);
+	updateRenderPreferences(&state);
 	const int result = app.exec();
 	saveSettings(&state);
 	return result;

mercurial