Tutorial: Creating cluster indicators

In this tutorial you learn how to create a turn indicator and control it with a property using the Kanzi state manager.

Complete the tutorial by watching the video, or by following the written instructions.

This tutorial assumes that you understand the basics of working with Kanzi Studio. The best entry points for getting familiar with Kanzi Studio are:

Assets for the tutorial

The starting point of this tutorial is the Indicator.kzproj Kanzi Studio project file stored in the <KanziWorkspace>/Tutorials/Indicator/Start directory.

The <KanziWorkspace>/Tutorials/Indicator/Completed directory contains the completed project of this tutorial.

Create the turn indicator

In this section you create the turn indicator. After opening the starting point project you first create a custom property type you use to control the turn indicators, then you create and use a state manager which you use to control the indicators.

To create the turn indicator:

  1. In Kanzi Studio open the project stored in <KanziWorkspace>/Tutorials/Indicator/Start.

    The project contains the working speed, fuel, and battery gauge needles. To learn how to control the position of gauge needles, see Tutorial: Create gauges.

    Tip

    If you cannot see all three gauges in the Preview, you can adjust the Preview zoom level in the upper right corner of the Preview.

    ../../_images/adjust-the-preview-zoom-level1.png
    ../../_images/start5.png
  2. In the Library press Alt and right-click Property Types and select Property Type.

    ../../_images/create-property-type1.png
  3. In the Property Type Editor set:

    • Name to Indicator.TurnIndicator

    • Display Name to Turn Indicator

    • Category to Gauges

    • Data Type to Boolean

    Click Save to create a property type with the properties you defined.

    You use this custom property type to control when the turn indicator is switched on and when off.

    ../../_images/turnsignal-property.png
  4. From the Assets at the bottom of the Kanzi Studio interface, drag the TurnIndicator image and drop it on the Prefabs window.

    When you drop an asset or a node to the Prefabs window, Kanzi Studio creates a prefab from that item.

    Use node prefabs (prefabricated templates) to structure your application and to create consistent interfaces. Prefabs allow you to create the building blocks of your application and make the application easier to maintain.

    Create a prefab for every item in your application that appears more than once, when you want to logically separate a part of your application, or add content to the node tree when your application is already running. See Using node prefabs.

    ../../_images/drag-turnindicator-from-assets-to-prefabs.png
  5. In the Prefabs select the TurnIndicator prefab, in the Properties right-click, and select Add Property > Gauges > Turn Indicator.

    You add this custom property type to the prefab so that you can control the visibility of the turn indicators with that property in each turn indicator.

    ../../_images/add-turnindicator-property.png
  6. In the Prefabs select the TurnIndicator prefab, and in the State Tools click Create State Manager.

    You can find the State Tools window below the Preview window.

    Kanzi Studio creates a new state manager and assigns it to the TurnIndicator node.

    ../../_images/turnsignalleft-create-state-mgr.png
  7. In the State Tools click Create State twice to create two states, double-click the name of each state, and rename the states.

    For example, name one state Visible and the other Invisible.

    The Visible state defines the state of your application when the turn indicator is visible, the Invisible state when the turn indicator is not visible.

    ../../_images/turnsignalleft-renamed-states.png
  8. In the Prefabs select the TurnIndicator prefab, in the Properties right-click, and select Add Property > Node > Opacity.

    With the Opacity property you can control how translucent is a node. You add this property so that you can face the appearance of the indicator.

    ../../_images/add-opacity-property.png
  9. In the State Tools click image0 in the Visible state to save the current value of the Opacity property to that state.

    The default value of the Opacity property is 1, which makes a node visible, so save that value to the Visible state.

    ../../_images/add-turnsignalleft-node-to-state.png
  10. In the Properties set the Opacity property to 0, and in the State Tools click image1 in the Invisible state to save the current value of the Opacity property to that state.

    ../../_images/add-turnsignalleft-node-to-invisible-state.png
  11. In the State Tools click <No Controller Property> and select Gauges > Turn Indicator.

    In a state manager the value of the property that you select as the Controller Property defines the conditions when each state in a state group is active.

    ../../_images/add-controller-property1.png
  12. In the State Tools set the value of the controller property for each state. For the Visible state set the value to True, and for the Invisible state leave the value set to False.

    ../../_images/set-visible-to-true.png
  13. In the State Tools right-click the Invisible state and select Set as initial state in this group.

    The initial state is the state that Kanzi uses when the application is first started. Because you want to keep the turn indicator off until the user switches it on, you use the Invisible state as the initial state.

    ../../_images/set-as-initial-state.png
  14. In the State Tools click Edit State Manager to deactivate the State Tools.

    ../../_images/deactivate-state-tools2.png

Add the turn indicator to the cluster

In this section you add the TurnIndicator prefab to the cluster to create the left and right turn indicators. Because the state manager logic for both left and right turn indicators is the same, you use the same state manager, but still control each turn indicator separately.

To add the turn indicator to the cluster:

  1. From the Prefabs drag the TurnIndicator prefab to the Node Tree and drop it on the Gauges node, select the TurnIndicator node, press the F2 key, and name the node TurnIndicatorLeft.

    ../../_images/turnindicatorleft-in-the-project.png
  2. In the Node Tree select the TurnIndicatorLeft node, in the Properties click image2 next to the Turn Indicator property to add that property, and enable the Turn Indicator property.

    When you enable the property you make the TurnIndicatorLeft node visible so that you can place it in the Preview.

    ../../_images/enable-turnindicator-property.png
  3. In the Preview select the Node tool node-tool and click snap to disable snapping to nodes and guides.

    When you disable snapping, you can use the Node tool to move a node in the Preview so that it does not snap to nodes or guides.

  4. In the Preview click image3, select Render Transformation for the target transformation, and use the Node tool to place the TurnIndicatorLeft node on the left side of the icons in the top row of the cluster. Position the TurnIndicatorLeft node so that it covers the off indicator for the TurnIndicatorLeft.

    Tip

    Hold down the Shift key when you drag a node with the Node tool to move the node in a true horizontal or vertical line.

    Tip

    To pan in the Preview:

    • Click and drag the middle mouse button.

    • Press the Space key, and click and drag the left mouse button.

    You can apply transformations in these ways:

    • Layout transformation transforms the item before it applies the layout pass.

    • Render transformation transforms the item after it applies the layout pass, but before it renders the item.

    Always use the Render Transformation, unless you know that you have to recalculate the layout.

    ../../_images/turnsignalleft-in-preview.png
  5. In the Node Tree right-click the TurnIndicatorLeft node, select Duplicate, press the F2 key, and name the node TurnIndicatorRight.

    ../../_images/turnindicatorright-in-the-project.png
  6. In the Preview use the Node tool image4 to place the TurnIndicatorRight node on the right side of the icons in the top row of the cluster, and to rotate it 180 degrees so that it points to the right.

    Tip

    When you use the Node tool node, move the mouse pointer over the center of the node handles to resize the node node-tool-resize, and to the outer side of the handles to rotate the node node-tool-rotate. When rotating hold down the Shift key to rotate a node in 45 degree increments.

    ../../_images/node-tool-rotate.png

When you select in the Node Tree either the TurnIndicatorLeft or the TurnIndicatorRight node you can control the visibility of the indicators by enabling and disabling the Turn Indicator property in the Properties.

See also

To learn more about the state managers, see State manager.

To learn how to use state managers and modify the transitions between states, see Using state managers.

To learn more about the Preview and the tools available in the Preview, see Preview and Editing your application in the Preview.

To learn more about different custom property types you can create, see Creating property types.

To learn about the underlying principles of Kanzi properties, see Property system.

To learn about the underlying Kanzi principles, see Kanzi fundamentals.

To learn more about creating Kanzi applications, see Tutorials.

To find out more about Kanzi Studio features, see Working with ....