Add content_container flag to enable/disable wrapping content
This commit is contained in:
parent
18a5c67065
commit
b8f1a366dd
2 changed files with 42 additions and 34 deletions
|
|
@ -26,6 +26,7 @@ pub struct Window {
|
|||
/// Label to display as header bar title.
|
||||
pub header_title: String,
|
||||
pub use_template: bool,
|
||||
pub content_container: bool,
|
||||
pub can_fullscreen: bool,
|
||||
pub sharp_corners: bool,
|
||||
pub show_context: bool,
|
||||
|
|
@ -98,6 +99,7 @@ impl Default for Core {
|
|||
context_title: String::new(),
|
||||
header_title: String::new(),
|
||||
use_template: true,
|
||||
content_container: true,
|
||||
can_fullscreen: false,
|
||||
sharp_corners: false,
|
||||
show_context: false,
|
||||
|
|
|
|||
|
|
@ -578,6 +578,45 @@ impl<App: Application> ApplicationExt for App {
|
|||
let core = self.core();
|
||||
let is_condensed = core.is_condensed();
|
||||
|
||||
let content_row = crate::widget::row::with_children({
|
||||
let mut widgets = Vec::with_capacity(2);
|
||||
|
||||
// Insert nav bar onto the left side of the window.
|
||||
if let Some(nav) = self.nav_bar() {
|
||||
widgets.push(nav.debug(core.debug));
|
||||
}
|
||||
|
||||
if self.nav_model().is_none() || core.show_content() {
|
||||
let main_content = self.view().debug(core.debug).map(Message::App);
|
||||
|
||||
widgets.push(if let Some(context) = self.context_drawer() {
|
||||
context_drawer(
|
||||
&core.window.context_title,
|
||||
Message::Cosmic(cosmic::Message::ContextDrawer(false)),
|
||||
main_content,
|
||||
context.map(Message::App),
|
||||
)
|
||||
.into()
|
||||
} else {
|
||||
main_content
|
||||
});
|
||||
}
|
||||
|
||||
widgets
|
||||
})
|
||||
.spacing(8);
|
||||
let content: Element<_> = if core.window.content_container {
|
||||
content_row
|
||||
.apply(crate::widget::container)
|
||||
.padding([0, 8, 8, 8])
|
||||
.width(iced::Length::Fill)
|
||||
.height(iced::Length::Fill)
|
||||
.style(crate::theme::Container::Background)
|
||||
.into()
|
||||
} else {
|
||||
content_row.into()
|
||||
};
|
||||
|
||||
crate::widget::column::with_capacity(2)
|
||||
.push_maybe(if core.window.show_headerbar {
|
||||
Some({
|
||||
|
|
@ -624,40 +663,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
None
|
||||
})
|
||||
// The content element contains every element beneath the header.
|
||||
.push(
|
||||
crate::widget::row::with_children({
|
||||
let mut widgets = Vec::with_capacity(2);
|
||||
|
||||
// Insert nav bar onto the left side of the window.
|
||||
if let Some(nav) = self.nav_bar() {
|
||||
widgets.push(nav.debug(core.debug));
|
||||
}
|
||||
|
||||
if self.nav_model().is_none() || core.show_content() {
|
||||
let main_content = self.view().debug(core.debug).map(Message::App);
|
||||
|
||||
widgets.push(if let Some(context) = self.context_drawer() {
|
||||
context_drawer(
|
||||
&core.window.context_title,
|
||||
Message::Cosmic(cosmic::Message::ContextDrawer(false)),
|
||||
main_content,
|
||||
context.map(Message::App),
|
||||
)
|
||||
.into()
|
||||
} else {
|
||||
main_content
|
||||
});
|
||||
}
|
||||
|
||||
widgets
|
||||
})
|
||||
.spacing(8)
|
||||
.apply(crate::widget::container)
|
||||
.padding([0, 8, 8, 8])
|
||||
.width(iced::Length::Fill)
|
||||
.height(iced::Length::Fill)
|
||||
.style(crate::theme::Container::Background),
|
||||
)
|
||||
.push(content)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue