mirror of
https://github.com/13hannes11/focus_annotator.git
synced 2024-09-03 23:21:01 +02:00
format file containing state module
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::constants::NONE_STRING_OPTION;
|
use crate::constants::NONE_STRING_OPTION;
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -25,21 +25,17 @@ pub struct State{
|
|||||||
Some(image_index) => {
|
Some(image_index) => {
|
||||||
let stack = self.get_current_focus_stack();
|
let stack = self.get_current_focus_stack();
|
||||||
match stack {
|
match stack {
|
||||||
Some(stack) => {
|
Some(stack) => stack.images.get(image_index).map(|x| x.clone()),
|
||||||
stack.images.get(image_index).map(|x| x.clone())
|
_ => None,
|
||||||
},
|
|
||||||
_ => None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_focus_stack(&self) -> Option<&AnnotationZStack> {
|
pub fn get_current_focus_stack(&self) -> Option<&AnnotationZStack> {
|
||||||
match self.stack_index {
|
match self.stack_index {
|
||||||
Some(stack_index) => {
|
Some(stack_index) => self.stacks.get(stack_index),
|
||||||
self.stacks.get(stack_index)
|
|
||||||
}
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +62,7 @@ pub struct State{
|
|||||||
pub fn get_current_foucs_stack_best_index(&self) -> Option<usize> {
|
pub fn get_current_foucs_stack_best_index(&self) -> Option<usize> {
|
||||||
match self.get_current_focus_stack() {
|
match self.get_current_focus_stack() {
|
||||||
Some(stack) => stack.best_index,
|
Some(stack) => stack.best_index,
|
||||||
_ => None
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +70,7 @@ pub struct State{
|
|||||||
let len = self.stacks.len();
|
let len = self.stacks.len();
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
self.stack_index = None;
|
self.stack_index = None;
|
||||||
} else if self.stack_index.map_or_else(|| false, |x| {x + 1 < len}) {
|
} else if self.stack_index.map_or_else(|| false, |x| x + 1 < len) {
|
||||||
self.stack_index = self.stack_index.map(|x| x + 1)
|
self.stack_index = self.stack_index.map(|x| x + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +94,6 @@ pub struct State{
|
|||||||
self.stack_index = self.stack_index.map(|x| x - 1)
|
self.stack_index = self.stack_index.map(|x| x - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
Reference in New Issue
Block a user