Listview.Visible: inconsistent behaviour

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Listview.Visible: inconsistent behaviour

Post by mrupp »

I noticed an inconsistent behaviour of Listview.Visible:

On Mac (in Dataview mode) & Windows, an entry that is not fully visible is not counted as visible. I would rate this behaviour as correct.
With Mac (in Listbox mode) & MUI, such an entry is counted as visible.

@Andreas: The RapaGUI 2.0 changelog doesn't mention this to be already fixed.

Here are some screenshots to demonstrate this:

Windows x64:
Image

Mac x64:
Image

AmigaOS 4.1 FEu2, MUI 5:
Image

AmigaOS 3.9, MUI 3.9:
Image

And here's the example script to test this out:
Test.hws:

Code: Select all

@REQUIRE "RapaGUI", {Link = True}
@APPTITLE "ListView-Test"
@FILE 1, "TestGUI.xml"

Function p_ListViewSetFirst(id$, pos)
	Local count = moai.Get(id$, "entries")
	Local countVisible = moai.Get(id$, "visible")
	Local maxFirst = count - countVisible
	Local currentFirst = moai.Get(id$, "first")
	Local jumpToPos = pos

	If jumpToPos > maxFirst
		jumpToPos = "bottom"
	ElseIf currentFirst < pos
		jumpToPos = jumpToPos + countVisible - 1
	EndIf

	moai.DoMethod(id$, "jump", jumpToPos)

	Return(moai.Get(id$, "first"))
EndFunction

Function p_EventFunc(msg)
	Switch(msg.ID)
	Case "btnSetFirst1":
		Local first = p_ListViewSetFirst("listview1", ToNumber(moai.Get("ctrlSetFirst1", "text")))
		moai.Set("ctrlTrulyFirst1", "text", first)
		moai.Set("ctrlVisible1", "text", moai.Get("listview1", "visible"))
	Case "btnSetFirst2":
		Local first = p_ListViewSetFirst("listview2", ToNumber(moai.Get("ctrlSetFirst2", "text")))
		moai.Set("ctrlTrulyFirst2", "text", first)
		moai.Set("ctrlVisible2", "text", moai.Get("listview2", "visible"))
	Case "btnSetFirst3":
		Local first = p_ListViewSetFirst("listview3", ToNumber(moai.Get("ctrlSetFirst3", "text")))
		moai.Set("ctrlTrulyFirst3", "text", first)
		moai.Set("ctrlVisible3", "text", moai.Get("listview3", "visible"))
	EndSwitch
EndFunction

moai.CreateApp(ReadString(1))
InstallEventHandler({RapaGUI = p_EventFunc})

For Local i = 0 To 100
	moai.DoMethod("listview1", "insert", "bottom", "Item " .. i)
	moai.DoMethod("listview2", "insert", "bottom", i, "Item " .. i)
	moai.DoMethod("listview3", "insert", "bottom", i, "Item " .. i)
Next

Repeat
	 WaitEvent
Forever
TestGUI.xml:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window id="mainWindow" title="ListView-Test">
		<vgroup>
			<hgroup frame="true" frametitle="Listbox">
				<colgroup columns="2">
					<button id="btnSetFirst1">Set first</button>
					<textentry id="ctrlSetFirst1" accept="0123456789">51</textentry>
					<label align="center">Truly first</label>
					<textentry id="ctrlTrulyFirst1" disabled="true">0</textentry>
					<label align="center">Visible entries</label>
					<textentry id="ctrlVisible1" disabled="true" />
					<rectangle/>
					<rectangle/>
				</colgroup>
				<listview id="listview1">
					<column/>
				</listview>	
			</hgroup>	
			<hgroup frame="true" frametitle="Listview witout Headers">
				<colgroup columns="2">
					<button id="btnSetFirst2">Set first</button>
					<textentry id="ctrlSetFirst2" accept="0123456789">51</textentry>
					<label align="center">Truly first</label>
					<textentry id="ctrlTrulyFirst2" disabled="true">0</textentry>
					<label align="center">Visible entries</label>
					<textentry id="ctrlVisible2" disabled="true" />
					<rectangle/>
					<rectangle/>
				</colgroup>
				<listview id="listview2">
					<column />
					<column />
				</listview>	
			</hgroup>	
			<hgroup frame="true" frametitle="Listview with Headers">
				<colgroup columns="2">
					<button id="btnSetFirst3">Set first</button>
					<textentry id="ctrlSetFirst3" accept="0123456789">51</textentry>
					<label align="center">Truly first</label>
					<textentry id="ctrlTrulyFirst3" disabled="true">0</textentry>
					<label align="center">Visible entries</label>
					<textentry id="ctrlVisible3" disabled="true" />
					<rectangle/>
					<rectangle/>
				</colgroup>
				<listview id="listview3">
					<column title="ID" />
					<column title="Text" />
				</listview>	
			</hgroup>	
		</vgroup>				
	</window>
</application>
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Listview.Visible: inconsistent behaviour

Post by airsoftsoftwair »

Well, this might count as one of those cases where complete consistency would involve going to extreme pains. RapaGUI just reports what MUI and wxWidgets report and apparently the two aren't really consistent here. But of course I don't plan on doing extensive calculations just to get this exactly right.

I think it's somewhat in the nature of using native widgets that there will always be very slight deviations in behaviour. You'll also see that when using controls like the text editing widget, for example. These won't behave exactly the same between all the platforms and it's impossible to make them do so. That's the price you have to pay when using native widgets. The only way around this is to use a toolkit that has its own widgets and just makes them look like native ones. That's what Qt does for example. With Qt everything will be perfectly consistent but the widgets aren't native anymore...
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Re: Listview.Visible: inconsistent behaviour

Post by mrupp »

airsoftsoftwair wrote: Sat Mar 13, 2021 11:33 pm Well, this might count as one of those cases where complete consistency would involve going to extreme pains. RapaGUI just reports what MUI and wxWidgets report and apparently the two aren't really consistent here. But of course I don't plan on doing extensive calculations just to get this exactly right.
Alright, I agree that it's definitely not your job to smooth things like this out. But I would definitely rate it as a wxWidgets bug that the behaviour on macOS itself is inconsistent: a Listview with just one column (Listbox) counts the visible rows differently than with two or more columns (Dataview).

Maybe you could report this to the wxWidgets team?
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Listview.Visible: inconsistent behaviour

Post by airsoftsoftwair »

mrupp wrote: Thu Mar 18, 2021 9:23 pm Maybe you could report this to the wxWidgets team?
I can but they'll very likely tell me to go and fix it myself... at least that's my experience after programming wxWidgets for some 6 years :) Nevertheless, I did fix quite a number of bugs in wxWidgets during RapaGUI development, see here: https://github.com/wxWidgets/wxWidgets/ ... hanges.txt
Post Reply