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

Changes AutomationPattern to use nodes instead of raw float values #5712

Merged
merged 62 commits into from
Feb 28, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
77d69e2
First commit
IanCaio Oct 13, 2020
fb2107d
Implements inValue/outValue on Automation Nodes
IanCaio Oct 14, 2020
28611b8
Fixes and refactor code on AutomationEditor.cpp
IanCaio Oct 15, 2020
e5c9669
Avoids unnecessary check in putValue
IanCaio Oct 15, 2020
ab0aeb0
Adds upgrade routine for the automation nodes
IanCaio Oct 15, 2020
2ed2a66
Allows dragging outValues on the Automation Editor
IanCaio Oct 16, 2020
7b6729b
Small fix inside AutomationPattern.cpp
IanCaio Oct 16, 2020
a800943
Creates separate files for AutomationNode
IanCaio Oct 16, 2020
3932106
Adds more members to AutomationNode
IanCaio Oct 16, 2020
9f55d2c
Removes unused code from AutomationEditor
IanCaio Oct 16, 2020
c42c46b
Changes to the outValues now update the tangents
IanCaio Oct 16, 2020
504143c
Keeps discrete jumps when flipping patterns
IanCaio Oct 16, 2020
d67942b
Allows reseting outValues on the AutomationEditor
IanCaio Oct 16, 2020
7c269bd
Makes so dragging nodes keep the outValue
IanCaio Oct 16, 2020
64fcec0
Fixes code style on modified code
IanCaio Oct 16, 2020
578367e
Adds a QProperty for the node outValue color
IanCaio Oct 16, 2020
c4960a1
Adds doxygen comments on methods
IanCaio Oct 16, 2020
5c94591
Refactor flipX and flipY methods
IanCaio Oct 16, 2020
939596a
Add a new edit mode to Automation Editor
IanCaio Oct 16, 2020
5a38f74
Improves the Draw OutValue edit mode
IanCaio Oct 17, 2020
7925196
Adds mutex to AutomationPattern
IanCaio Oct 17, 2020
9e325dc
Veratil's review changes
IanCaio Oct 19, 2020
61d20ff
Changes the inValue sphere to be draw first
IanCaio Oct 19, 2020
ff92b56
Merge branch 'master' into feature/automationProgression
IanCaio Oct 21, 2020
3d4be23
Changes comments and variables names
IanCaio Oct 21, 2020
caa43ad
Changes QProperty variables to use MEMBER
IanCaio Oct 22, 2020
61ef27a
Overloads some AutomationNode's operators
IanCaio Oct 22, 2020
932a46e
Improves getNodeAt method
IanCaio Oct 22, 2020
a64942a
Changes behavior of setDragValue
IanCaio Oct 22, 2020
3b6f238
Moves getNodeAt to an upper level, reducing lines
IanCaio Oct 22, 2020
53f4afa
Changes icon of Draw OutValue edit mode
IanCaio Oct 22, 2020
108323d
Merge branch 'master' into feature/automationProgression
IanCaio Oct 24, 2020
203d3b5
Removes unnecessary non-const methods
IanCaio Nov 12, 2020
1531668
Merge branch 'master' into feature/automationProgression
IanCaio Nov 12, 2020
5184d79
Fixes formatting and doxygen comments
IanCaio Nov 13, 2020
9805321
Adds helper macros for AutomationNodes
IanCaio Nov 13, 2020
055c95f
Removes tabs from ternary operator
IanCaio Nov 13, 2020
1c3502c
Update files to use AutomationNode macros
IanCaio Nov 13, 2020
3471b8f
Merge branch 'master' into feature/automationProgression
IanCaio Nov 26, 2020
7559a41
Addresses my own code review
IanCaio Nov 26, 2020
2cf33e1
Addresses Veratil's review
IanCaio Nov 26, 2020
e0c3563
Adds helper MACROs for node tangents
IanCaio Nov 26, 2020
85a0ca3
Merge branch 'master' into feature/automationProgression
IanCaio Dec 5, 2020
cbf73dc
Fixes header inclusion order
IanCaio Dec 5, 2020
de6d7c9
Removes mutex from AutomationEditor
IanCaio Dec 6, 2020
7d1f196
Locks mutex on AutomationPattern copy assignment
IanCaio Dec 6, 2020
128c723
Changes resetOutValue() so it generates tangents
IanCaio Dec 6, 2020
adc223b
Changes some methods to use for loops
IanCaio Dec 11, 2020
169cc3b
Move removeNodes/resetNodes to AutomationPattern
IanCaio Dec 11, 2020
033bfab
Optimizes loop inside putValue/putValues
IanCaio Dec 11, 2020
fe53845
Adds comment to mysterious calculation
IanCaio Dec 12, 2020
1f28a45
Merge branch 'master' into feature/automationProgression
IanCaio Dec 16, 2020
1e1e5f8
Reduces indentation on getNodeAt
IanCaio Dec 16, 2020
6bec055
Applies Veratil suggestions
IanCaio Dec 16, 2020
1d23334
Updates comment from changed code
IanCaio Dec 16, 2020
8c5f9d4
Uses lambda functions to extract code
IanCaio Dec 16, 2020
1d1d57c
Fixes behavior of AutomationPattern::flipX
IanCaio Dec 20, 2020
d9862c5
Changes pattern XML for backwards compatibility
IanCaio Dec 20, 2020
2d1fbd0
Fixes bug on AutomationPattern::resetNodes
IanCaio Dec 20, 2020
4b4ac2b
Adds comment about copy-assignment
IanCaio Jan 7, 2021
93c0c65
Merge branch 'master' into feature/automationProgression
IanCaio Jan 30, 2021
5a66667
Changes flipY logic and address PhysSong review
IanCaio Jan 30, 2021
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
Binary file added data/themes/classic/edit_draw_outvalue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ AutomationEditor {
background-color: rgb(0, 0, 0);
color: #e0e0e0;
qproperty-backgroundShade: rgba(255, 255, 255, 15);
qproperty-vertexColor: #ff77af;
qproperty-nodeInValueColor: rgba(255, 119, 175, 150);
qproperty-nodeOutValueColor: rgba(129, 231, 181, 150);
qproperty-crossColor: rgb( 255, 51, 51 );
/* Grid colors */
qproperty-lineColor: rgba(128, 128, 128, 80);
Expand Down
Binary file added data/themes/default/edit_draw_outvalue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ AutomationEditor {
color: #ffffff;
background-color: #141616;
qproperty-backgroundShade: rgba(255, 255, 255, 15);
qproperty-vertexColor: #6749C2;
qproperty-nodeInValueColor: rgba(103, 73, 194, 150);
qproperty-nodeOutValueColor: rgba(125, 40, 40, 150);
qproperty-crossColor: rgba(215, 210, 254, 150);
/* Grid colors */
qproperty-lineColor: #292929;
Expand Down
81 changes: 29 additions & 52 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ class TimeLineWidget;
class AutomationEditor : public QWidget, public JournallingObject
{
Q_OBJECT
Q_PROPERTY(QColor barLineColor READ barLineColor WRITE setBarLineColor)
Q_PROPERTY(QColor beatLineColor READ beatLineColor WRITE setBeatLineColor)
Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor)
Q_PROPERTY(QColor vertexColor READ vertexColor WRITE setVertexColor)
Q_PROPERTY(QBrush scaleColor READ scaleColor WRITE setScaleColor)
Q_PROPERTY(QBrush graphColor READ graphColor WRITE setGraphColor)
Q_PROPERTY(QColor crossColor READ crossColor WRITE setCrossColor)
Q_PROPERTY(QColor backgroundShade READ backgroundShade WRITE setBackgroundShade)
Q_PROPERTY(QColor barLineColor MEMBER m_barLineColor)
Q_PROPERTY(QColor beatLineColor MEMBER m_beatLineColor)
Q_PROPERTY(QColor lineColor MEMBER m_lineColor)
Q_PROPERTY(QColor nodeInValueColor MEMBER m_nodeInValueColor)
Q_PROPERTY(QColor nodeOutValueColor MEMBER m_nodeOutValueColor)
Q_PROPERTY(QBrush scaleColor MEMBER m_scaleColor)
Q_PROPERTY(QBrush graphColor MEMBER m_graphColor)
Q_PROPERTY(QColor crossColor MEMBER m_crossColor)
Q_PROPERTY(QColor backgroundShade MEMBER m_backgroundShade)
public:
void setCurrentPattern(AutomationPattern * new_pattern);

Expand All @@ -80,30 +81,11 @@ class AutomationEditor : public QWidget, public JournallingObject
return "automationeditor";
}

// qproperty access methods
QColor barLineColor() const;
void setBarLineColor(const QColor & c);
QColor beatLineColor() const;
void setBeatLineColor(const QColor & c);
QColor lineColor() const;
void setLineColor(const QColor & c);
QBrush graphColor() const;
void setGraphColor(const QBrush & c);
QColor vertexColor() const;
void setVertexColor(const QColor & c);
QBrush scaleColor() const;
void setScaleColor(const QBrush & c);
QColor crossColor() const;
void setCrossColor(const QColor & c);
QColor backgroundShade() const;
void setBackgroundShade(const QColor & c);

enum EditModes
{
DRAW,
ERASE,
SELECT,
MOVE
DRAW_OUTVALUES
};

public slots:
Expand All @@ -127,12 +109,14 @@ public slots:
int xCoordOfTick( int tick );
float yCoordOfLevel( float level );
inline void drawLevelTick( QPainter & p, int tick, float value);// bool is_selected ); //NEEDS Change in CSS
void removeSelection();
void selectAll();
void getSelectedValues(timeMap & selected_values );

timeMap::iterator getNodeAt(int x, int y, bool outValue = false, int r = 5);

void drawLine( int x0, float y0, int x1, float y1 );
void removePoints( int x0, int x1 );
// Remove nodes from tick0 to tick1
void removeNodes(int tick0, int tick1);
// Reset the outValue of nodes from tick0 to tick1
void resetNodes(int tick0, int tick1);

protected slots:
void play();
Expand All @@ -148,11 +132,6 @@ protected slots:
void setProgressionType(int type);
void setTension();

void copySelectedValues();
void cutSelectedValues();
void pasteValues();
void deleteSelectedValues();

void updatePosition( const MidiTime & t );

void zoomingXChanged();
Expand All @@ -167,8 +146,10 @@ protected slots:
{
NONE,
MOVE_VALUE,
SELECT_VALUES,
MOVE_SELECTION
ERASE_VALUES,
MOVE_OUTVALUE,
RESET_OUTVALUES,
DRAW_LINE
} ;

// some constants...
Expand All @@ -187,7 +168,7 @@ protected slots:

static QPixmap * s_toolDraw;
static QPixmap * s_toolErase;
static QPixmap * s_toolSelect;
static QPixmap * s_toolDrawOut;
static QPixmap * s_toolMove;
static QPixmap * s_toolYFlip;
static QPixmap * s_toolXFlip;
Expand All @@ -200,7 +181,10 @@ protected slots:

FloatModel * m_tensionModel;

QMutex m_patternMutex;
// Mutex for making automation editor methods thread safe
// Mutable so we can lock it from const objects
mutable QMutex m_patternEditorMutex;

AutomationPattern * m_pattern;
float m_minLevel;
float m_maxLevel;
Expand All @@ -219,13 +203,6 @@ protected slots:

Actions m_action;

tick_t m_selectStartTick;
tick_t m_selectedTick;
float m_selectStartLevel;
float m_selectedLevels;

float m_moveStartLevel;
tick_t m_moveStartTick;
int m_moveXOffset;

float m_drawLastLevel;
Expand All @@ -235,9 +212,8 @@ protected slots:
int m_y_delta;
bool m_y_auto;

timeMap m_valuesToCopy;
timeMap m_selValuesForMove;

// Time position (key) of automation node whose outValue is being dragged
int m_draggedOutValueKey;

EditModes m_editMode;

Expand All @@ -255,7 +231,8 @@ protected slots:
QColor m_beatLineColor;
QColor m_lineColor;
QBrush m_graphColor;
QColor m_vertexColor;
QColor m_nodeInValueColor;
QColor m_nodeOutValueColor;
QBrush m_scaleColor;
QColor m_crossColor;
QColor m_backgroundShade;
Expand Down
142 changes: 142 additions & 0 deletions include/AutomationNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* AutomationNode.h - Declaration of class AutomationNode, which contains
* all information about an automation node
*
* Copyright (c) 2020 Ian Caio <iancaio_dev/at/hotmail.com>
*
* This file is part of LMMS - https://lmms.io
*
* 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 2 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef AUTOMATION_NODE_H
#define AUTOMATION_NODE_H


class AutomationPattern;


class AutomationNode
{
public:
AutomationNode(); // Dummy constructor for the QMap
AutomationNode(AutomationPattern* pat, float value, int pos);
AutomationNode(AutomationPattern* pat, float inValue, float outValue, int pos);

AutomationNode& operator+=(float f)
{
m_inValue += f;
m_outValue += f;
return *this;
}
AutomationNode& operator-=(float f)
{
m_inValue -= f;
m_outValue -= f;
return *this;
}
AutomationNode& operator*=(float f)
{
m_inValue *= f;
m_outValue *= f;
return *this;
}
AutomationNode& operator/=(float f)
{
m_inValue /= f;
m_outValue /= f;
return *this;
}

inline const float getInValue() const
{
return m_inValue;
}
void setInValue(float value);

inline const float getOutValue() const
{
return m_outValue;
}
void setOutValue(float value);

/**
* @brief Gets the offset between inValue and outValue
* @return Float representing the offset between inValue and outValue
*/
inline const float getValueOffset() const
{
return m_outValue - m_inValue;
}

/**
* @brief Gets the tangent of the left side of the node
* @return Float with the tangent from the inValue side
*/
inline const float getInTangent() const
{
return m_inTangent;
}

/**
* @brief Sets the tangent of the left side of the node
* @param Float with the tangent for the inValue side
*/
inline void setInTangent(float tangent)
{
m_inTangent = tangent;
}

/**
* @brief Gets the tangent of the right side of the node
* @return Float with the tangent from the outValue side
*/
inline const float getOutTangent() const
{
return m_outTangent;
}

/**
* @brief Sets the tangent of the right side of the node
* @param Float with the tangent for the outValue side
*/
inline void setOutTangent(float tangent)
{
m_outTangent = tangent;
}

private:
// Pattern that this node belongs to
AutomationPattern* m_pattern;

// Time position of this node (matches the timeMap key)
int m_pos;

// Values of this node
float m_inValue;
float m_outValue;

// Slope at each point for calculating spline
// We might have discrete jumps between curves, so we possibly have
// two different tangents for each side of the curve. If inValue and
// outValue are equal, inTangent and outTangent are equal too.
float m_inTangent;
float m_outTangent;
} ;
IanCaio marked this conversation as resolved.
Show resolved Hide resolved


#endif
Loading