fix: apply style of header only for headers

This commit is contained in:
Cyrix126 2024-12-13 17:01:52 +01:00
parent e76c0f72fc
commit 07e3b49338

View file

@ -19,11 +19,12 @@ pub fn header_tab(
one_line_center: bool,
) {
check_header_element(logo.is_none(), links.is_empty(), subtitle.is_none());
ui.add_space(SPACE);
ui.scope(|ui| {
ui.style_mut().wrap_mode = Some(TextWrapMode::Extend);
ui.style_mut().override_text_style = Some(TextStyle::Heading);
ui.add_space(SPACE);
if one_line_center {
ui.spacing_mut().item_spacing.x = 0.0;
if one_line_center {
let height_logo = 64.0;
let width_links = links
.iter()
@ -34,8 +35,8 @@ pub fn header_tab(
/ 2.0;
let nb_txt = links.len() + if subtitle.is_some() { 1 } else { 0 };
// width of separator depends of width of ui and number of texts
let width_separator = (ui.available_width() / ui.text_style_height(&TextStyle::Heading)
* 4.0)
let width_separator =
(ui.available_width() / ui.text_style_height(&TextStyle::Heading) * 4.0)
/ nb_txt as f32;
// width available - logo and separator - total width of txt - separator for each text then divided by two
let border_width = (((ui.available_width()
@ -55,14 +56,14 @@ pub fn header_tab(
if let Some(logo) = logo {
ui.add_sized([height_logo, height_logo], logo);
ui.add_sized(
[width_separator, height_logo],
[0.0, height_logo],
Separator::default().vertical().spacing(width_separator),
);
}
for (count, link) in links.iter().enumerate() {
ui.add_sized(
// [width_links[count], height_logo],
[0.0, height_logo],
[width_links[count], height_logo],
// [0.0, height_logo],
Hyperlink::from_label_and_url(link.0, link.1),
);
if count != (links.len() - 1) || subtitle.is_some() {
@ -92,5 +93,6 @@ pub fn header_tab(
}
});
}
});
ui.add_space(SPACE);
}