-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factor out ControlElement base class without UI dependency
- Loading branch information
1 parent
9e09c46
commit ae8c279
Showing
15 changed files
with
233 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
oscsend-vst - An audio plugin that speaks OSC. | ||
Copyright (C) 2020 Patric Schmitz | ||
This program 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 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/>. | ||
*/ | ||
|
||
#include "LayoutHints.h" | ||
|
||
#include "ControlElementUI.h" | ||
|
||
ControlElementUI:: | ||
ControlElementUI | ||
(const CreateInfo & info, | ||
OSCSender & oscSender) : | ||
ControlElement(info, oscSender) | ||
{ | ||
buttonMute.reset (new TextButton ("buttonMute")); | ||
buttonMute->setButtonText("m"); | ||
buttonMute->setColour(TextButton::buttonOnColourId, | ||
Colours::crimson); | ||
buttonMute->setClickingTogglesState(true); | ||
buttonMute->setPaintingIsUnclipped(true); | ||
buttonMute->getToggleStateValue().addListener(this); | ||
addAndMakeVisible(buttonMute.get()); | ||
|
||
sendValue.addListener(this); | ||
} | ||
|
||
void | ||
ControlElementUI:: | ||
resized() | ||
{ | ||
auto area = getLocalBounds(); | ||
|
||
auto gap = LayoutHints::sizeGap; | ||
auto buttonSize = LayoutHints::heightRow - 2*gap; | ||
|
||
area.removeFromRight(gap); | ||
area.removeFromTop(gap); | ||
area.setHeight(buttonSize); | ||
|
||
buttonMute->setBounds(area.removeFromRight(buttonSize)); | ||
} | ||
|
||
void | ||
ControlElementUI:: | ||
registerSendValue() | ||
{ | ||
sendValue.removeListener(this); | ||
sendValue.referTo | ||
(getSpecificSendValue()); | ||
sendValue.addListener(this); | ||
} | ||
|
||
void | ||
ControlElementUI:: | ||
valueChanged | ||
(Value & value) | ||
{ | ||
if(value == buttonMute->getToggleStateValue()) { | ||
auto toggleState = buttonMute->getToggleState(); | ||
if(createInfo.messageMute != "") { | ||
auto oscMessage = | ||
OSCMessage(String(createInfo.messageMute), int(toggleState)); | ||
oscSender.send(oscMessage); | ||
} | ||
|
||
if(!toggleState) { | ||
send(); | ||
} | ||
} | ||
else if(value.refersToSameSourceAs(sendValue)) { | ||
send(); | ||
} | ||
} | ||
|
||
void | ||
ControlElementUI:: | ||
send() | ||
{ | ||
if (!buttonMute->getToggleState()) { | ||
auto value = sendValue.getValue(); | ||
auto oscMessage = | ||
OSCMessage(String(createInfo.message), float(value)); | ||
oscSender.send(oscMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
oscsend-vst - An audio plugin that speaks OSC. | ||
Copyright (C) 2020 Patric Schmitz | ||
This program 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 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/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "ControlElement.h" | ||
|
||
class ControlElementUI : | ||
public ControlElement, | ||
public Component, | ||
public Value::Listener | ||
{ | ||
public: | ||
ControlElementUI | ||
(const CreateInfo & info, | ||
OSCSender & oscSender); | ||
|
||
virtual int getNumberOfRows() const = 0; | ||
void resized() override; | ||
|
||
void registerSendValue(); | ||
|
||
void valueChanged(Value & value) override; | ||
|
||
void send() override; | ||
|
||
protected: | ||
|
||
virtual Value & getSpecificSendValue() = 0; | ||
|
||
private: | ||
|
||
std::unique_ptr<TextButton> buttonMute; | ||
Value sendValue; | ||
}; | ||
using ControlElementUIUniq = std::unique_ptr<ControlElementUI>; |
Oops, something went wrong.