LISTBROWSER_Top

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_Top

Post by mritter0 »

In my program Workbench Explorer sometimes I need to set the top item in the list. Normally when scan a drawer it is set to 0. But, say you have scrolled down 10 lines with the mouse wheel, then hit reload. I check what the _Top is first, rescan drawer, update the list (detach it, free old, build new), then attach it and set LISTBROWSER_Top, LBTop,. But it does not always work correctly. I can't figure out why.

This code works with 2 of the 4 situations I have.

Code: Select all

	ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
		LISTBROWSER_ColumnInfo,				WhichCI,
		LISTBROWSER_SortColumn,				SortColumn,
		LISTBROWSER_VertSeparators,			ShowVertSeparators,
		LISTBROWSER_AutoFit,				Prefs->AutoFitColumns,
		LISTBROWSER_Labels,					lblist2,
		LISTBROWSER_Top,					LBTop,
	TAG_DONE);
If I swap the last 2 lines, it works with 1 other but then first 2 no longer work. One situation never works. I know LBTop value is correct, I Printf() before attaching the list to see it.

I have played around with _Top and _Labels order, used SetAttrs() instead (yes, the gadget is on a page.gadget). LBTop will be set to 0, scan a drawer, but will start at the old LBTop spot. No rhyme or reason sometimes.

I would think you would set _Top first, then _Labels. Is there some magic order I am not doing? Does it even matter what order? Just baffling me.

listbrowser.gadget 53.74 (23.10.2016)
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_Top

Post by broadblues »

Try calling RefreshPageGadget() after re-adding the list and setting LISTBROWSER_Top.

Always set LISTBROWSER_Top after adding the list, it's not meaningfull if no list is attached,

Possibly use a seperate call to SetPageGadgetAttrs.


Code: Select all

   ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
      LISTBROWSER_ColumnInfo,            WhichCI,
      LISTBROWSER_SortColumn,            SortColumn,
      LISTBROWSER_VertSeparators,         ShowVertSeparators,
      LISTBROWSER_AutoFit,            Prefs->AutoFitColumns,
      LISTBROWSER_Labels,               lblist2,
   TAG_DONE);

   ILayout->SetPageGadgetAttrs((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,
          LISTBROWSER_Top,               LBTop,
   TAG_DONE);

ILayout->RefreshPageGadget((struct Gadget *)Objects[GAD_CONTENT],Objects[GAD_CF_PAGES_CONTENT],MainWindow,NULL,;

Ought to give consistant results.


AS an aside do you really need to set all those other attrs when you reattache the list (fine if they have changed, but wasteful if they didn't);
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: LISTBROWSER_Top

Post by mritter0 »

I made it work with the 2 separate calls, and a small change where list is detached. Slight little flicker as it adjusts, but I can live with it.
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_Top

Post by broadblues »

Not sure if I mentioned this in any previous post but you can reduce flicker when chnaging lists but removing it with SetAttrs() and only using SteGadgetAttrs() or equiv when you reattach the list.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: LISTBROWSER_Top

Post by mritter0 »

That was the issue I was having. I did it with 2 calls way back when, but not using SetAttrs() to detach, so it still flickered. Figured it out over time. Wish I knew earlier........
Workbench Explorer - A better way to browse drawers
Post Reply