Move all operations to widget::operation module
This commit is contained in:
parent
885d45f435
commit
34a42b5ad4
14 changed files with 124 additions and 136 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use iced::highlighter;
|
||||
use iced::keyboard;
|
||||
use iced::widget::{
|
||||
self, button, center_x, column, container, horizontal_space, pick_list,
|
||||
row, text, text_editor, toggler, tooltip,
|
||||
button, center_x, column, container, horizontal_space, operation,
|
||||
pick_list, row, text, text_editor, toggler, tooltip,
|
||||
};
|
||||
use iced::{Center, Element, Fill, Font, Task, Theme};
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ impl Editor {
|
|||
)),
|
||||
Message::FileOpened,
|
||||
),
|
||||
widget::focus_next(),
|
||||
operation::focus_next(),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use iced::clipboard;
|
|||
use iced::highlighter;
|
||||
use iced::time::{self, Instant, milliseconds};
|
||||
use iced::widget::{
|
||||
self, button, center_x, container, horizontal_space, hover, image,
|
||||
markdown, right, row, scrollable, sensor, text_editor, toggler,
|
||||
button, center_x, container, horizontal_space, hover, image, markdown,
|
||||
operation, right, row, scrollable, sensor, text_editor, toggler,
|
||||
};
|
||||
use iced::window;
|
||||
use iced::{
|
||||
|
|
@ -78,7 +78,7 @@ impl Markdown {
|
|||
theme: Theme::TokyoNight,
|
||||
now: Instant::now(),
|
||||
},
|
||||
widget::focus_next(),
|
||||
operation::focus_next(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -140,10 +140,7 @@ impl Markdown {
|
|||
pending: self.raw.text(),
|
||||
};
|
||||
|
||||
scrollable::snap_to(
|
||||
"preview",
|
||||
scrollable::RelativeOffset::END,
|
||||
)
|
||||
operation::snap_to_end("preview")
|
||||
} else {
|
||||
self.mode = Mode::Preview;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use iced::event::{self, Event};
|
|||
use iced::keyboard;
|
||||
use iced::keyboard::key;
|
||||
use iced::widget::{
|
||||
self, button, center, column, container, horizontal_space, mouse_area,
|
||||
opaque, pick_list, row, stack, text, text_input,
|
||||
button, center, column, container, horizontal_space, mouse_area, opaque,
|
||||
operation, pick_list, row, stack, text, text_input,
|
||||
};
|
||||
use iced::{Bottom, Color, Element, Fill, Subscription, Task};
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ impl App {
|
|||
match message {
|
||||
Message::ShowModal => {
|
||||
self.show_modal = true;
|
||||
widget::focus_next()
|
||||
operation::focus_next()
|
||||
}
|
||||
Message::HideModal => {
|
||||
self.hide_modal();
|
||||
|
|
@ -75,9 +75,9 @@ impl App {
|
|||
..
|
||||
}) => {
|
||||
if modifiers.shift() {
|
||||
widget::focus_previous()
|
||||
operation::focus_previous()
|
||||
} else {
|
||||
widget::focus_next()
|
||||
operation::focus_next()
|
||||
}
|
||||
}
|
||||
Event::Keyboard(keyboard::Event::KeyPressed {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use iced::widget::{
|
||||
button, center, center_x, column, container, horizontal_space, scrollable,
|
||||
text, text_input,
|
||||
button, center, center_x, column, container, horizontal_space, operation,
|
||||
scrollable, text, text_input,
|
||||
};
|
||||
use iced::window;
|
||||
use iced::{
|
||||
|
|
@ -85,7 +85,7 @@ impl Example {
|
|||
}
|
||||
Message::WindowOpened(id) => {
|
||||
let window = Window::new(self.windows.len() + 1);
|
||||
let focus_input = text_input::focus(format!("input-{id}"));
|
||||
let focus_input = operation::focus(format!("input-{id}"));
|
||||
|
||||
self.windows.insert(id, window);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use iced::widget::{
|
||||
button, column, container, horizontal_space, progress_bar, radio, row,
|
||||
scrollable, slider, text, vertical_space,
|
||||
button, column, container, horizontal_space, operation, progress_bar,
|
||||
radio, row, scrollable, slider, text, vertical_space,
|
||||
};
|
||||
use iced::{Border, Center, Color, Element, Fill, Task, Theme};
|
||||
|
||||
|
|
@ -60,13 +60,13 @@ impl ScrollableDemo {
|
|||
self.current_scroll_offset = scrollable::RelativeOffset::START;
|
||||
self.scrollable_direction = direction;
|
||||
|
||||
scrollable::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
operation::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
}
|
||||
Message::AlignmentChanged(alignment) => {
|
||||
self.current_scroll_offset = scrollable::RelativeOffset::START;
|
||||
self.anchor = alignment;
|
||||
|
||||
scrollable::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
operation::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
}
|
||||
Message::ScrollbarWidthChanged(width) => {
|
||||
self.scrollbar_width = width;
|
||||
|
|
@ -86,12 +86,12 @@ impl ScrollableDemo {
|
|||
Message::ScrollToBeginning => {
|
||||
self.current_scroll_offset = scrollable::RelativeOffset::START;
|
||||
|
||||
scrollable::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
operation::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
}
|
||||
Message::ScrollToEnd => {
|
||||
self.current_scroll_offset = scrollable::RelativeOffset::END;
|
||||
|
||||
scrollable::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
operation::snap_to(SCROLLABLE, self.current_scroll_offset)
|
||||
}
|
||||
Message::Scrolled(viewport) => {
|
||||
self.current_scroll_offset = viewport.relative_offset();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use iced::event::{self, Event};
|
|||
use iced::keyboard;
|
||||
use iced::keyboard::key;
|
||||
use iced::widget::{
|
||||
self, button, center, column, pick_list, row, slider, text, text_input,
|
||||
button, center, column, operation, pick_list, row, slider, text, text_input,
|
||||
};
|
||||
use iced::{Center, Element, Fill, Subscription, Task};
|
||||
|
||||
|
|
@ -83,11 +83,11 @@ impl App {
|
|||
key: keyboard::Key::Named(key::Named::Tab),
|
||||
modifiers,
|
||||
..
|
||||
})) if modifiers.shift() => widget::focus_previous(),
|
||||
})) if modifiers.shift() => operation::focus_previous(),
|
||||
Message::Event(Event::Keyboard(keyboard::Event::KeyPressed {
|
||||
key: keyboard::Key::Named(key::Named::Tab),
|
||||
..
|
||||
})) => widget::focus_next(),
|
||||
})) => operation::focus_next(),
|
||||
Message::Event(_) => Task::none(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use iced::keyboard;
|
||||
use iced::widget::{
|
||||
self, Text, button, center, center_x, checkbox, column, keyed_column, row,
|
||||
scrollable, text, text_input,
|
||||
self, Text, button, center, center_x, checkbox, column, keyed_column,
|
||||
operation, row, scrollable, text, text_input,
|
||||
};
|
||||
use iced::window;
|
||||
use iced::{
|
||||
|
|
@ -91,7 +91,7 @@ impl Todos {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
text_input::focus("new-task")
|
||||
operation::focus("new-task")
|
||||
}
|
||||
Todos::Loaded(state) => {
|
||||
let mut saved = false;
|
||||
|
|
@ -132,8 +132,8 @@ impl Todos {
|
|||
if should_focus {
|
||||
let id = Task::text_input_id(i);
|
||||
Command::batch(vec![
|
||||
text_input::focus(id.clone()),
|
||||
text_input::select_all(id),
|
||||
operation::focus(id.clone()),
|
||||
operation::select_all(id),
|
||||
])
|
||||
} else {
|
||||
Command::none()
|
||||
|
|
@ -150,9 +150,9 @@ impl Todos {
|
|||
}
|
||||
Message::TabPressed { shift } => {
|
||||
if shift {
|
||||
widget::focus_previous()
|
||||
operation::focus_previous()
|
||||
} else {
|
||||
widget::focus_next()
|
||||
operation::focus_next()
|
||||
}
|
||||
}
|
||||
Message::ToggleFullscreen(mode) => window::get_latest()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod echo;
|
|||
|
||||
use iced::futures::stream;
|
||||
use iced::widget::{
|
||||
self, button, center, column, row, scrollable, text, text_input,
|
||||
button, center, column, operation, row, scrollable, text, text_input,
|
||||
};
|
||||
use iced::{Center, Element, Fill, Subscription, Task, color};
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ impl WebSocket {
|
|||
new_message: String::new(),
|
||||
state: State::Disconnected,
|
||||
},
|
||||
widget::focus_next(),
|
||||
operation::focus_next(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -73,10 +73,7 @@ impl WebSocket {
|
|||
echo::Event::MessageReceived(message) => {
|
||||
self.messages.push(message);
|
||||
|
||||
scrollable::snap_to(
|
||||
MESSAGE_LOG,
|
||||
scrollable::RelativeOffset::END,
|
||||
)
|
||||
operation::snap_to_end(MESSAGE_LOG)
|
||||
}
|
||||
},
|
||||
Message::Server => Task::none(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue