ComponentTransitPtr createButtonedComp(Component* const LabelComp,
                                       const Button::ActionPerformedEventType::slot_type &listener)
{
    ButtonRecPtr CompRemoveButton = Button::create();
    CompRemoveButton->setText("-");
    //CompRemoveButton->setToolTipText("Remove");
    CompRemoveButton->setPreferredSize(Vec2f(17.0f,17.0f));
    CompRemoveButton->setAlignment(Vec2f(0.5f,0.5f));
    CompRemoveButton->setFont(dynamic_cast<Label*>(LabelComp)->getFont());

    //Connect
    CompRemoveButton->connectActionPerformed(listener);

    SpringLayoutRecPtr TreeCompLayout = SpringLayout::create();
    PanelRecPtr CompPanel = Panel::createEmpty();

    TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel);

    TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, CompRemoveButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompRemoveButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

    CompPanel->setLayout(TreeCompLayout);
    CompPanel->pushToChildren(LabelComp);
    CompPanel->pushToChildren(CompRemoveButton);

    return ComponentTransitPtr(CompPanel);
}
Esempio n. 2
0
PanelTransitPtr createPanelWithButtons(void)
{
    ButtonRecPtr PanelButton1 = Button::create();
    ButtonRecPtr PanelButton2 = Button::create();
    ButtonRecPtr PanelButton3 = Button::create();
    ButtonRecPtr PanelButton4 = Button::create();
    ButtonRecPtr PanelButton5 = Button::create();
    ButtonRecPtr PanelButton6 = Button::create();
    PanelButton1->setText("This");
    PanelButton2->setText("is");
    PanelButton3->setText("a");
    PanelButton4->setText("sample");
    PanelButton5->setText("Scroll");
    PanelButton6->setText("Panel!");

    // Create Panel to add Buttons to which will be inserted into 
    // the ScrollPanel itself
    PanelRecPtr ScrollPanelInsertPanel = Panel::create();
    FlowLayoutRecPtr ScrollPanelInsertPanelLayout = FlowLayout::create();
    ScrollPanelInsertPanel->setPreferredSize(Vec2f(100, 250 ));
    ScrollPanelInsertPanel->pushToChildren(PanelButton1);
    ScrollPanelInsertPanel->pushToChildren(PanelButton2);
    ScrollPanelInsertPanel->pushToChildren(PanelButton3);
    ScrollPanelInsertPanel->pushToChildren(PanelButton4);
    ScrollPanelInsertPanel->pushToChildren(PanelButton5);
    ScrollPanelInsertPanel->pushToChildren(PanelButton6);
    ScrollPanelInsertPanel->setLayout(ScrollPanelInsertPanelLayout);

    return PanelTransitPtr(ScrollPanelInsertPanel);
}
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);

}
Esempio n. 4
0
void LuaDebuggerInterface::createToolbars(void)
{
    createExecutionToolbar();
    createEditorToolbar();

    BorderLayoutRefPtr ToolbarLayout = BorderLayout::create();

    BorderLayoutConstraintsRefPtr EditorPanelConstraints = BorderLayoutConstraints::create();
    EditorPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_WEST);
    _EditorButtonPanel->setConstraints(EditorPanelConstraints);

    BorderLayoutConstraintsRefPtr CodeExecutionPanelConstraints = BorderLayoutConstraints::create();
    CodeExecutionPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);
    _CodeExecutionToolbar->setConstraints(CodeExecutionPanelConstraints);

    _Toolbars = Panel::createEmpty();
    _Toolbars->setPreferredSize(Vec2f(45.0f, 45.0f));
    _Toolbars->setLayout(ToolbarLayout);
    _Toolbars->pushToChildren(_EditorButtonPanel);
    _Toolbars->pushToChildren(_CodeExecutionToolbar);
}
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();

        //Background
        SolidBackgroundRefPtr TutorialBackground = SolidBackground::create();
        TutorialBackground->setColor(Color3f(1.0,0.0,0.0));
    		    
        UndoManagerPtr TheUndoManager = UndoManager::create();
        CommandManagerPtr TheCommandManager = CommandManager::create(TheUndoManager);

        //UndoList
	    DefaultListModelRecPtr UndoRedoListModel = DefaultListModel::create();
        UndoRedoListModel->pushBack(boost::any(std::string("Top")));

	    ListRecPtr UndoRedoList = List::create();
        UndoRedoList->setPreferredSize(Vec2f(250, 300));
        UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
	    UndoRedoList->setModel(UndoRedoListModel);

        UndoRedoList->getSelectionModel()->connectSelectionChanged(boost::bind(&handleUndoRedoListSelectionChanged, _1, TheUndoManager));

        ButtonRecPtr UndoButton = OSG::Button::create();
        UndoButton->setText("Undo");
	    UndoButton->setEnabled(false);
        UndoButton->connectActionPerformed(boost::bind(&handleUndoButtonAction, _1, TheUndoManager));
    	

        ButtonRecPtr RedoButton = OSG::Button::create();
        RedoButton->setText("Redo");
	    RedoButton->setEnabled(false);
        RedoButton->connectActionPerformed(boost::bind(&handleRedoButtonActionPerformed, _1, TheUndoManager));

        TheUndoManager->connectStateChanged(boost::bind(&handleUndoManagerStateChanged, _1, UndoButton.get(), RedoButton.get(), UndoRedoListModel.get(), TheUndoManager));

        // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
        ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
        UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
        UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        UndoRedoScrollPanel->setViewComponent(UndoRedoList);


        //Edited Label
        LabelRecPtr EditedLabel = Label::create();
        EditedLabel->setText("Can be edited");
        EditedLabel->setPreferredSize(Vec2f(100.0f,18.0f));

        //Editor Field
        LabelRecPtr TheTextEditorLabel = Label::create();
        TheTextEditorLabel->setText("Text");
        TheTextEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        FieldEditorComponentRefPtr TheTextEditor = FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
                                                                                                  Label::TextFieldId,
                                                                                                  TheCommandManager);
        TheTextEditor->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr ThePreferredSizeEditorLabel = Label::create();
        ThePreferredSizeEditorLabel->setText("PreferredSize");
        ThePreferredSizeEditorLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        FieldEditorComponentRefPtr ThePreferredSizeEditor =
            FieldEditorFactory::the()->createDefaultEditor(EditedLabel,
                                                           Label::PreferredSizeFieldId,
                                                           TheCommandManager);
        ThePreferredSizeEditor->setPreferredSize(Vec2f(150.0f, 20.0f));

        //Editing Panel
        LayoutRefPtr EditorPanelLayout = OSG::FlowLayout::create();
        PanelRecPtr EditorPanel = Panel::create();
        EditorPanel->setPreferredSize(Vec2f(200.0f,200.0f));
        EditorPanel->pushToChildren(TheTextEditorLabel);
        EditorPanel->pushToChildren(TheTextEditor);
        EditorPanel->pushToChildren(ThePreferredSizeEditorLabel);
        EditorPanel->pushToChildren(ThePreferredSizeEditor);
        EditorPanel->setLayout(EditorPanelLayout);

        //Undo Panel
        LabelRecPtr UndoPanelLabel = Label::create();
        UndoPanelLabel->setText("Undo Panel");
        UndoPanelLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LayoutRefPtr UndoPanelLayout = OSG::FlowLayout::create();
        PanelRecPtr UndoPanel = Panel::create();
        UndoPanel->setPreferredSize(Vec2f(300.0f,300.0f));
        UndoPanel->pushToChildren(UndoPanelLabel);
        UndoPanel->pushToChildren(UndoRedoScrollPanel);
        UndoPanel->pushToChildren(UndoButton);
        UndoPanel->pushToChildren(RedoButton);
        UndoPanel->setLayout(UndoPanelLayout);

        // 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(EditedLabel);
        MainInternalWindow->pushToChildren(EditorPanel);
        MainInternalWindow->pushToChildren(UndoPanel);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
        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);

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);
        sceneManager.setRoot(scene);

        // Add the UI Foreground Object to the Scene
        ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);
        TutorialViewport->setBackground(TutorialBackground);

        // 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,
                                    "02GenericFieldEditor");

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
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);
}
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);
}
Esempio n. 8
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();
}
ComponentTransitPtr GenericFieldContainerEditor::createFCToolTip(const FieldContainerType &FCType)
{
    std::string FieldDoc(doxygenToPlainFormatting(FCType.getDocumentation()));

    //TypeName
    LabelRecPtr TypeLabel = Label::create();
    TypeLabel->setText(FCType.getName());
    TypeLabel->setAlignment(Vec2f(0.5f,0.5f));
    TypeLabel->setBackgrounds(NULL);

    //Separator
    SeparatorRecPtr MainSeparator = Separator::create();
    MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION);
    MainSeparator->setSeparatorSize(1.0f);
    MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f));
    MainSeparator->setBackgrounds(NULL);

    //Inheritance Panel Layout
    //LabelRecPtr InheritanceLabel = Label::create();
    //InheritanceLabel->setText("Inheritance");

    //FlowLayoutRecPtr InheritancePanelLayout = FlowLayout::create();
    //InheritancePanelLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    //InheritancePanelLayout->setVerticalGap(3.0f);
    //InheritancePanelLayout->setMajorAxisAlignment(0.0f);
    //InheritancePanelLayout->setMinorAxisAlignment(0.5f);
    //InheritancePanelLayout->setComponentAlignment(0.5f);

    ////Inheritance Panel
    //PanelRecPtr InheritancePanel = Panel::createEmpty();
    //InheritancePanel->setAllInsets(5.0f);
    //InheritancePanel->setLayout(InheritancePanelLayout);

    //const TypeBase *ParentType(&FCType);
    ////while()
    ////{
        ////ToolTipPanel->pushToChildren(DescriptionTextArea);
    ////}
    //LabelRecPtr TypeNameLabel = Label::create();
    //TypeNameLabel->setText(FCType.getName());
    //TypeNameLabel->setAlignment(Vec2f(0.5f,0.5f));

    //InheritancePanel->pushToChildren(TypeNameLabel);

    //Set the layout constraints
    BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create();
    CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    //Description Panel
    LabelRecPtr DescriptionLabel = Label::create();
    DescriptionLabel->setText("Description:");
    DescriptionLabel->setBackgrounds(NULL);

    TextAreaRecPtr DescriptionTextArea = TextArea::create();
    DescriptionTextArea->setText(FieldDoc);
    DescriptionTextArea->setEditable(false);
    DescriptionTextArea->setBorders(NULL);
    DescriptionTextArea->setBackgrounds(NULL);
    DescriptionTextArea->setConstraints(CenterConstraints);

    //Description Panel
    PanelRecPtr DescriptionPanel = Panel::create();
    BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create();
    DescriptionPanel->setAllInsets(5.0f);
    DescriptionPanel->setLayout(DescriptionPanelLayout);
    DescriptionPanel->pushToChildren(DescriptionTextArea);
    DescriptionPanel->setBackgrounds(NULL);


    //ToolTip Layout
    PanelRecPtr ToolTipPanel = Panel::createEmpty();

    SpringLayoutRecPtr MainLayout = SpringLayout::create();

    //TypeLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //MainSeparator    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, TypeLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    ////InheritancePanel
    //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritanceLabel, 1,
                              //SpringLayoutConstraints::SOUTH_EDGE, MainSeparator);
    //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritanceLabel, 0,
                              //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritanceLabel, 0,
                              //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    ////InheritancePanel
    //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritancePanel, 1,
                              //SpringLayoutConstraints::SOUTH_EDGE, InheritanceLabel);
    //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritancePanel, 0,
                              //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritancePanel, 0,
                              //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);


    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, MainSeparator);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //ToolTip Panel

    Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip());
    ToolTipPanel->setBorders(DefaultToolTip->getBorder());
    ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground());
    ToolTipPanel->setForegrounds(DefaultToolTip->getForeground());
    ToolTipPanel->setLayout(MainLayout);
    ToolTipPanel->pushToChildren(TypeLabel);
    ToolTipPanel->pushToChildren(MainSeparator);
    //ToolTipPanel->pushToChildren(InheritanceLabel);
    //ToolTipPanel->pushToChildren(InheritancePanel);
    ToolTipPanel->pushToChildren(DescriptionLabel);
    ToolTipPanel->pushToChildren(DescriptionPanel);

    Real32 Height(100.0f + DescriptionTextArea->getLineHeight()
                  * (DescriptionTextArea->getText().size()/40));
    ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height));

    return ComponentTransitPtr(ToolTipPanel);
}
Esempio n. 10
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(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;
}
/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/
ComponentTransitPtr SceneComponentTreeComponentGenerator::getTreeComponent(Tree* const Parent, 
                                                                            const boost::any& Value, 
                                                                            bool IsSelected, 
                                                                            bool Expanded, 
                                                                            bool Leaf, 
                                                                            UInt32 Row, 
                                                                            bool HasFocus)
{
    std::string Text;
    if(Value.type() == typeid(Scene* const))
    {
        Text = "Scene";
    }
    else if(Value.type() == typeid(UInt32))
    {
        switch(boost::any_cast<UInt32>(Value))
        {
        case SceneTreeModel::BasicComponent:              //Basic
            Text = "Basic";
            break;
        case SceneTreeModel::BackgroundComponent:              //Background
            Text = "Background";
            break;
        case SceneTreeModel::CameraComponent:              //Camera
            Text = "Camera";
            break;
        case SceneTreeModel::ForegroundsComponent:              //Foregrounds
            Text = "Foregrounds";
            break;
        case SceneTreeModel::SceneObjectsComponent:              //Models
            Text = "SceneObjects";
            break;
        case SceneTreeModel::LightsComponent:              //Models
            Text = "Lights";
            break;
        case SceneTreeModel::DynamicsComponent:              //Dynamics
            Text = "Dynamics";
            break;
        case SceneTreeModel::ScriptsComponent:              //Scripts
            Text = "Scripts";
            break;
        case SceneTreeModel::BehavioursComponent:              //Behaviours
            Text = "Behaviours";
            break;
        case SceneTreeModel::AnimationsComponent:              //Animations
            Text = "Animations";
            break;
        }
    }
    else if(Value.type() == typeid(Foreground* const))
    {
        ForegroundRecPtr FG= boost::any_cast<Foreground* const>(Value);
        const Char8* Name(getName(FG));
        Text = std::string(Name ? Name : "No Name" ) + " [" + FG->getType().getName() + "]";
    }
    else if(Value.type() == typeid(SceneObject* const))
    {
        SceneObjectRecPtr SO= boost::any_cast<SceneObject* const>(Value);
        const Char8* Name(getName(SO));
        Text = (Name ? Name : "No Name" );
    }
    else if(Value.type() == typeid(Light* const))
    {
        LightRecPtr SceneLight= boost::any_cast<Light* const>(Value);
        const Char8* Name(getName(SceneLight));
        Text = std::string(Name ? Name : "No Name" ) + " [" + SceneLight->getType().getName() + "]";
    }

    ComponentRecPtr LabelComp = getTreeComponentText(Parent, Text, IsSelected, Expanded, Leaf, Row, HasFocus);

    if(Value.type() == typeid(UInt32))
    {
        switch(boost::any_cast<UInt32>(Value))
        {
        case SceneTreeModel::ForegroundsComponent:              //Foregrounds
            {
                if(_AddForegroundButton == NULL)
                {
                    _AddForegroundButton = MenuButton::create();
                    _AddForegroundButton->setText("+");
                    _AddForegroundButton->setToolTipText("Create new Foreground");
                    _AddForegroundButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddForegroundButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddForegroundButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());

                    //Fill with all of the foreground types
                    DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create();
                    MenuModel->editMFDerivedFieldContainerTypes()->push_back(Foreground::getClassType().getCName());
                    MenuModel->setIncludeAbstract(false);

                    _AddForegroundButton->setModel(MenuModel);

                    //Connect
                    _AddForegroundConnection.disconnect();
                    _AddForegroundConnection = _AddForegroundButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddForeground, _SceneComponentTree, _1, _AddForegroundButton.get()));
                }

                SpringLayoutRecPtr TreeCompLayout = SpringLayout::create();
                PanelRecPtr CompPanel = Panel::createEmpty();

                TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel);

                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddForegroundButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddForegroundButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddForegroundButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        case SceneTreeModel::SceneObjectsComponent:              //Models
            {
                if(_AddSceneObjectButton == NULL)
                {
                    _AddSceneObjectButton = Button::create();
                    _AddSceneObjectButton->setText("+");
                    _AddSceneObjectButton->setToolTipText("Create new Scene Object");
                    _AddSceneObjectButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddSceneObjectButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddSceneObjectButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());

                    //Connect
                    _AddSceneObjectConnection.disconnect();
                    _AddSceneObjectConnection = _AddSceneObjectButton->connectActionPerformed(boost::bind(&SceneComponentTree::handleAddSceneObject, _SceneComponentTree, _1));
                }

                SpringLayoutRecPtr TreeCompLayout = SpringLayout::create();
                PanelRecPtr CompPanel = Panel::createEmpty();

                TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel);

                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddSceneObjectButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddSceneObjectButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddSceneObjectButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        case SceneTreeModel::LightsComponent:              //Lights
            {
                if(_AddLightButton == NULL)
                {
                    _AddLightButton = MenuButton::create();
                    _AddLightButton->setText("+");
                    _AddLightButton->setToolTipText("Create new Light");
                    _AddLightButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddLightButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddLightButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());
                    //Connect
                    _AddLightConnection.disconnect();
                    _AddLightConnection = _AddLightButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddLight, _SceneComponentTree, _1, _AddLightButton.get()));
                }

                //Fill with all of the light types
                DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create();
                MenuModel->editMFDerivedFieldContainerTypes()->push_back(Light::getClassType().getCName());
                MenuModel->setIncludeAbstract(false);

                _AddLightButton->setModel(MenuModel);

                SpringLayoutRecPtr TreeCompLayout = SpringLayout::create();
                PanelRecPtr CompPanel = Panel::createEmpty();

                TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel);

                TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddLightButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddLightButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddLightButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        }
    }
    else if(Value.type() == typeid(Foreground* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveForeground, _SceneComponentTree, _1, boost::any_cast<Foreground* const>(Value)));
    }
    else if(Value.type() == typeid(SceneObject* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveSceneObject, _SceneComponentTree, _1, boost::any_cast<SceneObject* const>(Value)));
    }
    else if(Value.type() == typeid(Light* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveLight, _SceneComponentTree, _1, boost::any_cast<Light* const>(Value)));
    }

    return ComponentTransitPtr(LabelComp);
}
Esempio n. 12
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;
}
Esempio n. 13
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));

        NodeRecPtr Root(NULL);
        if(argc == 2)
        {
            Root = SceneFileHandler::the()->read(argv[1]);
        }

        if(Root == NULL)
        {
            // Make Torus Node (creates Torus in background of Root)
            NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
            setName(TorusGeometryNode, std::string("Torus"));

            NodeRecPtr TorusNode = Node::create();
            TorusNode->setCore(Transform::create());
            TorusNode->addChild(TorusGeometryNode);
            setName(TorusNode, std::string("Torus Transform"));

            NodeRecPtr SphereGeometryNode = makeSphere(2,1.0f);
            setName(SphereGeometryNode, std::string("Sphere"));
            NodeRecPtr BoxGeometryNode = makeBox(1.0,1.0,1.0,1,1,1);
            setName(BoxGeometryNode, std::string("Box"));

            // Make Main Scene Node and add the Torus
            Root = Node::create();
            Root->setCore(Group::create());
            Root->addChild(TorusNode);
            Root->addChild(SphereGeometryNode);
            Root->addChild(BoxGeometryNode);
            setName(Root, std::string("Root"));
        }

        // Create the Graphics
        GraphicsRecPtr TutorialGraphics = Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

        //Tree Model
        SceneGraphTreeModelRecPtr TheTreeModel = SceneGraphTreeModel::create();
        TheTreeModel->setRoot(Root);

        //Create the Tree
        TreeRecPtr TheTree = Tree::create();

        TheTree->setPreferredSize(Vec2f(100, 500));
        TheTree->setModel(TheTreeModel);


        // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
        BorderLayoutConstraintsRecPtr SceneTreeConstraints = BorderLayoutConstraints::create();
        SceneTreeConstraints->setRegion(BorderLayoutConstraints::BORDER_WEST);

        ScrollPanelRecPtr ExampleScrollPanel = ScrollPanel::create();
        ExampleScrollPanel->setPreferredSize(Vec2f(350,300));
        ExampleScrollPanel->setConstraints(SceneTreeConstraints);
        //ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        ExampleScrollPanel->setViewComponent(TheTree);

        //Details Panel Labels
        LabelRecPtr NodeNameLabel = Label::create();
        NodeNameLabel->setText("Name");
        NodeNameLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeNameValueLabel = Label::create();
        NodeNameValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeCoreTypeLabel = Label::create();
        NodeCoreTypeLabel->setText("Core Type");
        NodeCoreTypeLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeCoreTypeValueLabel = Label::create();
        NodeCoreTypeValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeMinLabel = Label::create();
        NodeMinLabel->setText("Min");
        NodeMinLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeMinValueLabel = Label::create();
        NodeMinValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeMaxLabel = Label::create();
        NodeMaxLabel->setText("Max");
        NodeMaxLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeMaxValueLabel = Label::create();
        NodeMaxValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeCenterLabel = Label::create();
        NodeCenterLabel->setText("Center");
        NodeCenterLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeCenterValueLabel = Label::create();
        NodeCenterValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeTriCountLabel = Label::create();
        NodeTriCountLabel->setText("TriCount");
        NodeTriCountLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeTriCountValueLabel = Label::create();
        NodeTriCountValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));

        LabelRecPtr NodeTravMaskLabel = Label::create();
        NodeTravMaskLabel->setText("Traversal Mask");
        NodeTravMaskLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

        LabelRecPtr NodeTravMaskValueLabel = Label::create();
        NodeTravMaskValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));
        //Details Panel
        BorderLayoutConstraintsRecPtr NodeDetailPanelConstraints = BorderLayoutConstraints::create();
        NodeDetailPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);

        GridLayoutRecPtr NodeDetailPanelLayout = GridLayout::create();

        NodeDetailPanelLayout->setRows(7);
        NodeDetailPanelLayout->setColumns(2);
        NodeDetailPanelLayout->setHorizontalGap(2);
        NodeDetailPanelLayout->setVerticalGap(2);

        PanelRecPtr NodeDetailPanel = Panel::create();
        NodeDetailPanel->setConstraints(NodeDetailPanelConstraints);
        NodeDetailPanel->setPreferredSize(Vec2f(100.0f, 200.0f));
        NodeDetailPanel->setLayout(NodeDetailPanelLayout);
        NodeDetailPanel->pushToChildren(NodeNameLabel);
        NodeDetailPanel->pushToChildren(NodeNameValueLabel);
        NodeDetailPanel->pushToChildren(NodeCoreTypeLabel);
        NodeDetailPanel->pushToChildren(NodeCoreTypeValueLabel);
        NodeDetailPanel->pushToChildren(NodeMinLabel);
        NodeDetailPanel->pushToChildren(NodeMinValueLabel);
        NodeDetailPanel->pushToChildren(NodeMaxLabel);
        NodeDetailPanel->pushToChildren(NodeMaxValueLabel);
        NodeDetailPanel->pushToChildren(NodeCenterLabel);
        NodeDetailPanel->pushToChildren(NodeCenterValueLabel);
        NodeDetailPanel->pushToChildren(NodeTriCountLabel);
        NodeDetailPanel->pushToChildren(NodeTriCountValueLabel);
        NodeDetailPanel->pushToChildren(NodeTravMaskLabel);
        NodeDetailPanel->pushToChildren(NodeTravMaskValueLabel);

        SelectionHandler TheTreeSelectionHandler(TheTree,
                                                 &sceneManager,
                                                 NodeNameValueLabel,
                                                 NodeCoreTypeValueLabel,
                                                 NodeMinValueLabel,
                                                 NodeMaxValueLabel,
                                                 NodeCenterValueLabel,
                                                 NodeTriCountValueLabel,
                                                 NodeTravMaskValueLabel);
        // 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));

        LayoutRecPtr MainInternalWindowLayout = BorderLayout::create();

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleScrollPanel);
        MainInternalWindow->pushToChildren(NodeDetailPanel);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(NULL);
        MainInternalWindow->setBorders(NULL);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.0f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0,1.0));
        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(Root);

        // 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,
                                   "52SceneGraphTree");

        //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));

        NodeRecPtr Root(NULL);
        if(argc == 2)
        {
            Root = SceneFileHandler::the()->read(argv[1]);
        }

        if(Root == NULL)
        {
            // Make Torus Node (creates Torus in background of Root)
            NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

            NodeRecPtr TorusNode = Node::create();
            TorusNode->setCore(Transform::create());
            TorusNode->addChild(TorusGeometryNode);

            NodeRecPtr SphereGeometryNode = makeSphere(2,1.0f);
            NodeRecPtr BoxGeometryNode = makeBox(1.0,1.0,1.0,1,1,1);

            // Make Main Scene Node and add the Torus
            Root = Node::create();
            Root->setCore(Group::create());
            Root->addChild(TorusNode);
            Root->addChild(SphereGeometryNode);
            Root->addChild(BoxGeometryNode);
        }

        // Create the Graphics
        GraphicsRecPtr TutorialGraphics = Graphics2D::create();

        // Initialize the LookAndFeelManager to enable default settings
        LookAndFeelManager::the()->getLookAndFeel()->init();

        // 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));

        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();

        //Import InternalWindow(s) from XML file
        std::vector<InternalWindowRecPtr> StoreWindows;

        FCFileType::FCPtrStore NewContainers;
        NewContainers = FCFileHandler::the()->read(BoostPath("./Data/55ComponentTree.xml"));

        //Store each window found in the XML in the vector
        FCFileType::FCPtrStore::iterator Itor;
        for(Itor = NewContainers.begin(); Itor != NewContainers.end(); ++Itor)
        {
            if( (*Itor)->getType() == (InternalWindow::getClassType()))
            {
                StoreWindows.push_back(dynamic_pointer_cast<InternalWindow>(*Itor));
            }
        }
        //Tree Model
        FieldContainerTreeModelRecPtr TheTreeModel = FieldContainerTreeModel::create();
        TheTreeModel->setRoot(StoreWindows.front());
        //TheTreeModel->setShowPtrFields(false);
        //TheTreeModel->setShowDataFields(false);
        //TheTreeModel->setShowParentPtrFields(false);
        //TheTreeModel->setShowChildPtrFields(false);
        TheTreeModel->setShowAttachments(false);
        //TheTreeModel->setShowCallbackFunctors(false);

        //Tree Component Generator
        FieldContainerFieldPathComponentGeneratorRecPtr TheTreeComponentGenerator = FieldContainerFieldPathComponentGenerator::create();

        //Create the Tree
        TreeRecPtr TheTree = Tree::create();

        TheTree->setPreferredSize(Vec2f(100, 500));
        TheTree->setRootVisible(true);
        TheTree->setModel(TheTreeModel);
        TheTree->setCellGenerator(TheTreeComponentGenerator);
        setName(TheTree, std::string("TheTree"));

        // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
        ScrollPanelRecPtr ExampleScrollPanel = ScrollPanel::create();
        ExampleScrollPanel->setPreferredSize(Vec2f(350,500));
        //ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        //ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
        ExampleScrollPanel->setViewComponent(TheTree);
        setName(ExampleScrollPanel, std::string("ExampleScrollPanel"));

        //Show Buttons
        CheckboxButtonRecPtr ShowMultiFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowSingleFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowPtrFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowDataFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowParentPtrFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowChildPtrFieldsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowAttachmentsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowCallbackFunctorsButton = CheckboxButton::create();
        CheckboxButtonRecPtr ShowInternalFieldsButton = CheckboxButton::create();

        ShowMultiFieldsButton->setText("Multi Fields");
        ShowMultiFieldsButton->setPreferredSize(Vec2f(120.0f,ShowMultiFieldsButton->getPreferredSize().y()));
        ShowMultiFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowSingleFieldsButton->setText("Single Fields");
        ShowSingleFieldsButton->setPreferredSize(Vec2f(120.0f,ShowSingleFieldsButton->getPreferredSize().y()));
        ShowSingleFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowPtrFieldsButton->setText("Ptr Fields");
        ShowPtrFieldsButton->setPreferredSize(Vec2f(120.0f,ShowPtrFieldsButton->getPreferredSize().y()));
        ShowPtrFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowDataFieldsButton->setText("Data Fields");
        ShowDataFieldsButton->setPreferredSize(Vec2f(120.0f,ShowDataFieldsButton->getPreferredSize().y()));
        ShowDataFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowParentPtrFieldsButton->setText("ParentPtr Fields");
        ShowParentPtrFieldsButton->setPreferredSize(Vec2f(120.0f,ShowParentPtrFieldsButton->getPreferredSize().y()));
        ShowParentPtrFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowChildPtrFieldsButton->setText("ChildPtr Fields");
        ShowChildPtrFieldsButton->setPreferredSize(Vec2f(120.0f,ShowChildPtrFieldsButton->getPreferredSize().y()));
        ShowChildPtrFieldsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowAttachmentsButton->setText("Attachments");
        ShowAttachmentsButton->setPreferredSize(Vec2f(120.0f,ShowAttachmentsButton->getPreferredSize().y()));
        ShowAttachmentsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowCallbackFunctorsButton->setText("Callback Functors");
        ShowCallbackFunctorsButton->setPreferredSize(Vec2f(120.0f,ShowCallbackFunctorsButton->getPreferredSize().y()));
        ShowCallbackFunctorsButton->setAlignment(Vec2f(0.0f,0.5f));
        ShowInternalFieldsButton->setText("Internal Fields");
        ShowInternalFieldsButton->setPreferredSize(Vec2f(120.0f,ShowInternalFieldsButton->getPreferredSize().y()));
        ShowInternalFieldsButton->setAlignment(Vec2f(0.0f,0.5f));

        ShowCheckboxesController CheckboxesController(TheTreeModel,
                                                      ShowMultiFieldsButton,
                                                      ShowSingleFieldsButton,
                                                      ShowPtrFieldsButton,
                                                      ShowDataFieldsButton,
                                                      ShowParentPtrFieldsButton,
                                                      ShowChildPtrFieldsButton,
                                                      ShowAttachmentsButton,
                                                      ShowCallbackFunctorsButton,
                                                      ShowInternalFieldsButton);

        PanelRecPtr OptionsPanel = Panel::create();
        FlowLayoutRecPtr OptionsPanelLayout = FlowLayout::create();
        OptionsPanel->setLayout(OptionsPanelLayout);
        OptionsPanel->setPreferredSize(Vec2f(250.0f, 300.0f));
        OptionsPanel->pushToChildren(ShowMultiFieldsButton);
        OptionsPanel->pushToChildren(ShowSingleFieldsButton);
        OptionsPanel->pushToChildren(ShowPtrFieldsButton);
        OptionsPanel->pushToChildren(ShowDataFieldsButton);
        OptionsPanel->pushToChildren(ShowInternalFieldsButton);
        OptionsPanel->pushToChildren(ShowParentPtrFieldsButton);
        OptionsPanel->pushToChildren(ShowChildPtrFieldsButton);
        OptionsPanel->pushToChildren(ShowAttachmentsButton);
        OptionsPanel->pushToChildren(ShowCallbackFunctorsButton);

        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        MainInternalWindow->pushToChildren(ExampleScrollPanel);
        MainInternalWindow->pushToChildren(OptionsPanel);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
        MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.85f,0.85f));
        MainInternalWindow->setDrawTitlebar(false);
        MainInternalWindow->setResizable(false);
        setName(MainInternalWindow, std::string("MainInternalWindow"));

        // Create the Drawing Surface
        UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);

        TutorialDrawingSurface->openWindow(MainInternalWindow);

        TutorialDrawingSurface->openWindow(StoreWindows.back());

        // Create the UI Foreground Object
        UIForegroundRecPtr TutorialUIForeground = UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(Root);

        // 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,
                                   "56FieldContainerTree");

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
Esempio n. 15
0
void HelperPanel::createIntrospectionTreeTab(TabPanel* const tabPanel)
{
    BorderLayoutConstraintsRefPtr CenterConstraints = OSG::BorderLayoutConstraints::create();
    CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);
    BorderLayoutConstraintsRefPtr NorthConstraints = OSG::BorderLayoutConstraints::create();
    NorthConstraints->setRegion(BorderLayoutConstraints::BORDER_NORTH);


    _GlobalLuaIntroTreeModel = LuaIntrospectionTreeModel::create();
    _GlobalLuaIntroTreeModel->setRoot("");

    LuaIntrospectionComponentGeneratorRecPtr LuaIntroTreeComponentGenerator = LuaIntrospectionComponentGenerator::create();

    //Create the Tree
    TreeRecPtr TheTree = Tree::create();

    TheTree->setPreferredSize(Vec2f(200, 500));
    TheTree->setModel(_GlobalLuaIntroTreeModel);
    TheTree->setCellGenerator(LuaIntroTreeComponentGenerator);

    //Layout Expansion
    TheTree->expandPath(_GlobalLuaIntroTreeModel->getRootPath());

    //Create a scroll panel for the tree
    ScrollPanelRefPtr TreeScrollPanel = ScrollPanel::create();
    TreeScrollPanel->setPreferredSize(Vec2f(200,300));
    TreeScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    TreeScrollPanel->setViewComponent(TheTree);
    TreeScrollPanel->setConstraints(CenterConstraints);

    //Global Label
    LabelRecPtr GlobalTreeLabel = Label::create();
    GlobalTreeLabel->setText("Global");
    GlobalTreeLabel->setConstraints(NorthConstraints);

    BorderLayoutRecPtr BorderPanelLayout = BorderLayout::create();

    //Global Panel
    PanelRecPtr GlobalLuaTreePanel = Panel::createEmpty();
    GlobalLuaTreePanel->pushToChildren(GlobalTreeLabel);
    GlobalLuaTreePanel->pushToChildren(TreeScrollPanel);
    GlobalLuaTreePanel->setLayout(BorderPanelLayout);

    //Local Label
    LabelRecPtr LocalTreeLabel = Label::create();
    LocalTreeLabel->setText("Local");
    LocalTreeLabel->setConstraints(NorthConstraints);

    //Local Panel
    PanelRecPtr LocalLuaTreePanel = Panel::createEmpty();
    LocalLuaTreePanel->pushToChildren(LocalTreeLabel);
    LocalLuaTreePanel->setLayout(BorderPanelLayout);

    //Global/Local Split Panel
    SplitPanelRecPtr GlocalLocalSplitPanel = SplitPanel::create();
    GlocalLocalSplitPanel->setMinComponent(GlobalLuaTreePanel);
    GlocalLocalSplitPanel->setMaxComponent(LocalLuaTreePanel);
    GlocalLocalSplitPanel->setDividerPosition(0.5f);
    GlocalLocalSplitPanel->setDividerSize(5);
    GlocalLocalSplitPanel->setMinDividerPosition(.1);
    GlocalLocalSplitPanel->setMaxDividerPosition(.9);
    

    //Add the Panel to the TabPanel
    LabelRefPtr IntrospectionTreeTabLabel = Label::create();
    IntrospectionTreeTabLabel->setText("Lua Introspection");
    IntrospectionTreeTabLabel->setBorders(NULL);
    IntrospectionTreeTabLabel->setBackgrounds(NULL);

    tabPanel->addTab(IntrospectionTreeTabLabel, GlocalLocalSplitPanel);
}
ComponentTransitPtr GenericFieldContainerEditor::createEventToolTip(const EventDescription *EventDesc)
{
    std::string FieldDoc(doxygenToPlainFormatting(EventDesc->getDescription()));

    //TypeName
    LabelRecPtr TypeLabel = Label::create();
    TypeLabel->setText(EventDesc->getName());
    TypeLabel->setAlignment(Vec2f(0.5f,0.5f));
    TypeLabel->setBackgrounds(NULL);

    //Separator
    SeparatorRecPtr MainSeparator = Separator::create();
    MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION);
    MainSeparator->setSeparatorSize(1.0f);
    MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f));
    MainSeparator->setBackgrounds(NULL);

    //Consumable Label
    LabelRecPtr ConsumableLabel = Label::create();
    ConsumableLabel->setText(EventDesc->getConsumable() ? "Consumable" : "Not Consumable");
    ConsumableLabel->setAlignment(Vec2f(0.0f,0.5f));
    ConsumableLabel->setBackgrounds(NULL);

    //Set the layout constraints
    BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create();
    CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    //Description Panel
    LabelRecPtr DescriptionLabel = Label::create();
    DescriptionLabel->setText("Description:");
    DescriptionLabel->setBackgrounds(NULL);

    TextAreaRecPtr DescriptionTextArea = TextArea::create();
    DescriptionTextArea->setText(FieldDoc);
    DescriptionTextArea->setEditable(false);
    DescriptionTextArea->setBorders(NULL);
    DescriptionTextArea->setBackgrounds(NULL);
    DescriptionTextArea->setConstraints(CenterConstraints);

    //Description Panel
    PanelRecPtr DescriptionPanel = Panel::create();
    BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create();
    DescriptionPanel->setAllInsets(5.0f);
    DescriptionPanel->setLayout(DescriptionPanelLayout);
    DescriptionPanel->pushToChildren(DescriptionTextArea);
    DescriptionPanel->setBackgrounds(NULL);


    //ToolTip Layout
    PanelRecPtr ToolTipPanel = Panel::createEmpty();

    SpringLayoutRecPtr MainLayout = SpringLayout::create();

    //TypeLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //MainSeparator    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, TypeLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);
    //ConsumableLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ConsumableLabel, 1,
                              SpringLayoutConstraints::NORTH_EDGE, MainSeparator);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ConsumableLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ConsumableLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::SOUTH_EDGE, ConsumableLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //ToolTip Panel

    Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip());
    ToolTipPanel->setBorders(DefaultToolTip->getBorder());
    ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground());
    ToolTipPanel->setForegrounds(DefaultToolTip->getForeground());
    ToolTipPanel->setLayout(MainLayout);
    ToolTipPanel->pushToChildren(TypeLabel);
    ToolTipPanel->pushToChildren(MainSeparator);
    ToolTipPanel->pushToChildren(ConsumableLabel);
    ToolTipPanel->pushToChildren(DescriptionLabel);
    ToolTipPanel->pushToChildren(DescriptionPanel);

    Real32 Height(130.0f + DescriptionTextArea->getLineHeight()
                  * (DescriptionTextArea->getText().size()/40));
    ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height));

    return ComponentTransitPtr(ToolTipPanel);
}
Esempio n. 17
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->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;
}
Esempio n. 18
0
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);
}
Esempio n. 19
0
PanelTransitPtr createLeftPanelRadioTextPanel(void)
{
    // Create TextArea
    TextAreaRecPtr LeftPanelTextArea = TextArea::create();
    LeftPanelTextArea->setPreferredSize(Vec2f(125, 200));
    LeftPanelTextArea->setText("Text Area");

    // Create the RadioButton group
    RadioButtonRecPtr RadioButton1 = RadioButton::create();
    RadioButtonRecPtr RadioButton2 = RadioButton::create();
    RadioButtonRecPtr RadioButton3 = RadioButton::create();
    RadioButtonRecPtr RadioButton4 = RadioButton::create();

    RadioButton1->setAlignment(Vec2f(0.0,0.5));
    RadioButton1->setPreferredSize(Vec2f(100, 40));
    RadioButton1->setText("Black Text");
    RadioButton1->setToolTipText("Set TextArea text black");
    RadioButton1->connectButtonSelected(boost::bind(setTextColors,
                                                    LeftPanelTextArea.get(),
                                                    Color4f(0.0f,0.0f,0.0f,1.0f)));

    RadioButton2->setAlignment(Vec2f(0.0,0.5));
    RadioButton2->setPreferredSize(Vec2f(100, 40));
    RadioButton2->setText("Red Text");
    RadioButton2->setToolTipText("Set TextArea text red");
    RadioButton2->connectButtonSelected(boost::bind(setTextColors,
                                              LeftPanelTextArea.get(),
                                              Color4f(1.0f,0.0f,0.0f,1.0f)));

    RadioButton3->setAlignment(Vec2f(0.0,0.5));
    RadioButton3->setPreferredSize(Vec2f(100, 40));
    RadioButton3->setText("Green Text");
    RadioButton3->setToolTipText("Set TextArea text green");
    RadioButton3->connectButtonSelected(boost::bind(setTextColors,
                                              LeftPanelTextArea.get(),
                                              Color4f(0.0f,1.0f,0.0f,1.0f)));

    RadioButton4->setAlignment(Vec2f(0.0,0.5));
    RadioButton4->setPreferredSize(Vec2f(100, 40));
    RadioButton4->setText("Blue Text");
    RadioButton4->setToolTipText("Set TextArea text blue");
    RadioButton4->connectButtonSelected(boost::bind(setTextColors,
                                              LeftPanelTextArea.get(),
                                              Color4f(0.0f,0.0f,1.0f,1.0f)));

    RadioButtonGroupRecPtr buttonGroup = RadioButtonGroup::create();
    buttonGroup->addButton(RadioButton1);
    buttonGroup->addButton(RadioButton2);
    buttonGroup->addButton(RadioButton3);
    buttonGroup->addButton(RadioButton4);


    // Create Panel and its Background/Border to label TextField
    LabelRecPtr LeftPanelTextFieldLabel = Label::create();
    EmptyLayerRecPtr LeftPanelTextFieldLabelBackground = EmptyLayer::create();
    EmptyBorderRecPtr LeftPanelTextFieldLabelBorder = EmptyBorder::create();
    LeftPanelTextFieldLabel->setPreferredSize(Vec2f(100, 25));
    LeftPanelTextFieldLabel->setBorders(LeftPanelTextFieldLabelBorder);
    LeftPanelTextFieldLabel->setBackgrounds(LeftPanelTextFieldLabelBackground);
    LeftPanelTextFieldLabel->setText("Text Field");

    // Create TextField
    TextFieldRecPtr LeftPanelTextField = TextField::create();
    LeftPanelTextField->setPreferredSize(Vec2f(125.0f, 22.0f));

    // Create an edit Panel Background
    ColorLayerRecPtr LeftPanelRadioTextPanelBackground = ColorLayer::create();
    LeftPanelRadioTextPanelBackground->setColor(Color4f(0.93f,0.93f,0.93f,1.0f));

    // Create and edit Panel layouts
    FlowLayoutRecPtr LeftPanelRadioTextPanelLayout = FlowLayout::create();
    FlowLayoutRecPtr LeftPanelRadioTextPanelRadioPanelLayout = FlowLayout::create();
    FlowLayoutRecPtr LeftPanelRadioTextPanelTextPanelLayout = FlowLayout::create();
    LeftPanelRadioTextPanelLayout->setMinorAxisAlignment(0.0f);

    // Create two Panels for this Panel
    PanelRecPtr LeftPanelRadioTextPanelRadioPanel = Panel::createEmpty();
    PanelRecPtr LeftPanelRadioTextPanelTextPanel = Panel::createEmpty();

    // Create some Borders
    EmptyBorderRecPtr LeftPanelRadioTextPanelRadioPanelBorder = EmptyBorder::create();

    LeftPanelRadioTextPanelRadioPanel->setBorders(LeftPanelRadioTextPanelRadioPanelBorder);
    LeftPanelRadioTextPanelRadioPanel->setPreferredSize(Vec2f(125, 200));
    LeftPanelRadioTextPanelRadioPanel->setLayout(LeftPanelRadioTextPanelRadioPanelLayout);
    LeftPanelRadioTextPanelRadioPanel->setBackgrounds(LeftPanelRadioTextPanelBackground);
    LeftPanelRadioTextPanelRadioPanel->pushToChildren(RadioButton1);
    LeftPanelRadioTextPanelRadioPanel->pushToChildren(RadioButton2);
    LeftPanelRadioTextPanelRadioPanel->pushToChildren(RadioButton3);
    LeftPanelRadioTextPanelRadioPanel->pushToChildren(RadioButton4);

    // Create Panel Border
    LineBorderRecPtr PanelBorder1 = LineBorder::create();
    PanelBorder1->setColor(Color4f(0.0,0.0,0.0,1.0));
    PanelBorder1->setWidth(1);

    // Create and edit Panel
    PanelRecPtr LeftPanelRadioTextPanel = Panel::createEmpty();
    LeftPanelRadioTextPanel->setPreferredSize(Vec2f(180, 500));
    LeftPanelRadioTextPanel->pushToChildren(LeftPanelRadioTextPanelRadioPanel);
    //LeftPanelRadioTextPanel->pushToChildren(LeftPanelTextArea);
    LeftPanelRadioTextPanel->pushToChildren(LeftPanelTextFieldLabel);
    LeftPanelRadioTextPanel->pushToChildren(LeftPanelTextField);
    LeftPanelRadioTextPanel->setLayout(LeftPanelRadioTextPanelLayout);
    LeftPanelRadioTextPanel->setBackgrounds(LeftPanelRadioTextPanelBackground);
    LeftPanelRadioTextPanel->setBorders(PanelBorder1);

    return PanelTransitPtr(LeftPanelRadioTextPanel);
}
Esempio n. 20
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 BorderLayout and some
          BorderLayoutConstraints to be used 
          to set up CardLayout.

         ******************************************************/

        BorderLayoutRecPtr MainInternalWindowLayout = BorderLayout::create();
        BorderLayoutConstraintsRecPtr ExampleButton1Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton2Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton7Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleButton8Constraints = BorderLayoutConstraints::create();
        BorderLayoutConstraintsRecPtr ExampleCardPanelConstraints = BorderLayoutConstraints::create();

        ExampleButton1Constraints->setRegion(BorderLayoutConstraints::BORDER_EAST);

        ExampleButton2Constraints->setRegion(BorderLayoutConstraints::BORDER_WEST);

        ExampleButton7Constraints->setRegion(BorderLayoutConstraints::BORDER_NORTH);

        ExampleButton8Constraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);

        ExampleCardPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

        /******************************************************

          Create CardLayout.  CardLayout shows 
          a single Component at a time, meaning
          it is not exactly practical to use it
          alone for a Layout.  This tutorial uses
          the BorderLayout to include a Panel in
          the Center Region, and within that Panel
          using a CardLayout.  A single card is 
          displayed at one time within a 
          ComponentContainer using CardLayout.

          CardLayout has four functions:
          next, previous, first, and last.

          ->next(CardContainerName): Causes 
          CardLayout to display the next card.
          ->previous(CardContainerName): Causes
          CardLayout to display the 
          previous card.
          ->first(CardContainerName): Causes
          CardLayout to display the
          first card.
          ->last(CardContainerName): Causes
          CardLayout to display the
          last card.

          These are most useful when combined with 
          Action, as shown at the top of 
          this Tutorial, to assign actions to the 
          Buttons or Components to allow the user 
          to cycle through the Card Layout and 
          view different ExampleCards.

          Note that CardContainerName is the name
          of the ComponentContainer which is using the
          CardLayout, while the begin/endEditCP
          is performed on the CardLayout itself.

         ******************************************************/

        CardLayoutRecPtr ExampleCardLayout = CardLayout::create();
        PanelRecPtr ExampleCardPanel = Panel::create();

        /******************************************************

          Create Button Components to be used with 
          CardLayout to allow for interactivity.

         ******************************************************/
        ButtonRecPtr ExampleButton1 = Button::create();
        ButtonRecPtr ExampleButton2 = Button::create();
        ButtonRecPtr ExampleButton3 = Button::create();
        ButtonRecPtr ExampleButton4 = Button::create();
        ButtonRecPtr ExampleButton5 = Button::create();
        ButtonRecPtr ExampleButton6 = Button::create();    
        ButtonRecPtr ExampleButton7 = Button::create();
        ButtonRecPtr ExampleButton8 = Button::create();

        ExampleButton1->setText("Next Card");
        ExampleButton1->setConstraints(ExampleButton1Constraints);

        // Add Action
        ExampleButton1->connectActionPerformed(boost::bind(handleNextCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton2->setText("Previous Card");
        ExampleButton2->setConstraints(ExampleButton2Constraints);

        // Add Action
        ExampleButton2->connectActionPerformed(boost::bind(handleBackCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton3->setText("This");

        ExampleButton4->setText("is");

        ExampleButton5->setText("Card");

        ExampleButton6->setText("Layout");

        ExampleButton7->setText("First Card");
        ExampleButton7->setConstraints(ExampleButton7Constraints);

        // Add Action
        ExampleButton7->connectActionPerformed(boost::bind(handleFirstCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleButton8->setText("Last Card");
        ExampleButton8->setConstraints(ExampleButton8Constraints);

        // Add Action
        ExampleButton8->connectActionPerformed(boost::bind(handleLastCardAction, _1,
                                                           ExampleCardLayout.get(),
                                                           ExampleCardPanel.get()));

        ExampleCardPanel->setLayout(ExampleCardLayout);
        ExampleCardPanel->pushToChildren(ExampleButton3);
        ExampleCardPanel->pushToChildren(ExampleButton4);
        ExampleCardPanel->pushToChildren(ExampleButton5);
        ExampleCardPanel->pushToChildren(ExampleButton6);
        ExampleCardPanel->setConstraints(ExampleCardPanelConstraints);




        // 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(ExampleButton7);
        MainInternalWindow->pushToChildren(ExampleButton8);
        MainInternalWindow->pushToChildren(ExampleCardPanel);
        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,
                                   "11CardLayout");

        //Enter main Loop
        TutorialWindow->mainLoop();
    }

    osgExit();

    return 0;
}
PanelTransitPtr VideoFieldContainerEditor::createVideoPreviewPanel(void)
{
    ChunkMaterialUnrecPtr VideoMaterial = ChunkMaterial::create();

    //Video MaterialLayer
    _VideoMaterialLayer = MaterialLayer::create();
    _VideoMaterialLayer->setMaterial(VideoMaterial);

    //Video Panel
    _VideoPanel = Panel::createEmpty();
    _VideoPanel->setBackgrounds(_VideoMaterialLayer);

    //Filename Label
    _FileNameLabel = Label::create();
    _FileNameLabel->setAlignment(Vec2f(0.5f, 0.5f));

    //Total time Label
    _TotalTimeLabel = Label::create();
    _TotalTimeLabel->setAlignment(Vec2f(0.0f, 1.0f));
    _TotalTimeLabel->setBorders(NULL);
    _TotalTimeLabel->setBackgrounds(NULL);
    _TotalTimeLabel->setPreferredSize(Vec2f(50.0f,_TotalTimeLabel->getPreferredSize().y()));

    //Playback time Label
    _PlaybackTimeLabel = Label::create();
    _PlaybackTimeLabel->setAlignment(Vec2f(1.0f, 1.0f));
    _PlaybackTimeLabel->setPreferredSize(Vec2f(50.0f,_TotalTimeLabel->getPreferredSize().y()));
    _PlaybackTimeLabel->setBorders(NULL);
    _PlaybackTimeLabel->setBackgrounds(NULL);

    LabelRecPtr TimeSeparatorLabel = Label::create();
    TimeSeparatorLabel->setAlignment(Vec2f(0.5f, 1.0f));
    TimeSeparatorLabel->setPreferredSize(Vec2f(8.0f,_TotalTimeLabel->getPreferredSize().y()));
    TimeSeparatorLabel->setBorders(NULL);
    TimeSeparatorLabel->setBackgrounds(NULL);
    TimeSeparatorLabel->setText("/");

    //PlayPause Button
    _PlayPauseButton = Button::create();
    _PlayPauseButton->setText("Play");
    _PlayPauseButton->setPreferredSize(Vec2f(40.0f,40.0f));
    _PlayPauseButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handlePlayPauseAction, this,   _1));

    //Stop Button
    _StopButton = Button::create();
    _StopButton->setText("Stop");
    _StopButton->setPreferredSize(Vec2f(40.0f,40.0f));
    _StopButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handleStopAction, this,   _1));

    //Load Button
    ButtonRecPtr LoadButton = Button::create();
    LoadButton->setText("Load");
    LoadButton->setPreferredSize(Vec2f(40.0f,40.0f));
    LoadButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handleLoadAction, this,   _1));

    //Playback position slider
    _LocationSlider = Slider::create();
    _LocationSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION);
    _LocationSlider->setDrawLabels(false);
    _LocationSlider->setDrawMajorTicks(false);
    _LocationSlider->setDrawMinorTicks(false);
    _LocationSlider->setBorders(NULL);
    _LocationSlider->setBackgrounds(NULL);
    //_LocationSlider->getKnobButton()->setPreferredSize(Vec2f(15.0f, 8.0f));
    _LocationSlider->getRangeModel()->connectStateChanged(boost::bind(&VideoFieldContainerEditor::handlePlaybackLocationStateChanged, this,   _1));


    //Layout
    PanelRecPtr VideoPanel = Panel::createEmpty();
    SpringLayoutRecPtr MainLayout = SpringLayout::create();


    //Video Panel
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _VideoPanel, 0,
                              SpringLayoutConstraints::EAST_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _VideoPanel, 0,
                              SpringLayoutConstraints::WEST_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _VideoPanel, 0,
                              SpringLayoutConstraints::NORTH_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _VideoPanel, -1,
                              SpringLayoutConstraints::NORTH_EDGE, _PlayPauseButton);

    //Filename Label
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _FileNameLabel, 0,
                              SpringLayoutConstraints::EAST_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _FileNameLabel, 0,
                              SpringLayoutConstraints::WEST_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _FileNameLabel, 0,
                              SpringLayoutConstraints::NORTH_EDGE, VideoPanel);

    //Play/pause Button
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _PlayPauseButton, -3,
                              SpringLayoutConstraints::WEST_EDGE, _StopButton);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _PlayPauseButton, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, VideoPanel);

    //Stop Button
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _StopButton, -3,
                              SpringLayoutConstraints::WEST_EDGE, _LocationSlider);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _StopButton, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, VideoPanel);

    //Playback Slider
    MainLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, _LocationSlider, 0,
                              SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, VideoPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LocationSlider, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, VideoPanel);

    //Total video length label
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _TotalTimeLabel, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, LoadButton);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _TotalTimeLabel, 0,
                              SpringLayoutConstraints::EAST_EDGE, _LocationSlider);

    //Separator label
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TimeSeparatorLabel, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, LoadButton);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TimeSeparatorLabel, -2,
                              SpringLayoutConstraints::WEST_EDGE, _TotalTimeLabel);

    //Playback time label
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _PlaybackTimeLabel, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, LoadButton);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _PlaybackTimeLabel, -2,
                              SpringLayoutConstraints::WEST_EDGE, TimeSeparatorLabel);

    //Load Button
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LoadButton, 3,
                              SpringLayoutConstraints::EAST_EDGE, _LocationSlider);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LoadButton, 0,
                              SpringLayoutConstraints::SOUTH_EDGE, VideoPanel);

    //Main Video Panel
    VideoPanel->setLayout(MainLayout);

    VideoPanel->pushToChildren(_VideoPanel);
    VideoPanel->pushToChildren(_FileNameLabel);
    VideoPanel->pushToChildren(_PlayPauseButton);
    VideoPanel->pushToChildren(_StopButton);
    VideoPanel->pushToChildren(LoadButton);
    VideoPanel->pushToChildren(_PlaybackTimeLabel);
    VideoPanel->pushToChildren(TimeSeparatorLabel);
    VideoPanel->pushToChildren(_TotalTimeLabel);
    VideoPanel->pushToChildren(_LocationSlider);

    return PanelTransitPtr(VideoPanel);
}