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:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
rust: [stable, beta, "1.85"]
|
||||
rust: [stable, beta, "1.88"]
|
||||
steps:
|
||||
- uses: hecrj/setup-rust-action@v2
|
||||
with:
|
||||
|
|
@ -23,5 +23,7 @@ jobs:
|
|||
sudo apt-get install -y libxkbcommon-dev libgtk-3-dev
|
||||
- name: Run tests
|
||||
run: |
|
||||
cargo test --verbose --workspace
|
||||
cargo test --verbose --workspace -- --ignored
|
||||
cargo test --verbose --workspace --all-features
|
||||
cargo test --verbose --workspace --all-features -- --ignored
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ repository = "https://github.com/iced-rs/iced"
|
|||
homepage = "https://iced.rs"
|
||||
categories = ["gui"]
|
||||
keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
||||
rust-version = "1.85"
|
||||
rust-version = "1.88"
|
||||
|
||||
[workspace.dependencies]
|
||||
iced = { version = "0.14.0-dev", path = "." }
|
||||
|
|
|
|||
|
|
@ -119,10 +119,10 @@ impl Editor {
|
|||
|
||||
let mut text = self.content.text();
|
||||
|
||||
if let Some(ending) = self.content.line_ending() {
|
||||
if !text.ends_with(ending.as_str()) {
|
||||
text.push_str(ending.as_str());
|
||||
}
|
||||
if let Some(ending) = self.content.line_ending()
|
||||
&& !text.ends_with(ending.as_str())
|
||||
{
|
||||
text.push_str(ending.as_str());
|
||||
}
|
||||
|
||||
Task::perform(
|
||||
|
|
|
|||
|
|
@ -71,11 +71,10 @@ impl Example {
|
|||
}
|
||||
}
|
||||
Message::FocusAdjacent(direction) => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||
{
|
||||
self.focus = Some(adjacent);
|
||||
}
|
||||
if let Some(pane) = self.focus
|
||||
&& let Some(adjacent) = self.panes.adjacent(pane, direction)
|
||||
{
|
||||
self.focus = Some(adjacent);
|
||||
}
|
||||
}
|
||||
Message::Clicked(pane) => {
|
||||
|
|
@ -106,14 +105,12 @@ impl Example {
|
|||
}
|
||||
}
|
||||
Message::CloseFocused => {
|
||||
if let Some(pane) = self.focus {
|
||||
if let Some(Pane { is_pinned, .. }) = self.panes.get(pane) {
|
||||
if !is_pinned {
|
||||
if let Some((_, sibling)) = self.panes.close(pane) {
|
||||
self.focus = Some(sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(pane) = self.focus
|
||||
&& let Some(Pane { is_pinned, .. }) = self.panes.get(pane)
|
||||
&& !is_pinned
|
||||
&& let Some((_, sibling)) = self.panes.close(pane)
|
||||
{
|
||||
self.focus = Some(sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
0e355b080ad33905145e9f70a3b29e2481197c8fc8f42491acd5358238ebbd5f
|
||||
99f418007af163f172e163565f166da31015521e1bf7de95fa55cda2fb5a7db5
|
||||
|
|
@ -1 +0,0 @@
|
|||
804a1bb6d49e3b3158463202960447d9e7820b967280f41dd0c34c00d3edf2c3
|
||||
|
|
@ -116,11 +116,11 @@ impl WebSocket {
|
|||
let mut button = button(text("Send").height(40).align_y(Center))
|
||||
.padding([0, 20]);
|
||||
|
||||
if matches!(self.state, State::Connected(_)) {
|
||||
if let Some(message) = echo::Message::new(&self.new_message) {
|
||||
input = input.on_submit(Message::Send(message.clone()));
|
||||
button = button.on_press(Message::Send(message));
|
||||
}
|
||||
if matches!(self.state, State::Connected(_))
|
||||
&& let Some(message) = echo::Message::new(&self.new_message)
|
||||
{
|
||||
input = input.on_submit(Message::Send(message.clone()));
|
||||
button = button.on_press(Message::Send(message));
|
||||
}
|
||||
|
||||
row![input, button].spacing(10).align_y(Center)
|
||||
|
|
|
|||
|
|
@ -321,10 +321,11 @@ impl editor::Editor for Editor {
|
|||
);
|
||||
|
||||
// Deselect if selection matches cursor position
|
||||
if let Some((start, end)) = editor.selection_bounds() {
|
||||
if start.line == end.line && start.index == end.index {
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
if let Some((start, end)) = editor.selection_bounds()
|
||||
&& start.line == end.line
|
||||
&& start.index == end.index
|
||||
{
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
}
|
||||
Action::SelectWord => {
|
||||
|
|
@ -438,10 +439,11 @@ impl editor::Editor for Editor {
|
|||
);
|
||||
|
||||
// Deselect if selection matches cursor position
|
||||
if let Some((start, end)) = editor.selection_bounds() {
|
||||
if start.line == end.line && start.index == end.index {
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
if let Some((start, end)) = editor.selection_bounds()
|
||||
&& start.line == end.line
|
||||
&& start.index == end.index
|
||||
{
|
||||
editor.set_selection(cosmic_text::Selection::None);
|
||||
}
|
||||
}
|
||||
Action::Scroll { lines } => {
|
||||
|
|
|
|||
|
|
@ -99,10 +99,8 @@ impl Cache {
|
|||
self.map.retain(|k, memory| {
|
||||
let retain = hits.contains(k);
|
||||
|
||||
if !retain {
|
||||
if let Memory::Device(entry) = memory {
|
||||
atlas.remove(entry);
|
||||
}
|
||||
if !retain && let Memory::Device(entry) = memory {
|
||||
atlas.remove(entry);
|
||||
}
|
||||
|
||||
retain
|
||||
|
|
|
|||
|
|
@ -320,11 +320,9 @@ where
|
|||
| Event::Touch(touch::Event::FingerPressed { .. }) => {
|
||||
let mouse_over = cursor.is_over(layout.bounds());
|
||||
|
||||
if mouse_over {
|
||||
if let Some(on_toggle) = &self.on_toggle {
|
||||
shell.publish((on_toggle)(!self.is_checked));
|
||||
shell.capture_event();
|
||||
}
|
||||
if mouse_over && let Some(on_toggle) = &self.on_toggle {
|
||||
shell.publish((on_toggle)(!self.is_checked));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -599,17 +599,16 @@ where
|
|||
|
||||
if is_focused {
|
||||
self.state.with_inner(|state| {
|
||||
if !started_focused {
|
||||
if let Some(on_option_hovered) = &mut self.on_option_hovered
|
||||
{
|
||||
let hovered_option = menu.hovered_option.unwrap_or(0);
|
||||
if !started_focused
|
||||
&& let Some(on_option_hovered) = &mut self.on_option_hovered
|
||||
{
|
||||
let hovered_option = menu.hovered_option.unwrap_or(0);
|
||||
|
||||
if let Some(option) =
|
||||
state.filtered_options.options.get(hovered_option)
|
||||
{
|
||||
shell.publish(on_option_hovered(option.clone()));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
if let Some(option) =
|
||||
state.filtered_options.options.get(hovered_option)
|
||||
{
|
||||
shell.publish(on_option_hovered(option.clone()));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -622,12 +621,11 @@ where
|
|||
let shift_modifier = modifiers.shift();
|
||||
match (named_key, shift_modifier) {
|
||||
(key::Named::Enter, _) => {
|
||||
if let Some(index) = &menu.hovered_option {
|
||||
if let Some(option) =
|
||||
if let Some(index) = &menu.hovered_option
|
||||
&& let Some(option) =
|
||||
state.filtered_options.options.get(*index)
|
||||
{
|
||||
menu.new_selection = Some(option.clone());
|
||||
}
|
||||
{
|
||||
menu.new_selection = Some(option.clone());
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
|
|
@ -650,21 +648,19 @@ where
|
|||
|
||||
if let Some(on_option_hovered) =
|
||||
&mut self.on_option_hovered
|
||||
{
|
||||
if let Some(option) =
|
||||
&& let Some(option) =
|
||||
menu.hovered_option.and_then(|index| {
|
||||
state
|
||||
.filtered_options
|
||||
.options
|
||||
.get(index)
|
||||
})
|
||||
{
|
||||
// Notify the selection
|
||||
shell.publish((on_option_hovered)(
|
||||
option.clone(),
|
||||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
{
|
||||
// Notify the selection
|
||||
shell.publish((on_option_hovered)(
|
||||
option.clone(),
|
||||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
|
|
@ -698,21 +694,19 @@ where
|
|||
|
||||
if let Some(on_option_hovered) =
|
||||
&mut self.on_option_hovered
|
||||
{
|
||||
if let Some(option) =
|
||||
&& let Some(option) =
|
||||
menu.hovered_option.and_then(|index| {
|
||||
state
|
||||
.filtered_options
|
||||
.options
|
||||
.get(index)
|
||||
})
|
||||
{
|
||||
// Notify the selection
|
||||
shell.publish((on_option_hovered)(
|
||||
option.clone(),
|
||||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
{
|
||||
// Notify the selection
|
||||
shell.publish((on_option_hovered)(
|
||||
option.clone(),
|
||||
));
|
||||
published_message_to_shell = true;
|
||||
}
|
||||
|
||||
shell.capture_event();
|
||||
|
|
|
|||
|
|
@ -377,24 +377,24 @@ fn update<Message: Clone, Theme, Renderer>(
|
|||
shell.capture_event();
|
||||
}
|
||||
|
||||
if let Some(position) = cursor_position {
|
||||
if let Some(message) = widget.on_double_click.as_ref() {
|
||||
let new_click = mouse::Click::new(
|
||||
position,
|
||||
mouse::Button::Left,
|
||||
state.previous_click,
|
||||
);
|
||||
if let Some(position) = cursor_position
|
||||
&& let Some(message) = widget.on_double_click.as_ref()
|
||||
{
|
||||
let new_click = mouse::Click::new(
|
||||
position,
|
||||
mouse::Button::Left,
|
||||
state.previous_click,
|
||||
);
|
||||
|
||||
if new_click.kind() == mouse::click::Kind::Double {
|
||||
shell.publish(message.clone());
|
||||
}
|
||||
|
||||
state.previous_click = Some(new_click);
|
||||
|
||||
// Even if this is not a double click, but the press is nevertheless
|
||||
// processed by us and should not be popup to parent widgets.
|
||||
shell.capture_event();
|
||||
if new_click.kind() == mouse::click::Kind::Double {
|
||||
shell.publish(message.clone());
|
||||
}
|
||||
|
||||
state.previous_click = Some(new_click);
|
||||
|
||||
// Even if this is not a double click, but the press is nevertheless
|
||||
// processed by us and should not be popup to parent widgets.
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
|
|
|
|||
|
|
@ -407,13 +407,12 @@ where
|
|||
) {
|
||||
match event {
|
||||
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) => {
|
||||
if cursor.is_over(layout.bounds()) {
|
||||
if let Some(index) = *self.hovered_option {
|
||||
if let Some(option) = self.options.get(index) {
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
if cursor.is_over(layout.bounds())
|
||||
&& let Some(index) = *self.hovered_option
|
||||
&& let Some(option) = self.options.get(index)
|
||||
{
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
Event::Mouse(mouse::Event::CursorMoved { .. }) => {
|
||||
|
|
@ -431,19 +430,16 @@ where
|
|||
let new_hovered_option =
|
||||
(cursor_position.y / option_height) as usize;
|
||||
|
||||
if *self.hovered_option != Some(new_hovered_option) {
|
||||
if let Some(option) =
|
||||
if *self.hovered_option != Some(new_hovered_option)
|
||||
&& let Some(option) =
|
||||
self.options.get(new_hovered_option)
|
||||
{
|
||||
if let Some(on_option_hovered) = self.on_option_hovered
|
||||
{
|
||||
if let Some(on_option_hovered) =
|
||||
self.on_option_hovered
|
||||
{
|
||||
shell
|
||||
.publish(on_option_hovered(option.clone()));
|
||||
}
|
||||
|
||||
shell.request_redraw();
|
||||
shell.publish(on_option_hovered(option.clone()));
|
||||
}
|
||||
|
||||
shell.request_redraw();
|
||||
}
|
||||
|
||||
*self.hovered_option = Some(new_hovered_option);
|
||||
|
|
@ -464,11 +460,11 @@ where
|
|||
*self.hovered_option =
|
||||
Some((cursor_position.y / option_height) as usize);
|
||||
|
||||
if let Some(index) = *self.hovered_option {
|
||||
if let Some(option) = self.options.get(index) {
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
if let Some(index) = *self.hovered_option
|
||||
&& let Some(option) = self.options.get(index)
|
||||
{
|
||||
shell.publish((self.on_selected)(option.clone()));
|
||||
shell.capture_event();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -593,56 +593,47 @@ where
|
|||
Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
|
||||
| Event::Touch(touch::Event::FingerLifted { .. })
|
||||
| Event::Touch(touch::Event::FingerLost { .. }) => {
|
||||
if let Some((pane, origin)) = action.picked_pane() {
|
||||
if let Some(on_drag) = on_drag {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
if cursor_position.distance(origin)
|
||||
> DRAG_DEADBAND_DISTANCE
|
||||
{
|
||||
let event = if let Some(edge) =
|
||||
in_edge(layout, cursor_position)
|
||||
if let Some((pane, origin)) = action.picked_pane()
|
||||
&& let Some(on_drag) = on_drag
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
if cursor_position.distance(origin) > DRAG_DEADBAND_DISTANCE
|
||||
{
|
||||
let event = if let Some(edge) =
|
||||
in_edge(layout, cursor_position)
|
||||
{
|
||||
DragEvent::Dropped {
|
||||
pane,
|
||||
target: Target::Edge(edge),
|
||||
}
|
||||
} else {
|
||||
let dropped_region = self
|
||||
.panes
|
||||
.iter()
|
||||
.copied()
|
||||
.zip(&self.contents)
|
||||
.zip(layout.children())
|
||||
.find_map(|(target, layout)| {
|
||||
layout_region(layout, cursor_position)
|
||||
.map(|region| (target, region))
|
||||
});
|
||||
|
||||
match dropped_region {
|
||||
Some(((target, _), region))
|
||||
if pane != target =>
|
||||
{
|
||||
DragEvent::Dropped {
|
||||
pane,
|
||||
target: Target::Edge(edge),
|
||||
target: Target::Pane(target, region),
|
||||
}
|
||||
} else {
|
||||
let dropped_region = self
|
||||
.panes
|
||||
.iter()
|
||||
.copied()
|
||||
.zip(&self.contents)
|
||||
.zip(layout.children())
|
||||
.find_map(|(target, layout)| {
|
||||
layout_region(
|
||||
layout,
|
||||
cursor_position,
|
||||
)
|
||||
.map(|region| (target, region))
|
||||
});
|
||||
|
||||
match dropped_region {
|
||||
Some(((target, _), region))
|
||||
if pane != target =>
|
||||
{
|
||||
DragEvent::Dropped {
|
||||
pane,
|
||||
target: Target::Pane(
|
||||
target, region,
|
||||
),
|
||||
}
|
||||
}
|
||||
_ => DragEvent::Canceled { pane },
|
||||
}
|
||||
};
|
||||
|
||||
shell.publish(on_drag(event));
|
||||
} else {
|
||||
shell.publish(on_drag(DragEvent::Canceled {
|
||||
pane,
|
||||
}));
|
||||
}
|
||||
_ => DragEvent::Canceled { pane },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
shell.publish(on_drag(event));
|
||||
} else {
|
||||
shell.publish(on_drag(DragEvent::Canceled { pane }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -660,34 +651,33 @@ where
|
|||
bounds.size(),
|
||||
);
|
||||
|
||||
if let Some((axis, rectangle, _)) = splits.get(&split) {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
let ratio = match axis {
|
||||
Axis::Horizontal => {
|
||||
let position = cursor_position.y
|
||||
- bounds.y
|
||||
- rectangle.y;
|
||||
if let Some((axis, rectangle, _)) = splits.get(&split)
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
let ratio = match axis {
|
||||
Axis::Horizontal => {
|
||||
let position = cursor_position.y
|
||||
- bounds.y
|
||||
- rectangle.y;
|
||||
|
||||
(position / rectangle.height)
|
||||
.clamp(0.0, 1.0)
|
||||
}
|
||||
Axis::Vertical => {
|
||||
let position = cursor_position.x
|
||||
- bounds.x
|
||||
- rectangle.x;
|
||||
(position / rectangle.height)
|
||||
.clamp(0.0, 1.0)
|
||||
}
|
||||
Axis::Vertical => {
|
||||
let position = cursor_position.x
|
||||
- bounds.x
|
||||
- rectangle.x;
|
||||
|
||||
(position / rectangle.width)
|
||||
.clamp(0.0, 1.0)
|
||||
}
|
||||
};
|
||||
(position / rectangle.width).clamp(0.0, 1.0)
|
||||
}
|
||||
};
|
||||
|
||||
shell.publish(on_resize(ResizeEvent {
|
||||
split,
|
||||
ratio,
|
||||
}));
|
||||
shell.publish(on_resize(ResizeEvent {
|
||||
split,
|
||||
ratio,
|
||||
}));
|
||||
|
||||
shell.capture_event();
|
||||
}
|
||||
shell.capture_event();
|
||||
}
|
||||
} else if action.picked_pane().is_some() {
|
||||
shell.request_redraw();
|
||||
|
|
@ -889,24 +879,23 @@ where
|
|||
viewport,
|
||||
);
|
||||
|
||||
if picked_pane.is_some() && pane_in_edge.is_none() {
|
||||
if let Some(region) =
|
||||
if picked_pane.is_some()
|
||||
&& pane_in_edge.is_none()
|
||||
&& let Some(region) =
|
||||
cursor.position().and_then(|cursor_position| {
|
||||
layout_region(pane_layout, cursor_position)
|
||||
})
|
||||
{
|
||||
let bounds =
|
||||
layout_region_bounds(pane_layout, region);
|
||||
{
|
||||
let bounds = layout_region_bounds(pane_layout, region);
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds,
|
||||
border: style.hovered_region.border,
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
style.hovered_region.background,
|
||||
);
|
||||
}
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds,
|
||||
border: style.hovered_region.border,
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
style.hovered_region.background,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
|
@ -937,64 +926,62 @@ where
|
|||
}
|
||||
|
||||
// Render picked pane last
|
||||
if let Some(((content, tree), origin, layout)) = render_picked_pane {
|
||||
if let Some(cursor_position) = cursor.position() {
|
||||
let bounds = layout.bounds();
|
||||
if let Some(((content, tree), origin, layout)) = render_picked_pane
|
||||
&& let Some(cursor_position) = cursor.position()
|
||||
{
|
||||
let bounds = layout.bounds();
|
||||
|
||||
let translation =
|
||||
cursor_position - Point::new(origin.x, origin.y);
|
||||
let translation = cursor_position - Point::new(origin.x, origin.y);
|
||||
|
||||
renderer.with_translation(translation, |renderer| {
|
||||
renderer.with_layer(bounds, |renderer| {
|
||||
content.draw(
|
||||
tree,
|
||||
renderer,
|
||||
theme,
|
||||
defaults,
|
||||
layout,
|
||||
pane_cursor,
|
||||
viewport,
|
||||
);
|
||||
});
|
||||
renderer.with_translation(translation, |renderer| {
|
||||
renderer.with_layer(bounds, |renderer| {
|
||||
content.draw(
|
||||
tree,
|
||||
renderer,
|
||||
theme,
|
||||
defaults,
|
||||
layout,
|
||||
pane_cursor,
|
||||
viewport,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if picked_pane.is_none() {
|
||||
if let Some((axis, split_region, is_picked)) = picked_split {
|
||||
let highlight = if is_picked {
|
||||
style.picked_split
|
||||
} else {
|
||||
style.hovered_split
|
||||
};
|
||||
if picked_pane.is_none()
|
||||
&& let Some((axis, split_region, is_picked)) = picked_split
|
||||
{
|
||||
let highlight = if is_picked {
|
||||
style.picked_split
|
||||
} else {
|
||||
style.hovered_split
|
||||
};
|
||||
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: match axis {
|
||||
Axis::Horizontal => Rectangle {
|
||||
x: split_region.x,
|
||||
y: (split_region.y
|
||||
+ (split_region.height - highlight.width)
|
||||
/ 2.0)
|
||||
.round(),
|
||||
width: split_region.width,
|
||||
height: highlight.width,
|
||||
},
|
||||
Axis::Vertical => Rectangle {
|
||||
x: (split_region.x
|
||||
+ (split_region.width - highlight.width)
|
||||
/ 2.0)
|
||||
.round(),
|
||||
y: split_region.y,
|
||||
width: highlight.width,
|
||||
height: split_region.height,
|
||||
},
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: match axis {
|
||||
Axis::Horizontal => Rectangle {
|
||||
x: split_region.x,
|
||||
y: (split_region.y
|
||||
+ (split_region.height - highlight.width)
|
||||
/ 2.0)
|
||||
.round(),
|
||||
width: split_region.width,
|
||||
height: highlight.width,
|
||||
},
|
||||
Axis::Vertical => Rectangle {
|
||||
x: (split_region.x
|
||||
+ (split_region.width - highlight.width) / 2.0)
|
||||
.round(),
|
||||
y: split_region.y,
|
||||
width: highlight.width,
|
||||
height: split_region.height,
|
||||
},
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
highlight.color,
|
||||
);
|
||||
}
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
highlight.color,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1086,15 +1073,15 @@ fn click_pane<'a, Message, T>(
|
|||
shell.publish(on_click(pane));
|
||||
}
|
||||
|
||||
if let Some(on_drag) = &on_drag {
|
||||
if content.can_be_dragged_at(layout, cursor_position) {
|
||||
*action = state::Action::Dragging {
|
||||
pane,
|
||||
origin: cursor_position,
|
||||
};
|
||||
if let Some(on_drag) = &on_drag
|
||||
&& content.can_be_dragged_at(layout, cursor_position)
|
||||
{
|
||||
*action = state::Action::Dragging {
|
||||
pane,
|
||||
origin: cursor_position,
|
||||
};
|
||||
|
||||
shell.publish(on_drag(DragEvent::Picked { pane }));
|
||||
}
|
||||
shell.publish(on_drag(DragEvent::Picked { pane }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,14 +219,14 @@ impl<T> State<T> {
|
|||
pane: Pane,
|
||||
swap: bool,
|
||||
) {
|
||||
if let Some((state, _)) = self.close(pane) {
|
||||
if let Some((new_pane, _)) = self.split(axis, target, state) {
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
if let Some((state, _)) = self.close(pane)
|
||||
&& let Some((new_pane, _)) = self.split(axis, target, state)
|
||||
{
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
|
||||
if swap {
|
||||
self.swap(target, pane);
|
||||
}
|
||||
if swap {
|
||||
self.swap(target, pane);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -257,13 +257,12 @@ impl<T> State<T> {
|
|||
pane: Pane,
|
||||
inverse: bool,
|
||||
) {
|
||||
if let Some((state, _)) = self.close(pane) {
|
||||
if let Some((new_pane, _)) =
|
||||
if let Some((state, _)) = self.close(pane)
|
||||
&& let Some((new_pane, _)) =
|
||||
self.split_node(axis, None, state, inverse)
|
||||
{
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
}
|
||||
{
|
||||
// Ensure new node corresponds to original closed `Pane` for state continuity
|
||||
self.relabel(new_pane, pane);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,38 +174,28 @@ where
|
|||
let title_layout = children.next().unwrap();
|
||||
let mut show_title = true;
|
||||
|
||||
if let Some(controls) = &self.controls {
|
||||
if show_controls || self.always_show_controls {
|
||||
let controls_layout = children.next().unwrap();
|
||||
if title_layout.bounds().width + controls_layout.bounds().width
|
||||
> padded.bounds().width
|
||||
{
|
||||
if let Some(compact) = controls.compact.as_ref() {
|
||||
let compact_layout = children.next().unwrap();
|
||||
if let Some(controls) = &self.controls
|
||||
&& (show_controls || self.always_show_controls)
|
||||
{
|
||||
let controls_layout = children.next().unwrap();
|
||||
if title_layout.bounds().width + controls_layout.bounds().width
|
||||
> padded.bounds().width
|
||||
{
|
||||
if let Some(compact) = controls.compact.as_ref() {
|
||||
let compact_layout = children.next().unwrap();
|
||||
|
||||
compact.as_widget().draw(
|
||||
&tree.children[2],
|
||||
renderer,
|
||||
theme,
|
||||
&inherited_style,
|
||||
compact_layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
} else {
|
||||
show_title = false;
|
||||
|
||||
controls.full.as_widget().draw(
|
||||
&tree.children[1],
|
||||
renderer,
|
||||
theme,
|
||||
&inherited_style,
|
||||
controls_layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
compact.as_widget().draw(
|
||||
&tree.children[2],
|
||||
renderer,
|
||||
theme,
|
||||
&inherited_style,
|
||||
compact_layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
} else {
|
||||
show_title = false;
|
||||
|
||||
controls.full.as_widget().draw(
|
||||
&tree.children[1],
|
||||
renderer,
|
||||
|
|
@ -216,6 +206,16 @@ where
|
|||
viewport,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
controls.full.as_widget().draw(
|
||||
&tree.children[1],
|
||||
renderer,
|
||||
theme,
|
||||
&inherited_style,
|
||||
controls_layout,
|
||||
cursor,
|
||||
viewport,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -798,12 +798,11 @@ where
|
|||
},
|
||||
);
|
||||
|
||||
if !had_input_method {
|
||||
if let InputMethod::Enabled { position, .. } =
|
||||
if !had_input_method
|
||||
&& let InputMethod::Enabled { position, .. } =
|
||||
shell.input_method_mut()
|
||||
{
|
||||
*position = *position - translation;
|
||||
}
|
||||
{
|
||||
*position = *position - translation;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1091,23 +1090,22 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(scroller) = scrollbar.scroller {
|
||||
if scroller.bounds.width > 0.0
|
||||
&& scroller.bounds.height > 0.0
|
||||
&& (style.scroller.color != Color::TRANSPARENT
|
||||
|| (style.scroller.border.color
|
||||
!= Color::TRANSPARENT
|
||||
&& style.scroller.border.width > 0.0))
|
||||
{
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: scroller.bounds,
|
||||
border: style.scroller.border,
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
style.scroller.color,
|
||||
);
|
||||
}
|
||||
if let Some(scroller) = scrollbar.scroller
|
||||
&& scroller.bounds.width > 0.0
|
||||
&& scroller.bounds.height > 0.0
|
||||
&& (style.scroller.color != Color::TRANSPARENT
|
||||
|| (style.scroller.border.color
|
||||
!= Color::TRANSPARENT
|
||||
&& style.scroller.border.width > 0.0))
|
||||
{
|
||||
renderer.fill_quad(
|
||||
renderer::Quad {
|
||||
bounds: scroller.bounds,
|
||||
border: style.scroller.border,
|
||||
..renderer::Quad::default()
|
||||
},
|
||||
style.scroller.color,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -127,10 +127,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if width == Length::Shrink {
|
||||
if let Some(first) = columns.first_mut() {
|
||||
first.width = Length::Fill;
|
||||
}
|
||||
if width == Length::Shrink
|
||||
&& let Some(first) = columns.first_mut()
|
||||
{
|
||||
first.width = Length::Fill;
|
||||
}
|
||||
|
||||
Self {
|
||||
|
|
|
|||
|
|
@ -689,22 +689,20 @@ where
|
|||
}
|
||||
}
|
||||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
if let Some(focus) = &mut state.focus {
|
||||
if focus.is_window_focused {
|
||||
focus.now = *now;
|
||||
if let Some(focus) = &mut state.focus
|
||||
&& focus.is_window_focused
|
||||
{
|
||||
focus.now = *now;
|
||||
|
||||
let millis_until_redraw =
|
||||
Focus::CURSOR_BLINK_INTERVAL_MILLIS
|
||||
- (focus.now - focus.updated_at).as_millis()
|
||||
% Focus::CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
let millis_until_redraw =
|
||||
Focus::CURSOR_BLINK_INTERVAL_MILLIS
|
||||
- (focus.now - focus.updated_at).as_millis()
|
||||
% Focus::CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
|
||||
shell.request_redraw_at(
|
||||
focus.now
|
||||
+ Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
);
|
||||
}
|
||||
shell.request_redraw_at(
|
||||
focus.now
|
||||
+ Duration::from_millis(millis_until_redraw as u64),
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -1247,12 +1247,12 @@ where
|
|||
Event::Keyboard(keyboard::Event::KeyReleased { key, .. }) => {
|
||||
let state = state::<Renderer>(tree);
|
||||
|
||||
if state.is_focused.is_some() {
|
||||
if let keyboard::Key::Character("v") = key.as_ref() {
|
||||
state.is_pasting = None;
|
||||
if state.is_focused.is_some()
|
||||
&& let keyboard::Key::Character("v") = key.as_ref()
|
||||
{
|
||||
state.is_pasting = None;
|
||||
|
||||
shell.capture_event();
|
||||
}
|
||||
shell.capture_event();
|
||||
}
|
||||
|
||||
state.is_pasting = None;
|
||||
|
|
@ -1328,32 +1328,31 @@ where
|
|||
Event::Window(window::Event::RedrawRequested(now)) => {
|
||||
let state = state::<Renderer>(tree);
|
||||
|
||||
if let Some(focus) = &mut state.is_focused {
|
||||
if focus.is_window_focused {
|
||||
if matches!(
|
||||
state.cursor.state(&self.value),
|
||||
cursor::State::Index(_)
|
||||
) {
|
||||
focus.now = *now;
|
||||
if let Some(focus) = &mut state.is_focused
|
||||
&& focus.is_window_focused
|
||||
{
|
||||
if matches!(
|
||||
state.cursor.state(&self.value),
|
||||
cursor::State::Index(_)
|
||||
) {
|
||||
focus.now = *now;
|
||||
|
||||
let millis_until_redraw =
|
||||
CURSOR_BLINK_INTERVAL_MILLIS
|
||||
- (*now - focus.updated_at).as_millis()
|
||||
% CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
let millis_until_redraw = CURSOR_BLINK_INTERVAL_MILLIS
|
||||
- (*now - focus.updated_at).as_millis()
|
||||
% CURSOR_BLINK_INTERVAL_MILLIS;
|
||||
|
||||
shell.request_redraw_at(
|
||||
*now + Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
shell.request_input_method(&self.input_method(
|
||||
state,
|
||||
layout,
|
||||
&self.value,
|
||||
));
|
||||
shell.request_redraw_at(
|
||||
*now + Duration::from_millis(
|
||||
millis_until_redraw as u64,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
shell.request_input_method(&self.input_method(
|
||||
state,
|
||||
layout,
|
||||
&self.value,
|
||||
));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ use window::WindowManager;
|
|||
use rustc_hash::FxHashMap;
|
||||
use std::borrow::Cow;
|
||||
use std::mem::ManuallyDrop;
|
||||
use std::slice;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Runs a [`Program`] with the provided settings.
|
||||
|
|
@ -652,11 +653,11 @@ async fn run_instance<P>(
|
|||
let now = Instant::now();
|
||||
|
||||
for (_id, window) in window_manager.iter_mut() {
|
||||
if let Some(redraw_at) = window.redraw_at {
|
||||
if redraw_at <= now {
|
||||
window.raw.request_redraw();
|
||||
window.redraw_at = None;
|
||||
}
|
||||
if let Some(redraw_at) = window.redraw_at
|
||||
&& redraw_at <= now
|
||||
{
|
||||
window.raw.request_redraw();
|
||||
window.redraw_at = None;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -760,7 +761,7 @@ async fn run_instance<P>(
|
|||
|
||||
let draw_span = debug::draw(id);
|
||||
let (ui_state, _) = ui.update(
|
||||
&[redraw_event.clone()],
|
||||
slice::from_ref(&redraw_event),
|
||||
cursor,
|
||||
&mut window.renderer,
|
||||
&mut clipboard,
|
||||
|
|
@ -1346,17 +1347,14 @@ fn run_action<'a, P, C>(
|
|||
}
|
||||
}
|
||||
window::Action::ShowSystemMenu(id) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
if let mouse::Cursor::Available(point) =
|
||||
if let Some(window) = window_manager.get_mut(id)
|
||||
&& let mouse::Cursor::Available(point) =
|
||||
window.state.cursor()
|
||||
{
|
||||
window.raw.show_window_menu(
|
||||
winit::dpi::LogicalPosition {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
},
|
||||
);
|
||||
}
|
||||
{
|
||||
window.raw.show_window_menu(winit::dpi::LogicalPosition {
|
||||
x: point.x,
|
||||
y: point.y,
|
||||
});
|
||||
}
|
||||
}
|
||||
window::Action::GetRawId(id, channel) => {
|
||||
|
|
@ -1375,20 +1373,20 @@ fn run_action<'a, P, C>(
|
|||
}
|
||||
}
|
||||
window::Action::Screenshot(id, channel) => {
|
||||
if let Some(window) = window_manager.get_mut(id) {
|
||||
if let Some(compositor) = compositor {
|
||||
let bytes = compositor.screenshot(
|
||||
&mut window.renderer,
|
||||
window.state.viewport(),
|
||||
window.state.background_color(),
|
||||
);
|
||||
if let Some(window) = window_manager.get_mut(id)
|
||||
&& let Some(compositor) = compositor
|
||||
{
|
||||
let bytes = compositor.screenshot(
|
||||
&mut window.renderer,
|
||||
window.state.viewport(),
|
||||
window.state.background_color(),
|
||||
);
|
||||
|
||||
let _ = channel.send(core::window::Screenshot::new(
|
||||
bytes,
|
||||
window.state.physical_size(),
|
||||
window.state.viewport().scale_factor(),
|
||||
));
|
||||
}
|
||||
let _ = channel.send(core::window::Screenshot::new(
|
||||
bytes,
|
||||
window.state.physical_size(),
|
||||
window.state.viewport().scale_factor(),
|
||||
));
|
||||
}
|
||||
}
|
||||
window::Action::EnableMousePassthrough(id) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue