mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 02:38:13 +00:00

The only major functional change is that the Track now needs to know whether it's active or not, in order to listen to the keyboard (or not). There are some bugs exposed/created by this, mainly: * KeysWidget sometimes shows phantom notes. Those do not actually exist as far as debugging has revealed and do not play in the synth. * The keyboard can lock up Piano when rapidly pressing keys. This appears to be a HashMap bug; I invested significant time in bugfixing but got nowhere.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2019-2020, William McPherson <willmcpherson2@gmail.com>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Music.h"
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <LibDSP/Keyboard.h>
|
|
#include <LibGUI/Frame.h>
|
|
|
|
class TrackManager;
|
|
|
|
class KeysWidget final : public GUI::Frame {
|
|
C_OBJECT(KeysWidget)
|
|
public:
|
|
virtual ~KeysWidget() override = default;
|
|
|
|
static i8 key_code_to_key(int key_code);
|
|
int mouse_note() const;
|
|
|
|
private:
|
|
KeysWidget(NonnullRefPtr<LibDSP::Keyboard>);
|
|
|
|
virtual void paint_event(GUI::PaintEvent&) override;
|
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
|
|
|
int note_for_event_position(Gfx::IntPoint const&) const;
|
|
|
|
void set_key(i8 key, LibDSP::Keyboard::Switch);
|
|
|
|
NonnullRefPtr<LibDSP::Keyboard> m_keyboard;
|
|
|
|
bool m_mouse_down { false };
|
|
int m_mouse_note { -1 };
|
|
};
|