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

Demo: Piano-Roll chop, stamp, strum, bulldozer and mode switcher #6140

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Binary file added data/themes/classic/edit_bulldozer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/classic/edit_stamp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/classic/edit_strum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/classic/quantize_len.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/classic/quantize_pos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/edit_bulldozer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/edit_stamp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/edit_strum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/quantize_len.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/quantize_pos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions include/ActionGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class ActionGroup : public QActionGroup
/// This signal is emitted when the action at the given index is triggered.
void triggered(int index);

public slots:
void setChecked(const int index);

private slots:
void actionTriggered_(QAction* action);

private:
QList<QAction*> m_actions;
};

#endif
49 changes: 49 additions & 0 deletions include/ComboButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* ComboButton.h - a QToolButton that remembers its last used action
*
* Copyright (c) 2021 Alex <allejok96>
*
* 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 COMBOBUTTON_H
#define COMBOBUTTON_H

#include <QToolButton>


class ComboButton : public QToolButton
{
Q_OBJECT
public:
ComboButton(QWidget* parent = nullptr, bool triggerOnScroll = false);

void addAction(QAction* action);
QAction* addAction(const QString& pixmap, const QString& text);

void addActions(QList<QAction*> actions);

protected:
void wheelEvent(QWheelEvent* event) override;

private:
bool m_triggerOnScroll;
} ;

#endif
56 changes: 56 additions & 0 deletions include/HexMenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* HexMenu.h - hexagonal menu widget
*
* Copyright (c) 2021 Alex <allejok96/gmail>
*
* 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 CIRCULAR_MENU_H
#define CIRCULAR_MENU_H

#include <QWidget>
#include <QMenu>
#include "lmms_export.h"

class LMMS_EXPORT HexMenu : public QWidget
{
Q_OBJECT
public:
HexMenu(QWidget* parent = nullptr);
virtual ~HexMenu();
void addAction(QAction* action);
void addMenu(QMenu* menu);

protected slots:
void mouseMoveEvent(QMouseEvent* event) override;
void paintEvent(QPaintEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;

private:
bool m_mouseHasMoved = false;

QMenu* m_contextMenu = nullptr;

std::vector<QAction*> m_actions;
int m_hoveredAction;
};

#endif
18 changes: 17 additions & 1 deletion include/Note.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class LMMS_EXPORT Note : public SerializingObject
{
m_oldLength = oldLength;
}
inline void setOldSelected(const bool selected)
{
m_oldSelected = selected;
}
inline void setIsPlaying( const bool isPlaying )
{
m_isPlaying = isPlaying;
Expand Down Expand Up @@ -153,6 +157,11 @@ class LMMS_EXPORT Note : public SerializingObject
return m_oldLength;
}

inline bool oldSelected() const
{
return m_oldSelected;
}

inline bool isPlaying() const
{
return m_isPlaying;
Expand Down Expand Up @@ -233,6 +242,7 @@ class LMMS_EXPORT Note : public SerializingObject
int m_oldKey;
TimePos m_oldPos;
TimePos m_oldLength;
bool m_oldSelected;
bool m_isPlaying;

int m_key;
Expand All @@ -244,7 +254,13 @@ class LMMS_EXPORT Note : public SerializingObject
};


typedef QVector<Note *> NoteVector;
class NoteVector : public QVector<Note*>
{
public:
using QVector::QVector;

TimePos lastEndPos();
};


#endif
44 changes: 24 additions & 20 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <QInputDialog>

#include "Editor.h"
#include "HexMenu.h"
#include "ComboBoxModel.h"
#include "SerializingObject.h"
#include "Note.h"
Expand Down Expand Up @@ -99,7 +100,10 @@ class PianoRoll : public QWidget
ModeErase,
ModeSelect,
ModeEditDetuning,
ModeEditKnife
ModeEditKnife,
ModeBulldozer,
ModeStamp,
ModeStrum
};

/*! \brief Resets settings to default when e.g. creating a new project */
Expand Down Expand Up @@ -159,6 +163,7 @@ class PianoRoll : public QWidget
void mouseDoubleClickEvent( QMouseEvent * me ) override;
void mouseReleaseEvent( QMouseEvent * me ) override;
void mouseMoveEvent( QMouseEvent * me ) override;
void contextMenuEvent(QContextMenuEvent* cme) override;
void paintEvent( QPaintEvent * pe ) override;
void resizeEvent( QResizeEvent * re ) override;
void wheelEvent( QWheelEvent * we ) override;
Expand Down Expand Up @@ -193,6 +198,7 @@ protected slots:
void verScrolled( int new_pos );

void setEditMode(int mode);
void setQuickEditMode(int mode);

void copySelectedNotes();
void cutSelectedNotes();
Expand Down Expand Up @@ -229,6 +235,7 @@ protected slots:

signals:
void currentPatternChanged();
void editModeChanged(int);
void ghostPatternSet(bool);
void semiToneMarkerMenuScaleSetEnabled(bool);
void semiToneMarkerMenuChordSetEnabled(bool);
Expand All @@ -240,10 +247,16 @@ protected slots:
ActionNone,
ActionMoveNote,
ActionResizeNote,
ActionBulldozerMove,
ActionBulldozerResize,
ActionEraseNote,
ActionSelectNotes,
ActionChangeNoteProperty,
ActionResizeNoteEditArea,
ActionKnife
ActionDetune,
ActionKnife,
ActionStrum,
ActionStrumResize
};

enum NoteEditMode
Expand Down Expand Up @@ -306,9 +319,6 @@ protected slots:
void playChordNotes(int key, int velocity=-1);
void pauseChordNotes(int key);

void setKnifeAction();
void cancelKnifeAction();

void updateScrollbars();
void updatePositionLineHeight();

Expand All @@ -326,13 +336,6 @@ protected slots:
static const int cm_scrollAmtHoriz = 10;
static const int cm_scrollAmtVert = 1;

static QPixmap * s_toolDraw;
static QPixmap * s_toolErase;
static QPixmap * s_toolSelect;
static QPixmap * s_toolMove;
static QPixmap * s_toolOpen;
static QPixmap* s_toolKnife;

static PianoRollKeyTypes prKeyOrder[];

static TextFloat * s_textFloat;
Expand Down Expand Up @@ -416,11 +419,9 @@ protected slots:
int m_startKey; // first key when drawing
int m_lastKey;

EditModes m_editMode;
EditModes m_ctrlMode; // mode they were in before they hit ctrl
EditModes m_knifeMode; // mode they where in before entering knife mode

bool m_mouseDownRight; //true if right click is being held down
EditModes m_editMode = ModeDraw;
EditModes m_ctrlMode = m_editMode; // mode they were in before they hit ctrl
EditModes m_quickEditMode = ModeEditDetuning; // edit mode activated by middle mouse button

TimeLineWidget * m_timeLine;
bool m_scrollBack;
Expand All @@ -436,10 +437,12 @@ protected slots:
void clearSelectedNotes();

// did we start a mouseclick with shift pressed
bool m_startedWithShift;
//bool m_startedWithShift;

// Variable that holds the position in ticks for the knife action
int m_knifeTickPos;
// Length of knife chop
int m_knifeChopTicks;
void updateKnifePos(QMouseEvent* me);

friend class PianoRollWindow;
Expand Down Expand Up @@ -530,6 +533,8 @@ class PianoRollWindow : public Editor, SerializingObject
signals:
void currentPatternChanged();

protected slots:
void contextMenuEvent(QContextMenuEvent* event) override;

private slots:
void updateAfterPatternChange();
Expand All @@ -544,8 +549,8 @@ private slots:
void updateStepRecordingIcon();

PianoRoll* m_editor;
HexMenu* m_editModeSelector;

QToolButton* m_fileToolsButton;
ComboBox * m_zoomingComboBox;
ComboBox * m_zoomingYComboBox;
ComboBox * m_quantizeComboBox;
Expand All @@ -555,7 +560,6 @@ private slots:
ComboBox * m_chordComboBox;
ComboBox* m_snapComboBox;
QPushButton * m_clearGhostButton;

};


Expand Down
18 changes: 18 additions & 0 deletions src/core/Note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,21 @@ bool Note::withinRange(int tickStart, int tickEnd) const
return pos().getTicks() >= tickStart && pos().getTicks() <= tickEnd
&& length().getTicks() != 0;
}




TimePos NoteVector::lastEndPos()
{
tick_t last = 0;

for (Note* note: *this)
{
if (note->length() > 0)
{
last = std::max(last, note->endPos().getTicks());
}
}

return last;
}
8 changes: 8 additions & 0 deletions src/gui/ActionGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ QAction* ActionGroup::addAction(const QIcon& icon, const QString& text)
return addAction(new QAction(icon, text, this));
}

void ActionGroup::setChecked(const int index)
{
if (0 <= index && index < actions().length())
{
actions().at(index)->setChecked(true);
}
}

void ActionGroup::actionTriggered_(QAction* action)
{
Q_ASSERT(action != 0);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ SET(LMMS_SRCS
gui/widgets/AutomatableSlider.cpp
gui/widgets/CaptionMenu.cpp
gui/widgets/ComboBox.cpp
gui/widgets/ComboButton.cpp
gui/widgets/ControllerRackView.cpp
gui/widgets/ControllerView.cpp
gui/widgets/Controls.cpp
Expand All @@ -76,6 +77,7 @@ SET(LMMS_SRCS
gui/widgets/FxLineLcdSpinBox.cpp
gui/widgets/Graph.cpp
gui/widgets/GroupBox.cpp
gui/widgets/HexMenu.cpp
gui/widgets/InstrumentFunctionViews.cpp
gui/widgets/InstrumentMidiIOView.cpp
gui/widgets/InstrumentSoundShapingView.cpp
Expand Down
Loading