Skip to content

Commit 7f3785b

Browse files
committed
moved key events to file viewer
1 parent e5803f6 commit 7f3785b

4 files changed

Lines changed: 19 additions & 17 deletions

File tree

include/Kaixo/SpectralRotator/Gui/SpectralFileViewer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ namespace Kaixo::Gui {
5151

5252
// ------------------------------------------------
5353

54+
bool keyPressed(const juce::KeyPress& event);
55+
56+
// ------------------------------------------------
57+
5458
void onIdle() override;
5559

5660
// ------------------------------------------------

include/Kaixo/SpectralRotator/Gui/SpectralViewer.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ namespace Kaixo::Gui {
5959

6060
// ------------------------------------------------
6161

62-
bool keyPressed(const juce::KeyPress& event) override;
63-
64-
// ------------------------------------------------
65-
6662
void reGenerateImage(bool withAnalyze);
6763
void fileWillProbablyChangeSoon() { m_FileWillProbablyChange = true; };
6864
void fileDidNotChange() { m_FileWillProbablyChange = false; };

source/Kaixo/SpectralRotator/Gui/SpectralFileViewer.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace Kaixo::Gui {
2222
SpectralFileViewer::SpectralFileViewer(Context c, Settings s)
2323
: View(c), settings(std::move(s))
2424
{
25+
// ------------------------------------------------
26+
27+
setWantsKeyboardFocus(true);
2528

2629
// ------------------------------------------------
2730

@@ -132,7 +135,18 @@ namespace Kaixo::Gui {
132135
}
133136

134137
// ------------------------------------------------
135-
138+
139+
bool SpectralFileViewer::keyPressed(const juce::KeyPress& event) {
140+
if (event.getKeyCode() == event.spaceKey) {
141+
settings.file->playPause();
142+
return true;
143+
}
144+
145+
return false;
146+
}
147+
148+
// ------------------------------------------------
149+
136150
void SpectralFileViewer::onIdle() {
137151
View::onIdle();
138152
if (m_RotateFuture.valid() && m_RotateFuture.wait_for(std::chrono::milliseconds(0)) == std::future_status::ready) {

source/Kaixo/SpectralRotator/Gui/SpectralViewer.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace Kaixo::Gui {
1616
SpectralViewer::SpectralViewer(Context c, Settings s)
1717
: View(c), settings(std::move(s))
1818
{
19-
setWantsKeyboardFocus(true);
2019
wantsIdle(true);
2120

2221
reGenerateImage(true);
@@ -135,17 +134,6 @@ namespace Kaixo::Gui {
135134

136135
// ------------------------------------------------
137136

138-
bool SpectralViewer::keyPressed(const juce::KeyPress& event) {
139-
if (event.getKeyCode() == event.spaceKey) {
140-
settings.file->playPause();
141-
return true;
142-
}
143-
144-
return false;
145-
}
146-
147-
// ------------------------------------------------
148-
149137
void SpectralViewer::reGenerateImage(bool withAnalyze) {
150138
m_CausedByResize = m_DidResize;
151139
if (withAnalyze) m_ShouldAnalyze = true;

0 commit comments

Comments
 (0)