1 // Copyright (c) Charles J. Cliffe 2 // SPDX-License-Identifier: GPL-2.0+ 3 4 #pragma once 5 6 #include "wx/glcanvas.h" 7 #include "wx/timer.h" 8 9 #include <vector> 10 #include <queue> 11 #include <atomic> 12 13 #include "InteractiveCanvas.h" 14 #include "MouseTracker.h" 15 #include "GLPanel.h" 16 #include "PrimaryGLContext.h" 17 #include "SDRDeviceInfo.h" 18 #include "Timer.h" 19 #include "MeterPanel.h" 20 21 22 class GainCanvas: public InteractiveCanvas { 23 public: 24 GainCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs); 25 ~GainCanvas() override; 26 27 void setHelpTip(std::string tip); 28 void updateGainUI(); 29 void setThemeColors(); 30 31 private: 32 33 // call this to refresh the gain values only, return true if refresh is needed 34 bool updateGainValues(); 35 36 void OnPaint(wxPaintEvent& event); 37 void OnIdle(wxIdleEvent &event); 38 39 void SetLevel(); 40 41 void OnShow(wxShowEvent& event); 42 void OnMouseMoved(wxMouseEvent& event); 43 void OnMouseDown(wxMouseEvent& event); 44 void OnMouseWheelMoved(wxMouseEvent& event); 45 void OnMouseReleased(wxMouseEvent& event); 46 void OnMouseEnterWindow(wxMouseEvent& event); 47 void OnMouseLeftWindow(wxMouseEvent& event); 48 49 PrimaryGLContext *glContext; 50 std::string helpTip; 51 std::vector<MeterPanel *> gainPanels; 52 GLPanel bgPanel; 53 SDRRangeMap gains; 54 55 float spacing, barWidth, startPos, barHeight, numGains; 56 int refreshCounter; 57 wxSize clientSize; 58 59 std::atomic_bool userGainAsChanged; 60 Timer userGainAsChangedDelayTimer; 61 // 62 wxDECLARE_EVENT_TABLE(); 63 }; 64 65