Add init flags to Offset and set vertical offset

Add `value_initiated` and `max_initiated` flags to prevent
repeated assignments. Provide `set_initial_value` for one‑time
initialisation and use it to centre the vertical offset when
creating the board widget. Remove stale comments on cell size constants.
This commit is contained in:
2026-03-28 14:35:05 +01:00
parent ba0028b7a7
commit edf491457e
2 changed files with 28 additions and 4 deletions
+19 -2
View File
@@ -5,23 +5,40 @@ use clap::ValueEnum;
pub struct Offset {
value: usize,
max: usize,
value_initiated: bool,
max_initiated: bool,
}
impl Offset {
pub fn new() -> Self {
Self { value: 0, max: 0 }
Self {
value: 0,
max: 0,
value_initiated: false,
max_initiated: false,
}
}
pub fn get_value(&self) -> usize {
self.value
}
pub fn set_initial_value(&mut self, value: usize) {
if self.value_initiated {
return;
}
self.value = value;
self.value_initiated = true;
}
pub fn set_max(&mut self, max: usize) {
if self.max != 0 {
if self.max_initiated {
return;
}
self.max = max;
self.max_initiated = true;
}
pub fn next(&mut self) {