本文整理汇总了C++中LabelRefPtr::getPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelRefPtr::getPreferredSize方法的具体用法?C++ LabelRefPtr::getPreferredSize怎么用?C++ LabelRefPtr::getPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelRefPtr
的用法示例。
在下文中一共展示了LabelRefPtr::getPreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMultiFieldPanel
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;
}
示例2: 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;
}
示例3: buildChooser
//.........这里部分代码省略.........
BlueSliderTrackCanvas->setBackgrounds(_BlueSliderTrackBackground);
_BlueSlider = Slider::create();
_BlueSlider->setDrawLabels(false);
_BlueSlider->setDrawMajorTicks(false);
_BlueSlider->setDrawMinorTicks(false);
_BlueSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION);;
_BlueSlider->setTrackDrawObject(BlueSliderTrackCanvas);
_BlueSlider->setRangeModel(_BlueModel->getBoundedRangeModel());
if(getIncludeAlpha())
{
_AlphaSliderTrackBackground = GradientLayer::create();
_AlphaSliderTrackBackground->setStartPosition(Vec2f(0.0f,0.0f));
_AlphaSliderTrackBackground->setEndPosition(Vec2f(1.0f,0.0f));
UIDrawObjectCanvasRefPtr AlphaSliderTrackCanvas = UIDrawObjectCanvas::create();
AlphaSliderTrackCanvas->setPreferredSize(Vec2f(15.0f,15.0f));
AlphaSliderTrackCanvas->setBorders(NULL);
AlphaSliderTrackCanvas->setBackgrounds(_AlphaSliderTrackBackground);
_AlphaSlider = Slider::create();
_AlphaSlider->setDrawLabels(false);
_AlphaSlider->setDrawMajorTicks(false);
_AlphaSlider->setDrawMinorTicks(false);
_AlphaSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION);;
_AlphaSlider->setTrackDrawObject(AlphaSliderTrackCanvas);
_AlphaSlider->setRangeModel(_AlphaModel->getBoundedRangeModel());
}
//Labels
LabelRefPtr RedLabel = Label::create();
RedLabel->setText("Red");
RedLabel->setPreferredSize(Vec2f(50.0f, RedLabel->getPreferredSize().y()));
RedLabel->setBackgrounds(NULL);
RedLabel->setBorders(NULL);
LabelRefPtr GreenLabel = Label::create();
GreenLabel->setText("Green");
GreenLabel->setPreferredSize(Vec2f(50.0f, GreenLabel->getPreferredSize().y()));
GreenLabel->setBackgrounds(NULL);
GreenLabel->setBorders(NULL);
LabelRefPtr BlueLabel = Label::create();
BlueLabel->setText("Blue");
BlueLabel->setPreferredSize(Vec2f(50.0f, BlueLabel->getPreferredSize().y()));
BlueLabel->setBackgrounds(NULL);
BlueLabel->setBorders(NULL);
LabelRefPtr AlphaLabel = Label::create();
if(getIncludeAlpha())
{
AlphaLabel->setText("Alpha");
AlphaLabel->setPreferredSize(Vec2f(50.0f, AlphaLabel->getPreferredSize().y()));
AlphaLabel->setBackgrounds(NULL);
AlphaLabel->setBorders(NULL);
}
//Layout
SpringLayoutRefPtr RGBPanelLayout = SpringLayout::create();
//Red
//Label
RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, RedLabel, 5.0f, SpringLayoutConstraints::WEST_EDGE, this);
RGBPanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, RedLabel, 5.0f, SpringLayoutConstraints::NORTH_EDGE, this);
RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, RedLabel, LayoutSpringUnrecPtr(LayoutSpring::width(RedLabel)));