Skip to content

Conversation

elektronisk
Copy link
Contributor

Here's a commit that fixes #195. It lets you scale with different amounts horizontally and vertically if you hold the shift key while scaling.

It generalizes the existing logic to be able to operate on x and y directions independently.

I'm unsure what to do with the absmax function, if it should be a static ScaleTool method, part of some utility function collection, or if it's ok for it to just hang out where it does as it does now. Please advise on this.

@elektronisk
Copy link
Contributor Author

Screen.Recording.2025-06-04.195843.mp4

Here is a short clip showing the function.

@dl3sdo
Copy link
Member

dl3sdo commented Jun 5, 2025

Maybe you want to add the possibility to cancel the scaling operation with Escape key (as added by @dg0yt in #2360).
Aborting some other operations (e.g., rotating) with Escape is not (yet) possible whereas aborting a move operation is.

bool ScaleTool::keyPressEvent(QKeyEvent* event)
{
	switch (event->key())
	{
	case Qt::Key_Control:
		using_scaling_center = false;
		updateStatusText();
		updateDirtyRect();
		return false; // not consuming Ctrl
	case Qt::Key_Shift:
		uniform_scaling = false;
		updateStatusText();
		updateDirtyRect();
		return false;
	case Qt::Key_Escape:
		if (isDragging())
		{
			cancelDragging();
			if (editingInProgress())
				abortEditing();
			updateStatusText();
			updateDirtyRect();
		}
		return false;
	}

	return false;
}

BTW: I propose to move double absmax(double v, double max) into an anonymous namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-isotropic scaling tool

2 participants