Custom cursors and high dpi (Windows and MacOS testers needed)

A forum for research and development of the user interface of FreeCAD

Moderator: agryson

jmaustpc
Posts: 10375
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby jmaustpc » Fri Jul 24, 2020 6:01 pm

mikeprice99 wrote:
Fri Jul 24, 2020 5:25 pm
jmaustpc wrote:
Fri Jul 24, 2020 4:23 pm
I will do them if you want, if that is Okay with others here, if no one else has already started doing them.
Or I'd be happy to. I know the svg format very well and have even written my own svg path editor which produces very compact paths.
If you use Inkscape it produces highly bloated files and paths that randomly flip between absolute and relative commands.

I could actually potentially add to my path editor to include a converter to take in the xpm data and spit out good svg.
We have always used Inkscape because it is the application written by the SVG body, so presumably it is most likely to be standards compliant.

Years ago we had issues with Windows systems only supporting a sub-set of SVG and hence some icons would not display, but that was a very long time ago. something like 7 years ago from memory. Eventually something was updated, possibly QT, and then they all worked as SVG was finally properly supported.

Interesting story, I can remember standing in my kitchen of the house I used to own in the Australian outback, trying to cook dinner while trying to workout why some SVG icons worked and others didn't, using my Linux system, sending Werner test samples and he was compiling them on his Windows computer in Germany and testing them. Pretty much two points as far apart as one could be on the planet and yet we worked together with instant and almost free communication. Common place today but was not, only a few decades ago. My wife nursed an old lady who was 101, in a nursing home in the year 2000. The old lady was telling my wife that she was amazed that she had made it to the year 2000 because that meant that she had been alive in three centuries! Being born in 1899, she had lived through the birth of the modern era, from the first car being invented to the telephone, the moon landings, super sonic jets, large cheap jet transport, the invention of computers, the Internet, nearly all of modern medicine. It is amazing how far we have come so quickly compared to the rest of history. Anyway I have digressed!

I have no idea if your SVG files are a good idea or not, I just don't know enough about it. My one possibly irrelevant comment would be that we would rather bloated SVG files that work on all platforms than ones with any compatibility issues. But I have no idea if I am talking garbage or not.

Jim
openBrain
Posts: 4870
Joined: Fri Nov 09, 2018 5:38 pm

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby openBrain » Fri Jul 24, 2020 6:34 pm

jmaustpc wrote:
Fri Jul 24, 2020 6:01 pm
My wife nursed an old lady who was 101, in a nursing home in the year 2000. The old lady was telling my wife that she was amazed that she had made it to the year 2000 because that meant that she had been alive in three centuries!
Unfortunately for the old lady she was wrong. The 21st century started only on the 1st January of 2001. Though it's a nice story and I hope the venerable lady lived the longest possible time. :)
mikeprice99
Posts: 79
Joined: Sat Jun 27, 2020 9:06 am
Location: Dorset, England

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby mikeprice99 » Fri Jul 24, 2020 6:45 pm

Just as an example of clean svg. This code gives virtually an identical image to Sketcher_Pointer_Slot.svg from a few pages back.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg"  xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="64" width="64">
  <g id="symbol">
    <ellipse style="fill:none;stroke:#cc0000;stroke-width:2;" cx="41" cy="45" rx="20" ry="14" />
    <circle cx="35" cy="45" r="5" fill="#cc0000"/>
    <circle cx="55" cy="35" r="5" fill="#cc0000"/>
  </g>
  <g id="crosshair" style="stroke:#eeeeec;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;"> 
    <path d="m16,3v9m0,8v9m-13-13h9m8,0h9" /> 
  </g>
</svg>
Inkscape includes many commands and xml additions to help the inkscape program control how things are edited. It also keeps track of grids and loads of things that are not needed for the actual image.
If you look at the code above and compare it with the file given a few pages back (Sketcher_Pointer_Slot.svg) you'll see how nice it is.
That example file a few pages back actually had several colour gradients defined that weren't even used.

Save the code above as test.svg and ask your browser to open it!

For each of the different cursors, we only need to change the section with id "symbol"
Last edited by mikeprice99 on Sat Jul 25, 2020 10:26 am, edited 1 time in total.
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby vanuan » Sat Jul 25, 2020 8:06 am

openBrain wrote:
Fri Jul 24, 2020 3:37 pm
I think if we go for SVG, we should split cross hair symbol and command symbols, then compose the cursor at creation time. It will be far more flexible.
It looks like this is done for constraints cursors, but not for geometric shapes cursors.

The issue is that if you split them, you'd need to store positioning somewhere. Otherwise, they'd be either too small or overlap.
chrisb
Posts: 29018
Joined: Tue Mar 17, 2015 9:14 am

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby chrisb » Sat Jul 25, 2020 8:12 am

jmaustpc wrote:
Fri Jul 24, 2020 6:01 pm
My wife nursed an old lady who was 101, in a nursing home in the year 2000.
I had a customer who's son was born shortly before 2000. He said: "He has good chances to see two century changes. And both times without teeth and without hair!".
A Sketcher Lecture with in-depth information is available in English, auf deutsch, en français, en español.
openBrain
Posts: 4870
Joined: Fri Nov 09, 2018 5:38 pm

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby openBrain » Sat Jul 25, 2020 8:23 am

vanuan wrote:
Sat Jul 25, 2020 8:06 am
The issue is that if you split them, you'd need to store positioning somewhere. Otherwise, they'd be either too small or overlap.
Don't get that point. As you generate pixmap from SVG, you masterize the size of the rendered cursor so it shouldn't be a problem.
jmaustpc
Posts: 10375
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby jmaustpc » Sat Jul 25, 2020 8:28 am

chrisb wrote:
Sat Jul 25, 2020 8:12 am
jmaustpc wrote:
Fri Jul 24, 2020 6:01 pm
My wife nursed an old lady who was 101, in a nursing home in the year 2000.
I had a customer who's son was born shortly before 2000. He said: "He has good chances to see two century changes. And both times without teeth and without hair!".
:lol:
openBrain wrote:
Fri Jul 24, 2020 6:34 pm
jmaustpc wrote:
Fri Jul 24, 2020 6:01 pm
My wife nursed an old lady who was 101, in a nursing home in the year 2000. The old lady was telling my wife that she was amazed that she had made it to the year 2000 because that meant that she had been alive in three centuries!
Unfortunately for the old lady she was wrong. The 21st century started only on the 1st January of 2001. Though it's a nice story and I hope the venerable lady lived the longest possible time. :)
Actually she did! She was still alive in 2001 when my wife left that job! :)
vanuan wrote:
Sat Jul 25, 2020 8:06 am
openBrain wrote:
Fri Jul 24, 2020 3:37 pm
I think if we go for SVG, we should split cross hair symbol and command symbols, then compose the cursor at creation time. It will be far more flexible.
It looks like this is done for constraints cursors, but not for geometric shapes cursors.

The issue is that if you split them, you'd need to store positioning somewhere. Otherwise, they'd be either too small or overlap.
Is it simpler/more reliable to just make one file each then? Although if it is done for the constraints should we copy what was bone there, although those didn't scale so the placement wouldn't need to have been scaled as well I suppose?
jmaustpc
Posts: 10375
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby jmaustpc » Sat Jul 25, 2020 8:30 am

openBrain wrote:
Sat Jul 25, 2020 8:23 am
vanuan wrote:
Sat Jul 25, 2020 8:06 am
The issue is that if you split them, you'd need to store positioning somewhere. Otherwise, they'd be either too small or overlap.
Don't get that point. As you generate pixmap from SVG, you masterize the size of the rendered cursor so it shouldn't be a problem.
but if we are going to be able to scale the icons, wouldn't we need to scale the placement between the two, if they are in different files? If they are in the same SVG file then placement would auto scale with the icons. Or am I wrong?
openBrain
Posts: 4870
Joined: Fri Nov 09, 2018 5:38 pm

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby openBrain » Sat Jul 25, 2020 8:50 am

jmaustpc wrote:
Sat Jul 25, 2020 8:28 am
Is it simpler/more reliable to just make one file each then? Although if it is done for the constraints should we copy what was bone there, although those didn't scale so the placement wouldn't need to have been scaled as well I suppose?
Simplicity is debatable. :) Having both separate is (in my mind) more simple and flexible in 2 cases :
  • Crosshair shape customization : if both symbols are separated, it's easier to offer cursor shape/color customization. Just one source file to be changed/tampered and it will be simply applied averywhere
  • New geometry : if one add a new geometry (eg. rounded rectangle) and want to add a custom symbol, it's easier done just by adding the new SVG symbol rather than having to compose a new "full cursor" shape.
jmaustpc wrote:
Sat Jul 25, 2020 8:30 am
but if we are going to be able to scale the icons, wouldn't we need to scale the placement between the two, if they are in different files? If they are in the same SVG file then placement would auto scale with the icons. Or am I wrong?
As we are using pixmaps to define the cursors, my idea is to first compose a pixmap of crosshair + symbol at maximum definition, then use the QPixmap::scaled() function on the compounded pixmap to get the cursor. Thus the relative spacing is naturally preserved at good scale. ;)
Last edited by openBrain on Sat Jul 25, 2020 8:50 am, edited 1 time in total.
User avatar
vanuan
Posts: 465
Joined: Wed Oct 24, 2018 9:49 pm

Re: Custom cursors and high dpi (Windows and MacOS testers needed)

Postby vanuan » Sat Jul 25, 2020 8:50 am

jmaustpc wrote:
Sat Jul 25, 2020 8:30 am
openBrain wrote:
Sat Jul 25, 2020 8:23 am
vanuan wrote:
Sat Jul 25, 2020 8:06 am
The issue is that if you split them, you'd need to store positioning somewhere. Otherwise, they'd be either too small or overlap.
Don't get that point. As you generate pixmap from SVG, you masterize the size of the rendered cursor so it shouldn't be a problem.
but if we are going to be able to scale the icons, wouldn't we need to scale the placement between the two, if they are in different files? If they are in the same SVG file then placement would auto scale with the icons. Or am I wrong?
I mean that not all icons are the same. Some touch the crosshair, some don't. Compare line and rectangle cursors for example.