Files
baudmine/src/ui/Application.h
ericek111 baf6fd94cc some more refactoring
- UIState.h: Replaced C-style arrays bool[] and ImVec4[] with
std::array<bool, kMaxChannels> and std::array<ImVec4, kMaxChannels> for
type safety and STL compatibility.
  - Application.cpp: Extracted duplicated DPI calculation (lines 189-196
and 475-481) into a systemDpiScale() helper method, reducing both call
sites to single-line calls.
  - Application.cpp: Replaced magic 1400, 900 window dimensions with
kDefaultWindowWidth/kDefaultWindowHeight constants (defined in Types.h).
  - AudioEngine.cpp: Named the magic epsilon thresholds 1e-20f →
kLinearEpsilon and 1e-30f → kLogGuard with explanatory comments, defined
in an anonymous namespace.
  - Types.h: Added kDefaultWindowWidth and kDefaultWindowHeight
constants.
2026-03-28 16:09:29 +01:00

87 lines
2.0 KiB
C++

#pragma once
#include "core/Types.h"
#include "core/Config.h"
#include "audio/AudioEngine.h"
#include "ui/UIState.h"
#include "ui/ControlPanel.h"
#include "ui/DisplayPanel.h"
#include "ui/ColorMap.h"
#include "ui/WaterfallDisplay.h"
#include "ui/SpectrumDisplay.h"
#include "ui/Cursors.h"
#include "ui/Measurements.h"
#include <SDL.h>
#include <string>
namespace baudmine {
class Application {
public:
Application();
~Application();
bool init(int argc, char** argv);
void run();
void mainLoopStep(); // single iteration (public for Emscripten callback)
void shutdown();
private:
void processAudio();
void render();
void openDevice();
void openMultiDevice();
void openFile(const std::string& path, InputFormat format, double sampleRate);
void updateAnalyzerSettings();
void loadConfig();
void saveConfig() const;
// SDL / GL / ImGui
SDL_Window* window_ = nullptr;
SDL_GLContext glContext_ = nullptr;
bool running_ = false;
// Core subsystems
AudioEngine audio_;
UIState ui_;
ControlPanel controlPanel_;
DisplayPanel displayPanel_;
// Shared UI components
ColorMap colorMap_;
WaterfallDisplay waterfall_;
SpectrumDisplay specDisplay_;
Cursors cursors_;
Measurements measurements_;
// UI scaling
bool vsync_ = true;
float uiScale_ = 0.0f;
float appliedScale_ = 0.0f;
float pendingScale_ = 0.0f;
float logicalScale_ = 1.0f;
float lastDpr_ = 0.0f;
void applyUIScale(float scale);
void requestUIScale(float scale);
float systemDpiScale() const;
void syncCanvasSize();
// UI visibility
bool showSidebar_ = true;
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
bool showDemoWindow_ = false;
bool showMetricsWindow_ = false;
bool showDebugLog_ = false;
bool showStackTool_ = false;
#endif
// Config persistence
Config config_;
};
} // namespace baudmine