Is there a way to lock the layout of the form? lazarus / 9-Editor ---------------------------------------------------------------------- bd4kc · 2020-12-13 17:40 I may not be the first to ask such a question. Sometimes, I carefully adjust a lot of label and edit layout, carefully align them, but sometimes mistakes, the mouse inadvertently click, it is a mess. Hope there is a switch, open on editing, turn off will not allow editing, it seems that any previous development tools have had this function, can not remember. ---------------------------------------------------------------------- Handoko · 2020-12-13 17:55 If you use Windows you can try: use Windows Explorer to browse to the location > right click on the *.lfm file > Properties > enable the Read-only checkbox. Not a good solution, but it may work. ---------------------------------------------------------------------- FTurtle · 2020-12-13 18:31 Looks like you use anchors like in Delphi. Lazarus has excellent anchor system and Delphi's anchor system is very little subset of it. Use Anchor Editor. Read: http://wiki.freepascal.org/Autosize_/_Layout http://wiki.freepascal.org/Anchor_Sides In this case you will not able accidentally move something by mouse. Since you use Lazarus it is a good idea forget about "aligning something by mouse" forever. ---------------------------------------------------------------------- MarkMLl · 2020-12-13 19:04 I /thought/ that there was something in the IDE to do it, possibly a right-click operation, but it didn't persist across sessions and is tricky to find. Of course, I can't find it :-) MarkMLl ---------------------------------------------------------------------- bd4kc · 2020-12-13 19:23 Is there such a function: similar to word, multi-select, combination, so that a group of components are grouped together, can be moved at the same time. How much my extra unreasonable request is!  The reason for the above requirements is that I found that the new version of lazarus HDPI does a very good job, if I avoid using some small number of less compatible controls, directly arrange components on the form, typography is very good, can basically adapt to 1366X768 to 3000X2000 resolution, not too deformed. There's no need for so many panels. ---------------------------------------------------------------------- howardpc · 2020-12-13 19:45 Quote from: bd4kc on December 13, 2020, 08:23:07 pmIs there such a function: similar to word, multi-select, combination, so that a group of components are grouped together, can be moved at the same time. In the designer press the Shift key and click on each component you want in the 'group'. You'll see a rubber-band selection rectangle enclosing these components. Dragging any one component now moves the entire group. Once located correctly, click anywhere outside the group to return to normal and lose the temporary grouping. ---------------------------------------------------------------------- bd4kc · 2020-12-13 19:54 Shift key selects multiple, can also stretch and move them at the same time, I do know the usage, how to bind them permanently? Quote from: howardpc on December 13, 2020, 08:45:02 pmQuote from: bd4kc on December 13, 2020, 08:23:07 pmIs there such a function: similar to word, multi-select, combination, so that a group of components are grouped together, can be moved at the same time. In the designer press the Shift key and click on each component you want in the 'group'. You'll see a rubber-band selection rectangle enclosing these components. Dragging any one component now moves the entire group. Once located correctly, click anywhere outside the group to return to normal and lose the temporary grouping. ---------------------------------------------------------------------- MarkMLl · 2020-12-13 20:10 Quote from: bd4kc on December 13, 2020, 08:54:17 pmShift key selects multiple, can also stretch and move them at the same time, I do know the usage, how to bind them permanently? Put them on a panel (or frame if you might want to reuse them). MarkMLl ---------------------------------------------------------------------- wp · 2020-12-13 21:29 There is no "Locking" option for the form designer. But as already proposed you should learn to use the Anchor Editor. This way you can lock the controls to each other with well-defined distances so that it is no longer possible to misplace controls by the mouse - you only can use the Anchor Editor. The main advantage, however, is that you can create self-adjusting layouts this way which still look perfect when the application is run under different widgetsets with different fonts and font sizes. Please read https://wiki.freepascal.org/Autosize_/_Layout. As a teaser study the attached demo ---------------------------------------------------------------------- bd4kc · 2020-12-14 02:31 I'm not used to learning to use anchors, these components also have left and top properties, in the object inpector change the number and then return, the number automatically changes back, people feel strange (the same behavior and the font size of the label also automatically change).  In addition, the anchor also has a specific distance point, not a percentage, which conflicts with the lefttop property value. I don't think I need "WYSIWYG" but "simple drag-and- drop" ---------------------------------------------------------------------- bd4kc · 2020-12-16 13:38 I tried it, and the result was an error in compilation, and then the lfm file became 0 size, so I got it back from the backup directory. Quote from: Handoko on December 13, 2020, 06:55:12 pmIf you use Windows you can try: use Windows Explorer to browse to the location > right click on the *.lfm file > Properties > enable the Read-only checkbox. Not a good solution, but it may work. ---------------------------------------------------------------------- Handoko · 2020-12-16 13:41 Oh, I'm sorry to cause you trouble. ---------------------------------------------------------------------- wp · 2020-12-16 13:56 Quote from: bd4kc on December 14, 2020, 03:31:42 amI'm not used to learning to use anchors Believe me, I refused against the Anchor Editor myself for a long time, but after having gotten used to it (which may take some time...) I am convinced that it is one of the best Lazarus utilities that we have! Quote from: bd4kc on December 14, 2020, 03:31:42 amthese components also have left and top properties, in the object inpector change the number and then return, the number automatically changes back[ Yes - but didn't you want to lock the controls? Quote from: bd4kc on December 14, 2020, 03:31:42 amand the font size of the label also automatically change [...] has a specific distance point, not a percentageI don't understand what you mean. Are we talking of the same thing? ---------------------------------------------------------------------- MarkMLl · 2020-12-16 14:34 Quote from: wp on December 16, 2020, 02:56:09 pmBelieve me, I refused against the Anchor Editor myself for a long time, but after having gotten used to it (which may take some time...) I am convinced that it is one of the best Lazarus utilities that we have! ... Yes - but didn't you want to lock the controls? That's a problem: things like anchors vs alignment where the IDE doesn't really make clear which has precedence. MarkMLl ---------------------------------------------------------------------- wp · 2020-12-16 17:32 Align and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). ---------------------------------------------------------------------- MarkMLl · 2020-12-16 21:18 Quote from: wp on December 16, 2020, 06:32:36 pmAlign and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). Yes, but there aren't really visual clues in the IDE that starting to use one will override or wipe out any existing settings etc. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2020-12-17 08:44 Quote from: wp on December 16, 2020, 06:32:36 pmAlign and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). First of I'd really like to see how you pass the set [akLeft, akTop] to the Align property that accepts the enum values alNone, alLeft, alTop, alBottom or alRight. Second you can use anchors together with alignment, but only those anchors that are not affected by the Align property. So for example if you have a control that is alBottom then the anchors are implicitly set to [akLeft, akRight, akBottom]. That means that if you enlarge the parent control (e.g. the form) then the control will keep its size. If you however add akTop then the control will also maintain its position and will enlarge itself should the parent be enlarged. This is obviously less useful for alLeft and alTop, but for alRight and alBottom it has its uses. ---------------------------------------------------------------------- bd4kc · 2020-12-17 20:54 Quote from: Handoko on December 16, 2020, 02:41:24 pmOh, I'm sorry to cause you trouble.  It's just an empty project for testing, and I'm just as curious as to why the lfm file is rewritten when compiled. ---------------------------------------------------------------------- bd4kc · 2020-12-17 21:08 It's hard for me, I've never designed ui well, and every time I need to test them on a lot of computers with different resolutions until they're barely acceptable. Sometimes I use form.scaleby, write a lot of code to identify, still not satisfied. Now there are more 2K and 4K monitors, how perfect it would be if it were automatically compatible with 800x600 to 4K. Quote from: PascalDragon on December 17, 2020, 09:44:22 amQuote from: wp on December 16, 2020, 06:32:36 pmAlign and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). First of I'd really like to see how you pass the set [akLeft, akTop] to the Align property that accepts the enum values alNone, alLeft, alTop, alBottom or alRight. Second you can use anchors together with alignment, but only those anchors that are not affected by the Align property. So for example if you have a control that is alBottom then the anchors are implicitly set to [akLeft, akRight, akBottom]. That means that if you enlarge the parent control (e.g. the form) then the control will keep its size. If you however add akTop then the control will also maintain its position and will enlarge itself should the parent be enlarged. This is obviously less useful for alLeft and alTop, but for alRight and alBottom it has its uses. ---------------------------------------------------------------------- MarkMLl · 2020-12-17 21:15 Quote from: bd4kc on December 17, 2020, 09:54:02 pmIt's just an empty project for testing, and I'm just as curious as to why the lfm file is rewritten when compiled. Frankly, you're not the only one :-) @Marcov: what was it you said elsewhere a couple of days ago about compilers never, under any circumstances, rewriting their sourcefile? OK, so I know that in the current case it's an IDE, and that processing something with Lazbuild would be more "compiler like". But this definitely shouldn't happen... thought experiment: does it happen if a junior team member tries to compile something owned by his boss? MarkMLl ---------------------------------------------------------------------- wp · 2020-12-17 21:17 Quote from: PascalDragon on December 17, 2020, 09:44:22 amQuote from: wp on December 16, 2020, 06:32:36 pmAlign and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). First of I'd really like to see how you pass the set [akLeft, akTop] to the Align property that accepts the enum values alNone, alLeft, alTop, alBottom or alRight. Second you can use anchors together with alignment, but only those anchors that are not affected by the Align property. So for example if you have a control that is alBottom then the anchors are implicitly set to [akLeft, akRight, akBottom]. That means that if you enlarge the parent control (e.g. the form) then the control will keep its size. If you however add akTop then the control will also maintain its position and will enlarge itself should the parent be enlarged. This is obviously less useful for alLeft and alTop, but for alRight and alBottom it has its uses. Let me put this right by fixing a typo and adding more words. I meant: "Align and Anchor Editor cannot be combined. Anchors must be left at [akLeft, akTop], otherwise anchoring is not possible with all features of the Anchor Editor. The same with ChildSizing (another little used genius tool)." Quote from: bd4kc on December 17, 2020, 10:08:25 pmI've never designed ui well, and every time I need to test them on a lot of computers with different resolutions until they're barely acceptableTake the time and learn how to use the Anchor Editor. Combined with LCLScaling (which is active now by default) all these problems will be solved. Look at the Lazarus IDE - it does nothing else and it works on every widgetset and at every resolution. ---------------------------------------------------------------------- PascalDragon · 2020-12-18 13:56 Quote from: wp on December 17, 2020, 10:17:16 pmQuote from: PascalDragon on December 17, 2020, 09:44:22 amQuote from: wp on December 16, 2020, 06:32:36 pmAlign and Anchors cannot be combined. Align must be left at [akLeft, akTop], otherwise anchoring is not possible. The same with ChildSizing (another little used genius tool). First of I'd really like to see how you pass the set [akLeft, akTop] to the Align property that accepts the enum values alNone, alLeft, alTop, alBottom or alRight. Second you can use anchors together with alignment, but only those anchors that are not affected by the Align property. So for example if you have a control that is alBottom then the anchors are implicitly set to [akLeft, akRight, akBottom]. That means that if you enlarge the parent control (e.g. the form) then the control will keep its size. If you however add akTop then the control will also maintain its position and will enlarge itself should the parent be enlarged. This is obviously less useful for alLeft and alTop, but for alRight and alBottom it has its uses. Let me put this right by fixing a typo and adding more words. I meant: "Align and Anchor Editor cannot be combined. Anchors must be left at [akLeft, akTop], otherwise anchoring is not possible with all features of the Anchor Editor. The same with ChildSizing (another little used genius tool)." Better ---------------------------------------------------------------------- BeniBela · 2020-12-18 21:25 Some automatic way to create responsible layouts would be really helpful I also have the problem  that Lazarus keeps resizing the form by a few pixels whenever I open it on a new computer.  It is kind of like it loads the sizes and then adds the border around the stored size, but saves the size including the border size, or something ---------------------------------------------------------------------- MarkMLl · 2020-12-18 22:53 Quote from: BeniBela on December 18, 2020, 10:25:46 pmI also have the problem  that Lazarus keeps resizing the form by a few pixels whenever I open it on a new computer.  It is kind of like it loads the sizes and then adds the border around the stored size, but saves the size including the border size, or something That could be a tricky one. What OSes... are you mixing Windows (which historically treats the borders/title as part of the window) and unix (which historically doesn't)? MarkMLl ---------------------------------------------------------------------- bd4kc · 2020-12-19 13:15 I also encountered this problem, which often occurs when I copy a project to a computer (surface) with a 3000x2000 screen. A larger portion of the right side of the form is cropped off. The width of the form needs to be adjusted manually to correct it. I experimented many times and found that when the load project, if the default form position is to the right and part of the form is outside the right edge of the screen, the excess is cropped off. Once I wrote code that also had this problem, when the right side was off-screen at startup, the result was that the part was trimmed off, and the effect was like I had designed a form and then reduced the width, and many of the components on the right were not fully displayed or visible. Quote from: MarkMLl on December 18, 2020, 11:53:22 pmQuote from: BeniBela on December 18, 2020, 10:25:46 pmI also have the problem  that Lazarus keeps resizing the form by a few pixels whenever I open it on a new computer.  It is kind of like it loads the sizes and then adds the border around the stored size, but saves the size including the border size, or something That could be a tricky one. What OSes... are you mixing Windows (which historically treats the borders/title as part of the window) and unix (which historically doesn't)? MarkMLl ---------------------------------------------------------------------- BeniBela · 2020-12-21 22:55 Quote from: MarkMLl on December 18, 2020, 11:53:22 pmQuote from: BeniBela on December 18, 2020, 10:25:46 pmI also have the problem  that Lazarus keeps resizing the form by a few pixels whenever I open it on a new computer.  It is kind of like it loads the sizes and then adds the border around the stored size, but saves the size including the border size, or something That could be a tricky one. What OSes... are you mixing Windows (which historically treats the borders/title as part of the window) and unix (which historically doesn't)? MarkMLl I mix different linuxs, Gnome or KDE, KUbuntu  19.04, KUbuntu 20.04, ... I used to use Windows, but have not in years ---------------------------------------------------------------------- winni · 2020-12-21 23:14 Hi: Is it this bug-feature?? If the form is bigger than the screen (design time)  Lazarus shrinks the form. Awful behaviour. Winni PS.: When I am really bothered I hard code the size in FormCreate. ---------------------------------------------------------------------- bd4kc · 2020-12-22 06:02 This happens only if the form position is to the right, not because the form width is too large, and the cut-off size is (form1.left+form1.width)-screen.width.