Flow Layout ノードを使用する

Flow Layout ノードを使用して、ノードを一列に配置します。行のスペースがなくなると、Flow Layout ノードはその子ノードを新しい行に配置します。

Flow Layout ノードを使用して、ページ上に配置するのと同じ方法でコンテンツを配置できます。

../../_images/flow-layout.gif

Flow Layout ノードは、追加した順にその子ノードを反復処理し、最初に Primary Direction プロパティで設定されたラインに沿ってアイテムを配置します。Flow Layout ノードが Primary Direction プロパティで設定された方向に利用可能なスペースがなくなると、Secondary Direction プロパティで設定した方向に沿って新しいラインを作成します。Flow Layout ノードの方向を設定する を参照してください。

Flow Layout 3D のチャイルドノードをx、y、z軸に沿って配置するための方向と開始点を設定でき、Flow Layout 2D のチャイルドノードをxおよびy軸に沿って配置することができます。

../../_images/flow-layout-width-change.gif

Flow Layout ノードの作成

Flow Layout ノードを作成するには:

  1. Node Tree Alt を押しながら右クリック で、Flow Layout ノードを作成したいノードを選択し、Flow Layout 3D または Flow Layout 2D のいずれかを選択します。

    3Dノードは、Scene ノードのような3Dノード内でのみ作成でき、2Dノードは2Dノード内でのみ作成できます。

    ../../_images/node-tree-add-flow-layout-node.png

    ヒント

    Preview で Flow Layout 2D tool flow-layout-2d-tool を選択し、Preview でクリックしてドラッグすることで Flow Layout 2D ノードを作成します。

    • 幅が高さよりも大きいレイアウトを作成する場合、レイアウトの方向は Left to Right です。

      ../../_images/flow-layout-x-axis.png ../../_images/flow-layout-x-direction.png
    • 幅よりも高さが大きいレイアウトを作成する場合、レイアウトの方向は Top to Bottom です。

      ../../_images/flow-layout-y-axis.png ../../_images/flow-layout-y-direction.png
  2. Node Tree で、前のステップで作成したレイアウトに子ノードを追加します。

    例えば、Flow Layout 3D ノードを作成した場合、3Dコンテンツを含む複数の Empty Node 3D ノードを追加します。Flow Layout 2D ノードを作成した場合は、複数の Image ノードを追加します。

    子ノードを追加すると、Flow Layout ノードは、Primary Direction プロパティと Secondary Direction プロパティで定義された軸に沿ってそれらを配置します。

    ../../_images/node-tree-add-nodes-in-flow-layout-node.png
  3. (オプション) レイアウト内のチャイルドノードの周囲をクリアするには、Node Tree でレイアウト内のチャイルドノードを選択し、Properties で image0 をクリックし、マージンプロパティを追加して設定します。

    • Depth Margin は、チャイルドノードの前後の領域をクリアします。

    • Horizontal Margin は、チャイルドノードの左側と右側のエリアをクリアします。

    • Vertical Margin は、チャイルドノードの上下の領域をクリアします。

    ../../_images/flow-layout-add-margin.gif

Flow Layout ノードの方向を設定する

Flow Layout ノードでは、Flow Layout ノードが子ノードを配置する開始点と方向の両方を設定できます。

Flow Layout ノードの方向を設定するには、

  1. Flow Layout ノードを作成し、子ノードを追加します。Flow Layout ノードの作成 を参照してください。

  2. Properties で、Flow Layout ノードの方向プロパティを設定します。

    • Primary Direction。この方向に沿ってチャイルドノードが配置され、Flow Layout ノードの制限に達するまで続きます。

      例えば、Flow Layout ノードで Primary Direction が Left to Right に設定されている場合、制限は Layout Width プロパティによって設定されます。しかし、Primary Direction が Near to Far に設定されている場合、制限は Layout Depth プロパティによって設定されます。

      ../../_images/flow-layout-changes-accroding-to-layout-depth.gif
    • Secondary Direction。この方向は、Primary Direction プロパティで設定された制限を超えた場合に、チャイルドノードが配置される方向です。

      例えば、子ノードが左から右、次に上から下に追加される Flow Layout ノードを設定するには、Primary Direction プロパティを Left to Right に設定し、Secondary Direction プロパティを Top to Bottom に設定します。

      Flow Layout ノードが Secondary Direction プロパティで定義された方向に進むようにするためには、Primary Direction プロパティの制限を設定する必要があります。

      ../../_images/flow-layout-secondary-direction.gif

    たとえば、次で使用されている規則に従ってフローレイアウト内のアイテムを配置するには:

    • 左から右への言語の場合、プロパティを設定します:

      • Primary Direction から Left to Right へ

      • Secondary Direction から Top to Bottom へ

      ../../_images/english-text-direction-property-setting.png ../../_images/english-text-preview.png
    • 右から左への言語の場合、プロパティを設定します:

      • Primary Direction から Right to Left へ

      • Secondary Direction から Top to Bottom へ

      ../../_images/arabic-text-direction-property-setting.png ../../_images/arabic-text-preview.png
    • 繁体字のレイアウト、プロパティを設定します:

      • Primary Direction から Top to Bottom へ

      • Secondary Direction から Right to Left へ

      ../../_images/chinese-text-direction-property-setting.png ../../_images/chinese-text-preview.png

Flow Layout 2D ノードの外観を設定する

2D ノードの外観を設定するには:

APIで Flow Layout 3D ノードを使用する

Flow Layout 3D ノードを作成するには、

// Create a Flow Layout 3D node named Flow. The default primary direction is
// left-to-right and the secondary direction top-to-bottom.
FlowLayout3DSharedPtr flow = FlowLayout3D::create(domain, "Flow");

Flow Layout 3D ノードの幅を設定するには、

// Set the width of the Flow Layout 3D node to 6 device-independent pixels to
// limit its size in its primary direction. By limiting the size in
// the primary direction you force the node to create a new line in
// the secondary direction, when it cannot fit an item in the primary direction.
flow->setWidth(6.0f);

Flow Layout 3D ノードにアイテムを追加するには:

// Flow Layout 3D node arranges its items in the order that you add them.
// Create a 3D node ...
Model3DSharedPtr item1 = Model3D::createBox(domain, "item1", Vector3(2.0f, 1.0f, 1.0f), ThemeRed);
// ... and add it to the Flow Layout 3D node.
flow->addChild(item1);
// The second item still fits in the first line.
Model3DSharedPtr item2 = Model3D::createBox(domain, "item2", Vector3(3.0f, 1.0f, 1.0f), ThemeGreen);
flow->addChild(item2);
// There is still space in the first line, but the third item is
// too large to fit, so the Flow Layout 3D node creates a new line.
Model3DSharedPtr item3 = Model3D::createBox(domain, "item3", Vector3(5.0f, 1.0f, 1.0f), ThemeBlue);
flow->addChild(item3);
// The fourth item fits in the second line by leaving no empty space.
Model3DSharedPtr item4 = Model3D::createBox(domain, "item4", Vector3(1.0f, 1.0f, 1.0f), ThemeOrange);
flow->addChild(item4);
// The Flow Layout 3D node places the last item in a new line.
Model3DSharedPtr item5 = Model3D::createBox(domain, "item5", Vector3(3.0f, 1.0f, 1.0f), ThemeGreen);
flow->addChild(item5);

詳細については、FlowLayout3D クラスを参照してください。

APIで Flow Layout 2D ノードを使用する

Flow Layout 2D ノードを作成するには、

// Create a Flow Layout 2D node named Flow. The default primary direction is
// left-to-right and secondary direction top-to-bottom.
FlowLayout2DSharedPtr flow = FlowLayout2D::create(domain, "Flow");

Flow Layout 2D ノードの幅を設定するには:

// Set the width of the Flow Layout 2D node to 600 pixels to limit its size in its
// primary direction. By limiting the size in the primary direction you force
// the node to create a new line in the secondary direction, when it cannot fit
// an item in the primary direction.
flow->setWidth(600.0f);

Flow Layout 2D ノードにアイテムを追加するには、

// Flow Layout 2D node arranges its items in the order that you add them.
// Create a 2D node ...
EmptyNode2DSharedPtr item1 = EmptyNode2D::create(domain, "item1", 200.0f, 200.0f, ThemeRed);
// ... and add it to the Flow Layout 2D node.
flow->addChild(item1);
// The second item still fits in the first line.
EmptyNode2DSharedPtr item2 = EmptyNode2D::create(domain, "item2", 250.0f, 250.0f, ThemeBlue);
flow->addChild(item2);
// There is still space in the first line, but the third item is
// too large to fit, so the Flow Layout 2D node creates a new line.
EmptyNode2DSharedPtr item3 = EmptyNode2D::create(domain, "item3", 200.0f, 200.0f, ThemeGreen);
flow->addChild(item3);
// The fourth item fits in the second line by leaving no empty space.
EmptyNode2DSharedPtr item4 = EmptyNode2D::create(domain, "item4", 400.0f, 400.0f, ThemeOrange);
flow->addChild(item4);
// The Flow Layout 2D node places the last item in a new line.
EmptyNode2DSharedPtr item5 = EmptyNode2D::create(domain, "item5", 150.0f, 150.0f, ThemeRed);
flow->addChild(item5);

詳細については、FlowLayout2D クラスを参照してください。

Flow Layout プロパティタイプとメッセージ

Flow Layout ノードの利用可能なプロパティタイプとメッセージのリストについては、Flow Layout 2D と Flow Layout 3D を参照してください。

関連項目

Dock Layout ノードを使用する

Grid Layout ノードを使用する

Stack Layout ノードを使用する

Trajectory Layout ノードを使用する

レイアウトコントロール (Layout control) ノード

Kanzi Studio Preview ツールを使用してノードのクリックジェスチャーを有効にする