started parameter editor

This commit is contained in:
itsmattkc
2019-07-19 00:15:59 -07:00
parent 98bb3e8d81
commit 136bb52fef
15 changed files with 527 additions and 4 deletions
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(node)
add_subdirectory(param)
add_subdirectory(project)
add_subdirectory(taskmanager)
add_subdirectory(timeline)
+3
View File
@@ -26,6 +26,9 @@ NodePanel::NodePanel(QWidget *parent) :
// Create NodeView widget
node_view_ = new NodeView(this);
// Connect node view signals to this panel
connect(node_view_, SIGNAL(SelectionChanged(QList<Node*>)), this, SIGNAL(SelectionChanged(QList<Node*>)));
// Set it as the main widget of this panel
setWidget(node_view_);
+6
View File
@@ -38,6 +38,12 @@ public:
protected:
virtual void changeEvent(QEvent* e) override;
signals:
/**
* @brief Wrapper for NodeView::SelectionChanged()
*/
void SelectionChanged(QList<Node*> selected_nodes);
private:
void Retranslate();
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 Olive Team
#
# 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 3 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. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
panel/param/param.h
panel/param/param.cpp
PARENT_SCOPE
)
+50
View File
@@ -0,0 +1,50 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#include "param.h"
ParamPanel::ParamPanel(QWidget* parent) :
PanelWidget(parent)
{
view_ = new NodeParamView(this);
setWidget(view_);
Retranslate();
}
void ParamPanel::SetNodes(QList<Node *> nodes)
{
view_->SetNodes(nodes);
}
void ParamPanel::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
Retranslate();
}
QDockWidget::changeEvent(e);
}
void ParamPanel::Retranslate()
{
SetTitle(tr("Parameter Editor"));
SetSubtitle(tr("(none)"));
}
+45
View File
@@ -0,0 +1,45 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef PARAM_H
#define PARAM_H
#include "widget/nodeparamview/nodeparamview.h"
#include "widget/panel/panel.h"
class ParamPanel : public PanelWidget
{
Q_OBJECT
public:
ParamPanel(QWidget* parent);
public slots:
void SetNodes(QList<Node*> nodes);
protected:
virtual void changeEvent(QEvent* e);
private:
void Retranslate();
NodeParamView* view_;
};
#endif // PARAM_H
+1
View File
@@ -17,6 +17,7 @@
add_subdirectory(flowlayout)
add_subdirectory(menu)
add_subdirectory(nodeview)
add_subdirectory(nodeparamview)
add_subdirectory(panel)
add_subdirectory(playbackcontrols)
add_subdirectory(projectexplorer)
+24
View File
@@ -0,0 +1,24 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 Olive Team
#
# 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 3 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. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/nodeparamview/nodeparamview.h
widget/nodeparamview/nodeparamview.cpp
widget/nodeparamview/nodeparamviewitem.h
widget/nodeparamview/nodeparamviewitem.cpp
PARENT_SCOPE
)
@@ -0,0 +1,73 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#include "nodeparamview.h"
NodeParamView::NodeParamView(QWidget *parent) :
QWidget(parent)
{
// Set new layout
layout_ = new QVBoxLayout(this);
layout_->setSpacing(0);
layout_->setMargin(0);
// Add a stretch to allow empty space at the bottom of the layout
layout_->addStretch();
}
void NodeParamView::SetNodes(QList<Node *> nodes)
{
// If we already have item widgets, delete them all now
foreach (NodeParamViewItem* item, items_) {
delete item;
}
items_.clear();
// Set the internal list to the one we've received
nodes_ = nodes;
// For each node, create a widget
foreach (Node* node, nodes_) {
// See if we already have an item for this node type
bool merged_node = false;
foreach (NodeParamViewItem* existing_item, items_) {
if (existing_item->CanAddNode(node)) {
existing_item->AttachNode(node);
merged_node = true;
break;
}
}
// If we couldn't merge this node into the existing item, create a new one
if (!merged_node) {
NodeParamViewItem* item = new NodeParamViewItem(this);
item->AttachNode(node);
// Insert the widget before the stretch
layout_->insertWidget(layout_->count() - 1, item);
items_.append(item);
}
}
}
+45
View File
@@ -0,0 +1,45 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEPARAMVIEW_H
#define NODEPARAMVIEW_H
#include <QVBoxLayout>
#include <QWidget>
#include "node/node.h"
#include "nodeparamviewitem.h"
class NodeParamView : public QWidget
{
public:
NodeParamView(QWidget* parent);
void SetNodes(QList<Node*> nodes);
private:
QVBoxLayout* layout_;
QList<Node*> nodes_;
QList<NodeParamViewItem*> items_;
};
#endif // NODEPARAMVIEW_H
@@ -0,0 +1,142 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#include "nodeparamviewitem.h"
#include <QDebug>
#include <QPainter>
#include "ui/icons/icons.h"
NodeParamViewItem::NodeParamViewItem(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout* main_layout = new QVBoxLayout(this);
main_layout->setSpacing(0);
main_layout->setMargin(0);
// Create title bar widget
title_bar_ = new NodeParamViewItemTitleBar(this);
title_bar_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
QHBoxLayout* title_bar_layout = new QHBoxLayout(title_bar_);
title_bar_collapse_btn_ = new QPushButton();
title_bar_collapse_btn_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
title_bar_collapse_btn_->setStyleSheet("border: none; background: none;");
title_bar_collapse_btn_->setCheckable(true);
title_bar_collapse_btn_->setChecked(true);
connect(title_bar_collapse_btn_, SIGNAL(clicked(bool)), this, SLOT(SetExpanded(bool)));
title_bar_layout->addWidget(title_bar_collapse_btn_);
title_bar_lbl_ = new QLabel(title_bar_);
title_bar_layout->addWidget(title_bar_lbl_);
// Add title bar to widget
main_layout->addWidget(title_bar_);
// Create and add contents widget
contents_ = new QWidget(this);
content_layout_ = new QGridLayout(contents_);
main_layout->addWidget(contents_);
// Set correct widget state
SetExpanded(title_bar_collapse_btn_->isChecked());
}
void NodeParamViewItem::AttachNode(Node *n)
{
// Make sure we can attach this node (CanAddNode() should be run by the caller to make sure this node is valid)
Q_ASSERT(CanAddNode(n));
// Add node to the list
nodes_.append(n);
// If the added node was the first node, set up the UI
if (nodes_.size() == 1) {
SetupUI();
}
}
bool NodeParamViewItem::CanAddNode(Node* n)
{
// Ensures that all Nodes have the same ID
return (nodes_.isEmpty() || nodes_.first()->id() == n->id());
}
void NodeParamViewItem::changeEvent(QEvent *e)
{
// FIXME: Retranslate all UI elements
QWidget::changeEvent(e);
}
void NodeParamViewItem::SetupUI()
{
Q_ASSERT(!nodes_.isEmpty());
Node* first_node = nodes_.first();
title_bar_lbl_->setText(first_node->Name());
int row_count = 0;
for (int i=0;i<first_node->ParameterCount();i++) {
NodeParam* param = first_node->ParamAt(i);
// This widget only needs to show input parameters
if (param->type() == NodeParam::kInput) {
QLabel* param_label = new QLabel(tr("%1:").arg(param->name()));
content_layout_->addWidget(param_label, row_count, 0);
row_count++;
}
}
}
void NodeParamViewItem::SetExpanded(bool e)
{
expanded_ = e;
contents_->setVisible(e);
if (expanded_) {
title_bar_collapse_btn_->setIcon(olive::icon::TriDown);
} else {
title_bar_collapse_btn_->setIcon(olive::icon::TriRight);
}
}
NodeParamViewItemTitleBar::NodeParamViewItemTitleBar(QWidget *parent) :
QWidget(parent)
{
}
void NodeParamViewItemTitleBar::paintEvent(QPaintEvent *event)
{
QWidget::paintEvent(event);
QPainter p(this);
// Draw bottom border using text color
p.setPen(palette().text().color());
p.drawLine(0, height() - 1, width(), height() - 1);
}
@@ -0,0 +1,74 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
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 3 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. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef NODEPARAMVIEWITEM_H
#define NODEPARAMVIEWITEM_H
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>
#include "node/node.h"
class NodeParamViewItemTitleBar : public QWidget {
public:
NodeParamViewItemTitleBar(QWidget* parent = nullptr);
protected:
virtual void paintEvent(QPaintEvent *event) override;
};
class NodeParamViewItem : public QWidget
{
Q_OBJECT
public:
NodeParamViewItem(QWidget* parent);
void AttachNode(Node* n);
bool CanAddNode(Node *n);
protected:
void changeEvent(QEvent *e) override;
private:
void SetupUI();
bool expanded_;
NodeParamViewItemTitleBar* title_bar_;
QLabel* title_bar_lbl_;
QPushButton* title_bar_collapse_btn_;
QWidget* contents_;
QGridLayout* content_layout_;
QList<Node*> nodes_;
private slots:
void SetExpanded(bool e);
};
#endif // NODEPARAMVIEWITEM_H
+20
View File
@@ -29,6 +29,7 @@ NodeView::NodeView(QWidget *parent) :
setDragMode(RubberBandDrag);
connect(&scene_, SIGNAL(changed(const QList<QRectF>&)), this, SLOT(ItemsChanged()));
connect(&scene_, SIGNAL(selectionChanged()), this, SLOT(SceneSelectionChangedSlot()));
}
void NodeView::SetGraph(NodeGraph *graph)
@@ -149,3 +150,22 @@ void NodeView::ItemsChanged()
}
}
}
void NodeView::SceneSelectionChangedSlot()
{
// Get the scene's selected items and convert it into a list of selected nodes
QList<QGraphicsItem*> selected_items = scene_.selectedItems();
QList<Node*> selected_nodes;
for (int i=0;i<selected_items.size();i++) {
// Try to dynamically cast to a widget holding a Node
NodeViewItem* item = dynamic_cast<NodeViewItem*>(selected_items.at(i));
if (item != nullptr) {
selected_nodes.append(item->node());
}
}
emit SelectionChanged(selected_nodes);
}
+11
View File
@@ -74,6 +74,12 @@ public:
*/
NodeViewEdge* EdgeToUIObject(NodeEdgePtr n);
signals:
/**
* @brief Signal emitted when the selected nodes have changed
*/
void SelectionChanged(QList<Node*> selected_nodes);
private:
NodeGraph* graph_;
@@ -103,6 +109,11 @@ private slots:
*/
void ItemsChanged();
/**
* @brief Receiver for when the scene's selected items change
*/
void SceneSelectionChangedSlot();
};
#endif // NODEVIEW_H
+10 -4
View File
@@ -23,8 +23,9 @@
#include <QDebug>
// Panel objects
#include "panel/project/project.h"
#include "panel/node/node.h"
#include "panel/param/param.h"
#include "panel/project/project.h"
#include "panel/timeline/timeline.h"
#include "panel/tool/tool.h"
#include "panel/viewer/viewer.h"
@@ -74,12 +75,17 @@ void olive::MainWindow::ProjectOpen(Project* p)
ToolPanel* tool_panel = new ToolPanel(this);
addDockWidget(Qt::BottomDockWidgetArea, tool_panel);
NodePanel* task_panel = new NodePanel(this);
addDockWidget(Qt::BottomDockWidgetArea, task_panel);
NodePanel* node_panel = new NodePanel(this);
addDockWidget(Qt::BottomDockWidgetArea, node_panel);
ParamPanel* param_panel = new ParamPanel(this);
addDockWidget(Qt::BottomDockWidgetArea, param_panel);
TimelinePanel* timeline_panel = new TimelinePanel(this);
addDockWidget(Qt::BottomDockWidgetArea, timeline_panel);
connect(node_panel, SIGNAL(SelectionChanged(QList<Node*>)), param_panel, SLOT(SetNodes(QList<Node*>)));
// FIXME: Test code
NodeGraph* graph = new NodeGraph();
graph->setParent(this);
@@ -92,6 +98,6 @@ void olive::MainWindow::ProjectOpen(Project* p)
graph->AddNode(sg);
ImageInput* ii = new ImageInput();
graph->AddNode(ii);
task_panel->SetGraph(graph);
node_panel->SetGraph(graph);
// End test code
}