Recent

Author Topic: Cocoa - content mirrored or upside down  (Read 3607 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Cocoa - content mirrored or upside down
« on: January 27, 2021, 06:20:12 am »
I have seen a few references to a problem like this but none so bad as mine (everyone thinks they are worse off ...)

Using FPC3.2.0, Lazarus Trunk (yesterdays and a month old one), Mac Sierra. 10.12

Yesterday, doing some normal pre-release testing of my app, this time on the Sierra box, one of my forms is partially mirrored, content that should be near the bottom, appears at the top. And flipped upside down and left to right. A real mess. Its like that in the designer and at run time, in design mode, I click down where I know a component should be to select it up where it is !  I see text displayed in the flipped components that belong in another component !

I had recently upgraded to FPC320 and suspected the Lazarus rebuild, but even going back to Laz 2.0.10 has a similar problem, but only at run time. I even went back to FPC304 but problem remained.

This form displays fine on  GTK2, Qt5, Windows and even Carbon but in Cocoa, its terrible.

I believe it may relate to having a couple of panels, one above the other, anchored together, so by setting height to '1', they appear to disappear.

I can duplicate the problem, or something close to it (??!) in a simple one form app but I need to drop a KMemo (from Kcontrols) on the form.  I have not posted that demo as few people will have KControls installed. Its an easy install from Online Package Manager (thank GetMem!) if anyone is interested.

I have seen a few other posts from people, all working with MacOS, with things being upside down, mirrored etc. Anyone have any ideas about this particular ugly problem ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Cocoa - content mirrored or upside down
« Reply #1 on: January 27, 2021, 10:12:31 pm »
This reminds me of a very similar issue that Lazarus and some programs written with Lazarus have with Reactos.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Cocoa - content mirrored or upside down
« Reply #2 on: January 27, 2021, 10:41:15 pm »
Similar issue here: https://forum.lazarus.freepascal.org/index.php/topic,41623.0.html

I also encountered it in Lazarus 2.0.6 when using the lhelp recently  - the table of contents window had the entries at the bottom and they were upside down until clicked on, after which they went to the top and the right way up. Tested OK in 2.0.10 and trunk.

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Cocoa - content mirrored or upside down
« Reply #3 on: January 28, 2021, 12:59:29 am »
I had a similar issue.
I found that using a speedbutton on my form was causing that.  The flip (or fold) happened exactly where the speedbutton was placed.
I removed that speedbutton and the problem went away.
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa - content mirrored or upside down
« Reply #4 on: January 28, 2021, 08:47:44 am »
Yes, interesting.  I cannot replicate it with Speedbuttons, I think it involves the 'right' interaction, probably via anchors, between particular components.  It must be easier on average to avoid than to demonstrate but its obvious affecting a wide range of components.

Would there be any point in me putting together a minimalist project to demo it ?  If, as I suspect, it has to use KMemo ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

AL

  • Sr. Member
  • ****
  • Posts: 261
Re: Cocoa - content mirrored or upside down
« Reply #5 on: January 28, 2021, 06:59:21 pm »
I also was not able to replicate in a new project. But removing that speedbutton surely solved my problem
Probably  it involve like you said, anchors or a combination of some other positionning parameters.   
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Cocoa - content mirrored or upside down
« Reply #6 on: January 31, 2021, 07:03:18 am »
Anyone have any ideas about this particular ugly problem ?
it has been haunting CocoaWS from the start.
I do believe that it is related to the fact LCL mirrors the cocoa drawing context to save on recalculations for each drawing call.

I've just committed r64451, which should cleanup drawing state to keep things clean.
The patch was introduced for a different issue, but could help with the problem you're experiencing.

If you've an easy way to replicate the problem, please test the latest trunk.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa - content mirrored or upside down
« Reply #7 on: February 01, 2021, 10:08:29 am »
 skalogryz, thanks for jumping in, a great relief.

I will most certainly test but right now, I am flat out getting an app ready before the Debian Bullseye freeze in a few days.  So, hope you don't mind, I will most certainly test your update as soon as I can. A few days is absolutely no indication I am not interested !

Thanks, Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa - content mirrored or upside down
« Reply #8 on: February 06, 2021, 11:25:56 am »
skalogryz, sorry for the delay, utf8 issues elsewhere !

Anyway, I just updated the Lazarus Trunk on my Mac, its using FPC320, and I am afraid the problem is still there.  In my case, very repeatable if I have a KMemo on a form.

So, I tried poking around, I have been using KMemo on the Mac for some time now, not seen this problem before so assumed it has to be triggered by something (other than just adding a KMemo to the form).  The one thing that seems to affect it is the Z-Order. 

Now, no definition of just what Z-Order is can be found (by me) but seems to relate to the order controls are created in time ?  Sure you know.... 

If I can help any way to clarify this, please let me know.

Incidentally, KMemo is an easy Online Package Manager install. :-)

Davo


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Cocoa - content mirrored or upside down
« Reply #9 on: March 29, 2021, 11:32:08 pm »
Opening the "Online Package Manager" on a Mac shows a bug that is probably related.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Cocoa - content mirrored or upside down
« Reply #10 on: March 30, 2021, 01:58:25 am »
Apart from the unreadable black header line, I don't see any issue? (Lazarus trunk)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Cocoa - content mirrored or upside down
« Reply #11 on: March 30, 2021, 03:06:42 pm »
Apart from the unreadable black header line, I don't see any issue? (Lazarus trunk)

Thanks, it has probably been fixed in trunk. All the toolbar buttons were upside down.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Cocoa - content mirrored or upside down
« Reply #12 on: April 07, 2021, 07:03:12 am »
Apart from the unreadable black header line, I don't see any issue? (Lazarus trunk)
fixed now in Lazarus trunk

Incidentally, KMemo is an easy Online Package Manager install. :-)
I've just tried to install KControls and created a simple project. A blank form with KMemo on it.
works fine! (no upside down effect).
Is there a sample project?
« Last Edit: April 07, 2021, 07:17:56 am by skalogryz »

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa - content mirrored or upside down
« Reply #13 on: April 07, 2021, 07:50:16 am »
From memory, you need a couple of buttons on the form, now you have KControls, I'll see if I can make a reliable demo project.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Cocoa - content mirrored or upside down
« Reply #14 on: April 07, 2021, 09:40:48 am »
OK, made a small test app and run it with my 'old' Lazarus Trunk, screen shots below.  Then updated to new version of Trunk, problem is still there I am afraid. 

Design.png, taken at design time, shows Edit1 selected but the 'handles' are no where near Edit1, they are above it, down from the top by the distance the control is up from the bottom.

RunTime.png shows the app at run time, I have clicked in the Edit1 control but its highlighting again shows up near the top of the app.

Also attached, the very basic project I just used.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018