Fix lints for Rust 1.89 and bump MSRV to 1.88
This commit is contained in:
parent
88185f9d97
commit
d5cd0a6de9
21 changed files with 360 additions and 395 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -9,7 +9,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
rust: [stable, beta, "1.85"]
|
rust: [stable, beta, "1.88"]
|
||||||
steps:
|
steps:
|
||||||
- uses: hecrj/setup-rust-action@v2
|
- uses: hecrj/setup-rust-action@v2
|
||||||
with:
|
with:
|
||||||
|
|
@ -23,5 +23,7 @@ jobs:
|
||||||
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
|
cargo test --verbose --workspace
|
||||||
cargo test --verbose --workspace -- --ignored
|
cargo test --verbose --workspace -- --ignored
|
||||||
|
cargo test --verbose --workspace --all-features
|
||||||
cargo test --verbose --workspace --all-features -- --ignored
|
cargo test --verbose --workspace --all-features -- --ignored
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ repository = "https://github.com/iced-rs/iced"
|
||||||
homepage = "https://iced.rs"
|
homepage = "https://iced.rs"
|
||||||
categories = ["gui"]
|
categories = ["gui"]
|
||||||
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
||||||
rust-version = "1.85"
|
rust-version = "1.88"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
iced = { version = "0.14.0-dev", path = "." }
|
iced = { version = "0.14.0-dev", path = "." }
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ impl Editor {
|
||||||
|
|
||||||
let mut text = self.content.text();
|
let mut text = self.content.text();
|
||||||
|
|
||||||
if let Some(ending) = self.content.line_ending() {
|
if let Some(ending) = self.content.line_ending()
|
||||||
if !text.ends_with(ending.as_str()) {
|
&& !text.ends_with(ending.as_str())
|
||||||
|
{
|
||||||
text.push_str(ending.as_str());
|
text.push_str(ending.as_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Task::perform(
|
Task::perform(
|
||||||
save_file(self.file.clone(), text),
|
save_file(self.file.clone(), text),
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,12 @@ impl Example {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::FocusAdjacent(direction) => {
|
Message::FocusAdjacent(direction) => {
|
||||||
if let Some(pane) = self.focus {
|
if let Some(pane) = self.focus
|
||||||
if let Some(adjacent) = self.panes.adjacent(pane, direction)
|
&& let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||||
{
|
{
|
||||||
self.focus = Some(adjacent);
|
self.focus = Some(adjacent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Message::Clicked(pane) => {
|
Message::Clicked(pane) => {
|
||||||
self.focus = Some(pane);
|
self.focus = Some(pane);
|
||||||
}
|
}
|
||||||
|
|
@ -106,18 +105,16 @@ impl Example {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::CloseFocused => {
|
Message::CloseFocused => {
|
||||||
if let Some(pane) = self.focus {
|
if let Some(pane) = self.focus
|
||||||
if let Some(Pane { is_pinned, .. }) = self.panes.get(pane) {
|
&& let Some(Pane { is_pinned, .. }) = self.panes.get(pane)
|
||||||
if !is_pinned {
|
&& !is_pinned
|
||||||
if let Some((_, sibling)) = self.panes.close(pane) {
|
&& let Some((_, sibling)) = self.panes.close(pane)
|
||||||
|
{
|
||||||
self.focus = Some(sibling);
|
self.focus = Some(sibling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn subscription(&self) -> Subscription<Message> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
keyboard::on_key_press(|key_code, modifiers| {
|
keyboard::on_key_press(|key_code, modifiers| {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
0e355b080ad33905145e9f70a3b29e2481197c8fc8f42491acd5358238ebbd5f
|
99f418007af163f172e163565f166da31015521e1bf7de95fa55cda2fb5a7db5
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
804a1bb6d49e3b3158463202960447d9e7820b967280f41dd0c34c00d3edf2c3
|
|
||||||
|
|
@ -116,12 +116,12 @@ impl WebSocket {
|
||||||
let mut button = button(text("Send").height(40).align_y(Center))
|
let mut button = button(text("Send").height(40).align_y(Center))
|
||||||
.padding([0, 20]);
|
.padding([0, 20]);
|
||||||
|
|
||||||
if matches!(self.state, State::Connected(_)) {
|
if matches!(self.state, State::Connected(_))
|
||||||
if let Some(message) = echo::Message::new(&self.new_message) {
|
&& let Some(message) = echo::Message::new(&self.new_message)
|
||||||
|
{
|
||||||
input = input.on_submit(Message::Send(message.clone()));
|
input = input.on_submit(Message::Send(message.clone()));
|
||||||
button = button.on_press(Message::Send(message));
|
button = button.on_press(Message::Send(message));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
row![input, button].spacing(10).align_y(Center)
|
row![input, button].spacing(10).align_y(Center)
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -321,12 +321,13 @@ impl editor::Editor for Editor {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Deselect if selection matches cursor position
|
// Deselect if selection matches cursor position
|
||||||
if let Some((start, end)) = editor.selection_bounds() {
|
if let Some((start, end)) = editor.selection_bounds()
|
||||||
if start.line == end.line && start.index == end.index {
|
&& start.line == end.line
|
||||||
|
&& start.index == end.index
|
||||||
|
{
|
||||||
editor.set_selection(cosmic_text::Selection::None);
|
editor.set_selection(cosmic_text::Selection::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Action::SelectWord => {
|
Action::SelectWord => {
|
||||||
let cursor = editor.cursor();
|
let cursor = editor.cursor();
|
||||||
|
|
||||||
|
|
@ -438,12 +439,13 @@ impl editor::Editor for Editor {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Deselect if selection matches cursor position
|
// Deselect if selection matches cursor position
|
||||||
if let Some((start, end)) = editor.selection_bounds() {
|
if let Some((start, end)) = editor.selection_bounds()
|
||||||
if start.line == end.line && start.index == end.index {
|
&& start.line == end.line
|
||||||
|
&& start.index == end.index
|
||||||
|
{
|
||||||
editor.set_selection(cosmic_text::Selection::None);
|
editor.set_selection(cosmic_text::Selection::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Action::Scroll { lines } => {
|
Action::Scroll { lines } => {
|
||||||
editor.action(
|
editor.action(
|
||||||
font_system.raw(),
|
font_system.raw(),
|
||||||
|
|
|
||||||
|
|
@ -99,11 +99,9 @@ impl Cache {
|
||||||
self.map.retain(|k, memory| {
|
self.map.retain(|k, memory| {
|
||||||
let retain = hits.contains(k);
|
let retain = hits.contains(k);
|
||||||
|
|
||||||
if !retain {
|
if !retain && let Memory::Device(entry) = memory {
|
||||||
if let Memory::Device(entry) = memory {
|
|
||||||
atlas.remove(entry);
|
atlas.remove(entry);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
retain
|
retain
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -320,13 +320,11 @@ where
|
||||||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||||
let mouse_over = cursor.is_over(layout.bounds());
|
let mouse_over = cursor.is_over(layout.bounds());
|
||||||
|
|
||||||
if mouse_over {
|
if mouse_over && let Some(on_toggle) = &self.on_toggle {
|
||||||
if let Some(on_toggle) = &self.on_toggle {
|
|
||||||
shell.publish((on_toggle)(!self.is_checked));
|
shell.publish((on_toggle)(!self.is_checked));
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -599,8 +599,8 @@ where
|
||||||
|
|
||||||
if is_focused {
|
if is_focused {
|
||||||
self.state.with_inner(|state| {
|
self.state.with_inner(|state| {
|
||||||
if !started_focused {
|
if !started_focused
|
||||||
if let Some(on_option_hovered) = &mut self.on_option_hovered
|
&& let Some(on_option_hovered) = &mut self.on_option_hovered
|
||||||
{
|
{
|
||||||
let hovered_option = menu.hovered_option.unwrap_or(0);
|
let hovered_option = menu.hovered_option.unwrap_or(0);
|
||||||
|
|
||||||
|
|
@ -611,7 +611,6 @@ where
|
||||||
published_message_to_shell = true;
|
published_message_to_shell = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Event::Keyboard(keyboard::Event::KeyPressed {
|
if let Event::Keyboard(keyboard::Event::KeyPressed {
|
||||||
key: keyboard::Key::Named(named_key),
|
key: keyboard::Key::Named(named_key),
|
||||||
|
|
@ -622,13 +621,12 @@ where
|
||||||
let shift_modifier = modifiers.shift();
|
let shift_modifier = modifiers.shift();
|
||||||
match (named_key, shift_modifier) {
|
match (named_key, shift_modifier) {
|
||||||
(key::Named::Enter, _) => {
|
(key::Named::Enter, _) => {
|
||||||
if let Some(index) = &menu.hovered_option {
|
if let Some(index) = &menu.hovered_option
|
||||||
if let Some(option) =
|
&& let Some(option) =
|
||||||
state.filtered_options.options.get(*index)
|
state.filtered_options.options.get(*index)
|
||||||
{
|
{
|
||||||
menu.new_selection = Some(option.clone());
|
menu.new_selection = Some(option.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
shell.request_redraw();
|
shell.request_redraw();
|
||||||
|
|
@ -650,8 +648,7 @@ where
|
||||||
|
|
||||||
if let Some(on_option_hovered) =
|
if let Some(on_option_hovered) =
|
||||||
&mut self.on_option_hovered
|
&mut self.on_option_hovered
|
||||||
{
|
&& let Some(option) =
|
||||||
if let Some(option) =
|
|
||||||
menu.hovered_option.and_then(|index| {
|
menu.hovered_option.and_then(|index| {
|
||||||
state
|
state
|
||||||
.filtered_options
|
.filtered_options
|
||||||
|
|
@ -665,7 +662,6 @@ where
|
||||||
));
|
));
|
||||||
published_message_to_shell = true;
|
published_message_to_shell = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
shell.request_redraw();
|
shell.request_redraw();
|
||||||
|
|
@ -698,8 +694,7 @@ where
|
||||||
|
|
||||||
if let Some(on_option_hovered) =
|
if let Some(on_option_hovered) =
|
||||||
&mut self.on_option_hovered
|
&mut self.on_option_hovered
|
||||||
{
|
&& let Some(option) =
|
||||||
if let Some(option) =
|
|
||||||
menu.hovered_option.and_then(|index| {
|
menu.hovered_option.and_then(|index| {
|
||||||
state
|
state
|
||||||
.filtered_options
|
.filtered_options
|
||||||
|
|
@ -713,7 +708,6 @@ where
|
||||||
));
|
));
|
||||||
published_message_to_shell = true;
|
published_message_to_shell = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
shell.request_redraw();
|
shell.request_redraw();
|
||||||
|
|
|
||||||
|
|
@ -377,8 +377,9 @@ fn update<Message: Clone, Theme, Renderer>(
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(position) = cursor_position {
|
if let Some(position) = cursor_position
|
||||||
if let Some(message) = widget.on_double_click.as_ref() {
|
&& let Some(message) = widget.on_double_click.as_ref()
|
||||||
|
{
|
||||||
let new_click = mouse::Click::new(
|
let new_click = mouse::Click::new(
|
||||||
position,
|
position,
|
||||||
mouse::Button::Left,
|
mouse::Button::Left,
|
||||||
|
|
@ -396,7 +397,6 @@ fn update<Message: Clone, Theme, Renderer>(
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
| Event::Touch(touch::Event::FingerLifted { .. }) => {
|
||||||
if let Some(message) = widget.on_release.as_ref() {
|
if let Some(message) = widget.on_release.as_ref() {
|
||||||
|
|
|
||||||
|
|
@ -407,15 +407,14 @@ where
|
||||||
) {
|
) {
|
||||||
match event {
|
match event {
|
||||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||||
if cursor.is_over(layout.bounds()) {
|
if cursor.is_over(layout.bounds())
|
||||||
if let Some(index) = *self.hovered_option {
|
&& let Some(index) = *self.hovered_option
|
||||||
if let Some(option) = self.options.get(index) {
|
&& let Some(option) = self.options.get(index)
|
||||||
|
{
|
||||||
shell.publish((self.on_selected)(option.clone()));
|
shell.publish((self.on_selected)(option.clone()));
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||||
if let Some(cursor_position) =
|
if let Some(cursor_position) =
|
||||||
cursor.position_in(layout.bounds())
|
cursor.position_in(layout.bounds())
|
||||||
|
|
@ -431,20 +430,17 @@ where
|
||||||
let new_hovered_option =
|
let new_hovered_option =
|
||||||
(cursor_position.y / option_height) as usize;
|
(cursor_position.y / option_height) as usize;
|
||||||
|
|
||||||
if *self.hovered_option != Some(new_hovered_option) {
|
if *self.hovered_option != Some(new_hovered_option)
|
||||||
if let Some(option) =
|
&& let Some(option) =
|
||||||
self.options.get(new_hovered_option)
|
self.options.get(new_hovered_option)
|
||||||
{
|
{
|
||||||
if let Some(on_option_hovered) =
|
if let Some(on_option_hovered) = self.on_option_hovered
|
||||||
self.on_option_hovered
|
|
||||||
{
|
{
|
||||||
shell
|
shell.publish(on_option_hovered(option.clone()));
|
||||||
.publish(on_option_hovered(option.clone()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.request_redraw();
|
shell.request_redraw();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*self.hovered_option = Some(new_hovered_option);
|
*self.hovered_option = Some(new_hovered_option);
|
||||||
}
|
}
|
||||||
|
|
@ -464,14 +460,14 @@ where
|
||||||
*self.hovered_option =
|
*self.hovered_option =
|
||||||
Some((cursor_position.y / option_height) as usize);
|
Some((cursor_position.y / option_height) as usize);
|
||||||
|
|
||||||
if let Some(index) = *self.hovered_option {
|
if let Some(index) = *self.hovered_option
|
||||||
if let Some(option) = self.options.get(index) {
|
&& let Some(option) = self.options.get(index)
|
||||||
|
{
|
||||||
shell.publish((self.on_selected)(option.clone()));
|
shell.publish((self.on_selected)(option.clone()));
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -593,11 +593,11 @@ where
|
||||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||||
| Event::Touch(touch::Event::FingerLifted { .. })
|
| Event::Touch(touch::Event::FingerLifted { .. })
|
||||||
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||||
if let Some((pane, origin)) = action.picked_pane() {
|
if let Some((pane, origin)) = action.picked_pane()
|
||||||
if let Some(on_drag) = on_drag {
|
&& let Some(on_drag) = on_drag
|
||||||
if let Some(cursor_position) = cursor.position() {
|
&& let Some(cursor_position) = cursor.position()
|
||||||
if cursor_position.distance(origin)
|
{
|
||||||
> DRAG_DEADBAND_DISTANCE
|
if cursor_position.distance(origin) > DRAG_DEADBAND_DISTANCE
|
||||||
{
|
{
|
||||||
let event = if let Some(edge) =
|
let event = if let Some(edge) =
|
||||||
in_edge(layout, cursor_position)
|
in_edge(layout, cursor_position)
|
||||||
|
|
@ -614,10 +614,7 @@ where
|
||||||
.zip(&self.contents)
|
.zip(&self.contents)
|
||||||
.zip(layout.children())
|
.zip(layout.children())
|
||||||
.find_map(|(target, layout)| {
|
.find_map(|(target, layout)| {
|
||||||
layout_region(
|
layout_region(layout, cursor_position)
|
||||||
layout,
|
|
||||||
cursor_position,
|
|
||||||
)
|
|
||||||
.map(|region| (target, region))
|
.map(|region| (target, region))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -627,9 +624,7 @@ where
|
||||||
{
|
{
|
||||||
DragEvent::Dropped {
|
DragEvent::Dropped {
|
||||||
pane,
|
pane,
|
||||||
target: Target::Pane(
|
target: Target::Pane(target, region),
|
||||||
target, region,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => DragEvent::Canceled { pane },
|
_ => DragEvent::Canceled { pane },
|
||||||
|
|
@ -638,11 +633,7 @@ where
|
||||||
|
|
||||||
shell.publish(on_drag(event));
|
shell.publish(on_drag(event));
|
||||||
} else {
|
} else {
|
||||||
shell.publish(on_drag(DragEvent::Canceled {
|
shell.publish(on_drag(DragEvent::Canceled { pane }));
|
||||||
pane,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -660,8 +651,9 @@ where
|
||||||
bounds.size(),
|
bounds.size(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some((axis, rectangle, _)) = splits.get(&split) {
|
if let Some((axis, rectangle, _)) = splits.get(&split)
|
||||||
if let Some(cursor_position) = cursor.position() {
|
&& let Some(cursor_position) = cursor.position()
|
||||||
|
{
|
||||||
let ratio = match axis {
|
let ratio = match axis {
|
||||||
Axis::Horizontal => {
|
Axis::Horizontal => {
|
||||||
let position = cursor_position.y
|
let position = cursor_position.y
|
||||||
|
|
@ -676,8 +668,7 @@ where
|
||||||
- bounds.x
|
- bounds.x
|
||||||
- rectangle.x;
|
- rectangle.x;
|
||||||
|
|
||||||
(position / rectangle.width)
|
(position / rectangle.width).clamp(0.0, 1.0)
|
||||||
.clamp(0.0, 1.0)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -688,7 +679,6 @@ where
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if action.picked_pane().is_some() {
|
} else if action.picked_pane().is_some() {
|
||||||
shell.request_redraw();
|
shell.request_redraw();
|
||||||
}
|
}
|
||||||
|
|
@ -889,14 +879,14 @@ where
|
||||||
viewport,
|
viewport,
|
||||||
);
|
);
|
||||||
|
|
||||||
if picked_pane.is_some() && pane_in_edge.is_none() {
|
if picked_pane.is_some()
|
||||||
if let Some(region) =
|
&& pane_in_edge.is_none()
|
||||||
|
&& let Some(region) =
|
||||||
cursor.position().and_then(|cursor_position| {
|
cursor.position().and_then(|cursor_position| {
|
||||||
layout_region(pane_layout, cursor_position)
|
layout_region(pane_layout, cursor_position)
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let bounds =
|
let bounds = layout_region_bounds(pane_layout, region);
|
||||||
layout_region_bounds(pane_layout, region);
|
|
||||||
|
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
renderer::Quad {
|
renderer::Quad {
|
||||||
|
|
@ -908,7 +898,6 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
content.draw(
|
content.draw(
|
||||||
tree,
|
tree,
|
||||||
|
|
@ -937,12 +926,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render picked pane last
|
// Render picked pane last
|
||||||
if let Some(((content, tree), origin, layout)) = render_picked_pane {
|
if let Some(((content, tree), origin, layout)) = render_picked_pane
|
||||||
if let Some(cursor_position) = cursor.position() {
|
&& let Some(cursor_position) = cursor.position()
|
||||||
|
{
|
||||||
let bounds = layout.bounds();
|
let bounds = layout.bounds();
|
||||||
|
|
||||||
let translation =
|
let translation = cursor_position - Point::new(origin.x, origin.y);
|
||||||
cursor_position - Point::new(origin.x, origin.y);
|
|
||||||
|
|
||||||
renderer.with_translation(translation, |renderer| {
|
renderer.with_translation(translation, |renderer| {
|
||||||
renderer.with_layer(bounds, |renderer| {
|
renderer.with_layer(bounds, |renderer| {
|
||||||
|
|
@ -958,10 +947,10 @@ where
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if picked_pane.is_none() {
|
if picked_pane.is_none()
|
||||||
if let Some((axis, split_region, is_picked)) = picked_split {
|
&& let Some((axis, split_region, is_picked)) = picked_split
|
||||||
|
{
|
||||||
let highlight = if is_picked {
|
let highlight = if is_picked {
|
||||||
style.picked_split
|
style.picked_split
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -982,8 +971,7 @@ where
|
||||||
},
|
},
|
||||||
Axis::Vertical => Rectangle {
|
Axis::Vertical => Rectangle {
|
||||||
x: (split_region.x
|
x: (split_region.x
|
||||||
+ (split_region.width - highlight.width)
|
+ (split_region.width - highlight.width) / 2.0)
|
||||||
/ 2.0)
|
|
||||||
.round(),
|
.round(),
|
||||||
y: split_region.y,
|
y: split_region.y,
|
||||||
width: highlight.width,
|
width: highlight.width,
|
||||||
|
|
@ -996,7 +984,6 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn overlay<'b>(
|
fn overlay<'b>(
|
||||||
&'b mut self,
|
&'b mut self,
|
||||||
|
|
@ -1086,8 +1073,9 @@ fn click_pane<'a, Message, T>(
|
||||||
shell.publish(on_click(pane));
|
shell.publish(on_click(pane));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(on_drag) = &on_drag {
|
if let Some(on_drag) = &on_drag
|
||||||
if content.can_be_dragged_at(layout, cursor_position) {
|
&& content.can_be_dragged_at(layout, cursor_position)
|
||||||
|
{
|
||||||
*action = state::Action::Dragging {
|
*action = state::Action::Dragging {
|
||||||
pane,
|
pane,
|
||||||
origin: cursor_position,
|
origin: cursor_position,
|
||||||
|
|
@ -1096,7 +1084,6 @@ fn click_pane<'a, Message, T>(
|
||||||
shell.publish(on_drag(DragEvent::Picked { pane }));
|
shell.publish(on_drag(DragEvent::Picked { pane }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_edge(layout: Layout<'_>, cursor: Point) -> Option<Edge> {
|
fn in_edge(layout: Layout<'_>, cursor: Point) -> Option<Edge> {
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,9 @@ impl<T> State<T> {
|
||||||
pane: Pane,
|
pane: Pane,
|
||||||
swap: bool,
|
swap: bool,
|
||||||
) {
|
) {
|
||||||
if let Some((state, _)) = self.close(pane) {
|
if let Some((state, _)) = self.close(pane)
|
||||||
if let Some((new_pane, _)) = self.split(axis, target, state) {
|
&& let Some((new_pane, _)) = self.split(axis, target, state)
|
||||||
|
{
|
||||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||||
self.relabel(new_pane, pane);
|
self.relabel(new_pane, pane);
|
||||||
|
|
||||||
|
|
@ -229,7 +230,6 @@ impl<T> State<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Move [`Pane`] to an [`Edge`] of the [`PaneGrid`].
|
/// Move [`Pane`] to an [`Edge`] of the [`PaneGrid`].
|
||||||
///
|
///
|
||||||
|
|
@ -257,15 +257,14 @@ impl<T> State<T> {
|
||||||
pane: Pane,
|
pane: Pane,
|
||||||
inverse: bool,
|
inverse: bool,
|
||||||
) {
|
) {
|
||||||
if let Some((state, _)) = self.close(pane) {
|
if let Some((state, _)) = self.close(pane)
|
||||||
if let Some((new_pane, _)) =
|
&& let Some((new_pane, _)) =
|
||||||
self.split_node(axis, None, state, inverse)
|
self.split_node(axis, None, state, inverse)
|
||||||
{
|
{
|
||||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||||
self.relabel(new_pane, pane);
|
self.relabel(new_pane, pane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn relabel(&mut self, target: Pane, label: Pane) {
|
fn relabel(&mut self, target: Pane, label: Pane) {
|
||||||
self.swap(target, label);
|
self.swap(target, label);
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,9 @@ where
|
||||||
let title_layout = children.next().unwrap();
|
let title_layout = children.next().unwrap();
|
||||||
let mut show_title = true;
|
let mut show_title = true;
|
||||||
|
|
||||||
if let Some(controls) = &self.controls {
|
if let Some(controls) = &self.controls
|
||||||
if show_controls || self.always_show_controls {
|
&& (show_controls || self.always_show_controls)
|
||||||
|
{
|
||||||
let controls_layout = children.next().unwrap();
|
let controls_layout = children.next().unwrap();
|
||||||
if title_layout.bounds().width + controls_layout.bounds().width
|
if title_layout.bounds().width + controls_layout.bounds().width
|
||||||
> padded.bounds().width
|
> padded.bounds().width
|
||||||
|
|
@ -217,7 +218,6 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if show_title {
|
if show_title {
|
||||||
self.content.as_widget().draw(
|
self.content.as_widget().draw(
|
||||||
|
|
|
||||||
|
|
@ -798,13 +798,12 @@ where
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if !had_input_method {
|
if !had_input_method
|
||||||
if let InputMethod::Enabled { position, .. } =
|
&& let InputMethod::Enabled { position, .. } =
|
||||||
shell.input_method_mut()
|
shell.input_method_mut()
|
||||||
{
|
{
|
||||||
*position = *position - translation;
|
*position = *position - translation;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
|
|
@ -1091,8 +1090,8 @@ where
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(scroller) = scrollbar.scroller {
|
if let Some(scroller) = scrollbar.scroller
|
||||||
if scroller.bounds.width > 0.0
|
&& scroller.bounds.width > 0.0
|
||||||
&& scroller.bounds.height > 0.0
|
&& scroller.bounds.height > 0.0
|
||||||
&& (style.scroller.color != Color::TRANSPARENT
|
&& (style.scroller.color != Color::TRANSPARENT
|
||||||
|| (style.scroller.border.color
|
|| (style.scroller.border.color
|
||||||
|
|
@ -1108,7 +1107,6 @@ where
|
||||||
style.scroller.color,
|
style.scroller.color,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
renderer.with_layer(
|
renderer.with_layer(
|
||||||
|
|
|
||||||
|
|
@ -127,11 +127,11 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if width == Length::Shrink {
|
if width == Length::Shrink
|
||||||
if let Some(first) = columns.first_mut() {
|
&& let Some(first) = columns.first_mut()
|
||||||
|
{
|
||||||
first.width = Length::Fill;
|
first.width = Length::Fill;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
columns,
|
columns,
|
||||||
|
|
|
||||||
|
|
@ -689,8 +689,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||||
if let Some(focus) = &mut state.focus {
|
if let Some(focus) = &mut state.focus
|
||||||
if focus.is_window_focused {
|
&& focus.is_window_focused
|
||||||
|
{
|
||||||
focus.now = *now;
|
focus.now = *now;
|
||||||
|
|
||||||
let millis_until_redraw =
|
let millis_until_redraw =
|
||||||
|
|
@ -700,13 +701,10 @@ where
|
||||||
|
|
||||||
shell.request_redraw_at(
|
shell.request_redraw_at(
|
||||||
focus.now
|
focus.now
|
||||||
+ Duration::from_millis(
|
+ Duration::from_millis(millis_until_redraw as u64),
|
||||||
millis_until_redraw as u64,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1247,13 +1247,13 @@ where
|
||||||
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
||||||
let state = state::<Renderer>(tree);
|
let state = state::<Renderer>(tree);
|
||||||
|
|
||||||
if state.is_focused.is_some() {
|
if state.is_focused.is_some()
|
||||||
if let keyboard::Key::Character("v") = key.as_ref() {
|
&& let keyboard::Key::Character("v") = key.as_ref()
|
||||||
|
{
|
||||||
state.is_pasting = None;
|
state.is_pasting = None;
|
||||||
|
|
||||||
shell.capture_event();
|
shell.capture_event();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
state.is_pasting = None;
|
state.is_pasting = None;
|
||||||
}
|
}
|
||||||
|
|
@ -1328,16 +1328,16 @@ where
|
||||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||||
let state = state::<Renderer>(tree);
|
let state = state::<Renderer>(tree);
|
||||||
|
|
||||||
if let Some(focus) = &mut state.is_focused {
|
if let Some(focus) = &mut state.is_focused
|
||||||
if focus.is_window_focused {
|
&& focus.is_window_focused
|
||||||
|
{
|
||||||
if matches!(
|
if matches!(
|
||||||
state.cursor.state(&self.value),
|
state.cursor.state(&self.value),
|
||||||
cursor::State::Index(_)
|
cursor::State::Index(_)
|
||||||
) {
|
) {
|
||||||
focus.now = *now;
|
focus.now = *now;
|
||||||
|
|
||||||
let millis_until_redraw =
|
let millis_until_redraw = CURSOR_BLINK_INTERVAL_MILLIS
|
||||||
CURSOR_BLINK_INTERVAL_MILLIS
|
|
||||||
- (*now - focus.updated_at).as_millis()
|
- (*now - focus.updated_at).as_millis()
|
||||||
% CURSOR_BLINK_INTERVAL_MILLIS;
|
% CURSOR_BLINK_INTERVAL_MILLIS;
|
||||||
|
|
||||||
|
|
@ -1355,7 +1355,6 @@ where
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ use window::WindowManager;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
|
use std::slice;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Runs a [`Program`] with the provided settings.
|
/// Runs a [`Program`] with the provided settings.
|
||||||
|
|
@ -652,13 +653,13 @@ async fn run_instance<P>(
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
|
|
||||||
for (_id, window) in window_manager.iter_mut() {
|
for (_id, window) in window_manager.iter_mut() {
|
||||||
if let Some(redraw_at) = window.redraw_at {
|
if let Some(redraw_at) = window.redraw_at
|
||||||
if redraw_at <= now {
|
&& redraw_at <= now
|
||||||
|
{
|
||||||
window.raw.request_redraw();
|
window.raw.request_redraw();
|
||||||
window.redraw_at = None;
|
window.redraw_at = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(redraw_at) = window_manager.redraw_at() {
|
if let Some(redraw_at) = window_manager.redraw_at() {
|
||||||
let _ =
|
let _ =
|
||||||
|
|
@ -760,7 +761,7 @@ async fn run_instance<P>(
|
||||||
|
|
||||||
let draw_span = debug::draw(id);
|
let draw_span = debug::draw(id);
|
||||||
let (ui_state, _) = ui.update(
|
let (ui_state, _) = ui.update(
|
||||||
&[redraw_event.clone()],
|
slice::from_ref(&redraw_event),
|
||||||
cursor,
|
cursor,
|
||||||
&mut window.renderer,
|
&mut window.renderer,
|
||||||
&mut clipboard,
|
&mut clipboard,
|
||||||
|
|
@ -1346,17 +1347,14 @@ fn run_action<'a, P, C>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window::Action::ShowSystemMenu(id) => {
|
window::Action::ShowSystemMenu(id) => {
|
||||||
if let Some(window) = window_manager.get_mut(id) {
|
if let Some(window) = window_manager.get_mut(id)
|
||||||
if let mouse::Cursor::Available(point) =
|
&& let mouse::Cursor::Available(point) =
|
||||||
window.state.cursor()
|
window.state.cursor()
|
||||||
{
|
{
|
||||||
window.raw.show_window_menu(
|
window.raw.show_window_menu(winit::dpi::LogicalPosition {
|
||||||
winit::dpi::LogicalPosition {
|
|
||||||
x: point.x,
|
x: point.x,
|
||||||
y: point.y,
|
y: point.y,
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window::Action::GetRawId(id, channel) => {
|
window::Action::GetRawId(id, channel) => {
|
||||||
|
|
@ -1375,8 +1373,9 @@ fn run_action<'a, P, C>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window::Action::Screenshot(id, channel) => {
|
window::Action::Screenshot(id, channel) => {
|
||||||
if let Some(window) = window_manager.get_mut(id) {
|
if let Some(window) = window_manager.get_mut(id)
|
||||||
if let Some(compositor) = compositor {
|
&& let Some(compositor) = compositor
|
||||||
|
{
|
||||||
let bytes = compositor.screenshot(
|
let bytes = compositor.screenshot(
|
||||||
&mut window.renderer,
|
&mut window.renderer,
|
||||||
window.state.viewport(),
|
window.state.viewport(),
|
||||||
|
|
@ -1390,7 +1389,6 @@ fn run_action<'a, P, C>(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
window::Action::EnableMousePassthrough(id) => {
|
window::Action::EnableMousePassthrough(id) => {
|
||||||
if let Some(window) = window_manager.get_mut(id) {
|
if let Some(window) = window_manager.get_mut(id) {
|
||||||
let _ = window.raw.set_cursor_hittest(false);
|
let _ = window.raw.set_cursor_hittest(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue