forked from rorywalsh/cabbage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCabbageRangeSlider.h
More file actions
executable file
·109 lines (87 loc) · 3.36 KB
/
CabbageRangeSlider.h
File metadata and controls
executable file
·109 lines (87 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Copyright (C) 2016 Rory Walsh
Cabbage is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Cabbage 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 Lesser General Public License for more details.
You should have received a copy of the GNU General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
#ifndef CABBAGERANGESLIDER_H_INCLUDED
#define CABBAGERANGESLIDER_H_INCLUDED
#include "../CabbageCommonHeaders.h"
#include "CabbageWidgetBase.h"
#include "../LookAndFeel/FlatButtonLookAndFeel.h"
class CabbagePluginEditor;
class CabbageRangeSlider;
class RangeSlider : public Slider
{
CabbageRangeSlider* owner;
public:
explicit RangeSlider (CabbageRangeSlider* owner);
void setMinMax(double mi, double ma){ min = mi; max = ma; }
~RangeSlider() override;
private:
double min = 0, max = 0;
void mouseDown (const MouseEvent& event) override;
void mouseExit (const MouseEvent& event) override;
void mouseDrag (const MouseEvent& event) override;
void mouseEnter (const MouseEvent& event) override;
//void valueChanged() override {};
bool mouseDragBetweenThumbs;
float xMinAtThumbDown = 0;
float xMaxAtThumbDown = 0;
float yMinAtThumbDown = 0;
float yMaxAtThumbDown = 0;
};
class CabbageRangeSlider : public Component, public ValueTree::Listener, public CabbageWidgetBase
{
CabbagePluginEditor* owner;
String name, text, textColour;
RangeSlider slider;
Label textLabel;
Label minValueLabel, maxValueLabel;
bool shouldShowTextBox = false;
bool isVertical = false;
bool shouldDisplayPopup;
float minValue, maxValue, min, max, decimalPlaces, sliderIncrement, sliderSkew;
BubbleMessageComponent popupBubble;
String prefix = "";
String postfix = "";
String popupPrefix = "";
String popupPostfix = "";
void createPopupBubble();
void setLookAndFeelColours (ValueTree wData);
void setSliderValues (ValueTree wData);
// FlatButtonLookAndFeel flatLookAndFeel;
LookAndFeel_V4 flatLookAndFeel;
public:
CabbageRangeSlider (ValueTree wData, CabbagePluginEditor* _owner);
~CabbageRangeSlider() override{
widgetData.removeListener(this);
slider.setLookAndFeel (nullptr);
setLookAndFeel(nullptr);
}
void setCurrentValues (float min, float max);
void resized() override;
void showPopup (int displayTime);
//ValueTree::Listener virtual methods....
void valueTreePropertyChanged (ValueTree& valueTree, const Identifier&) override;
void valueTreeChildAdded (ValueTree&, ValueTree&)override {}
void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override {}
void valueTreeChildOrderChanged (ValueTree&, int, int) override {}
void valueTreeParentChanged (ValueTree&) override {}
RangeSlider& getSlider()
{
return slider;
}
ValueTree widgetData;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CabbageRangeSlider)
};
#endif // CABBAGERANGESLIDER_H_INCLUDED