PanelTransitPtr createRightPanelButtonPanel(void) { // Create and edit the Panel Buttons ToggleButtonRecPtr RightPanelButton1 = ToggleButton::create(); ToggleButtonRecPtr RightPanelButton2 = ToggleButton::create(); ToggleButtonRecPtr RightPanelButton3 = ToggleButton::create(); ToggleButtonRecPtr RightPanelButton4 = ToggleButton::create(); RightPanelButton1->setText("These"); RightPanelButton1->setPreferredSize(Vec2f(100,50)); RightPanelButton2->setText("are"); RightPanelButton2->setPreferredSize(Vec2f(100,50)); RightPanelButton3->setText("toggle"); RightPanelButton3->setPreferredSize(Vec2f(100,50)); RightPanelButton4->setText("buttons"); RightPanelButton4->setPreferredSize(Vec2f(100,50)); // Create an edit Panel Background ColorLayerRecPtr RightPanelButtonPanelBackground = ColorLayer::create(); RightPanelButtonPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0)); // Create and edit Panel layout BoxLayoutRecPtr RightPanelButtonPanelLayout = BoxLayout::create(); RightPanelButtonPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); // Create Panel Border LineBorderRecPtr PanelBorder2 = LineBorder::create(); PanelBorder2->setColor(Color4f(0.0,0.0,0.0,1.0)); PanelBorder2->setWidth(1); // Create and edit Panel PanelRecPtr RightPanelButtonPanel = Panel::createEmpty(); RightPanelButtonPanel->setPreferredSize(Vec2f(200, 300)); RightPanelButtonPanel->pushToChildren(RightPanelButton1); RightPanelButtonPanel->pushToChildren(RightPanelButton2); RightPanelButtonPanel->pushToChildren(RightPanelButton3); RightPanelButtonPanel->pushToChildren(RightPanelButton4); RightPanelButtonPanel->setLayout(RightPanelButtonPanelLayout); RightPanelButtonPanel->setBackgrounds(RightPanelButtonPanelBackground); RightPanelButtonPanel->setBorders(PanelBorder2); return PanelTransitPtr(RightPanelButtonPanel); }
PanelTransitPtr createRightPanelCheckPanel(Node* const TorusNode, Node* const SphereNode, Node* const ConeNode, Node* const BoxNode) { // Create and edit the CheckBoxes CheckboxButtonRecPtr RightPanelCheck1 = CheckboxButton::create(); CheckboxButtonRecPtr RightPanelCheck2 = CheckboxButton::create(); CheckboxButtonRecPtr RightPanelCheck3 = CheckboxButton::create(); CheckboxButtonRecPtr RightPanelCheck4 = CheckboxButton::create(); //NOTE HorizontalAlignment needs to be changed to Alignment only with Vec2f arg RightPanelCheck1->setText("Show Torus"); RightPanelCheck1->setPreferredSize(Vec2f(125,50)); RightPanelCheck1->setAlignment(0.0); RightPanelCheck1->connectButtonSelected(boost::bind(setNodeTravMask, TorusNode, 1)); RightPanelCheck1->connectButtonDeselected(boost::bind(setNodeTravMask, TorusNode, 0)); RightPanelCheck2->setText("Show Box"); RightPanelCheck2->setPreferredSize(Vec2f(125,50)); RightPanelCheck2->setAlignment(Vec2f (0.5,0.0)); RightPanelCheck2->connectButtonSelected(boost::bind(setNodeTravMask, BoxNode, 1)); RightPanelCheck2->connectButtonDeselected(boost::bind(setNodeTravMask, BoxNode, 0)); RightPanelCheck3->setText("Show Sphere"); RightPanelCheck3->setPreferredSize(Vec2f(125,50)); RightPanelCheck3->setAlignment(Vec2f(0.0,0.0)); RightPanelCheck3->connectButtonSelected(boost::bind(setNodeTravMask, SphereNode, 1)); RightPanelCheck3->connectButtonDeselected(boost::bind(setNodeTravMask, SphereNode, 0)); RightPanelCheck4->setText("Show Cone"); RightPanelCheck4->setPreferredSize(Vec2f(125,50)); RightPanelCheck4->setAlignment(Vec2f(0.0,0.0)); RightPanelCheck4->connectButtonSelected(boost::bind(setNodeTravMask, ConeNode, 1)); RightPanelCheck4->connectButtonDeselected(boost::bind(setNodeTravMask, ConeNode, 0)); // Create an edit Panel Background ColorLayerRecPtr RightPanelCheckPanelBackground = ColorLayer::create(); RightPanelCheckPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0)); // Create and edit Panel layout BoxLayoutRecPtr RightPanelCheckPanelLayout = BoxLayout::create(); RightPanelCheckPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); RightPanelCheckPanelLayout->setMinorAxisAlignment(0.5f); // Create Panel Border LineBorderRecPtr PanelBorder3 = LineBorder::create(); PanelBorder3->setColor(Color4f(0.0,0.0,0.0,1.0)); PanelBorder3->setWidth(1); // Create and edit Panel PanelRecPtr RightPanelCheckPanel = Panel::createEmpty(); RightPanelCheckPanel->setPreferredSize(Vec2f(200, 300)); RightPanelCheckPanel->pushToChildren(RightPanelCheck1); RightPanelCheckPanel->pushToChildren(RightPanelCheck2); RightPanelCheckPanel->pushToChildren(RightPanelCheck3); RightPanelCheckPanel->pushToChildren(RightPanelCheck4); RightPanelCheckPanel->setLayout(RightPanelCheckPanelLayout); RightPanelCheckPanel->setBackgrounds(RightPanelCheckPanelBackground); RightPanelCheckPanel->setBorders(PanelBorder3); return PanelTransitPtr(RightPanelCheckPanel); }
PanelTransitPtr createLeftPanelButtonPanel(void) { // Create Label for this Panel LabelRecPtr LeftPanelButtonPanelLabel = Label::create(); LeftPanelButtonPanelLabel->setTextColor(Color4f(1.0,1.0,1.0,1.0)); LeftPanelButtonPanelLabel->setRolloverTextColor(Color4f(1.0,1.0,1.0,1.0)); LayerRecPtr ComplexBackground = createComplexBackground(); LeftPanelButtonPanelLabel->setBackground(ComplexBackground); LeftPanelButtonPanelLabel->setPreferredSize(Vec2f(100, 50)); LeftPanelButtonPanelLabel->setText("Various Options"); LeftPanelButtonPanelLabel->setAlignment(Vec2f(0.5,0.5)); // Create and edit the Panel buttons ButtonRecPtr LeftPanelButton1 = Button::create(); ButtonRecPtr LeftPanelButton2 = Button::create(); ButtonRecPtr LeftPanelButton3 = Button::create(); ButtonRecPtr LeftPanelButton4 = Button::create(); ButtonRecPtr LeftPanelButton5 = Button::create(); ButtonRecPtr LeftPanelButton6 = Button::create(); LeftPanelButton1->setText("This"); LeftPanelButton1->setPreferredSize(Vec2f(100,50)); LeftPanelButton2->setText("is"); LeftPanelButton2->setPreferredSize(Vec2f(100,50)); LeftPanelButton3->setText("an"); LeftPanelButton3->setPreferredSize(Vec2f(100,50)); LeftPanelButton4->setText("example"); LeftPanelButton4->setPreferredSize(Vec2f(100,50)); LeftPanelButton5->setText("user"); LeftPanelButton5->setPreferredSize(Vec2f(100,50)); LeftPanelButton6->setText("interface."); LeftPanelButton6->setPreferredSize(Vec2f(100,50)); // Create and edit Panel layout BoxLayoutRecPtr LeftPanelButtonPanelLayout = BoxLayout::create(); LeftPanelButtonPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); // Create an edit Panel Background ColorLayerRecPtr LeftPanelButtonPanelBackground = ColorLayer::create(); LeftPanelButtonPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0)); // Create Panel Border LineBorderRecPtr LeftPanelBorder = LineBorder::create(); LeftPanelBorder->setColor(Color4f(0.0,0.0,0.0,1.0)); LeftPanelBorder->setWidth(1); // Create and edit Panel PanelRecPtr LeftPanelButtonPanel = Panel::createEmpty(); LeftPanelButtonPanel->setPreferredSize(Vec2f(180, 500)); LeftPanelButtonPanel->pushToChildren(LeftPanelButtonPanelLabel); LeftPanelButtonPanel->pushToChildren(LeftPanelButton1); LeftPanelButtonPanel->pushToChildren(LeftPanelButton2); LeftPanelButtonPanel->pushToChildren(LeftPanelButton3); LeftPanelButtonPanel->pushToChildren(LeftPanelButton4); LeftPanelButtonPanel->pushToChildren(LeftPanelButton5); LeftPanelButtonPanel->pushToChildren(LeftPanelButton6); LeftPanelButtonPanel->setLayout(LeftPanelButtonPanelLayout); LeftPanelButtonPanel->setBackgrounds(LeftPanelButtonPanelBackground); LeftPanelButtonPanel->setBorders(LeftPanelBorder); return PanelTransitPtr(LeftPanelButtonPanel); }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); TutorialWindow->connectMousePressed(boost::bind(mousePressed, _1, &sceneManager)); TutorialWindow->connectMouseReleased(boost::bind(mouseReleased, _1, &sceneManager)); TutorialWindow->connectMouseDragged(boost::bind(mouseDragged, _1, &sceneManager)); TutorialWindow->connectMouseWheelMoved(boost::bind(mouseWheelMoved, _1, &sceneManager)); TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1)); // Make Main Scene Node NodeRecPtr Scene = makeCoredNode<Group>(); NodeRecPtr TorusNode = createTorus(); NodeRecPtr SphereNode = createSphere(); NodeRecPtr ConeNode = createCone(); NodeRecPtr BoxNode = createBox(); Scene->addChild(TorusNode); Scene->addChild(SphereNode); Scene->addChild(ConeNode); Scene->addChild(BoxNode); // Create the Graphics GraphicsRecPtr TutorialGraphics = Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); /****************************************************** Create a Background ******************************************************/ ColorLayerRecPtr GreyBackground = ColorLayer::create(); GreyBackground->setColor(Color4f(.93,.93,.93,1.0)); /****************************************************** Create some Borders ******************************************************/ LineBorderRecPtr PanelBorder = LineBorder::create(); EmptyBorderRecPtr Panel1Border = EmptyBorder::create(); EmptyBorderRecPtr Panel2Border = EmptyBorder::create(); EmptyBorderRecPtr emptyBorder = EmptyBorder::create(); PanelBorder->setColor(Color4f(0.0,0.0,0.0,1.0)); PanelBorder->setWidth(1); Panel1Border->setTopWidth(0); Panel1Border->setBottomWidth(6); Panel1Border->setLeftWidth(0); Panel1Border->setRightWidth(0); Panel2Border->setTopWidth(0); Panel2Border->setBottomWidth(0); Panel2Border->setLeftWidth(0); Panel2Border->setRightWidth(0); /****************************************************** Create some Labels and stuff to go with them ******************************************************/ LabelRecPtr LeftPanelLabel1 = Label::create(); UIFontRecPtr LeftPanelLabel1Font = UIFont::create(); LeftPanelLabel1Font->setSize(50); LeftPanelLabel1->setBorders(emptyBorder); LeftPanelLabel1->setBackgrounds(GreyBackground); LeftPanelLabel1->setFont(LeftPanelLabel1Font); LeftPanelLabel1->setText("OSG Gui"); LeftPanelLabel1->setPreferredSize(Vec2f(300, 100)); LeftPanelLabel1->setAlignment(Vec2f(0.0f, 0.5f)); /****************************************************** Create some Layouts ******************************************************/ BoxLayoutRecPtr MainInternalWindowLayout = BoxLayout::create(); FlowLayoutRecPtr LeftPanelLayout = FlowLayout::create(); BoxLayoutRecPtr RightPanelLayout = BoxLayout::create(); MainInternalWindowLayout->setOrientation(BoxLayout::HORIZONTAL_ORIENTATION); LeftPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION); LeftPanelLayout->setMinorAxisAlignment(1.0f); RightPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); /****************************************************** Create MainFrame and Panels ******************************************************/ PanelRecPtr LeftPanel = Panel::createEmpty(); PanelRecPtr RightPanel = Panel::createEmpty(); // LeftPanel stuff LeftPanel->setPreferredSize(Vec2f(400, 500)); LeftPanel->pushToChildren(LeftPanelLabel1); PanelRecPtr LeftPanelButtonPanel = createLeftPanelButtonPanel(); LeftPanel->pushToChildren(LeftPanelButtonPanel); PanelRecPtr LeftPanelRadioTextPanel = createLeftPanelRadioTextPanel(); LeftPanel->pushToChildren(LeftPanelRadioTextPanel); LeftPanel->setLayout(LeftPanelLayout); LeftPanel->setBackgrounds(GreyBackground); LeftPanel->setBorders(Panel1Border); //RightPanel stuff RightPanel->setPreferredSize(Vec2f(200, 620)); PanelRecPtr RightPanelButtonPanel = createRightPanelButtonPanel(); RightPanel->pushToChildren(RightPanelButtonPanel); PanelRecPtr RightPanelCheckPanel = createRightPanelCheckPanel(TorusNode, SphereNode, ConeNode, BoxNode); RightPanel->pushToChildren(RightPanelCheckPanel); RightPanel->setLayout(RightPanelLayout); RightPanel->setBackgrounds(GreyBackground); RightPanel->setBorders(Panel2Border); // Create The Main InternalWindow InternalWindowRecPtr MainInternalWindow = InternalWindow::create(); MainInternalWindow->pushToChildren(LeftPanel); MainInternalWindow->pushToChildren(RightPanel); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(GreyBackground); MainInternalWindow->setBorders(PanelBorder); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); //MainInternalWindow->setOpacity(0.7f); // Create the Drawing Surface UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Make A 3D Rectangle to draw the UI on UIRectangleRecPtr UIRectCore = UIRectangle::create(); UIRectCore->setPoint(Pnt3f(-310.0,-310.0,370.0)); UIRectCore->setWidth(620); UIRectCore->setHeight(620); UIRectCore->setDrawingSurface(TutorialDrawingSurface); NodeRecPtr UIRectNode = Node::create(); UIRectNode->setCore(UIRectCore); // add the UIRect as a child Scene->addChild(UIRectNode); sceneManager.setRoot(Scene); // Show the whole Scene sceneManager.showAll(); //Create the Documentation Foreground and add it to the viewport SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "21ExampleInterface"); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1)); // Make Torus Node (creates Torus in background of scene) NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodeRecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(TorusGeometryNode); // Create the Graphics GraphicsRecPtr TutorialGraphics = Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); /****************************************************** Create some Button Components ******************************************************/ ButtonRecPtr ExampleButton1 = Button::create(); ButtonRecPtr ExampleButton2 = Button::create(); ButtonRecPtr ExampleButton3 = Button::create(); ButtonRecPtr ExampleButton4 = Button::create(); /****************************************************** Create Box Layout. Box Layout arranges objects automatically within the Frame, so that the objects are evenly spaced within the Frame. Box Layout also causes all objects to have the same height (if arranged Horizontally) or the same width (if arranged Vertically) using the maximum width of the objects in the Layout. This overrides the specified dimensions of the object, unless the object has a Maximum or Minimum size set. In this case, the object size cannot be changed to greater than the Maximum size, or less than the Minimum size (it will still be changed, however it will not exceed the Max/Min size). You can experiment with this by changing the window size, changing the size of the Buttons as shown in 01Button, editing the Buttons, or adding more Buttons to the view. Note that if the Frame is too small, the objects will appear out of the Frame background. -setOrientation(ENUM): Determine alignment of Layout. Takes VERTICAL_ORIENTATION and HORIZONTAL_ORIENTATION arguments. ******************************************************/ BoxLayoutRecPtr MainInternalWindowLayout = BoxLayout::create(); MainInternalWindowLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); //Make the swap to see what happens Between Vertical and Horizontal! //MainInternalWindowLayout->setOrientation(BoxLayout::HORIZONTAL_ORIENTATION); /****************************************************** Edit some of the Button Components. Because of how BoxLayout works, by setting a MaxSize, even though other Buttons within the Layout will be resized, ExampleButton1 cannot be larger than Vec2f(50,50). The default size for all Buttons is Vec2f(100,50) [see DefaultLookAndFeel.cpp], but because ExampleButton2 is larger, each of the other Buttons will be resized to match ExampleButton2's larger size. Experiment by commenting out either line and observing the results. ******************************************************/ ExampleButton1->setPreferredSize(Vec2f(50,50)); ExampleButton1->setMaxSize(Vec2f(50, 50)); //The max size determines how large this button can be even though the BoxLayout says otherwise.(comment out to see the difference) ExampleButton2->setPreferredSize(Vec2f(200,100)); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); InternalWindowRecPtr MainInternalWindow = InternalWindow::create(); MainInternalWindow->pushToChildren(ExampleButton1); MainInternalWindow->pushToChildren(ExampleButton2); MainInternalWindow->pushToChildren(ExampleButton3); MainInternalWindow->pushToChildren(ExampleButton4); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); // Create the Drawing Surface UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRecPtr TutorialUIForeground = UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); // Tell the Manager what to manage sceneManager.setRoot(scene); // Add the UI Foreground Object to the Scene ViewportRecPtr TutorialViewport = sceneManager.getWindow()->getPort(0); TutorialViewport->addForeground(TutorialUIForeground); // Show the whole Scene sceneManager.showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "06BoxLayout"); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
InternalWindowTransitPtr createMainInternalWindow(void) { /****************************************************** Create Button Components to be used with TabPanel and specify their characteristics. Note: Buttons are used for simplicity, any Component can be used as Tab content or as a Tab. A Panel with several Buttons within it is also added. ******************************************************/ ButtonRecPtr ExampleTabButton1 = Button::create(); ButtonRecPtr ExampleTabButton2 = Button::create(); ButtonRecPtr ExampleTabButton3 = Button::create(); ButtonRecPtr ExampleTabButton4 = Button::create(); ButtonRecPtr ExampleTabButton5 = Button::create(); ButtonRecPtr ExampleTabButton6 = Button::create(); ButtonRecPtr ExampleTabContentA = Button::create(); ButtonRecPtr ExampleTabContentB = Button::create(); ButtonRecPtr ExampleTabContentC = Button::create(); ButtonRecPtr ExampleTabContentD = Button::create(); ButtonRecPtr ExampleTabContentE = Button::create(); ButtonRecPtr ExampleTabContentF = Button::create(); ExampleTabButton1->setText("Tab1"); ExampleTabButton2->setText("Tab2"); ExampleTabButton3->setText("To Rotate"); ExampleTabButton4->setText("Tab4"); ExampleTabButton5->setText("To Zoom"); ExampleTabButton6->setText("To Move"); ExampleTabContentA->setText("Add another Tab"); ExampleTabContentB->setText("Add a Tab in Tab1!"); ExampleTabContentC->setText("Enable CapsLock, then rotate scene using left Mouse button!"); ExampleTabContentD->setText("Enable CapsLock, then zoom in and out with right Mouse button and dragging"); ExampleTabContentE->setText("Enable CapsLock, then move using center Mouse button"); /****************************************************** Create a Panel to add to the TabPanel ******************************************************/ // Create and edit the Panel Buttons ButtonRecPtr ExampleTabPanelButton1 = Button::create(); ButtonRecPtr ExampleTabPanelButton2 = Button::create(); ButtonRecPtr ExampleTabPanelButton3 = Button::create(); ButtonRecPtr ExampleTabPanelButton4 = Button::create(); ButtonRecPtr ExampleTabPanelButton5 = Button::create(); ButtonRecPtr ExampleTabPanelButton6 = Button::create(); ExampleTabPanelButton1->setText("This is a"); ExampleTabPanelButton2->setText("sample"); ExampleTabPanelButton3->setText("UIRectangle"); ExampleTabPanelButton4->setText("containing"); ExampleTabPanelButton5->setText("interactive"); ExampleTabPanelButton6->setText("components"); // Create and edit Panel Layout BoxLayoutRecPtr TabPanelLayout = BoxLayout::create(); TabPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION); // Create and edit Panel PanelRecPtr ExampleTabPanelPanel = Panel::create(); ExampleTabPanelPanel->setPreferredSize(Vec2f(180, 500)); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton1); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton2); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton3); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton4); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton5); ExampleTabPanelPanel->pushToChildren(ExampleTabPanelButton6); ExampleTabPanelPanel->setLayout(TabPanelLayout); TabPanelRecPtr ExampleTabPanel = TabPanel::create(); ExampleTabPanel->setPreferredSize(Vec2f(350,350)); ExampleTabPanel->addTab(ExampleTabButton1, ExampleTabContentA); ExampleTabPanel->addTab(ExampleTabButton2, ExampleTabContentB); ExampleTabPanel->addTab(ExampleTabButton3, ExampleTabContentC); ExampleTabPanel->addTab(ExampleTabButton4, ExampleTabPanelPanel); ExampleTabPanel->addTab(ExampleTabButton5, ExampleTabContentD); ExampleTabPanel->addTab(ExampleTabButton6, ExampleTabContentE); ExampleTabPanel->setTabAlignment(0.5f); ExampleTabPanel->setTabPlacement(TabPanel::PLACEMENT_SOUTH); ExampleTabPanel->setSelectedIndex(3); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); CardLayoutRecPtr MainInternalWindowLayout = CardLayout::create(); InternalWindowRecPtr MainInternalWindow = InternalWindow::create(); MainInternalWindow->pushToChildren(ExampleTabPanel); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); ExampleTabContentB->connectActionPerformed(boost::bind(handleRemoveTabAction, _1, ExampleTabPanel.get(), ExampleTabContentA.get(), ExampleTabContentB.get())); ExampleTabContentA->connectActionPerformed(boost::bind(handleAddTabAction, _1, ExampleTabPanel.get(), ExampleTabContentA.get(), ExampleTabContentB.get())); return InternalWindowTransitPtr(MainInternalWindow); }