I am have been using absolute positioning for my GUI for a while now but I have added so many things to the GUI that at this point when I change the base layout it can take a couple of hours to realign everything. Now I already know people are going to tell me I should be using sizers for everything but I don’t know if that is possible for my use case I have attached an image here that shows the base diagram of what I am trying to overlay my controls on to. This is what it looks like when the controls are misaligned over the background schematic. anytime the base image changes I have to manually adjust the absolute positioning of each control so it shows up in the right location. If anyone could explain to me how I can avoid that it would be extremely helpful.
Sizers won’t help you. Something, somewhere, has to specify where the positions for your widgets are in each new background image that you receive.
What you can do is make it easier to specify. Don’t hardwire positions into your program, store them in a configuration file. Then make an “editing mode” that displays your controls, or placeholders for your controls, overlaid on the background image, and allows the operator to move them around, putting them in position visually, and then saving the positions to your configuration file.
Such an editor can be very simple: Put a list of control names in a listbox to the side. The operator selects which control to position in the listbox, and then clicks on the position on the image where it goes. Your program then draws the control or placeholder at that position, and if the position is off, the operator just clicks again on a different position to try again, until it looks OK.
Thank you for this answer I m working on an editing mode now though I’m getting stuck on some event handling maybe I’ll make a separate post if I can not figure it out.
Make your positioning relative to the major things in the drawing, or to adjacent objects. IOW, don’t put things at (235, 256), but rather at (piece3.pos.x+120, piece3.pos.1+32) etc. Then when the drawing changes, you only need to tell your code what the current positions of each of the pieces are, and the code takes it from there.
(Of course, the exact syntax of piece3.pos.x may be something else, this is just placeholder code)
IOW, you can keep your pieces positioned in code, just not counting from the form’s (top, left), but rather from the movable pieces’ positions.