style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
+360
-360
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEW_H
|
||||
#define NODEVIEW_H
|
||||
#ifndef OAK_NODEVIEW_H
|
||||
#define OAK_NODEVIEW_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QTimer>
|
||||
@@ -50,85 +50,85 @@ public:
|
||||
|
||||
virtual ~NodeView() override;
|
||||
|
||||
void SetContexts(const QVector<Node *> &nodes);
|
||||
void set_contexts(const QVector<Node *> &nodes);
|
||||
|
||||
const QVector<Node *> &GetContexts() const
|
||||
const QVector<Node *> &get_contexts() const
|
||||
{
|
||||
if (overlay_view_) {
|
||||
return overlay_view_->GetContexts();
|
||||
return overlay_view_->get_contexts();
|
||||
} else {
|
||||
return contexts_;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsGroupOverlay() const
|
||||
bool is_group_overlay() const
|
||||
{
|
||||
return overlay_view_;
|
||||
}
|
||||
|
||||
void CloseContextsBelongingToProject(Project *project);
|
||||
void close_contexts_belonging_to_project(Project *project);
|
||||
|
||||
void ClearGraph();
|
||||
void clear_graph();
|
||||
|
||||
/**
|
||||
* @brief Delete selected nodes from graph (user-friendly/undoable)
|
||||
*/
|
||||
void DeleteSelected();
|
||||
void delete_selected();
|
||||
|
||||
void SelectAll();
|
||||
void DeselectAll();
|
||||
void select_all();
|
||||
void deselect_all();
|
||||
|
||||
void Select(const QVector<Node::ContextPair> &nodes,
|
||||
void select(const QVector<Node::ContextPair> &nodes,
|
||||
bool center_view_on_item);
|
||||
|
||||
void CopySelected(bool cut);
|
||||
void Paste();
|
||||
void copy_selected(bool cut);
|
||||
void paste();
|
||||
|
||||
void Duplicate();
|
||||
void duplicate();
|
||||
|
||||
void SetColorLabel(int index);
|
||||
void set_color_label(int index);
|
||||
|
||||
void ZoomIn();
|
||||
void zoom_in();
|
||||
|
||||
void ZoomOut();
|
||||
void zoom_out();
|
||||
|
||||
const QVector<Node *> &GetCurrentContexts() const
|
||||
const QVector<Node *> &get_current_contexts() const
|
||||
{
|
||||
return contexts_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void SetMiniMapEnabled(bool e)
|
||||
void set_mini_map_enabled(bool e)
|
||||
{
|
||||
minimap_->setVisible(e);
|
||||
}
|
||||
|
||||
void ShowAddMenu()
|
||||
void show_add_menu()
|
||||
{
|
||||
Menu *m = CreateAddMenu(nullptr);
|
||||
Menu *m = create_add_menu(nullptr);
|
||||
m->exec(QCursor::pos());
|
||||
delete m;
|
||||
}
|
||||
|
||||
void CenterOnItemsBoundingRect();
|
||||
void center_on_items_bounding_rect();
|
||||
|
||||
void CenterOnNode(olive::Node *n);
|
||||
void center_on_node(olive::Node *n);
|
||||
|
||||
void LabelSelectedNodes();
|
||||
void label_selected_nodes();
|
||||
|
||||
signals:
|
||||
void NodesSelected(const QVector<Node *> &nodes);
|
||||
void nodes_selected(const QVector<Node *> &nodes);
|
||||
|
||||
void NodesDeselected(const QVector<Node *> &nodes);
|
||||
void nodes_deselected(const QVector<Node *> &nodes);
|
||||
|
||||
void NodeSelectionChanged(const QVector<Node *> &nodes);
|
||||
void node_selection_changed(const QVector<Node *> &nodes);
|
||||
void
|
||||
NodeSelectionChangedWithContexts(const QVector<Node::ContextPair> &nodes);
|
||||
node_selection_changed_with_contexts(const QVector<Node::ContextPair> &nodes);
|
||||
|
||||
void NodeGroupOpened(NodeGroup *group);
|
||||
void NodeGroupClosed();
|
||||
void node_group_opened(NodeGroup *group);
|
||||
void node_group_closed();
|
||||
|
||||
void EscPressed();
|
||||
void esc_pressed();
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
@@ -145,7 +145,7 @@ protected:
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
virtual void ZoomIntoCursorPosition(QWheelEvent *event, double multiplier,
|
||||
virtual void zoom_into_cursor_position(QWheelEvent *event, double multiplier,
|
||||
const QPointF &cursor_pos) override;
|
||||
|
||||
virtual bool event(QEvent *event) override;
|
||||
@@ -155,54 +155,54 @@ protected:
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void DetachItemsFromCursor(bool delete_nodes_too = true);
|
||||
void detach_items_from_cursor(bool delete_nodes_too = true);
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
void MoveAttachedNodesToCursor(const QPoint &p);
|
||||
void ProcessMovingAttachedNodes(const QPoint &pos);
|
||||
QVector<Node *> ProcessDroppingAttachedNodes(MultiUndoCommand *command,
|
||||
void move_attached_nodes_to_cursor(const QPoint &p);
|
||||
void process_moving_attached_nodes(const QPoint &pos);
|
||||
QVector<Node *> process_dropping_attached_nodes(MultiUndoCommand *command,
|
||||
Node *select_context,
|
||||
const QPoint &pos);
|
||||
Node *GetContextAtMousePos(const QPoint &p);
|
||||
Node *get_context_at_mouse_pos(const QPoint &p);
|
||||
|
||||
void ConnectSelectionChangedSignal();
|
||||
void DisconnectSelectionChangedSignal();
|
||||
void connect_selection_changed_signal();
|
||||
void disconnect_selection_changed_signal();
|
||||
|
||||
void ZoomFromKeyboard(double multiplier);
|
||||
void zoom_from_keyboard(double multiplier);
|
||||
|
||||
void ClearCreateEdgeInputIfNecessary();
|
||||
void clear_create_edge_input_if_necessary();
|
||||
|
||||
QPointF GetEstimatedPositionForContext(NodeViewItem *item,
|
||||
QPointF get_estimated_position_for_context(NodeViewItem *item,
|
||||
Node *context) const;
|
||||
|
||||
NodeViewItem *GetAssumedItemForSelectedNode(Node *node);
|
||||
bool GetAssumedPositionForSelectedNode(Node *node, Node::Position *pos);
|
||||
NodeViewItem *get_assumed_item_for_selected_node(Node *node);
|
||||
bool get_assumed_position_for_selected_node(Node *node, Node::Position *pos);
|
||||
|
||||
Menu *CreateAddMenu(Menu *parent);
|
||||
Menu *create_add_menu(Menu *parent);
|
||||
|
||||
void PositionNewEdge(const QPoint &pos);
|
||||
void position_new_edge(const QPoint &pos);
|
||||
|
||||
void AddContext(Node *n);
|
||||
void add_context(Node *n);
|
||||
|
||||
void RemoveContext(Node *n);
|
||||
void remove_context(Node *n);
|
||||
|
||||
bool IsItemAttachedToCursor(NodeViewItem *item) const;
|
||||
bool is_item_attached_to_cursor(NodeViewItem *item) const;
|
||||
|
||||
void ExpandItem(NodeViewItem *item);
|
||||
void expand_item(NodeViewItem *item);
|
||||
|
||||
void CollapseItem(NodeViewItem *item);
|
||||
void collapse_item(NodeViewItem *item);
|
||||
|
||||
void EndEdgeDrag(bool cancel = false);
|
||||
void end_edge_drag(bool cancel = false);
|
||||
|
||||
void PostPaste(const QVector<Node *> &new_nodes,
|
||||
void post_paste(const QVector<Node *> &new_nodes,
|
||||
const Node::PositionMap &map);
|
||||
|
||||
void ResizeOverlay();
|
||||
void resize_overlay();
|
||||
|
||||
NodeViewMiniMap *minimap_;
|
||||
|
||||
NodeViewContext *GetContextItemFromNodeItem(NodeViewItem *item);
|
||||
NodeViewContext *get_context_item_from_node_item(NodeViewItem *item);
|
||||
|
||||
struct AttachedItem {
|
||||
NodeViewItem *item;
|
||||
@@ -210,7 +210,7 @@ private:
|
||||
QPointF original_pos;
|
||||
};
|
||||
|
||||
void SetAttachedItems(const QVector<AttachedItem> &items);
|
||||
void set_attached_items(const QVector<AttachedItem> &items);
|
||||
QVector<AttachedItem> attached_items_;
|
||||
|
||||
NodeViewEdge *drop_edge_;
|
||||
@@ -243,59 +243,59 @@ private:
|
||||
|
||||
QAction *show_in_param_editor_action_;
|
||||
|
||||
static const double kMinimumScale;
|
||||
static const double k_minimum_scale;
|
||||
|
||||
static const int kMaximumContexts;
|
||||
static const int k_maximum_contexts;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Receiver for when the scene's selected items change
|
||||
*/
|
||||
void UpdateSelectionCache();
|
||||
void update_selection_cache();
|
||||
|
||||
/**
|
||||
* @brief Receiver for when the user right clicks (or otherwise requests a context menu)
|
||||
*/
|
||||
void ShowContextMenu(const QPoint &pos);
|
||||
void show_context_menu(const QPoint &pos);
|
||||
|
||||
/**
|
||||
* @brief Receiver for when the user requests a new node from the add menu
|
||||
*/
|
||||
void CreateNodeSlot(QAction *action);
|
||||
void create_node_slot(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief Receiver for setting the direction from the context menu
|
||||
*/
|
||||
void ContextMenuSetDirection(QAction *action);
|
||||
void context_menu_set_direction(QAction *action);
|
||||
|
||||
/**
|
||||
* @brief Opens the selected node in a Viewer
|
||||
*/
|
||||
void OpenSelectedNodeInViewer();
|
||||
void open_selected_node_in_viewer();
|
||||
|
||||
void UpdateSceneBoundingRect();
|
||||
void update_scene_bounding_rect();
|
||||
|
||||
void RepositionMiniMap();
|
||||
void reposition_mini_map();
|
||||
|
||||
void UpdateViewportOnMiniMap();
|
||||
void update_viewport_on_mini_map();
|
||||
|
||||
void MoveToScenePoint(const QPointF &pos);
|
||||
void move_to_scene_point(const QPointF &pos);
|
||||
|
||||
void NodeRemovedFromGraph();
|
||||
void node_removed_from_graph();
|
||||
|
||||
void GroupNodes();
|
||||
void group_nodes();
|
||||
|
||||
void UngroupNodes();
|
||||
void ungroup_nodes();
|
||||
|
||||
void ShowNodeProperties();
|
||||
void show_node_properties();
|
||||
|
||||
void ShowSelectedNodeInParamEditor();
|
||||
void show_selected_node_in_param_editor();
|
||||
|
||||
void ItemAboutToBeDeleted(NodeViewItem *item);
|
||||
void item_about_to_be_deleted(NodeViewItem *item);
|
||||
|
||||
void CloseOverlay();
|
||||
void close_overlay();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEW_H
|
||||
#endif // OAK_NODEVIEW_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWCOMMON_H
|
||||
#define NODEVIEWCOMMON_H
|
||||
#ifndef OAK_NODEVIEWCOMMON_H
|
||||
#define OAK_NODEVIEWCOMMON_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -32,45 +32,45 @@ namespace olive
|
||||
class NodeViewCommon {
|
||||
public:
|
||||
enum FlowDirection {
|
||||
kInvalidDirection = -1,
|
||||
kTopToBottom,
|
||||
kBottomToTop,
|
||||
kLeftToRight,
|
||||
kRightToLeft
|
||||
k_invalid_direction = -1,
|
||||
k_top_to_bottom,
|
||||
k_bottom_to_top,
|
||||
k_left_to_right,
|
||||
k_right_to_left
|
||||
};
|
||||
|
||||
static Qt::Orientation GetFlowOrientation(FlowDirection dir)
|
||||
static Qt::Orientation get_flow_orientation(FlowDirection dir)
|
||||
{
|
||||
if (dir == kTopToBottom || dir == kBottomToTop) {
|
||||
if (dir == k_top_to_bottom || dir == k_bottom_to_top) {
|
||||
return Qt::Vertical;
|
||||
} else {
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsFlowVertical(FlowDirection dir)
|
||||
static bool is_flow_vertical(FlowDirection dir)
|
||||
{
|
||||
return dir == kTopToBottom || dir == kBottomToTop;
|
||||
return dir == k_top_to_bottom || dir == k_bottom_to_top;
|
||||
}
|
||||
|
||||
static bool IsFlowHorizontal(FlowDirection dir)
|
||||
static bool is_flow_horizontal(FlowDirection dir)
|
||||
{
|
||||
return dir == kLeftToRight || dir == kRightToLeft;
|
||||
return dir == k_left_to_right || dir == k_right_to_left;
|
||||
}
|
||||
|
||||
static bool DirectionsAreOpposing(FlowDirection a, FlowDirection b)
|
||||
static bool directions_are_opposing(FlowDirection a, FlowDirection b)
|
||||
{
|
||||
return ((a == NodeViewCommon::kLeftToRight &&
|
||||
b == NodeViewCommon::kRightToLeft) ||
|
||||
(a == NodeViewCommon::kRightToLeft &&
|
||||
b == NodeViewCommon::kLeftToRight) ||
|
||||
(a == NodeViewCommon::kTopToBottom &&
|
||||
b == NodeViewCommon::kBottomToTop) ||
|
||||
(a == NodeViewCommon::kBottomToTop &&
|
||||
b == NodeViewCommon::kTopToBottom));
|
||||
return ((a == NodeViewCommon::k_left_to_right &&
|
||||
b == NodeViewCommon::k_right_to_left) ||
|
||||
(a == NodeViewCommon::k_right_to_left &&
|
||||
b == NodeViewCommon::k_left_to_right) ||
|
||||
(a == NodeViewCommon::k_top_to_bottom &&
|
||||
b == NodeViewCommon::k_bottom_to_top) ||
|
||||
(a == NodeViewCommon::k_bottom_to_top &&
|
||||
b == NodeViewCommon::k_top_to_bottom));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWCOMMON_H
|
||||
#endif // OAK_NODEVIEWCOMMON_H
|
||||
|
||||
@@ -45,36 +45,36 @@ NodeViewContext::NodeViewContext(Node *context, QGraphicsItem *item)
|
||||
{
|
||||
Block *block = dynamic_cast<Block *>(context_);
|
||||
if (block && block->track() && block->track()->sequence()) {
|
||||
rational timebase = block->track()
|
||||
Rational timebase = block->track()
|
||||
->sequence()
|
||||
->GetVideoParams()
|
||||
->get_video_params()
|
||||
.frame_rate_as_time_base();
|
||||
lbl_ =
|
||||
QCoreApplication::translate("NodeViewContext", "%1 [%2] :: %3 - %4")
|
||||
.arg(block->GetLabelAndName(),
|
||||
Track::Reference::TypeToTranslatedString(
|
||||
.arg(block->get_label_and_name(),
|
||||
Track::Reference::type_to_translated_string(
|
||||
block->track()->type()),
|
||||
QString::fromStdString(Timecode::time_to_timecode(
|
||||
block->in(), timebase,
|
||||
Core::instance()->GetTimecodeDisplay())),
|
||||
Core::instance()->get_timecode_display())),
|
||||
QString::fromStdString(Timecode::time_to_timecode(
|
||||
block->out(), timebase,
|
||||
Core::instance()->GetTimecodeDisplay())));
|
||||
Core::instance()->get_timecode_display())));
|
||||
} else {
|
||||
lbl_ = context_->GetLabelAndName();
|
||||
lbl_ = context_->get_label_and_name();
|
||||
}
|
||||
|
||||
const Node::PositionMap &map = context_->GetContextPositions();
|
||||
const Node::PositionMap &map = context_->get_context_positions();
|
||||
for (auto it = map.cbegin(); it != map.cend(); it++) {
|
||||
AddChild(it.key());
|
||||
add_child(it.key());
|
||||
}
|
||||
|
||||
connect(context_, &Node::NodeAddedToContext, this,
|
||||
&NodeViewContext::AddChild, Qt::DirectConnection);
|
||||
connect(context_, &Node::NodePositionInContextChanged, this,
|
||||
&NodeViewContext::SetChildPosition, Qt::DirectConnection);
|
||||
connect(context_, &Node::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::RemoveChild, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_added_to_context, this,
|
||||
&NodeViewContext::add_child, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_position_in_context_changed, this,
|
||||
&NodeViewContext::set_child_position, Qt::DirectConnection);
|
||||
connect(context_, &Node::node_removed_from_context, this,
|
||||
&NodeViewContext::remove_child, Qt::DirectConnection);
|
||||
}
|
||||
|
||||
NodeViewContext::~NodeViewContext()
|
||||
@@ -84,50 +84,50 @@ NodeViewContext::~NodeViewContext()
|
||||
edges_.clear();
|
||||
}
|
||||
|
||||
void NodeViewContext::AddChild(Node *node)
|
||||
void NodeViewContext::add_child(Node *node)
|
||||
{
|
||||
if (!context_) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeViewItem *item = new NodeViewItem(node, context_, this);
|
||||
item->SetFlowDirection(flow_dir_);
|
||||
item->set_flow_direction(flow_dir_);
|
||||
|
||||
AddNodeInternal(node, item);
|
||||
add_node_internal(node, item);
|
||||
|
||||
if (NodeGroup *group = dynamic_cast<NodeGroup *>(node)) {
|
||||
for (auto it = group->GetContextPositions().cbegin();
|
||||
it != group->GetContextPositions().cend(); it++) {
|
||||
for (auto it = group->get_context_positions().cbegin();
|
||||
it != group->get_context_positions().cend(); it++) {
|
||||
// Use this item as the representative for all of these nodes too
|
||||
AddNodeInternal(it.key(), item);
|
||||
add_node_internal(it.key(), item);
|
||||
}
|
||||
|
||||
connect(group, &NodeGroup::NodeAddedToContext, this,
|
||||
&NodeViewContext::GroupAddedNode);
|
||||
connect(group, &NodeGroup::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::GroupRemovedNode);
|
||||
connect(group, &NodeGroup::node_added_to_context, this,
|
||||
&NodeViewContext::group_added_node);
|
||||
connect(group, &NodeGroup::node_removed_from_context, this,
|
||||
&NodeViewContext::group_removed_node);
|
||||
}
|
||||
|
||||
UpdateRect();
|
||||
update_rect();
|
||||
}
|
||||
|
||||
void NodeViewContext::SetChildPosition(Node *node, const QPointF &pos)
|
||||
void NodeViewContext::set_child_position(Node *node, const QPointF &pos)
|
||||
{
|
||||
item_map_.value(node)->SetNodePosition(pos);
|
||||
item_map_.value(node)->set_node_position(pos);
|
||||
}
|
||||
|
||||
void NodeViewContext::RemoveChild(Node *node)
|
||||
void NodeViewContext::remove_child(Node *node)
|
||||
{
|
||||
disconnect(node, &Node::InputConnected, this,
|
||||
&NodeViewContext::ChildInputConnected);
|
||||
disconnect(node, &Node::InputDisconnected, this,
|
||||
&NodeViewContext::ChildInputDisconnected);
|
||||
disconnect(node, &Node::input_connected, this,
|
||||
&NodeViewContext::child_input_connected);
|
||||
disconnect(node, &Node::input_disconnected, this,
|
||||
&NodeViewContext::child_input_disconnected);
|
||||
|
||||
if (NodeGroup *group = dynamic_cast<NodeGroup *>(node)) {
|
||||
disconnect(group, &NodeGroup::NodeAddedToContext, this,
|
||||
&NodeViewContext::GroupAddedNode);
|
||||
disconnect(group, &NodeGroup::NodeRemovedFromContext, this,
|
||||
&NodeViewContext::GroupRemovedNode);
|
||||
disconnect(group, &NodeGroup::node_added_to_context, this,
|
||||
&NodeViewContext::group_added_node);
|
||||
disconnect(group, &NodeGroup::node_removed_from_context, this,
|
||||
&NodeViewContext::group_removed_node);
|
||||
}
|
||||
|
||||
NodeViewItem *item = item_map_.take(node);
|
||||
@@ -136,22 +136,22 @@ void NodeViewContext::RemoveChild(Node *node)
|
||||
// now can be handled before the item is destroyed
|
||||
scene()->removeItem(item);
|
||||
|
||||
emit ItemAboutToBeDeleted(item);
|
||||
emit item_about_to_be_deleted(item);
|
||||
|
||||
// Delete edges first because the edge destructor will try to reference item (maybe that should
|
||||
// be changed...)
|
||||
QVector<NodeViewEdge *> edges_to_remove = item->GetAllEdgesRecursively();
|
||||
QVector<NodeViewEdge *> edges_to_remove = item->get_all_edges_recursively();
|
||||
foreach (NodeViewEdge *edge, edges_to_remove) {
|
||||
if (node == item->GetNode() || edge->output() == node ||
|
||||
if (node == item->get_node() || edge->output() == node ||
|
||||
edge->input().node() == node) {
|
||||
ChildInputDisconnected(edge->output(), edge->input());
|
||||
child_input_disconnected(edge->output(), edge->input());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if this item is specifically for this node and the node is a group. If so, remove it for
|
||||
// all other entries in the map.
|
||||
if (item->GetNode() == node) {
|
||||
if (dynamic_cast<NodeGroup *>(item->GetNode())) {
|
||||
if (item->get_node() == node) {
|
||||
if (dynamic_cast<NodeGroup *>(item->get_node())) {
|
||||
for (auto it = item_map_.begin(); it != item_map_.end();) {
|
||||
if (it.value() == item) {
|
||||
it = item_map_.erase(it);
|
||||
@@ -164,22 +164,22 @@ void NodeViewContext::RemoveChild(Node *node)
|
||||
delete item;
|
||||
}
|
||||
|
||||
UpdateRect();
|
||||
update_rect();
|
||||
}
|
||||
|
||||
void NodeViewContext::ChildInputConnected(Node *output, const NodeInput &input)
|
||||
void NodeViewContext::child_input_connected(Node *output, const NodeInput &input)
|
||||
{
|
||||
// Add edge
|
||||
if (!input.IsHidden()) {
|
||||
if (!input.is_hidden()) {
|
||||
if (NodeViewItem *output_item = item_map_.value(output)) {
|
||||
AddEdgeInternal(
|
||||
add_edge_internal(
|
||||
output, input, output_item,
|
||||
item_map_.value(input.node())->GetItemForInput(input));
|
||||
item_map_.value(input.node())->get_item_for_input(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeViewContext::ChildInputDisconnected(Node *output,
|
||||
bool NodeViewContext::child_input_disconnected(Node *output,
|
||||
const NodeInput &input)
|
||||
{
|
||||
// Remove edge
|
||||
@@ -195,59 +195,59 @@ bool NodeViewContext::ChildInputDisconnected(Node *output,
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal GetTextOffset(const QFontMetricsF &fm)
|
||||
qreal get_text_offset(const QFontMetricsF &fm)
|
||||
{
|
||||
return fm.height() / 2;
|
||||
}
|
||||
|
||||
void NodeViewContext::UpdateRect()
|
||||
void NodeViewContext::update_rect()
|
||||
{
|
||||
QFont f;
|
||||
QFontMetricsF fm(f);
|
||||
qreal lbl_offset = GetTextOffset(fm);
|
||||
qreal lbl_offset = get_text_offset(fm);
|
||||
|
||||
QRectF cbr = childrenBoundingRect();
|
||||
QRectF rect = cbr;
|
||||
int pad = NodeViewItem::DefaultItemHeight();
|
||||
int pad = NodeViewItem::default_item_height();
|
||||
rect.adjust(-pad, -lbl_offset * 2 - fm.height() - pad, pad, pad);
|
||||
setRect(rect);
|
||||
|
||||
last_titlebar_height_ = rect.y() + (cbr.y() - rect.y()) - pad;
|
||||
}
|
||||
|
||||
void NodeViewContext::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
void NodeViewContext::set_flow_direction(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
flow_dir_ = dir;
|
||||
|
||||
foreach (NodeViewItem *item, item_map_) {
|
||||
item->SetFlowDirection(dir);
|
||||
item->set_flow_direction(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewContext::SetCurvedEdges(bool e)
|
||||
void NodeViewContext::set_curved_edges(bool e)
|
||||
{
|
||||
curved_edges_ = e;
|
||||
|
||||
foreach (NodeViewEdge *edge, edges_) {
|
||||
edge->SetCurved(e);
|
||||
edge->set_curved(e);
|
||||
}
|
||||
}
|
||||
|
||||
int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command)
|
||||
int NodeViewContext::delete_selected(NodeViewDeleteCommand *command)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
// Delete any selected edges
|
||||
foreach (NodeViewEdge *edge, edges_) {
|
||||
if (edge->isSelected()) {
|
||||
command->AddEdge(edge->output(), edge->input());
|
||||
command->add_edge(edge->output(), edge->input());
|
||||
}
|
||||
}
|
||||
|
||||
// Delete any selected nodes
|
||||
foreach (NodeViewItem *node, item_map_) {
|
||||
if (node->isSelected()) {
|
||||
command->AddNode(node->GetNode(), context_);
|
||||
command->add_node(node->get_node(), context_);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ int NodeViewContext::DeleteSelected(NodeViewDeleteCommand *command)
|
||||
return count;
|
||||
}
|
||||
|
||||
void NodeViewContext::Select(const QVector<Node *> &nodes)
|
||||
void NodeViewContext::select(const QVector<Node *> &nodes)
|
||||
{
|
||||
foreach (Node *n, nodes) {
|
||||
if (NodeViewItem *item = item_map_.value(n)) {
|
||||
@@ -264,7 +264,7 @@ void NodeViewContext::Select(const QVector<Node *> &nodes)
|
||||
}
|
||||
}
|
||||
|
||||
QVector<NodeViewItem *> NodeViewContext::GetSelectedItems() const
|
||||
QVector<NodeViewItem *> NodeViewContext::get_selected_items() const
|
||||
{
|
||||
QVector<NodeViewItem *> items;
|
||||
|
||||
@@ -279,12 +279,12 @@ QVector<NodeViewItem *> NodeViewContext::GetSelectedItems() const
|
||||
return items;
|
||||
}
|
||||
|
||||
QPointF NodeViewContext::MapScenePosToNodePosInContext(const QPointF &pos) const
|
||||
QPointF NodeViewContext::map_scene_pos_to_node_pos_in_context(const QPointF &pos) const
|
||||
{
|
||||
for (auto it = item_map_.cbegin(); it != item_map_.cend(); it++) {
|
||||
QPointF pos_inside_parent =
|
||||
it.value()->mapToParent(it.value()->mapFromScene(pos));
|
||||
return NodeViewItem::ScreenToNodePoint(pos_inside_parent, flow_dir_);
|
||||
return NodeViewItem::screen_to_node_point(pos_inside_parent, flow_dir_);
|
||||
}
|
||||
return QPointF(0, 0);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ void NodeViewContext::paint(QPainter *painter,
|
||||
{
|
||||
// Set pen and brush
|
||||
Color color = context_->color();
|
||||
QColor c = QtUtils::toQColor(color);
|
||||
QColor c = QtUtils::to_q_color(color);
|
||||
QPen pen(c, 2);
|
||||
if (option->state & QStyle::State_Selected) {
|
||||
pen.setStyle(Qt::DotLine);
|
||||
@@ -319,9 +319,9 @@ void NodeViewContext::paint(QPainter *painter,
|
||||
painter->setClipping(false);
|
||||
|
||||
// Draw titlebar text
|
||||
painter->setPen(ColorCoding::GetUISelectorColor(color));
|
||||
painter->setPen(ColorCoding::get_ui_selector_color(color));
|
||||
|
||||
int offset = GetTextOffset(painter->fontMetrics());
|
||||
int offset = get_text_offset(painter->fontMetrics());
|
||||
|
||||
QRectF text_rect = rect();
|
||||
text_rect.adjust(offset, offset, -offset, -offset);
|
||||
@@ -344,41 +344,41 @@ void NodeViewContext::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
super::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void NodeViewContext::AddNodeInternal(Node *node, NodeViewItem *item)
|
||||
void NodeViewContext::add_node_internal(Node *node, NodeViewItem *item)
|
||||
{
|
||||
connect(node, &Node::InputConnected, this,
|
||||
&NodeViewContext::ChildInputConnected);
|
||||
connect(node, &Node::InputDisconnected, this,
|
||||
&NodeViewContext::ChildInputDisconnected);
|
||||
connect(node, &Node::input_connected, this,
|
||||
&NodeViewContext::child_input_connected);
|
||||
connect(node, &Node::input_disconnected, this,
|
||||
&NodeViewContext::child_input_disconnected);
|
||||
|
||||
item_map_.insert(node, item);
|
||||
|
||||
if (node == context_) {
|
||||
item->SetLabelAsOutput(true);
|
||||
item->set_label_as_output(true);
|
||||
}
|
||||
|
||||
for (auto it = node->output_connections().cbegin();
|
||||
it != node->output_connections().cend(); it++) {
|
||||
if (!it->second.IsHidden()) {
|
||||
if (!it->second.is_hidden()) {
|
||||
if (NodeViewItem *other_item = item_map_.value(it->second.node())) {
|
||||
AddEdgeInternal(node, it->second, item,
|
||||
other_item->GetItemForInput(it->second));
|
||||
add_edge_internal(node, it->second, item,
|
||||
other_item->get_item_for_input(it->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = node->input_connections().cbegin();
|
||||
it != node->input_connections().cend(); it++) {
|
||||
if (!it->first.IsHidden()) {
|
||||
if (!it->first.is_hidden()) {
|
||||
if (NodeViewItem *other_item = item_map_.value(it->second)) {
|
||||
AddEdgeInternal(it->second, it->first, other_item,
|
||||
item->GetItemForInput(it->first));
|
||||
add_edge_internal(it->second, it->first, other_item,
|
||||
item->get_item_for_input(it->first));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
void NodeViewContext::add_edge_internal(Node *output, const NodeInput &input,
|
||||
NodeViewItem *from, NodeViewItem *to)
|
||||
{
|
||||
if (from == to) {
|
||||
@@ -387,20 +387,20 @@ void NodeViewContext::AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
|
||||
NodeViewEdge *edge_ui = new NodeViewEdge(output, input, from, to, this);
|
||||
|
||||
edge_ui->Adjust();
|
||||
edge_ui->SetCurved(curved_edges_);
|
||||
edge_ui->adjust();
|
||||
edge_ui->set_curved(curved_edges_);
|
||||
|
||||
edges_.append(edge_ui);
|
||||
}
|
||||
|
||||
void NodeViewContext::GroupAddedNode(Node *node)
|
||||
void NodeViewContext::group_added_node(Node *node)
|
||||
{
|
||||
NodeGroup *group = static_cast<NodeGroup *>(sender());
|
||||
|
||||
AddNodeInternal(node, item_map_.value(group));
|
||||
add_node_internal(node, item_map_.value(group));
|
||||
}
|
||||
|
||||
void NodeViewContext::GroupRemovedNode(Node *node)
|
||||
void NodeViewContext::group_removed_node(Node *node)
|
||||
{
|
||||
NodeGroup *group = static_cast<NodeGroup *>(sender());
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NODEVIEWCONTEXT_H
|
||||
#define NODEVIEWCONTEXT_H
|
||||
#ifndef OAK_NODEVIEWCONTEXT_H
|
||||
#define OAK_NODEVIEWCONTEXT_H
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsTextItem>
|
||||
@@ -37,26 +37,26 @@ public:
|
||||
|
||||
virtual ~NodeViewContext() override;
|
||||
|
||||
Node *GetContext() const
|
||||
Node *get_context() const
|
||||
{
|
||||
return context_;
|
||||
}
|
||||
|
||||
void UpdateRect();
|
||||
void update_rect();
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
void SetCurvedEdges(bool e);
|
||||
void set_curved_edges(bool e);
|
||||
|
||||
int DeleteSelected(NodeViewDeleteCommand *command);
|
||||
int delete_selected(NodeViewDeleteCommand *command);
|
||||
|
||||
void Select(const QVector<Node *> &nodes);
|
||||
void select(const QVector<Node *> &nodes);
|
||||
|
||||
QVector<NodeViewItem *> GetSelectedItems() const;
|
||||
QVector<NodeViewItem *> get_selected_items() const;
|
||||
|
||||
QPointF MapScenePosToNodePosInContext(const QPointF &pos) const;
|
||||
QPointF map_scene_pos_to_node_pos_in_context(const QPointF &pos) const;
|
||||
|
||||
NodeViewItem *GetItemFromMap(Node *node) const
|
||||
NodeViewItem *get_item_from_map(Node *node) const
|
||||
{
|
||||
return item_map_.value(node);
|
||||
}
|
||||
@@ -66,18 +66,18 @@ public:
|
||||
QWidget *widget = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void AddChild(Node *node);
|
||||
void add_child(Node *node);
|
||||
|
||||
void SetChildPosition(Node *node, const QPointF &pos);
|
||||
void set_child_position(Node *node, const QPointF &pos);
|
||||
|
||||
void RemoveChild(Node *node);
|
||||
void remove_child(Node *node);
|
||||
|
||||
void ChildInputConnected(Node *output, const NodeInput &input);
|
||||
void child_input_connected(Node *output, const NodeInput &input);
|
||||
|
||||
bool ChildInputDisconnected(Node *output, const NodeInput &input);
|
||||
bool child_input_disconnected(Node *output, const NodeInput &input);
|
||||
|
||||
signals:
|
||||
void ItemAboutToBeDeleted(NodeViewItem *item);
|
||||
void item_about_to_be_deleted(NodeViewItem *item);
|
||||
|
||||
protected:
|
||||
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
@@ -86,9 +86,9 @@ protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
void AddNodeInternal(Node *node, NodeViewItem *item);
|
||||
void add_node_internal(Node *node, NodeViewItem *item);
|
||||
|
||||
void AddEdgeInternal(Node *output, const NodeInput &input,
|
||||
void add_edge_internal(Node *output, const NodeInput &input,
|
||||
NodeViewItem *from, NodeViewItem *to);
|
||||
|
||||
Node *context_;
|
||||
@@ -106,11 +106,11 @@ private:
|
||||
QVector<NodeViewEdge *> edges_;
|
||||
|
||||
private slots:
|
||||
void GroupAddedNode(Node *node);
|
||||
void group_added_node(Node *node);
|
||||
|
||||
void GroupRemovedNode(Node *node);
|
||||
void group_removed_node(Node *node);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWCONTEXT_H
|
||||
#endif // OAK_NODEVIEWCONTEXT_H
|
||||
|
||||
@@ -45,11 +45,11 @@ NodeViewEdge::NodeViewEdge(Node *output, const NodeInput &input,
|
||||
, from_item_(from_item)
|
||||
, to_item_(to_item)
|
||||
{
|
||||
Init();
|
||||
SetConnected(true);
|
||||
init();
|
||||
set_connected(true);
|
||||
|
||||
from_item_->AddEdge(this);
|
||||
to_item_->AddEdge(this);
|
||||
from_item_->add_edge(this);
|
||||
to_item_->add_edge(this);
|
||||
}
|
||||
|
||||
NodeViewEdge::NodeViewEdge(QGraphicsItem *parent)
|
||||
@@ -57,83 +57,83 @@ NodeViewEdge::NodeViewEdge(QGraphicsItem *parent)
|
||||
, from_item_(nullptr)
|
||||
, to_item_(nullptr)
|
||||
{
|
||||
Init();
|
||||
init();
|
||||
}
|
||||
|
||||
NodeViewEdge::~NodeViewEdge()
|
||||
{
|
||||
if (from_item_) {
|
||||
from_item_->RemoveEdge(this);
|
||||
from_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
if (to_item_) {
|
||||
to_item_->RemoveEdge(this);
|
||||
to_item_->remove_edge(this);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewEdge::set_from_item(NodeViewItem *i)
|
||||
{
|
||||
if (from_item_) {
|
||||
from_item_->RemoveEdge(this);
|
||||
from_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
from_item_ = i;
|
||||
|
||||
if (from_item_) {
|
||||
from_item_->AddEdge(this);
|
||||
from_item_->add_edge(this);
|
||||
}
|
||||
|
||||
Adjust();
|
||||
adjust();
|
||||
}
|
||||
|
||||
void NodeViewEdge::set_to_item(NodeViewItem *i)
|
||||
{
|
||||
if (to_item_) {
|
||||
to_item_->RemoveEdge(this);
|
||||
to_item_->remove_edge(this);
|
||||
}
|
||||
|
||||
to_item_ = i;
|
||||
|
||||
if (to_item_) {
|
||||
to_item_->AddEdge(this);
|
||||
to_item_->add_edge(this);
|
||||
}
|
||||
|
||||
Adjust();
|
||||
adjust();
|
||||
}
|
||||
|
||||
void NodeViewEdge::Adjust()
|
||||
void NodeViewEdge::adjust()
|
||||
{
|
||||
// Draw a line between the two
|
||||
SetPoints(from_item()->GetOutputPoint(), to_item()->GetInputPoint());
|
||||
set_points(from_item()->get_output_point(), to_item()->get_input_point());
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetConnected(bool c)
|
||||
void NodeViewEdge::set_connected(bool c)
|
||||
{
|
||||
connected_ = c;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetHighlighted(bool e)
|
||||
void NodeViewEdge::set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetPoints(const QPointF &start, const QPointF &end)
|
||||
void NodeViewEdge::set_points(const QPointF &start, const QPointF &end)
|
||||
{
|
||||
cached_start_ = start;
|
||||
cached_end_ = end;
|
||||
|
||||
UpdateCurve();
|
||||
update_curve();
|
||||
}
|
||||
|
||||
void NodeViewEdge::SetCurved(bool e)
|
||||
void NodeViewEdge::set_curved(bool e)
|
||||
{
|
||||
curved_ = e;
|
||||
|
||||
UpdateCurve();
|
||||
update_curve();
|
||||
}
|
||||
|
||||
void NodeViewEdge::paint(QPainter *painter,
|
||||
@@ -162,7 +162,7 @@ void NodeViewEdge::paint(QPainter *painter,
|
||||
painter->drawPath(path());
|
||||
}
|
||||
|
||||
void NodeViewEdge::Init()
|
||||
void NodeViewEdge::init()
|
||||
{
|
||||
connected_ = false;
|
||||
highlighted_ = false;
|
||||
@@ -177,7 +177,7 @@ void NodeViewEdge::Init()
|
||||
edge_width_ = QFontMetrics(QFont()).height() / 12;
|
||||
}
|
||||
|
||||
void NodeViewEdge::UpdateCurve()
|
||||
void NodeViewEdge::update_curve()
|
||||
{
|
||||
const QPointF &start = cached_start_;
|
||||
const QPointF &end = cached_end_;
|
||||
@@ -194,30 +194,30 @@ void NodeViewEdge::UpdateCurve()
|
||||
QPointF cp1, cp2;
|
||||
|
||||
NodeViewCommon::FlowDirection from_flow =
|
||||
from_item_ ? from_item_->GetFlowDirection() :
|
||||
NodeViewCommon::kInvalidDirection;
|
||||
from_item_ ? from_item_->get_flow_direction() :
|
||||
NodeViewCommon::k_invalid_direction;
|
||||
NodeViewCommon::FlowDirection to_flow =
|
||||
to_item_ ? to_item_->GetFlowDirection() :
|
||||
NodeViewCommon::kInvalidDirection;
|
||||
to_item_ ? to_item_->get_flow_direction() :
|
||||
NodeViewCommon::k_invalid_direction;
|
||||
|
||||
if (from_flow == NodeViewCommon::kInvalidDirection &&
|
||||
to_flow == NodeViewCommon::kInvalidDirection) {
|
||||
if (from_flow == NodeViewCommon::k_invalid_direction &&
|
||||
to_flow == NodeViewCommon::k_invalid_direction) {
|
||||
// This is a technically unsupported scenario, but to avoid issues, we'll use a fallback
|
||||
from_flow = NodeViewCommon::kLeftToRight;
|
||||
to_flow = NodeViewCommon::kLeftToRight;
|
||||
} else if (from_flow == NodeViewCommon::kInvalidDirection) {
|
||||
from_flow = NodeViewCommon::k_left_to_right;
|
||||
to_flow = NodeViewCommon::k_left_to_right;
|
||||
} else if (from_flow == NodeViewCommon::k_invalid_direction) {
|
||||
from_flow = to_flow;
|
||||
} else if (to_flow == NodeViewCommon::kInvalidDirection) {
|
||||
} else if (to_flow == NodeViewCommon::k_invalid_direction) {
|
||||
to_flow = from_flow;
|
||||
}
|
||||
|
||||
if (NodeViewCommon::GetFlowOrientation(from_flow) == Qt::Horizontal) {
|
||||
if (NodeViewCommon::get_flow_orientation(from_flow) == Qt::Horizontal) {
|
||||
cp1 = QPointF(half_x, start.y());
|
||||
} else {
|
||||
cp1 = QPointF(start.x(), half_y);
|
||||
}
|
||||
|
||||
if (NodeViewCommon::GetFlowOrientation(to_flow) == Qt::Horizontal) {
|
||||
if (NodeViewCommon::get_flow_orientation(to_flow) == Qt::Horizontal) {
|
||||
cp2 = QPointF(half_x, end.y());
|
||||
} else {
|
||||
cp2 = QPointF(end.x(), half_y);
|
||||
@@ -244,8 +244,8 @@ void NodeViewEdge::UpdateCurve()
|
||||
std::swap(y2, y3);
|
||||
}
|
||||
|
||||
double t = Bezier::CubicXtoT(continue_x, x1, x2, x3, x4);
|
||||
double y = Bezier::CubicTtoY(y1, y2, y3, y4, t);
|
||||
double t = Bezier::cubic_xto_t(continue_x, x1, x2, x3, x4);
|
||||
double y = Bezier::cubic_tto_y(y1, y2, y3, y4, t);
|
||||
|
||||
angle = std::atan2(end.y() - y, end.x() - continue_x);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEEDGEITEM_H
|
||||
#define NODEEDGEITEM_H
|
||||
#ifndef OAK_NODEEDGEITEM_H
|
||||
#define OAK_NODEEDGEITEM_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QPalette>
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
void set_to_item(NodeViewItem *i);
|
||||
|
||||
void Adjust();
|
||||
void adjust();
|
||||
|
||||
/**
|
||||
* @brief Set the connected state of this line
|
||||
@@ -88,9 +88,9 @@ public:
|
||||
* Using SetEdge() automatically sets this to true. Under most circumstances this should be left alone, and only
|
||||
* be set when an edge is being created/dragged.
|
||||
*/
|
||||
void SetConnected(bool c);
|
||||
void set_connected(bool c);
|
||||
|
||||
bool IsConnected() const
|
||||
bool is_connected() const
|
||||
{
|
||||
return connected_;
|
||||
}
|
||||
@@ -100,17 +100,17 @@ public:
|
||||
*
|
||||
* Changes color of edge.
|
||||
*/
|
||||
void SetHighlighted(bool e);
|
||||
void set_highlighted(bool e);
|
||||
|
||||
/**
|
||||
* @brief Set points to create curve from
|
||||
*/
|
||||
void SetPoints(const QPointF &start, const QPointF &end);
|
||||
void set_points(const QPointF &start, const QPointF &end);
|
||||
|
||||
/**
|
||||
* @brief Set whether edges should be drawn as curved or as straight lines
|
||||
*/
|
||||
void SetCurved(bool e);
|
||||
void set_curved(bool e);
|
||||
|
||||
protected:
|
||||
virtual void paint(QPainter *painter,
|
||||
@@ -118,9 +118,9 @@ protected:
|
||||
QWidget *widget = nullptr) override;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void init();
|
||||
|
||||
void UpdateCurve();
|
||||
void update_curve();
|
||||
|
||||
Node *output_;
|
||||
|
||||
@@ -146,4 +146,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEEDGEITEM_H
|
||||
#endif // OAK_NODEEDGEITEM_H
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "core.h"
|
||||
#include "node/nodeundo.h"
|
||||
#include "node/value.h"
|
||||
#include "pluginSupport/OlivePluginInstance.h"
|
||||
#include "pluginSupport/oliveplugininstance.h"
|
||||
#include "nodeview.h"
|
||||
#include "nodeviewscene.h"
|
||||
#include "ui/colorcoding.h"
|
||||
@@ -51,7 +51,7 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element,
|
||||
, context_(context)
|
||||
, expanded_(false)
|
||||
, highlighted_(false)
|
||||
, flow_dir_(NodeViewCommon::kInvalidDirection)
|
||||
, flow_dir_(NodeViewCommon::k_invalid_direction)
|
||||
, arrow_click_(false)
|
||||
, label_as_output_(false)
|
||||
{
|
||||
@@ -60,28 +60,28 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element,
|
||||
//
|
||||
|
||||
// Set border width
|
||||
node_border_width_ = DefaultItemBorder();
|
||||
node_border_width_ = default_item_border();
|
||||
|
||||
// Set rect size to default
|
||||
SetRectSize();
|
||||
set_rect_size();
|
||||
|
||||
// Create connector
|
||||
input_connector_ = new NodeViewItemConnector(false, this);
|
||||
output_connector_ = new NodeViewItemConnector(true, this);
|
||||
|
||||
connect(node_, &Node::LabelChanged, this,
|
||||
&NodeViewItem::NodeAppearanceChanged);
|
||||
connect(node_, &Node::ColorChanged, this,
|
||||
&NodeViewItem::NodeAppearanceChanged);
|
||||
connect(node_, &Node::MessageCountChanged, this,
|
||||
&NodeViewItem::NodeAppearanceChanged);
|
||||
connect(node_, &Node::label_changed, this,
|
||||
&NodeViewItem::node_appearance_changed);
|
||||
connect(node_, &Node::color_changed, this,
|
||||
&NodeViewItem::node_appearance_changed);
|
||||
connect(node_, &Node::message_count_changed, this,
|
||||
&NodeViewItem::node_appearance_changed);
|
||||
|
||||
if (IsOutputItem()) {
|
||||
connect(node_, &Node::InputAdded, this,
|
||||
&NodeViewItem::RepopulateInputs);
|
||||
connect(node_, &Node::InputRemoved, this,
|
||||
&NodeViewItem::RepopulateInputs);
|
||||
RepopulateInputs();
|
||||
if (is_output_item()) {
|
||||
connect(node_, &Node::input_added, this,
|
||||
&NodeViewItem::repopulate_inputs);
|
||||
connect(node_, &Node::input_removed, this,
|
||||
&NodeViewItem::repopulate_inputs);
|
||||
repopulate_inputs();
|
||||
|
||||
// Set flags for this widget
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges);
|
||||
@@ -89,19 +89,19 @@ NodeViewItem::NodeViewItem(Node *node, const QString &input, int element,
|
||||
setFlag(QGraphicsItem::ItemIsSelectable);
|
||||
|
||||
if (context_) {
|
||||
SetNodePosition(context_->GetNodePositionDataInContext(node_));
|
||||
set_node_position(context_->get_node_position_data_in_context(node_));
|
||||
}
|
||||
} else {
|
||||
output_connector_->setVisible(false);
|
||||
|
||||
connect(node_, &Node::InputArraySizeChanged, this,
|
||||
&NodeViewItem::InputArraySizeChanged);
|
||||
connect(node_, &Node::InputArraySizeChanged, this,
|
||||
&NodeViewItem::InputArraySizeChanged);
|
||||
connect(node_, &Node::input_array_size_changed, this,
|
||||
&NodeViewItem::input_array_size_changed);
|
||||
connect(node_, &Node::input_array_size_changed, this,
|
||||
&NodeViewItem::input_array_size_changed);
|
||||
}
|
||||
|
||||
// This should be set during runtime, but just in case here's a default fallback
|
||||
SetFlowDirection(NodeViewCommon::kLeftToRight);
|
||||
set_flow_direction(NodeViewCommon::k_left_to_right);
|
||||
}
|
||||
|
||||
NodeViewItem::~NodeViewItem()
|
||||
@@ -109,185 +109,185 @@ NodeViewItem::~NodeViewItem()
|
||||
Q_ASSERT(edges_.isEmpty());
|
||||
}
|
||||
|
||||
Node::Position NodeViewItem::GetNodePositionData() const
|
||||
Node::Position NodeViewItem::get_node_position_data() const
|
||||
{
|
||||
return Node::Position(GetNodePosition(), IsExpanded());
|
||||
return Node::Position(get_node_position(), is_expanded());
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::GetNodePosition() const
|
||||
QPointF NodeViewItem::get_node_position() const
|
||||
{
|
||||
return ScreenToNodePoint(pos(), flow_dir_);
|
||||
return screen_to_node_point(pos(), flow_dir_);
|
||||
}
|
||||
|
||||
void NodeViewItem::SetNodePosition(const QPointF &pos)
|
||||
void NodeViewItem::set_node_position(const QPointF &pos)
|
||||
{
|
||||
cached_node_pos_ = pos;
|
||||
|
||||
UpdateNodePosition();
|
||||
update_node_position();
|
||||
}
|
||||
|
||||
void NodeViewItem::SetNodePosition(const Node::Position &pos)
|
||||
void NodeViewItem::set_node_position(const Node::Position &pos)
|
||||
{
|
||||
SetNodePosition(pos.position);
|
||||
SetExpanded(pos.expanded);
|
||||
set_node_position(pos.position);
|
||||
set_expanded(pos.expanded);
|
||||
}
|
||||
|
||||
QVector<NodeViewEdge *> NodeViewItem::GetAllEdgesRecursively() const
|
||||
QVector<NodeViewEdge *> NodeViewItem::get_all_edges_recursively() const
|
||||
{
|
||||
QVector<NodeViewEdge *> list = edges_;
|
||||
|
||||
foreach (NodeViewItem *item, children_) {
|
||||
list.append(item->GetAllEdgesRecursively());
|
||||
list.append(item->get_all_edges_recursively());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
int NodeViewItem::DefaultTextPadding()
|
||||
int NodeViewItem::default_text_padding()
|
||||
{
|
||||
return QFontMetrics(QFont()).height() / 4;
|
||||
}
|
||||
|
||||
int NodeViewItem::DefaultItemHeight()
|
||||
int NodeViewItem::default_item_height()
|
||||
{
|
||||
return QFontMetrics(QFont()).height() + DefaultTextPadding() * 2;
|
||||
return QFontMetrics(QFont()).height() + default_text_padding() * 2;
|
||||
}
|
||||
|
||||
int NodeViewItem::DefaultItemWidth()
|
||||
int NodeViewItem::default_item_width()
|
||||
{
|
||||
return QtUtils::QFontMetricsWidth(QFontMetrics(QFont()),
|
||||
return QtUtils::q_font_metrics_width(QFontMetrics(QFont()),
|
||||
"HHHHHHHHHHHHHHHH");
|
||||
;
|
||||
}
|
||||
|
||||
int NodeViewItem::DefaultItemBorder()
|
||||
int NodeViewItem::default_item_border()
|
||||
{
|
||||
return QFontMetrics(QFont()).height() / 12;
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::NodeToScreenPoint(QPointF p,
|
||||
QPointF NodeViewItem::node_to_screen_point(QPointF p,
|
||||
NodeViewCommon::FlowDirection direction)
|
||||
{
|
||||
switch (direction) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
// NodeGraphs are always left-to-right internally, no need to translate
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
// Invert X value
|
||||
p.setX(-p.x());
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
// Swap X/Y
|
||||
p = QPointF(p.y(), p.x());
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
// Swap X/Y and invert Y
|
||||
p = QPointF(p.y(), -p.x());
|
||||
break;
|
||||
case NodeViewCommon::kInvalidDirection:
|
||||
case NodeViewCommon::k_invalid_direction:
|
||||
break;
|
||||
}
|
||||
|
||||
// Multiply by item sizes for this direction
|
||||
p.setX(p.x() * DefaultItemHorizontalPadding(direction));
|
||||
p.setY(p.y() * DefaultItemVerticalPadding(direction));
|
||||
p.setX(p.x() * default_item_horizontal_padding(direction));
|
||||
p.setY(p.y() * default_item_vertical_padding(direction));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::ScreenToNodePoint(QPointF p,
|
||||
QPointF NodeViewItem::screen_to_node_point(QPointF p,
|
||||
NodeViewCommon::FlowDirection direction)
|
||||
{
|
||||
// Divide by item sizes for this direction
|
||||
p.setX(p.x() / DefaultItemHorizontalPadding(direction));
|
||||
p.setY(p.y() / DefaultItemVerticalPadding(direction));
|
||||
p.setX(p.x() / default_item_horizontal_padding(direction));
|
||||
p.setY(p.y() / default_item_vertical_padding(direction));
|
||||
|
||||
switch (direction) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
// NodeGraphs are always left-to-right internally, no need to translate
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
// Invert X value
|
||||
p.setX(-p.x());
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
// Swap X/Y
|
||||
p = QPointF(p.y(), p.x());
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
// Swap X/Y and invert Y
|
||||
p = QPointF(-p.y(), p.x());
|
||||
break;
|
||||
case NodeViewCommon::kInvalidDirection:
|
||||
case NodeViewCommon::k_invalid_direction:
|
||||
break;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
qreal NodeViewItem::DefaultItemHorizontalPadding(
|
||||
qreal NodeViewItem::default_item_horizontal_padding(
|
||||
NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
if (NodeViewCommon::GetFlowOrientation(dir) == Qt::Horizontal) {
|
||||
return DefaultItemWidth() * 1.5;
|
||||
if (NodeViewCommon::get_flow_orientation(dir) == Qt::Horizontal) {
|
||||
return default_item_width() * 1.5;
|
||||
} else {
|
||||
return DefaultItemWidth() * 1.25;
|
||||
return default_item_width() * 1.25;
|
||||
}
|
||||
}
|
||||
|
||||
qreal NodeViewItem::DefaultItemVerticalPadding(NodeViewCommon::FlowDirection dir)
|
||||
qreal NodeViewItem::default_item_vertical_padding(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
if (NodeViewCommon::GetFlowOrientation(dir) == Qt::Horizontal) {
|
||||
return DefaultItemHeight() * 1.5;
|
||||
if (NodeViewCommon::get_flow_orientation(dir) == Qt::Horizontal) {
|
||||
return default_item_height() * 1.5;
|
||||
} else {
|
||||
return DefaultItemHeight() * 2.0;
|
||||
return default_item_height() * 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
qreal NodeViewItem::DefaultItemHorizontalPadding() const
|
||||
qreal NodeViewItem::default_item_horizontal_padding() const
|
||||
{
|
||||
return DefaultItemHorizontalPadding(flow_dir_);
|
||||
return default_item_horizontal_padding(flow_dir_);
|
||||
}
|
||||
|
||||
qreal NodeViewItem::DefaultItemVerticalPadding() const
|
||||
qreal NodeViewItem::default_item_vertical_padding() const
|
||||
{
|
||||
return DefaultItemVerticalPadding(flow_dir_);
|
||||
return default_item_vertical_padding(flow_dir_);
|
||||
}
|
||||
|
||||
void NodeViewItem::AddEdge(NodeViewEdge *edge)
|
||||
void NodeViewItem::add_edge(NodeViewEdge *edge)
|
||||
{
|
||||
edges_.append(edge);
|
||||
}
|
||||
|
||||
void NodeViewItem::RemoveEdge(NodeViewEdge *edge)
|
||||
void NodeViewItem::remove_edge(NodeViewEdge *edge)
|
||||
{
|
||||
edges_.removeOne(edge);
|
||||
}
|
||||
|
||||
void NodeViewItem::SetExpanded(bool e, bool hide_titlebar)
|
||||
void NodeViewItem::set_expanded(bool e, bool hide_titlebar)
|
||||
{
|
||||
if (!CanBeExpanded() || (expanded_ == e)) {
|
||||
if (!can_be_expanded() || (expanded_ == e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
expanded_ = e;
|
||||
|
||||
if (context_) {
|
||||
context_->SetNodeExpandedInContext(node_, e);
|
||||
context_->set_node_expanded_in_context(node_, e);
|
||||
}
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
// We don't have to check has_connectable_inputs_ here because we did it at the top
|
||||
input_connector_->setVisible(!expanded_);
|
||||
}
|
||||
|
||||
if (expanded_) {
|
||||
node_->Retranslate();
|
||||
node_->retranslate();
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
// Create items for each input of the node
|
||||
foreach (const QString &input, node_->inputs()) {
|
||||
if (IsInputValid(input)) {
|
||||
if (is_input_valid(input)) {
|
||||
NodeViewItem *item =
|
||||
new NodeViewItem(node_, input, -1, context_, this);
|
||||
children_.append(item);
|
||||
@@ -297,12 +297,12 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar)
|
||||
QVector<NodeViewEdge *> edges = edges_;
|
||||
for (auto it = edges.cbegin(); it != edges.cend(); it++) {
|
||||
if ((*it)->to_item() == this) {
|
||||
(*it)->set_to_item(GetItemForInput((*it)->input()));
|
||||
(*it)->set_to_item(get_item_for_input((*it)->input()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Create items for each element of the input array
|
||||
int arr_sz = node_->InputArraySize(input_);
|
||||
int arr_sz = node_->input_array_size(input_);
|
||||
children_.resize(arr_sz);
|
||||
for (int i = 0; i < arr_sz; i++) {
|
||||
NodeViewItem *item =
|
||||
@@ -313,7 +313,7 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar)
|
||||
QVector<NodeViewEdge *> edges = edges_;
|
||||
for (auto it = edges.cbegin(); it != edges.cend(); it++) {
|
||||
if ((*it)->to_item() == this) {
|
||||
(*it)->set_to_item(GetItemForInput((*it)->input()));
|
||||
(*it)->set_to_item(get_item_for_input((*it)->input()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,22 +328,22 @@ void NodeViewItem::SetExpanded(bool e, bool hide_titlebar)
|
||||
children_.clear();
|
||||
}
|
||||
|
||||
UpdateChildrenPositions();
|
||||
update_children_positions();
|
||||
|
||||
if (flow_dir_ == NodeViewCommon::kTopToBottom) {
|
||||
UpdateOutputConnectorPosition();
|
||||
if (flow_dir_ == NodeViewCommon::k_top_to_bottom) {
|
||||
update_output_connector_position();
|
||||
}
|
||||
|
||||
ReadjustAllEdges();
|
||||
readjust_all_edges();
|
||||
|
||||
UpdateContextRect();
|
||||
update_context_rect();
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewItem::ToggleExpanded()
|
||||
void NodeViewItem::toggle_expanded()
|
||||
{
|
||||
SetExpanded(!IsExpanded());
|
||||
set_expanded(!is_expanded());
|
||||
}
|
||||
|
||||
void NodeViewItem::paint(QPainter *painter,
|
||||
@@ -355,9 +355,9 @@ void NodeViewItem::paint(QPainter *painter,
|
||||
|
||||
// We only draw a single unit's worth
|
||||
QRectF single_unit_rect = rect();
|
||||
single_unit_rect.setHeight(DefaultItemHeight());
|
||||
single_unit_rect.setHeight(default_item_height());
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
// Set output item colors
|
||||
painter->setPen(Qt::black);
|
||||
painter->setBrush(
|
||||
@@ -382,30 +382,30 @@ void NodeViewItem::paint(QPainter *painter,
|
||||
// Determine what text to draw and whether to draw an arrow
|
||||
QString node_label, node_name;
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
if (label_as_output_) {
|
||||
node_name = QCoreApplication::translate("NodeViewItem", "Output");
|
||||
} else {
|
||||
node_label = node_->GetLabel();
|
||||
node_name = node_->ShortName();
|
||||
node_label = node_->get_label();
|
||||
node_name = node_->short_name();
|
||||
}
|
||||
} else {
|
||||
if (element_ == -1) {
|
||||
node_name = node_->GetInputName(input_);
|
||||
node_name = node_->get_input_name(input_);
|
||||
} else {
|
||||
node_name = QString::number(
|
||||
element_ +
|
||||
node_->GetInputProperty(input_, QStringLiteral("arraystart"))
|
||||
node_->get_input_property(input_, QStringLiteral("arraystart"))
|
||||
.toInt());
|
||||
}
|
||||
}
|
||||
|
||||
// Draw arrow if necessary
|
||||
int arrow_size = CanBeExpanded() ? DrawExpandArrow(painter) : 0;
|
||||
int arrow_size = can_be_expanded() ? draw_expand_arrow(painter) : 0;
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
// Determine the text color (automatically calculate from node background color)
|
||||
painter->setPen(ColorCoding::GetUISelectorColor(node_->color()));
|
||||
painter->setPen(ColorCoding::get_ui_selector_color(node_->color()));
|
||||
} else {
|
||||
// Just use text item
|
||||
painter->setPen(app_pal.text().color());
|
||||
@@ -413,10 +413,10 @@ void NodeViewItem::paint(QPainter *painter,
|
||||
|
||||
if (node_label.isEmpty()) {
|
||||
// Draw name only
|
||||
DrawNodeTitle(painter, node_name, single_unit_rect, Qt::AlignVCenter,
|
||||
draw_node_title(painter, node_name, single_unit_rect, Qt::AlignVCenter,
|
||||
arrow_size);
|
||||
} else {
|
||||
int text_pad = DefaultTextPadding() / 2;
|
||||
int text_pad = default_text_padding() / 2;
|
||||
QRectF safe_label_bounds =
|
||||
single_unit_rect.adjusted(text_pad, text_pad, -text_pad, -text_pad);
|
||||
QFont f;
|
||||
@@ -425,22 +425,22 @@ void NodeViewItem::paint(QPainter *painter,
|
||||
// Draw label as larger/upper text
|
||||
f.setPointSizeF(font_sz * 0.8);
|
||||
painter->setFont(f);
|
||||
DrawNodeTitle(painter, node_label, safe_label_bounds, Qt::AlignTop,
|
||||
draw_node_title(painter, node_label, safe_label_bounds, Qt::AlignTop,
|
||||
arrow_size);
|
||||
|
||||
// Draw node name as smaller/lower text
|
||||
f.setPointSizeF(font_sz * 0.6);
|
||||
painter->setFont(f);
|
||||
DrawNodeTitle(painter, node_name, safe_label_bounds, Qt::AlignBottom,
|
||||
draw_node_title(painter, node_name, safe_label_bounds, Qt::AlignBottom,
|
||||
arrow_size);
|
||||
}
|
||||
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
auto *instance = node_->getPluginInstance();
|
||||
auto *olive_instance =
|
||||
dynamic_cast<plugin::OlivePluginInstance *>(instance);
|
||||
int message_count =
|
||||
olive_instance ? olive_instance->persistentMessageCount() : 0;
|
||||
olive_instance ? olive_instance->persistent_message_count() : 0;
|
||||
|
||||
if (message_count > 0) {
|
||||
QString badge_text = QString::number(message_count);
|
||||
@@ -470,7 +470,7 @@ void NodeViewItem::paint(QPainter *painter,
|
||||
}
|
||||
|
||||
// Draw final border (output only)
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
QPen border_pen;
|
||||
border_pen.setWidth(node_border_width_);
|
||||
|
||||
@@ -491,12 +491,12 @@ void NodeViewItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (last_arrow_rect_.contains(event->pos().toPoint())) {
|
||||
arrow_click_ = true;
|
||||
ToggleExpanded();
|
||||
toggle_expanded();
|
||||
return;
|
||||
}
|
||||
|
||||
event->setModifiers(
|
||||
QtUtils::FlipControlAndShiftModifiers(event->modifiers()));
|
||||
QtUtils::flip_control_and_shift_modifiers(event->modifiers()));
|
||||
|
||||
QGraphicsRectItem::mousePressEvent(event);
|
||||
}
|
||||
@@ -508,7 +508,7 @@ void NodeViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
}
|
||||
|
||||
event->setModifiers(
|
||||
QtUtils::FlipControlAndShiftModifiers(event->modifiers()));
|
||||
QtUtils::flip_control_and_shift_modifiers(event->modifiers()));
|
||||
|
||||
QGraphicsRectItem::mouseMoveEvent(event);
|
||||
}
|
||||
@@ -521,7 +521,7 @@ void NodeViewItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
}
|
||||
|
||||
event->setModifiers(
|
||||
QtUtils::FlipControlAndShiftModifiers(event->modifiers()));
|
||||
QtUtils::flip_control_and_shift_modifiers(event->modifiers()));
|
||||
|
||||
QGraphicsRectItem::mouseReleaseEvent(event);
|
||||
}
|
||||
@@ -531,9 +531,9 @@ QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
{
|
||||
if (node_) {
|
||||
if (change == ItemPositionHasChanged) {
|
||||
ReadjustAllEdges();
|
||||
readjust_all_edges();
|
||||
|
||||
UpdateContextRect();
|
||||
update_context_rect();
|
||||
} else if (change == ItemSelectedHasChanged) {
|
||||
if (value.toBool()) {
|
||||
qDebug() << "Selected node:" << node_;
|
||||
@@ -544,28 +544,28 @@ QVariant NodeViewItem::itemChange(QGraphicsItem::GraphicsItemChange change,
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void NodeViewItem::ReadjustAllEdges()
|
||||
void NodeViewItem::readjust_all_edges()
|
||||
{
|
||||
foreach (NodeViewEdge *edge, edges_) {
|
||||
if (NodeViewItem *to_item = edge->to_item()) {
|
||||
static_cast<NodeViewItem *>(to_item->parentItem())
|
||||
->UpdateFlowDirectionOfInputItem(to_item);
|
||||
->update_flow_direction_of_input_item(to_item);
|
||||
}
|
||||
|
||||
edge->Adjust();
|
||||
edge->adjust();
|
||||
}
|
||||
foreach (NodeViewItem *child, children_) {
|
||||
child->ReadjustAllEdges();
|
||||
child->readjust_all_edges();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateContextRect()
|
||||
void NodeViewItem::update_context_rect()
|
||||
{
|
||||
QGraphicsItem *item = parentItem();
|
||||
|
||||
while (item) {
|
||||
if (NodeViewContext *ctx = dynamic_cast<NodeViewContext *>(item)) {
|
||||
ctx->UpdateRect();
|
||||
ctx->update_rect();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -573,7 +573,7 @@ void NodeViewItem::UpdateContextRect()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text,
|
||||
void NodeViewItem::draw_node_title(QPainter *painter, QString text,
|
||||
const QRectF &rect,
|
||||
Qt::Alignment vertical_align,
|
||||
int icon_full_size)
|
||||
@@ -582,8 +582,8 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text,
|
||||
|
||||
// Calculate how much space we have for text
|
||||
int item_width = this->rect().width();
|
||||
int max_text_width = item_width - DefaultTextPadding() * 2 - icon_full_size;
|
||||
int label_width = QtUtils::QFontMetricsWidth(fm, text);
|
||||
int max_text_width = item_width - default_text_padding() * 2 - icon_full_size;
|
||||
int label_width = QtUtils::q_font_metrics_width(fm, text);
|
||||
|
||||
// Concatenate text if necessary (adds a "..." to the end and removes characters until the
|
||||
// string fits in the bounds)
|
||||
@@ -594,7 +594,7 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text,
|
||||
text.chop(1);
|
||||
concatenated =
|
||||
QCoreApplication::translate("NodeViewItem", "%1...").arg(text);
|
||||
} while ((label_width = QtUtils::QFontMetricsWidth(fm, concatenated)) >
|
||||
} while ((label_width = QtUtils::q_font_metrics_width(fm, concatenated)) >
|
||||
max_text_width);
|
||||
|
||||
text = concatenated;
|
||||
@@ -613,16 +613,16 @@ void NodeViewItem::DrawNodeTitle(QPainter *painter, QString text,
|
||||
painter->drawText(text_rect, text_align, text);
|
||||
}
|
||||
|
||||
int NodeViewItem::DrawExpandArrow(QPainter *painter)
|
||||
int NodeViewItem::draw_expand_arrow(QPainter *painter)
|
||||
{
|
||||
// Draw right or down arrow based on expanded state
|
||||
int icon_size = painter->fontMetrics().height() / 2;
|
||||
int icon_padding = DefaultItemHeight() / 2 - icon_size / 2;
|
||||
int icon_padding = default_item_height() / 2 - icon_size / 2;
|
||||
int icon_full_size = icon_size + icon_padding * 2;
|
||||
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
|
||||
const QIcon &expand_icon = IsExpanded() ? icon::TriDown : icon::TriRight;
|
||||
const QIcon &expand_icon = is_expanded() ? icon::tri_down : icon::tri_right;
|
||||
int icon_size_scaled = icon_size * painter->transform().m11();
|
||||
|
||||
last_arrow_rect_ = QRect(this->rect().x() + icon_padding,
|
||||
@@ -636,35 +636,35 @@ int NodeViewItem::DrawExpandArrow(QPainter *painter)
|
||||
return icon_full_size;
|
||||
}
|
||||
|
||||
void NodeViewItem::SetLabelAsOutput(bool e)
|
||||
void NodeViewItem::set_label_as_output(bool e)
|
||||
{
|
||||
label_as_output_ = e;
|
||||
output_connector_->setVisible(!e);
|
||||
update();
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::GetInputPoint() const
|
||||
QPointF NodeViewItem::get_input_point() const
|
||||
{
|
||||
return input_connector_->scenePos();
|
||||
}
|
||||
|
||||
QPointF NodeViewItem::GetOutputPoint() const
|
||||
QPointF NodeViewItem::get_output_point() const
|
||||
{
|
||||
QPointF p = output_connector_->scenePos();
|
||||
QRectF r = output_connector_->polygon().boundingRect();
|
||||
|
||||
switch (flow_dir_) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
default:
|
||||
p.setX(p.x() + r.width());
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
p.setX(p.x() - r.width());
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
p.setY(p.y() + r.height());
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
p.setY(p.y() - r.height());
|
||||
break;
|
||||
}
|
||||
@@ -672,173 +672,173 @@ QPointF NodeViewItem::GetOutputPoint() const
|
||||
return p;
|
||||
}
|
||||
|
||||
void NodeViewItem::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
void NodeViewItem::set_flow_direction(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
if (flow_dir_ != dir) {
|
||||
flow_dir_ = dir;
|
||||
|
||||
input_connector_->SetFlowDirection(dir);
|
||||
output_connector_->SetFlowDirection(dir);
|
||||
input_connector_->set_flow_direction(dir);
|
||||
output_connector_->set_flow_direction(dir);
|
||||
|
||||
UpdateInputConnectorPosition();
|
||||
UpdateOutputConnectorPosition();
|
||||
update_input_connector_position();
|
||||
update_output_connector_position();
|
||||
|
||||
if (IsOutputItem()) {
|
||||
UpdateNodePosition();
|
||||
if (is_output_item()) {
|
||||
update_node_position();
|
||||
}
|
||||
|
||||
ReadjustAllEdges();
|
||||
readjust_all_edges();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateNodePosition()
|
||||
void NodeViewItem::update_node_position()
|
||||
{
|
||||
setPos(NodeToScreenPoint(cached_node_pos_, flow_dir_));
|
||||
setPos(node_to_screen_point(cached_node_pos_, flow_dir_));
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateInputConnectorPosition()
|
||||
void NodeViewItem::update_input_connector_position()
|
||||
{
|
||||
QRectF output_rect = input_connector_->polygon().boundingRect();
|
||||
|
||||
NodeViewCommon::FlowDirection using_flow_dir = flow_dir_;
|
||||
|
||||
if (IsExpanded() && !NodeViewCommon::IsFlowHorizontal(flow_dir_)) {
|
||||
if (is_expanded() && !NodeViewCommon::is_flow_horizontal(flow_dir_)) {
|
||||
if (edges_.isEmpty() || edges_.first()->from_item()->x() < this->x()) {
|
||||
using_flow_dir = NodeViewCommon::kLeftToRight;
|
||||
using_flow_dir = NodeViewCommon::k_left_to_right;
|
||||
} else {
|
||||
using_flow_dir = NodeViewCommon::kRightToLeft;
|
||||
using_flow_dir = NodeViewCommon::k_right_to_left;
|
||||
}
|
||||
}
|
||||
|
||||
// Input connector flow directions change conditionally
|
||||
switch (using_flow_dir) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
input_connector_->setPos(rect().left() - output_rect.width(), 0);
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
input_connector_->setPos(rect().right() + output_rect.width(), 0);
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
input_connector_->setPos(rect().center().x(),
|
||||
rect().top() - output_rect.height());
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
input_connector_->setPos(rect().center().x(),
|
||||
rect().bottom() + output_rect.height());
|
||||
break;
|
||||
case NodeViewCommon::kInvalidDirection:
|
||||
case NodeViewCommon::k_invalid_direction:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateOutputConnectorPosition()
|
||||
void NodeViewItem::update_output_connector_position()
|
||||
{
|
||||
switch (flow_dir_) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
output_connector_->setPos(rect().right(), 0);
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
output_connector_->setPos(rect().left(), 0);
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
output_connector_->setPos(rect().center().x(), rect().bottom());
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
output_connector_->setPos(rect().center().x(), rect().top());
|
||||
break;
|
||||
case NodeViewCommon::kInvalidDirection:
|
||||
case NodeViewCommon::k_invalid_direction:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeViewItem::IsInputValid(const QString &input)
|
||||
bool NodeViewItem::is_input_valid(const QString &input)
|
||||
{
|
||||
if (!node_->IsInputConnectable(input) || node_->IsInputHidden(input)) {
|
||||
if (!node_->is_input_connectable(input) || node_->is_input_hidden(input)) {
|
||||
return false;
|
||||
}
|
||||
// For OFX plugin nodes, only show texture inputs in the node graph
|
||||
// to avoid excessively tall nodes with dozens of scalar parameters.
|
||||
// Scalar parameters are still visible in the parameter panel.
|
||||
if (node_->getPluginInstance() != nullptr &&
|
||||
node_->GetInputDataType(input) != NodeValue::kTexture) {
|
||||
node_->get_input_data_type(input) != NodeValue::k_texture) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NodeViewItem::SetRectSize(int height_units)
|
||||
void NodeViewItem::set_rect_size(int height_units)
|
||||
{
|
||||
// Set rect
|
||||
int widget_width = DefaultItemWidth();
|
||||
int widget_height = DefaultItemHeight();
|
||||
int widget_width = default_item_width();
|
||||
int widget_height = default_item_height();
|
||||
|
||||
setRect(QRectF(-widget_width / 2, -widget_height / 2, widget_width,
|
||||
widget_height * height_units));
|
||||
}
|
||||
|
||||
bool NodeViewItem::CanBeExpanded() const
|
||||
bool NodeViewItem::can_be_expanded() const
|
||||
{
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
return has_connectable_inputs_;
|
||||
} else {
|
||||
return node_->GetInputFlags(input_) & kInputFlagArray &&
|
||||
element_ == -1 && !node_->IsInputConnected(input_);
|
||||
return node_->get_input_flags(input_) & k_input_flag_array &&
|
||||
element_ == -1 && !node_->is_input_connected(input_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateChildrenPositions()
|
||||
void NodeViewItem::update_children_positions()
|
||||
{
|
||||
int y = 1;
|
||||
int h = DefaultItemHeight();
|
||||
int h = default_item_height();
|
||||
|
||||
foreach (NodeViewItem *c, children_) {
|
||||
c->setPos(QPointF(0, y * h));
|
||||
|
||||
y += c->GetLogicalHeightWithChildren();
|
||||
y += c->get_logical_height_with_children();
|
||||
}
|
||||
|
||||
SetRectSize(y);
|
||||
set_rect_size(y);
|
||||
|
||||
if (NodeViewItem *p = dynamic_cast<NodeViewItem *>(parentItem())) {
|
||||
p->UpdateChildrenPositions();
|
||||
p->update_children_positions();
|
||||
}
|
||||
}
|
||||
|
||||
int NodeViewItem::GetLogicalHeightWithChildren() const
|
||||
int NodeViewItem::get_logical_height_with_children() const
|
||||
{
|
||||
int h = 1;
|
||||
|
||||
foreach (NodeViewItem *c, children_) {
|
||||
h += c->GetLogicalHeightWithChildren();
|
||||
h += c->get_logical_height_with_children();
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
void NodeViewItem::UpdateFlowDirectionOfInputItem(NodeViewItem *child)
|
||||
void NodeViewItem::update_flow_direction_of_input_item(NodeViewItem *child)
|
||||
{
|
||||
if (!child->IsOutputItem()) {
|
||||
if (NodeViewCommon::IsFlowVertical(flow_dir_)) {
|
||||
if (!child->is_output_item()) {
|
||||
if (NodeViewCommon::is_flow_vertical(flow_dir_)) {
|
||||
if (!child->edges().isEmpty() &&
|
||||
child->edges().first()->from_item()->scenePos().x() >
|
||||
child->scenePos().x()) {
|
||||
child->SetFlowDirection(NodeViewCommon::kRightToLeft);
|
||||
child->set_flow_direction(NodeViewCommon::k_right_to_left);
|
||||
} else {
|
||||
child->SetFlowDirection(NodeViewCommon::kLeftToRight);
|
||||
child->set_flow_direction(NodeViewCommon::k_left_to_right);
|
||||
}
|
||||
} else {
|
||||
child->SetFlowDirection(flow_dir_);
|
||||
child->set_flow_direction(flow_dir_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::RepopulateInputs()
|
||||
void NodeViewItem::repopulate_inputs()
|
||||
{
|
||||
if (IsOutputItem()) {
|
||||
if (is_output_item()) {
|
||||
has_connectable_inputs_ = false;
|
||||
|
||||
foreach (const QString &input, node_->inputs()) {
|
||||
if (IsInputValid(input)) {
|
||||
if (is_input_valid(input)) {
|
||||
has_connectable_inputs_ = true;
|
||||
break;
|
||||
}
|
||||
@@ -847,55 +847,55 @@ void NodeViewItem::RepopulateInputs()
|
||||
input_connector_->setVisible(has_connectable_inputs_);
|
||||
}
|
||||
|
||||
if (IsExpanded() && (IsOutputItem() || element_ == -1)) {
|
||||
if (is_expanded() && (is_output_item() || element_ == -1)) {
|
||||
// Create or remove inputs when necessary
|
||||
// NOTE: This is not the most efficient thing in the world, but it does work
|
||||
SetExpanded(false);
|
||||
SetExpanded(true);
|
||||
set_expanded(false);
|
||||
set_expanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::InputArraySizeChanged(const QString &input)
|
||||
void NodeViewItem::input_array_size_changed(const QString &input)
|
||||
{
|
||||
if (input == input_) {
|
||||
RepopulateInputs();
|
||||
repopulate_inputs();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewItem::NodeAppearanceChanged()
|
||||
void NodeViewItem::node_appearance_changed()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void NodeViewItem::SetHighlighted(bool e)
|
||||
void NodeViewItem::set_highlighted(bool e)
|
||||
{
|
||||
highlighted_ = e;
|
||||
update();
|
||||
}
|
||||
|
||||
NodeViewItem *NodeViewItem::GetItemForInput(NodeInput input)
|
||||
NodeViewItem *NodeViewItem::get_item_for_input(NodeInput input)
|
||||
{
|
||||
if (NodeGroup *group = dynamic_cast<NodeGroup *>(node_)) {
|
||||
if (input.node() != group) {
|
||||
// Translate input to group input
|
||||
QString id = group->GetIDOfPassthrough(input);
|
||||
QString id = group->get_id_of_passthrough(input);
|
||||
input.set_node(group);
|
||||
input.set_input(id);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsExpanded()) {
|
||||
if (is_expanded()) {
|
||||
if (input_.isEmpty()) {
|
||||
// Look for the input in our children
|
||||
foreach (NodeViewItem *i, children_) {
|
||||
if (i->input_ == input.input()) {
|
||||
return i->GetItemForInput(input);
|
||||
return i->get_item_for_input(input);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Look for element in our children
|
||||
if (input.element() >= 0 && input.element() < children_.size()) {
|
||||
return children_.at(input.element())->GetItemForInput(input);
|
||||
return children_.at(input.element())->get_item_for_input(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWITEM_H
|
||||
#define NODEVIEWITEM_H
|
||||
#ifndef OAK_NODEVIEWITEM_H
|
||||
#define OAK_NODEVIEWITEM_H
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QGraphicsRectItem>
|
||||
@@ -56,27 +56,27 @@ public:
|
||||
|
||||
virtual ~NodeViewItem() override;
|
||||
|
||||
Node::Position GetNodePositionData() const;
|
||||
QPointF GetNodePosition() const;
|
||||
void SetNodePosition(const QPointF &pos);
|
||||
void SetNodePosition(const Node::Position &pos);
|
||||
Node::Position get_node_position_data() const;
|
||||
QPointF get_node_position() const;
|
||||
void set_node_position(const QPointF &pos);
|
||||
void set_node_position(const Node::Position &pos);
|
||||
|
||||
QVector<NodeViewEdge *> GetAllEdgesRecursively() const;
|
||||
QVector<NodeViewEdge *> get_all_edges_recursively() const;
|
||||
|
||||
/**
|
||||
* @brief Get currently attached node
|
||||
*/
|
||||
Node *GetNode() const
|
||||
Node *get_node() const
|
||||
{
|
||||
return node_;
|
||||
}
|
||||
|
||||
NodeInput GetInput() const
|
||||
NodeInput get_input() const
|
||||
{
|
||||
return NodeInput(node_, input_, element_);
|
||||
}
|
||||
|
||||
Node *GetContext() const
|
||||
Node *get_context() const
|
||||
{
|
||||
return context_;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
/**
|
||||
* @brief Get expanded state
|
||||
*/
|
||||
bool IsExpanded() const
|
||||
bool is_expanded() const
|
||||
{
|
||||
return expanded_;
|
||||
}
|
||||
@@ -97,65 +97,65 @@ public:
|
||||
/**
|
||||
* @brief Set expanded state
|
||||
*/
|
||||
void SetExpanded(bool e, bool hide_titlebar = false);
|
||||
void ToggleExpanded();
|
||||
void set_expanded(bool e, bool hide_titlebar = false);
|
||||
void toggle_expanded();
|
||||
|
||||
QPointF GetInputPoint() const;
|
||||
QPointF GetOutputPoint() const;
|
||||
QPointF get_input_point() const;
|
||||
QPointF get_output_point() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the direction nodes are flowing
|
||||
*/
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
NodeViewCommon::FlowDirection GetFlowDirection() const
|
||||
NodeViewCommon::FlowDirection get_flow_direction() const
|
||||
{
|
||||
return flow_dir_;
|
||||
}
|
||||
|
||||
static int DefaultTextPadding();
|
||||
static int default_text_padding();
|
||||
|
||||
static int DefaultItemHeight();
|
||||
static int default_item_height();
|
||||
|
||||
static int DefaultItemWidth();
|
||||
static int default_item_width();
|
||||
|
||||
static int DefaultItemBorder();
|
||||
static int default_item_border();
|
||||
|
||||
static QPointF NodeToScreenPoint(QPointF p,
|
||||
static QPointF node_to_screen_point(QPointF p,
|
||||
NodeViewCommon::FlowDirection direction);
|
||||
static QPointF ScreenToNodePoint(QPointF p,
|
||||
static QPointF screen_to_node_point(QPointF p,
|
||||
NodeViewCommon::FlowDirection direction);
|
||||
|
||||
static qreal
|
||||
DefaultItemHorizontalPadding(NodeViewCommon::FlowDirection dir);
|
||||
static qreal DefaultItemVerticalPadding(NodeViewCommon::FlowDirection dir);
|
||||
qreal DefaultItemHorizontalPadding() const;
|
||||
qreal DefaultItemVerticalPadding() const;
|
||||
default_item_horizontal_padding(NodeViewCommon::FlowDirection dir);
|
||||
static qreal default_item_vertical_padding(NodeViewCommon::FlowDirection dir);
|
||||
qreal default_item_horizontal_padding() const;
|
||||
qreal default_item_vertical_padding() const;
|
||||
|
||||
void AddEdge(NodeViewEdge *edge);
|
||||
void RemoveEdge(NodeViewEdge *edge);
|
||||
void add_edge(NodeViewEdge *edge);
|
||||
void remove_edge(NodeViewEdge *edge);
|
||||
|
||||
bool IsLabelledAsOutputOfContext() const
|
||||
bool is_labelled_as_output_of_context() const
|
||||
{
|
||||
return label_as_output_;
|
||||
}
|
||||
|
||||
void SetLabelAsOutput(bool e);
|
||||
void set_label_as_output(bool e);
|
||||
|
||||
void SetHighlighted(bool e);
|
||||
void set_highlighted(bool e);
|
||||
|
||||
NodeViewItem *GetItemForInput(NodeInput input);
|
||||
NodeViewItem *get_item_for_input(NodeInput input);
|
||||
|
||||
bool IsOutputItem() const
|
||||
bool is_output_item() const
|
||||
{
|
||||
return input_.isEmpty();
|
||||
}
|
||||
|
||||
void ReadjustAllEdges();
|
||||
void readjust_all_edges();
|
||||
|
||||
void UpdateFlowDirectionOfInputItem(NodeViewItem *child);
|
||||
void update_flow_direction_of_input_item(NodeViewItem *child);
|
||||
|
||||
bool CanBeExpanded() const;
|
||||
bool can_be_expanded() const;
|
||||
|
||||
protected:
|
||||
virtual void paint(QPainter *painter,
|
||||
@@ -170,28 +170,28 @@ protected:
|
||||
const QVariant &value) override;
|
||||
|
||||
private:
|
||||
void UpdateContextRect();
|
||||
void update_context_rect();
|
||||
|
||||
void DrawNodeTitle(QPainter *painter, QString text, const QRectF &rect,
|
||||
void draw_node_title(QPainter *painter, QString text, const QRectF &rect,
|
||||
Qt::Alignment vertical_align, int icon_full_size);
|
||||
|
||||
int DrawExpandArrow(QPainter *painter);
|
||||
int draw_expand_arrow(QPainter *painter);
|
||||
|
||||
/**
|
||||
* @brief Internal update function when logical position changes
|
||||
*/
|
||||
void UpdateNodePosition();
|
||||
void update_node_position();
|
||||
|
||||
void UpdateInputConnectorPosition();
|
||||
void UpdateOutputConnectorPosition();
|
||||
void update_input_connector_position();
|
||||
void update_output_connector_position();
|
||||
|
||||
bool IsInputValid(const QString &input);
|
||||
bool is_input_valid(const QString &input);
|
||||
|
||||
void SetRectSize(int height_units = 1);
|
||||
void set_rect_size(int height_units = 1);
|
||||
|
||||
void UpdateChildrenPositions();
|
||||
void update_children_positions();
|
||||
|
||||
int GetLogicalHeightWithChildren() const;
|
||||
int get_logical_height_with_children() const;
|
||||
|
||||
/**
|
||||
* @brief Reference to attached Node
|
||||
@@ -234,13 +234,13 @@ private:
|
||||
bool label_as_output_;
|
||||
|
||||
private slots:
|
||||
void NodeAppearanceChanged();
|
||||
void node_appearance_changed();
|
||||
|
||||
void RepopulateInputs();
|
||||
void repopulate_inputs();
|
||||
|
||||
void InputArraySizeChanged(const QString &input);
|
||||
void input_array_size_changed(const QString &input);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWITEM_H
|
||||
#endif // OAK_NODEVIEWITEM_H
|
||||
|
||||
@@ -37,11 +37,11 @@ NodeViewItemConnector::NodeViewItemConnector(bool is_output,
|
||||
, output_(is_output)
|
||||
{
|
||||
QColor c = qApp->palette().text().color();
|
||||
setPen(QPen(c, NodeViewItem::DefaultItemBorder()));
|
||||
setPen(QPen(c, NodeViewItem::default_item_border()));
|
||||
setBrush(c);
|
||||
}
|
||||
|
||||
void NodeViewItemConnector::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
void NodeViewItemConnector::set_flow_direction(NodeViewCommon::FlowDirection dir)
|
||||
{
|
||||
QFont f;
|
||||
QFontMetricsF fm(f);
|
||||
@@ -53,31 +53,31 @@ void NodeViewItemConnector::SetFlowDirection(NodeViewCommon::FlowDirection dir)
|
||||
p.resize(3);
|
||||
|
||||
switch (dir) {
|
||||
case NodeViewCommon::kLeftToRight:
|
||||
case NodeViewCommon::k_left_to_right:
|
||||
// Triangle pointing right
|
||||
p[0] = QPointF(0, -triangle_sz_half);
|
||||
p[1] = QPointF(triangle_sz_half, 0);
|
||||
p[2] = QPointF(0, triangle_sz_half);
|
||||
break;
|
||||
case NodeViewCommon::kTopToBottom:
|
||||
case NodeViewCommon::k_top_to_bottom:
|
||||
// Triangle pointing down
|
||||
p[0] = QPointF(-triangle_sz_half, 0);
|
||||
p[1] = QPointF(0, triangle_sz_half);
|
||||
p[2] = QPointF(triangle_sz_half, 0);
|
||||
break;
|
||||
case NodeViewCommon::kBottomToTop:
|
||||
case NodeViewCommon::k_bottom_to_top:
|
||||
// Triangle pointing up
|
||||
p[0] = QPointF(-triangle_sz_half, 0);
|
||||
p[1] = QPointF(0, -triangle_sz_half);
|
||||
p[2] = QPointF(triangle_sz_half, 0);
|
||||
break;
|
||||
case NodeViewCommon::kRightToLeft:
|
||||
case NodeViewCommon::k_right_to_left:
|
||||
// Triangle pointing left
|
||||
p[0] = QPointF(0, -triangle_sz_half);
|
||||
p[1] = QPointF(-triangle_sz_half, 0);
|
||||
p[2] = QPointF(0, triangle_sz_half);
|
||||
break;
|
||||
case NodeViewCommon::kInvalidDirection:
|
||||
case NodeViewCommon::k_invalid_direction:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWITEMCONNECTOR_H
|
||||
#define NODEVIEWITEMCONNECTOR_H
|
||||
#ifndef OAK_NODEVIEWITEMCONNECTOR_H
|
||||
#define OAK_NODEVIEWITEMCONNECTOR_H
|
||||
|
||||
#include <QGraphicsPolygonItem>
|
||||
|
||||
@@ -33,9 +33,9 @@ class NodeViewItemConnector : public QGraphicsPolygonItem {
|
||||
public:
|
||||
NodeViewItemConnector(bool is_output, QGraphicsItem *parent = nullptr);
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection dir);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection dir);
|
||||
|
||||
bool IsOutput() const
|
||||
bool is_output() const
|
||||
{
|
||||
return output_;
|
||||
}
|
||||
@@ -49,4 +49,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWITEMCONNECTOR_H
|
||||
#endif // OAK_NODEVIEWITEMCONNECTOR_H
|
||||
|
||||
@@ -33,7 +33,7 @@ NodeViewMiniMap::NodeViewMiniMap(NodeViewScene *scene, QWidget *parent)
|
||||
, resizing_(false)
|
||||
{
|
||||
connect(scene, &QGraphicsScene::sceneRectChanged, this,
|
||||
&NodeViewMiniMap::SceneChanged);
|
||||
&NodeViewMiniMap::scene_changed);
|
||||
setScene(scene);
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@@ -43,13 +43,13 @@ NodeViewMiniMap::NodeViewMiniMap(NodeViewScene *scene, QWidget *parent)
|
||||
setFrameShadow(QFrame::Plain);
|
||||
setMouseTracking(true);
|
||||
|
||||
QMetaObject::invokeMethod(this, &NodeViewMiniMap::SetDefaultSize,
|
||||
QMetaObject::invokeMethod(this, &NodeViewMiniMap::set_default_size,
|
||||
Qt::QueuedConnection);
|
||||
|
||||
resize_triangle_sz_ = fontMetrics().height() / 2;
|
||||
}
|
||||
|
||||
void NodeViewMiniMap::SetViewportRect(const QPolygonF &rect)
|
||||
void NodeViewMiniMap::set_viewport_rect(const QPolygonF &rect)
|
||||
{
|
||||
viewport_rect_ = rect;
|
||||
|
||||
@@ -85,20 +85,20 @@ void NodeViewMiniMap::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
super::resizeEvent(event);
|
||||
|
||||
emit Resized();
|
||||
emit resized();
|
||||
|
||||
SceneChanged(sceneRect());
|
||||
scene_changed(sceneRect());
|
||||
}
|
||||
|
||||
void NodeViewMiniMap::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
if (MouseInsideResizeTriangle(event)) {
|
||||
if (mouse_inside_resize_triangle(event)) {
|
||||
// Resizing!
|
||||
resizing_ = true;
|
||||
resize_anchor_ = QCursor::pos();
|
||||
} else {
|
||||
EmitMoveSignal(event);
|
||||
emit_move_signal(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,10 +111,10 @@ void NodeViewMiniMap::mouseMoveEvent(QMouseEvent *event)
|
||||
resize(QSize(width() - movement.x(), height() - movement.y()));
|
||||
resize_anchor_ = QCursor::pos();
|
||||
} else {
|
||||
EmitMoveSignal(event);
|
||||
emit_move_signal(event);
|
||||
}
|
||||
} else {
|
||||
if (MouseInsideResizeTriangle(event)) {
|
||||
if (mouse_inside_resize_triangle(event)) {
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
} else {
|
||||
unsetCursor();
|
||||
@@ -127,7 +127,7 @@ void NodeViewMiniMap::mouseReleaseEvent(QMouseEvent *event)
|
||||
resizing_ = false;
|
||||
}
|
||||
|
||||
void NodeViewMiniMap::SceneChanged(const QRectF &bounding)
|
||||
void NodeViewMiniMap::scene_changed(const QRectF &bounding)
|
||||
{
|
||||
double x_scale = double(this->width()) / bounding.width();
|
||||
double y_scale = double(this->height()) / bounding.height();
|
||||
@@ -140,22 +140,22 @@ void NodeViewMiniMap::SceneChanged(const QRectF &bounding)
|
||||
setTransform(transform);
|
||||
}
|
||||
|
||||
void NodeViewMiniMap::SetDefaultSize()
|
||||
void NodeViewMiniMap::set_default_size()
|
||||
{
|
||||
if (parentWidget()) {
|
||||
resize(parentWidget()->width() / 4, parentWidget()->height() / 4);
|
||||
}
|
||||
}
|
||||
|
||||
bool NodeViewMiniMap::MouseInsideResizeTriangle(QMouseEvent *event)
|
||||
bool NodeViewMiniMap::mouse_inside_resize_triangle(QMouseEvent *event)
|
||||
{
|
||||
return event->pos().x() <= resize_triangle_sz_ &&
|
||||
event->pos().y() <= resize_triangle_sz_;
|
||||
}
|
||||
|
||||
void NodeViewMiniMap::EmitMoveSignal(QMouseEvent *event)
|
||||
void NodeViewMiniMap::emit_move_signal(QMouseEvent *event)
|
||||
{
|
||||
emit MoveToScenePoint(mapToScene(event->pos()));
|
||||
emit move_to_scene_point(mapToScene(event->pos()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWMINIMAP_H
|
||||
#define NODEVIEWMINIMAP_H
|
||||
#ifndef OAK_NODEVIEWMINIMAP_H
|
||||
#define OAK_NODEVIEWMINIMAP_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
|
||||
@@ -35,12 +35,12 @@ public:
|
||||
NodeViewMiniMap(NodeViewScene *scene, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void SetViewportRect(const QPolygonF &rect);
|
||||
void set_viewport_rect(const QPolygonF &rect);
|
||||
|
||||
signals:
|
||||
void Resized();
|
||||
void resized();
|
||||
|
||||
void MoveToScenePoint(const QPointF &pos);
|
||||
void move_to_scene_point(const QPointF &pos);
|
||||
|
||||
protected:
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
@@ -55,14 +55,14 @@ protected:
|
||||
}
|
||||
|
||||
private slots:
|
||||
void SceneChanged(const QRectF &bounding);
|
||||
void scene_changed(const QRectF &bounding);
|
||||
|
||||
void SetDefaultSize();
|
||||
void set_default_size();
|
||||
|
||||
private:
|
||||
bool MouseInsideResizeTriangle(QMouseEvent *event);
|
||||
bool mouse_inside_resize_triangle(QMouseEvent *event);
|
||||
|
||||
void EmitMoveSignal(QMouseEvent *event);
|
||||
void emit_move_signal(QMouseEvent *event);
|
||||
|
||||
int resize_triangle_sz_;
|
||||
|
||||
@@ -75,4 +75,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWMINIMAP_H
|
||||
#endif // OAK_NODEVIEWMINIMAP_H
|
||||
|
||||
@@ -31,54 +31,54 @@ namespace olive
|
||||
|
||||
NodeViewScene::NodeViewScene(QObject *parent)
|
||||
: QGraphicsScene(parent)
|
||||
, direction_(NodeViewCommon::kLeftToRight)
|
||||
, direction_(NodeViewCommon::k_left_to_right)
|
||||
, curved_edges_(true)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeViewScene::SetFlowDirection(NodeViewCommon::FlowDirection direction)
|
||||
void NodeViewScene::set_flow_direction(NodeViewCommon::FlowDirection direction)
|
||||
{
|
||||
direction_ = direction;
|
||||
|
||||
foreach (NodeViewContext *ctx, context_map_) {
|
||||
ctx->SetFlowDirection(direction_);
|
||||
ctx->set_flow_direction(direction_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewScene::SelectAll()
|
||||
void NodeViewScene::select_all()
|
||||
{
|
||||
foreach (QGraphicsItem *i, items()) {
|
||||
i->setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeViewScene::DeselectAll()
|
||||
void NodeViewScene::deselect_all()
|
||||
{
|
||||
foreach (QGraphicsItem *i, items()) {
|
||||
i->setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<NodeViewItem *> NodeViewScene::GetSelectedItems() const
|
||||
QVector<NodeViewItem *> NodeViewScene::get_selected_items() const
|
||||
{
|
||||
QVector<NodeViewItem *> items;
|
||||
|
||||
foreach (NodeViewContext *ctx, context_map_) {
|
||||
items.append(ctx->GetSelectedItems());
|
||||
items.append(ctx->get_selected_items());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
NodeViewContext *NodeViewScene::AddContext(Node *node)
|
||||
NodeViewContext *NodeViewScene::add_context(Node *node)
|
||||
{
|
||||
NodeViewContext *context_item = context_map_.value(node);
|
||||
|
||||
if (!context_item) {
|
||||
context_item = new NodeViewContext(node);
|
||||
|
||||
context_item->SetFlowDirection(GetFlowDirection());
|
||||
context_item->SetCurvedEdges(GetEdgesAreCurved());
|
||||
context_item->set_flow_direction(get_flow_direction());
|
||||
context_item->set_curved_edges(get_edges_are_curved());
|
||||
|
||||
QPointF pos(0, 0);
|
||||
QRectF item_rect = context_item->rect();
|
||||
@@ -96,23 +96,23 @@ NodeViewContext *NodeViewScene::AddContext(Node *node)
|
||||
return context_item;
|
||||
}
|
||||
|
||||
void NodeViewScene::RemoveContext(Node *node)
|
||||
void NodeViewScene::remove_context(Node *node)
|
||||
{
|
||||
delete context_map_.take(node);
|
||||
}
|
||||
|
||||
Qt::Orientation NodeViewScene::GetFlowOrientation() const
|
||||
Qt::Orientation NodeViewScene::get_flow_orientation() const
|
||||
{
|
||||
return NodeViewCommon::GetFlowOrientation(direction_);
|
||||
return NodeViewCommon::get_flow_orientation(direction_);
|
||||
}
|
||||
|
||||
void NodeViewScene::SetEdgesAreCurved(bool curved)
|
||||
void NodeViewScene::set_edges_are_curved(bool curved)
|
||||
{
|
||||
if (curved_edges_ != curved) {
|
||||
curved_edges_ = curved;
|
||||
|
||||
foreach (NodeViewContext *ctx, context_map_) {
|
||||
ctx->SetCurvedEdges(curved_edges_);
|
||||
ctx->set_curved_edges(curved_edges_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEVIEWSCENE_H
|
||||
#define NODEVIEWSCENE_H
|
||||
#ifndef OAK_NODEVIEWSCENE_H
|
||||
#define OAK_NODEVIEWSCENE_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QTimer>
|
||||
@@ -39,38 +39,38 @@ class NodeViewScene : public QGraphicsScene {
|
||||
public:
|
||||
NodeViewScene(QObject *parent = nullptr);
|
||||
|
||||
void SelectAll();
|
||||
void DeselectAll();
|
||||
void select_all();
|
||||
void deselect_all();
|
||||
|
||||
QVector<NodeViewItem *> GetSelectedItems() const;
|
||||
QVector<NodeViewItem *> get_selected_items() const;
|
||||
|
||||
const QHash<Node *, NodeViewContext *> &context_map() const
|
||||
{
|
||||
return context_map_;
|
||||
}
|
||||
|
||||
Qt::Orientation GetFlowOrientation() const;
|
||||
Qt::Orientation get_flow_orientation() const;
|
||||
|
||||
NodeViewCommon::FlowDirection GetFlowDirection() const
|
||||
NodeViewCommon::FlowDirection get_flow_direction() const
|
||||
{
|
||||
return direction_;
|
||||
}
|
||||
|
||||
void SetFlowDirection(NodeViewCommon::FlowDirection direction);
|
||||
void set_flow_direction(NodeViewCommon::FlowDirection direction);
|
||||
|
||||
bool GetEdgesAreCurved() const
|
||||
bool get_edges_are_curved() const
|
||||
{
|
||||
return curved_edges_;
|
||||
}
|
||||
|
||||
public slots:
|
||||
NodeViewContext *AddContext(Node *node);
|
||||
void RemoveContext(Node *node);
|
||||
NodeViewContext *add_context(Node *node);
|
||||
void remove_context(Node *node);
|
||||
|
||||
/**
|
||||
* @brief Set whether edges in this scene should be curved or not
|
||||
*/
|
||||
void SetEdgesAreCurved(bool curved);
|
||||
void set_edges_are_curved(bool curved);
|
||||
|
||||
private:
|
||||
QHash<Node *, NodeViewContext *> context_map_;
|
||||
@@ -84,4 +84,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWSCENE_H
|
||||
#endif // OAK_NODEVIEWSCENE_H
|
||||
|
||||
@@ -36,41 +36,41 @@ NodeViewToolBar::NodeViewToolBar(QWidget *parent)
|
||||
|
||||
add_node_btn_ = new QPushButton();
|
||||
connect(add_node_btn_, &QPushButton::clicked, this,
|
||||
&NodeViewToolBar::AddNodeClicked);
|
||||
&NodeViewToolBar::add_node_clicked);
|
||||
layout->addWidget(add_node_btn_);
|
||||
|
||||
minimap_btn_ = new QPushButton();
|
||||
minimap_btn_->setCheckable(true);
|
||||
connect(minimap_btn_, &QPushButton::clicked, this,
|
||||
&NodeViewToolBar::MiniMapEnabledToggled);
|
||||
&NodeViewToolBar::mini_map_enabled_toggled);
|
||||
layout->addWidget(minimap_btn_);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
Retranslate();
|
||||
UpdateIcons();
|
||||
retranslate();
|
||||
update_icons();
|
||||
}
|
||||
|
||||
void NodeViewToolBar::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
Retranslate();
|
||||
retranslate();
|
||||
} else if (e->type() == QEvent::StyleChange) {
|
||||
UpdateIcons();
|
||||
update_icons();
|
||||
}
|
||||
super::changeEvent(e);
|
||||
}
|
||||
|
||||
void NodeViewToolBar::Retranslate()
|
||||
void NodeViewToolBar::retranslate()
|
||||
{
|
||||
add_node_btn_->setToolTip(tr("Add Node"));
|
||||
minimap_btn_->setToolTip(tr("Toggle Mini-Map"));
|
||||
}
|
||||
|
||||
void NodeViewToolBar::UpdateIcons()
|
||||
void NodeViewToolBar::update_icons()
|
||||
{
|
||||
add_node_btn_->setIcon(icon::Add);
|
||||
minimap_btn_->setIcon(icon::MiniMap);
|
||||
add_node_btn_->setIcon(icon::add);
|
||||
minimap_btn_->setIcon(icon::mini_map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NODEVIEWTOOLBAR_H
|
||||
#define NODEVIEWTOOLBAR_H
|
||||
#ifndef OAK_NODEVIEWTOOLBAR_H
|
||||
#define OAK_NODEVIEWTOOLBAR_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
@@ -31,23 +31,23 @@ public:
|
||||
NodeViewToolBar(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void SetMiniMapEnabled(bool e)
|
||||
void set_mini_map_enabled(bool e)
|
||||
{
|
||||
minimap_btn_->setChecked(e);
|
||||
}
|
||||
|
||||
signals:
|
||||
void AddNodeClicked();
|
||||
void add_node_clicked();
|
||||
|
||||
void MiniMapEnabledToggled(bool e);
|
||||
void mini_map_enabled_toggled(bool e);
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void Retranslate();
|
||||
void retranslate();
|
||||
|
||||
void UpdateIcons();
|
||||
void update_icons();
|
||||
|
||||
QPushButton *add_node_btn_;
|
||||
|
||||
@@ -56,4 +56,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEVIEWTOOLBAR_H
|
||||
#endif // OAK_NODEVIEWTOOLBAR_H
|
||||
|
||||
@@ -40,14 +40,14 @@ NodeWidget::NodeWidget(QWidget *parent)
|
||||
outer_layout->addWidget(node_view_);
|
||||
|
||||
// Connect toolbar to NodeView
|
||||
connect(toolbar_, &NodeViewToolBar::MiniMapEnabledToggled, node_view_,
|
||||
&NodeView::SetMiniMapEnabled);
|
||||
connect(toolbar_, &NodeViewToolBar::AddNodeClicked, node_view_,
|
||||
&NodeView::ShowAddMenu);
|
||||
connect(toolbar_, &NodeViewToolBar::mini_map_enabled_toggled, node_view_,
|
||||
&NodeView::set_mini_map_enabled);
|
||||
connect(toolbar_, &NodeViewToolBar::add_node_clicked, node_view_,
|
||||
&NodeView::show_add_menu);
|
||||
|
||||
// Set defaults
|
||||
toolbar_->SetMiniMapEnabled(true);
|
||||
node_view_->SetMiniMapEnabled(true);
|
||||
toolbar_->set_mini_map_enabled(true);
|
||||
node_view_->set_mini_map_enabled(true);
|
||||
|
||||
setSizePolicy(node_view_->sizePolicy());
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef NODEWIDGET_H
|
||||
#define NODEWIDGET_H
|
||||
#ifndef OAK_NODEWIDGET_H
|
||||
#define OAK_NODEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@@ -40,9 +40,9 @@ public:
|
||||
return node_view_;
|
||||
}
|
||||
|
||||
void SetContexts(const QVector<Node *> &nodes)
|
||||
void set_contexts(const QVector<Node *> &nodes)
|
||||
{
|
||||
node_view_->SetContexts(nodes);
|
||||
node_view_->set_contexts(nodes);
|
||||
toolbar_->setEnabled(!nodes.isEmpty());
|
||||
}
|
||||
|
||||
@@ -54,4 +54,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // NODEWIDGET_H
|
||||
#endif // OAK_NODEWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user