Lazarus

Programming => Widgetset => Cocoa => Topic started by: MISV on August 17, 2018, 01:32:32 am

Title: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 17, 2018, 01:32:32 am
I submitted this bug report (https://bugs.freepascal.org/view.php?id=34002) including a demo app that shows that an app with a virtualtreeview has the following issues:

1) toolbuttons becoming invisible until clicked (just click on the top toolbar to expose them)
2) TPageControl tabsheets misdrawn until clicked
3) TEdit looking very weird with black background until clicked
4) some captions/labels etc. are drawn upside down some places

To see all issues simply
- run project
- doubleclick window title bar (minimizes to dock)
- open from mac dock.

...

Dimitry was kind enough to write back it was a clipping problem in Cocoa implementation.

...

i understand clipping stuff is probably complicated... But my problem is I need a virtual treeview control since I may have up to a million items with 50 data columns... But still.. Is thee any LCL control I may be able to use instead of virtual treeview?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: Bart on August 17, 2018, 12:14:10 pm
Most likely not, given that you have millions of items ....

Bart
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: wp on August 17, 2018, 12:20:27 pm
But my problem is I need a virtual treeview control since I may have up to a million items with 50 data columns...
Are you sure that your users will ever look at 50 millions of pieces of data and not give up after the first ten rows? Isn't there a more clever way of showing them the data that they need?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 17, 2018, 01:08:11 pm
Well, if they crawl a website with a million pages... they will want to be able to filter data but also dive through the directory structure as they please. (And enable whatever data columns they want)

Virtual Treeview is great in that regard since it is quite fast and quite memory friendly. It is a beautiful control for heavy duty stuff. (But yes, usually websites will have less pages.)



Posting this for myself to remind me of this option: http://wiki.lazarus.freepascal.org/Bounties#Cocoa_bounties (http://wiki.lazarus.freepascal.org/Bounties#Cocoa_bounties)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on August 17, 2018, 11:16:05 pm
There's an alternative to alternative of VirtualTreeView.

Instead of searching for something else, you could attempt to create a simple test case that demonstrated the problem.

It's potentially a simple task.
Implement some easy drawing using cliprect and see how it looks in any other widgetset (Win or Linux)
then run in on Cocoa.
If results are different (or worse, messing up drawing entirely), the project could be used to resolve the issue.
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 18, 2018, 05:50:43 pm
I did create a demo project demonstrating the problem if virtual treeview control was placed on a form.

However, I will consider seeing if I can create a demo project using cliprect directly! (Never had to touch that part of LCL before)

(Thank you for all the Cocoa fixes)


Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 20, 2018, 01:05:32 pm
If simple cliprect examples fail to reproduce:

I am wondering if perhaps a good approach would be to test other components using cliprect. If they fail, maybe report to the author of the component. They have inrinsic knowledge of their code which will help them figure out what is wrong.

If people have suggestions for components to test on Cocoa (ideally available in OPM or FPCUpDeluxe) let me know

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 20, 2018, 11:36:32 pm
I found various sprite/clipping/drawing demos here:
https://forum.lazarus.freepascal.org/index.php?topic=36871.0 (https://forum.lazarus.freepascal.org/index.php?topic=36871.0)

...

One can download a relative simple demo here
https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246309.html#msg246309 (https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246309.html#msg246309)
called SpriteTest2.Zip and it uses copyrect, mask, union
It works on both Lazarus/Windows and Lazarus/Cocoa so I did not manage to reproduce error using this

...

Nextup was to test Mr.Madguy code listed here which uses intersect, fillrect, cliprect
https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246790.html#msg246790 (https://forum.lazarus.freepascal.org/index.php/topic,36871.msg246790.html#msg246790)
It works on both Lazarus/Windows and Lazarus/Cocoa so I did not manage to reproduce error using this

...


Should anyone else have better ideas for testing/reproducing, I am crossing fingers you will manage at reproducing the problem! :)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 21, 2018, 06:16:25 pm
There's an alternative to alternative of VirtualTreeView.

Instead of searching for something else, you could attempt to create a simple test case that demonstrated the problem.

It's potentially a simple task.
Implement some easy drawing using cliprect and see how it looks in any other widgetset (Win or Linux)
then run in on Cocoa.
If results are different (or worse, messing up drawing entirely), the project could be used to resolve the issue.

Unfortunately the problem has been hard to reproduce - even with non-trivial examples. (See other posts)

If you have more ideas, please let me know!


Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on August 22, 2018, 03:06:52 pm
If you have more ideas, please let me know!
Well, sure.
You might want to show these simple samples to the authors of TVirtualTree,
and ask them what TVirtualTreeView is doing different then than those tests?

You could also ask them how to modify those simple tests to how TVirtualTreeView is actually drawing its contents.

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 23, 2018, 01:59:55 pm
Almost ahead of you:
https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8 (https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8)
But I will try ask explicitly instead of just listing that I have tried duplicate the issue using other demos.

Currently I am looking into the VConfig.inc that can alter defines

1) I can not comment USE_DELPHICOMPAT define out since virtualreeview wont compile then. (So that suggestion won't fly it seems) - I think USE_DELPHICOMPAT is what uses the lcl_extensions unit albeit not sure. In the link above, you can see the lazarus-port/maintainer recommend commenting the define out

2) However, I can comment EnableAdvancedGraphics define out... That does not seems to make any difference (todo repeat test)

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 24, 2018, 09:05:43 pm
I think this is a Lazarus/LCL issue and not virtualtreeview-new/5.x port

The reason is is that if you look here: https://github.com/blikblum/luipack/tree/master/lclextensions/include there is no Cocoa version (but there is e.g. a Carbon version) - 4 important units

However, the virtual-treeview that ships with Lazarus/trunk *has* those carbon units translated to Cocoa code placed in a Cocoa folder.

So someone added those things for Lazarus but never merged back into the website for Lazarus virtual treeview port.

That problem also relates to this issue: https://bugs.freepascal.org/view.php?id=33973 (https://bugs.freepascal.org/view.php?id=33973)

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 26, 2018, 02:00:27 pm
For what it is worth :

There is a new virtual treeview version out
https://github.com/blikblum/VirtualTreeView-Lazarus/tree/lazarus-v5
which allows to complile with USE_DELPHICOMPAT define commented out

The clipping problem remains unsolved though, but it means VT can be compiled without lcl-extensions.
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 27, 2018, 04:15:50 pm
Virtual Treeview Lazarus port maintainer has come up with multiple good test cases - next time I get lazarus/cocoa/64bit trunk working (I have a weird issue rendering my IDE unusuable) I will try those (but since trunk is not working for me, anyone else please feel free to chip in)

1)
In the past this was fixed for Carbon LCL related to virtual treeview
https://bugs.freepascal.org/view.php?id=28689 (https://bugs.freepascal.org/view.php?id=28689) / http://bugs.freepascal.org/view.php?id=25564 (http://bugs.freepascal.org/view.php?id=25564) (latter contains demo)
He suggests trying the attached demo on the Cocoa LCL implementation.

Bug? Lazarus/Cocoa: Seems seems to yield different results than other platforms with the BitBlt/SetWindowOrgEx demo



2)
He suggest trying this ExcludeClipRect demo:
https://bitbucket.org/blikblum/pascal-demos/src/16fc10cb12ed7a9fb1c4793bd592efb8ca198a9f/lazarus/LCLTests/ExcludeClipRect/?at=master (https://bitbucket.org/blikblum/pascal-demos/src/16fc10cb12ed7a9fb1c4793bd592efb8ca198a9f/lazarus/LCLTests/ExcludeClipRect/?at=master)

Bug? Lazarus/Cocoa: Seems ExcludeClipRect is ignored


See also
https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8 (https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 28, 2018, 12:05:05 am
Bump - believe above post includes two examples of where Lazarus/Cocoa misbehaves
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: LuizAmérico on August 28, 2018, 12:20:10 am
I suggest reporting the bugs in the bugtracker
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 28, 2018, 09:31:10 am
I originally reported this - and O have already updated it :)
https://bugs.freepascal.org/view.php?id=34002 (https://bugs.freepascal.org/view.php?id=34002)

@LuizAmérico
Now we are at it - beyond those two demos provided by you - do you think here are more things worth testing? Because if there is a 3rd issue / demo somewhere, I will be happy to test it out :)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 29, 2018, 11:43:13 am
@skalogryz
Would you prefer two new separate bug reports? One for each example? And then possibly checking if that combination then solves the original bug report?

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on August 29, 2018, 02:55:45 pm
divide and conquer
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 29, 2018, 03:14:11 pm
Bug report for ExcludeClipRect
https://bugs.freepascal.org/view.php?id=34196 (https://bugs.freepascal.org/view.php?id=34196)

@LuizAmérico
I linked the demo provided since by you - I can download/attach if ok with you?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 29, 2018, 03:21:03 pm
Bug report for BBitBlt/SetWindowOrgEx
https://bugs.freepascal.org/view.php?id=34197 (https://bugs.freepascal.org/view.php?id=34197)

@LuizAmérico
I linked to the demo found in the original Carbon bug report - I can download/attach if ok with you for the new Cocoa bug report?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on August 29, 2018, 03:22:29 pm
divide and conquer

Done :)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 01, 2018, 12:15:12 am
Just to show the full problem of Cocoa/clipping/graphics/virtual-treeview/whatever-the-cause

how it should look
vtv-set-to-invisible--no-vtv-tab.png

problem manifested
vtv-set-to-visible--visible-vtv-tab--just-resized-form.png
vtv-set-to-visible--visible-vtv-tab--just-resized-form--2--hover-over-button.png
vtv--inside-ide-reversed-text-and-icons.png
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 01, 2018, 09:52:19 am
Here is much better demo attached.

After a continued amount of testing in this discussion thread: https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8

It seems fixing the two reported issues will have a very high chance of solving all the issues. (Repeated tests seem to narrow down the problems to these.)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 05, 2018, 01:47:07 pm
For the bug report
https://bugs.freepascal.org/view.php?id=34196 (https://bugs.freepascal.org/view.php?id=34196)
ExcludeClipRect

-- Possible explanation pinpointed by Lazarus virtual treeview maintainer - https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8 [^] --

Quote
There's a possible bug in TCocoaRegion.CombineWith when handling cc_DIFF (used by ExcludeClipRect)

If FShape is empty, a big one is created and stored in Shape var to be used in HIShapeCreateDifference, but Shape var is not used. The empty shape is used instead

Code: Pascal  [Select][+][-]
  1. cc_DIFF:
  2.       begin
  3.         if HIShapeIsEmpty(FShape) then
  4.           {HIShapeCreateDifference doesn't work properly if original shape is empty}
  5.           {to simulate "emptieness" very big shape is created }
  6.           Shape := HIShapeCreateWithRect(GetCGRect(MinCoord, MinCoord, MaxSize, MaxSize)); // create clip nothing.
  7.  
  8.         Shape := HIShapeCreateDifference(FShape, ARegion.Shape);
  9.         Result := GetType;
  10.       end;  
  11.  

However, that said, the attempted solution underneath here did not seem to be enough - not on its own at least:

Code: Pascal  [Select][+][-]
  1. cc_DIFF:
  2.       begin
  3.         if HIShapeIsEmpty(FShape) then
  4.           begin
  5.             {HIShapeCreateDifference doesn't work properly if original shape is empty}
  6.             {to simulate "emptieness" very big shape is created }
  7.             Shape := HIShapeCreateWithRect(GetCGRect(MinCoord, MinCoord, MaxSize, MaxSize)); // create clip nothing.
  8.             Shape := HIShapeCreateDifference(Shape, ARegion.Shape);
  9.           end
  10.         else
  11.           begin
  12.             Shape := HIShapeCreateDifference(FShape, ARegion.Shape);
  13.           end
  14.         ;
  15.         Result := GetType;
  16.       end;  
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on September 05, 2018, 02:37:05 pm
HIShape, huh?
check out the third line on cocoagdiobjects.pas
Code: Pascal  [Select][+][-]
  1. //todo: Remove HIShape usage used in TCocoaRegion.

I'm surprised this code still works (to some extent)
I wonder for how long Apple is going to drag the legacy compatibility code.
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 07, 2018, 10:37:01 pm
I see the two bug reports are reported as solved- I will get back sunday/monday and check everything out in-depth. Great news if the problems are solved now :)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 11, 2018, 02:38:59 pm
Testing against toggle-vtv-visible-then-reisze.zip in the parent bug report https://bugs.freepascal.org/view.php?id=34002#bugnotes shows the primary issue remain unsolved :(

...

I can see the demo app for the ExcludeClipRect child bug report https://bugs.freepascal.org/view.php?id=34196 [^] appears to be solved now though....

...

However, the reason I do not believe ExcludeClipRect is fixed yet is:

The toggle-vtv-visible-then-reisze.zip demo will work if ExcludeClipRect is replaced by a complete dummy function (!)

The Lazarus maintainter of virtual reeview for Lazarus applied the "dummy exclupdecliprect" fix for testing:
https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8#issuecomment-418730214 [^]

...

The  SetWindowOrgEx issue appear fixed in the demo app provided in the child bug report: https://bugs.freepascal.org/view.php?id=34197
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on September 11, 2018, 03:28:57 pm
The toggle-vtv-visible-then-reisze.zip demo will work if ExcludeClipRect is replaced by a complete dummy function (!)

The Lazarus maintainter of virtual reeview for Lazarus applied the "dummy exclupdecliprect" fix for testing:
https://github.com/blikblum/VirtualTreeView-Lazarus/issues/8#issuecomment-418730214 [^]
how does vtv test look with the dummy function vs the latest trunk?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 11, 2018, 07:41:31 pm
The toggle-vtv-visible-then-reisze.zip demo:

- Lazaus trunk: Looks the same like earlier. Toolbuttons still go invisible when form is maximized maximized, Edit control looks weird etc.
- Dummy excludecliprect: Everything appears to work fine.

(If you test yourself, remember to click the button which toggles virtual treeview visiblity before maximizing)

Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on September 11, 2018, 09:10:29 pm
A picture is worth a thousand words
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 11, 2018, 10:09:26 pm
Will try do today or tomorrow! (But will look 99% same as earlier posted showing he toolbar problem - only reason slightly different is I simplified the demo further after posting screenshots last time in this forum thread.)
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: skalogryz on September 11, 2018, 10:34:51 pm
I'm asking, because the trunk is now producing for me the same result as was shown on "vtv-set-to-invisible--no-vtv-tab.png".

In the past there were issues with "fpcupdeluxe" not pulling the latest version -and-or- produced different results that just "svn update". So I want to exclude this case in particular.
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: MISV on September 29, 2018, 11:40:35 pm
For what it is worth I still have various problems with the virtual treeview control. With/without using the recent fixes in virtualtreeview / cocoa

But on a happy note I think many improvements have been made, but it is just not 100% yet - at least for me. But since it seems not many Cocoa users are using virtual treeview then maybe other issues should take priority.



-- I almost have workarounds for all remaining issues (not code fixes, just work arounds) I am experiencing so if anyone has vtv problems - just post here and ask



Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: Wallaby on March 08, 2019, 03:05:44 pm
Sorry for bringing up the old thread - I am trying to use a VTV on Cocoa and facing the same issue.

Using Lazarus/Cocoa built by fpcupdeluxe from FPC fixes_3_2 and Lazarus fixes 2_0. Then adding the VTV package (virtualtreeview, not virtualtreeviewonline).

In my test app on Cocoa the same thing happens: toolbar buttons disappear until clicked, some edits get clipped or misplaced, etc.

I wonder if it was solved or there is a workaround for now?
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: Wallaby on March 09, 2019, 12:49:26 pm
Answer myself:

There is a fixed/worked-around version on Github (https://github.com/blikblum/VirtualTreeView-Lazarus).

When using FpcupDeluxe, install the virtualtreeviewnew package, but before that change in FPC.INI the branch to pull the code from. The default is lazarus-master, but the latest fixes are in lazarus-v5.
Title: Re: Alternative to VirtualTreeView in Cocoa which does not mess up other controls?
Post by: apeoperaio on March 10, 2019, 06:13:39 pm
I am starting using VTV on cocoa. But I have some issues, mostly related to how text is drawn on virtualstringtree.
The text is not drawn well as for the other components but it is quite blurry.
See attached image of the online package manager.
Anyone faced the same problem?
TinyPortal © 2005-2018