Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added button with editable MIDI feedback values #31

Merged
merged 19 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ Makefile*
*.qmlproject.user
*.qmlproject.user.*

.DS_Store
.DS_Store

build-luminosus*/

*.qmlc
34 changes: 34 additions & 0 deletions src/block_implementations/Controls/LaunchpadButtonBlock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2016 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#include "LaunchpadButtonBlock.h"

#include "core/MainController.h"


LaunchpadButtonBlock::LaunchpadButtonBlock(MainController* controller, QString uid)
: OneOutputBlock(controller, uid)
, m_toggleMode(this, "toggleMode", false)
, m_labelText(this, "labelText")
, m_lowValue(this, "lowValue", 0, 0, 127)
, m_highValue(this, "highValue", 127, 0, 127)
{
m_widthIsResizable = true;
}
60 changes: 60 additions & 0 deletions src/block_implementations/Controls/LaunchpadButtonBlock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) 2016 Electronic Theatre Controls, Inc., http://www.etcconnect.com
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef LAUNCHPADBUTTONBLOCK
#define LAUNCHPADBUTTONBLOCK

#include "core/block_data/OneOutputBlock.h"
#include "core/SmartAttribute.h"


class LaunchpadButtonBlock : public OneOutputBlock
{
Q_OBJECT

public:

static BlockInfo info() {
static BlockInfo info;
info.typeName = "LaunchpadButton";
info.category << "General" << "Controls";
info.helpText = "A simple Launchpad button.\n"
"Outputs 1 if pressed and 0 if not.\n"
"User can set custom values for MIDI feedback\n"
"(e. g. for using Launchpad colors)";
info.qmlFile = "qrc:/qml/Blocks/Controls/LaunchpadButtonBlock.qml";
info.complete<LaunchpadButtonBlock>();
return info;
}

explicit LaunchpadButtonBlock(MainController* controller, QString uid);

public slots:
virtual BlockInfo getBlockInfo() const override { return info(); }

protected:
BoolAttribute m_toggleMode;
StringAttribute m_labelText;
IntegerAttribute m_lowValue;
IntegerAttribute m_highValue;
};

#endif // LAUNCHPADBUTTONBLOCK

2 changes: 2 additions & 0 deletions src/core/block_data/BlockList_blocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "block_implementations/Audio/AudioStreamingBlock.h"
#include "block_implementations/Controls/SwitchBlock.h"
#include "block_implementations/Controls/ButtonBlock.h"
#include "block_implementations/Controls/LaunchpadButtonBlock.h"
#include "block_implementations/Controls/SliderBlock.h"
#include "block_implementations/Controls/ColorwheelBlock.h"
#include "block_implementations/Controls/PixelControlBlock.h"
Expand Down Expand Up @@ -110,6 +111,7 @@ void BlockList::addAllBlocks() {
// Controls
addBlock(SliderBlock::info());
addBlock(ButtonBlock::info());
addBlock(LaunchpadButtonBlock::info());
addBlock(SwitchBlock::info());
addBlock(PixelControlBlock::info());
addBlock(ColorwheelBlock::info());
Expand Down
2 changes: 2 additions & 0 deletions src/luminosus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SOURCES += main.cpp \
block_implementations/Audio/BeatDetectionBlock.cpp \
block_implementations/Audio/BpmBlock.cpp \
block_implementations/Controls/ButtonBlock.cpp \
block_implementations/Controls/LaunchpadButtonBlock.cpp \
block_implementations/Controls/ColorwheelBlock.cpp \
block_implementations/Controls/PixelControlBlock.cpp \
block_implementations/Controls/SliderBlock.cpp \
Expand Down Expand Up @@ -220,6 +221,7 @@ HEADERS += \
block_implementations/Audio/BeatDetectionBlock.h \
block_implementations/Audio/BpmBlock.h \
block_implementations/Controls/ButtonBlock.h \
block_implementations/Controls/LaunchpadButtonBlock.h \
block_implementations/Controls/ColorwheelBlock.h \
block_implementations/Controls/PixelControlBlock.h \
block_implementations/Controls/SliderBlock.h \
Expand Down
1 change: 1 addition & 0 deletions src/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@
<file>qml/Tutorial/HogName.qml</file>
<file>qml/Tutorial/EosDiscovery.qml</file>
<file>qml/CombinationEntry.qml</file>
<file>qml/CustomControls/LaunchpadPushButton.qml</file>
</qresource>
</RCC>
115 changes: 115 additions & 0 deletions src/qml/Blocks/Controls/LaunchpadButtonBlock.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import QtQuick 2.5
import CustomElements 1.0
import "../../CustomBasics"
import "../../CustomControls"

BlockBase {
id: root
width: 70*dp
// block is 8*dp smaller that button to end before the rounding of the edges starts
height: width + 30*dp - 8*dp
settingsComponent: settings

StretchColumn {
y: -8*dp
height: parent.height + 8*dp
width: parent.width

LaunchpadPushButton {
mappingID: block.getUid() + "launchpadbutton"
toggle: block.attr("toggleMode").val
text: block.attr("labelText").val
onActiveChanged: root.block.value = (active ? 1 : 0)
low: block.attr("lowValue").val
high: block.attr("highValue").val
}

DragArea {
WidthResizeAreaLeft {
target: root
minSize: 60*dp
maxSize: 200*dp
}

OutputNode {
node: block.node("outputNode")
}
}
}

// -------------------------- Settings ----------------------------

Component {
id: settings
StretchColumn {
leftMargin: 15*dp
rightMargin: 15*dp
defaultSize: 30*dp

BlockRow {
Text {
text: "Toggle Mode:"
width: parent.width - 30*dp
}
AttributeCheckbox {
id: toggleCheckbox
attr: block.attr("toggleMode")
width: 30*dp
}
}

BlockRow {
StretchText {
text: "Low Value:"
}
NumericInput {
width: 120*dp
implicitWidth: 0
minimumValue: 0
maximumValue: 127
decimals: 0
value: block.attr("lowValue").val
onValueChanged: {
if(value !== block.attr("lowValue").val) {
block.attr("lowValue").val = value
}
}
}
}

BlockRow {
StretchText {
text: "High Value:"
}
NumericInput {
width: 120*dp
implicitWidth: 0
minimumValue: 0
maximumValue: 127
decimals: 0
value: block.attr("highValue").val
onValueChanged: {
if(value !== block.attr("highValue").val) {
block.attr("highValue").val = value
}
}
}
}

BlockRow {
StretchText {
text: "Button Label:"
}
TextInput {
width: parent.width * 0.5
text: block.attr("labelText").val
onDisplayTextChanged: {
if (text !== block.attr("labelText").val) {
block.attr("labelText").val = text
}
}
}
}
}
} // end Settings Component
}
Loading