Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
sudo apt-get install -y libxkbcommon-dev
- name: Run tests
run: |
cargo test --verbose --all --lib
cargo test --verbose --all --all-features --lib
cargo test --verbose --all --lib --tests --bins
cargo test --verbose --all --all-features --lib --tests --bins

todo_windows:
name: Windows Checks
Expand All @@ -35,8 +35,8 @@ jobs:
- uses: actions/checkout@master
- name: Run tests
run: |
cargo test --verbose --all --lib
cargo test --verbose --all --all-features --lib
cargo test --verbose --all --lib --tests --bins
cargo test --verbose --all --all-features --lib --tests --bins

todo_macos:
name: Mac OS Checks
Expand All @@ -51,5 +51,5 @@ jobs:
- uses: actions/checkout@master
- name: Run tests
run: |
cargo test --verbose --all --lib
cargo test --verbose --all --all-features --lib
cargo test --verbose --all --lib --tests --bins
cargo test --verbose --all --all-features --lib --tests --bins
5 changes: 4 additions & 1 deletion src/widget/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ where
operation.traverse(&mut |operation| {
self.content.as_widget_mut().operate(
&mut tree.children[0],
layout.children().next().unwrap(),
layout
.children()
.next()
.expect("Badge layout should have a content child"),
renderer,
operation,
);
Expand Down
99 changes: 50 additions & 49 deletions src/widget/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ where
fn layout(&mut self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node {
let limits = limits.max_width(self.max_width).max_height(self.max_height);

let close_button_tree_index = 2 + if self.foot.is_some() { 1 } else { 0 };
let close_button_tree_index = 2 + usize::from(self.foot.is_some());

let head_node = head_node(
renderer,
Expand Down Expand Up @@ -395,20 +395,20 @@ where
);

// Update close button if present
if let Some(close_layout) = head_children.next() {
if let Some(close_button) = self.close_button.as_mut() {
let close_button_tree_index = 2 + if self.foot.is_some() { 1 } else { 0 };
close_button.as_widget_mut().update(
&mut state.children[close_button_tree_index],
event,
close_layout,
cursor,
renderer,
clipboard,
shell,
viewport,
);
}
if let Some((close_layout, close_button)) =
head_children.next().zip(self.close_button.as_mut())
{
let close_button_tree_index = 2 + usize::from(self.foot.is_some());
close_button.as_widget_mut().update(
&mut state.children[close_button_tree_index],
event,
close_layout,
cursor,
renderer,
clipboard,
shell,
viewport,
);
}

let body_layout = children
Expand Down Expand Up @@ -551,16 +551,16 @@ where
}

// Operate on close button if present (second child of head_layout)
if let Some(close_layout) = head_children.next() {
if let Some(close_button) = self.close_button.as_mut() {
let close_button_tree_index = 2 + if self.foot.is_some() { 1 } else { 0 };
close_button.as_widget_mut().operate(
&mut state.children[close_button_tree_index],
close_layout,
renderer,
operation,
);
}
if let Some((close_layout, close_button)) =
head_children.next().zip(self.close_button.as_mut())
{
let close_button_tree_index = 2 + usize::from(self.foot.is_some());
close_button.as_widget_mut().operate(
&mut state.children[close_button_tree_index],
close_layout,
renderer,
operation,
);
}

// Operate on body (body_layout contains a child with the actual body content)
Expand All @@ -574,15 +574,15 @@ where
}

// Operate on footer if present (foot_layout contains a child with the actual foot content)
if let Some(footer) = &mut self.foot {
if let Some(foot_content_layout) = foot_layout.children().next() {
footer.as_widget_mut().operate(
&mut state.children[2],
foot_content_layout,
renderer,
operation,
);
}
if let Some((footer, foot_content_layout)) =
self.foot.as_mut().zip(foot_layout.children().next())
{
footer.as_widget_mut().operate(
&mut state.children[2],
foot_content_layout,
renderer,
operation,
);
}
}

Expand Down Expand Up @@ -637,7 +637,7 @@ where
let head_layout = children
.next()
.expect("Graphics: Layout should have a head layout");
let close_button_tree_index = 2 + if self.foot.is_some() { 1 } else { 0 };
let close_button_tree_index = 2 + usize::from(self.foot.is_some());
draw_head(
&state.children[0],
renderer,
Expand Down Expand Up @@ -935,20 +935,21 @@ fn draw_head<Message, Theme, Renderer>(
);

// Draw close button if present
if let Some(close_layout) = head_children.next() {
if let Some((close_btn, close_state)) = close_button.zip(close_button_state) {
close_btn.as_widget().draw(
close_state,
renderer,
theme,
&renderer::Style {
text_color: style.close_color,
},
close_layout,
cursor,
viewport,
);
}
if let Some((close_layout, (close_btn, close_state))) = head_children
.next()
.zip(close_button.zip(close_button_state))
{
close_btn.as_widget().draw(
close_state,
renderer,
theme,
&renderer::Style {
text_color: style.close_color,
},
close_layout,
cursor,
viewport,
);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/widget/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ mod tests {
use chrono::Datelike;

#[derive(Clone, Debug)]
#[allow(dead_code)]
enum TestMessage {
Cancel,
Submit(Date),
Expand Down
14 changes: 10 additions & 4 deletions src/widget/menu/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ pub(super) fn schedule_close_on_click<
items: &mut [Item<'a, Message, Theme, Renderer>],
slice_layout: impl Iterator<Item = Layout<'b>>,
cursor: mouse::Cursor,
menu_coic: Option<bool>,
menu_cobc: Option<bool>,
menu_close_on_item_click: Option<bool>,
menu_close_on_background_click: Option<bool>,
) {
global_state.clear_task();

Expand All @@ -273,7 +273,10 @@ pub(super) fn schedule_close_on_click<
global_state.schedule(MenuBarTask::CloseOnClick);
}
}
for cocfb in [menu_coic, Some(global_parameters.close_on_item_click)] {
for cocfb in [
menu_close_on_item_click,
Some(global_parameters.close_on_item_click),
] {
if let (false, Some(coc)) = (coc_handled, cocfb) {
coc_handled = true;
if coc {
Expand All @@ -285,7 +288,10 @@ pub(super) fn schedule_close_on_click<
}
}

for cocfb in [menu_cobc, Some(global_parameters.close_on_background_click)] {
for cocfb in [
menu_close_on_background_click,
Some(global_parameters.close_on_background_click),
] {
if let (false, Some(coc)) = (coc_handled, cocfb) {
coc_handled = true;
if coc {
Expand Down
14 changes: 4 additions & 10 deletions src/widget/menu/menu_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,10 @@ where
let active_bounds = slice_layout
.children()
.nth(active_in_slice)
.unwrap_or_else(|| {
panic!(
"Index {:?} (in slice space) is not within the menu bar layout \
| slice_layout.children().count(): {:?} \
| This should not happen, please report this issue
",
active_in_slice,
slice_layout.children().count()
)
})
.expect(
"Index (in slice space) is not within the menu bar layout. \
This should not happen, please report this issue",
)
.bounds();

renderer.fill_quad(
Expand Down
18 changes: 9 additions & 9 deletions src/widget/menu/menu_bar_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,10 @@ where
let next_parent_bounds = slice_layout
.children()
.nth(active_in_slice)
.unwrap_or_else(|| panic!("Index {:?} (in slice space) is not within the slice layout \
| slice_layout.children().count(): {:?} \
| This should not happen, please report this issue
",
active_in_slice,
slice_layout.children().count()))
.expect(
"Index (in slice space) is not within the slice layout. \
This should not happen, please report this issue"
)
.bounds();

rec(
Expand Down Expand Up @@ -760,7 +758,7 @@ where
let mut overlays = vec![];
let mut next = None;

let slice_layout = self.layout.children().next().unwrap();
let slice_layout = self.layout.children().next()?;

for (i, ((item, item_tree), item_layout)) in itl_iter_slice_enum!(
slice,
Expand All @@ -780,8 +778,10 @@ where
continue;
};

if i == active {
next = Some((item_menu.as_mut().unwrap(), item_menu_tree));
if i == active
&& let Some(menu) = item_menu.as_mut()
{
next = Some((menu, item_menu_tree));
}
if let Some(overlay) = item_widget.as_widget_mut().overlay(
item_widget_tree,
Expand Down
24 changes: 8 additions & 16 deletions src/widget/menu/menu_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,10 @@ where
let center = slice_layout
.children()
.nth(active_in_slice)
.unwrap_or_else(|| panic!(" Index {:?} (in slice space) is not within the slice layout \
| slice_layout.children().count(): {:?} \
| This should not happen, please report this issue
",
active_in_slice,
slice_layout.children().count()))
.expect(
"Index (in slice space) is not within the slice layout. \
This should not happen, please report this issue",
)
.bounds()
.center();
mouse::Cursor::Available(center)
Expand Down Expand Up @@ -705,16 +703,10 @@ where
let active_bounds = slice_layout
.children()
.nth(active_in_slice)
.unwrap_or_else(|| {
panic!(
"Index {:?} (in slice space) is not within the slice layout \
| slice_layout.children().count(): {:?} \
| This should not happen, please report this issue
",
active_in_slice,
slice_layout.children().count()
)
})
.expect(
"Index (in slice space) is not within the slice layout. \
This should not happen, please report this issue",
)
.bounds();

renderer.fill_quad(
Expand Down
Loading