Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9aa997e
Allow TabWidget to be variable sized
JohannesLorenz Mar 16, 2019
dd43127
Allow instrument views to grow with contents
JohannesLorenz Mar 16, 2019
5101aa0
Make Model class visitable
JohannesLorenz Mar 16, 2019
7e7141f
Fix too small instrument tabs
JohannesLorenz Mar 17, 2019
d52c220
Fix instrument window tab sizes
JohannesLorenz Mar 28, 2019
82e3ba7
[Equalizer] Bright analyzer colors, opacity increased (#4772)
0xf0xx0 Apr 6, 2019
91f9f1a
Don't try to connect to nonexistent controllers (#4939)
enp2s0 Apr 14, 2019
5a56969
Allow sample track TCOs to resize smaller than one bar (#4933)
Spekular Apr 15, 2019
5784dd6
Use local cursor for TrackContentObjectView (#4918)
Apr 15, 2019
96cc5e0
Add PluginIssue class (#4901)
JohannesLorenz Apr 17, 2019
d06f508
Move macro definition out of class
JohannesLorenz Apr 20, 2019
91099e2
Fix -1 offset in plugin tab
JohannesLorenz Apr 20, 2019
53942a1
Fix bad identation in old code
JohannesLorenz Apr 20, 2019
e1df16c
Coding conventions
JohannesLorenz Apr 20, 2019
407444e
FileBrowser: Backup expanded directories and restore that state when …
Apr 3, 2019
22fb650
Merge branch 'variable-tab-widget'
JohannesLorenz Apr 22, 2019
a685049
Allow build for Wayland w/o X11Extras, if VST off
nykula Apr 19, 2019
d537561
Document Effect::checkGate
JohannesLorenz Apr 22, 2019
7ae4e85
Document graph widget
JohannesLorenz Apr 22, 2019
b5e408d
Update wiki submodule
JohannesLorenz Apr 22, 2019
c80f0bf
Fix wiki submodule
PhysSong Apr 24, 2019
461facc
Fix notes getting stuck under high CPU conditions (#4908)
DomClark Apr 24, 2019
160d306
Record chords (#4938)
alxdttn Apr 24, 2019
ca9a956
Make more connections direct for automation (#4942)
DomClark Apr 26, 2019
0fd5693
Improve dcast
JohannesLorenz Apr 26, 2019
8d005e7
AutomatableModelTest: Improve tests
JohannesLorenz Apr 27, 2019
777da5e
Fix CI on windows
JohannesLorenz Apr 27, 2019
2c134d6
Code style + Extend for TempoSyncKnob
JohannesLorenz Apr 27, 2019
c9ed6fc
Merge pull request #4902 from JohannesLorenz/model-visitor
JohannesLorenz Apr 27, 2019
8bcdf06
Travis: fix a debootstrap error from missing keyrings
PhysSong Apr 29, 2019
32df2d7
Don't draw note detuning info over the volume/panning area (#4965)
PhysSong May 5, 2019
cb6b4ec
Show/Focus BBEditor on TrackLabelButton click #4946 (#4959)
May 5, 2019
8f4757e
Use extracted linuxdeployqt directly
PhysSong May 6, 2019
9ff882d
Fix invisible note editing handles when a note has detuning info
PhysSong May 6, 2019
6d7ce58
Merge branch 'stable-1.2'
PhysSong May 6, 2019
d54c79d
Fix the wrong merge
PhysSong May 6, 2019
28143e6
playing/recording pianoRoll's chord notes (#4963)
sharpblade4 May 24, 2019
fb1b18e
Merge pull request #4990 from sharpblade4/fix#4963_nextver
JohannesLorenz May 25, 2019
46c74d0
Making clearer the hierarchy. (#4967)
devnexen May 27, 2019
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
Prev Previous commit
Next Next commit
Make Model class visitable
  • Loading branch information
JohannesLorenz committed Mar 16, 2019
commit 5101aa021440c9e6c183fd197af09154df5d619a
45 changes: 45 additions & 0 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "MidiTime.h"
#include "ValueBuffer.h"
#include "MemoryManager.h"
#include "ModelVisitor.h"

// simple way to map a property of a view to a model
#define mapPropertyFromModelPtr(type,getfunc,setfunc,modelname) \
Expand Down Expand Up @@ -68,6 +69,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
Q_OBJECT
MM_OPERATORS
public:

typedef QVector<AutomatableModel *> AutoModelVector;

enum ScaleType
Expand All @@ -80,6 +82,32 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject

virtual ~AutomatableModel();

// Implement those by using the MODEL_IS_VISITABLE macro
virtual void accept(ModelVisitor& v) = 0;
virtual void accept(ConstModelVisitor& v) const = 0;
// use this to make subclasses visitable
#define MODEL_IS_VISITABLE \
void accept(ModelVisitor& v) override { v.visit(*this); } \
void accept(ConstModelVisitor& v) const override { v.visit(*this); }

public:
//! Return this class casted to Target, or nullptr if impossible
template<class Target>
Target* dcast(bool doThrow = false)
{
DCastVisitor<Target> vis; accept(vis);
if(doThrow && !vis.result) Q_ASSERT(false);
return vis.result;
}

//! Return this class casted to const Target, or nullptr if impossible
template<class Target>
const Target* dcast(bool doThrow = false) const
{
ConstDCastVisitor<Target> vis; accept(vis);
if(doThrow && !vis.result) Q_ASSERT(false);
return vis.result;
}

bool isAutomated() const;
bool isAutomatedOrControlled() const
Expand Down Expand Up @@ -283,6 +311,20 @@ public slots:


private:
template<class Target>
struct DCastVisitor : public ModelVisitor
{
Target* result = nullptr;
void visit(Target& tar) { result = &tar; }
};

template<class Target>
struct ConstDCastVisitor : public ConstModelVisitor
{
const Target* result = nullptr;
void visit(const Target& tar) { result = &tar; }
};

static bool mustQuoteName(const QString &name);

virtual void saveSettings( QDomDocument& doc, QDomElement& element )
Expand Down Expand Up @@ -382,6 +424,7 @@ template <typename T> class LMMS_EXPORT TypedAutomatableModel : public Automatab
class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
FloatModel( float val = 0, float min = 0, float max = 0, float step = 0,
Model * parent = NULL,
Expand All @@ -399,6 +442,7 @@ class LMMS_EXPORT FloatModel : public TypedAutomatableModel<float>
class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
IntModel( int val = 0, int min = 0, int max = 0,
Model* parent = NULL,
Expand All @@ -414,6 +458,7 @@ class LMMS_EXPORT IntModel : public TypedAutomatableModel<int>
class LMMS_EXPORT BoolModel : public TypedAutomatableModel<bool>
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
BoolModel( const bool val = false,
Model* parent = NULL,
Expand Down
1 change: 1 addition & 0 deletions include/ComboBoxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
class LMMS_EXPORT ComboBoxModel : public IntModel
{
Q_OBJECT
MODEL_IS_VISITABLE
public:
ComboBoxModel( Model* parent = NULL,
const QString& displayName = QString(),
Expand Down
53 changes: 53 additions & 0 deletions include/ModelVisitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* ModelVisitor.h - visitors for automatable models
*
* Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
*
* 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 MODELVISITOR_H
#define MODELVISITOR_H

class BoolModel;
class IntModel;
class FloatModel;
class ComboBoxModel;

class ModelVisitor
{
public:
virtual void visit(BoolModel& ) {}
virtual void visit(IntModel& ) {}
virtual void visit(FloatModel& ) {}
virtual void visit(ComboBoxModel& ) {}
virtual ~ModelVisitor();
};

class ConstModelVisitor
{
public:
virtual void visit(const BoolModel& ) {}
virtual void visit(const IntModel& ) {}
virtual void visit(const FloatModel& ) {}
virtual void visit(const ComboBoxModel& ) {}
virtual ~ConstModelVisitor();
};

#endif // MODELVISITOR_H
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set(LMMS_SRCS
core/MixerWorkerThread.cpp
core/MixHelpers.cpp
core/Model.cpp
core/ModelVisitor.cpp
core/Note.cpp
core/NotePlayHandle.cpp
core/Oscillator.cpp
Expand Down
28 changes: 28 additions & 0 deletions src/core/ModelVisitor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* ModelVisitor.cpp - visitors for automatable models
*
* Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
*
* 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.
*
*/

#include "ModelVisitor.h"

ModelVisitor::~ModelVisitor() {}
ConstModelVisitor::~ConstModelVisitor() {}