nav_bar: allow setting close_icon and on_close
This commit is contained in:
parent
a0ed887b7d
commit
d138c86a11
1 changed files with 15 additions and 1 deletions
|
|
@ -12,7 +12,7 @@ use iced::{
|
|||
};
|
||||
use iced_core::{Border, Color, Shadow};
|
||||
|
||||
use crate::widget::{container, menu, scrollable, segmented_button, Container};
|
||||
use crate::widget::{container, menu, scrollable, segmented_button, Container, Icon};
|
||||
use crate::{theme, Theme};
|
||||
|
||||
use super::dnd_destination::DragId;
|
||||
|
|
@ -62,6 +62,11 @@ pub struct NavBar<'a, Message> {
|
|||
}
|
||||
|
||||
impl<'a, Message: Clone + 'static> NavBar<'a, Message> {
|
||||
pub fn close_icon(mut self, close_icon: Icon) -> Self {
|
||||
self.segmented_button = self.segmented_button.close_icon(close_icon);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn context_menu(mut self, context_menu: Option<Vec<menu::Tree<'a, Message>>>) -> Self {
|
||||
self.segmented_button = self.segmented_button.context_menu(context_menu);
|
||||
self
|
||||
|
|
@ -78,6 +83,15 @@ impl<'a, Message: Clone + 'static> NavBar<'a, Message> {
|
|||
Container::from(self)
|
||||
}
|
||||
|
||||
/// Emitted when a tab close button is pressed.
|
||||
pub fn on_close<T>(mut self, on_close: T) -> Self
|
||||
where
|
||||
T: Fn(Id) -> Message + 'static,
|
||||
{
|
||||
self.segmented_button = self.segmented_button.on_close(on_close);
|
||||
self
|
||||
}
|
||||
|
||||
/// Emitted when a button is right-clicked.
|
||||
pub fn on_context<T>(mut self, on_context: T) -> Self
|
||||
where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue