Recent

Author Topic: Undo for Form Designer working?  (Read 23079 times)

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Undo for Form Designer working?
« on: March 27, 2011, 03:52:46 am »
I have been unable to get the undo to work for changes to my forms.
Is that function available in Lazarus?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Undo for Form Designer working?
« Reply #1 on: March 27, 2011, 04:42:45 am »
There is no undo function for Form Designer. If you delete component from your form you cannot undo it (get the deleted component back).
Undo is for Source Editor only.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Undo for Form Designer working?
« Reply #2 on: March 27, 2011, 03:59:02 pm »
I have been unable to get the undo to work for changes to my forms.
Is that function available in Lazarus?

 http://bugs.freepascal.org/view.php?id=1579

I also missed that feature so much that I started to implement it > a year ago.
First I forwarded the Undo and Redo commands to form designer. It worked but also screwed the whole internal command dispatch system. There are some complex dependencies.
Implementing the designer undo itself is rather difficult, too. The designer is a complicated piece of SW.

If someone dives in and implements this feature, I will give him 10 points in cool-factor scale :-)
It i possible to do of course, it is just difficult.

BTW, even Delphi doesn't have this feature, even after years of similar open feature requests.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Undo for Form Designer working?
« Reply #3 on: March 27, 2011, 04:10:55 pm »
Maybe simplier solution would be a trash for deleted components (the same what is for files in all OS) instead of classic Undo/Redo.
I understand it is very difficult because of grouping components (TGroupBox, TPanel or TPageControl).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: Undo for Form Designer working?
« Reply #4 on: March 27, 2011, 06:32:45 pm »
"trash for deleted components" would solve a large portion of the instances where I've attempted to "undo".

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Undo for Form Designer working?
« Reply #5 on: March 27, 2011, 07:24:32 pm »
Is there this issue on BugTracker? Maybe requesting it should attract some interest.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Undo for Form Designer working?
« Reply #6 on: March 27, 2011, 07:53:08 pm »
Is there this issue on BugTracker? Maybe requesting it should attract some interest.

Yes, see my message above. There is a link.

I believe there is enough interest for this feature but nobody has enough time/energy/knowledge or whatever to implement it. If someone is interested, please look at "designer/designer.pp" + the units in its uses section.

@Blaazen & IPguy: How would "trash for deleted components" work?
So, the deleted components could be restored from the trash? Hey, that actually is called "Undo" feature.
Maybe it is a one-level Undo, and maybe it works only for delete-operation, but still it is Undo.
I don't think implementing this stripped-down Undo feature is much easier than doing it properly.
You must understand much of the form designer and cmd dispatch system anyway.
At the same go you should do it properly, IMO.
Intermediate goals can be set to "one-level-undo" or "undo-for-delete" of course but the design should support a full Undo implementation.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Undo for Form Designer working?
« Reply #7 on: March 27, 2011, 08:26:31 pm »
Which approach did you use? Did you save somehow the whole LFM file at each operation or only the operation itself?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Undo for Form Designer working?
« Reply #8 on: March 27, 2011, 08:39:39 pm »
Quote
How would "trash for deleted components" work?
Similarly to a trash for file in OS (I use KDE4). You can have thousands files in your trash and you can select any file to restore. You don't have to restore files in order 'last-in ~ first out' (trash is not stack). It is difference to classic Undo function.
Another example is bash-history. Pressing up-arrow key you can list between previously used commands.

When you would restore any components from such trash it would be similar to adding a new component. Only differce would be that its properties and events will not be initial.
And next problem - also similar to files. When I try restore file to a directory which is already deleted then I get warning:
'Directory XYZ does not exists. You can restore file to other directory.'

The same would be when you have Button on Panel. You delete Button, you delete Panel and then you try restore Button.

Finally I think undo for components is not a 'must have' function, at least for me.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Undo for Form Designer working?
« Reply #9 on: March 27, 2011, 08:43:29 pm »
Which approach did you use? Did you save somehow the whole LFM file at each operation or only the operation itself?

I really didn't get so far. I still don't understand enough of the designer code to make such decision.
I THOUGHT I understood enough of the command passing code but then other parts of the IDE behaved strangely.
The cmd forward patch is still in bug tracker. Mattias committed it but it had to be reverted quickly.

Anyway, this task is something that takes time and effort unless you know the designer code well already (... and maybe 1 or 2 people know it well).
Learn code, try something, learn more, try more... and so on...

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Undo for Form Designer working?
« Reply #10 on: March 27, 2011, 09:09:55 pm »
The same would be when you have Button on Panel. You delete Button, you delete Panel and then you try restore Button.

Yes, that makes the task more difficult, not easier.
Good ideas still.

Quote
Finally I think undo for components is not a 'must have' function, at least for me.

I would like the feature very much. It would make a big difference when you accidentally delete a container component with other comps inside, or you experiment with the layout and want to revert it.

Anyway, someone just have to make the effort and implement it.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Undo for Form Designer working?
« Reply #11 on: March 27, 2011, 09:27:53 pm »
Maybe the task can be divided in two parts:

1) Writing the code itself
2) Inserting it on the Form Designer (made by someone who knows the IDE code)

And then the second subtask could be requested on BugTracker.
« Last Edit: March 27, 2011, 09:45:03 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Undo for Form Designer working?
« Reply #12 on: March 27, 2011, 10:26:59 pm »
I have added a note on the BugTracker's issue.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4474
  • I like bugs.
Re: Undo for Form Designer working?
« Reply #13 on: March 27, 2011, 11:31:17 pm »
Maybe the task can be divided in two parts:
1) Writing the code itself
2) Inserting it on the Form Designer (made by someone who knows the IDE code)

To me that sounds very unrealistic, sorry.
The difficult part is exactly to figure out how to interact with the complex designer code, and the cmd dispatch code.
It is not like you write an independent Undo program without looking at designer code, and then someone else "inserts" it to Lazarus.

Or, maybe I misundertood the idea, don't know...

In practice, somebody must jump in the code back and forth, Ctrl-Click and Ctrl-H, and debug it, again and again so its logic and structure opens. And then based on that knowledge implement Undo.

... this brings me to another issue: Class- and other UML-diagrams, or lack of them. There is no documentation of the code internals. Sure, the programmer always must read the code to understand details but the big picture could be more easily understood from a good diagram. Another task for somebody...

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Undo for Form Designer working?
« Reply #14 on: March 27, 2011, 11:43:50 pm »
Quote
The difficult part is exactly to figure out how to interact with the complex designer code, and the cmd dispatch code.
It is not like you write an independent Undo program without looking at designer code, and then someone else "inserts" it to Lazarus.

If you want to restore each operation, of course you need to know how exactly is that operation in order to reverse it. But you could restore the whole previous state of the form instead of reversing each operation. And then you don't need to know what exactly was done. So, the code would be the same for any operation and could be "inserted" or whatever.
« Last Edit: March 28, 2011, 12:22:10 am by typo »

 

TinyPortal © 2005-2018