generated from GarandPLG/rust-flake-template
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user