Recent

Author Topic: Form inheritance - any chance of supporting in designer  (Read 4268 times)

maxerist

  • New Member
  • *
  • Posts: 28
Form inheritance - any chance of supporting in designer
« on: April 04, 2024, 12:10:16 pm »
Hi,

I'm not sure whether technically LAMW supports form inheritance. I suspect that it might, since the component loading comes directly from RTL (CMIIW). Ok, just remembered that an existing unit with class(TDataModule) inheritance worked on Android so the answer is probably yes so if I place new components in the published part and manually edit lfm file, the LAMW Rtl would accept this. But obviously the designer in laz4android doesn't support editing the inherited form, I just don't see one when pressing F12 on a jForm descendant.

Is this something "too complex to implement"+"noone really needs one" kinda thing? 

Thanks

jmpessoa

  • Hero Member
  • *****
  • Posts: 2305
Re: Form inheritance - any chance of supporting in designer
« Reply #1 on: April 05, 2024, 03:31:47 am »
Quote
I'm not sure whether technically LAMW supports form inheritance...

No, LAMW [out-of-box]  don't support jForm inheritance....

But you can re-use your form (and all your app or some LAMW demo) as  template "theme"....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

maxerist

  • New Member
  • *
  • Posts: 28
Re: Form inheritance - any chance of supporting in designer
« Reply #2 on: April 05, 2024, 12:00:57 pm »
Quote
I'm not sure whether technically LAMW supports form inheritance...
No, LAMW [out-of-box]  don't support jForm inheritance....
But you can re-use your form (and all your app or some LAMW demo) as  template "theme"....

Thanks, is it possible to use jPanels (for instance) as something easily moved between forms. I'll explain. Imagine a template form where there's a complex "frame" consisting of different side panels. But the inside part of this template is empty in order to absorb functionality depending on the context. In modern Delphi and Lazarus I would use form inheritance to make a base form with common "frame" part and make specific inherited instances with different middle parts. Also without inheritance it is also possible in Delphi/Lazarus to design those middle parts as TPanels on another forms and insert them inside this "frame-only" instance. Is something like this possible in LAMW, so to design different jPanels, remove from the jForm instances where they were designed and insert them dynamically to another jForm?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2305
Re: Form inheritance - any chance of supporting in designer
« Reply #3 on: April 06, 2024, 09:46:29 pm »
Quote
Is something like this possible in LAMW...

Yes!

The jForm "ActiityMode"  property -->   actEasel   

(There is some demo about.... I will try find it! )


Edited: I found these...

AppCompatNavigationDrawerDemo1
AppCompatNavigationDrawerDemo2
« Last Edit: April 07, 2024, 12:40:26 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

maxerist

  • New Member
  • *
  • Posts: 28
Re: Form inheritance - any chance of supporting in designer
« Reply #4 on: April 08, 2024, 12:39:49 pm »
Quote
Is something like this possible in LAMW...

Yes!
The jForm "ActiityMode"  property -->   actEasel   

AppCompatNavigationDrawerDemo1
AppCompatNavigationDrawerDemo2

Thanks! I run the first demo, probably understand how it works. The search shows that there are about 12 forms in the  demos with actEasel property so there are plenty to look at to learn.

maxerist

  • New Member
  • *
  • Posts: 28
Re: Form inheritance - any chance of supporting in designer
« Reply #5 on: April 09, 2024, 04:27:47 pm »
Actually, I now see that the feature I was asking for is almost working, but needs some manual corrections

My version of the IDE is laz4android v2.2.2. I suspect that there might be some obstacles for it to work perfectly, but at least what was already supported in Lazarus and fpc rtl works as expected.
  • So currently what I observed is that after using New menu -> New -> inherited project component, I saw a new inherited unit, but designer didnt' respond to F12 (this was reported in my original post).  This was because this action didn't produce the corresponding lfm life. One should do this manually. So, if in your new file unit1.pas you see TForm2 = class(TForm1) then you have to create a unit1.lfm with the text inherited   Form2: TForm2 end
  • you have to get rid of all default uses Lazarus put in this module (Forms, Controls, all lcl related) because with them present there will be crash on start. This is because LCL units like controls.pas, compiled for arm are linked, but have some start up code incompatible with Android
  • After that the designer can edit properties of inherited forms and save it effectively (utilizing inheritance logic when lfm contains only changed properties). I suspect all this comes from the classic Lazarus and FreePascal rtl, that supports this platform-independently

I think that on the LAMW side there's not much that should be done to make the feature works (mostly just allowing creating lfm file for a newly created unit and fix the uses list). But I just suspect that there are not so many fans of form inheritance amongst the LAMW developers :) From my perspective this might be a strong point of LAMW and developing bigger and more complex projects.


 

TinyPortal © 2005-2018