ComponentRefPtr createRightPanelCheckPanel(void)
{
    // Create and edit the CheckBoxes
    CheckboxButtonRefPtr RightPanelCheck1 = OSG::CheckboxButton::create();
    CheckboxButtonRefPtr RightPanelCheck2 = OSG::CheckboxButton::create();
    CheckboxButtonRefPtr RightPanelCheck3 = OSG::CheckboxButton::create();
    CheckboxButtonRefPtr RightPanelCheck4 = OSG::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);
        // Add Listener
        RightPanelCheck1->addButtonSelectedListener(&RightPanelCheck1Listener);
    
        RightPanelCheck2->setText("Show Box");
        RightPanelCheck2->setPreferredSize(Vec2f(125,50));
        RightPanelCheck2->setAlignment(Vec2f (0.5,0.0));
        // Add Listener
        RightPanelCheck2->addButtonSelectedListener(&RightPanelCheck2Listener);

        RightPanelCheck3->setText("Show Sphere");
        RightPanelCheck3->setPreferredSize(Vec2f(125,50));
        RightPanelCheck3->setAlignment(Vec2f(0.0,0.0));
        // Add Listener
        RightPanelCheck3->addButtonSelectedListener(&RightPanelCheck3Listener);

        RightPanelCheck4->setText("Show Cone");
        RightPanelCheck4->setPreferredSize(Vec2f(125,50));
        RightPanelCheck4->setAlignment(Vec2f(0.0,0.0));
        // Add Listener
        RightPanelCheck4->addButtonSelectedListener(&RightPanelCheck4Listener);

    // Create an edit Panel Background
    ColorLayerRefPtr RightPanelCheckPanelBackground = OSG::ColorLayer::create();
        RightPanelCheckPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0));

    // Create and edit Panel layout
    BoxLayoutRefPtr RightPanelCheckPanelLayout = OSG::BoxLayout::create();
        RightPanelCheckPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
        RightPanelCheckPanelLayout->setMinorAxisAlignment(0.5f);

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

    // Create and edit Panel
    PanelRefPtr RightPanelCheckPanel = OSG::Panel::create();
        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 RightPanelCheckPanel;
}
Пример #2
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);
}
PanelUnrecPtr createSinglePtrFieldPanel(void)
{
    SinglePtrFieldLabel = OSG::Label::create();

    SinglePtrFieldLabel->setText("Changable");
    SinglePtrFieldLabel->setBorders(NULL);
    
    ButtonRefPtr SinglePtrFieldCreateBackgroundButton = OSG::Button::create();
    SinglePtrFieldCreateBackgroundButton->setText("Create Background");
    SinglePtrFieldCreateBackgroundButton->setPreferredSize(Vec2f(175.0f,SinglePtrFieldCreateBackgroundButton->getPreferredSize().y()));
    SinglePtrFieldCreateActionListener* TheCreateBackgroundActionListener = new SinglePtrFieldCreateActionListener();
    SinglePtrFieldCreateBackgroundButton->addActionListener(TheCreateBackgroundActionListener);

    LayoutRefPtr ThePanelLayout = OSG::FlowLayout::create();

    PanelRefPtr ThePanel = Panel::createEmpty();
    ThePanel->setLayout(ThePanelLayout);
    ThePanel->pushToChildren(SinglePtrFieldLabel);
    ThePanel->pushToChildren(SinglePtrFieldCreateBackgroundButton);

    return ThePanel;
    
}
ComponentRefPtr createRightPanelButtonPanel(void)
{
    // Create and edit the Panel Buttons
    ToggleButtonRefPtr RightPanelButton1 = OSG::ToggleButton::create();
    ToggleButtonRefPtr RightPanelButton2 = OSG::ToggleButton::create();
    ToggleButtonRefPtr RightPanelButton3 = OSG::ToggleButton::create();
    ToggleButtonRefPtr RightPanelButton4 = OSG::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
    ColorLayerRefPtr RightPanelButtonPanelBackground = OSG::ColorLayer::create();
        RightPanelButtonPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0));

    // Create and edit Panel layout
    BoxLayoutRefPtr RightPanelButtonPanelLayout = OSG::BoxLayout::create();
        RightPanelButtonPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);

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

    // Create and edit Panel
    PanelRefPtr RightPanelButtonPanel = OSG::Panel::create();
        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 RightPanelButtonPanel;

}
PanelUnrecPtr createMultiFieldPanel(void)
{
    //Popup Menu
    MenuItemRefPtr RemoveIndexMenuItem = MenuItem::create();
    RemoveIndexMenuItem->setText("Remove Index");
    RemoveIndexMenuItem->addActionListener(new RemoveMultiFieldActionListener());

    MenuItemRefPtr SetValueMenuItem = MenuItem::create();
    SetValueMenuItem->setText("Set Value");
    SetValueMenuItem->addActionListener(new SetMultiFieldActionListener());
    
    MenuItemRefPtr AddValueMenuItem = MenuItem::create();
    AddValueMenuItem->setText("Add Value");
    AddValueMenuItem->addActionListener(new AddMultiFieldActionListener());
    
    MenuItemRefPtr InsertIndexMenuItem = MenuItem::create();
    InsertIndexMenuItem->setText("Insert Value");
    InsertIndexMenuItem->addActionListener(new InsertMultiFieldActionListener());
    
    MenuItemRefPtr MoveIndexMenuItem = MenuItem::create();
    MoveIndexMenuItem->setText("Move Value");
    MoveIndexMenuItem->addActionListener(new MoveMultiFieldActionListener());
    
    MenuItemRefPtr SwapIndexMenuItem = MenuItem::create();
    SwapIndexMenuItem->setText("Swap Value");
    SwapIndexMenuItem->addActionListener(new SwapMultiFieldActionListener());

    PopupMenuRefPtr MultiFieldListPopupMenu = PopupMenu::create();
    MultiFieldListPopupMenu->addItem(SetValueMenuItem);
    MultiFieldListPopupMenu->addItem(AddValueMenuItem);
    MultiFieldListPopupMenu->addItem(InsertIndexMenuItem);
    MultiFieldListPopupMenu->addItem(MoveIndexMenuItem);
    MultiFieldListPopupMenu->addItem(SwapIndexMenuItem);
    MultiFieldListPopupMenu->addItem(RemoveIndexMenuItem);

    //Multi-field List Model
	MultiFieldListModel = MFieldListModel::create();
    MultiFieldListModel->setContainer(TutorialBackground);
    MultiFieldListModel->setFieldId(GradientBackground::ColorFieldId);
    //MultiFieldListModel->setFieldId(GradientBackground::PositionFieldId);

    //List
    MultiFieldList = List::create();
    MultiFieldList->setPreferredSize(Vec2f(200, 300));
    MultiFieldList->setOrientation(List::VERTICAL_ORIENTATION);
	MultiFieldList->setModel(MultiFieldListModel);
    ListSelectionModelPtr MultiFieldListSelectionModel(new DefaultListSelectionModel());
    MultiFieldList->setSelectionModel(MultiFieldListSelectionModel);
    MultiFieldList->setPopupMenu(MultiFieldListPopupMenu);

    // Create a ScrollPanel for easier viewing of the List
    ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
        ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
        ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    ExampleScrollPanel->setViewComponent(MultiFieldList);

    // Create MainFramelayout
    FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
    MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
    MainInternalWindowLayout->setMinorAxisAlignment(0.5f);

    //Label
    LabelRefPtr ListLabel = Label::create();
    ListLabel->setText("Background Colors List");
    ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));


    //Panel
    FlowLayoutRefPtr ThePanelLayout = OSG::FlowLayout::create();
    ThePanelLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    ThePanelLayout->setMajorAxisAlignment(0.5f);
    ThePanelLayout->setMinorAxisAlignment(0.5f);

    PanelRefPtr ThePanel = Panel::createEmpty();
    ThePanel->setLayout(ThePanelLayout);
    ThePanel->pushToChildren(ListLabel);
    ThePanel->pushToChildren(ExampleScrollPanel);

    return ThePanel;
    
}
PanelUnrecPtr createSingleFieldPanel(void)
{

    ChangableBorder = OSG::LineBorder::create();
		ChangableBorder->setColor(Color4f(0.0,0.0,0.0,1.0));
    
	ChangableBackground = OSG::ColorLayer::create();
		ChangableBackground->setColor(Color4f(1.0,1.0,1.0,1.0));

    LabelRefPtr ChangableLabel = OSG::Label::create();

            ChangableLabel->setText("Changable");
            ChangableLabel->setBorders(ChangableBorder);
            ChangableLabel->setBackgrounds(ChangableBackground);

	//Command Buttons

    TheCommandManager = CommandManager::create(TheUndoManager);
    ButtonRefPtr BorderRedButton = OSG::Button::create();
            BorderRedButton->setText("Border Red");
    SetBorderColorActionListener* TheSetRedBorderColorActionListener = new SetBorderColorActionListener(ChangableBorder, Color4f(1.0,0.0,0.0,1.0), TheCommandManager);
    BorderRedButton->addActionListener(TheSetRedBorderColorActionListener);
	
    ButtonRefPtr BorderGreenButton = OSG::Button::create();
            BorderGreenButton->setText("Border Green");
    SetBorderColorActionListener* TheSetGreenBorderColorActionListener = new SetBorderColorActionListener(ChangableBorder, Color4f(0.0,1.0,0.0,1.0), TheCommandManager);
    BorderGreenButton->addActionListener(TheSetGreenBorderColorActionListener);
	
    ButtonRefPtr BorderBlueButton = OSG::Button::create();
            BorderBlueButton->setText("Border Blue");
    SetBorderColorActionListener* TheSetBlueBorderColorActionListener = new SetBorderColorActionListener(ChangableBorder, Color4f(0.0,0.0,1.0,1.0), TheCommandManager);
    BorderBlueButton->addActionListener(TheSetBlueBorderColorActionListener);
	
	//Background
    ButtonRefPtr BackgroundRedButton = OSG::Button::create();
            BackgroundRedButton->setText("Background Red");
    SetBackgroundColorActionListener* TheSetRedBackgroundColorActionListener = new SetBackgroundColorActionListener(ChangableBackground, Color4f(1.0,0.0,0.0,1.0), TheCommandManager);
    BackgroundRedButton->addActionListener(TheSetRedBackgroundColorActionListener);
	
    ButtonRefPtr BackgroundGreenButton = OSG::Button::create();
            BackgroundGreenButton->setText("Background Green");
    SetBackgroundColorActionListener* TheSetGreenBackgroundColorActionListener = new SetBackgroundColorActionListener(ChangableBackground, Color4f(0.0,1.0,0.0,1.0), TheCommandManager);
    BackgroundGreenButton->addActionListener(TheSetGreenBackgroundColorActionListener);
	
    ButtonRefPtr BackgroundBlueButton = OSG::Button::create();
            BackgroundBlueButton->setText("Background Blue");
    SetBackgroundColorActionListener* TheSetBlueBackgroundColorActionListener = new SetBackgroundColorActionListener(ChangableBackground, Color4f(0.0,0.0,1.0,1.0), TheCommandManager);
    BackgroundBlueButton->addActionListener(TheSetBlueBackgroundColorActionListener);

    LayoutRefPtr ThePanelLayout = OSG::FlowLayout::create();

    PanelRefPtr ThePanel = Panel::createEmpty();
    ThePanel->setLayout(ThePanelLayout);
    ThePanel->pushToChildren(BorderRedButton);
    ThePanel->pushToChildren(BorderGreenButton);
    ThePanel->pushToChildren(BorderBlueButton);
    ThePanel->pushToChildren(BackgroundRedButton);
    ThePanel->pushToChildren(BackgroundGreenButton);
    ThePanel->pushToChildren(BackgroundBlueButton);
    ThePanel->pushToChildren(ChangableLabel);

    return ThePanel;
    
}
PanelUnrecPtr createMultiPtrFieldPanel(void)
{
    //Buttons for Inner Panel
    ButtonRefPtr AButton = Button::create();
    AButton->setText("A");

    ButtonRefPtr BButton = Button::create();
    BButton->setText("B");

    //Inner Panel
    LayoutRefPtr MultiPtrFieldInnerPanelLayout = OSG::FlowLayout::create();

    MultiPtrFieldInnerPanel = OSG::Panel::create();
    MultiPtrFieldInnerPanel->setLayout(MultiPtrFieldInnerPanelLayout);
    MultiPtrFieldInnerPanel->setPreferredSize(Vec2f(200.0f, 200.0f));
    MultiPtrFieldInnerPanel->pushToChildren(AButton);
    MultiPtrFieldInnerPanel->pushToChildren(BButton);

    //Popup Menu
    MenuItemRefPtr RemoveIndexMenuItem = MenuItem::create();
    RemoveIndexMenuItem->setText("Remove Index");
    RemoveIndexMenuItem->addActionListener(new RemoveMultiPtrFieldActionListener());

    MenuItemRefPtr SetValueMenuItem = MenuItem::create();
    SetValueMenuItem->setText("Set Value");
    SetValueMenuItem->addActionListener(new SetMultiPtrFieldActionListener());
    
    MenuItemRefPtr AddValueMenuItem = MenuItem::create();
    AddValueMenuItem->setText("Add Value");
    AddValueMenuItem->addActionListener(new AddMultiPtrFieldActionListener());
    
    MenuItemRefPtr InsertIndexMenuItem = MenuItem::create();
    InsertIndexMenuItem->setText("Insert Value");
    InsertIndexMenuItem->addActionListener(new InsertMultiPtrFieldActionListener());
    
    MenuItemRefPtr MoveIndexMenuItem = MenuItem::create();
    MoveIndexMenuItem->setText("Move Value");
    MoveIndexMenuItem->addActionListener(new MoveMultiPtrFieldActionListener());
    
    MenuItemRefPtr SwapIndexMenuItem = MenuItem::create();
    SwapIndexMenuItem->setText("Swap Value");
    SwapIndexMenuItem->addActionListener(new SwapMultiPtrFieldActionListener());

    PopupMenuRefPtr MultiPtrFieldListPopupMenu = PopupMenu::create();
    MultiPtrFieldListPopupMenu->addItem(SetValueMenuItem);
    MultiPtrFieldListPopupMenu->addItem(AddValueMenuItem);
    MultiPtrFieldListPopupMenu->addItem(InsertIndexMenuItem);
    MultiPtrFieldListPopupMenu->addItem(MoveIndexMenuItem);
    MultiPtrFieldListPopupMenu->addItem(SwapIndexMenuItem);
    MultiPtrFieldListPopupMenu->addItem(RemoveIndexMenuItem);

    //Multi-field List Model
	MultiPtrFieldListModel = MFieldListModel::create();
    MultiPtrFieldListModel->setContainer(MultiPtrFieldInnerPanel);
    MultiPtrFieldListModel->setFieldId(Panel::ChildrenFieldId);

    //List
    MultiPtrFieldList = List::create();
    MultiPtrFieldList->setPreferredSize(Vec2f(200, 300));
    MultiPtrFieldList->setOrientation(List::VERTICAL_ORIENTATION);
	MultiPtrFieldList->setModel(MultiPtrFieldListModel);
    ListSelectionModelPtr MultiPtrFieldListSelectionModel(new DefaultListSelectionModel());
    MultiPtrFieldList->setSelectionModel(MultiPtrFieldListSelectionModel);
    MultiPtrFieldList->setPopupMenu(MultiPtrFieldListPopupMenu);

    // Create a ScrollPanel for easier viewing of the List
    ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
        ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
        ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    ExampleScrollPanel->setViewComponent(MultiPtrFieldList);


    LayoutRefPtr ThePanelLayout = OSG::FlowLayout::create();

    PanelRefPtr ThePanel = Panel::createEmpty();
    ThePanel->setLayout(ThePanelLayout);
    ThePanel->pushToChildren(MultiPtrFieldInnerPanel);
    ThePanel->pushToChildren(ExampleScrollPanel);

    return ThePanel;
    
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialMouseListener mouseListener;
    TutorialMouseMotionListener mouseMotionListener;
    TutorialWindow->addMouseListener(&mouseListener);
    TutorialWindow->addMouseMotionListener(&mouseMotionListener);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);

    // Set up Window

	//Load in File
	NodeRefPtr LoadedFile = SceneFileHandler::the()->read("C:\\Documents and Settings\\All Users\\Documents\\Cell.osb");

    // Make Main Scene Node
    create3DObjects();
    scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
		scene->addChild(LoadedFile);

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

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

        
    /******************************************************
            
            Create a Background

    ******************************************************/
    ColorLayerRefPtr GreyBackground = OSG::ColorLayer::create();

        GreyBackground->setColor(Color4f(.93,.93,.93,1.0));


    /******************************************************
            
            Create some Borders

    ******************************************************/
    LineBorderRefPtr PanelBorder = OSG::LineBorder::create();
    EmptyBorderRefPtr Panel1Border = OSG::EmptyBorder::create();
    EmptyBorderRefPtr Panel2Border = OSG::EmptyBorder::create();
    EmptyBorderRefPtr emptyBorder = OSG::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

    ******************************************************/
    LabelRefPtr LeftPanelLabel1 = OSG::Label::create();
    UIFontRefPtr LeftPanelLabel1Font = OSG::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

    ******************************************************/
    BoxLayoutRefPtr MainInternalWindowLayout = OSG::BoxLayout::create();
    FlowLayoutRefPtr LeftPanelLayout = OSG::FlowLayout::create();
    BoxLayoutRefPtr RightPanelLayout = OSG::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

    ******************************************************/
    PanelRefPtr LeftPanel = OSG::Panel::create();
    PanelRefPtr RightPanel = OSG::Panel::create();

    // LeftPanel stuff
        LeftPanel->setPreferredSize(Vec2f(400, 500));
        LeftPanel->pushToChildren(LeftPanelLabel1);
        LeftPanel->pushToChildren(createLeftPanelButtonPanel());
        LeftPanel->pushToChildren(createLeftPanelRadioTextPanel());
        LeftPanel->setLayout(LeftPanelLayout);
        LeftPanel->setBackgrounds(GreyBackground);
        LeftPanel->setBorders(Panel1Border);

    //RightPanel stuff
        RightPanel->setPreferredSize(Vec2f(200, 620));
        RightPanel->pushToChildren(createRightPanelButtonPanel());
        RightPanel->pushToChildren(createRightPanelCheckPanel());
        RightPanel->setLayout(RightPanelLayout);
        RightPanel->setBackgrounds(GreyBackground);
        RightPanel->setBorders(Panel2Border);
    
    // Create The Main InternalWindow
    InternalWindowRefPtr MainInternalWindow = OSG::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);

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

    // Make A 3D Rectangle to draw the UI on
    UIRectangleRefPtr UIRectCore = UIRectangle::create();
        UIRectCore->setPoint(Pnt3f(-310.0,-310.0,370.0));
        UIRectCore->setWidth(620);
        UIRectCore->setHeight(620);
        UIRectCore->setDrawingSurface(TutorialDrawingSurface);
    
    NodeRefPtr UIRectNode = OSG::Node::create();
        UIRectNode->setCore(UIRectCore);
    
        // add the UIRect as a child
        scene->addChild(UIRectNode);


    mgr->setRoot(scene);

    // Show the whole Scene
    mgr->showAll();

    //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;
}
Пример #9
0
void LuaDebuggerInterface::createCodeEditor(void)
{
    //Create the Breakpoint images
    BoostPath BreakpointIconPath(_BaseIconDir / BoostPath("breakpoint.png")),
              BreakpointDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-disabled.png")),
              BreakpointConditionalIconPath(_BaseIconDir / BoostPath("breakpoint-conditional.png")),
              BreakpointConditionalDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-conditional-disabled.png")),
              BreakpointCountIconPath(_BaseIconDir / BoostPath("breakpoint-count.png")),
              BreakpointCountDisabledIconPath(_BaseIconDir / BoostPath("breakpoint-count-disabled.png"));
    
    //Breakpoint Button prototypes
    //Regular Breakpoint
    ButtonRecPtr BreakpointProtoButton = Button::create();
    BreakpointProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointProtoButton->setImages(BreakpointIconPath.string());
    BreakpointProtoButton->setDisabledImage(BreakpointDisabledIconPath.string());
    BreakpointProtoButton->setBorders(NULL);
    BreakpointProtoButton->setBackgrounds(NULL);
    BreakpointProtoButton->setForegrounds(NULL);

    //Count Breakpoint
    ButtonRecPtr BreakpointCountProtoButton = Button::create();
    BreakpointCountProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointCountProtoButton->setImages(BreakpointCountIconPath.string());
    BreakpointCountProtoButton->setDisabledImage(BreakpointCountDisabledIconPath.string());
    BreakpointCountProtoButton->setBorders(NULL);
    BreakpointCountProtoButton->setBackgrounds(NULL);
    BreakpointCountProtoButton->setForegrounds(NULL);

    //Conditional breakpoint
    ButtonRecPtr BreakpointConditionalProtoButton = Button::create();
    BreakpointConditionalProtoButton->setPreferredSize(Vec2f(18.0f, 18.0f));
    BreakpointConditionalProtoButton->setImages(BreakpointConditionalIconPath.string());
    BreakpointConditionalProtoButton->setDisabledImage(BreakpointConditionalDisabledIconPath.string());
    BreakpointConditionalProtoButton->setBorders(NULL);
    BreakpointConditionalProtoButton->setBackgrounds(NULL);
    BreakpointConditionalProtoButton->setForegrounds(NULL);

    //Create the default font
    _CodeFont = UIFont::create();
    _CodeFont->setFamily("Courier New");
    _CodeFont->setSize(21);
    _CodeFont->setGlyphPixelSize(22);
    _CodeFont->setAntiAliasing(false);

    // Create a TextArea component
    _CodeTextArea = TextEditor::create();
    _CodeTextArea->setIsSplit(false);
    _CodeTextArea->setClipboardVisible(false);
    //_CodeTextArea->getTextDomArea()->setFont(_CodeFont);
    //_CodeTextArea->setGutterWidth(50.0f);
    _CodeTextArea->setText(createDefaultCodeText());

    //_CodeTextArea->connectCaretChanged(boost::bind(&LuaDebuggerInterface::codeAreaCaretChanged,this, _1));
    //_CodeTextArea->connectMouseClicked(boost::bind(&LuaDebuggerInterface::handleCodeAreaMouseClicked,this, _1));

    _MainSplitPanel = SplitPanel::create();
    _MainSplitPanel->setMinComponent(_CodeTextArea);
    _MainSplitPanel->setMaxComponent(_InfoTabPanel);
    _MainSplitPanel->setOrientation(SplitPanel::VERTICAL_ORIENTATION);
    _MainSplitPanel->setDividerPosition(0.7);
    // location from the left/top
    _MainSplitPanel->setDividerSize(4);
    _MainSplitPanel->setMaxDividerPosition(.8);
    _MainSplitPanel->setMinDividerPosition(.2);

    //Code Area Info
    LabelRefPtr LineLabel = Label::create();
    LineLabel->setText("Line:");
    LineLabel->setPreferredSize(Vec2f(40.0f, 30.0f));
    LineLabel->setAlignment(Vec2f(1.0f, 0.5f));

    _LineValueLabel = Label::create();
    _LineValueLabel->setText("");
    _LineValueLabel->setPreferredSize(Vec2f(40.0f, 30.0f));

    LabelRefPtr ColumnLabel = Label::create();
    ColumnLabel->setText("Column:");
    ColumnLabel->setPreferredSize(Vec2f(55.0f, 30.0f));
    ColumnLabel->setAlignment(Vec2f(1.0f, 0.5f));

    _ColumnValueLabel = Label::create();
    _ColumnValueLabel->setText("");
    _ColumnValueLabel->setPreferredSize(Vec2f(40.0f, 30.0f));
    //TextArea Info Panel

    _CodeAreaInfoPanel = Panel::create();

    SpringLayoutRefPtr CodeAreaInfoLayout = SpringLayout::create();

    //ColumnValueLabel
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _ColumnValueLabel, 0, SpringLayoutConstraints::EAST_EDGE, _CodeAreaInfoPanel);

    //ColumnLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ColumnLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ColumnLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ColumnLabel, -1, SpringLayoutConstraints::WEST_EDGE, _ColumnValueLabel);

    //LineValueLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _LineValueLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LineValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _LineValueLabel, -1, SpringLayoutConstraints::WEST_EDGE, ColumnLabel);

    //LineLabel    
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LineLabel, 0, SpringLayoutConstraints::NORTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LineLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, _CodeAreaInfoPanel);
    CodeAreaInfoLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LineLabel, -1, SpringLayoutConstraints::WEST_EDGE, _LineValueLabel);

    _CodeAreaInfoPanel->setPreferredSize(Vec2f(400.0f, 22.0f));
    _CodeAreaInfoPanel->pushToChildren(LineLabel);
    _CodeAreaInfoPanel->pushToChildren(_LineValueLabel);
    _CodeAreaInfoPanel->pushToChildren(ColumnLabel);
    _CodeAreaInfoPanel->pushToChildren(_ColumnValueLabel);
    _CodeAreaInfoPanel->setBorders(NULL);
    _CodeAreaInfoPanel->setLayout(CodeAreaInfoLayout);
}
Пример #10
0
DialogWindowUnrecPtr DialogWindow::createColorChooserDialog(const std::string& Title, 
                                                           const std::string& Message, 
                                                           bool showAlpha,
                                                           ColorSelectionModelPtr colorModel,
                                                           bool showCancel, 
                                                           const std::string& ConfirmBtnText, 
                                                           const std::string& CancelBtnText)
{
    ButtonRefPtr ConfirmationButton = OSG::Button::create();
    ButtonRefPtr CancelButton;

    //Confirm Button
    ConfirmationButton->setText(ConfirmBtnText);
    ConfirmationButton->setMinSize(ConfirmationButton->getPreferredSize());
    ConfirmationButton->setPreferredSize(ConfirmationButton->getRequestedSize());

    if(showCancel)
    {
        //Cancel Button
        CancelButton = OSG::Button::create();
        CancelButton->setText(CancelBtnText);
        CancelButton->setMinSize(CancelButton->getPreferredSize());
        CancelButton->setPreferredSize(CancelButton->getRequestedSize());
    }

    // Create Panel for top half of SplitPanel
    TextAreaRefPtr MessagePanelText = OSG::TextArea::create();

    MessagePanelText->setBorders(NULL);
    MessagePanelText->setPreferredSize(Vec2f(100.0f, 100.0f));
    MessagePanelText->setBackgrounds(NULL);
    MessagePanelText->setWrapStyleWord(true);
    MessagePanelText->setText(Message);
    MessagePanelText->setEditable(false);

    // Create Panel for bottom half of SplitPanel
    PanelRefPtr MessageButtonPanel = OSG::Panel::createEmpty();
    FlowLayoutRefPtr MessagePanelBottomLayout = OSG::FlowLayout::create();
    MessageButtonPanel->pushToChildren(ConfirmationButton);
    if(showCancel) 
        MessageButtonPanel->pushToChildren(CancelButton);
    MessageButtonPanel->setLayout(MessagePanelBottomLayout);
    MessageButtonPanel->setPreferredSize(Vec2f(450,75));

    PanelRefPtr MessagePanel = OSG::Panel::createEmpty();
    SpringLayoutRefPtr MessagePanelLayout = SpringLayout::create();
    MessagePanel->pushToChildren(MessagePanelText);
    MessagePanel->pushToChildren(MessageButtonPanel);
    MessagePanel->setLayout(MessagePanelLayout);


    ColorChooserRefPtr TheColorChooser = ColorChooser::create();
    TheColorChooser->setSelectionModel(colorModel);

    //Internals Layout and constraints

    DialogWindowUnrecPtr TheDialog = DialogWindow::create();
    SpringLayoutRefPtr DialogLayout = SpringLayout::create();

    //Message Text
    DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MessagePanelText, 5, SpringLayoutConstraints::NORTH_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessagePanelText, -5, SpringLayoutConstraints::EAST_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessagePanelText, 5, SpringLayoutConstraints::WEST_EDGE, TheDialog);

    //Color Chooser
    DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheColorChooser, 5, SpringLayoutConstraints::SOUTH_EDGE, MessagePanelText);
    DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TheColorChooser, -5, SpringLayoutConstraints::EAST_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheColorChooser, 5, SpringLayoutConstraints::WEST_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TheColorChooser, -5, SpringLayoutConstraints::NORTH_EDGE, MessageButtonPanel);

    //Button Panel
    DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::WEST_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::EAST_EDGE, TheDialog);
    DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessageButtonPanel, 20, SpringLayoutConstraints::SOUTH_EDGE, TheDialog);

    //Create the Dialog box
    TheDialog->setLayout(DialogLayout);
    TheDialog->setPreferredSize(Vec2f(350,400));
    TheDialog->pushToChildren(MessagePanelText);
    TheDialog->pushToChildren(TheColorChooser);
    TheDialog->pushToChildren(MessageButtonPanel);
    TheDialog->setTitle(Title);

    //Attach listener to the Confirm button
    ConfirmationButton->addActionListener(&TheDialog->_ConfirmButtonListener);

    if(showCancel)
    {
        //Attach listener to the Cancel button
        CancelButton->addActionListener(&TheDialog->_CancelButtonListener);
    }

    return DialogWindowTransitPtr(TheDialog);
}
ForegroundRefPtr ApplicationStartScreen::createInterface(void)
{
    // Create the Graphics
    GraphicsRefPtr StartScreenUIGraphics = OSG::Graphics2D::create();



    UIFontRefPtr ButtonFont = OSG::UIFont::create();
    ButtonFont->setSize(32);

    ButtonRefPtr BuilderButton = ::OSG::Button::create();
    BuilderButton->setPreferredSize(Vec2f(200, 75));
    BuilderButton->setText("Builder");
    BuilderButton->setFont(ButtonFont);
    BuilderButton->addActionListener(&_BuilderButtonActionListener); 

    ButtonRefPtr PlayerButton = ::OSG::Button::create();
    PlayerButton->setPreferredSize(Vec2f(200, 75));
    PlayerButton->setText("Player");
    PlayerButton->setFont(ButtonFont);
    PlayerButton->addActionListener(&_PlayerButtonActionListener); 

    ButtonRefPtr ExitButton = ::OSG::Button::create();
    ExitButton->setPreferredSize(Vec2f(200, 75));
    ExitButton->setText("Exit");
    ExitButton->setFont(ButtonFont);
    ExitButton->addActionListener(&_ExitButtonActionListener); 

    //ButtonPanel
    PanelRefPtr ButtonPanel = Panel::createEmpty();
    LayoutRefPtr ButtonPanelLayout = OSG::FlowLayout::create();
    ButtonPanel->pushToChildren(BuilderButton);
    ButtonPanel->pushToChildren(PlayerButton);
    ButtonPanel->pushToChildren(ExitButton);
    ButtonPanel->setLayout(ButtonPanelLayout);

    //Font
    UIFontRefPtr LabelFont = UIFont::create();
    LabelFont->setSize(16);

    //Version Label
    LabelRefPtr VersionLabel = OSG::Label::create();
    VersionLabel->setText("Version:");
    VersionLabel->setAlignment(Vec2f(1.0f,0.5f));
    VersionLabel->setPreferredSize(Vec2f(100,20));
    VersionLabel->setTextColors(Color4f(1.0f,1.0f,1.0f,1.0f));
    VersionLabel->setBackgrounds(NULL);
    VersionLabel->setBorders(NULL);
    VersionLabel->setFont(LabelFont);

    //Version Value Label
    LabelRefPtr VersionValueLabel = OSG::Label::create();
    VersionValueLabel->setText(getKabalaEngineVersion() + " - " + getKabalaEngineBuildType());
    VersionValueLabel->setPreferredSize(Vec2f(110,20));
    VersionValueLabel->setTextColors(Color4f(1.0f,1.0f,1.0f,1.0f));
    VersionValueLabel->setBackgrounds(NULL);
    VersionValueLabel->setBorders(NULL);
    VersionValueLabel->setFont(LabelFont);

    //Author Value Label
    LabelRefPtr AuthorValueLabel = OSG::Label::create();
    AuthorValueLabel->setText(getKabalaEngineAuthors());
    AuthorValueLabel->setPreferredSize(Vec2f(300,20));
    AuthorValueLabel->setTextColors(Color4f(1.0f,1.0f,1.0f,1.0f));
    AuthorValueLabel->setBackgrounds(NULL);
    AuthorValueLabel->setBorders(NULL);
    AuthorValueLabel->setFont(LabelFont);

    // Create The Main InternalWindow
    InternalWindowRefPtr StartScreenInternalWindow = OSG::InternalWindow::create();

    //Layout
    SpringLayoutRefPtr StartScreenInternalWindowLayout = OSG::SpringLayout::create();
    //::OSG::Button Panel
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ButtonPanel, 0, SpringLayoutConstraints::WEST_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ButtonPanel, 0, SpringLayoutConstraints::EAST_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ButtonPanel, 0, SpringLayoutConstraints::NORTH_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ButtonPanel, 0, SpringLayoutConstraints::SOUTH_EDGE, StartScreenInternalWindow);

    //Version Label
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, VersionLabel, 0, SpringLayoutConstraints::WEST_EDGE, VersionValueLabel);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, VersionLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, VersionLabel, LayoutSpring::height(VersionLabel));
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, VersionLabel, LayoutSpring::width(VersionLabel));

    //Version Value Label
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, VersionValueLabel, 0, SpringLayoutConstraints::EAST_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, VersionValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, VersionValueLabel, LayoutSpring::height(VersionValueLabel));
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, VersionValueLabel, LayoutSpring::width(VersionValueLabel));

    //Author Value Label
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, AuthorValueLabel, 0, SpringLayoutConstraints::WEST_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, AuthorValueLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, StartScreenInternalWindow);
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, AuthorValueLabel, LayoutSpring::height(AuthorValueLabel));
    StartScreenInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, AuthorValueLabel, LayoutSpring::width(AuthorValueLabel));

    StartScreenInternalWindow->pushToChildren(ButtonPanel);
    StartScreenInternalWindow->pushToChildren(AuthorValueLabel);
    StartScreenInternalWindow->pushToChildren(VersionLabel);
    StartScreenInternalWindow->pushToChildren(VersionValueLabel);
    StartScreenInternalWindow->setLayout(StartScreenInternalWindowLayout);
    StartScreenInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
    StartScreenInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
    StartScreenInternalWindow->setDrawTitlebar(false);
    StartScreenInternalWindow->setDrawDecorations(false);
    StartScreenInternalWindow->setResizable(false);

    // Create the Drawing Surface
    _TheUIDrawingSurface = UIDrawingSurface::create();
    _TheUIDrawingSurface->setGraphics(StartScreenUIGraphics);

    _TheUIDrawingSurface->openWindow(StartScreenInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr StartScreenUIForeground = OSG::UIForeground::create();

    StartScreenUIForeground->setDrawingSurface(_TheUIDrawingSurface);

    return StartScreenUIForeground;
}
Пример #12
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

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

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

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

        NodeRefPtr SphereGeometryNode = makeSphere(2,1.0f);
        setName(SphereGeometryNode, std::string("Sphere"));
        NodeRefPtr 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 = OSG::Node::create();
        Root->setCore(OSG::Group::create());
        Root->addChild(TorusNode);
        Root->addChild(SphereGeometryNode);
        Root->addChild(BoxGeometryNode);
        setName(Root, std::string("Root"));
    }

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

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

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

    //TheFileSystemTreeModel = FileSystemTreeModel::create();
    //TheFileSystemTreeModel->setRoot(BoostPath("C:\\"));
    //TheFileSystemTreeModel->setRoot(BoostPath("/"));

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

    TheTree->setPreferredSize(Vec2f(100, 500));
    TheTree->setModel(TheTreeModel);
    //TheTree->setModel(TheFileSystemTreeModel);
    TutorialTreeSelectionListener  TheTutorialTreeSelectionListener;
    TheTree->getSelectionModel()->addTreeSelectionListener(&TheTutorialTreeSelectionListener);


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

    ScrollPanelRefPtr 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
    LabelRefPtr NodeNameLabel = Label::create();
    NodeNameLabel->setText("Name");
    NodeNameLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

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

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

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

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

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

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

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

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

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

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

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

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

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

    LabelRefPtr NodeOcclusionMaskLabel = Label::create();
    NodeOcclusionMaskLabel->setText("Occlusion Mask");
    NodeOcclusionMaskLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

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

    LabelRefPtr NodeActiveLabel = Label::create();
    NodeActiveLabel->setText("Active");
    NodeActiveLabel->setPreferredSize(Vec2f(100.0f, 20.0f));

    NodeActiveValueLabel = Label::create();
    NodeActiveValueLabel->setPreferredSize(Vec2f(300.0f, 20.0f));
    //Details Panel
    BorderLayoutConstraintsRefPtr NodeDetailPanelConstraints = OSG::BorderLayoutConstraints::create();
    NodeDetailPanelConstraints->setRegion(BorderLayoutConstraints::BORDER_SOUTH);

    GridLayoutRefPtr NodeDetailPanelLayout = OSG::GridLayout::create();

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

    PanelRefPtr 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);
    NodeDetailPanel->pushToChildren(NodeOcclusionMaskLabel);
    NodeDetailPanel->pushToChildren(NodeOcclusionMaskValueLabel);
    NodeDetailPanel->pushToChildren(NodeActiveLabel);
    NodeDetailPanel->pushToChildren(NodeActiveValueLabel);

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

    LayoutRefPtr MainInternalWindowLayout = OSG::BorderLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::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
    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);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(Root);

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

    // Show the whole Scene
    mgr->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;
}
Пример #13
0
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
        scene->addChild(TorusGeometryNode);

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

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

            Create BorderLayout and some
            BorderLayoutConstraints to be used 
            to set up CardLayout.

    ******************************************************/
    
    BorderLayoutRefPtr MainInternalWindowLayout = OSG::BorderLayout::create();
    BorderLayoutConstraintsRefPtr ExampleButton1Constraints = OSG::BorderLayoutConstraints::create();
    BorderLayoutConstraintsRefPtr ExampleButton2Constraints = OSG::BorderLayoutConstraints::create();
    BorderLayoutConstraintsRefPtr ExampleButton7Constraints = OSG::BorderLayoutConstraints::create();
    BorderLayoutConstraintsRefPtr ExampleButton8Constraints = OSG::BorderLayoutConstraints::create();
    BorderLayoutConstraintsRefPtr ExampleCardPanelConstraints = OSG::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 
            ActionListeners, 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.

    ******************************************************/
    
    ExampleCardLayout = OSG::CardLayout::create();
    ExampleCardPanel = OSG::Panel::create();

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

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

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

        ExampleButton1->setText("Next Card");
        ExampleButton1->setConstraints(ExampleButton1Constraints);
    
    // Add ActionListener
    NextCardActionListener TheNextCardActionListener;
    ExampleButton1->addActionListener( &TheNextCardActionListener);
    
        ExampleButton2->setText("Previous Card");
        ExampleButton2->setConstraints(ExampleButton2Constraints);

    // Add ActionListener
    BackCardActionListener TheBackCardActionListener;
    ExampleButton2->addActionListener( &TheBackCardActionListener);

        ExampleButton3->setText("This");

        ExampleButton4->setText("is");

        ExampleButton5->setText("Card");
    
        ExampleButton6->setText("Layout");

        ExampleButton7->setText("First Card");
        ExampleButton7->setConstraints(ExampleButton7Constraints);
        
    // Add ActionListener
    FirstCardActionListener TheFirstCardActionListener;
    ExampleButton7->addActionListener( &TheFirstCardActionListener);

        ExampleButton8->setText("Last Card");
        ExampleButton8->setConstraints(ExampleButton8Constraints);
    
    // Add ActionListener
    LastCardActionListener TheLastCardActionListener;
    ExampleButton8->addActionListener( &TheLastCardActionListener);


        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
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    InternalWindowRefPtr MainInternalWindow = OSG::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
    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);

    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

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

    // Show the whole Scene
    mgr->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;
}
ComponentRefPtr createLeftPanelRadioTextPanel(void)
{

    // Create the RadioButton group
    RadioButtonRefPtr RadioButton1 = OSG::RadioButton::create();
    RadioButtonRefPtr RadioButton2 = OSG::RadioButton::create();
    RadioButtonRefPtr RadioButton3 = OSG::RadioButton::create();
    RadioButtonRefPtr RadioButton4 = OSG::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->addButtonSelectedListener(&RadioButton1Listener);

        RadioButton2->setAlignment(Vec2f(0.0,0.5));
        RadioButton2->setPreferredSize(Vec2f(100, 40));
        RadioButton2->setText("Red Text");
        RadioButton2->setToolTipText("Set TextArea text red");
    RadioButton2->addButtonSelectedListener(&RadioButton2Listener);

        RadioButton3->setAlignment(Vec2f(0.0,0.5));
        RadioButton3->setPreferredSize(Vec2f(100, 40));
        RadioButton3->setText("Green Text");
        RadioButton3->setToolTipText("Set TextArea text green");
    RadioButton3->addButtonSelectedListener(&RadioButton3Listener);

        RadioButton4->setAlignment(Vec2f(0.0,0.5));
        RadioButton4->setPreferredSize(Vec2f(100, 40));
        RadioButton4->setText("Blue Text");
        RadioButton4->setToolTipText("Set TextArea text blue");
    RadioButton4->addButtonSelectedListener(&RadioButton4Listener);

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


    // Create TextArea
    LeftPanelTextArea = OSG::TextArea::create();
        LeftPanelTextArea->setPreferredSize(Vec2f(125, 200));

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

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

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

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

    // Create two Panels for this Panel
    PanelRefPtr LeftPanelRadioTextPanelRadioPanel = OSG::Panel::create();
    PanelRefPtr LeftPanelRadioTextPanelTextPanel = OSG::Panel::create();

    // Create some Borders
    EmptyBorderRefPtr LeftPanelRadioTextPanelRadioPanelBorder = OSG::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
    LineBorderRefPtr PanelBorder1 = OSG::LineBorder::create();
        PanelBorder1->setColor(Color4f(0.0,0.0,0.0,1.0));
        PanelBorder1->setWidth(1);

    // Create and edit Panel
    PanelRefPtr LeftPanelRadioTextPanel = OSG::Panel::create();
        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 LeftPanelRadioTextPanel;
}
ComponentRefPtr createLeftPanelButtonPanel(void)

{

    // Create Label for this Panel
    LabelRefPtr LeftPanelButtonPanelLabel = OSG::Label::create();

        LeftPanelButtonPanelLabel->setTextColor(Color4f(1.0,1.0,1.0,1.0));
        LeftPanelButtonPanelLabel->setRolloverTextColor(Color4f(1.0,1.0,1.0,1.0));
        LeftPanelButtonPanelLabel->setBackground(createComplexBackground());
        LeftPanelButtonPanelLabel->setPreferredSize(Vec2f(100, 50));
        LeftPanelButtonPanelLabel->setText("Various Options");
		LeftPanelButtonPanelLabel->setAlignment(Vec2f(0.5,0.5));

    // Create and edit the Panel buttons
    ButtonRefPtr LeftPanelButton1 = OSG::Button::create();
    ButtonRefPtr LeftPanelButton2 = OSG::Button::create();
    ButtonRefPtr LeftPanelButton3 = OSG::Button::create();
    ButtonRefPtr LeftPanelButton4 = OSG::Button::create();
    ButtonRefPtr LeftPanelButton5 = OSG::Button::create();
    ButtonRefPtr LeftPanelButton6 = OSG::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
    BoxLayoutRefPtr LeftPanelButtonPanelLayout = OSG::BoxLayout::create();
        LeftPanelButtonPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);

    // Create an edit Panel Background
    ColorLayerRefPtr LeftPanelButtonPanelBackground = OSG::ColorLayer::create();
        LeftPanelButtonPanelBackground->setColor(Color4f(0.93,0.93,0.93,1.0));

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

    // Create and edit Panel
    PanelRefPtr LeftPanelButtonPanel = OSG::Panel::create();
        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 LeftPanelButtonPanel;
}
Пример #16
0
DialogWindowUnrecPtr DialogWindow::createInputDialog(const std::string& Title, const std::string& Message, const int& Type, const bool& showCancel, const std::vector<std::string>& InputValues, const std::string& ConfirmBtnText, const std::string& CancelBtnText)
{
    int DialogHeight = 175;
    DialogWindowRefPtr TheDialog = DialogWindow::create();

    ImageComponentRefPtr TheIcon = ImageComponent::create();
    LineBorderRefPtr TempIconBorder = OSG::LineBorder::create();
    TheIcon->setPreferredSize(Vec2f(45,45));
    TheIcon->setBorders(TempIconBorder);

    // Create Panel for input
    PanelRefPtr InputPanel = OSG::Panel::createEmpty();
    FlowLayoutRefPtr InputPanelLayout = OSG::FlowLayout::create();
    InputPanel->setLayout(InputPanelLayout);
    InputPanel->setPreferredSize(Vec2f(450,75));

    ButtonRefPtr InputButton;
    switch (Type) {
        case INPUT_TEXT:
            TheDialog->_InputTextField = OSG::TextField::create();
            TheDialog->_InputTextField->setText(InputValues[0]);
            TheDialog->_InputTextField->setPreferredSize(Vec2f(200,25));
            InputPanel->pushToChildren(TheDialog->_InputTextField);
            break;
        case INPUT_BTNS:	
            DialogHeight = 150;
            for (std::vector<std::string>::const_iterator it = InputValues.begin(); it!=InputValues.end(); ++it)
            {
                InputButton = OSG::Button::create();
                InputButton->setText(*it);
                InputButton->setMinSize(InputButton->getPreferredSize());
                InputButton->setPreferredSize(InputButton->getRequestedSize());
                InputButton->addActionListener(&TheDialog->_InputButtonListener);
                InputPanel->pushToChildren(InputButton);
            }				
            break;
        case INPUT_COMBO:
        default:
            TheDialog->_InputComboBox = OSG::ComboBox::create();
            DefaultMutableComboBoxModelRefPtr _InputComboBoxModel;
            _InputComboBoxModel = DefaultMutableComboBoxModel::create();

            for (std::vector<std::string>::const_iterator it = InputValues.begin(); it!=InputValues.end(); ++it)
            {
                _InputComboBoxModel->addElement(boost::any(std::string(*it)));
            }

            TheDialog->_InputComboBox->setPreferredSize(Vec2f(150, 23));
            TheDialog->_InputComboBox->setModel(_InputComboBoxModel);
            TheDialog->_InputComboBox->setSelectedIndex(0);

            InputPanel->pushToChildren(TheDialog->_InputComboBox);
            break;
    }

    FlowLayoutRefPtr MessagePanelBottomLayout;
    PanelRefPtr MessageButtonPanel;
    ButtonRefPtr ConfirmationButton;
    ButtonRefPtr CancelButton;


    if(Type != INPUT_BTNS)
    {
        ConfirmationButton = OSG::Button::create();
        //Confirm Button
        ConfirmationButton->setText(ConfirmBtnText);
        ConfirmationButton->setMinSize(ConfirmationButton->getPreferredSize());
        ConfirmationButton->setPreferredSize(ConfirmationButton->getRequestedSize());

        if(Type == INPUT_TEXT)
        {
            ConfirmationButton->addActionListener(&TheDialog->_TextButtonListener);
        }
        else
        {
            ConfirmationButton->addActionListener(&TheDialog->_ComboButtonListener);
        }
    }

    if(showCancel)
    {
        CancelButton = OSG::Button::create();
        //Cancel Button
        CancelButton->setText(CancelBtnText);
        CancelButton->setMinSize(CancelButton->getPreferredSize());
        CancelButton->setPreferredSize(CancelButton->getRequestedSize());

        //Attach listener to the Cancel button
        CancelButton->addActionListener(&TheDialog->_CancelButtonListener);
    }

    // Create Panel for top half of SplitPanel
    TextAreaRefPtr MessagePanelText = createTransparentTextArea(Message);

    //If the type of input is buttons and showCancel is true, just push the cancel button onto the input panel
    if(Type == INPUT_BTNS && showCancel)
    {
        InputPanel->pushToChildren(CancelButton);
    }
    else if(Type != INPUT_BTNS)
    {
        // Create Panel for bottom half of SplitPanel
        MessageButtonPanel = OSG::Panel::createEmpty();
        MessagePanelBottomLayout = OSG::FlowLayout::create();
        MessageButtonPanel->pushToChildren(ConfirmationButton);
        if(showCancel) 
            MessageButtonPanel->pushToChildren(CancelButton);
        MessageButtonPanel->setLayout(MessagePanelBottomLayout);
        MessageButtonPanel->setPreferredSize(Vec2f(450,75));
    } 

    // Create SplitPanel itself
    PanelRefPtr MessagePanel = OSG::Panel::createEmpty();
    SpringLayoutRefPtr MessagePanelLayout = SpringLayout::create();
    MessagePanel->pushToChildren(MessagePanelText);
    MessagePanel->pushToChildren(TheIcon);
    MessagePanel->pushToChildren(InputPanel);
    if(Type != INPUT_BTNS)
        MessagePanel->pushToChildren(MessageButtonPanel);
    MessagePanel->setLayout(MessagePanelLayout);


    //MessagePanelLayout
    //Icon
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheIcon, 10, SpringLayoutConstraints::NORTH_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, TheIcon, LayoutSpring::width(TheIcon));
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheIcon, 10, SpringLayoutConstraints::WEST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, TheIcon, LayoutSpring::height(TheIcon));

    //Message
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MessagePanelText, 5, SpringLayoutConstraints::NORTH_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessagePanelText, -5, SpringLayoutConstraints::EAST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessagePanelText, 10, SpringLayoutConstraints::EAST_EDGE, TheIcon);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessagePanelText, 20, SpringLayoutConstraints::NORTH_EDGE, InputPanel);

    //Input Panel
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InputPanel, 0, SpringLayoutConstraints::WEST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InputPanel, 0, SpringLayoutConstraints::EAST_EDGE, MessagePanel);

    if(Type != INPUT_BTNS)
    {
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, InputPanel, 40, SpringLayoutConstraints::NORTH_EDGE, MessageButtonPanel);
        //Button Panel
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, MessageButtonPanel, LayoutSpring::height(MessageButtonPanel));
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::WEST_EDGE, MessagePanel);
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::EAST_EDGE, MessagePanel);
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessageButtonPanel, 20, SpringLayoutConstraints::SOUTH_EDGE, MessagePanel);
    }
    else
    {
        MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, InputPanel, 20, SpringLayoutConstraints::SOUTH_EDGE, MessagePanel);
    }

    //Internals Layout and constraints
    BorderLayoutConstraintsRefPtr MessagePanelConstraints = BorderLayoutConstraints::create();
    MessagePanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    MessagePanel->setConstraints(MessagePanelConstraints);

    BorderLayoutRefPtr DialogLayout = BorderLayout::create();

    //Create the Dialog box
    TheDialog->setLayout(DialogLayout);
    TheDialog->setPreferredSize(Vec2f(350,DialogHeight));
    TheDialog->pushToChildren(MessagePanel);
    TheDialog->setTitle(Title);

    return TheDialog;
}
Пример #17
0
DialogWindowUnrecPtr DialogWindow::createMessageDialog(const std::string& Title, const std::string& Message, const int& Type, const bool& showCancel, const std::string& ConfirmBtnText, const std::string& CancelBtnText)
{
    ImageComponentRefPtr TheIcon = ImageComponent::create();
    LineBorderRefPtr TempIconBorder = OSG::LineBorder::create();
    TheIcon->setPreferredSize(Vec2f(45,45));
    TheIcon->setBorders(TempIconBorder);

    ButtonRefPtr ConfirmationButton = OSG::Button::create();
    ButtonRefPtr CancelButton;

    //Confirm Button
    ConfirmationButton->setText(ConfirmBtnText);
    ConfirmationButton->setMinSize(ConfirmationButton->getPreferredSize());
    ConfirmationButton->setPreferredSize(ConfirmationButton->getRequestedSize());

    if(showCancel)
    {
        //Cancel Button
        CancelButton = OSG::Button::create();
        CancelButton->setText(CancelBtnText);
        CancelButton->setMinSize(CancelButton->getPreferredSize());
        CancelButton->setPreferredSize(CancelButton->getRequestedSize());
    }

    // Create Panel for top half of SplitPanel
    TextAreaRefPtr MessagePanelText = createTransparentTextArea(Message);

    // Create Panel for bottom half of SplitPanel
    PanelRefPtr MessageButtonPanel = OSG::Panel::createEmpty();
    FlowLayoutRefPtr MessagePanelBottomLayout = OSG::FlowLayout::create();
    MessageButtonPanel->pushToChildren(ConfirmationButton);
    if(showCancel) 
        MessageButtonPanel->pushToChildren(CancelButton);
    MessageButtonPanel->setLayout(MessagePanelBottomLayout);
    MessageButtonPanel->setPreferredSize(Vec2f(450,75));

    // Create SplitPanel itself
    PanelRefPtr MessagePanel = OSG::Panel::createEmpty();
    SpringLayoutRefPtr MessagePanelLayout = SpringLayout::create();
    MessagePanel->pushToChildren(MessagePanelText);
    MessagePanel->pushToChildren(TheIcon);
    MessagePanel->pushToChildren(MessageButtonPanel);
    MessagePanel->setLayout(MessagePanelLayout);


    //MessagePanelLayout
    //Icon
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheIcon, 10, SpringLayoutConstraints::NORTH_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, TheIcon, LayoutSpring::width(TheIcon));
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheIcon, 10, SpringLayoutConstraints::WEST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, TheIcon, LayoutSpring::height(TheIcon));

    //Message
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MessagePanelText, 5, SpringLayoutConstraints::NORTH_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessagePanelText, -5, SpringLayoutConstraints::EAST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessagePanelText, 10, SpringLayoutConstraints::EAST_EDGE, TheIcon);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessagePanelText, -30, SpringLayoutConstraints::SOUTH_EDGE, MessagePanel);

    //Button Panel
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::WEST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::EAST_EDGE, MessagePanel);
    MessagePanelLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessageButtonPanel, 20, SpringLayoutConstraints::SOUTH_EDGE, MessagePanel);

    //Internals Layout and constraints
    BorderLayoutConstraintsRefPtr MessagePanelConstraints = BorderLayoutConstraints::create();
    MessagePanelConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    MessagePanel->setConstraints(MessagePanelConstraints);

    BorderLayoutRefPtr DialogLayout = BorderLayout::create();

    //Create the Dialog box
    DialogWindowRefPtr TheDialog = DialogWindow::create();
    TheDialog->setLayout(DialogLayout);
    TheDialog->setPreferredSize(Vec2f(350,150));
    TheDialog->pushToChildren(MessagePanel);
    TheDialog->setTitle(Title);

    //Attach listener to the Confirm button
    ConfirmationButton->addActionListener(&TheDialog->_ConfirmButtonListener);

    if(showCancel)
    {
        //Attach listener to the Cancel button
        CancelButton->addActionListener(&TheDialog->_CancelButtonListener);
    }

    return TheDialog;
}
/*-------------------------------------------------------------------------*\
 -  private                                                                 -
\*-------------------------------------------------------------------------*/
void GenericFieldContainerEditor::updateFieldsPanel(FieldContainer* fc)
{
    _FieldsContainer->clearChildren();

    UInt32 NumFields(fc->getType().getNumFieldDescs());
    FieldDescriptionBase* Desc;
    FieldEditorComponentUnrecPtr TheEditor;
    LabelUnrecPtr TheLabel;
    ComponentRecPtr TheToolTip;
    GridBagLayoutConstraintsRefPtr LayoutConstraints;
    PanelRefPtr FieldPanel;
    UInt32 NumRows(0),NumRowsForField(1);

    BorderLayoutRefPtr TheBorderLayout = BorderLayout::create();
    BorderLayoutConstraintsRefPtr WestConstraint = BorderLayoutConstraints::create();
    WestConstraint->setRegion(BorderLayoutConstraints::BORDER_WEST);
    BorderLayoutConstraintsRefPtr CenterConstraint = BorderLayoutConstraints::create();
    CenterConstraint->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    //Backgrounds
    ColorLayerRefPtr HeaderBgLayer = ColorLayer::create();
    HeaderBgLayer->setColor(Color4f(0.7f,0.7f,0.7f,1.0f));

    ColorLayerRefPtr LightBgLayer = ColorLayer::create();
    LightBgLayer->setColor(Color4f(0.9f,0.9f,0.9f,1.0f));
    ColorLayerRefPtr DarkBgLayer = ColorLayer::create();
    DarkBgLayer->setColor(Color4f(0.8f,0.8f,0.8f,1.0f));

    LayoutConstraints = GridBagLayoutConstraints::create();
    LayoutConstraints->setGridX(0);
    LayoutConstraints->setGridY(NumRows);
    LayoutConstraints->setGridHeight(1);
    LayoutConstraints->setGridWidth(2);
    LayoutConstraints->setFill(GridBagLayoutConstraints::FILL_BOTH);

    LabelRecPtr FieldsLabel = Label::create();
    FieldsLabel->setAlignment(Vec2f(0.5f,0.5f));
    FieldsLabel->setText("Fields");
    FieldsLabel->setBackgrounds(HeaderBgLayer);
    FieldsLabel->setConstraints(LayoutConstraints);
    FieldsLabel->setFont(_BoldFont);

    _FieldsContainer->pushToChildren(FieldsLabel);
    ++NumRows;

    if(_GenericNameAttachmentEditor->isTypeEditable(fc->getType()))
    {
        //Create the Label
        TheLabel = Label::create();
        TheLabel->setText("Name");
        TheLabel->setBackgrounds(NULL);
        TheLabel->setConstraints(WestConstraint);
        TheLabel->setPreferredSize(Vec2f(160.0f,22.0f));

        //Attach the Generic Name Editor
        _GenericNameAttachmentEditor->setCommandManager(_CmdManager);
        _GenericNameAttachmentEditor->attachContainer(fc);
        _GenericNameAttachmentEditor->setConstraints(CenterConstraint);

        //Create the Panel
        LayoutConstraints = GridBagLayoutConstraints::create();
        LayoutConstraints->setGridX(0);
        LayoutConstraints->setGridY(NumRows);
        LayoutConstraints->setGridHeight(1);
        LayoutConstraints->setGridWidth(1);
        LayoutConstraints->setFill(GridBagLayoutConstraints::FILL_BOTH);

        FieldPanel = Panel::createEmpty();
        FieldPanel->setInset(Vec4f(1.0f,1.0f,1.0f,1.0f));
        FieldPanel->pushToChildren(TheLabel);
        FieldPanel->pushToChildren(_GenericNameAttachmentEditor);
        FieldPanel->setLayout(TheBorderLayout);
        FieldPanel->setConstraints(LayoutConstraints);
        FieldPanel->setBackgrounds(LightBgLayer);

        _FieldsContainer->pushToChildren(FieldPanel);
        ++NumRows;
    }

    UInt32 UsedFieldCount(0);
    for(UInt32 i(1) ; i<=NumFields ; ++i)
    {
        Desc = fc->getFieldDescription(i);
        if(Desc != NULL &&
           !Desc->isInternal() &&
           Desc->getFieldType().getClass() != FieldType::ParentPtrField &&
           //HACK: Stop the pixel field from being editable on Images
           !(fc->getType().isDerivedFrom(Image::getClassType()) &&
             Desc->getFieldId() == Image::PixelFieldId))
        {
            //Create the Editor
            TheEditor = FieldEditorFactory::the()->createDefaultEditor(fc, Desc->getFieldId(), _CmdManager);
            if(TheEditor != NULL)
            {
                NumRowsForField = TheEditor->getNumRequestedRows();
                pushToEditors(TheEditor);
                TheEditor->setConstraints(CenterConstraint);

                //Create the Label
                TheLabel = Label::create();
                TheLabel->setText(Desc->getCName());
                TheLabel->setBackgrounds(NULL);
                TheLabel->setConstraints(WestConstraint);
                TheLabel->setPreferredSize(Vec2f(160.0f,22.0f));
                TheToolTip = createFieldToolTip(Desc);
                TheLabel->setToolTip(TheToolTip);

                //Create the Panel
                LayoutConstraints = GridBagLayoutConstraints::create();
                LayoutConstraints->setGridX(0);
                LayoutConstraints->setGridY(NumRows);
                LayoutConstraints->setGridHeight(NumRowsForField);
                LayoutConstraints->setGridWidth(1);
                LayoutConstraints->setFill(GridBagLayoutConstraints::FILL_BOTH);


                FieldPanel = Panel::createEmpty();
                FieldPanel->setInset(Vec4f(1.0f,1.0f,1.0f,1.0f));
                FieldPanel->pushToChildren(TheLabel);
                FieldPanel->pushToChildren(TheEditor);
                FieldPanel->setLayout(TheBorderLayout);
                FieldPanel->setConstraints(LayoutConstraints);
                if((UsedFieldCount%2) == 0)
                {
                    FieldPanel->setBackgrounds(DarkBgLayer);
                }
                else
                {
                    FieldPanel->setBackgrounds(LightBgLayer);
                }

                _FieldsContainer->pushToChildren(FieldPanel);
                NumRows += NumRowsForField;
                TheEditor->setPreferredSize(Vec2f(50.0f,22.0f * NumRowsForField));
                ++UsedFieldCount;
            }
        }
    }

    //Set the number of rows for the grid layout
    dynamic_cast<GridBagLayout*>(_FieldsContainer->getLayout())->setRows(NumRows);
    _FieldsContainer->setPreferredSize(Vec2f(400.0f, NumRows*24.0f));
}
/*----------------------------- class specific ----------------------------*/
void GenericFieldContainerEditor::onCreate(const GenericFieldContainerEditor *Id)
{
	Inherited::onCreate(Id);
    if(Id != NULL)
    {
        _BoldFont = UIFont::create();
        UIFontUnrecPtr ProtoFont(dynamic_cast<Label*>(Label::getClassType().getPrototype())->getFont());
        _BoldFont->setFamily(ProtoFont->getFamily());
        _BoldFont->setGlyphPixelSize(ProtoFont->getGlyphPixelSize());
        _BoldFont->setSize(ProtoFont->getSize());
        _BoldFont->setStyle(TextFace::STYLE_BOLD);

        BorderLayoutConstraintsRefPtr WestConstraint = BorderLayoutConstraints::create();
        WestConstraint->setRegion(BorderLayoutConstraints::BORDER_WEST);

        BorderLayoutConstraintsRefPtr NorthConstraint = BorderLayoutConstraints::create();
        NorthConstraint->setRegion(BorderLayoutConstraints::BORDER_NORTH);

        BorderLayoutConstraintsRefPtr CenterConstraint = BorderLayoutConstraints::create();
        CenterConstraint->setRegion(BorderLayoutConstraints::BORDER_CENTER);

        BorderLayoutConstraintsRefPtr SouthConstraint = BorderLayoutConstraints::create();
        SouthConstraint->setRegion(BorderLayoutConstraints::BORDER_SOUTH);

        //Backgournds
        ColorLayerRefPtr HeaderBgLayer = ColorLayer::create();
        HeaderBgLayer->setColor(Color4f(0.7f,0.7f,0.7f,1.0f));

        //Type Panel
        _ContainerTypeLabel = Label::create();
        _ContainerTypeLabel->setAlignment(Vec2f(0.5f,0.5f));
        _ContainerTypeLabel->setBackgrounds(HeaderBgLayer);
        _ContainerTypeLabel->setConstraints(WestConstraint);
        _ContainerTypeLabel->setPreferredSize(Vec2f(160.0f,22.0f));

        _ContainerIdLabel = Label::create();
        _ContainerIdLabel->setAlignment(Vec2f(0.5f,0.5f));
        _ContainerIdLabel->setBackgrounds(HeaderBgLayer);
        _ContainerIdLabel->setConstraints(CenterConstraint);


        BorderLayoutRefPtr TheBorderLayout = BorderLayout::create();
        PanelRefPtr TypePanel = Panel::createEmpty();
        TypePanel->setPreferredSize(Vec2f(160.0f,33.0f));
        TypePanel->setInset(Vec4f(1.0f,1.0f,1.0f,10.0f));
        TypePanel->pushToChildren(_ContainerIdLabel);
        TypePanel->pushToChildren(_ContainerTypeLabel);
        TypePanel->setLayout(TheBorderLayout);
        TypePanel->setConstraints(NorthConstraint);
        pushToChildren(TypePanel);

        //Fields Panel
        GridBagLayoutRecPtr AllFieldsPanelLayout = GridBagLayout::create();
        AllFieldsPanelLayout->setColumns(1);

        _FieldsContainer = Panel::createEmpty();
        _FieldsContainer->setConstraints(CenterConstraint);
        _FieldsContainer->setLayout(AllFieldsPanelLayout);
        if(getShowFields())
        {
            pushToChildren(_FieldsContainer);
        }

        //Events Panel
        GridLayoutRecPtr AllProducedEventsPanelLayout = GridLayout::create();
        AllProducedEventsPanelLayout->setColumns(1);
        AllProducedEventsPanelLayout->setHorizontalGap(0.0f);
        AllProducedEventsPanelLayout->setVerticalGap(0.0f);

        _ProducedEventsContainer = Panel::createEmpty();
        _ProducedEventsContainer->setConstraints(SouthConstraint);
        _ProducedEventsContainer->setLayout(AllProducedEventsPanelLayout);
        _ProducedEventsContainer->setInset(Vec4f(0.0f,0.0f,15.0f,0.0f));
        if(getShowEvents())
        {
            pushToChildren(_ProducedEventsContainer);
        }

        //Main Layout
        BorderLayoutRefPtr MainLayout = BorderLayout::create();
        setLayout(MainLayout);

        _GenericNameAttachmentEditor = GenericNameAttachmentEditor::create();
    }
}
ComponentTransitPtr ColorChooserComboBoxComponentGenerator::getComboBoxComponent(ComboBox* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	PanelRefPtr TheComponent = Panel::create();//dynamic_pointer_cast<Component>(getDrawObjectPrototype()->shallowCopy());
	TheComponent->setLayout(LayoutRefPtr(FlowLayout::create()));

	LabelRefPtr theColorLabel = Label::create();
	//theColorLabel->setPreferredSize(Vec2f(50.0f,50.0f));
	theColorLabel->setBorders(NULL);

	try
	{
		Color4f theColor = boost::any_cast<Color4f>(Value);

		if(theColor != NULL)
		{
			ColorLayerRefPtr theColorLabelBackground = ColorLayer::create();
			theColorLabelBackground->setColor(theColor);
			theColorLabel->setBackgrounds(theColorLabelBackground);
		}
	}
	catch(boost::bad_any_cast &)
	{
		std::string ValueString;

		try
		{
			ValueString = lexical_cast(Value);
		}
		catch (boost::bad_lexical_cast &)
		{
			//Could not convert to string
			SWARNING << "ColorChooserComboBoxComponentGenerator::getComboBoxComponent - The elements should either be a Color4f value or a std::string\n";
		}

		theColorLabel->setText(ValueString);

		if(IsSelected && HasFocus)
		{
			if(getFocusedTextColorHasPriority())
			{
				theColorLabel->setTextColors(getFocusedTextColor());
			}
			else
			{
				theColorLabel->setTextColors(getSelectedTextColor());
			}
		}
		else if(IsSelected)
		{
				theColorLabel->setTextColors(getSelectedTextColor());
		}
		else if(HasFocus)
		{
				theColorLabel->setTextColors(getFocusedTextColor());
		}
	}

	TheComponent->pushToChildren(theColorLabel);
    
	if(IsSelected && HasFocus)
	{
			if(getFocusedBorderHasPriority())
			{
				TheComponent->setBorders(getFocusedBorder());
			}
			else
			{
				TheComponent->setBorders(getSelectedBorder());
			}
			if(getFocusedBackgroundHasPriority())
			{
				TheComponent->setBackgrounds(getFocusedBackground());
			    TheComponent->setForegrounds(getFocusedForeground());
			}
			else
			{
				TheComponent->setBackgrounds(getSelectedBackground());
			    TheComponent->setForegrounds(getSelectedForeground());
			}
	}
	else if(IsSelected)
	{
			TheComponent->setBorders(getSelectedBorder());
			TheComponent->setBackgrounds(getSelectedBackground());
			TheComponent->setForegrounds(getSelectedForeground());
	}
	else if(HasFocus)
	{
			TheComponent->setBorders(getFocusedBorder());
			TheComponent->setBackgrounds(getFocusedBackground());
			TheComponent->setForegrounds(getFocusedForeground());
	}
	return ComponentTransitPtr(TheComponent.get());
}
Пример #21
0
void LuaDebuggerInterface::createEditorToolbar(void)
{
    BoostPath OpenIconPath(_BaseIconDir / BoostPath("open.png"));
    ButtonRefPtr OpenButton = Button::create();
    OpenButton->setToolTipText("Open");
    OpenButton->setPreferredSize(_ToolButtonSize);
    OpenButton->setImages(OpenIconPath.string());
    setName(OpenButton,"Open Button");
    OpenButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::openScriptButtonAction,this));

    BoostPath SaveIconPath(_BaseIconDir / BoostPath("Save.png"));
    ButtonRefPtr SaveButton = Button::create();
    SaveButton->setPreferredSize(_ToolButtonSize);
    SaveButton->setToolTipText("Save");
    setName(SaveButton,"Save Button");
    SaveButton->setImages(SaveIconPath.string());
    SaveButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::saveScriptButtonAction,this));

    BoostPath ClearIconPath(_BaseIconDir / BoostPath("clear.png"));
    ButtonRefPtr ClearButton = Button::create();
    ClearButton->setPreferredSize(_ToolButtonSize);
    ClearButton->setToolTipText("Clear");
    setName(ClearButton,"Clear Button");
    ClearButton->setImages(ClearIconPath.string());
    ClearButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::clearScriptButtonAction,this));



    BoostPath SplitHorzIconPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
    BoostPath SplitVertIconPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
    BoostPath SplitNoneIconPath(_BaseIconDir / BoostPath("view-split-none.png"));

    //Split Options Component Generator
    FunctorListComponentGeneratorRecPtr SplitOptionsCompGenerator =
        FunctorListComponentGenerator::create();

    SplitOptionsCompGenerator->setGenerateFunction(boost::bind(&LuaDebuggerInterface::generateSplitOptionListComponent,
                                                               this,
                                                               _1, _2, _3, _4, _5));

    //Split Options List Model
    DefaultListModelRecPtr SplitOptionsListModel = DefaultListModel::create();
    SplitOptionsListModel->pushBack(boost::any(std::string("None")));
    SplitOptionsListModel->pushBack(boost::any(std::string("Horizontal")));
    SplitOptionsListModel->pushBack(boost::any(std::string("Vertical")));

    _SplitButton = MenuButton::create();
    _SplitButton->setToolTipText("Split Options");
    _SplitButton->setPreferredSize(_ToolButtonSize);
    _SplitButton->setImages(SplitNoneIconPath.string());
    _SplitButton->setModel(SplitOptionsListModel);
    _SplitButton->setCellGenerator(SplitOptionsCompGenerator);
    setName(_SplitButton,"Split Button");
    _SplitButton->connectMenuActionPerformed(boost::bind(&LuaDebuggerInterface::handleSplitMenuAction,
                                                         this,
                                                         _1));

    //Make the Button Panel
    FlowLayoutRefPtr ButtonPanelLayout = FlowLayout::create();
    ButtonPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
    ButtonPanelLayout->setHorizontalGap(3.0f);
    ButtonPanelLayout->setMajorAxisAlignment(0.0f);
    ButtonPanelLayout->setMinorAxisAlignment(0.5);

    _EditorButtonPanel = Panel::createEmpty();
    _EditorButtonPanel->setPreferredSize(Vec2f(200.0f, 45.0f));
    _EditorButtonPanel->pushToChildren(OpenButton);
    _EditorButtonPanel->pushToChildren(SaveButton);
    _EditorButtonPanel->pushToChildren(ClearButton);
    _EditorButtonPanel->pushToChildren(_SplitButton);
    _EditorButtonPanel->setLayout(ButtonPanelLayout);
    setName(_EditorButtonPanel,"Button Panel");
}
ComponentTransitPtr PanelListComponentGenerator::getListComponent(List* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	std::string ValueString;

    try
    {
        ValueString = lexical_cast(Value);
		PanelRefPtr theComponent = Panel::create();
	
		GridLayoutRefPtr PanelLayout = OSG::GridLayout::create();
		PanelLayout->setRows(3);
		PanelLayout->setColumns(1);
		PanelLayout->setHorizontalGap(0);
		PanelLayout->setVerticalGap(2);

		

		std::stringstream is;
		is<<Index;
		std::string iss;
		is>>iss;
		TextFieldRefPtr theName = TextField::create();
		theName->setText("Group"+iss);
		theName->setPreferredSize(Vec2f(146,20));
		

		PanelRefPtr rangePanel = Panel::create();
		
		GridLayoutRefPtr rangePanelLayout = OSG::GridLayout::create();
		rangePanelLayout->setRows(1);
		rangePanelLayout->setColumns(4);
		rangePanelLayout->setHorizontalGap(2);
		rangePanelLayout->setVerticalGap(0);

		
		LabelRefPtr rangeLabel = Label::create();
		rangeLabel->setText("Range:");
		rangeLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr from = TextField::create();
		from->setEmptyDescText("From");
		from->setPreferredSize(Vec2f(35,20));

		LabelRefPtr hiphenLabel = Label::create();
		hiphenLabel->setText(" - ");
		hiphenLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr to = TextField::create();
		to->setPreferredSize(Vec2f(35,20));
		to->setEmptyDescText("To");

		rangePanel->pushToChildren(rangeLabel);
		rangePanel->pushToChildren(from);
		rangePanel->pushToChildren(hiphenLabel);
		rangePanel->pushToChildren(to);
		rangePanel->setLayout(rangePanelLayout);
		rangePanel->setPreferredSize(Vec2f(146,20));

		DefaultMutableComboBoxModelRefPtr TheComboBoxModel = DefaultMutableComboBoxModel::create();
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(std::string("More Colors")));

		ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
		
		//Create the ComboBox
		ComboBoxRefPtr TheComboBox = ComboBox::create();
		TheComboBox->setModel(TheComboBoxModel);
		TheComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
		TheComboBox->setEditable(false);
		TheComboBox->setSelectedIndex(0);
		TheComboBox->setPreferredSize(Vec2f(146,20));

		theComponent->pushToChildren(theName);
		theComponent->pushToChildren(rangePanel);
		theComponent->pushToChildren(TheComboBox);
		theComponent->setLayout(PanelLayout);
		theComponent->setPreferredSize(Vec2f(146,66));

		Parent->setCellMajorAxisLength(66);

		return ComponentTransitPtr(theComponent.get());

    }
    catch (boost::bad_lexical_cast &)
    {
        return ComponentTransitPtr(NULL);
    }

}