@@ -505,7 +505,7 @@ void ndbl::_graphview_do_layout_element(Graph_View* graph_view, Node_View* nodev
505505
506506 if ( nodeview->state .has_flags (View_Flag_PINNED) )
507507 {
508- layout_pin_element_at_position (rect.top_left ());
508+ layout_set_floating_at_position (rect.top_left ());
509509 }
510510}
511511
@@ -565,41 +565,45 @@ void ndbl::_graphview_do_layout_recursively(Graph_View* graph_view, Node_View* n
565565 {
566566 if ( nodeview->node () == graph_root ( graph_view->graph () ) )
567567 {
568- layout_pin_element_at_position (nodeview->shape .position ());
568+ layout_set_floating_at_position (nodeview->shape .position ());
569569 }
570570
571571 _graphview_do_layout_recursively_on_expressions_only (graph_view, nodeview);
572572
573+ // propagate on switch branches
574+ // TODO: the container must be centered horizontally, we cannot do that currently with layout
575+ if ( node_has_switch_behavior (node))
576+ {
577+ if ( node->switch_data .branch_count > 1 )
578+ {
579+ Rect parent_rect = nodeview_get_rect (nodeview);
580+ layout_begin_row ();
581+ layout_set_padding (500 .f ,0 ,0 ,0 );
582+ layout_set_gap ( cfg->ui_node_gap (tools::Size_SM).x );
583+
584+ // TODO: There is an issue with Scope, its partition is never set and therefore is empty.
585+ // In the past, I've been implemented partitions to represent nested Scopes. But,
586+ // I don't know if this is the right method. I guess it could be also interested
587+ // to get special links to go from parent to child nodes.
588+ for ( Scope* partition : node->internal_scope ->partition )
589+ {
590+ Node* partition_node = partition->node ();
591+ Node_View* partition_nodeview = node_component<Node_View>(partition->node ());
592+
593+ _graphview_do_layout_recursively (graph_view, partition_nodeview);
594+ }
595+ layout_end ();
596+ }
597+ }
598+
599+ // propagate on internal scope backbone
573600 for ( Node* backbone_node : scope_get_backbone (node->internal_scope ) )
574601 {
575602 Node_View* backbone_nodeview = node_component<Node_View>(backbone_node);
576- _graphview_do_layout_recursively_on_expressions_only (graph_view, backbone_nodeview);
603+ _graphview_do_layout_recursively (graph_view, backbone_nodeview);
577604 }
578605 }
579606 layout_end ();
580-
581- // // Create a row with each branch
582- // if( node_has_switch_behavior(node))
583- // {
584- // if( node->switch_data.branch_count > 1)
585- // {
586- // Rect parent_rect = nodeview_get_rect(node_view);
587- // layout_set_cursor( parent_rect.bottom_left() + cfg->ui_node_gap() * Vec2(1.f, 1.f) );
588- // layout_begin( Container_Config::Row );
589- // layout_set_container_gap( cfg->ui_node_gap(tools::Size_SM).x );
590-
591- // for( Scope* partition : node->internal_scope->partition )
592- // {
593- // Node* partition_node = partition->node();
594- // Node_View* partition_nodeview = node_component<Node_View>(partition->node());
595-
596- // Rect partition_rect = partition_nodeview->shape.rect(WORLD_SPACE);
597-
598- // layout_push(partition_rect.width(), partition_rect.height(), partition_nodeview);
599- // }
600- // layout_end();
601- // }
602- // }
603607};
604608
605609void ndbl::graphview_update (Graph_View* graph_view, float dt)
@@ -618,7 +622,7 @@ void ndbl::graphview_update(Graph_View* graph_view, float dt)
618622 {
619623 Node* root_node = graph_root (graph_view->graph ());
620624 auto * root_nodeview = node_component<Node_View>(root_node);
621- layout_pin_element_at_position (root_nodeview->shape .position (tools::WORLD_SPACE ) + get_config ()->ui_textview_padding );
625+ layout_set_floating_at_position (root_nodeview->shape .position (tools::WORLD_SPACE ) + get_config ()->ui_textview_padding );
622626 _graphview_do_layout_recursively (graph_view, root_nodeview);
623627 }
624628 layout_end ();
0 commit comments