本文整理汇总了C++中UIForegroundRefPtr::setDrawingSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ UIForegroundRefPtr::setDrawingSurface方法的具体用法?C++ UIForegroundRefPtr::setDrawingSurface怎么用?C++ UIForegroundRefPtr::setDrawingSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIForegroundRefPtr
的用法示例。
在下文中一共展示了UIForegroundRefPtr::setDrawingSurface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
ExamplePanel1->setPreferredSize(Vec2f(400, 400));
ExamplePanel1->pushToChildren(ExampleButton2);
ExamplePanel1->pushToChildren(ExamplePanel3);
ExamplePanel1->pushToChildren(ExamplePanel4);
ExamplePanel1->setLayout(ExamplePanel1Layout);
ExamplePanel1->setBackgrounds(ExamplePanelBackground);
ExamplePanel1->setBorders(ExamplePanelBorder);
ExamplePanel2->setPreferredSize(Vec2f(400, 400));
ExamplePanel2->pushToChildren(ExampleButton3);
ExamplePanel2->pushToChildren(ExamplePanel5);
ExamplePanel2->pushToChildren(ExamplePanel6);
ExamplePanel2->setLayout(ExamplePanel2Layout);
ExamplePanel2->setBackgrounds(ExamplePanelBackground);
ExamplePanel2->setBorders(ExamplePanelBorder);
ExamplePanel3->pushToChildren(ExampleButton4);
ExamplePanel3->pushToChildren(ExampleButton5);
ExamplePanel3->setLayout(ExamplePanel3Layout);
ExamplePanel3->setPreferredSize(Vec2f(125, 130));
ExamplePanel3->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel4->pushToChildren(ExampleButton6);
ExamplePanel4->pushToChildren(ExampleButton7);
ExamplePanel4->setLayout(ExamplePanel4Layout);
ExamplePanel4->setPreferredSize(Vec2f(125, 130));
ExamplePanel4->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel5->pushToChildren(ExampleButton8);
ExamplePanel5->pushToChildren(ExampleButton9);
ExamplePanel5->setLayout(ExamplePanel5Layout);
ExamplePanel5->setPreferredSize(Vec2f(125, 130));
ExamplePanel5->setBackgrounds(ExampleSmallPanelBackground);
ExamplePanel6->pushToChildren(ExampleButton10);
ExamplePanel6->pushToChildren(ExampleButton11);
ExamplePanel6->setLayout(ExamplePanel6Layout);
ExamplePanel6->setPreferredSize(Vec2f(125, 130));
ExamplePanel6->setBackgrounds(ExampleSmallPanelBackground);
// 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->setBorder(ExamplePanelBorder);
MainInternalWindow->pushToChildren(ExampleLabel1);
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExamplePanel1);
MainInternalWindow->pushToChildren(ExamplePanel2);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.8f,0.8f));
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,
"12ComplexLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例2: main
//.........这里部分代码省略.........
// creating a submenu. Note this does not
// involve begin/endEditCPs to do
ExampleSubMenu->addItem(SubMenuItem1);
ExampleSubMenu->addItem(SubMenuItem2);
ExampleSubMenu->addItem(SubMenuItem3);
/******************************************************
Create the PopupMenu itself.
Items are added in the order in which
they will be displayed (top to bottom)
via addItem(ItemToBeAdded)
The PopupMenu is attached to a
Button below using
setPopupMenu(PopupMenuName).
Note: PopupMenus can be added to any
Component.
******************************************************/
PopupMenuRefPtr ExamplePopupMenu = PopupMenu::create();
ExamplePopupMenu->addItem(MenuItem1);
ExamplePopupMenu->addItem(MenuItem2);
ExamplePopupMenu->addItem(MenuItem3);
ExamplePopupMenu->addSeparator();
ExamplePopupMenu->addItem(ExampleSubMenu);
ExamplePopupMenu->addItem(MenuItem4);
// Create a Button and Font
UIFontRefPtr PopupMenuButtonFont = OSG::UIFont::create();
PopupMenuButtonFont->setSize(16);
ButtonRefPtr PopupMenuButton = OSG::Button::create();
PopupMenuButton->setText("RightClickMe!");
// Add the PopupMenu to PopupMenuButton so that when right clicked,
// the PopupMenu will appear
PopupMenuButton->setPopupMenu(ExamplePopupMenu);
PopupMenuButton->setPreferredSize(Vec2f(200,100));
PopupMenuButton->setFont(PopupMenuButtonFont);
// 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::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(PopupMenuButton);
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,
"01RubberBandCamera");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例3: createInterface
//.........这里部分代码省略.........
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;
}
示例4: main
//.........这里部分代码省略.........
ExampleList->setModel(ExampleListModel);
ExampleList->setSelectionModel(ExampleListSelectionModel);
/******************************************************
Determine the SelectionModel
-SINGLE_SELECTION lets you select ONE item
via a single mouse click
-SINGLE_INTERVAL_SELECTION lets you select
one interval via mouse and SHIFT key
-MULTIPLE_INTERVAL_SELECTION lets you select
via mouse, and SHIFT and CONTRL keys
Note: this tutorial is currently set up
to allow for this to be changed via
TogggleButtons with ActionListeners attached
to them so this code is commented out.
******************************************************/
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::SINGLE_INTERVAL_SELECTION);
//SelectionModel.setMode(DefaultListSelectionModel::MULTIPLE_INTERVAL_SELECTION);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr ExampleScrollPanel = ScrollPanel::create();
ExampleScrollPanel->setPreferredSize(Vec2f(200,300));
ExampleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
//ExampleScrollPanel->setVerticalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
ExampleScrollPanel->setViewComponent(ExampleList);
// Create MainFramelayout
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(0.5f);
LabelRefPtr ListLabel = Label::create();
ListLabel->setText("Background Colors List");
ListLabel->setPreferredSize(Vec2f(200.0f, ListLabel->getPreferredSize().y()));
// 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(ListLabel);
MainInternalWindow->pushToChildren(ExampleScrollPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.7f,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);
TutorialViewport->setBackground(TheBackground);
// 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,
"44MFieldList");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例5: main
//.........这里部分代码省略.........
distorted. For Layouts which will often
be dynamically changed, FlowLayout is not
the best choice.
-setHorizontalGap(int): Determine the Horizontal
gap in pixels between Components in
FlowLayout.
-setVerticalGap(int): Determine the Vertical
gap in pixels between Components in
FlowLayout.
-setOrientation(ENUM): Determine whether the
Layout is arranged Vertically or
Horizontally. Takes HORIZONTAL_ORIENTATION
or VERTICAL_ORIENTATION arguments.
-setMajorAxisAlignment(ENUM): Determines
the alignment of the entire Layout
within its ComponentContainer. See below.
-setMinorAxistAlignment(ENUM): Determines
the alignment of Components within
the Layout. See below.
Both of the last two functions take the
following arguments: AXIS_MAX_ALIGNMENT,
AXIS_CENTER_ALIGNMENT, and AXIS_MIN_ALIGNMENT.
MAX puts it to the bottom/right, CENTER
centers it, and MIN puts it to the
top/left (for Vertical/Horizontal as
set above, respectively).
******************************************************/
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setHorizontalGap(3.0f);
MainInternalWindowLayout->setVerticalGap(3.0f);
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(1.0f);
// 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(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
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);
// Add a 10 pixel "padding" inside the MainFrame
MainInternalWindow->setAllInsets(10);
//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,
"05FlowLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例6: main
//.........这里部分代码省略.........
// SpringLayoutConstraints Information
// It is possible to set the constraint for the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of a component.
// It is possible to constrain a component's edge x pixels above, below, to the right of, or to the left of the edges other components, frames, and/or the MainInternalWindow.
// It is possible to constrain a component to the Y_EDGE, X_EDGE, BASELINE_EDGE, NORTH_EDGE, SOUTH_EDGE, EAST_EDGE, WEST_EDGE, HORIZONTAL_CENTER_EDGE, VERTICAL_CENTER_EDGE, HEIGHT_EDGE, and/or WIDTH_EDGE of whatever component to which it is constrained.
//Example Button 1
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton1, 25, SpringLayoutConstraints::NORTH_EDGE, MainInternalWindow); // The North edge of ExampleButton1 is 25 pixels below the North edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1, -5, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, MainInternalWindow); // The South edge of ExampleButton1 is 5 pixels above the Vertical Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton1, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow); // The East edge of ExampleButton1 is 25 pixels to the left of the East edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton1, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton1 is 25 pixels to the right of the West edge of the MainInternalWindow.
//Example Button 2
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton2, LayoutSpring::height(ExampleButton2)); // The Height edge of ExampleButton2 is set to the height of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton2, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow); // The South edge of ExampleButton2 is 25 pixels above the South edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton2, -5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton2 is 5 pixels to the left of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton2, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton2 is 25 pixels to the right of the West edge of the MainInternalWindow.
//Example Button 3
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton3, LayoutSpring::height(ExampleButton3)); // The Height edge of ExampleButton3 is set to the height of ExampleButton3.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton3, -25, SpringLayoutConstraints::SOUTH_EDGE, MainInternalWindow); // The South edge of ExampleButton3 is 25 pixels above the South edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton3, 5, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton3 is 5 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton3, -25, SpringLayoutConstraints::EAST_EDGE, MainInternalWindow); // The East edge of ExampleButton3 is 25 pixels to the left of the East edge of the MainInternalWindow.
//Example Button 4
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton4, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton4 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton4, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2); // The South edge of ExampleButton4 is 25 pixels above the North edge of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton4, 25, SpringLayoutConstraints::WEST_EDGE, MainInternalWindow); // The West edge of ExampleButton4 is 25 pixels to the right of the West edge of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton4, -100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton4 is 100 pixels to the left of the Horizontal Center of the MainInternalWindow.
//Example Button 5
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton5, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton5 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton5, 0, SpringLayoutConstraints::HEIGHT_EDGE, ExampleButton4); // The Height of ExampleButton5 is set to the Height of ExampleButton4.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ExampleButton5, 75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The East edge of ExampleButton5 is 75 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton5, -75, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton5 is 75 pixels to the left of the Horizontal Center of the MainInternalWindow.
//Example Button 6
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ExampleButton6, 25, SpringLayoutConstraints::SOUTH_EDGE, ExampleButton1); // The North edge of ExampleButton6 is 25 pixels below the South edge of ExampleButton1.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ExampleButton6, -25, SpringLayoutConstraints::NORTH_EDGE, ExampleButton2); // The South edge of ExampleButton6 is 25 pixels above the North edge of ExampleButton2.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ExampleButton6, 100, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, MainInternalWindow); // The West edge of ExampleButton6 is 100 pixels to the right of the Horizontal Center of the MainInternalWindow.
MainInternalWindowLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, ExampleButton6, 0, SpringLayoutConstraints::WIDTH_EDGE, ExampleButton4); // The Width of ExampleButton6 is set to the Width of ExampleButton4.
// 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));
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
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,
"36SpringLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例7: main
//.........这里部分代码省略.........
ExampleTabPanel->addTab(MultiFieldLabel, createMultiFieldPanel());
ExampleTabPanel->addTab(SinglePtrFieldLabel, createSinglePtrFieldPanel());
ExampleTabPanel->addTab(MultiPtrFieldLabel, createMultiPtrFieldPanel());
ExampleTabPanel->setTabAlignment(0.5f);
ExampleTabPanel->setTabPlacement(TabPanel::PLACEMENT_NORTH);
ExampleTabPanel->setSelectedIndex(0);
//UndoList
UndoRedoListModel = DefaultListModel::create();
UndoRedoListModel->pushBack(boost::any(std::string("Top")));
ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());
UndoRedoList = List::create();
UndoRedoList->setPreferredSize(Vec2f(200, 300));
UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
UndoRedoList->setModel(UndoRedoListModel);
UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);
UndoRedoListListener TheUndoRedoListListener;
UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);
UndoButton = OSG::Button::create();
UndoButton->setText("Undo");
UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
UndoButtonActionListener TheUndoButtonActionListener;
UndoButton->addActionListener(&TheUndoButtonActionListener);
RedoButton = OSG::Button::create();
RedoButton->setText("Redo");
RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
RedoButtonActionListener TheRedoButtonActionListener;
RedoButton->addActionListener(&TheRedoButtonActionListener);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
UndoRedoScrollPanel->setViewComponent(UndoRedoList);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(ExampleTabPanel);
MainInternalWindow->pushToChildren(UndoRedoScrollPanel);
MainInternalWindow->pushToChildren(UndoButton);
MainInternalWindow->pushToChildren(RedoButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// 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);
TutorialViewport->setBackground(TutorialBackground);
// 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,
"01ChangeFieldCommands");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例8: main
//.........这里部分代码省略.........
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;
}
示例9: main
//.........这里部分代码省略.........
on the alignment) and the max is the east
or west Component. Takes VERTICAL_ORIENTATION
and HORIZONTAL_ORIENTATION arguments.
-setDividerPosition("smart" REAL): Determines the initial
location of the divider. Note that this REAL is
a percentage if between 0.0 and 1.0 (inclusive)
and absolute is greater than 1.0. Also note that
when resizing a window with a percentage, the
divider will move, but with absolute, it does
not until it no longer fits in the panel.
-setDividerSize(SIZE): Determine divider Size
in pixels.
-setExpandable(bool): Determine whether
divider can be moved by user. Default is
TRUE (is movable) while FALSE removes
the users ability to move the divider.
-setMaxDividerPosition("smart" REAL): Determine
the Maximum position for the divider.
-setMinDividerPosition("smart" REAL): Determine
the Minimum position for the divider. Note
that for both Max/Min, the "smart" REAL
follows same format as in setDividerPosition;
it is a percentage if between 0.0 and 1.0
and absolute when > 1.0
******************************************************/
SplitPanelRefPtr ExampleSplitPanel = OSG::SplitPanel::create();
ExampleSplitPanel->setConstraints(ExampleSplitPanelConstraints);
ExampleSplitPanel->setMinComponent(ExampleSplitPanelPanel1);
ExampleSplitPanel->setMaxComponent(ExampleSplitPanelPanel2);
// ExampleSplitPanel->setOrientation(SplitPanel::VERTICAL_ORIENTATION);
// ExampleSplitPanel->setDividerPosition(.25); // this is a percentage
ExampleSplitPanel->setDividerPosition(300); // this is an absolute (300 > 1.0)
// location from the left/top
ExampleSplitPanel->setDividerSize(5);
// ExampleSplitPanel->setExpandable(false);
ExampleSplitPanel->setMaxDividerPosition(.9);
ExampleSplitPanel->setMinDividerPosition(220);
// also, if you want to change the way the divider looks, you can always set a
// DrawObjectCanvas in place of the default divider
// ExampleSplitPanel->setDividerDrawObject(drawObjectName);
// 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(ExampleSplitPanel);
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);
MainInternalWindow->setAllInsets(5);
// 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,
"23SplitPanel");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例10: main
//.........这里部分代码省略.........
of pixels between each row.
******************************************************/
GridLayoutRefPtr MainInternalWindowLayout = OSG::GridLayout::create();
MainInternalWindowLayout->setRows(3);
MainInternalWindowLayout->setColumns(2);
MainInternalWindowLayout->setHorizontalGap(4);
MainInternalWindowLayout->setVerticalGap(4);
/******************************************************
Create and edit some Button Components.
Note that as with BoxLayout, Components
are resized to fit their respective
grid boxes. Unless a MaxSize is set,
this will be the case. This will
override even PreferredSizes (see
ExampleButton3).
******************************************************/
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();
ExampleButton1->setPreferredSize(Vec2f(50,50));
ExampleButton1->setMaxSize(Vec2f(50,50)); //if MaxSize is commented out, this button then will revert to being the same size as the others in the grid.
ExampleButton2->setPreferredSize(Vec2f(200,100)); //<----
// |
ExampleButton3->setPreferredSize(Vec2f(50,100)); //Notice that even though these two differ in size they appear the same on the grid
// 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(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
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,
"07GridLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例11: main
// Initialize WIN32 & OpenSG and set up the scene
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 graphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create the DefaultMutableComboBoxModel and
add Elements to it (several Colors
in this case). These will be the data
values shown in the ComboBox.
******************************************************/
DefaultMutableComboBoxModelRefPtr ExampleComboBoxModel = DefaultMutableComboBoxModel::create();
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(std::string("More Colors")));
/******************************************************
Create an editable ComboBox. A ComboBox
has a Model just like various other
Components.
******************************************************/
ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
ExampleComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
ExampleComboBox->setEditable(false);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
// 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::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
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(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->setDrawingSurface(TutorialDrawingSurface);
//.........这里部分代码省略.........
示例12: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
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 and edit a CheckboxButton.
Note: the only function call shown
specific to CheckboxButton is setSelected.
In DefaultLookAndFeel, the options
for changing the style of the CheckBox
are shown. CheckboxButton also
inherits off Button so all features
of Button may be used.
-setSelected(bool): Determines if the
CheckboxButton is checked(true) or
not checked(false).
******************************************************/
CheckboxButtonRefPtr ExampleCheckboxButton = OSG::CheckboxButton::create();
ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
ExampleCheckboxButton->setEnabled(true);
ExampleCheckboxButton->setText("Checkbox Button");
ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
ExampleCheckboxButton->setSelected(true);
// 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::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleCheckboxButton);
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();
//.........这里部分代码省略.........
示例13: main
//.........这里部分代码省略.........
SplitButton->setText("Split");
SplitButton->connectButtonSelected(boost::bind(handleSplitSelected,
_1,
theTextEditor.get()));
SplitButton->connectButtonDeselected(boost::bind(handleSplitDeselected,
_1,
theTextEditor.get()));
ButtonRefPtr LoadButton = Button::create();
LoadButton->setMinSize(Vec2f(50, 25));
LoadButton->setMaxSize(Vec2f(200, 100));
LoadButton->setPreferredSize(Vec2f(80, 40));
LoadButton->setToolTipText("Click to open a file browser window");
LoadButton->setText("Load File");
LoadButton->connectActionPerformed(boost::bind(handleLoadButtonAction, _1, TutorialWindow.get(), theTextEditor.get()));
ButtonRefPtr SaveButton = Button::create();
SaveButton->setMinSize(Vec2f(50, 25));
SaveButton->setMaxSize(Vec2f(200, 100));
SaveButton->setPreferredSize(Vec2f(80, 40));
SaveButton->setToolTipText("Click to save the currently opened file");
SaveButton->setText("Save File");
SaveButton->connectActionPerformed(boost::bind(handleSaveButtonAction, _1, TutorialWindow.get(),theTextEditor.get()));
//Button Panel
LayoutRefPtr ButtonPanelLayout = FlowLayout::create();
PanelRecPtr ButtonPanel = Panel::createEmpty();
ButtonPanel->setPreferredSize(Vec2f(300, 300));
ButtonPanel->setLayout(ButtonPanelLayout);
ButtonPanel->pushToChildren(LoadButton);
ButtonPanel->pushToChildren(SaveButton);
ButtonPanel->pushToChildren(SplitButton);
ButtonPanel->pushToChildren(ClipboardButton);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = InternalWindow::create();
//MainInternalWindow->pushToChildren(TextAreaScrollPanel);
MainInternalWindow->pushToChildren(theTextEditor);
MainInternalWindow->pushToChildren(ButtonPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
//MainInternalWindow->setDrawTitlebar(true);
//MainInternalWindow->setResizable(true);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
sceneManager.setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager.getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
sceneManager.showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.95f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"06Editor");
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, theTextEditor.get()));
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例14: main
//.........这里部分代码省略.........
******************************************************/
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
/******************************************************
Create a non-editable ComboBox.
-setEditable(bool): Determine whether
the user can type in the ComboBox
or if it is uneditable. In this
case, it is set to false.
When creating a non-editable ComboBox,
a Renderer must also be assigned. For
editable ComboBoxes, the ComboBox
automatically shows its text due to the
nature of the ComboBox. However, when
uneditable, this aspect of the ComboBox
is disabled, and so to display the
selection, a renderer must be created and
assigned to the ComboBox.
Note: as with Sliders and ScrollBars,
having the same Model assigned causes
the ComboBoxes to be tied together.
******************************************************/
// Create another ComboBox
ComboBoxRefPtr ExampleUneditableComboBox = ComboBox::create();
// Set it to be uneditable
ExampleUneditableComboBox->setEditable(false);
ExampleUneditableComboBox->setModel(ExampleComboBoxModel);
// 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::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->pushToChildren(ExampleUneditableComboBox);
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(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->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 viewport = mgr->getWindow()->getPort(0);
viewport->addForeground(foreground);
// 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,
"33ComboBox");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例15: main
//.........这里部分代码省略.........
-setText("TextToBeDisplayed"): Determine
initial Text within TextField.
-setFont(FontName): Determine the Font
used within TextField.
-setSelectionStart(StartCharacterNumber):
Determine the character with which
the selection will initially start.
-setSelectionEnd(EndCharacterNumber):
Determine the character which the
selection ends before.
-setAlignment(float): Determine
the alignment of the text.
The float is a percentage is from the
top of the text [0.0-1.0]. Note: be
sure to visually verify this, as due
to font size and line size this does
not always place it exactly
at the percentage point.
******************************************************/
// Create a TextField component
TextFieldRefPtr ExampleTextField = OSG::TextField::create();
ExampleTextField->setPreferredSize(Vec2f(100, 50));
ExampleTextField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExampleTextField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
ExampleTextField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
ExampleTextField->setText("What");
ExampleTextField->setFont(sampleFont);
// The next two functions will select the "a" from above
ExampleTextField->setSelectionStart(2);
ExampleTextField->setSelectionEnd(3);
ExampleTextField->setAlignment(Vec2f(0.0,0.5));
// Create another TextField Component
TextFieldRefPtr ExampleTextField2 = OSG::TextField::create();
ExampleTextField2->setText("");
ExampleTextField2->setEmptyDescText("Write in me, please");
ExampleTextField2->setPreferredSize(Vec2f(200.0f,ExampleTextField2->getPreferredSize().y()));
// 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::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleTextField);
MainInternalWindow->pushToChildren(ExampleTextField2);
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,
"16TextField");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}