refactor node gizmo release
This commit is contained in:
@@ -233,13 +233,11 @@ void CropDistortNode::GizmoMove(const QPointF &p, const rational &time, const Qt
|
||||
}
|
||||
}
|
||||
|
||||
void CropDistortNode::GizmoRelease()
|
||||
void CropDistortNode::GizmoRelease(MultiUndoCommand *command)
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
|
||||
gizmo_start_.clear();
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
virtual void GizmoRelease(MultiUndoCommand *command) override;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kLeftInput;
|
||||
|
||||
@@ -301,13 +301,11 @@ void TransformDistortNode::GizmoMove(const QPointF &p, const rational &time, con
|
||||
}
|
||||
}
|
||||
|
||||
void TransformDistortNode::GizmoRelease()
|
||||
void TransformDistortNode::GizmoRelease(MultiUndoCommand *command)
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
|
||||
gizmo_start_.clear();
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow &row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
virtual void GizmoRelease(MultiUndoCommand *command) override;
|
||||
|
||||
enum AutoScaleType {
|
||||
kAutoScaleNone,
|
||||
|
||||
@@ -297,13 +297,11 @@ void ShapeNodeBase::GizmoMove(const QPointF &p, const rational &time, const Qt::
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeNodeBase::GizmoRelease()
|
||||
void ShapeNodeBase::GizmoRelease(MultiUndoCommand *command)
|
||||
{
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
for (NodeInputDragger& i : gizmo_dragger_) {
|
||||
i.End(command);
|
||||
}
|
||||
Core::instance()->undo_stack()->push(command);
|
||||
gizmo_dragger_.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF &p) override;
|
||||
virtual void GizmoMove(const QPointF &p, const rational &time, const Qt::KeyboardModifiers &modifiers) override;
|
||||
virtual void GizmoRelease() override;
|
||||
virtual void GizmoRelease(MultiUndoCommand *command) override;
|
||||
|
||||
private:
|
||||
static QVector2D GenerateGizmoAnchor(const QVector2D &pos, const QVector2D &size, int drag, QVector2D *pt);
|
||||
|
||||
+1
-1
@@ -1504,7 +1504,7 @@ void Node::GizmoMove(const QPointF &, const rational&, const Qt::KeyboardModifie
|
||||
{
|
||||
}
|
||||
|
||||
void Node::GizmoRelease()
|
||||
void Node::GizmoRelease(MultiUndoCommand *)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -855,7 +855,7 @@ public:
|
||||
|
||||
virtual bool GizmoPress(const NodeValueRow& row, const NodeGlobals &globals, const QPointF& p);
|
||||
virtual void GizmoMove(const QPointF& p, const rational &time, const Qt::KeyboardModifiers &modifiers);
|
||||
virtual void GizmoRelease();
|
||||
virtual void GizmoRelease(MultiUndoCommand *command);
|
||||
|
||||
const QString& GetLabel() const;
|
||||
void SetLabel(const QString& s);
|
||||
|
||||
@@ -95,6 +95,40 @@ PanelManager *PanelManager::instance()
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void PanelManager::RegisterPanel(PanelWidget *panel)
|
||||
{
|
||||
// Add panel to the bottom of the focus history
|
||||
focus_history_.append(panel);
|
||||
|
||||
panel->SetMovementLocked(locked_);
|
||||
|
||||
// Get panel parent (it's assumed it has one)
|
||||
QWidget *parent = panel->parentWidget();
|
||||
|
||||
// Sane default for panel size
|
||||
panel->resize(parent->size() / 3);
|
||||
|
||||
// We're about to center the panel relative to the parent (usually the main window), but for some
|
||||
// reason this requires the panel to be shown first.
|
||||
panel->show();
|
||||
|
||||
// Center the panel relative to the parent
|
||||
QPoint parent_center = panel->mapFromGlobal(parent->mapToGlobal(parent->rect().center()));
|
||||
QPoint panel_center = panel->rect().center();
|
||||
panel->move(parent_center - panel_center);
|
||||
|
||||
if (focus_history_.size() == 1) {
|
||||
// This is the first panel, focus it
|
||||
panel->SetBorderVisible(true);
|
||||
emit FocusedPanelChanged(panel);
|
||||
}
|
||||
}
|
||||
|
||||
void PanelManager::UnregisterPanel(PanelWidget *panel)
|
||||
{
|
||||
focus_history_.removeOne(panel);
|
||||
}
|
||||
|
||||
void PanelManager::FocusChanged(QWidget *old, QWidget *now)
|
||||
{
|
||||
Q_UNUSED(old)
|
||||
@@ -151,11 +185,4 @@ void PanelManager::SetPanelsLocked(bool locked)
|
||||
locked_ = locked;
|
||||
}
|
||||
|
||||
void PanelManager::PanelDestroyed()
|
||||
{
|
||||
PanelWidget* panel = static_cast<PanelWidget*>(sender());
|
||||
|
||||
focus_history_.removeOne(panel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-46
@@ -84,12 +84,6 @@ public:
|
||||
*/
|
||||
T* MostRecentlyFocused();
|
||||
|
||||
template<class T>
|
||||
/**
|
||||
* @brief Create a panel
|
||||
*/
|
||||
T* CreatePanel(QWidget* parent);
|
||||
|
||||
/**
|
||||
* @brief Get whether panels are currently prevented from moving
|
||||
*/
|
||||
@@ -118,6 +112,16 @@ public:
|
||||
*/
|
||||
QList<T*> GetPanelsOfType();
|
||||
|
||||
/**
|
||||
* @brief Panel should call this upon construction so it can be kept track of
|
||||
*/
|
||||
void RegisterPanel(PanelWidget *panel);
|
||||
|
||||
/**
|
||||
* @brief Panel should call this upon destruction so no invalid pointers will be kept for it
|
||||
*/
|
||||
void UnregisterPanel(PanelWidget *panel);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Connect this to a QApplication's SIGNAL(focusChanged())
|
||||
@@ -153,48 +157,8 @@ private:
|
||||
*/
|
||||
static PanelManager* instance_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Processing if a panel gets deleted
|
||||
*/
|
||||
void PanelDestroyed();
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T *PanelManager::CreatePanel(QWidget *parent)
|
||||
{
|
||||
T* panel = new T(parent);
|
||||
|
||||
// Add panel to the bottom of the focus history
|
||||
focus_history_.append(panel);
|
||||
|
||||
panel->SetMovementLocked(locked_);
|
||||
|
||||
// Sane default for panel size
|
||||
panel->resize(parent->size() / 3);
|
||||
|
||||
// We're about to center the panel relative to the parent (usually the main window), but for some
|
||||
// reason this requires the panel to be shown first.
|
||||
panel->show();
|
||||
|
||||
// Center the panel relative to the parent
|
||||
QPoint parent_center = panel->mapFromGlobal(parent->mapToGlobal(parent->rect().center()));
|
||||
QPoint panel_center = panel->rect().center();
|
||||
panel->move(parent_center - panel_center);
|
||||
|
||||
// Connect destroy signal so we can remove it from focus history
|
||||
connect(panel, &PanelWidget::destroyed, this, &PanelManager::PanelDestroyed, Qt::DirectConnection);
|
||||
|
||||
if (focus_history_.size() == 1) {
|
||||
// This is the first panel, focus it
|
||||
panel->SetBorderVisible(true);
|
||||
emit FocusedPanelChanged(panel);
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T* PanelManager::MostRecentlyFocused()
|
||||
{
|
||||
|
||||
@@ -271,7 +271,9 @@ void ViewerDisplayWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
} else if (gizmo_click_) {
|
||||
|
||||
// Handle gizmo
|
||||
gizmos_->GizmoRelease();
|
||||
MultiUndoCommand *command = new MultiUndoCommand();
|
||||
gizmos_->GizmoRelease(command);
|
||||
undo_stack()->pushIfHasChildren(command);
|
||||
gizmo_click_ = false;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -78,17 +78,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
setStatusBar(status_bar);
|
||||
|
||||
// Create standard panels
|
||||
node_panel_ = PanelManager::instance()->CreatePanel<NodePanel>(this);
|
||||
footage_viewer_panel_ = PanelManager::instance()->CreatePanel<FootageViewerPanel>(this);
|
||||
param_panel_ = PanelManager::instance()->CreatePanel<ParamPanel>(this);
|
||||
curve_panel_ = PanelManager::instance()->CreatePanel<CurvePanel>(this);
|
||||
sequence_viewer_panel_ = PanelManager::instance()->CreatePanel<SequenceViewerPanel>(this);
|
||||
pixel_sampler_panel_ = PanelManager::instance()->CreatePanel<PixelSamplerPanel>(this);
|
||||
node_panel_ = new NodePanel(undo_stack_, this);
|
||||
footage_viewer_panel_ = new FootageViewerPanel(undo_stack_, this);
|
||||
param_panel_ = new ParamPanel(undo_stack_, this);
|
||||
curve_panel_ = new CurvePanel(undo_stack_, this);
|
||||
sequence_viewer_panel_ = new SequenceViewerPanel(undo_stack_, this);
|
||||
pixel_sampler_panel_ = new PixelSamplerPanel(undo_stack_, this);
|
||||
AppendProjectPanel();
|
||||
tool_panel_ = PanelManager::instance()->CreatePanel<ToolPanel>(this);
|
||||
task_man_panel_ = PanelManager::instance()->CreatePanel<TaskManagerPanel>(this);
|
||||
tool_panel_ = new ToolPanel(undo_stack_, this);
|
||||
task_man_panel_ = new TaskManagerPanel(undo_stack_, this);
|
||||
AppendTimelinePanel();
|
||||
audio_monitor_panel_ = PanelManager::instance()->CreatePanel<AudioMonitorPanel>(this);
|
||||
audio_monitor_panel_ = new AudioMonitorPanel(undo_stack_, this);
|
||||
|
||||
// Make node-related connections
|
||||
connect(node_panel_, &NodePanel::NodesSelected, param_panel_, &ParamPanel::SelectNodes);
|
||||
@@ -218,7 +218,7 @@ bool MainWindow::IsSequenceOpen(Sequence *sequence) const
|
||||
|
||||
void MainWindow::FolderOpen(Project* p, Folder *i, bool floating)
|
||||
{
|
||||
ProjectPanel* panel = PanelManager::instance()->CreatePanel<ProjectPanel>(this);
|
||||
ProjectPanel* panel = new ProjectPanel(undo_stack_, this);
|
||||
|
||||
panel->set_project(p);
|
||||
panel->set_root(i);
|
||||
@@ -256,7 +256,7 @@ void MainWindow::OpenNodeInViewer(ViewerOutput *node)
|
||||
viewer_panels_.value(node)->raise();
|
||||
} else {
|
||||
// Create a viewer for this node
|
||||
ViewerPanel* viewer = PanelManager::instance()->CreatePanel<ViewerPanel>(this);
|
||||
ViewerPanel* viewer = new ViewerPanel(undo_stack_, this);
|
||||
|
||||
viewer->SetSignalInsteadOfClose(true);
|
||||
viewer->setFloating(true);
|
||||
@@ -816,7 +816,7 @@ void MainWindow::showEvent(QShowEvent *e)
|
||||
template<typename T>
|
||||
T *MainWindow::AppendPanelInternal(QList<T*>& list)
|
||||
{
|
||||
T* panel = PanelManager::instance()->CreatePanel<T>(this);
|
||||
T* panel = new T(undo_stack_, this);
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
tabifyDockWidget(list.last(), panel);
|
||||
@@ -837,7 +837,7 @@ T *MainWindow::AppendPanelInternal(QList<T*>& list)
|
||||
template<typename T>
|
||||
T *MainWindow::AppendFloatingPanelInternal(QList<T *> &list)
|
||||
{
|
||||
T* panel = PanelManager::instance()->CreatePanel<T>(this);
|
||||
T* panel = new T(undo_stack_, this);
|
||||
|
||||
panel->setFloating(true);
|
||||
panel->show();
|
||||
|
||||
Reference in New Issue
Block a user