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-07 15:51:50 Functions: 100.0 % 2 2

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

Generated by: LCOV version 2.0-1