forked from 1b-agent/opencadstudio-upstream
Merge pull request #1353 from HakanSeven12/ui/options-ok-apply-close
feat(options): OK / Apply / Close with a discard guard # Conflicts: # src/app/view/modal.rs # src/ui/window/options.rs
This commit is contained in:
commit
1c0ef9d7a0
8 files changed
+365
-55
No files matched your search
@@ -212,6 +212,8 @@ pub fn view_window<'a>(
|
||||
paper_bg_input: &'a str,
|
||||
desk_bg_input: &'a str,
|
||||
bg_picker: Option<crate::app::BgTarget>,
|
||||
dirty: bool,
|
||||
close_confirm: bool,
|
||||
sizing: crate::ui::modal::ModalSizing,
|
||||
) -> Element<'a, Message> {
|
||||
let selected_format = crate::io::SAVE_FORMAT_OPTIONS
|
||||
@@ -311,8 +313,18 @@ pub fn view_window<'a>(
|
||||
);
|
||||
}
|
||||
|
||||
// Changes show at once but are committed by OK / Apply; Close puts them
|
||||
// back (asking first when there is something to lose).
|
||||
let ok = button(text(crate::t!("OK")).size(12))
|
||||
.on_press(Message::OptionsOk)
|
||||
.padding([6, 18])
|
||||
.style(button::primary);
|
||||
let apply = button(text(crate::t!("Apply")).size(12))
|
||||
.on_press_maybe(dirty.then_some(Message::OptionsApply))
|
||||
.padding([6, 18])
|
||||
.style(if dirty { button::secondary } else { button::text });
|
||||
let close = button(text(crate::tr!("action", "close")).size(12))
|
||||
.on_press(Message::CloseModal)
|
||||
.on_press(Message::OptionsClose)
|
||||
.padding([6, 18])
|
||||
.style(button::secondary);
|
||||
|
||||
@@ -1668,7 +1680,7 @@ pub fn view_window<'a>(
|
||||
// controls at the trailing edge of the Options content.
|
||||
scrollable(content).spacing(8).height(Fill),
|
||||
Space::new().height(12),
|
||||
row![Space::new().width(Fill), close],
|
||||
row![Space::new().width(Fill), ok, apply, close].spacing(8),
|
||||
]
|
||||
.width(Fill)
|
||||
.height(sizing.height);
|
||||
@@ -1678,10 +1690,13 @@ pub fn view_window<'a>(
|
||||
.height(sizing.height);
|
||||
|
||||
let intrinsic = sizing.width == crate::ui::modal::ModalSizing::INTRINSIC.width;
|
||||
container(body)
|
||||
let main = container(body)
|
||||
.style(container::rounded_box)
|
||||
.padding([16, 18])
|
||||
.width(if intrinsic { iced::Length::Fixed(DIALOG_WIDTH) } else { sizing.width })
|
||||
.height(if intrinsic { iced::Length::Fixed(DIALOG_HEIGHT) } else { sizing.height })
|
||||
.into()
|
||||
.height(if intrinsic { iced::Length::Fixed(DIALOG_HEIGHT) } else { sizing.height });
|
||||
if !close_confirm {
|
||||
return main.into();
|
||||
}
|
||||
crate::ui::modal::discard_guard(main, Message::OptionsCloseDiscard, Message::OptionsCloseKeep)
|
||||
}
|
||||
Reference in new issue
Block a user