2022-04-22 03:04:30 +00:00
|
|
|
// SPDX-License-Identifier: GPLv3-or-later WITH Appstore-exception
|
|
|
|
// Copyright (C) 2017 Xenakios
|
|
|
|
// Copyright (C) 2020 Jesse Chappell
|
2018-06-04 19:04:53 +00:00
|
|
|
|
2018-02-27 00:33:41 +00:00
|
|
|
|
2018-02-26 23:59:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../JuceLibraryCode/JuceHeader.h"
|
|
|
|
#include <memory>
|
|
|
|
#include <functional>
|
|
|
|
#include <future>
|
|
|
|
#include "jcdp_envelope.h"
|
|
|
|
|
|
|
|
class EnvelopeComponent : public Component,
|
|
|
|
public ChangeListener,
|
|
|
|
public MultiTimer
|
|
|
|
//public TooltipClient
|
|
|
|
{
|
|
|
|
public:
|
2018-02-27 13:21:36 +00:00
|
|
|
EnvelopeComponent(CriticalSection* cs);
|
2018-02-26 23:59:22 +00:00
|
|
|
~EnvelopeComponent();
|
|
|
|
void paint(Graphics& g) override;
|
2022-04-14 07:26:26 +00:00
|
|
|
void resized() override;
|
2018-02-26 23:59:22 +00:00
|
|
|
void set_envelope(std::shared_ptr<breakpoint_envelope> env, String name = String());
|
|
|
|
std::shared_ptr<breakpoint_envelope> get_envelope() { return m_envelope; }
|
|
|
|
String get_name() { return m_name; }
|
|
|
|
void mouseMove(const MouseEvent& ev) override;
|
|
|
|
void mouseDown(const MouseEvent& ev) override;
|
|
|
|
void mouseDrag(const MouseEvent& ev) override;
|
|
|
|
void mouseUp(const MouseEvent& ev) override;
|
|
|
|
bool keyPressed(const KeyPress& ev) override;
|
|
|
|
double get_view_start_time() const { return m_view_start_time; }
|
|
|
|
double get_view_end_time() const { return m_view_end_time; }
|
|
|
|
void set_view_start_time(double t) { m_view_start_time = t; repaint(); }
|
|
|
|
void set_view_end_time(double t) { m_view_end_time = t; repaint(); }
|
|
|
|
std::function<void(EnvelopeComponent*, Graphics&)> EnvelopeUnderlayDraw;
|
|
|
|
std::function<void(EnvelopeComponent*, Graphics&)> EnvelopeOverlayDraw;
|
|
|
|
std::function<void(breakpoint_envelope*)> OnEnvelopeEdited;
|
2018-07-08 11:38:50 +00:00
|
|
|
std::function<double(double)> YFromNormalized;
|
|
|
|
std::function<double(double)> XFromNormalized;
|
2018-02-26 23:59:22 +00:00
|
|
|
void changeListenerCallback(ChangeBroadcaster*) override;
|
|
|
|
void timerCallback(int id) override;
|
|
|
|
//String getTooltip() override;
|
|
|
|
private:
|
2022-04-14 07:26:26 +00:00
|
|
|
void showPopupMenu();
|
|
|
|
|
2022-04-18 19:11:22 +00:00
|
|
|
void deleteSelectedNodes();
|
|
|
|
|
2018-02-26 23:59:22 +00:00
|
|
|
std::shared_ptr<breakpoint_envelope> m_envelope;
|
|
|
|
String m_name;
|
|
|
|
Colour m_env_color{ Colours::yellow };
|
|
|
|
double m_view_start_time = 0.0;
|
|
|
|
double m_view_end_time = 1.0;
|
|
|
|
double m_view_start_value = 0.0;
|
|
|
|
double m_view_end_value = 1.0;
|
|
|
|
int find_hot_envelope_point(double xcor, double ycor);
|
|
|
|
int findHotEnvelopeSegment(double xcor, double ycor, bool detectsegment);
|
|
|
|
bool m_mouse_down = false;
|
|
|
|
int m_node_to_drag = -1;
|
2022-04-18 19:11:22 +00:00
|
|
|
Point<int> m_touch_offset;
|
2018-02-26 23:59:22 +00:00
|
|
|
std::pair<int, bool> m_segment_drag_info{ -1,false };
|
|
|
|
int m_node_that_was_dragged = -1;
|
2022-04-18 19:11:22 +00:00
|
|
|
int m_selected_node = -1;
|
2018-02-26 23:59:22 +00:00
|
|
|
String m_last_tip;
|
|
|
|
BubbleMessageComponent m_bubble;
|
2022-04-14 07:26:26 +00:00
|
|
|
TextButton m_menubutton;
|
2018-10-17 10:06:07 +00:00
|
|
|
void show_bubble(int x, int y, const envelope_point &node);
|
2018-02-27 13:21:36 +00:00
|
|
|
CriticalSection* m_cs = nullptr;
|
2018-02-26 23:59:22 +00:00
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EnvelopeComponent)
|
|
|
|
};
|