Customizing Widgetset Generation Customizing Widgetset Generation For adding your own behaviors and widgets to the default widget set, it is required to specify them in the widget set definition (WidgetSet.cpp), which is finally accessed by SceneComposer to provide all exported behaviors and widgets in the user interface. The Candera CMake build system automatically generates this widget set definition (WidgetSet.cpp), so it is only required to provide behavior and widget implementations at any location and to specify this additional behavior and widget location for CMake. This chapter explains how the widget set generation works. Specifying Widget Set (WidgetSet.cpp) The main widget set is a project to generate a library containing definitions for all behaviors and widgets to be used. Behavior and widget implementations can be part of other libraries which of course also need to be linked together with the widget set definition. Refer to the CMake configuration of the Player demo widget set: [CGI-Studio-Root]/cgi_studio_player/src/Behaviors/CMakeLists.txt Following configurations are important: The WidgetSet project source path must point to "${PRV_CGI_GENERATED_CANDERA_DIR}/WidgetSet.cpp". This file will be generated by CMake including all widget implementations. No other files are required as they are added to a separate project. CMake macro CgiAddWidgetSet must be called to register the WidgetSet project. There is no need to call CgiCollectListedFiles as the project should only contain "WidgetSet.cpp". Take care to include the CMake file "${FeatStd_DIR}/cmake/cgistudio/cgistudio_widgetset_generator.cmake". For the Player Widgets, this is already done in /cgi_studio_player/src/Behaviors/CMakeLists.txt. CgiFetchHeaderFiles must be called to register the default widgets project. It has two parameters, the project name and the variable containing the include paths. CgiCreateWidgetSet must be called to generated the WidgetSet.cpp file. It has one parameter containing the CdaDescription which is written to the file. Refer to the following example from the Player behaviors: # Declare widget set class files set(WidgetSet_SRC ${PRV_CGI_GENERATED_CANDERA_DIR}/WidgetSet.cpp ) source_group("WidgetSet" FILES ${WidgetSet_SRC}) # Declare behavior set class files set(BehaviorSet_SRC ${PRV_CGI_GENERATED_CANDERA_DIR}/WidgetSet.cpp ) source_group("BehaviorSet" FILES ${BehaviorSet_SRC}) # Register widget set CgiAddWidgetSet(PRV_WIDGET_TARGET_NAME_WIDGETSET WidgetsSet ${WidgetSet_SRC}) # Register behavior set CgiAddWidgetSet(PRV_WIDGET_TARGET_NAME_WIDGETSET BehaviorSet ${BehaviorSet_SRC}) # Declare default widget directories (include here all your subdirectories # containing behavior and/or widget implementations include(${CGISTUDIO_BEHAVIORSET_CMAKE_INCLUDE}) if (CGIAPP_ENABLE_ADDITIONAL_WIDGETS) if ((EXISTS "${CGIAPP_ADDITIONAL_WIDGET_PATH}")) CgiAddAdditionalWidgets(${CGIAPP_ADDITIONAL_WIDGET_PATH} "Widgets_CgiStudioWidgetsLib") endif() endif() if (CGIAPP_ENABLE_ADDITIONAL_BEHAVIORS) if ((EXISTS "${CGIAPP_ADDITIONAL_BEHAVIOR_PATH}")) CgiGetCurrentDir(PRV_CUR_DIR) CgiAddAdditionalBehaviors(${CGIAPP_ADDITIONAL_BEHAVIOR_PATH} "ControlBehaviors") endif() endif() #add to WidgetSet.cpp if (CGIAPP_ENABLE_TUTORIAL) source_group(PRV_ALL_SRCS FILES ${PRV_CGIAPP_TUTORIALWIDGET_SUBDIRS}) CgiCollectListedFiles(PRV_ALL_SRCS "" "" LIST ${PRV_CGIAPP_TUTORIALWIDGET_SUBDIRS}) CgiFetchHeaderFiles("Widgets_Tutorial" "${PRV_CGIAPP_TUTORIALWIDGET_SUBDIRS}") endif(CGIAPP_ENABLE_TUTORIAL) source_group(PRV_ALL_SRCS FILES ${PRV_CGIAPP_BEHAVIORS_SUBDIRS}) CgiCollectListedFiles(PRV_ALL_SRCS "" "" LIST ${PRV_CGIAPP_BEHAVIORS_SUBDIRS}) #CgiFetchHeaderFiles("Behaviors_Examples" "${PRV_CGIAPP_BEHAVIORS_SUBDIRS}") CgiFetchBehaviorsHeaderFiles("Behaviors_Examples" "${PRV_CGIAPP_BEHAVIORS_SUBDIRS} In this example, following projects will be created in the solution: BehaviorSet for compiling WidgetSet.cpp ControlBehaviors_1 for compiling behaviors defined at /cgi_studio_controls/src/Behaviors Adding Widget Sets If other locations than in the example above shall be included for widget set generation, following steps are required: Specify the paths to additional widget locations in the file /cgi_studio_player/src/Behaviors/AdditionalBehaviorsPaths.txt and/or AdditionalWidgetsPaths.txt. These paths must be relative to the default widget folder. Each directory must - as always - provide a "FileList.txt" which lists all files to include. All subdirectories of the given directories which contain a "FileList.txt" file will also be included. Setup Visual Studio Solution "Player.sln" Start CMake again Point "Where is the source code" to /cmake/Candera/Player Point "Where to build the binaries" to /cgi_studio_player/build. Enable option "CGIAPP_ENABLE_ADDITIONAL_BEHAVIORS" and/or "CGIAPP_ENABLE_ADDITIONAL_WIDGETS" After pressing configure the new option "CGIAPP_ADDITIONAL_BEHAVIOR_PATH" and/or "CGIAPP_ADDITIONAL_WIDGET_PATH" is shown. Cmake should automatically detect "AdditionalBehaviorsPaths.txt" and/or "AdditionalWidgetsPaths.txt" Click "Configure" again Click "Generate", the solution is generated The project will contain a sub project for the generated widget set, a sub project for the main widget set, and further sub projects for each additional widget location specified in AdditionalBehaviorsPaths.txt and/or AdditionalWidgetsPaths.txt. : ATTENTION: The last part of a path in AdditionalBehaviorsPaths.txt and AdditionalBehaviorsWidgetsPaths.txt can not be the same. Fine Wrong (last part is Behaviors for both paths) cgi_studio_controls/src/Behaviors cgi_studio_controls/src/Behaviors CustomBehaviors/src/CustomBehaviors CustomBehaviors/src/Behaviors