developed beginnings of media node

This commit is contained in:
itsmattkc
2019-07-20 12:34:57 -07:00
parent 6c52c45aea
commit 3605a2f988
21 changed files with 298 additions and 24 deletions
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(flowlayout)
add_subdirectory(footagecombobox)
add_subdirectory(menu)
add_subdirectory(nodeview)
add_subdirectory(nodeparamview)
+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}
widget/footagecombobox/footagecombobox.h
widget/footagecombobox/footagecombobox.cpp
PARENT_SCOPE
)
@@ -0,0 +1,59 @@
#include "footagecombobox.h"
#include <QAction>
#include <QMenu>
FootageComboBox::FootageComboBox(QWidget *parent) :
QComboBox(parent),
root_(nullptr)
{
}
void FootageComboBox::showPopup()
{
if (root_ == nullptr) {
return;
}
QMenu menu;
menu.setMinimumWidth(width());
TraverseFolder(root_, &menu);
QAction* selected = menu.exec(parentWidget()->mapToGlobal(pos()));
if (selected != nullptr) {
clear();
addItem(selected->text());
emit FootageChanged(reinterpret_cast<Footage*>(selected->data().value<quintptr>()));
}
}
void FootageComboBox::SetRoot(const Folder *p)
{
root_ = p;
clear();
}
void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
{
for (int i=0;i<f->child_count();i++) {
Item* child = f->child(i);
if (child->type() == Item::kFolder) {
TraverseFolder(static_cast<Folder*>(child), m->addMenu(child->name()));
} else if (child->type() == Item::kFootage) {
QAction* footage_action = m->addAction(child->name());
footage_action->setData(reinterpret_cast<quintptr>(child));
}
}
}
@@ -0,0 +1,29 @@
#ifndef FOOTAGECOMBOBOX_H
#define FOOTAGECOMBOBOX_H
#include <QComboBox>
#include <QMenu>
#include "project/item/footage/footage.h"
#include "project/project.h"
class FootageComboBox : public QComboBox
{
Q_OBJECT
public:
FootageComboBox(QWidget* parent = nullptr);
virtual void showPopup() override;
void SetRoot(const Folder *p);
signals:
void FootageChanged(Footage* f);
private:
void TraverseFolder(const Folder *f, QMenu* m);
const Folder* root_;
};
#endif // FOOTAGECOMBOBOX_H
@@ -20,10 +20,20 @@
#include "nodeparamviewitem.h"
#include <QCheckBox>
#include <QDebug>
#include <QFontComboBox>
#include <QLineEdit>
#include <QPainter>
#include "project/item/sequence/sequence.h"
#include "ui/icons/icons.h"
#include "widget/footagecombobox/footagecombobox.h"
// FIXME: Test code only
#include "panel/panelfocusmanager.h"
#include "panel/project/project.h"
// End test code
NodeParamViewItem::NodeParamViewItem(QWidget *parent) :
QWidget(parent)
@@ -107,15 +117,90 @@ void NodeParamViewItem::SetupUI()
// This widget only needs to show input parameters
if (param->type() == NodeParam::kInput) {
// Add descriptor label
QLabel* param_label = new QLabel(tr("%1:").arg(param->name()));
content_layout_->addWidget(param_label, row_count, 0);
// Add widgets for this parameter
QList<QWidget*> widgets_for_param = CreateWidget(static_cast<NodeInput*>(param));
for (int i=0;i<widgets_for_param.size();i++) {
content_layout_->addWidget(widgets_for_param.at(i), row_count, i + 1);
}
row_count++;
}
}
}
QList<QWidget*> NodeParamViewItem::CreateWidget(NodeInput* input)
{
QList<QWidget*> widgets;
if (input->inputs().isEmpty()) {
return widgets;
}
switch (input->inputs().first()) {
case NodeParam::kNone:
case NodeParam::kAny:
case NodeParam::kBlock:
case NodeParam::kTexture:
case NodeParam::kMatrix:
break;
case NodeParam::kInt:
// FIXME: LabelSlider in INTEGER mode
break;
case NodeParam::kFloat:
// FIXME: LabelSlider in FLOAT mode
break;
case NodeParam::kFile:
// FIXME: File selector
break;
case NodeParam::kColor:
// FIXME: Color selector
break;
case NodeParam::kString:
{
QLineEdit* line_edit = new QLineEdit();
widgets.append(line_edit);
}
break;
case NodeParam::kBoolean:
{
QCheckBox* check_box = new QCheckBox();
widgets.append(check_box);
}
break;
case NodeParam::kFont:
{
QFontComboBox* font_combobox = new QFontComboBox();
widgets.append(font_combobox);
}
break;
case NodeParam::kFootage:
{
FootageComboBox* footage_combobox = new FootageComboBox();
// FIXME: Test code
ProjectPanel* pp = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
footage_combobox->SetRoot(pp->project()->root());
// End test code
// Pretty hacky way of getting the root folder for this node's sequence
//const Folder* root_folder = static_cast<const Folder*>(static_cast<Sequence*>(input->parent()->parent())->root());
//footage_combobox->SetRoot(root_folder);
widgets.append(footage_combobox);
}
break;
}
return widgets;
}
void NodeParamViewItem::SetExpanded(bool e)
{
expanded_ = e;
@@ -53,6 +53,8 @@ protected:
private:
void SetupUI();
QList<QWidget*> CreateWidget(NodeInput *input);
bool expanded_;
NodeParamViewItemTitleBar* title_bar_;