more work
This commit is contained in:
@@ -44,6 +44,20 @@ void NodeGraph::Clear()
|
||||
}
|
||||
}
|
||||
|
||||
qreal NodeGraph::GetNodeContextHeight(void *context)
|
||||
{
|
||||
const PositionMap &map = position_map_.value(context);
|
||||
|
||||
qreal top = 0, bottom = 0;
|
||||
|
||||
foreach (const QPointF &pt, map) {
|
||||
top = qMin(pt.y(), top);
|
||||
bottom = qMax(pt.y(), bottom);
|
||||
}
|
||||
|
||||
return bottom - top;
|
||||
}
|
||||
|
||||
void NodeGraph::childEvent(QChildEvent *event)
|
||||
{
|
||||
super::childEvent(event);
|
||||
|
||||
@@ -89,6 +89,8 @@ public:
|
||||
emit NodePositionRemoved(node, relative);;
|
||||
}
|
||||
|
||||
qreal GetNodeContextHeight(void *context);
|
||||
|
||||
using PositionMap = QMap<Node*, QPointF>;
|
||||
|
||||
const PositionMap &GetNodesForRelative(void *relative)
|
||||
|
||||
@@ -113,28 +113,63 @@ void NodeView::SetGraph(NodeGraph *graph, const QVector<void*> &nodes)
|
||||
|
||||
// Handle changing nodes
|
||||
if (filter_nodes_ != nodes) {
|
||||
DeselectAll();
|
||||
scene_.clear();
|
||||
|
||||
filter_nodes_ = nodes;
|
||||
|
||||
foreach (void *n, filter_nodes_) {
|
||||
const NodeGraph::PositionMap &map = graph_->GetNodesForRelative(n);
|
||||
if (filter_mode_ == kFilterShowSelective) {
|
||||
DeselectAll();
|
||||
scene_.clear();
|
||||
|
||||
for (auto it=map.cbegin(); it!=map.cend(); it++) {
|
||||
NodeViewItem *item = scene_.AddNode(it.key());
|
||||
item->SetNodePosition(it.value());
|
||||
}
|
||||
}
|
||||
QMap<NodeViewItem*, QVector<QPointF> > averaged_positions;
|
||||
|
||||
for (auto it=scene_.item_map().cbegin(); it!=scene_.item_map().cend(); it++) {
|
||||
Node *node = it.key();
|
||||
for (auto jt=node->input_connections().cbegin(); jt!=node->input_connections().cend(); jt++) {
|
||||
const NodeOutput &output = jt->second;
|
||||
if (scene_.item_map().contains(output.node())) {
|
||||
// Create edge since both input and output exist
|
||||
scene_.AddEdge(output, jt->first);
|
||||
QPointF origin(0, 0);
|
||||
|
||||
foreach (void *n, filter_nodes_) {
|
||||
const NodeGraph::PositionMap &map = graph_->GetNodesForRelative(n);
|
||||
|
||||
qreal top = 0, bottom = 0;
|
||||
|
||||
for (auto it=map.cbegin(); it!=map.cend(); it++) {
|
||||
NodeViewItem *item = scene_.item_map().value(it.key());
|
||||
|
||||
if (item) {
|
||||
QVector<QPointF> &averages = averaged_positions[item];
|
||||
if (averages.isEmpty()) {
|
||||
averages.append(item->GetNodePosition());
|
||||
}
|
||||
averages.append(origin + it.value());
|
||||
} else {
|
||||
item = scene_.AddNode(it.key());
|
||||
}
|
||||
|
||||
const QPointF &pos = it.value();
|
||||
top = qMin(top, pos.y());
|
||||
bottom = qMax(bottom, pos.y());
|
||||
|
||||
item->SetNodePosition(origin + pos);
|
||||
}
|
||||
|
||||
origin.setY(origin.y() + 1 + (bottom - top));
|
||||
}
|
||||
|
||||
for (auto it=scene_.item_map().cbegin(); it!=scene_.item_map().cend(); it++) {
|
||||
Node *node = it.key();
|
||||
for (auto jt=node->input_connections().cbegin(); jt!=node->input_connections().cend(); jt++) {
|
||||
const NodeOutput &output = jt->second;
|
||||
if (scene_.item_map().contains(output.node())) {
|
||||
// Create edge since both input and output exist
|
||||
scene_.AddEdge(output, jt->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it=averaged_positions.cbegin(); it!=averaged_positions.cend(); it++) {
|
||||
const QVector<QPointF> &positions = it.value();
|
||||
QPointF p;
|
||||
foreach (const QPointF &pos, positions) {
|
||||
p += pos;
|
||||
}
|
||||
p /= positions.size();
|
||||
it.key()->SetNodePosition(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,14 +471,7 @@ void MainWindow::TimelinePanelSelectionChanged(const QVector<Block *> &blocks)
|
||||
TimelinePanel *panel = static_cast<TimelinePanel *>(sender());
|
||||
|
||||
if (PanelManager::instance()->CurrentlyFocused(false) == panel) {
|
||||
QVector<void *> context(blocks.size());
|
||||
for (int i=0; i<blocks.size(); i++) {
|
||||
context[i] = blocks.at(i);
|
||||
}
|
||||
|
||||
ViewerOutput *viewer = panel->GetConnectedViewer();
|
||||
|
||||
node_panel_->SetGraph(viewer ? viewer->parent() : nullptr, context);
|
||||
UpdateNodePanelContextFromTimelinePanel(panel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,6 +703,24 @@ void MainWindow::UpdateAudioMonitorParams(ViewerOutput *viewer)
|
||||
audio_monitor_panel_->SetParams(viewer ? viewer->GetAudioParams() : AudioParams());
|
||||
}
|
||||
|
||||
void MainWindow::UpdateNodePanelContextFromTimelinePanel(TimelinePanel *panel)
|
||||
{
|
||||
// Add selected blocks (if any)
|
||||
const QVector<Block*> &blocks = panel->GetSelectedBlocks();
|
||||
QVector<void *> context(blocks.size());
|
||||
for (int i=0; i<blocks.size(); i++) {
|
||||
context[i] = blocks.at(i);
|
||||
}
|
||||
|
||||
// If no selected blocks, set the context to the sequence
|
||||
ViewerOutput *viewer = panel->GetConnectedViewer();
|
||||
if (viewer && context.isEmpty()) {
|
||||
context.append(viewer);
|
||||
}
|
||||
|
||||
node_panel_->SetGraph(viewer ? viewer->parent() : nullptr, context);
|
||||
}
|
||||
|
||||
void MainWindow::FocusedPanelChanged(PanelWidget *panel)
|
||||
{
|
||||
// Update audio monitor panel
|
||||
@@ -721,12 +732,7 @@ void MainWindow::FocusedPanelChanged(PanelWidget *panel)
|
||||
// Signal timeline focus
|
||||
TimelineFocused(timeline->GetConnectedViewer());
|
||||
|
||||
NodeGraph *graph = timeline->GetConnectedViewer() ? timeline->GetConnectedViewer()->parent() : nullptr;
|
||||
QVector<void*> n(timeline->GetSelectedBlocks().size());
|
||||
for (int j=0; j<n.size(); j++) {
|
||||
n[j] = timeline->GetSelectedBlocks().at(j);
|
||||
}
|
||||
node_panel_->SetGraph(graph, n);
|
||||
UpdateNodePanelContextFromTimelinePanel(timeline);
|
||||
} else if (ProjectPanel* project = dynamic_cast<ProjectPanel*>(panel)) {
|
||||
// Signal project panel focus
|
||||
UpdateTitle();
|
||||
|
||||
@@ -142,6 +142,8 @@ private:
|
||||
|
||||
void UpdateAudioMonitorParams(ViewerOutput* viewer);
|
||||
|
||||
void UpdateNodePanelContextFromTimelinePanel(TimelinePanel *panel);
|
||||
|
||||
QByteArray premaximized_state_;
|
||||
|
||||
// Standard panels
|
||||
|
||||
Reference in New Issue
Block a user