slint icon indicating copy to clipboard operation
slint copied to clipboard

`source-clip-x`, `source-clip-width`, etc. don't seem to be doing anything.

Open Kirottu opened this issue 4 years ago • 6 comments
trafficstars

As simple as that, I have tried specifying those values with the proper coordinates in the image space (dependent on the resolution i think?) but they do not seem to be doing anything at all.

Image {
	image-fit: cover;
	source: banner;
	height: parent.height;
	width: 400px;
	source-clip-x: 200;
	Image {
		source: logo;
		width: 200px;
	}
}

In that snippet of code, the source-clip-x does nothing. The banner image is 1920x620 in resolution.

Kirottu avatar Nov 21 '21 07:11 Kirottu

I can reproduce the bug with the Qt backend (but the GL backend works fine)

ogoffart avatar Nov 21 '21 12:11 ogoffart

In fact, it only work if all of source-clip-x, cource-clip-y, source-clip-width and source-clip-height are specified. The GL backend also shows some artifacts if the 4 properties are not specified.

ogoffart avatar Nov 21 '21 12:11 ogoffart

@tronical when source-clip-width is not specified, it is the same as source-clip-width: 0. Currently, when the size of the clip is 0, the Qt backend disable the clipping, and the GL backend then use the size of the image (which is too big if one does not start at 0)

We could make it that source-clip-width of 0 means, in fact, source.width - source-clip-x. That would fix the issue, but it is strange that if i specify source-clip-width:0; then there is no more cut (IMHO the image should be empty in that case). There is still the problem that if i specify source-clip-width to a huge number bigger than the image, it will show artifacts.

ogoffart avatar Nov 21 '21 13:11 ogoffart

You're right, source-clip-width defaulting to source.width - source-clip-x makes sense. I also agree that 0 as source-clip-width should make the image invisible. That requires the above default though.

And indeed, source-clip-width should be internally restricted to the range 0..source.width.

And I guess meanwhile @Kirottu can work around it by specifying all four properties?

tronical avatar Nov 22 '21 11:11 tronical

Yes I did that and now it works, but probably should be more intuitive like how height/width are automatically scales when the other one is specified.

Kirottu avatar Nov 22 '21 20:11 Kirottu

Another thing that would make sense is that the implicit width of Image is reduces to source-clip-width when specified. Same for height and source-clip-height of course.

lukas-jung avatar Aug 01 '22 12:08 lukas-jung

We should add a default binding from source-clip-width to source.width - source-clip-x makes And since this take some memory, we should make sure that Colorized image is not impacted

ogoffart avatar Nov 29 '22 13:11 ogoffart

I assume the default width and height should be based on the source-clip-width / source-clip-height

ogoffart avatar Dec 20 '22 11:12 ogoffart