Add GTK app shell with wizard navigation, step indicator, and actions
This commit is contained in:
88
pixstrip-gtk/src/wizard.rs
Normal file
88
pixstrip-gtk/src/wizard.rs
Normal file
@@ -0,0 +1,88 @@
|
||||
pub struct WizardState {
|
||||
pub current_step: usize,
|
||||
pub total_steps: usize,
|
||||
pub visited: Vec<bool>,
|
||||
names: Vec<String>,
|
||||
}
|
||||
|
||||
impl WizardState {
|
||||
pub fn new() -> Self {
|
||||
let names = vec![
|
||||
"Workflow".into(),
|
||||
"Images".into(),
|
||||
"Resize".into(),
|
||||
"Convert".into(),
|
||||
"Compress".into(),
|
||||
"Metadata".into(),
|
||||
"Output".into(),
|
||||
];
|
||||
let total = names.len();
|
||||
let mut visited = vec![false; total];
|
||||
visited[0] = true;
|
||||
|
||||
Self {
|
||||
current_step: 0,
|
||||
total_steps: total,
|
||||
visited,
|
||||
names,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn step_names(&self) -> Vec<String> {
|
||||
self.names.clone()
|
||||
}
|
||||
|
||||
pub fn can_go_next(&self) -> bool {
|
||||
self.current_step < self.total_steps - 1
|
||||
}
|
||||
|
||||
pub fn can_go_back(&self) -> bool {
|
||||
self.current_step > 0
|
||||
}
|
||||
|
||||
pub fn is_last_step(&self) -> bool {
|
||||
self.current_step == self.total_steps - 1
|
||||
}
|
||||
|
||||
pub fn go_next(&mut self) {
|
||||
if self.can_go_next() {
|
||||
self.current_step += 1;
|
||||
self.visited[self.current_step] = true;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn go_back(&mut self) {
|
||||
if self.can_go_back() {
|
||||
self.current_step -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_wizard_pages() -> Vec<adw::NavigationPage> {
|
||||
let steps = [
|
||||
("step-workflow", "Choose a Workflow", "image-x-generic-symbolic", "Select a preset or build a custom workflow"),
|
||||
("step-images", "Add Images", "folder-pictures-symbolic", "Drop images here or click Browse"),
|
||||
("step-resize", "Resize", "view-fullscreen-symbolic", "Set output dimensions"),
|
||||
("step-convert", "Convert", "document-save-symbolic", "Choose output format"),
|
||||
("step-compress", "Compress", "system-file-manager-symbolic", "Set compression quality"),
|
||||
("step-metadata", "Metadata", "security-high-symbolic", "Control metadata privacy"),
|
||||
("step-output", "Output & Process", "emblem-ok-symbolic", "Review and process"),
|
||||
];
|
||||
|
||||
steps
|
||||
.iter()
|
||||
.map(|(tag, title, icon, description)| {
|
||||
let status_page = adw::StatusPage::builder()
|
||||
.title(*title)
|
||||
.description(*description)
|
||||
.icon_name(*icon)
|
||||
.build();
|
||||
|
||||
adw::NavigationPage::builder()
|
||||
.title(*title)
|
||||
.tag(*tag)
|
||||
.child(&status_page)
|
||||
.build()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
Reference in New Issue
Block a user