void HelperPanel::createLoggingTab() { //Logging List Component Generator LogListComponentGeneratorRecPtr LoggingCompGenerator = LogListComponentGenerator::create(); //Logging Model LogListModelRecPtr LoggingModel = LogListModel::create(); LoggingModel->connectLogging(); ListRecPtr _LoggingList = List::create(); _LoggingList->setPreferredSize(Vec2f(200, 300)); _LoggingList->setOrientation(List::VERTICAL_ORIENTATION); _LoggingList->setModel(LoggingModel); _LoggingList->setCellGenerator(LoggingCompGenerator); _LoggingList->setSelectable(false); // Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel) _LoggingScrollPanel = ScrollPanel::create(); _LoggingScrollPanel->setPreferredSize(Vec2f(200,300)); _LoggingScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); _LoggingScrollPanel->setViewComponent(_LoggingList); //Content Panel _LoggingContent = Panel::createEmpty(); SpringLayoutRefPtr LoggingContentLayout = SpringLayout::create(); LoggingContentLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _LoggingScrollPanel, 5, SpringLayoutConstraints::NORTH_EDGE, _LoggingContent); LoggingContentLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LoggingScrollPanel, -5, SpringLayoutConstraints::SOUTH_EDGE, _LoggingContent); LoggingContentLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _LoggingScrollPanel, -5, SpringLayoutConstraints::EAST_EDGE, _LoggingContent); LoggingContentLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _LoggingScrollPanel, 5, SpringLayoutConstraints::WEST_EDGE, _LoggingContent); _LoggingContent->setLayout(LoggingContentLayout); _LoggingContent->pushToChildren(_LoggingScrollPanel); }
void TextureFieldContainerEditor::onCreate(const TextureFieldContainerEditor *Id) { Inherited::onCreate(Id); if(Id != NULL) { Matrix m; m.setScale(Vec3f(3.0f,3.0f,1.0f)); m.setTranslate(Pnt3f(-1.0f,-1.0f,0.0f)); TextureTransformChunkRefPtr TextureTransform = TextureTransformChunk::create(); TextureTransform->setMatrix(m); //Create the ImageComponent _ImageDisplayComponent = ImageComponent::create(); _ImageDisplayComponent->setPreferredSize(Vec2f(250.0f,250.0f)); _ImageDisplayComponent->setScale(ImageComponent::SCALE_STRETCH); _ImageDisplayComponent->setTransformation(TextureTransform); SpringLayoutRefPtr TheLayout = SpringLayout::create(); TheLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE,_ImageDisplayComponent, 0,SpringLayoutConstraints::NORTH_EDGE, this); TheLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE,_ImageDisplayComponent, 0,SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, this); TheLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE,_GenericEditor, 1,SpringLayoutConstraints::SOUTH_EDGE, _ImageDisplayComponent); TheLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE,_GenericEditor, 0,SpringLayoutConstraints::SOUTH_EDGE, this); TheLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE,_GenericEditor, 0,SpringLayoutConstraints::EAST_EDGE, this); TheLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _GenericEditor, 0,SpringLayoutConstraints::WEST_EDGE, this); setLayout(TheLayout); pushToChildren(_ImageDisplayComponent); pushToChildren(_GenericEditor); } }
OSG_BEGIN_NAMESPACE DialogWindowTransitPtr createFCEditorDialog(FieldContainer* fc, CommandManagerPtr CmdManager, const std::string& editorName) { DialogWindowRefPtr TheDialog = DialogWindow::create(); //Create the FieldEditorComponent FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(fc, CmdManager); ScrollPanelRefPtr EditorScrollPanel = ScrollPanel::create(); EditorScrollPanel->setPreferredSize(Vec2f(300,400)); EditorScrollPanel->setViewComponent(TheEditor); //Ok button ButtonRefPtr ConfirmButton = Button::create(); ConfirmButton->setText("Ok"); ConfirmButton->connectActionPerformed(boost::bind(&DialogWindow::handleConfirmButtonAction, TheDialog.get(), _1)); SpringLayoutRefPtr DialogLayout = OSG::SpringLayout::create(); //EditorScrollPanel DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, EditorScrollPanel, 2, SpringLayoutConstraints::NORTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, EditorScrollPanel, -15, SpringLayoutConstraints::NORTH_EDGE, ConfirmButton); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, EditorScrollPanel, 1, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, EditorScrollPanel, 2, SpringLayoutConstraints::WEST_EDGE, TheDialog); //ConfirmButton DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ConfirmButton, -15, SpringLayoutConstraints::SOUTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, ConfirmButton, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, TheDialog); TheDialog->setLayout(DialogLayout); TheDialog->setPreferredSize(Vec2f(330.0f, 475.0f)); TheDialog->pushToChildren(EditorScrollPanel); TheDialog->pushToChildren(ConfirmButton); return DialogWindowTransitPtr(TheDialog); }
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); }
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); }
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; }
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; }
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(); /****************************************************** Creates some Button components ******************************************************/ 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(); /****************************************************** Create SpringLayout. This layout simply places all Components within it on top of each other. They are placed in reverse order of how they are added to the MainFrame (Components added first are rendered last, those added last are rendered first). Note: SpringLayout has no options which can be set. ******************************************************/ SpringLayoutRefPtr MainInternalWindowLayout = OSG::SpringLayout::create(); // OverlayLayout has no options to edit! // NOTHING : ) /****************************************************** Create and edit some Button Components. ******************************************************/ ExampleButton1->setPreferredSize(Vec2f(50,50)); ExampleButton1->setText("Button 1"); ExampleButton2->setPreferredSize(Vec2f(50,50)); ExampleButton2->setText("Button 2"); ExampleButton3->setPreferredSize(Vec2f(50,50)); ExampleButton3->setText("Button 3"); ExampleButton4->setPreferredSize(Vec2f(50,50)); ExampleButton4->setText("Button 4"); ExampleButton5->setPreferredSize(Vec2f(50,50)); ExampleButton5->setText("Button 5"); ExampleButton6->setPreferredSize(Vec2f(50,50)); ExampleButton6->setText("Button 6"); InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create(); // 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; }
void HelperPanel::setupLuaTab() { // Create a _CodeTextArea _CodeTextArea = TextArea::create(); _CodeTextArea->setText(""); setName(_CodeTextArea,"__KABALA_ENGINE_PLAYER_CODE_TEXT_AREA"); _LuaConsoleScrollPanel = ScrollPanel::create(); _LuaConsoleScrollPanel->setPreferredSize(Vec2f(300,1200)); _LuaConsoleScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); // Add the _CodeTextArea to the ScrollPanel so it is displayed _LuaConsoleScrollPanel->setViewComponent(_CodeTextArea); _HistoryList = List::create(); _HistoryList->setPreferredSize(Vec2f(100, 100)); _HistoryList->setOrientation(List::VERTICAL_ORIENTATION); _HistoryList->setModel(_HistoryListModel); _HistoryListMouseClickedConnection = _HistoryList->connectMouseClicked(boost::bind(&HelperPanel::handleHistoryListMouseClicked, this, _1)); _HistoryScrollPanel = ScrollPanel::create(); _HistoryScrollPanel->setPreferredSize(Vec2f(400,100)); _HistoryScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); _HistoryScrollPanel->setViewComponent(_HistoryList); _HistoryLabel = Label::create(); _HistoryLabel->setText("History"); // the execute button _ExecuteBtn=Button::create(); _ExecuteBtn->setText("Execute"); _ExecuteBtn->setPreferredSize(Vec2f(90,25)); _ExecuteScriptActionConnection = _ExecuteBtn->connectActionPerformed(boost::bind(&HelperPanel::handleExecuteScriptAction, this, _1)); //Content Panel _LuaConsoleContent = Panel::createEmpty(); SpringLayoutRefPtr LuaConsoleContentLayout = SpringLayout::create(); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _LuaConsoleScrollPanel, 0, SpringLayoutConstraints::NORTH_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LuaConsoleScrollPanel, 0, SpringLayoutConstraints::SOUTH_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _LuaConsoleScrollPanel, -5, SpringLayoutConstraints::WEST_EDGE, _HistoryScrollPanel); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _LuaConsoleScrollPanel, 0, SpringLayoutConstraints::WEST_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _HistoryLabel, 5, SpringLayoutConstraints::NORTH_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _HistoryLabel, -5, SpringLayoutConstraints::EAST_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _HistoryLabel, 0, SpringLayoutConstraints::WEST_EDGE, _HistoryScrollPanel); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _HistoryScrollPanel, 5, SpringLayoutConstraints::SOUTH_EDGE, _HistoryLabel); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _HistoryScrollPanel, -5, SpringLayoutConstraints::NORTH_EDGE, _ExecuteBtn); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _HistoryScrollPanel, 0, SpringLayoutConstraints::EAST_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _ExecuteBtn, -5, SpringLayoutConstraints::SOUTH_EDGE, _LuaConsoleContent); LuaConsoleContentLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, _ExecuteBtn, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, _HistoryScrollPanel); _LuaConsoleContent->setLayout(LuaConsoleContentLayout); _LuaConsoleContent->pushToChildren(_LuaConsoleScrollPanel); _LuaConsoleContent->pushToChildren(_HistoryLabel); _LuaConsoleContent->pushToChildren(_HistoryScrollPanel); _LuaConsoleContent->pushToChildren(_ExecuteBtn); }
DialogWindowTransitPtr createFCTreeEditorDialog (FieldContainer* fc, CommandManagerPtr CmdManager, const std::string& editorName) { DialogWindowRefPtr TheDialog = DialogWindow::create(); //Create the FieldEditorComponent FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(fc, CmdManager); ScrollPanelRefPtr EditorScrollPanel = ScrollPanel::create(); EditorScrollPanel->setViewComponent(TheEditor); //Field Container Tree Model FieldContainerTreeModelRefPtr TheTreeModel = FieldContainerTreeModel::create(); TheTreeModel->setRoot(fc); TheTreeModel->setShowInternalFields(true); TheTreeModel->setShowPtrFields(true); TheTreeModel->setShowDataFields(false); TheTreeModel->setShowParentPtrFields(false); TheTreeModel->setShowChildPtrFields(true); TheTreeModel->setShowAttachments(true); TheTreeModel->setShowCallbackFunctors(false); //Field Container Tree Component Generator FieldContainerFieldPathComponentGeneratorRefPtr TheTreeComponentGenerator = FieldContainerFieldPathComponentGenerator::create(); //Create the PopupMenu for the tree MenuItemRecPtr ExportMenuItem = MenuItem::create(); ExportMenuItem->setText("Export ..."); MenuItemRecPtr ImportMenuItem = MenuItem::create(); ImportMenuItem->setText("Import ..."); PopupMenuRecPtr TreePopupMenu = PopupMenu::create(); TreePopupMenu->addItem(ExportMenuItem); TreePopupMenu->addItem(ImportMenuItem); //Create the Field Container Tree TreeRefPtr TheTree = Tree::create(); TheTree->setPreferredSize(Vec2f(100, 500)); TheTree->setRootVisible(true); TheTree->setModel(TheTreeModel); TheTree->setCellGenerator(TheTreeComponentGenerator); TheTree->setPopupMenu(TreePopupMenu); TheTree->getSelectionModel()->connectSelectionAdded(boost::bind(&handleFCSelectionAdded, _1, TheTree.get(), EditorScrollPanel.get())); ExportMenuItem->connectActionPerformed(boost::bind(&handleTreeNodeExport, _1, TheTree.get())); ImportMenuItem->connectActionPerformed(boost::bind(&handleTreeNodeImport, _1, TheTree.get())); //TheDialog->addTransientObject(boost::any(TheTreeEditorSelectionListener)); ScrollPanelRefPtr TreeScrollPanel = ScrollPanel::create(); TreeScrollPanel->setViewComponent(TheTree); //Ok button ButtonRefPtr ConfirmButton = Button::create(); ConfirmButton->setText("Ok"); ConfirmButton->connectActionPerformed(boost::bind(&DialogWindow::handleConfirmButtonAction, TheDialog.get(), _1)); SpringLayoutRefPtr DialogLayout = OSG::SpringLayout::create(); //SplitPanel SplitPanelRefPtr TheSplitPanel = SplitPanel::create(); TheSplitPanel->setOrientation(SplitPanel::HORIZONTAL_ORIENTATION); TheSplitPanel->setDividerPosition(0.4f); TheSplitPanel->setDividerSize(5.0f); TheSplitPanel->setMaxDividerPosition(0.8f); TheSplitPanel->setMinDividerPosition(0.2f); TheSplitPanel->setMinComponent(TreeScrollPanel); TheSplitPanel->setMaxComponent(EditorScrollPanel); //TreeScrollPanel DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheSplitPanel, 2, SpringLayoutConstraints::NORTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TheSplitPanel, -15, SpringLayoutConstraints::NORTH_EDGE, ConfirmButton); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TheSplitPanel, -2, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheSplitPanel, 2, SpringLayoutConstraints::WEST_EDGE, TheDialog); //ConfirmButton DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, ConfirmButton, -15, SpringLayoutConstraints::SOUTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, ConfirmButton, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, TheDialog); TheDialog->setLayout(DialogLayout); TheDialog->setPreferredSize(Vec2f(750.0f, 600.0f)); TheDialog->pushToChildren(TheSplitPanel); TheDialog->pushToChildren(ConfirmButton); 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; }
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); }