Recent

Author Topic: TListView: Reduce space between images.  (Read 3169 times)

GAN

  • Sr. Member
  • ****
  • Posts: 370
TListView: Reduce space between images.
« on: February 23, 2018, 11:06:59 pm »
Is there a way to reduce it?, because I don't use caption. SmallImages used and ViewStyle := vsSmallIcon.

Best regards.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: TListView: Reduce space between images.
« Reply #1 on: February 23, 2018, 11:31:08 pm »
Look in the "Columns" Array and set the Maxwidth for First column ?

Columns is an array of TlistColumn  which has MaxWidth and MinWidth or even Width..

The only true wisdom is knowing you know nothing

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: TListView: Reduce space between images.
« Reply #2 on: February 24, 2018, 12:14:33 am »
Sorry, I was referring to the vertical space between images. I'm not using columns because I only need a list of images.

Thanks anyway.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TListView: Reduce space between images.
« Reply #3 on: February 24, 2018, 12:20:19 am »
The green envelope looks as if your images are not square. What is the Width and Height in the ImageList associated to the ListView? For square images, both values must be equal.

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: TListView: Reduce space between images.
« Reply #4 on: February 24, 2018, 12:32:55 am »
No, the green envelope is because the empty caption.
TImageList 32x32 and TListView.SmallImages are 32x32 too.
I need to hide the caption of the items to solve this. (I think...)
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TListView: Reduce space between images.
« Reply #5 on: February 24, 2018, 12:43:55 am »
Working fine for me, the icons practically touch. Can you post a little demo to play with? (only .pas, .lfm, .lpr, and .lpi files, all packed into a common zip which you can upload under "Attachments and other options". No big project, please, this effect should be reproducible for you in a little stand-alone demo - otherwise the bug is somewhere else).

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: TListView: Reduce space between images.
« Reply #6 on: February 24, 2018, 12:59:14 am »
Zip file atached. I also include .res because the images.
I made a new proyect with only the TListView a TImageList.
May be a GTK2 limitation?
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: TListView: Reduce space between images.
« Reply #7 on: February 24, 2018, 01:36:21 am »
Works fine on Windows, so the problem is only with GTK widget.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TListView: Reduce space between images.
« Reply #8 on: February 24, 2018, 01:48:14 am »
Thank you. On Windows the icons are close together, like I see it in my own demo. On Linux I see the same wide vertical spacing as you. I switched from gtk2 to qt4 - same result. It looks as if Linux reserves the space for the text and ignores that there is no text at all.

But just to draw icons, a TListview maybe is "overkill". Can't you try to paint them yourself on a Paintbox which you insert into a Scrollbox? Use its OnPaint event, call ImageList.Draw(Canvas, x,y, ImgIndex) to draw the image. See attached demo (quick and dirty, could be improved to draw only the visible images, which certainly will be much faster than the overloaded ListView).
« Last Edit: February 24, 2018, 01:50:19 am by wp »

GAN

  • Sr. Member
  • ****
  • Posts: 370
Re: TListView: Reduce space between images.
« Reply #9 on: February 24, 2018, 04:08:26 am »
Compilar proyecto, Objetivo: project1: Código de salida 256, Errores: 1
project1.lpr(17,15) Error: identifier idents no member "Scaled"

Anyway, I know nothing about paintbox, scrollbox and canvas. I'm new in the world of graphical programation, I come from Clipper.... I need lot of time to study the LCL components. Also this program will be used on Windows, so there's not real problem.

Thank you for your help and "sorry" for my english  :)

Best Regards.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TListView: Reduce space between images.
« Reply #10 on: February 24, 2018, 10:30:05 am »
project1.lpr(17,15) Error: identifier idents no member "Scaled"
That problem again! It is because I am switching between Laz trunk and 1.8. Just remove this line in project1.lpr.

zeljko

  • Hero Member
  • *****
  • Posts: 1596
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: TListView: Reduce space between images.
« Reply #11 on: February 24, 2018, 11:57:28 am »
Thank you. On Windows the icons are close together, like I see it in my own demo. On Linux I see the same wide vertical spacing as you. I switched from gtk2 to qt4 - same result. It looks as if Linux reserves the space for the text and ignores that there is no text at all.

But just to draw icons, a TListview maybe is "overkill". Can't you try to paint them yourself on a Paintbox which you insert into a Scrollbox? Use its OnPaint event, call ImageList.Draw(Canvas, x,y, ImgIndex) to draw the image. See attached demo (quick and dirty, could be improved to draw only the visible images, which certainly will be much faster than the overloaded ListView).

Linux does not have anything todo with spacing in TListView. It's up to widgetset, so better fill bug report against gtk2 and qt and attach simple example project.

wp

  • Hero Member
  • *****
  • Posts: 11910
Re: TListView: Reduce space between images.
« Reply #12 on: February 24, 2018, 01:40:55 pm »
You're right. I should try to use more precise words.

 

TinyPortal © 2005-2018