Files
hcie-rust-v3.05/hcie-iced-app/crates/hcie-iced-gui/src/dialogs/confirm.rs
T

60 lines
1.9 KiB
Rust
Raw Normal View History

//! Confirm dialog — save/discard/cancel confirmation.
use crate::app::Message;
use crate::theme::ThemeColors;
use crate::widgets::plain_slider::plain_slider;
use iced::widget::{column, horizontal_rule, row, text};
use iced::Element;
/// Build a confirmation dialog with save/discard/cancel.
pub fn close_confirm_view(doc_name: &str, colors: ThemeColors) -> Element<'static, Message> {
let msg = format!("\"{}\" has unsaved changes.", doc_name);
let save_btn = super::primary_btn("Save", Message::DialogCloseSave, colors);
let discard_btn = super::secondary_btn("Discard", Message::DialogCloseDiscard, colors);
let cancel_btn = super::secondary_btn("Cancel", Message::DialogClose, colors);
let dialog = column![
text("Unsaved Changes").size(16).font(iced::Font::MONOSPACE),
horizontal_rule(1),
text(msg).size(12),
horizontal_rule(1),
row![save_btn, discard_btn, cancel_btn].spacing(12),
]
.spacing(8)
.padding(16)
.width(400);
super::modal(dialog, colors)
}
/// Build a selection operation dialog (grow/shrink/feather).
pub fn selection_op_view(
op_name: &str,
value: f32,
min: f32,
max: f32,
colors: ThemeColors,
) -> Element<'static, Message> {
let op_owned = op_name.to_string();
let value_slider = plain_slider("Value", value, min..=max, 1.0, "", 0, |v| {
Message::SelectionOpValue(v)
});
let apply_btn = super::primary_btn("Apply", Message::SelectionOpApply, colors);
let cancel_btn = super::secondary_btn("Cancel", Message::DialogClose, colors);
let dialog = column![
text(op_owned).size(14).font(iced::Font::MONOSPACE),
horizontal_rule(1),
value_slider,
horizontal_rule(1),
row![apply_btn, cancel_btn].spacing(12),
]
.spacing(8)
.padding(16)
.width(350);
super::modal(dialog, colors)
}