refactor(gui): break down monolithic draw_footer into helper methods (#127)

Split the long continuous block in `draw_footer` into smaller,
modular methods (`draw_mic_selection`, `draw_master_volume`,
`draw_hotkeys_button`, `draw_settings_button`) for better
readability and maintainability.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Tarasov Aleksandr
2026-06-01 22:56:37 +03:00
committed by GitHub
parent 105be87222
commit 6841d8d1c3
+17 -11
View File
@@ -8,7 +8,17 @@ impl SoundpadGui {
pub fn draw_footer(&mut self, ui: &mut Ui) { pub fn draw_footer(&mut self, ui: &mut Ui) {
ui.add_space(5.0); ui.add_space(5.0);
ui.horizontal(|ui| { ui.horizontal(|ui| {
// ---------- Microphone selection ---------- self.draw_mic_selection(ui);
self.draw_master_volume(ui);
ui.add_space(ui.available_width() - 18.0 * 2.0 - ui.spacing().item_spacing.x * 2.0);
self.draw_hotkeys_button(ui);
self.draw_settings_button(ui);
});
}
fn draw_mic_selection(&mut self, ui: &mut Ui) {
let mics = &self.audio_player_state.all_inputs_sorted; let mics = &self.audio_player_state.all_inputs_sorted;
let mut selected_input = self.audio_player_state.current_input.to_owned(); let mut selected_input = self.audio_player_state.current_input.to_owned();
@@ -30,9 +40,9 @@ impl SoundpadGui {
if selected_input != prev_input { if selected_input != prev_input {
self.set_input(selected_input); self.set_input(selected_input);
} }
// -------------------------------- }
// ---------- Master Volume Slider ---------- fn draw_master_volume(&mut self, ui: &mut Ui) {
let volume_icon = Self::get_volume_icon(self.audio_player_state.volume); let volume_icon = Self::get_volume_icon(self.audio_player_state.volume);
let volume_label = Label::new(RichText::new(volume_icon).size(18.0)); let volume_label = Label::new(RichText::new(volume_icon).size(18.0));
ui.add_sized([18.0, 18.0], volume_label) ui.add_sized([18.0, 18.0], volume_label)
@@ -59,11 +69,9 @@ impl SoundpadGui {
if volume_slider_response.drag_stopped() { if volume_slider_response.drag_stopped() {
self.app_state.volume_dragged = true; self.app_state.volume_dragged = true;
} }
// ------------------------------------------ }
ui.add_space(ui.available_width() - 18.0 * 2.0 - ui.spacing().item_spacing.x * 2.0); fn draw_hotkeys_button(&mut self, ui: &mut Ui) {
// ---------- Hotkeys button ----------
let hotkeys_button = let hotkeys_button =
Button::new(ICON_KEYBOARD.atom_size(Vec2::new(18.0, 18.0))).frame(false); Button::new(ICON_KEYBOARD.atom_size(Vec2::new(18.0, 18.0))).frame(false);
let hotkeys_button_response = ui.add_sized([18.0, 18.0], hotkeys_button); let hotkeys_button_response = ui.add_sized([18.0, 18.0], hotkeys_button);
@@ -71,16 +79,14 @@ impl SoundpadGui {
self.app_state.show_hotkeys = true; self.app_state.show_hotkeys = true;
} }
hotkeys_button_response.on_hover_text("Hotkeys (H)"); hotkeys_button_response.on_hover_text("Hotkeys (H)");
// -------------------------------- }
// ---------- Settings button ---------- fn draw_settings_button(&mut self, ui: &mut Ui) {
let settings_button = let settings_button =
Button::new(ICON_SETTINGS.atom_size(Vec2::new(18.0, 18.0))).frame(false); Button::new(ICON_SETTINGS.atom_size(Vec2::new(18.0, 18.0))).frame(false);
let settings_button_response = ui.add_sized([18.0, 18.0], settings_button); let settings_button_response = ui.add_sized([18.0, 18.0], settings_button);
if settings_button_response.clicked() { if settings_button_response.clicked() {
self.app_state.show_settings = true; self.app_state.show_settings = true;
} }
// --------------------------------
});
} }
} }