OSG_BEGIN_NAMESPACE DialogWindowTransitPtr createFCEditorDialog(FieldContainer* fc, CommandManagerPtr CmdManager, const std::string& editorName) { DialogWindowRefPtr TheDialog = DialogWindow::create(); //Create the FieldEditorComponent FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(fc, CmdManager); ScrollPanelRefPtr EditorScrollPanel = ScrollPanel::create(); EditorScrollPanel->setPreferredSize(Vec2f(300,400)); EditorScrollPanel->setViewComponent(TheEditor); //Ok button ButtonRefPtr ConfirmButton = Button::create(); ConfirmButton->setText("Ok"); ConfirmButton->connectActionPerformed(boost::bind(&DialogWindow::handleConfirmButtonAction, TheDialog.get(), _1)); SpringLayoutRefPtr DialogLayout = OSG::SpringLayout::create(); //EditorScrollPanel DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, EditorScrollPanel, 2, SpringLayoutConstraints::NORTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, EditorScrollPanel, -15, SpringLayoutConstraints::NORTH_EDGE, ConfirmButton); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, EditorScrollPanel, 1, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, EditorScrollPanel, 2, SpringLayoutConstraints::WEST_EDGE, TheDialog); //ConfirmButton DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ConfirmButton, -15, SpringLayoutConstraints::SOUTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, ConfirmButton, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, TheDialog); TheDialog->setLayout(DialogLayout); TheDialog->setPreferredSize(Vec2f(330.0f, 475.0f)); TheDialog->pushToChildren(EditorScrollPanel); TheDialog->pushToChildren(ConfirmButton); return DialogWindowTransitPtr(TheDialog); }
void LuaDebuggerInterface::createEditorToolbar(void) { BoostPath OpenIconPath(_BaseIconDir / BoostPath("open.png")); ButtonRefPtr OpenButton = Button::create(); OpenButton->setToolTipText("Open"); OpenButton->setPreferredSize(_ToolButtonSize); OpenButton->setImages(OpenIconPath.string()); setName(OpenButton,"Open Button"); OpenButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::openScriptButtonAction,this)); BoostPath SaveIconPath(_BaseIconDir / BoostPath("Save.png")); ButtonRefPtr SaveButton = Button::create(); SaveButton->setPreferredSize(_ToolButtonSize); SaveButton->setToolTipText("Save"); setName(SaveButton,"Save Button"); SaveButton->setImages(SaveIconPath.string()); SaveButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::saveScriptButtonAction,this)); BoostPath ClearIconPath(_BaseIconDir / BoostPath("clear.png")); ButtonRefPtr ClearButton = Button::create(); ClearButton->setPreferredSize(_ToolButtonSize); ClearButton->setToolTipText("Clear"); setName(ClearButton,"Clear Button"); ClearButton->setImages(ClearIconPath.string()); ClearButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::clearScriptButtonAction,this)); BoostPath SplitHorzIconPath(_BaseIconDir / BoostPath("view-split-left-right.png")); BoostPath SplitVertIconPath(_BaseIconDir / BoostPath("view-split-top-bottom.png")); BoostPath SplitNoneIconPath(_BaseIconDir / BoostPath("view-split-none.png")); //Split Options Component Generator FunctorListComponentGeneratorRecPtr SplitOptionsCompGenerator = FunctorListComponentGenerator::create(); SplitOptionsCompGenerator->setGenerateFunction(boost::bind(&LuaDebuggerInterface::generateSplitOptionListComponent, this, _1, _2, _3, _4, _5)); //Split Options List Model DefaultListModelRecPtr SplitOptionsListModel = DefaultListModel::create(); SplitOptionsListModel->pushBack(boost::any(std::string("None"))); SplitOptionsListModel->pushBack(boost::any(std::string("Horizontal"))); SplitOptionsListModel->pushBack(boost::any(std::string("Vertical"))); _SplitButton = MenuButton::create(); _SplitButton->setToolTipText("Split Options"); _SplitButton->setPreferredSize(_ToolButtonSize); _SplitButton->setImages(SplitNoneIconPath.string()); _SplitButton->setModel(SplitOptionsListModel); _SplitButton->setCellGenerator(SplitOptionsCompGenerator); setName(_SplitButton,"Split Button"); _SplitButton->connectMenuActionPerformed(boost::bind(&LuaDebuggerInterface::handleSplitMenuAction, this, _1)); //Make the Button Panel FlowLayoutRefPtr ButtonPanelLayout = FlowLayout::create(); ButtonPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION); ButtonPanelLayout->setHorizontalGap(3.0f); ButtonPanelLayout->setMajorAxisAlignment(0.0f); ButtonPanelLayout->setMinorAxisAlignment(0.5); _EditorButtonPanel = Panel::createEmpty(); _EditorButtonPanel->setPreferredSize(Vec2f(200.0f, 45.0f)); _EditorButtonPanel->pushToChildren(OpenButton); _EditorButtonPanel->pushToChildren(SaveButton); _EditorButtonPanel->pushToChildren(ClearButton); _EditorButtonPanel->pushToChildren(_SplitButton); _EditorButtonPanel->setLayout(ButtonPanelLayout); setName(_EditorButtonPanel,"Button Panel"); }
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)); TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); // Make Torus Node (creates Torus in background of scene) NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodeRefPtr scene = OSG::Node::create(); scene->setCore(OSG::Group::create()); scene->addChild(TorusGeometryNode); // Create the Graphics GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); /****************************************************** Create an Button Component and a simple Font. See 17Label_Font for more information about Fonts. ******************************************************/ ButtonRefPtr ExampleButton = OSG::Button::create(); UIFontRefPtr ExampleFont = OSG::UIFont::create(); ExampleFont->setSize(16); /****************************************************** Edit the Button's characteristics. Note: the first 4 functions can be used with any Component and are not specific to Button. -setMinSize(Vec2f): Determine the Minimum Size of the Component. Some Layouts will automatically resize Components; this prevents the Size from going below a certain value. -setMaxSize(Vec2f): Determine the Maximum Size of the Component. -setPreferredSize(Vec2f): Determine the Preferred Size of the Component. This is what the Component will be displayed at unless changed by another Component (such as a Layout). -setToolTipText("Text"): Determine what text is displayed while Mouse is hovering above Component. The word Text will be displayed in this case. Functions specfic to Button: -setText("DesiredText"): Determine the Button's text. It will read DesiredText in this case. -setFont(FontName): Determine the Font to be used on the Button. -setTextColor(Color4f): Determine the Color for the text. -setRolloverTextColor(Color4f): Determine what the text Color will be when the Mouse Cursor is above the Button. -setActiveTextColor(Color4f): Determine what the text Color will be when the Button is pressed (denoted by Active). -setAlignment(Vec2f): Determine the Vertical Alignment of the text. The value is in [0.0, 1.0]. ******************************************************/ ExampleButton->setMinSize(Vec2f(50, 25)); ExampleButton->setMaxSize(Vec2f(200, 100)); ExampleButton->setPreferredSize(Vec2f(100, 50)); ExampleButton->setToolTipText("Button 1 ToolTip"); ExampleButton->setText("Button 1"); ExampleButton->setFont(ExampleFont); ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0)); ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0)); ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0)); ExampleButton->setAlignment(Vec2f(1.0,0.0)); // Create an Action and assign it to ExampleButton // This Class is defined above, and will cause the output // window to display "Button 1 Action" when pressed ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1)); /****************************************************** Create a ToggleButton and determine its characteristics. ToggleButton inherits off of Button, so all characteristsics used above can be used with ToggleButtons as well. The only difference is that when pressed, ToggleButton remains pressed until pressed again. -setSelected(bool): Determine whether the ToggleButton is Selected (true) or deselected (false). ******************************************************/ ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create(); ExampleToggleButton->setSelected(false); ExampleToggleButton->setText("ToggleMe"); ExampleToggleButton->setToolTipText("Toggle Button ToolTip"); //Button with Image ButtonRefPtr ExampleDrawObjectButton = OSG::Button::create(); ExampleDrawObjectButton->setDrawObjectToTextAlignment(Button::ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT); ExampleDrawObjectButton->setText("Icon"); ExampleDrawObjectButton->setImage(std::string("./Data/Icon.png")); ExampleDrawObjectButton->setActiveImage(std::string("./Data/Icon.png")); ExampleDrawObjectButton->setFocusedImage(std::string("./Data/Icon.png")); ExampleDrawObjectButton->setRolloverImage(std::string("./Data/Icon.png")); ExampleDrawObjectButton->setDisabledImage(std::string("./Data/Icon.png")); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create(); LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create(); MainInternalWindow->pushToChildren(ExampleButton); MainInternalWindow->pushToChildren(ExampleToggleButton); MainInternalWindow->pushToChildren(ExampleDrawObjectButton); 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 UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); sceneManager.setRoot(scene); // Add the UI Foreground Object to the Scene ViewportRefPtr 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(); //Attach key controls //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "01Button"); commitChanges(); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
DialogWindowTransitPtr createFCTreeEditorDialog (FieldContainer* fc, CommandManagerPtr CmdManager, const std::string& editorName) { DialogWindowRefPtr TheDialog = DialogWindow::create(); //Create the FieldEditorComponent FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(fc, CmdManager); ScrollPanelRefPtr EditorScrollPanel = ScrollPanel::create(); EditorScrollPanel->setViewComponent(TheEditor); //Field Container Tree Model FieldContainerTreeModelRefPtr TheTreeModel = FieldContainerTreeModel::create(); TheTreeModel->setRoot(fc); TheTreeModel->setShowInternalFields(true); TheTreeModel->setShowPtrFields(true); TheTreeModel->setShowDataFields(false); TheTreeModel->setShowParentPtrFields(false); TheTreeModel->setShowChildPtrFields(true); TheTreeModel->setShowAttachments(true); TheTreeModel->setShowCallbackFunctors(false); //Field Container Tree Component Generator FieldContainerFieldPathComponentGeneratorRefPtr TheTreeComponentGenerator = FieldContainerFieldPathComponentGenerator::create(); //Create the PopupMenu for the tree MenuItemRecPtr ExportMenuItem = MenuItem::create(); ExportMenuItem->setText("Export ..."); MenuItemRecPtr ImportMenuItem = MenuItem::create(); ImportMenuItem->setText("Import ..."); PopupMenuRecPtr TreePopupMenu = PopupMenu::create(); TreePopupMenu->addItem(ExportMenuItem); TreePopupMenu->addItem(ImportMenuItem); //Create the Field Container Tree TreeRefPtr TheTree = Tree::create(); TheTree->setPreferredSize(Vec2f(100, 500)); TheTree->setRootVisible(true); TheTree->setModel(TheTreeModel); TheTree->setCellGenerator(TheTreeComponentGenerator); TheTree->setPopupMenu(TreePopupMenu); TheTree->getSelectionModel()->connectSelectionAdded(boost::bind(&handleFCSelectionAdded, _1, TheTree.get(), EditorScrollPanel.get())); ExportMenuItem->connectActionPerformed(boost::bind(&handleTreeNodeExport, _1, TheTree.get())); ImportMenuItem->connectActionPerformed(boost::bind(&handleTreeNodeImport, _1, TheTree.get())); //TheDialog->addTransientObject(boost::any(TheTreeEditorSelectionListener)); ScrollPanelRefPtr TreeScrollPanel = ScrollPanel::create(); TreeScrollPanel->setViewComponent(TheTree); //Ok button ButtonRefPtr ConfirmButton = Button::create(); ConfirmButton->setText("Ok"); ConfirmButton->connectActionPerformed(boost::bind(&DialogWindow::handleConfirmButtonAction, TheDialog.get(), _1)); SpringLayoutRefPtr DialogLayout = OSG::SpringLayout::create(); //SplitPanel SplitPanelRefPtr TheSplitPanel = SplitPanel::create(); TheSplitPanel->setOrientation(SplitPanel::HORIZONTAL_ORIENTATION); TheSplitPanel->setDividerPosition(0.4f); TheSplitPanel->setDividerSize(5.0f); TheSplitPanel->setMaxDividerPosition(0.8f); TheSplitPanel->setMinDividerPosition(0.2f); TheSplitPanel->setMinComponent(TreeScrollPanel); TheSplitPanel->setMaxComponent(EditorScrollPanel); //TreeScrollPanel DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheSplitPanel, 2, SpringLayoutConstraints::NORTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TheSplitPanel, -15, SpringLayoutConstraints::NORTH_EDGE, ConfirmButton); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TheSplitPanel, -2, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheSplitPanel, 2, SpringLayoutConstraints::WEST_EDGE, TheDialog); //ConfirmButton DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ConfirmButton, -15, SpringLayoutConstraints::SOUTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, ConfirmButton, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, TheDialog); TheDialog->setLayout(DialogLayout); TheDialog->setPreferredSize(Vec2f(750.0f, 600.0f)); TheDialog->pushToChildren(TheSplitPanel); TheDialog->pushToChildren(ConfirmButton); return DialogWindowTransitPtr(TheDialog); }
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(keyTyped, _1)); // Make Torus Node (creates Torus in background of scene) NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodeRefPtr scene = OSG::Node::create(); scene->setCore(OSG::Group::create()); scene->addChild(TorusGeometryNode); // Create the Graphics GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); ButtonRefPtr ExampleButton = OSG::Button::create(); ExampleButton->setMinSize(Vec2f(50, 25)); ExampleButton->setMaxSize(Vec2f(200, 100)); ExampleButton->setPreferredSize(Vec2f(100, 50)); ExampleButton->setText("Button 1"); // Create an ActionListener and assign it to ExampleButton // This Class is defined above, and will cause the output // window to display "Button 1 Action" when pressed ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1)); //Toggle Button ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create(); ExampleToggleButton->setSelected(false); ExampleToggleButton->setText("ToggleMe"); //Text Field TextFieldRefPtr ExampleTextField = OSG::TextField::create(); //Password Field PasswordFieldRefPtr ExamplePasswordField = OSG::PasswordField::create(); LayoutRefPtr MainLayout = OSG::FlowLayout::create(); //Panel PanelRecPtr ExamplePanel = Panel::create(); ExamplePanel->setPreferredSize(Vec2f(200.0f,200.0f)); ExamplePanel->setLayout(MainLayout); ExamplePanel->pushToChildren(ExampleTextField); ExamplePanel->pushToChildren(ExamplePasswordField); //Text Field 2 TextFieldRefPtr ExampleTextField2 = OSG::TextField::create(); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create(); MainInternalWindow->pushToChildren(ExampleButton); MainInternalWindow->pushToChildren(ExampleToggleButton); MainInternalWindow->pushToChildren(ExamplePanel); MainInternalWindow->pushToChildren(ExampleTextField2); MainInternalWindow->setLayout(MainLayout); 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 UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); sceneManager.setRoot(scene); // Add the UI Foreground Object to the Scene ViewportRefPtr 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.5f); TutorialWindow->openWindow(WinPos, WinSize, "54FocusProgession"); commitChanges(); //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); // Make Torus Node (creates Torus in background of scene) NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodeRefPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(TorusGeometryNode); // Create the Graphics GraphicsRefPtr TutorialGraphics = Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); TextEditorRefPtr theTextEditor = TextEditor::create(); theTextEditor->setPreferredSize(Vec2f(1000,700)); theTextEditor->setIsSplit(false); theTextEditor->setClipboardVisible(false); //Toggle Button for clipboard ToggleButtonRefPtr ClipboardButton = ToggleButton::create(); ClipboardButton->setPreferredSize(Vec2f(80, 40)); ClipboardButton->setText("Clipboard"); ClipboardButton->connectButtonSelected(boost::bind(handleClipboardSelected, _1, theTextEditor.get())); ClipboardButton->connectButtonDeselected(boost::bind(handleClipboardDeselected, _1, theTextEditor.get())); //Toggle Button for split panel ToggleButtonRefPtr SplitButton = ToggleButton::create(); SplitButton->setPreferredSize(Vec2f(80, 40)); SplitButton->setText("Split"); SplitButton->connectButtonSelected(boost::bind(handleSplitSelected, _1, theTextEditor.get())); SplitButton->connectButtonDeselected(boost::bind(handleSplitDeselected, _1, theTextEditor.get())); ButtonRefPtr LoadButton = Button::create(); LoadButton->setMinSize(Vec2f(50, 25)); LoadButton->setMaxSize(Vec2f(200, 100)); LoadButton->setPreferredSize(Vec2f(80, 40)); LoadButton->setToolTipText("Click to open a file browser window"); LoadButton->setText("Load File"); LoadButton->connectActionPerformed(boost::bind(handleLoadButtonAction, _1, TutorialWindow.get(), theTextEditor.get())); ButtonRefPtr SaveButton = Button::create(); SaveButton->setMinSize(Vec2f(50, 25)); SaveButton->setMaxSize(Vec2f(200, 100)); SaveButton->setPreferredSize(Vec2f(80, 40)); SaveButton->setToolTipText("Click to save the currently opened file"); SaveButton->setText("Save File"); SaveButton->connectActionPerformed(boost::bind(handleSaveButtonAction, _1, TutorialWindow.get(),theTextEditor.get())); //Button Panel LayoutRefPtr ButtonPanelLayout = FlowLayout::create(); PanelRecPtr ButtonPanel = Panel::createEmpty(); ButtonPanel->setPreferredSize(Vec2f(300, 300)); ButtonPanel->setLayout(ButtonPanelLayout); ButtonPanel->pushToChildren(LoadButton); ButtonPanel->pushToChildren(SaveButton); ButtonPanel->pushToChildren(SplitButton); ButtonPanel->pushToChildren(ClipboardButton); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); LayoutRefPtr MainInternalWindowLayout = FlowLayout::create(); InternalWindowRefPtr MainInternalWindow = InternalWindow::create(); //MainInternalWindow->pushToChildren(TextAreaScrollPanel); MainInternalWindow->pushToChildren(theTextEditor); MainInternalWindow->pushToChildren(ButtonPanel); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f)); //MainInternalWindow->setDrawTitlebar(true); //MainInternalWindow->setResizable(true); // Create the Drawing Surface UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRefPtr TutorialUIForeground = UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); sceneManager.setRoot(scene); // Add the UI Foreground Object to the Scene ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0); TutorialViewport->addForeground(TutorialUIForeground); // Show the whole Scene sceneManager.showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.95f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "06Editor"); TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, theTextEditor.get())); commitChanges(); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }