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; }
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(); GradientBackgroundRefPtr TheBackground = GradientBackground::create(); TheBackground->addLine(Color3f(1.0,0.0,0.0), 0.0); TheBackground->addLine(Color3f(0.0,1.0,0.0), 0.2); TheBackground->addLine(Color3f(0.0,0.0,1.0), 0.4); TheBackground->addLine(Color3f(0.0,1.0,1.0), 0.6); TheBackground->addLine(Color3f(1.0,1.0,0.0), 0.8); TheBackground->addLine(Color3f(1.0,1.0,1.0), 1.0); /****************************************************** Create a List. A List has several parts to it: -ListModel: Contains the data which is to be displayed in the List. Data is added as shown below -ListCellRenderer: Creates the Components to be used within the List (the default setting is to create Labels using the desired text). -ListSelectionModel: Determines how the List may be selected. To add values to the list: First, create SFStrings and use the .setValue("Value") function to set their values. Then, use the .pushBack(&SFStringName) to add them to the List. Next, create the CellRenderer and ListSelectionModel defaults. Finally, actually create the List. Set its Model, CellRenderer, and SelectionModel as shown below. Finally, choose the type of display for the List (choices outlined below). ******************************************************/ // Add data to it ExampleListModel = MFieldListModel::create(); ExampleListModel->setContainer(TheBackground); ExampleListModel->setFieldId(GradientBackground::ColorFieldId); /****************************************************** Create ListCellRenderer and ListSelectionModel. Most often the defauls will be used. Note: the ListSelectionModel was created above and is referenced by the ActionListeners. ******************************************************/ /****************************************************** Create List itself and assign its Model, CellRenderer, and SelectionModel to it. -setOrientation(ENUM): Determine the Layout of the cells (Horizontal or Vertical). Takes List::VERTICAL_ORIENTATION and List::HORIZONTAL_ORIENTATION arguments. ******************************************************/ ExampleList = List::create(); ExampleList->setPreferredSize(Vec2f(200, 300)); ExampleList->setOrientation(List::VERTICAL_ORIENTATION); //ExampleList->setOrientation(List::HORIZONTAL_ORIENTATION); 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; }
void RGBColorChooserPanel::buildChooser(void) { //Bounded Range Models _RedModel->setMinimum(0); _RedModel->setMaximum(255); _GreenModel->setMinimum(0); _GreenModel->setMaximum(255); _BlueModel->setMinimum(0); _BlueModel->setMaximum(255); _AlphaModel->setMinimum(0); _AlphaModel->setMaximum(255); //Spinners _RedSpinner = Spinner::create(); _RedSpinner->setModel(_RedModel->getSpinnerModel()); _GreenSpinner = Spinner::create(); _GreenSpinner->setModel(_GreenModel->getSpinnerModel()); _BlueSpinner = Spinner::create(); _BlueSpinner->setModel(_BlueModel->getSpinnerModel()); if(getIncludeAlpha()) { _AlphaSpinner = Spinner::create(); _AlphaSpinner->setModel(_AlphaModel->getSpinnerModel()); } //Sliders _RedSliderTrackBackground = GradientLayer::create(); _RedSliderTrackBackground->setStartPosition(Vec2f(0.0f,0.0f)); _RedSliderTrackBackground->setEndPosition(Vec2f(1.0f,0.0f)); UIDrawObjectCanvasRefPtr RedSliderTrackCanvas = UIDrawObjectCanvas::create(); RedSliderTrackCanvas->setPreferredSize(Vec2f(15.0f,15.0f)); RedSliderTrackCanvas->setBorders(NULL); RedSliderTrackCanvas->setBackgrounds(_RedSliderTrackBackground); _RedSlider = Slider::create(); _RedSlider->setDrawLabels(false); _RedSlider->setDrawMajorTicks(false); _RedSlider->setDrawMinorTicks(false); _RedSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION); _RedSlider->setTrackDrawObject(RedSliderTrackCanvas); _RedSlider->setRangeModel(_RedModel->getBoundedRangeModel()); //Green _GreenSliderTrackBackground = GradientLayer::create(); _GreenSliderTrackBackground->setStartPosition(Vec2f(0.0f,0.0f)); _GreenSliderTrackBackground->setEndPosition(Vec2f(1.0f,0.0f)); UIDrawObjectCanvasRefPtr GreenSliderTrackCanvas = UIDrawObjectCanvas::create(); GreenSliderTrackCanvas->setPreferredSize(Vec2f(15.0f,15.0f)); GreenSliderTrackCanvas->setBorders(NULL); GreenSliderTrackCanvas->setBackgrounds(_GreenSliderTrackBackground); _GreenSlider = Slider::create(); _GreenSlider->setDrawLabels(false); _GreenSlider->setDrawMajorTicks(false); _GreenSlider->setDrawMinorTicks(false); _GreenSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION);; _GreenSlider->setTrackDrawObject(GreenSliderTrackCanvas); _GreenSlider->setRangeModel(_GreenModel->getBoundedRangeModel()); //Blue _BlueSliderTrackBackground = GradientLayer::create(); _BlueSliderTrackBackground->setStartPosition(Vec2f(0.0f,0.0f)); _BlueSliderTrackBackground->setEndPosition(Vec2f(1.0f,0.0f)); UIDrawObjectCanvasRefPtr BlueSliderTrackCanvas = UIDrawObjectCanvas::create(); BlueSliderTrackCanvas->setPreferredSize(Vec2f(15.0f,15.0f)); BlueSliderTrackCanvas->setBorders(NULL); 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))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, RedLabel, LayoutSpringUnrecPtr(LayoutSpring::height(RedLabel))); //Slider RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _RedSlider, 5.0f, SpringLayoutConstraints::EAST_EDGE, RedLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _RedSlider, -5.0f, SpringLayoutConstraints::WEST_EDGE, _RedSpinner); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _RedSlider, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, RedLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _RedSlider, LayoutSpringUnrecPtr(LayoutSpring::height(_RedSlider))); //Spinner RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _RedSpinner, -5.0f, SpringLayoutConstraints::EAST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _RedSpinner, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, RedLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, _RedSpinner, LayoutSpringUnrecPtr(LayoutSpring::width(_RedSpinner))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _RedSpinner, LayoutSpringUnrecPtr(LayoutSpring::height(_RedSpinner))); //Green //Label RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, GreenLabel, 5.0f, SpringLayoutConstraints::WEST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, GreenLabel, 5.0f, SpringLayoutConstraints::SOUTH_EDGE, RedLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, GreenLabel, LayoutSpringUnrecPtr(LayoutSpring::width(GreenLabel))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, GreenLabel, LayoutSpringUnrecPtr(LayoutSpring::height(GreenLabel))); //Slider RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _GreenSlider, 5.0f, SpringLayoutConstraints::EAST_EDGE, GreenLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _GreenSlider, -5.0f, SpringLayoutConstraints::WEST_EDGE, _GreenSpinner); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _GreenSlider, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, GreenLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _GreenSlider, LayoutSpringUnrecPtr(LayoutSpring::height(_GreenSlider))); //Spinner RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _GreenSpinner, -5.0f, SpringLayoutConstraints::EAST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _GreenSpinner, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, GreenLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, _GreenSpinner, LayoutSpringUnrecPtr(LayoutSpring::width(_GreenSpinner))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _GreenSpinner, LayoutSpringUnrecPtr(LayoutSpring::height(_GreenSpinner))); //Blue //Label RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, BlueLabel, 5.0f, SpringLayoutConstraints::WEST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, BlueLabel, 5.0f, SpringLayoutConstraints::SOUTH_EDGE, GreenLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, BlueLabel, LayoutSpringUnrecPtr(LayoutSpring::width(BlueLabel))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, BlueLabel, LayoutSpringUnrecPtr(LayoutSpring::height(BlueLabel))); //Slider RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _BlueSlider, 5.0f, SpringLayoutConstraints::EAST_EDGE, BlueLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _BlueSlider, -5.0f, SpringLayoutConstraints::WEST_EDGE, _BlueSpinner); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _BlueSlider, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, BlueLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _BlueSlider, LayoutSpringUnrecPtr(LayoutSpring::height(_BlueSlider))); //Spinner RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _BlueSpinner, -5.0f, SpringLayoutConstraints::EAST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _BlueSpinner, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, BlueLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, _BlueSpinner, LayoutSpringUnrecPtr(LayoutSpring::width(_BlueSpinner))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _BlueSpinner, LayoutSpringUnrecPtr(LayoutSpring::height(_BlueSpinner))); if(getIncludeAlpha()) { //Alpha //Label RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, AlphaLabel, 5.0f, SpringLayoutConstraints::WEST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, AlphaLabel, 5.0f, SpringLayoutConstraints::SOUTH_EDGE, BlueLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, AlphaLabel, LayoutSpringUnrecPtr(LayoutSpring::width(AlphaLabel))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, AlphaLabel, LayoutSpringUnrecPtr(LayoutSpring::height(AlphaLabel))); //Slider RGBPanelLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _AlphaSlider, 5.0f, SpringLayoutConstraints::EAST_EDGE, AlphaLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AlphaSlider, -5.0f, SpringLayoutConstraints::WEST_EDGE, _AlphaSpinner); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AlphaSlider, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, AlphaLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _AlphaSlider, LayoutSpringUnrecPtr(LayoutSpring::height(_AlphaSlider))); //Spinner RGBPanelLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AlphaSpinner, -5, SpringLayoutConstraints::EAST_EDGE, this); RGBPanelLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AlphaSpinner, 0.0f, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, AlphaLabel); RGBPanelLayout->putConstraint(SpringLayoutConstraints::WIDTH_EDGE, _AlphaSpinner, LayoutSpringUnrecPtr(LayoutSpring::width(_AlphaSpinner))); RGBPanelLayout->putConstraint(SpringLayoutConstraints::HEIGHT_EDGE, _AlphaSpinner, LayoutSpringUnrecPtr(LayoutSpring::height(_AlphaSpinner))); } clearChildren(); pushToChildren(RedLabel); pushToChildren(_RedSlider); pushToChildren(_RedSpinner); pushToChildren(GreenLabel); pushToChildren(_GreenSlider); pushToChildren(_GreenSpinner); pushToChildren(BlueLabel); pushToChildren(_BlueSlider); pushToChildren(_BlueSpinner); if(getIncludeAlpha()) { pushToChildren(AlphaLabel); pushToChildren(_AlphaSlider); pushToChildren(_AlphaSpinner); } setLayout(RGBPanelLayout); }