LCOV - code coverage report
Current view: top level - src/gui - gui_manager.cpp (source / functions) Coverage Total Hit
Test: merged.info Lines: 45.0 % 40 18
Test Date: 2026-06-07 15:51:50 Functions: 75.0 % 4 3

            Line data    Source code
       1              : #include "gui/gui_manager.h"
       2              : 
       3              : #include <SDL2/SDL.h>
       4              : #include <imgui.h>
       5              : #include <imgui_impl_opengl3.h>
       6              : #include <imgui_impl_sdl2.h>
       7              : 
       8              : #include <algorithm>
       9              : #include <cmath>
      10              : #include <cstdio>
      11              : #include <cstring>
      12              : #include <iostream>
      13              : 
      14              : #include "amplitron_session.h"
      15              : #include "gui/commands/command.h"
      16              : #include "gui/dialogs/file_dialog.h"
      17              : #include "gui/gl_setup.h"
      18              : #include "gui/pedalboard/pedal_board.h"
      19              : #include "gui/state/gui_graph_state.h"
      20              : #include "gui/theme/theme.h"
      21              : #include "preset_manager.h"
      22              : #if defined(__APPLE__)
      23              : #include <TargetConditionals.h>
      24              : #endif
      25              : #if defined(EMSCRIPTEN) || (defined(__APPLE__) && TARGET_OS_IOS)
      26              : #define AMPLITRON_NO_DESKTOP_SHELL 1
      27              : #endif
      28              : #ifdef __EMSCRIPTEN__
      29              : #include <emscripten.h>
      30              : #endif
      31              : 
      32              : #pragma GCC diagnostic push
      33              : #if defined(__GNUC__) && !defined(__clang__)
      34              : #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
      35              : #endif
      36              : #pragma GCC diagnostic pop
      37              : 
      38              : namespace Amplitron {
      39              : 
      40           25 : GuiManager::GuiManager(AmplitronSession& session)
      41           20 :     : session_(session),
      42           15 :       engine_(session.engine()),
      43           15 :       command_history_(session.command_history()),
      44           15 :       midi_manager_(session.midi()),
      45           15 :       snapshot_manager_(session.snapshot_manager()),
      46           10 :       tuner_pedal_(std::make_shared<TunerPedal>()),
      47           10 :       gui_presets_(engine_, command_history_, session.presets()),
      48           25 :       gui_midi_(midi_manager_) {
      49           15 :     pedal_board_ = std::make_unique<PedalBoard>(engine_, command_history_, &gui_midi_);
      50           15 :     gui_presets_.set_pedal_board(pedal_board_.get());
      51           15 :     gui_presets_.set_midi_manager(&midi_manager_);
      52           15 :     gui_analyzer_.set_expanded(engine_.is_analyzer_enabled());
      53           15 : }
      54              : 
      55           25 : GuiManager::~GuiManager() { shutdown(); }
      56              : 
      57            0 : bool GuiManager::initialize(int width, int height) {
      58            0 :     if (!window_context_.initialize(width, height, Theme::WINDOW_TITLE)) {
      59            0 :         return false;
      60              :     }
      61            0 :     PresetManager::load_config();
      62              : 
      63              :     // MIDI: load config first; if no saved mappings, install defaults
      64            0 :     midi_manager_.load_config();
      65            0 :     if (midi_manager_.mappings().empty()) {
      66            0 :         midi_manager_.install_default_mappings();
      67            0 :     }
      68            0 :     midi_manager_.initialize();
      69              : 
      70              : #ifndef AMPLITRON_NO_DESKTOP_SHELL
      71            0 :     update_checker_.start_check();
      72              : #endif
      73              : 
      74            0 :     if (pedal_board_) {
      75            0 :         pedal_board_->rebuild_widgets();
      76            0 :     }
      77              : 
      78            0 :     initialized_ = true;
      79            0 :     return true;
      80            0 : }
      81              : 
      82           33 : void GuiManager::shutdown() {
      83           33 :     if (!initialized_) return;
      84            0 :     initialized_ = false;
      85              : 
      86            0 :     midi_manager_.save_config();
      87            0 :     midi_manager_.shutdown();
      88              : 
      89            0 :     engine_.clear_tuner_tap();
      90            0 :     pedal_board_.reset();
      91              : 
      92            0 :     window_context_.shutdown();
      93           11 : }
      94              : 
      95              : }  // namespace Amplitron
        

Generated by: LCOV version 2.0-1