Tchick/Source/PlayPanel.h
2026-02-04 11:51:22 +01:00

73 lines
2.1 KiB
C++

#pragma once
/*
==============================================================================
Copyright 2022 Nicolas Chambert
This program is free software : you can redistribute itand /or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see < http://www.gnu.org/licenses/>.
==============================================================================
*/
/*
==============================================================================
Gestion du bouton play et du volume.
==============================================================================
*/
#include <JuceHeader.h>
#include "Metronome.h"
// Etat de lecture
enum class PlayState
{
playing,
stopped
};
// surcharge du look&feel pour dessiner le bouton play en cercle
struct RoundButtonLookAndFeel : public juce::LookAndFeel_V4
{
void drawButtonBackground(juce::Graphics& g, juce::Button& button, const juce::Colour& backgroundColour,
bool isMouseOverButton, bool isButtonDown) override;
};
// classe principale
struct PlayPanel : public juce::Component
{
explicit PlayPanel(juce::Colour c);
~PlayPanel();
// Méthode de surcharge JUCE
void paint(juce::Graphics& g) override;
void resized() override;
// utilitaire graphique
void addComponent(juce::Component& c);
// méthodes de gestion du lecteur
void init(Metronome& metro);
void play(Metronome& metro);
void highlight();
// composants graphiques
juce::Colour backgroundColour;
juce::Slider volume;
juce::DrawableButton playButton { "Play", juce::DrawableButton::ImageOnButtonBackground };
std::unique_ptr <RoundButtonLookAndFeel> lef;
// variables internes
int highlightFrames;
PlayState playState{ PlayState::stopped };
};