forked from 1b-agent/opencadstudio-upstream
1 parent
4af141ebec
commit
c9aab122f0
10 files changed
+814
-7
No files matched your search
@@ -0,0 +1,66 @@
|
||||
use crate::app::Message;
|
||||
use iced::widget::{button, column, row, text, text_input, Space};
|
||||
use iced::{Element, Fill};
|
||||
|
||||
pub const FIND_INPUT_ID: &str = "find-replace-search";
|
||||
|
||||
pub fn view_window<'a>(
|
||||
search: &'a str,
|
||||
replacement: &'a str,
|
||||
status: &'a str,
|
||||
) -> Element<'a, Message> {
|
||||
let find_input = text_input("Text to find", search)
|
||||
.id(iced::widget::Id::new(FIND_INPUT_ID))
|
||||
.on_input(Message::FindReplaceSearchChanged)
|
||||
.on_submit(Message::FindReplaceNext)
|
||||
.padding([6, 8])
|
||||
.size(13);
|
||||
let replacement_input = text_input("Replacement text", replacement)
|
||||
.on_input(Message::FindReplaceReplacementChanged)
|
||||
.padding([6, 8])
|
||||
.size(13);
|
||||
|
||||
let enabled = !search.trim().is_empty();
|
||||
let action = |label: &'static str, message: Message| {
|
||||
let button = button(text(label).size(12)).padding([6, 12]);
|
||||
if enabled {
|
||||
button.on_press(message)
|
||||
} else {
|
||||
button
|
||||
}
|
||||
};
|
||||
|
||||
column![
|
||||
row![
|
||||
text("Find:").size(12).width(90),
|
||||
find_input.width(Fill),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
row![
|
||||
text("Replace with:").size(12).width(90),
|
||||
replacement_input.width(Fill),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
text("Searches Text, MText, Attribute Definitions, and block attribute values.")
|
||||
.size(11),
|
||||
text(status).size(11),
|
||||
row![
|
||||
Space::new().width(Fill),
|
||||
button(text("Close").size(12))
|
||||
.on_press(Message::CloseModal)
|
||||
.padding([6, 12])
|
||||
.style(button::secondary),
|
||||
action("Replace", Message::FindReplaceOne).style(button::secondary),
|
||||
action("Replace All", Message::FindReplaceAll).style(button::danger),
|
||||
action("Find Next", Message::FindReplaceNext).style(button::primary),
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(iced::Center),
|
||||
]
|
||||
.spacing(10)
|
||||
.padding(12)
|
||||
.width(Fill)
|
||||
.into()
|
||||
}
|
||||
Reference in new issue
Block a user