commit ce6496cbb40b2cee65737079d195f20ac5b2b6a1
parent 57756a0c52c579f3e4f20c9c7e1ca94c3b09cd5e
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date: Tue, 18 Sep 2012 21:29:01 -0700
Handle keyboard shortcuts changing dynamic range
Diffstat:
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/spek-spectrogram.cc b/src/spek-spectrogram.cc
@@ -32,7 +32,8 @@ extern "C" {
#include "spek-spectrogram.hh"
-BEGIN_EVENT_TABLE(SpekSpectrogram, wxPanel)
+BEGIN_EVENT_TABLE(SpekSpectrogram, wxWindow)
+ EVT_CHAR(SpekSpectrogram::on_char)
EVT_IDLE(SpekSpectrogram::on_idle)
EVT_PAINT(SpekSpectrogram::on_paint)
EVT_SIZE(SpekSpectrogram::on_size)
@@ -56,7 +57,10 @@ enum
static wxString trim(wxDC& dc, const wxString& s, int length, bool trim_end);
SpekSpectrogram::SpekSpectrogram(wxFrame *parent) :
- wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE),
+ wxWindow(
+ parent, -1, wxDefaultPosition, wxDefaultSize,
+ wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS
+ ),
pipeline(NULL),
duration(0.0),
sample_rate(0),
@@ -65,6 +69,7 @@ SpekSpectrogram::SpekSpectrogram(wxFrame *parent) :
prev_width(-1)
{
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+ SetFocus();
// Pre-draw the palette.
for (int y = 0; y < BANDS; y++) {
@@ -98,6 +103,21 @@ void SpekSpectrogram::save(const wxString& path)
bitmap.SaveFile(path, wxBITMAP_TYPE_PNG);
}
+void SpekSpectrogram::on_char(wxKeyEvent& evt)
+{
+ bool C = evt.GetModifiers() == wxMOD_CONTROL;
+ bool S = evt.GetModifiers() == wxMOD_SHIFT;
+ bool CS = evt.GetModifiers() == (wxMOD_CONTROL | wxMOD_SHIFT);
+ bool dn = evt.GetKeyCode() == WXK_DOWN;
+ bool up = evt.GetKeyCode() == WXK_UP;
+
+ if (C && up) {
+ } else if (C && dn) {
+ } else if (CS && up) {
+ } else if (CS && dn) {
+ }
+}
+
void SpekSpectrogram::on_idle(wxIdleEvent& evt)
{
// TODO: remove?
diff --git a/src/spek-spectrogram.hh b/src/spek-spectrogram.hh
@@ -25,7 +25,7 @@ class SpekHaveSampleEvent;
struct spek_audio_properties;
struct spek_pipeline;
-class SpekSpectrogram : public wxPanel
+class SpekSpectrogram : public wxWindow
{
public:
SpekSpectrogram(wxFrame *parent);
@@ -34,6 +34,7 @@ public:
void save(const wxString& path);
private:
+ void on_char(wxKeyEvent& evt);
void on_idle(wxIdleEvent& evt);
void on_paint(wxPaintEvent& evt);
void on_size(wxSizeEvent& evt);