MIDI2LR 6.2.0.1
MIDI2LR is an application that interfaces MIDI controllers with Lightroom 6+/CC Classic. It processes MIDI input into develop parameter updates and photo actions, and sends MIDI output when parameters are changed for motorized feedback (on controllers that have motorized faders). A listing of available LightRoom commands is in the Wiki. Assistance on the code and design is welcome.
Loading...
Searching...
No Matches
CCoptions Class Reference

#include <CCoptions.h>

+ Inheritance diagram for CCoptions:

Public Member Functions

 CCoptions ()
 
 CCoptions (CCoptions &&other) noexcept=delete
 
 ~CCoptions ()
 
void BindToControl (int channel, int control_number)
 
void buttonClicked (juce::Button *buttonThatWasClicked) override
 
CCoptionsoperator= (CCoptions &&other) noexcept=delete
 
void paint (juce::Graphics &g) override
 
void resized () override
 

Static Public Member Functions

static void LinkToControlsModel (_In_ ControlsModel *model) noexcept
 

Private Member Functions

void textEditorFocusLost (juce::TextEditor &t) override
 

Private Attributes

std::unique_ptr< juce::ToggleButton > absbutton
 
std::unique_ptr< juce::TextButton > applyAll
 
std::unique_ptr< juce::ToggleButton > binbutton
 
int bound_channel_ {0}
 
int bound_number_ {0}
 
std::unique_ptr< juce::Label > controlID
 
std::unique_ptr< juce::GroupComponent > groupComponent
 
std::unique_ptr< juce::Label > maxvallabel
 
std::unique_ptr< juce::TextEditor > maxvaltext
 
std::unique_ptr< juce::Label > minvallabel
 
std::unique_ptr< juce::TextEditor > minvaltext
 
juce::TextEditor::LengthAndCharacterRestriction numrestrict_ {5, "0123456789"}
 
std::unique_ptr< juce::ToggleButton > signbutton
 
std::unique_ptr< juce::ToggleButton > twosbutton
 

Static Private Attributes

static ControlsModelcontrols_model_ {nullptr}
 

Detailed Description

[Comments] An auto-generated component, created by the Projucer.

Describe your class and how it works here! [/Comments]

Constructor & Destructor Documentation

◆ CCoptions() [1/2]

CCoptions::CCoptions ( )
51{
52 //[Constructor_pre] You can add your own custom stuff here..
53 auto fo {juce::FontOptions(15.00f, Font::plain)};
54 //[/Constructor_pre]
55
56 groupComponent.reset(new GroupComponent("CCmethod", TRANS("CC Message Type")));
57 addAndMakeVisible(groupComponent.get());
58
59 groupComponent->setBounds(16, 60, 240, 157);
60
61 twosbutton.reset(new ToggleButton("twoscomp"));
62 addAndMakeVisible(twosbutton.get());
63 twosbutton->setTooltip(TRANS("Control value is 1 or greater when turned one way, and 127 or "
64 "smaller when turned the other."));
65 twosbutton->setExplicitFocusOrder(2);
66 twosbutton->setButtonText(TRANS("Two\'s complement"));
67 twosbutton->setConnectedEdges(Button::ConnectedOnTop | Button::ConnectedOnBottom);
68 twosbutton->setRadioGroupId(1);
69 twosbutton->addListener(this);
70
71 twosbutton->setBounds(40, 117, 150, 24);
72
73 absbutton.reset(new ToggleButton("Absolute"));
74 addAndMakeVisible(absbutton.get());
75 absbutton->setTooltip(TRANS("Control value increases when turned one way, decreases when turned "
76 "the other."));
77 absbutton->setExplicitFocusOrder(1);
78 absbutton->setConnectedEdges(Button::ConnectedOnBottom);
79 absbutton->setRadioGroupId(1);
80 absbutton->addListener(this);
81 absbutton->setToggleState(true, dontSendNotification);
82
83 absbutton->setBounds(40, 85, 150, 24);
84
85 binbutton.reset(new ToggleButton("Binaryoffset"));
86 addAndMakeVisible(binbutton.get());
87 binbutton->setTooltip(TRANS("Control value is near 63 when turned one way, and near 65 when "
88 "turned the other."));
89 binbutton->setExplicitFocusOrder(3);
90 binbutton->setButtonText(TRANS("Binary offset"));
91 binbutton->setConnectedEdges(Button::ConnectedOnTop | Button::ConnectedOnBottom);
92 binbutton->setRadioGroupId(1);
93 binbutton->addListener(this);
94
95 binbutton->setBounds(40, 149, 150, 24);
96
97 signbutton.reset(new ToggleButton("Signmagnitude"));
98 addAndMakeVisible(signbutton.get());
99 signbutton->setTooltip(TRANS("Control value is near 1 when turned one way, and near 65 when "
100 "turned the other."));
101 signbutton->setExplicitFocusOrder(4);
102 signbutton->setButtonText(TRANS("Sign and magnitude"));
103 signbutton->setConnectedEdges(Button::ConnectedOnTop);
104 signbutton->setRadioGroupId(1);
105 signbutton->addListener(this);
106
107 signbutton->setBounds(40, 181, 150, 24);
108
109 maxvaltext.reset(new TextEditor("maxvaltext"));
110 addAndMakeVisible(maxvaltext.get());
111 maxvaltext->setExplicitFocusOrder(6);
112 maxvaltext->setMultiLine(false);
113 maxvaltext->setReturnKeyStartsNewLine(false);
114 maxvaltext->setReadOnly(false);
115 maxvaltext->setScrollbarsShown(true);
116 maxvaltext->setCaretVisible(true);
117 maxvaltext->setPopupMenuEnabled(true);
118 maxvaltext->setText(TRANS("127"));
119
120 maxvaltext->setBounds(200, 268, 56, 24);
121
122 minvaltext.reset(new TextEditor("minvaltext"));
123 addAndMakeVisible(minvaltext.get());
124 minvaltext->setExplicitFocusOrder(5);
125 minvaltext->setMultiLine(false);
126 minvaltext->setReturnKeyStartsNewLine(false);
127 minvaltext->setReadOnly(false);
128 minvaltext->setScrollbarsShown(true);
129 minvaltext->setCaretVisible(true);
130 minvaltext->setPopupMenuEnabled(true);
131 minvaltext->setText(TRANS("0"));
132
133 minvaltext->setBounds(200, 228, 56, 24);
134
135 minvallabel.reset(new Label("new label", TRANS("Minimum value")));
136 addAndMakeVisible(minvallabel.get());
137 minvallabel->setFont(Font(fo).withTypefaceStyle("Regular"));
138 minvallabel->setJustificationType(Justification::centredLeft);
139 minvallabel->setEditable(false, false, false);
140 minvallabel->setColour(TextEditor::textColourId, Colours::black);
141 minvallabel->setColour(TextEditor::backgroundColourId, Colour(0x00000000));
142
143 minvallabel->setBounds(16, 228, 150, 24);
144
145 maxvallabel.reset(new Label("maxlabel", TRANS("Maximum value")));
146 addAndMakeVisible(maxvallabel.get());
147 maxvallabel->setFont(Font(fo).withTypefaceStyle("Regular"));
148 maxvallabel->setJustificationType(Justification::centredLeft);
149 maxvallabel->setEditable(false, false, false);
150 maxvallabel->setColour(TextEditor::textColourId, Colours::black);
151 maxvallabel->setColour(TextEditor::backgroundColourId, Colour(0x00000000));
152
153 maxvallabel->setBounds(16, 268, 150, 24);
154
155 applyAll.reset(new TextButton("new button"));
156 addAndMakeVisible(applyAll.get());
157 applyAll->setTooltip(TRANS("Apply these settings to all similar controls."));
158 applyAll->setExplicitFocusOrder(7);
159 applyAll->setButtonText(TRANS("Apply to all"));
160 applyAll->addListener(this);
161
162 controlID.reset(new Label("channel 0 number 0", TRANS("Channel 0 Number 0")));
163 addAndMakeVisible(controlID.get());
164 controlID->setFont(Font(fo).withTypefaceStyle("Regular"));
165 controlID->setJustificationType(Justification::centred);
166 controlID->setEditable(false, false, false);
167 controlID->setColour(TextEditor::textColourId, Colours::black);
168 controlID->setColour(TextEditor::backgroundColourId, Colour(0x00000000));
169
170 //[UserPreSize]
171 //[/UserPreSize]
172
173 setSize(280, 350);
174
175 //[Constructor] You can add your own custom stuff here..
176 maxvaltext->setInputFilter(&numrestrict_, false);
177 minvaltext->setInputFilter(&numrestrict_, false);
178 maxvaltext->addListener(this);
179 minvaltext->addListener(this);
180 //[/Constructor]
181}
std::unique_ptr< juce::TextEditor > maxvaltext
Definition CCoptions.h:92
std::unique_ptr< juce::Label > maxvallabel
Definition CCoptions.h:95
std::unique_ptr< juce::TextButton > applyAll
Definition CCoptions.h:96
std::unique_ptr< juce::ToggleButton > signbutton
Definition CCoptions.h:91
std::unique_ptr< juce::ToggleButton > twosbutton
Definition CCoptions.h:88
std::unique_ptr< juce::Label > controlID
Definition CCoptions.h:97
juce::TextEditor::LengthAndCharacterRestriction numrestrict_
Definition CCoptions.h:79
std::unique_ptr< juce::TextEditor > minvaltext
Definition CCoptions.h:93
std::unique_ptr< juce::ToggleButton > absbutton
Definition CCoptions.h:89
std::unique_ptr< juce::ToggleButton > binbutton
Definition CCoptions.h:90
std::unique_ptr< juce::GroupComponent > groupComponent
Definition CCoptions.h:87
std::unique_ptr< juce::Label > minvallabel
Definition CCoptions.h:94

◆ ~CCoptions()

CCoptions::~CCoptions ( )
184{
185 //[Destructor_pre]. You can add your own custom destruction code here..
186 //[/Destructor_pre]
187
188 groupComponent = nullptr;
189 twosbutton = nullptr;
190 absbutton = nullptr;
191 binbutton = nullptr;
192 signbutton = nullptr;
193 maxvaltext = nullptr;
194 minvaltext = nullptr;
195 minvallabel = nullptr;
196 maxvallabel = nullptr;
197 applyAll = nullptr;
198 controlID = nullptr;
199
200 //[Destructor]. You can add your own custom destruction code here..
201 //[/Destructor]
202}

◆ CCoptions() [2/2]

CCoptions::CCoptions ( CCoptions &&  other)
deletenoexcept

Member Function Documentation

◆ BindToControl()

void CCoptions::BindToControl ( int  channel,
int  control_number 
)
309{
310 bound_channel_ = channel; // 0-based but displays as 1-based
311 bound_number_ = control_number;
312 controlID->setText("channel " + juce::String(channel + 1) + " number "
313 + juce::String(control_number),
314 juce::dontSendNotification);
316 juce::dontSendNotification);
318 juce::dontSendNotification);
321 absbutton->setToggleState(true, juce::sendNotification);
322 break;
324 binbutton->setToggleState(true, juce::sendNotification);
325 break;
327 signbutton->setToggleState(true, juce::sendNotification);
328 break;
330 twosbutton->setToggleState(true, juce::sendNotification);
331 break;
332 }
333}
static ControlsModel * controls_model_
Definition CCoptions.h:81
int bound_channel_
Definition CCoptions.h:82
int bound_number_
Definition CCoptions.h:83
rsj::CCmethod GetCcMethod(int channel, int controlnumber) const
Definition ControlsModel.h:244
int GetCcMax(int channel, int controlnumber) const
Definition ControlsModel.h:256
int GetCcMin(int channel, int controlnumber) const
Definition ControlsModel.h:261

◆ buttonClicked()

void CCoptions::buttonClicked ( juce::Button *  buttonThatWasClicked)
override
228{
229 //[UserbuttonClicked_Pre]
230 //[/UserbuttonClicked_Pre]
231
232 if (buttonThatWasClicked == twosbutton.get()) {
233 //[UserButtonCode_twosbutton] -- add your button handler code here..
234 minvaltext->setVisible(false);
235 minvallabel->setVisible(false);
236 maxvallabel->setText(TRANS("Resolution"), juce::dontSendNotification);
237 minvaltext->setText("0", juce::dontSendNotification);
239 //[/UserButtonCode_twosbutton]
240 }
241 else if (buttonThatWasClicked == absbutton.get()) {
242 //[UserButtonCode_absbutton] -- add your button handler code here..
243 minvaltext->setVisible(true);
244 minvallabel->setVisible(true);
245 maxvallabel->setText(TRANS("Maximum value"), juce::dontSendNotification);
247 //[/UserButtonCode_absbutton]
248 }
249 else if (buttonThatWasClicked == binbutton.get()) {
250 //[UserButtonCode_binbutton] -- add your button handler code here..
251 minvaltext->setVisible(false);
252 minvallabel->setVisible(false);
253 maxvallabel->setText(TRANS("Resolution"), juce::dontSendNotification);
254 minvaltext->setText("0", juce::dontSendNotification);
256
257 //[/UserButtonCode_binbutton]
258 }
259 else if (buttonThatWasClicked == signbutton.get()) {
260 //[UserButtonCode_signbutton] -- add your button handler code here..
261 minvaltext->setVisible(false);
262 minvallabel->setVisible(false);
263 maxvallabel->setText(TRANS("Resolution"), juce::dontSendNotification);
264 minvaltext->setText("0", juce::dontSendNotification);
266 //[/UserButtonCode_signbutton]
267 }
268 else if (buttonThatWasClicked == applyAll.get()) {
269 //[UserButtonCode_applyAll] -- add your button handler code here..
270 rsj::CCmethod ccm {};
271 if (twosbutton->getToggleState()) { ccm = rsj::CCmethod::kTwosComplement; }
272 else if (absbutton->getToggleState()) {
274 }
275 else if (binbutton->getToggleState()) {
277 }
278 else if (signbutton->getToggleState()) {
280 }
281 else {
282 throw std::logic_error("CCoptions::buttonClicked reached unreachable code");
283 }
285 maxvaltext->getText().getIntValue(), ccm);
286 //[/UserButtonCode_applyAll]
287 }
288 else { /* no action needed */
289 }
290
291 //[UserbuttonClicked_Post]
292 //[/UserbuttonClicked_Post]
293}
void SetCcMethod(int channel, int controlnumber, rsj::CCmethod value)
Definition ControlsModel.h:297
void SetCcAll(int channel, int controlnumber, int min, int max, rsj::CCmethod controltype)
Definition ControlsModel.h:287
CCmethod
Definition ControlsModel.h:33

◆ LinkToControlsModel()

static void CCoptions::LinkToControlsModel ( _In_ ControlsModel model)
inlinestaticnoexcept
66{ controls_model_ = model; }

◆ operator=()

CCoptions & CCoptions::operator= ( CCoptions &&  other)
deletenoexcept

◆ paint()

void CCoptions::paint ( juce::Graphics &  g)
override
206{
207 //[UserPrePaint] Add your own custom painting code here..
208 //[/UserPrePaint]
209
210 g.fillAll(Colours::white);
211
212 //[UserPaint] Add your own custom painting code here..
213 //[/UserPaint]
214}

◆ resized()

void CCoptions::resized ( )
override
217{
218 //[UserPreResize] Add your own custom resize code here..
219 //[/UserPreResize]
220
221 applyAll->setBounds((getWidth() / 2) - (150 / 2), (getHeight() / 2) + 141, 150, 24);
222 controlID->setBounds((getWidth() / 2) - (248 / 2), 16, 248, 24);
223 //[UserResized] Add your own custom resize handling here..
224 //[/UserResized]
225}

◆ textEditorFocusLost()

void CCoptions::textEditorFocusLost ( juce::TextEditor &  t)
overrideprivate
297{
298 const auto val = t.getText().getIntValue();
299 const auto& nam = t.getName();
300 if (nam == "minvaltext") { controls_model_->SetCcMin(bound_channel_, bound_number_, val); }
301 else if (nam == "maxvaltext") {
303 }
304 else { /* no action needed */
305 }
306}
void SetCcMax(int channel, int controlnumber, int value)
Definition ControlsModel.h:292
void SetCcMin(int channel, int controlnumber, int value)
Definition ControlsModel.h:302

Member Data Documentation

◆ absbutton

std::unique_ptr<juce::ToggleButton> CCoptions::absbutton
private

◆ applyAll

std::unique_ptr<juce::TextButton> CCoptions::applyAll
private

◆ binbutton

std::unique_ptr<juce::ToggleButton> CCoptions::binbutton
private

◆ bound_channel_

int CCoptions::bound_channel_ {0}
private
82{0}; // note: 0-based in program, add one to compensate for display

◆ bound_number_

int CCoptions::bound_number_ {0}
private
83{0};

◆ controlID

std::unique_ptr<juce::Label> CCoptions::controlID
private

◆ controls_model_

ControlsModel* CCoptions::controls_model_ {nullptr}
inlinestaticprivate
81{nullptr};

◆ groupComponent

std::unique_ptr<juce::GroupComponent> CCoptions::groupComponent
private

◆ maxvallabel

std::unique_ptr<juce::Label> CCoptions::maxvallabel
private

◆ maxvaltext

std::unique_ptr<juce::TextEditor> CCoptions::maxvaltext
private

◆ minvallabel

std::unique_ptr<juce::Label> CCoptions::minvallabel
private

◆ minvaltext

std::unique_ptr<juce::TextEditor> CCoptions::minvaltext
private

◆ numrestrict_

juce::TextEditor::LengthAndCharacterRestriction CCoptions::numrestrict_ {5, "0123456789"}
private
79{5, "0123456789"};

◆ signbutton

std::unique_ptr<juce::ToggleButton> CCoptions::signbutton
private

◆ twosbutton

std::unique_ptr<juce::ToggleButton> CCoptions::twosbutton
private

The documentation for this class was generated from the following files: