Godot Version
4.4
Background
I am creating a Sudoku UI, which is a game with a 9x9 grid where each square in the grid can show a number from 1-9.
Presently, I have:
- A Square scene, which represents a single square in the grid and is composed of a Panel with a Label child.
- A Row scene, which is an HBoxContainer that contains nine Square scenes as children.
- A Rows scene, which is a VBoxContainer that contains nine Row scenes.
I have code attached to the Square scene that sets the Label text based on the assigned value to that square (if any), and code in the Rows scene that works with the grid as a whole.
Question
In one sentence: What is the recommended best practices for UI elements that have a “base” theme but need to override certain parts of it based on the element’s position or user input?
What’s a good way to theme the Square scene’s Panel and Label given that the styling needs to change frequently based on position or user interaction?
For example, by default all squares should have a white background and a thin, light gray border. BUT… if the square is on the edge of the grid then it should have a thicker, black background along the edge. Likewise, if the square makes up one of the edges of the 3x3 boxes in Sudoku then it should have the same thicker, black background along the box edge.
I see that with a theme I can define the Panel’s border color and width for all four sides, but how would I go about saying, "For these square use the same default border color and width for its top, left, and right border, but override the bottom border styling to have a thicker, black border?
Do I need to create a unique theme for each combination of border differences? Or can I override these programmatically in a loop?