Recent

Author Topic: Dimm Form Crossplatform  (Read 5398 times)

tetrastes

  • Hero Member
  • *****
  • Posts: 640
Re: Dimm Form Crossplatform
« Reply #15 on: May 13, 2024, 01:21:58 pm »
There is software/window manager that is able to apply such fx with gtk2. But as mentioned in the linked discussion: is it worth the effort to implement for gtk2.

It's no more effort than on windows. Enable alphablending and use compositing WM (which is by default on most modern DEs, except may be Mate, where you have to enable Compton by hands):
https://forum.lazarus.freepascal.org/index.php/topic,52056.msg382970.html#msg382970
« Last Edit: May 13, 2024, 01:25:12 pm by tetrastes »

TRon

  • Hero Member
  • *****
  • Posts: 4292
Re: Dimm Form Crossplatform
« Reply #16 on: May 13, 2024, 01:26:51 pm »
Thank you for that link tetrastes. That might also explain as I am using mate....
Today is tomorrow's yesterday.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #17 on: May 13, 2024, 02:28:59 pm »
Shot2 is when pressing the button, showing another form exactly as the original form (but at another location) then moving the initial form from it's original location to reveal the dimmed form.
Okay, I have thought about possible reasons for missing caption and came to conclusion that on Linux the Titlebar is not part of a TForms canvas.
I will need to screenshot complete Desktop and cutout the needed reactangle or see if I can direct snap a rectangle (I assume with BGRA all yes ^_^).
For the rounded corners its a win-win since "wysiwyg"  :P
Also "BringToFront" will be added.
Give me a time to prepare something that I have never done crossplatform, all be good.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

TRon

  • Hero Member
  • *****
  • Posts: 4292
Re: Dimm Form Crossplatform
« Reply #18 on: May 13, 2024, 02:33:06 pm »
Give me a time to prepare something that I have never done crossplatform, all be good.
For me no need to hurry... I have a very busy day scheduled so might not even be able to make it today.... ofc there are others as well  :)
Today is tomorrow's yesterday.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #19 on: May 13, 2024, 03:21:09 pm »
Updated project attached.

Please make me happy and say it works, jk, be honest with me thats all I need :D

here is the relevant screenshot part:
Code: Pascal  [Select][+][-]
  1.     LDesktop := TBitmap.Create;
  2.     try
  3.       LDesktop.PixelFormat := pf24bit;
  4.       LDesktop.Canvas.CopyMode := cmSrcCopy;
  5.       LMon := Screen.Monitors[Screen.MonitorFromWindow(AForm.Handle, mdNearest).MonitorNum].BoundsRect;
  6.       LDesktop.SetSize(LMon.Width, LMon.Height);
  7.       LDC := GetDC(0);
  8.       try
  9.         if not BitBlt(LDesktop.Canvas.Handle,
  10.                       LMon.Left, LMon.Top, LMon.Width, LMon.Height,
  11.                       LDC, 0, 0, SRCCOPY) then
  12.           raise Exception.Create('TkzDimmedForm - Error, BitBlt failed to capture screenshot!');
  13.       finally
  14.         ReleaseDC(0, LDC);
  15.       end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paweld

  • Hero Member
  • *****
  • Posts: 1354
Re: Dimm Form Crossplatform
« Reply #20 on: May 13, 2024, 03:48:14 pm »
tested on debian
Best regards / Pozdrawiam
paweld

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #21 on: May 13, 2024, 03:58:31 pm »
tested on debian
Ouch ;.-/
Could you please "{$Define Debug}" and in code change the message to?
Code: Pascal  [Select][+][-]
  1.   {$If Defined(Debug)}
  2.   ShowMessage(Format('Top: %d Left: %d Width: %d Height: %d' + sLineBreak +
  3.                      'Top: %d Left: %d Width: %d Height: %d' + sLineBreak +
  4.                      'Top: %d Left: %d Width: %d Height: %d' ,
  5.                      [FDimmedForm.Top, FDimmedForm.Left, FDimmedForm.Width, FDimmedForm.Height,
  6.                      AForm.Top, AForm.Left, AForm.Width, AForm.Height,
  7.                      LMon.Top, LMon.Left, LMon.Width, LMon.Height]));
  8.   {$IfEnd}
It is hard to reproduce for me, maby the numbers can help to get info if the basics are wrong.

Thank you for testing!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paweld

  • Hero Member
  • *****
  • Posts: 1354
« Last Edit: May 13, 2024, 04:21:08 pm by paweld »
Best regards / Pozdrawiam
paweld

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #23 on: May 13, 2024, 07:51:12 pm »
https://files.brudnopis.ovh/file/mSAul85XKT1iJ8bf/EUjsquoKgixbMGhB/debian-screen0.webm
and previous version: https://files.brudnopis.ovh/file/QtJbPT421F7IVxAR/D4iXOPe1RLbrww5c/debian-screen0.webm
Thank you very much for your hard work and try to helping me, I rechecked and rechecked and rechecked, beside the ScanLine "platform specific" I can't find anything non-crosscompileable.
But earlier it worked at least when I try to grab the AForm.Canvas.

I guess my luck with "write once compile anywhere" aint that good :D

@Paweld, since the third line is missing from the debug, could you tell me please if the monitor dimensions are correct?
A try to comment out "DimmBitmap(LFormImage, AAlphaBlendValue);" would also be very appreciated, there I do use ScanLine, if thats the fault of a black image (when monitor dimensions are good)
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

tetrastes

  • Hero Member
  • *****
  • Posts: 640
Re: Dimm Form Crossplatform
« Reply #24 on: May 14, 2024, 12:02:07 am »
I guess my luck with "write once compile anywhere" aint that good :D

Why? Your code is compiled. Nobody promised, that behavour will be the same on all systems. Moreover, on linux it depends on numerous DEs and WMs, including the behaviour of modal forms and their parent forms. F.e., parent forms can be resized and moved (see picture).

A try to comment out "DimmBitmap(LFormImage, AAlphaBlendValue);" would also be very appreciated, there I do use ScanLine, if thats the fault of a black image (when monitor dimensions are good)
 
This commenting changes nothing, but this helps:
Code: Pascal  [Select][+][-]
  1.   ...
  2.   FDimmedForm.BorderStyle := bsNone;
  3.  
  4.   FDimmedForm.AlphaBlend := true;          // !
  5.   FDimmedForm.AlphaBlendValue := 127;      // !
  6.  
  7.   FDimmedForm.Top := FormTop(AForm);
  8.   ...
  9.  


This is how it looks at Xfce 4.12 (Debian 10):
« Last Edit: May 14, 2024, 12:39:29 am by tetrastes »

tetrastes

  • Hero Member
  • *****
  • Posts: 640
Re: Dimm Form Crossplatform
« Reply #25 on: May 14, 2024, 12:35:17 am »
And this is the same gtk2 app at KDE. Note that modal forms can be under your dimmed forms, contrary to that at Xfce, and parent forms are already dimmed by WM, making your dimmed forms needless.
Welcome to the freedom of choice world!  :D
« Last Edit: May 14, 2024, 12:52:41 am by tetrastes »

Handoko

  • Hero Member
  • *****
  • Posts: 5399
  • My goal: build my own game engine using Lazarus
Re: Dimm Form Crossplatform
« Reply #26 on: May 14, 2024, 08:18:16 am »
I guess my luck with "write once compile anywhere" aint that good :D

You misunderstand what that slogan means. It only says the same code can be compiled anywhere but not promising they will run or behave similarly.  :P

If you really want to make your code cross platform, you need to test it on many widgetsets:
https://wiki.freepascal.org/Widgetset

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #27 on: May 14, 2024, 09:18:11 am »
If you really want to make your code cross platform, you need to test it on many widgetsets
I did installed my Lazarus with FP(UP)Deluxe using Windows as host. Unsure if I can install other Widgetset to test my doing but the problem beside different widget behaviour is also Linux itself.
By watching the chaos above, on one Linux Modal has no effect on others Windows are mini greyed by default, on others my screenshot lead to black on others setting the location is somehow prohibited etc etc etc....
I guess to develop something for Linux, equal how simple the task is, includes massive checkings that I am currently not aware off.

Thank you all for showing results on Linux!
« Last Edit: May 14, 2024, 09:25:53 am by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Dimm Form Crossplatform
« Reply #28 on: May 14, 2024, 09:30:53 am »
This commenting changes nothing, but this helps:
Code: Pascal  [Select][+][-]
  1.   FDimmedForm.AlphaBlend := true;          // !
  2.   FDimmedForm.AlphaBlendValue := 127;      // !
That was my first variant where I did do nothing else than LCL stuff but I was than correctly told that "AlphaBlend" is a widgetfeature that is not available unified on Linux.
I have opened a thread in Linux section about exactly that thing, a method that return me True/False if "AlphaBlend" can be used.
Sad, no answers yet.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paweld

  • Hero Member
  • *****
  • Posts: 1354
Re: Dimm Form Crossplatform
« Reply #29 on: May 14, 2024, 12:00:06 pm »
Quote from: KodeZwerg
@Paweld, since the third line is missing from the debug, could you tell me please if the monitor dimensions are correct?
A try to comment out "DimmBitmap(LFormImage, AAlphaBlendValue);" would also be very appreciated, there I do use ScanLine, if thats the fault of a black image (when monitor dimensions are good)
Hi,
yes the message shows the correct monitor resolution (in my case 1920x977), and commenting out the line you indicated does not change anything in the behavior of the program.
Best regards / Pozdrawiam
paweld

 

TinyPortal © 2005-2018