Listbrowser centering

This forum is for general developer support questions.
Post Reply
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Listbrowser centering

Post by mritter0 »

I am trying to center an image in a listbrowser column, but the values are incorrect (?)

Code: Select all

IListBrowser->SetListBrowserNodeAttrs(node,
	LBNA_Column,						ci,
//		LBNCA_HorizJustify,					LCJ_CENTER,		// RIGHT
//		LBNCA_HorizJustify,					LCJ_LEFT,		// CENTER
//		LBNCA_HorizJustify,					LCJ_RIGHT,		// RIGHT
		LBNCA_Image,						ContentNode->ImageLabel,
TAG_DONE);
With nothing specified the image is centered. According to the AutoDoc left is the default.
If I specify LCJ_CENTER it right aligns.
If I specify LCJ_LEFT it is centered.
If I specify LCJ_RIGHT it is right aligned.

It appears to just be when use LBNCA_Image because LBNCA_Text works just fine.

V53.62
Workbench Explorer - A better way to browse drawers
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Listbrowser centering

Post by broadblues »

I just modified the LB_Example.c to repeat the label image with left center right justification and it works okay see atached grab.

Do you have specific bit of example code that repeats your issue?

What kind of image object are you adding (small chance the issue might be with the image not the browser).
Attachments
ReAction ListBrowser class exa_702x487x24.jpg
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Listbrowser centering

Post by mritter0 »

After some trials it turns out it is centering correctly. There is extra padding on the left side of the column that moves the image (and text) in a bit (All of the columns have it). In my case, with a narrow column, those extra pixels pushed it to the right, looking not centered. Wouldn't have noticed it with a wider column and image.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Listbrowser centering

Post by mritter0 »

Maybe I am not totally crazy, just partially. ;)

I am using AISS image "list_drawer" which is 16x16. I did some more testing with my column widths.

Width: 22, LCJ_LEFT
LCJ_LEFT_1.png
LCJ_LEFT_1.png (2.93 KiB) Viewed 9933 times
This looks centered, at least on the striped lines.


Width: 22, LCJ_CENTER
LCJ_CENTER_1.png
LCJ_CENTER_1.png (2.64 KiB) Viewed 9933 times
This looks right aligned, mostly, but not centered.


Width: 32, LCJ_CENTER
LCJ_CENTER_2.png
LCJ_CENTER_2.png (2.4 KiB) Viewed 9933 times
Still not centered, still to the right a 4 pixels.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Listbrowser centering

Post by mritter0 »

(only 3 attachments per post allowed)

Width: 50, LCJ_CENTER
LCJ_CENTER_3.png
LCJ_CENTER_3.png (2.5 KiB) Viewed 9932 times
Still 4 pixels to the right of center.


Width: 50, LCJ_LEFT
LCJ_LEFT_2.png
LCJ_LEFT_2.png (2.59 KiB) Viewed 9932 times
Not all the way to the left, 2 pixels to the right.


So is there some padding on the left that is moving the images to the right? It is not truly being centered.


Side note: Why is the striping not all the way to the left/right? It makes the centering look even more off. It is 4 pixels indented, the images are off by 4 pixels......
Workbench Explorer - A better way to browse drawers
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Listbrowser centering

Post by xenic »

mritter0 wrote:Width: 50, LCJ_LEFT
LCJ_LEFT_2.png
Not all the way to the left, 2 pixels to the right.

So is there some padding on the left that is moving the images to the right? It is not truly being centered.
Assuming that your drawer images are TBImage drawer images, there are 2 pixels of border on the left of the actual drawer image that are being blended into the background by the PNG alpha channel. If you look closely at the drawer image in your attachment it isn't perfectly rectangular. That's because the image is being blended into the background by the alpha channel. The actual image in the file is larger than what you see on the screen. You can load the TBImages drawer image into PPaint or ImageFX and you will see that it's actually rectangular with a border around the little drawer picture.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Listbrowser centering

Post by mritter0 »

The image is 16x16 with 1 pixel blank on each side. I accounted for that.

Load one of my images in a paint program and zoom in max and count the pixels.

Two pixels doesn't sound like a big deal until you have a narrow column with small images.
Workbench Explorer - A better way to browse drawers
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Listbrowser centering

Post by xenic »

mritter0 wrote:The image is 16x16 with 1 pixel blank on each side. I accounted for that.

Load one of my images in a paint program and zoom in max and count the pixels.

Two pixels doesn't sound like a big deal until you have a narrow column with small images.
O.K. I was looking at the wrong TBImage and the 16x16 list_drawer doesn't have the extra border pixels. I grabbed a number of Reaction windows and it appears that even when the leftmost items are text, there is a 4 pixel space between the window border and the items in a lister. It does seem that the extra 4 pixel space is not being taken into account when the object position is calculated.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Listbrowser centering

Post by mritter0 »

It's not due to the striping effect. Even without it it still is off.

LCJ_LEFT
LCJ_Left.png
LCJ_Left.png (1.69 KiB) Viewed 9856 times

LCJ_CENTER
LCJ_Center.png
LCJ_Center.png (1.76 KiB) Viewed 9856 times
Workbench Explorer - A better way to browse drawers
Post Reply