Skip to content

Commit

Permalink
Fix warnings and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kelpsyberry committed Mar 30, 2024
1 parent 43640f0 commit ea98940
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
6 changes: 3 additions & 3 deletions frontend/desktop/src/ui/config_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ use crate::{
},
ui::{
utils::{
add2, combo_value, heading_options, heading_spacing, mul2s, sub2, sub2s,
add2, add_y_spacing, combo_value, heading, heading_options, mul2s, sub2, sub2s,
table_row_heading,
},
Config, EmuState,
Expand Down Expand Up @@ -1663,7 +1663,8 @@ with the Imgui title bar mode)
)]
);

heading_spacing(
add_y_spacing(ui, 8.0);
heading(
ui,
&if self.data.game_loaded {
format!("Game saves - {}", emu_state.as_deref().unwrap().title)
Expand All @@ -1673,7 +1674,6 @@ with the Imgui title bar mode)
16.0,
5.0,
BORDER_WIDTH,
8.0,
);
if self.data.game_loaded {
self.draw_game_saves_config(ui, config, emu_state.unwrap());
Expand Down
49 changes: 15 additions & 34 deletions frontend/desktop/src/ui/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ pub fn scale_to_fit_rotated(
)
}

pub fn add_y_spacing(ui: &Ui, spacing: f32) {
let mut cursor_pos = ui.cursor_screen_pos();
cursor_pos[1] += spacing;
ui.set_cursor_screen_pos(cursor_pos);
}

#[allow(clippy::too_many_arguments)]
pub fn heading_options_custom(
ui: &Ui,
Expand Down Expand Up @@ -249,29 +255,27 @@ pub fn table_row_heading(
);
}

pub fn heading_spacing(
#[allow(dead_code)]
pub fn heading_custom(
ui: &Ui,
text: &str,
text_indent: f32,
inner_indent: f32,
line_inner_margin: f32,
line_thickness: f32,
spacing: f32,
inner_height: f32,
draw: impl FnOnce(),
) {
let mut cursor_pos = ui.cursor_screen_pos();
cursor_pos[1] += spacing;
ui.set_cursor_screen_pos(cursor_pos);

heading_options(
heading_options_custom(
ui,
text,
text_indent,
inner_indent,
line_inner_margin,
0.0,
0.0,
line_thickness,
ui.content_region_avail()[0],
0.0,
inner_height,
false,
draw,
);
}

Expand All @@ -290,29 +294,6 @@ pub fn heading(ui: &Ui, text: &str, text_indent: f32, line_inner_margin: f32, li
);
}

pub fn heading_custom(
ui: &Ui,
inner_indent: f32,
line_inner_margin: f32,
line_thickness: f32,
inner_height: f32,
draw: impl FnOnce(),
) {
heading_options_custom(
ui,
inner_indent,
line_inner_margin,
0.0,
0.0,
line_thickness,
ui.content_region_avail()[0],
0.0,
inner_height,
false,
draw,
);
}

pub fn combo_value<T: PartialEq + Clone, L: for<'a> Fn(&'a T) -> Cow<'a, str>>(
ui: &Ui,
label: impl AsRef<str>,
Expand Down

0 comments on commit ea98940

Please sign in to comment.