int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create(); 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(); /****************************************************** Creates RadioButton components and edit them. The RadioButton class inherits from the Button class. Radio Buttons are special ToggleButtons. When they are selected, any RadioButton in the same group is deselected, so there can only be one option selected. Advanced options for RadioButton can be found in the DefaultLookAndFeel.cpp file found in OSGUserInterface/Source Files/ LookAndFeel (options for changing the RadioButton style, etc). ******************************************************/ RadioButtonRecPtr ExampleRadioButton1 = RadioButton::create(); RadioButtonRecPtr ExampleRadioButton2 = RadioButton::create(); RadioButtonRecPtr ExampleRadioButton3 = RadioButton::create(); ExampleRadioButton1->setAlignment(Vec2f(0.0,0.5)); ExampleRadioButton1->setPreferredSize(Vec2f(100, 50)); ExampleRadioButton1->setText("Option 1"); ExampleRadioButton2->setAlignment(Vec2f(0.0,0.5)); ExampleRadioButton2->setPreferredSize(Vec2f(100, 50)); ExampleRadioButton2->setText("Option 2"); ExampleRadioButton3->setAlignment(Vec2f(0.0,0.5)); ExampleRadioButton3->setPreferredSize(Vec2f(100, 50)); ExampleRadioButton3->setText("Option 3"); /*************************************************** Create and populate a group of RadioButtons. Defining the group allows you to pick which RadioButtons are tied together so that only one can be selected. Each RadioButtonGroup can only have ONE RadioButton selected at a time, and by selecting this RadioButton, will deselect all other RadioButtons in the RadioButtonGroup. ******************************************************/ RadioButtonGroupRecPtr ExampleRadioButtonGroup = RadioButtonGroup::create(); ExampleRadioButtonGroup->addButton(ExampleRadioButton1); ExampleRadioButtonGroup->addButton(ExampleRadioButton2); ExampleRadioButtonGroup->addButton(ExampleRadioButton3); ExampleRadioButtonGroup->setSelectedButton(ExampleRadioButton2); FlowLayoutRecPtr MainInternalWindowLayout = FlowLayout::create(); MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION); MainInternalWindowLayout->setMajorAxisAlignment(0.5f); MainInternalWindowLayout->setMinorAxisAlignment(0.5f); // 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(ExampleRadioButton1); MainInternalWindow->pushToChildren(ExampleRadioButton2); MainInternalWindow->pushToChildren(ExampleRadioButton3); 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); //Create the Documentation Foreground and add it to the viewport SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow); // 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, "14RadioButton"); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
void LuaDebuggerInterface::createExecutionToolbar(void) { //Execute Button BoostPath ExecuteIconPath(_BaseIconDir / BoostPath("execute.png")); BoostPath ExecuteDisabledIconPath(_BaseIconDir / BoostPath("execute-disabled.png")); _ExecuteButton = Button::create(); _ExecuteButton->setPreferredSize(_ToolButtonSize); _ExecuteButton->setImages(ExecuteIconPath.string()); _ExecuteButton->setDisabledImage(ExecuteDisabledIconPath.string()); _ExecuteButton->setAlignment(Vec2f(0.5f,0.5f)); _ExecuteButton->setToolTipText("Execute"); _ExecuteButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::executeScriptButtonAction,this)); //Step Into Button BoostPath StepInIconPath(_BaseIconDir / BoostPath("basicstepinto.png")); BoostPath StepInDisabledIconPath(_BaseIconDir / BoostPath("basicstepinto-disabled.png")); _StepInButton = Button::create(); _StepInButton->setPreferredSize(_ToolButtonSize); _StepInButton->setImages(StepInIconPath.string()); _StepInButton->setDisabledImage(StepInDisabledIconPath.string()); _StepInButton->setAlignment(Vec2f(0.5f,0.5f)); _StepInButton->setToolTipText("Step In"); //Step Out Button BoostPath StepOutIconPath(_BaseIconDir / BoostPath("basicstepout.png")); BoostPath StepOutDisabledIconPath(_BaseIconDir / BoostPath("basicstepout-disabled.png")); _StepOutButton = Button::create(); _StepOutButton->setPreferredSize(_ToolButtonSize); _StepOutButton->setImages(StepOutIconPath.string()); _StepOutButton->setDisabledImage(StepOutDisabledIconPath.string()); _StepOutButton->setAlignment(Vec2f(0.5f,0.5f)); _StepOutButton->setToolTipText("Step Out"); //Step Over Button BoostPath StepOverIconPath(_BaseIconDir / BoostPath("basicstepover.png")); BoostPath StepOverDisabledIconPath(_BaseIconDir / BoostPath("basicstepover-disabled.png")); _StepOverButton = Button::create(); _StepOverButton->setPreferredSize(_ToolButtonSize); _StepOverButton->setImages(StepOverIconPath.string()); _StepOverButton->setDisabledImage(StepOverDisabledIconPath.string()); _StepOverButton->setAlignment(Vec2f(0.5f,0.5f)); _StepOverButton->setToolTipText("Step Over"); //Stop Button BoostPath StopExecutionIconPath(_BaseIconDir / BoostPath("stop.png")); BoostPath StopExecutionDisabledIconPath(_BaseIconDir / BoostPath("stop-disabled.png")); _StopExecutionButton = Button::create(); _StopExecutionButton->setPreferredSize(_ToolButtonSize); _StopExecutionButton->setImages(StopExecutionIconPath.string()); _StopExecutionButton->setDisabledImage(StopExecutionDisabledIconPath.string()); _StopExecutionButton->setAlignment(Vec2f(0.5f,0.5f)); _StopExecutionButton->setToolTipText("Stop"); //Code Execution Toolbar //Layout FlowLayoutRecPtr ToolbarLayout = FlowLayout::create(); ToolbarLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION); ToolbarLayout->setHorizontalGap(3.0f); ToolbarLayout->setMajorAxisAlignment(0.0f); ToolbarLayout->setMinorAxisAlignment(0.5); _CodeExecutionToolbar = Panel::createEmpty(); _CodeExecutionToolbar->setPreferredSize(Vec2f(45.0f, 45.0f)); _CodeExecutionToolbar->setLayout(ToolbarLayout); _CodeExecutionToolbar->pushToChildren(_ExecuteButton); _CodeExecutionToolbar->pushToChildren(_StopExecutionButton); _CodeExecutionToolbar->pushToChildren(_StepOverButton); _CodeExecutionToolbar->pushToChildren(_StepInButton); _CodeExecutionToolbar->pushToChildren(_StepOutButton); updateExecutionToolbar(); }