LCOV - code coverage report
Current view: top level - src/gui - gui_manager.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 100.0 % 2 2
Test Date: 2026-06-01 11:15:25 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "common.h"
       4              : #include "audio/engine/audio_engine.h"
       5              : #include "gui/commands/command_history.h"
       6              : #include "gui/state/snapshot_manager.h"
       7              : #include "gui/views/gui_settings.h"
       8              : #include "gui/views/gui_presets.h"
       9              : #include "gui/views/gui_recording.h"
      10              : #include "gui/views/gui_tuner.h"
      11              : #include "gui/views/gui_analyzer.h"
      12              : #include "gui/views/gui_snapshots.h"
      13              : #include "gui/views/gui_midi.h"
      14              : #include "midi/midi_manager.h"
      15              : #include <thread>
      16              : #include <mutex>
      17              : #include <string>
      18              : #include <memory>
      19              : 
      20              : struct SDL_Window;
      21              : typedef void* SDL_GLContext;
      22              : 
      23              : namespace Amplitron {
      24              : 
      25              : class PedalBoard;
      26              : class TunerPedal;
      27              : 
      28              : /**
      29              :  * @brief Top-level GUI controller — acts as the reactive root component.
      30              :  *
      31              :  * GuiManager owns the SDL window, OpenGL context, and Dear ImGui state.
      32              :  * It drives the main render loop, assembles Props from the AudioEngine, and
      33              :  * passes them down to each child UI component.  Mutations (callbacks from
      34              :  * children) are handled here, keeping all state-change logic in one place.
      35              :  *
      36              :  * UI concerns are delegated to focused reactive sub-modules:
      37              :  * - GuiSettings:  Audio device & latency settings
      38              :  * - GuiPresets:   Preset save/load/delete
      39              :  * - GuiRecording: Recording controls & waveform display
      40              :  * - GuiTuner:     Chromatic tuner modal
      41              :  * - GuiAnalyzer:  VU meters & spectrum analyzer
      42              :  * - GuiSnapshots: A/B/C/D board-state snapshots
      43              :  * - GuiMidi:      MIDI mapping & learn window
      44              :  */
      45              : class GuiManager {
      46              : public:
      47              :     GuiManager(AudioEngine& engine);
      48              :     ~GuiManager();
      49              : 
      50              :     bool initialize(int width = 1280, int height = 720);
      51              :     void shutdown();
      52              :     bool run_frame();
      53              : 
      54            6 :     MidiManager& midi_manager() { return midi_manager_; }
      55            3 :     AudioEngine& audio_engine() { return engine_; }
      56              :     CommandHistory& command_history() { return command_history_; }
      57              : 
      58              : private:
      59              :     // ── Menu bar ──
      60              :     void render_menu_bar();
      61              : 
      62              :     // ── Master controls strip ──
      63              :     void render_master_controls();
      64              : 
      65              :     // ── Prop-assembly helpers ──
      66              :     RecordingProps  build_recording_props();
      67              :     TunerProps      build_tuner_props();
      68              :     SettingsProps   build_settings_props();
      69              :     AnalyzerProps   build_analyzer_props();
      70              :     SnapshotsProps  build_snapshots_props();
      71              : 
      72              :     // ── Actions (called from child callbacks / keyboard shortcuts) ──
      73              :     void toggle_audio_mute_state();
      74              :     void set_show_tuner(bool show);
      75              :     void recallSnapshotFromSlot(int slot);
      76              : 
      77              :     // ─────────────────────────────────────────────────────────────────────
      78              :     // Core objects
      79              :     // ─────────────────────────────────────────────────────────────────────
      80              :     AudioEngine&   engine_;
      81              :     CommandHistory command_history_;
      82              : 
      83              :     SDL_Window*    window_     = nullptr;
      84              :     SDL_GLContext  gl_context_ = nullptr;
      85              : 
      86              :     std::unique_ptr<PedalBoard> pedal_board_;
      87              : 
      88              :     // Tuner pedal instance shared between engine tap and TunerProps assembly
      89              :     std::shared_ptr<TunerPedal> tuner_pedal_;
      90              : 
      91              :     bool initialized_      = false;
      92              :     int  window_width_     = 1280;
      93              :     int  window_height_    = 720;
      94              :     bool audio_muted_      = false;
      95              : 
      96              :     // ── Smoothed master level meters (computed in GuiManager, not in children) ──
      97              :     float smoothed_input_level_  = 0.0f;
      98              :     float smoothed_output_level_ = 0.0f;
      99              : 
     100              :     // ── Visibility flags (owned here, passed to child render calls) ──
     101              :     bool show_settings_      = false;
     102              :     bool show_save_preset_   = false;
     103              :     bool show_load_preset_   = false;
     104              :     bool show_tuner_         = false;
     105              :     bool show_midi_          = false;
     106              : 
     107              :     // ── Snapshot manager (state lives in GuiManager; GuiSnapshots is a pure view) ──
     108              :     SnapshotManager snapshot_manager_;
     109              : 
     110              :     // ── Reactive child components ──
     111              :     GuiSettings   gui_settings_;
     112              :     GuiPresets    gui_presets_;
     113              :     GuiRecording  gui_recording_;
     114              :     GuiTuner      gui_tuner_;
     115              :     GuiAnalyzer   gui_analyzer_;
     116              :     GuiSnapshots  gui_snapshots_;
     117              :     MidiManager   midi_manager_;
     118              :     GuiMidi       gui_midi_;
     119              : 
     120              :     // ── Toast notification ──
     121              :     std::string toast_message_;
     122              :     float       toast_timer_ = 0.0f;
     123              : 
     124              :     // ── Update checking ──
     125              :     void check_for_updates();
     126              :     std::thread update_check_thread_;
     127              :     std::mutex  update_mutex_;
     128              :     bool        has_new_release_     = false;
     129              :     std::string new_release_version_;
     130              :     std::string new_release_url_;
     131              : 
     132              :     // ── Waveform buffer (filled from recorder, passed to RecordingProps) ──
     133              :     float rec_waveform_buf_[512] = {};
     134              : };
     135              : 
     136              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1