Recent

Author Topic: IDE - Panel hide away!  (Read 2128 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1009
IDE - Panel hide away!
« on: February 23, 2024, 05:08:49 pm »
Some functions are to display and to hide away. These functions I group on an invisible panel. A button allows at runtime to display the panel with its functions. The second click hides the panel away again.

This is a fine solution at runtime. But how to work with it at design time? The elements BELOW these panel are complicated to work with. So I shift the panel and on next run its position is lost. I found a thing called "z-order". I am not sure how it works and it never does what I want.

As everybody has this topic, there shall be better ways to handle this. Please be so kind to share them with me.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: IDE - Panel hide away!
« Reply #1 on: February 23, 2024, 05:27:16 pm »
I am unsure what you talk about, it sound like a component but wait, we are in the IDE/Editor forum...

Please explain it better, in best case with screenshots.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

VisualLab

  • Hero Member
  • *****
  • Posts: 500
Re: IDE - Panel hide away!
« Reply #2 on: February 23, 2024, 05:31:17 pm »
Some functions are to display and to hide away. These functions I group on an invisible panel. A button allows at runtime to display the panel with its functions. The second click hides the panel away again.

This is a fine solution at runtime. But how to work with it at design time? The elements BELOW these panel are complicated to work with. So I shift the panel and on next run its position is lost. I found a thing called "z-order". I am not sure how it works and it never does what I want.

As everybody has this topic, there shall be better ways to handle this. Please be so kind to share them with me.

This is useful when you need to change the order in which sibling window controls overlap with each other. To move controls programmatically you can use: BrignTo Front and SendToBack.

You can also use TNotebook or TPageControl controls. They both have pages. Except that TPageControl has tabs (they can be hidden).

Josh

  • Hero Member
  • *****
  • Posts: 1324
Re: IDE - Panel hide away!
« Reply #3 on: February 23, 2024, 05:34:49 pm »
If it were me,I would move it out the way.
then in the form onactivate or form onshow or the code that the button runs move it back where needed.

you could send the panel to back in object inspector of the panel, but then its out of sight,i like things to be in sight even if not in right location.
Code: Pascal  [Select][+][-]
  1. ....
  2.   mypanel.top:=mybutton.top+mybutton.height+4;//or absolute address if only one widgetset
  3.   mypanel.left:=mybutton.left;//or absolute address if only one widgetset
  4. ...
  5. // code for button
  6. ...
  7.   mypanel.visible:=not mypanel.visible;
  8.   if mypanel.visible then
  9.   begin
  10.     mypanel.bringtofront;
  11.     mypanel.invalidate;
  12.   end;
  13. .....
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

TRon

  • Hero Member
  • *****
  • Posts: 3297
Re: IDE - Panel hide away!
« Reply #4 on: February 23, 2024, 05:35:54 pm »
At designtime use two panels: one for your 'shift' panel and one for your client area. Align the shift panel to the left and the other panel to the client rectangle of the form. On formcreate event remove the alignment of the shift panel and change the z-order as suggested by VisualLab.

That should be able to make things workable for you at designtime. Perhaps you also need to change the size (width) of the window at form creation (form.width := formwidth - shiftpanel.width to not make it too obvious there is space reserved for your shifting panel.
This tagline is powered by AI

Handoko

  • Hero Member
  • *****
  • Posts: 5290
  • My goal: build my own game engine using Lazarus
Re: IDE - Panel hide away!
« Reply #5 on: February 23, 2024, 05:41:15 pm »
Did OP mean a feature that can show/hide component on design time?

As everybody has this topic, there shall be better ways to handle this.

If I understood your issue correctly, my solutions are:

Use TFrame. It should works for someone but I personally don't like TFrame.

Instead I use TForm. On OnCreate, the form will be showed/positioned into a TPanel.

TFrame and TForm are very useful to simplify complex UI layout. But I usually prefer to generate the UI components at runtime by code. There are some advantages generating them by code than by using the visual editor.
« Last Edit: February 23, 2024, 05:43:27 pm by Handoko »

TRon

  • Hero Member
  • *****
  • Posts: 3297
Re: IDE - Panel hide away!
« Reply #6 on: February 23, 2024, 07:04:46 pm »
Did OP mean a feature that can show/hide component on design time?
That would most probably be the better solution for OP (or anyone else having to deal with such feature).

Note that your embedded form solution is a nice one but probably has quirks when using another widgetset yes or no in combination with certain window managers (Linux).
This tagline is powered by AI

wp

  • Hero Member
  • *****
  • Posts: 12368
Re: IDE - Panel hide away!
« Reply #7 on: February 23, 2024, 07:25:44 pm »
The elements BELOW these panel are complicated to work with. So I shift the panel and on next run its position is lost.
[...]
As everybody has this topic, there shall be better ways to handle this. Please be so kind to share them with me.
Better ways, yes, definitely. One of the most ignored, but most powerful features in the LCL - ChildSizing.
  • Drop the containers (e.g. a panel with other controls that you want to show/hide depending on context) in a panel, roughly position them so that you can work with them, but keep their Align settings unchanged.
  • Then activate ChildSizing of the panel: When the containers should be stacked vertically set Panel.ChildSizing.Layout to cclLeftToRigthThenTopToBottom; with Panel.ChildSizing.ControlsPerLine at the default of 0 or at 1 you get one column of nicely stacked controls (if you want more columns set the ControlsPerLine accordingly).
  • When you now hide one or more containers and reshow them later their order remains unchanged.
  • The order is the order in which they were added. If you want to move a container up you must right-click on it (or on its node in the object tree) and select "Z-Order" > "Move to front" if you want it at the top, "Move to back" if you want it at the bottom, "Forward one" if you want it to change its place with the next lower one, or "Back one" if you want it at one place higher. (or the other way around - I always forget...)
See attached demo.

vfclists

  • Hero Member
  • *****
  • Posts: 1120
    • HowTos Considered Harmful?
Re: IDE - Panel hide away!
« Reply #8 on: February 24, 2024, 05:27:15 pm »
Some functions are to display and to hide away. These functions I group on an invisible panel. A button allows at runtime to display the panel with its functions. The second click hides the panel away again.

This is a fine solution at runtime. But how to work with it at design time? The elements BELOW these panel are complicated to work with. So I shift the panel and on next run its position is lost. I found a thing called "z-order". I am not sure how it works and it never does what I want.

As everybody has this topic, there shall be better ways to handle this. Please be so kind to share them with me.

This is useful when you need to change the order in which sibling window controls overlap with each other. To move controls programmatically you can use: BrignTo Front and SendToBack.

You can also use TNotebook or TPageControl controls. They both have pages. Except that TPageControl has tabs (they can be hidden).


I think you already have your answer from VisualLab. It is the part I have highlighted in bold.

Another thing I want to add is that if committing your code to a source code control system is important to you, the form designer is hell, as it means you get spurious changes as you move stuff around, sometimes just to gain access to some controls to make the changes you want.

Write everything in code as much as you can or else you will be in a whole world of pain when you are constantly squinting at the changes in the LFMs to see what matters and what doesn't
« Last Edit: February 24, 2024, 10:44:17 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

Nicole

  • Hero Member
  • *****
  • Posts: 1009
Re: IDE - Panel hide away!
« Reply #9 on: February 24, 2024, 06:08:51 pm »
Thank you for all answers.

@vfclists
is there an easy online way to do it?

At the moment I make a full copy of my project after every step which works.

And at the end of the day I use the freeware PersonalBackup, which was originally written by a Delphi genius who wanted to safe his own project files in a way, they make sense. e.g. nobody wants to save the backup-folders or huge exe every day. This is the Swiss knife for making an offline copy.

lainz

  • Hero Member
  • *****
  • Posts: 4593
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: IDE - Panel hide away!
« Reply #10 on: February 24, 2024, 10:13:47 pm »
Thank you for all answers.

@vfclists
is there an easy online way to do it?

At the moment I make a full copy of my project after every step which works.

And at the end of the day I use the freeware PersonalBackup, which was originally written by a Delphi genius who wanted to safe his own project files in a way, they make sense. e.g. nobody wants to save the backup-folders or huge exe every day. This is the Swiss knife for making an offline copy.

SVN, GIT

vfclists

  • Hero Member
  • *****
  • Posts: 1120
    • HowTos Considered Harmful?
Re: IDE - Panel hide away!
« Reply #11 on: February 24, 2024, 10:55:51 pm »
Thank you for all answers.

@vfclists
is there an easy online way to do it?

At the moment I make a full copy of my project after every step which works.

And at the end of the day I use the freeware PersonalBackup, which was originally written by a Delphi genius who wanted to safe his own project files in a way, they make sense. e.g. nobody wants to save the backup-folders or huge exe every day. This is the Swiss knife for making an offline copy.

Git is the tool you probably want to familiarize yourself with, but the UIs available for it are horrendous.

Grasping the concepts behind it through the tools available is rather hard, and far as Git is concerned, installing Emacs just to be able to use Magit is probably worth it, whether on Windows or Linux.

TortoiseGit on Windows will be good to get you going.

If just tagging and saving snapshots is your main need it then any backup tool that does tagged and labelled snapshots of a directory will be fine, like the PersonalBackup tool you mentioned.

Lazarus 3.0/FPC 3.2.2

lainz

  • Hero Member
  • *****
  • Posts: 4593
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: IDE - Panel hide away!
« Reply #12 on: February 25, 2024, 12:17:37 am »
I personally use Source tree that's git for mac and Windows.
Also you have Github client.

If you want to pay you have GitKraken.

 

TinyPortal © 2005-2018