refactor: option for customizing the border padding, instead of disabling the content container
This commit is contained in:
parent
ee5d965983
commit
9691870f72
2 changed files with 11 additions and 13 deletions
|
|
@ -625,21 +625,23 @@ impl<App: Application> ApplicationExt for App {
|
||||||
let content_container = core.window.content_container;
|
let content_container = core.window.content_container;
|
||||||
let show_context = core.window.show_context;
|
let show_context = core.window.show_context;
|
||||||
let nav_bar_active = core.nav_bar_active();
|
let nav_bar_active = core.nav_bar_active();
|
||||||
let transparent_header = core.window.transparent_header;
|
|
||||||
let focused = core
|
let focused = core
|
||||||
.focus_chain()
|
.focus_chain()
|
||||||
.iter()
|
.iter()
|
||||||
.any(|i| Some(*i) == self.core().main_window_id());
|
.any(|i| Some(*i) == core.main_window_id());
|
||||||
|
|
||||||
let border_padding = if maximized { 8 } else { 7 };
|
let border_padding = core
|
||||||
|
.window
|
||||||
|
.border_padding
|
||||||
|
.unwrap_or(if maximized { 8 } else { 7 });
|
||||||
|
|
||||||
let main_content_padding = if !content_container {
|
let main_content_padding = if content_container {
|
||||||
[0, 0, 0, 0]
|
|
||||||
} else {
|
|
||||||
let right_padding = if show_context { 0 } else { border_padding };
|
let right_padding = if show_context { 0 } else { border_padding };
|
||||||
let left_padding = if nav_bar_active { 0 } else { border_padding };
|
let left_padding = if nav_bar_active { 0 } else { border_padding };
|
||||||
|
|
||||||
[0, right_padding, 0, left_padding]
|
[0, right_padding, 0, left_padding]
|
||||||
|
} else {
|
||||||
|
[0, 0, 0, 0]
|
||||||
};
|
};
|
||||||
|
|
||||||
let content_row = crate::widget::row::with_children({
|
let content_row = crate::widget::row::with_children({
|
||||||
|
|
@ -834,11 +836,7 @@ impl<App: Application> ApplicationExt for App {
|
||||||
let cosmic = theme.cosmic();
|
let cosmic = theme.cosmic();
|
||||||
container::Style {
|
container::Style {
|
||||||
background: Some(iced::Background::Color(
|
background: Some(iced::Background::Color(
|
||||||
if transparent_header {
|
cosmic.background(theme.transparent).base.into(),
|
||||||
Color::TRANSPARENT
|
|
||||||
} else {
|
|
||||||
cosmic.background(theme.transparent).base.into()
|
|
||||||
},
|
|
||||||
)),
|
)),
|
||||||
border: iced::Border {
|
border: iced::Border {
|
||||||
radius: [
|
radius: [
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ pub struct Window {
|
||||||
pub show_close: bool,
|
pub show_close: bool,
|
||||||
pub show_maximize: bool,
|
pub show_maximize: bool,
|
||||||
pub show_minimize: bool,
|
pub show_minimize: bool,
|
||||||
pub transparent_header: bool,
|
|
||||||
pub is_maximized: bool,
|
pub is_maximized: bool,
|
||||||
|
pub border_padding: Option<u16>,
|
||||||
height: f32,
|
height: f32,
|
||||||
width: f32,
|
width: f32,
|
||||||
}
|
}
|
||||||
|
|
@ -170,9 +170,9 @@ impl Default for Core {
|
||||||
show_minimize: true,
|
show_minimize: true,
|
||||||
show_window_menu: false,
|
show_window_menu: false,
|
||||||
is_maximized: false,
|
is_maximized: false,
|
||||||
transparent_header: false,
|
|
||||||
height: 0.,
|
height: 0.,
|
||||||
width: 0.,
|
width: 0.,
|
||||||
|
border_padding: None,
|
||||||
},
|
},
|
||||||
focused_window: Vec::new(),
|
focused_window: Vec::new(),
|
||||||
#[cfg(feature = "applet")]
|
#[cfg(feature = "applet")]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue