Page 1 of 1

Bug or new Feature? SetGadgetState(,) centers Items on LIG

Posted: Fri Sep 25, 2015 2:16 pm
by Oma
From PureBasic V5.40 B4 and higher, gtk2 + gtk3 on all TreeView-based Gadgets (ListIconGadget, ListViewGadget, TreeGadget ...) a SetGadgetState() (to select an item) automatically centers the selected item vertically in the List.

I think this, as Default-Behaviour, is no good idea because it's sometimes very hard to keep the overview. As Option-Flag it's very welcome. :)

Example

Code: Select all

EnableExplicit

;Window Variablen
#MainWin= 0
#LIG    = 0
#TrG    = 1

Global.l gEvent, gQuit, gCounter

Procedure FillLIG()
	Protected.l I
	SetGadgetState(#LIG, gCounter)
	SetGadgetState(#TrG, gCounter)
	gCounter+ 1
	If gCounter = 50 : RemoveWindowTimer(#MainWin, 0) : EndIf
EndProcedure

Procedure CreateWindow_Main()
	Protected.i I

	If OpenWindow(#MainWin, 200, 200, 700, 400, "New? Vert. autocenter.", #PB_Window_SystemMenu)
		ListIconGadget(#LIG, 5, 5, 340, 380, "Spalte 1", 135, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines)
		For I= 1 To 1
			AddGadgetColumn(#LIG, I, "Spalte "+Str(I+ 1), 135)
		Next I
		For I= gCounter*100 To gCounter*100 +49
			AddGadgetItem(#LIG, -1, "Zelle - Zeile " +Str(I)+" / Spalte 1" + #LF$ + "Zelle - Zeile " +Str(I)+" / Spalte 2")
		Next I

		TreeGadget(#TrG, 350, 5, 340, 380)
		For I = 0 To 10
			AddGadgetItem (#TrG, -1, "Normal Item "+Str(I), 0, 0)
			AddGadgetItem (#TrG, -1, "Node "+Str(I), 0, 0)
			AddGadgetItem(#TrG, -1, "Sub-Item 1", 0, 1)
			AddGadgetItem(#TrG, -1, "Sub-Item 2", 0, 1)
			AddGadgetItem(#TrG, -1, "Sub-Item 3", 0, 1)
			AddGadgetItem(#TrG, -1, "Sub-Item 4", 0, 1)
			AddGadgetItem (#TrG, -1, "File "+Str(i), 0, 0)
		Next I
		gtk_tree_view_expand_all_(GadgetID(#TrG))
	EndIf
EndProcedure

CreateWindow_Main()

AddWindowTimer(#MainWin, 0, 100)

Repeat
	gEvent= WaitWindowEvent()

	Select gEvent
		Case #PB_Event_CloseWindow
			gQuit= #True
		Case #PB_Event_Timer
			FillLIG()
			
	EndSelect
	
Until gQuit
RemoveWindowTimer(#MainWin, 0)
Regards, Charly

Re: Bug or new Feature? SetGadgetState(,) centers Items on L

Posted: Fri Sep 25, 2015 3:43 pm
by bbanelli
Oma wrote:From PureBasic V5.40 B4 and higher, gtk2 + gtk3 on all TreeView-based Gadgets (ListIconGadget, ListViewGadget, TreeGadget ...) a SetGadgetState() (to select an item) automatically centers the selected item vertically in the List.

I think this, as Default-Behaviour, is no good idea because it's sometimes very hard to keep the overview. As Option-Flag it's very welcome. :)
On Ubuntu 14.04, x64, they are the same, which is confirmed with gtk_tree_view_get_column_(); for example:

Code: Select all

*Column = gtk_tree_view_get_column_(GadgetID(#LIG), 0)
Debug PeekF(gtk_tree_view_column_get_alignment_(*Column))
Which returns 0.0 for left alignment in both 5.31 and 5.4b7.

Re: Bug or new Feature? SetGadgetState(,) centers Items on L

Posted: Fri Sep 25, 2015 5:59 pm
by Oma
Hello Bruno,

i think there's a little misunderstanding:
Not the column content is centered. Unlike in previous versions, all changes of the selected item (line) via SetGadgetState(#Gadget, Status) causes a up/down-scrolling (if possible) to try to center the line in the middle of the visible items.
In versions up to 5.40B3 a scrolling only happens if the selected item is outside the visible range.

And by the way:
I think a PeekF(gtk_tree_view_column_get_alignment_(*Column) will always return a 0.0, even with right-aligned column-contents.
Try this:

Code: Select all

ImportC ""
	gtk_tree_view_column_get_alignment.f(*tree_column);  Return type 'float'!
EndImport
;the call...
Debug gtk_tree_view_column_get_alignment(*Column)
Regards, Charly

Re: Bug or new Feature? SetGadgetState(,) centers Items on L

Posted: Sat Oct 10, 2015 8:48 am
by Oma
Hello again.

Sorry that i'm annoying again and bring this issue up once more, but this is really annoying and confusing too (like i am). :?

In PB5.40B9 it's still the same behaviour, that TreeGadget items, selected with SetGadgetState(#Gadget, Status) will be scrolled to the middle position.
The same behaviour you can see in the PureBasic-Help, if you click on a node or entry in the index/tree.

Is that intentional?

Best regards, Charly