Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom cursors are not so responsive #182

Open
vakokako opened this issue Mar 21, 2022 · 1 comment
Open

Custom cursors are not so responsive #182

vakokako opened this issue Mar 21, 2022 · 1 comment
Labels

Comments

@vakokako
Copy link

When moving crosshair cursor, there is a slight delay compared to standard mouse. I've seen that custom cursor was done with quick items and sending mouse position via signals/slots.

I'm not so familiar with qt quick, but could this be implemented without signal/slots to remove the delay?

@vakokako vakokako added the bug label Mar 21, 2022
@mitchcurtis
Copy link
Owner

Hi, thank you for the feedback. :)

I am using Qt Quick items for the cursors currently:

CrosshairCursor {
id: crosshairCursor
x: canvas ? canvas.cursorX - width / 2 : 0
y: canvas ? canvas.cursorY - height / 2 : 0
z: 1
colour: canvas ? canvas.invertedCursorPixelColour : defaultColour
visible: canvas && canvas.hasBlankCursor && !canvas.useIconCursor && (canvas.useCrosshairCursor || settings.alwaysShowCrosshair)
}
RectangularCursor {
id: rectangleCursor
x: canvas ? Math.floor(canvas.cursorX - width / 2) : 0
y: canvas ? Math.floor(canvas.cursorY - height / 2) : 0
z: 1
width: canvas ? canvas.toolSize * canvas.currentPaneZoomLevel : 0
height: canvas ? canvas.toolSize * canvas.currentPaneZoomLevel : 0
visible: canvas && canvas.hasBlankCursor && !canvas.useIconCursor && !canvas.useCrosshairCursor
}
Label {
id: iconCursor
x: canvas ? canvas.cursorX : 0
y: canvas ? canvas.cursorY - height + 3 : 0
z: 1
visible: canvas && canvas.hasBlankCursor && canvas.useIconCursor
text: visible && checkedToolButton ? checkedToolButton.text : ""
font.family: "FontAwesome"
color: canvas ? canvas.invertedCursorPixelColour : crosshairCursor.defaultColour
}

The benefit of this approach is that the cursors can be coloured, which means we can also use the inverse of the colour under the pixel to ensure that the cursor has good visibility due to contrast.

Another advantage is that we can have nice, smooth cursors. From memory, a custom QCursor shape will be quite blocky and not smooth, but I'd have to double-check that.

The disadvantage is, as you've seen, it can lag behind the mouse a bit due to it not being a system cursor. That's unrelated to signals and slots though, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants