mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2024-12-22 14:49:21 +00:00
fix: apply style of header only for headers
This commit is contained in:
parent
e76c0f72fc
commit
07e3b49338
1 changed files with 68 additions and 66 deletions
|
@ -19,11 +19,12 @@ pub fn header_tab(
|
||||||
one_line_center: bool,
|
one_line_center: bool,
|
||||||
) {
|
) {
|
||||||
check_header_element(logo.is_none(), links.is_empty(), subtitle.is_none());
|
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().wrap_mode = Some(TextWrapMode::Extend);
|
||||||
ui.style_mut().override_text_style = Some(TextStyle::Heading);
|
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;
|
ui.spacing_mut().item_spacing.x = 0.0;
|
||||||
|
if one_line_center {
|
||||||
let height_logo = 64.0;
|
let height_logo = 64.0;
|
||||||
let width_links = links
|
let width_links = links
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -34,8 +35,8 @@ pub fn header_tab(
|
||||||
/ 2.0;
|
/ 2.0;
|
||||||
let nb_txt = links.len() + if subtitle.is_some() { 1 } else { 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
|
// width of separator depends of width of ui and number of texts
|
||||||
let width_separator = (ui.available_width() / ui.text_style_height(&TextStyle::Heading)
|
let width_separator =
|
||||||
* 4.0)
|
(ui.available_width() / ui.text_style_height(&TextStyle::Heading) * 4.0)
|
||||||
/ nb_txt as f32;
|
/ nb_txt as f32;
|
||||||
// width available - logo and separator - total width of txt - separator for each text then divided by two
|
// width available - logo and separator - total width of txt - separator for each text then divided by two
|
||||||
let border_width = (((ui.available_width()
|
let border_width = (((ui.available_width()
|
||||||
|
@ -55,14 +56,14 @@ pub fn header_tab(
|
||||||
if let Some(logo) = logo {
|
if let Some(logo) = logo {
|
||||||
ui.add_sized([height_logo, height_logo], logo);
|
ui.add_sized([height_logo, height_logo], logo);
|
||||||
ui.add_sized(
|
ui.add_sized(
|
||||||
[width_separator, height_logo],
|
[0.0, height_logo],
|
||||||
Separator::default().vertical().spacing(width_separator),
|
Separator::default().vertical().spacing(width_separator),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (count, link) in links.iter().enumerate() {
|
for (count, link) in links.iter().enumerate() {
|
||||||
ui.add_sized(
|
ui.add_sized(
|
||||||
// [width_links[count], height_logo],
|
[width_links[count], height_logo],
|
||||||
[0.0, height_logo],
|
// [0.0, height_logo],
|
||||||
Hyperlink::from_label_and_url(link.0, link.1),
|
Hyperlink::from_label_and_url(link.0, link.1),
|
||||||
);
|
);
|
||||||
if count != (links.len() - 1) || subtitle.is_some() {
|
if count != (links.len() - 1) || subtitle.is_some() {
|
||||||
|
@ -92,5 +93,6 @@ pub fn header_tab(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
ui.add_space(SPACE);
|
ui.add_space(SPACE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue