distributeButtonsHorizontally takes a list of buttons and horizontally arrange them with equal width each. At least, that's what you would get from reading the function name. In reality, the function handles positioning the buttons, with some hardcoded constants as well as hardcoded placement logic for 1 <= N <=3 buttons. The list of changes are as follows.
- Rename distributeButtonsHorizontally to something more descriptive. packButtonsHorizontally inspired from python Tkinter.
- Remove the vertical positioning hardcoding and instead let the function take a parameter to define the relative vertical positioning.
- Dynamically set button heights based on the text height, normalized to the highest text height. This is needed to prevent text overflows.
- Make paddings and margins consistent.
- Refactor the function to calculate the positioning instead of hardcoding it.
TODO:
- Use the function for placing other buttons across the GUI which would make buttons consistent. (GameSetup is a perfect use case)
- Maybe consider a max width, which would prevent single buttons from stretching the full horizontal space.