Skip to content

Commit

Permalink
Better fix for automation rescale issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Mar 30, 2021
1 parent 352219a commit 179a8ac
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class MultiOngoingCommandDispatcher final : public ICommandDispatcher
theCmd->addCommand(cmd);
}

SendStrategy::Quiet::send(stack(), theCmd);
SendStrategy::UndoRedo::send(stack(), theCmd);
m_cmds.clear();

stack().enableActions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class OngoingCommandDispatcher final : public ICommandDispatcher
{
if (m_cmd)
{
SendStrategy::Quiet::send(stack(), m_cmd.release());
SendStrategy::UndoRedo::send(stack(), m_cmd.release());
stack().enableActions();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ void ProcessModel::setDurationAndGrow(const TimeVal& newDuration) noexcept

void ProcessModel::setDurationAndShrink(const TimeVal& newDuration) noexcept
{
// let's assume that automations just can't shrink
return;
/*
// If there are no segments, nothing changes
if (m_curve->segments().size() == 0)
{
Expand All @@ -169,6 +165,7 @@ void ProcessModel::setDurationAndShrink(const TimeVal& newDuration) noexcept

if(newDuration <= TimeVal::zero())
{
setDuration(TimeVal::zero());
m_curve->clear();
return;
}
Expand Down Expand Up @@ -207,7 +204,6 @@ void ProcessModel::setDurationAndShrink(const TimeVal& newDuration) noexcept
//
setDuration(newDuration);
m_curve->changed();
*/
}

void ProcessModel::setCurve_impl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <Inspector/InspectorWidgetBase.hpp>
#include <Process/TimeValue.hpp>

#include <score/document/DocumentContext.hpp>
#include <score/command/Dispatchers/CommandDispatcher.hpp>
#include <score/command/Dispatchers/OngoingCommandDispatcher.hpp>
#include <score/widgets/SignalUtils.hpp>
Expand All @@ -29,7 +30,7 @@ PointInspectorWidget::PointInspectorWidget(
QWidget* parent)
: InspectorWidgetBase{model, doc, parent, tr("Point")}
, m_model{model}
, m_dispatcher{commandDispatcher()->stack()}
, m_dispatcher{doc.dispatcher}
{
setObjectName("CurvePointInspectorWidget");
setParent(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PointInspectorWidget final : public Inspector::InspectorWidgetBase
const Curve::PointModel& m_model;
QDoubleSpinBox* m_XBox;
QDoubleSpinBox* m_YBox;
OngoingCommandDispatcher m_dispatcher;
OngoingCommandDispatcher& m_dispatcher;
double m_yFactor;
double m_xFactor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void PowerSegment::updateData(int numInterp) const
{
m_data.resize(numInterp + 1);
double start_x = start().x();

double start_y = start().y();
double end_x = end().x();
double end_y = end().y();
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/score-plugin-media/Media/Merger/Inspector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <score/document/DocumentContext.hpp>
#include <score/widgets/DoubleSlider.hpp>
#include <score/widgets/SignalUtils.hpp>
#include <score/tools/Bind.hpp>

#include <QFormLayout>
#include <QSpinBox>
Expand All @@ -20,7 +21,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<Model>
{
public:
explicit InspectorWidget(const Model& obj, const score::DocumentContext& doc, QWidget* parent)
: InspectorWidgetDelegate_T{obj, parent}, m_dispatcher{doc.commandStack}, m_count{this}
: InspectorWidgetDelegate_T{obj, parent}, m_dispatcher{doc.dispatcher}, m_count{this}
{
m_count.setRange(1, 24);
m_count.setValue(obj.inCount());
Expand All @@ -38,7 +39,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<Model>
}

private:
OngoingCommandDispatcher m_dispatcher;
OngoingCommandDispatcher& m_dispatcher;

QSpinBox m_count;
};
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/score-plugin-media/Media/Step/Inspector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<Model>
public:
explicit InspectorWidget(const Model& obj, const score::DocumentContext& doc, QWidget* parent)
: InspectorWidgetDelegate_T{obj, parent}
, m_dispatcher{doc.commandStack}
, m_dispatcher{doc.dispatcher}
, m_count{this}
, m_dur{this}
, m_min{this}
Expand Down Expand Up @@ -67,7 +67,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<Model>
}

private:
OngoingCommandDispatcher m_dispatcher;
OngoingCommandDispatcher& m_dispatcher;

QSpinBox m_count;
QSpinBox m_dur;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/score-plugin-midi/Patternist/PatternInspector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<ProcessM
const score::DocumentContext& doc,
QWidget* parent)
: InspectorWidgetDelegate_T{obj, parent}
, m_dispatcher{doc.commandStack}
, m_dispatcher{doc.dispatcher}
, m_channel{this}
, m_currentPattern{this}
, m_lanes{this}
Expand Down Expand Up @@ -133,7 +133,7 @@ class InspectorWidget final : public Process::InspectorWidgetDelegate_T<ProcessM
}

private:
OngoingCommandDispatcher m_dispatcher;
OngoingCommandDispatcher& m_dispatcher;

QSpinBox m_channel;
QSpinBox m_currentPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EditionGrid : public QWidget
, m_dur{m.duration}
, m_editionSettings{set}
, m_moveFactory{fac.app.interfaces<IntervalResizerList>().find(m)}
, m_dispatcher{fac.commandStack}
, m_dispatcher{fac.dispatcher}
, m_simpleDispatcher{fac.commandStack}
{
using namespace score;
Expand Down Expand Up @@ -353,7 +353,7 @@ class EditionGrid : public QWidget
TimeVal m_max;
TimeVal m_min;

OngoingCommandDispatcher m_dispatcher;
OngoingCommandDispatcher& m_dispatcher;
CommandDispatcher<> m_simpleDispatcher;
};
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ScenarioPresenter::ScenarioPresenter(
, m_view{static_cast<ScenarioView*>(view)}
, m_viewInterface{*this}
, m_editionSettings{e}
, m_ongoingDispatcher{context.commandStack}
, m_selectionDispatcher{context.selectionStack}
, m_sm{m_context, *this}
{
Expand Down Expand Up @@ -987,11 +986,11 @@ void ScenarioPresenter::on_commentCreated(const CommentBlockModel& comment_block
// Commands
connect(cmt_pres, &CommentBlockPresenter::moved, this, [&](QPointF scenPos) {
auto pos = Scenario::ConvertToScenarioPoint(scenPos, m_zoomRatio, m_view->height());
m_ongoingDispatcher.submit<MoveCommentBlock>(
this->context().context.dispatcher.submit<MoveCommentBlock>(
model(), comment_block_model.id(), pos.date, pos.y);
});
connect(cmt_pres, &CommentBlockPresenter::released, this, [&](QPointF scenPos) {
m_ongoingDispatcher.commit();
this->context().context.dispatcher.commit();
});

connect(cmt_pres, &CommentBlockPresenter::editFinished, this, [&](const QString& doc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioPresenter final : public Process::Lay

Scenario::EditionSettings& m_editionSettings;

OngoingCommandDispatcher m_ongoingDispatcher;

score::SelectionDispatcher m_selectionDispatcher;
Scenario::ToolPalette m_sm;

Expand Down

0 comments on commit 179a8ac

Please sign in to comment.