ComponentTransitPtr createButtonedComp(Component* const LabelComp, const Button::ActionPerformedEventType::slot_type &listener) { ButtonRecPtr CompRemoveButton = Button::create(); CompRemoveButton->setText("-"); //CompRemoveButton->setToolTipText("Remove"); CompRemoveButton->setPreferredSize(Vec2f(17.0f,17.0f)); CompRemoveButton->setAlignment(Vec2f(0.5f,0.5f)); CompRemoveButton->setFont(dynamic_cast<Label*>(LabelComp)->getFont()); //Connect CompRemoveButton->connectActionPerformed(listener); SpringLayoutRecPtr TreeCompLayout = SpringLayout::create(); PanelRecPtr CompPanel = Panel::createEmpty(); TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, CompRemoveButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompRemoveButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel); CompPanel->setLayout(TreeCompLayout); CompPanel->pushToChildren(LabelComp); CompPanel->pushToChildren(CompRemoveButton); return ComponentTransitPtr(CompPanel); }
ComponentTransitPtr GenericFieldContainerEditor::createFCToolTip(const FieldContainerType &FCType) { std::string FieldDoc(doxygenToPlainFormatting(FCType.getDocumentation())); //TypeName LabelRecPtr TypeLabel = Label::create(); TypeLabel->setText(FCType.getName()); TypeLabel->setAlignment(Vec2f(0.5f,0.5f)); TypeLabel->setBackgrounds(NULL); //Separator SeparatorRecPtr MainSeparator = Separator::create(); MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION); MainSeparator->setSeparatorSize(1.0f); MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f)); MainSeparator->setBackgrounds(NULL); //Inheritance Panel Layout //LabelRecPtr InheritanceLabel = Label::create(); //InheritanceLabel->setText("Inheritance"); //FlowLayoutRecPtr InheritancePanelLayout = FlowLayout::create(); //InheritancePanelLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION); //InheritancePanelLayout->setVerticalGap(3.0f); //InheritancePanelLayout->setMajorAxisAlignment(0.0f); //InheritancePanelLayout->setMinorAxisAlignment(0.5f); //InheritancePanelLayout->setComponentAlignment(0.5f); ////Inheritance Panel //PanelRecPtr InheritancePanel = Panel::createEmpty(); //InheritancePanel->setAllInsets(5.0f); //InheritancePanel->setLayout(InheritancePanelLayout); //const TypeBase *ParentType(&FCType); ////while() ////{ ////ToolTipPanel->pushToChildren(DescriptionTextArea); ////} //LabelRecPtr TypeNameLabel = Label::create(); //TypeNameLabel->setText(FCType.getName()); //TypeNameLabel->setAlignment(Vec2f(0.5f,0.5f)); //InheritancePanel->pushToChildren(TypeNameLabel); //Set the layout constraints BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create(); CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER); //Description Panel LabelRecPtr DescriptionLabel = Label::create(); DescriptionLabel->setText("Description:"); DescriptionLabel->setBackgrounds(NULL); TextAreaRecPtr DescriptionTextArea = TextArea::create(); DescriptionTextArea->setText(FieldDoc); DescriptionTextArea->setEditable(false); DescriptionTextArea->setBorders(NULL); DescriptionTextArea->setBackgrounds(NULL); DescriptionTextArea->setConstraints(CenterConstraints); //Description Panel PanelRecPtr DescriptionPanel = Panel::create(); BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create(); DescriptionPanel->setAllInsets(5.0f); DescriptionPanel->setLayout(DescriptionPanelLayout); DescriptionPanel->pushToChildren(DescriptionTextArea); DescriptionPanel->setBackgrounds(NULL); //ToolTip Layout PanelRecPtr ToolTipPanel = Panel::createEmpty(); SpringLayoutRecPtr MainLayout = SpringLayout::create(); //TypeLabel MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5, SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //MainSeparator MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1, SpringLayoutConstraints::SOUTH_EDGE, TypeLabel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); ////InheritancePanel //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritanceLabel, 1, //SpringLayoutConstraints::SOUTH_EDGE, MainSeparator); //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritanceLabel, 0, //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritanceLabel, 0, //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); ////InheritancePanel //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritancePanel, 1, //SpringLayoutConstraints::SOUTH_EDGE, InheritanceLabel); //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritancePanel, 0, //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritancePanel, 0, //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //DescriptionTextArea MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 1, SpringLayoutConstraints::SOUTH_EDGE, MainSeparator); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //DescriptionTextArea MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1, SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5, SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //ToolTip Panel Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip()); ToolTipPanel->setBorders(DefaultToolTip->getBorder()); ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground()); ToolTipPanel->setForegrounds(DefaultToolTip->getForeground()); ToolTipPanel->setLayout(MainLayout); ToolTipPanel->pushToChildren(TypeLabel); ToolTipPanel->pushToChildren(MainSeparator); //ToolTipPanel->pushToChildren(InheritanceLabel); //ToolTipPanel->pushToChildren(InheritancePanel); ToolTipPanel->pushToChildren(DescriptionLabel); ToolTipPanel->pushToChildren(DescriptionPanel); Real32 Height(100.0f + DescriptionTextArea->getLineHeight() * (DescriptionTextArea->getText().size()/40)); ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height)); return ComponentTransitPtr(ToolTipPanel); }
ComponentTransitPtr GenericFieldContainerEditor::createEventToolTip(const EventDescription *EventDesc) { std::string FieldDoc(doxygenToPlainFormatting(EventDesc->getDescription())); //TypeName LabelRecPtr TypeLabel = Label::create(); TypeLabel->setText(EventDesc->getName()); TypeLabel->setAlignment(Vec2f(0.5f,0.5f)); TypeLabel->setBackgrounds(NULL); //Separator SeparatorRecPtr MainSeparator = Separator::create(); MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION); MainSeparator->setSeparatorSize(1.0f); MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f)); MainSeparator->setBackgrounds(NULL); //Consumable Label LabelRecPtr ConsumableLabel = Label::create(); ConsumableLabel->setText(EventDesc->getConsumable() ? "Consumable" : "Not Consumable"); ConsumableLabel->setAlignment(Vec2f(0.0f,0.5f)); ConsumableLabel->setBackgrounds(NULL); //Set the layout constraints BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create(); CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER); //Description Panel LabelRecPtr DescriptionLabel = Label::create(); DescriptionLabel->setText("Description:"); DescriptionLabel->setBackgrounds(NULL); TextAreaRecPtr DescriptionTextArea = TextArea::create(); DescriptionTextArea->setText(FieldDoc); DescriptionTextArea->setEditable(false); DescriptionTextArea->setBorders(NULL); DescriptionTextArea->setBackgrounds(NULL); DescriptionTextArea->setConstraints(CenterConstraints); //Description Panel PanelRecPtr DescriptionPanel = Panel::create(); BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create(); DescriptionPanel->setAllInsets(5.0f); DescriptionPanel->setLayout(DescriptionPanelLayout); DescriptionPanel->pushToChildren(DescriptionTextArea); DescriptionPanel->setBackgrounds(NULL); //ToolTip Layout PanelRecPtr ToolTipPanel = Panel::createEmpty(); SpringLayoutRecPtr MainLayout = SpringLayout::create(); //TypeLabel MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5, SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //MainSeparator MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1, SpringLayoutConstraints::SOUTH_EDGE, TypeLabel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //ConsumableLabel MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ConsumableLabel, 1, SpringLayoutConstraints::NORTH_EDGE, MainSeparator); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ConsumableLabel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ConsumableLabel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //DescriptionTextArea MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 5, SpringLayoutConstraints::SOUTH_EDGE, ConsumableLabel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //DescriptionTextArea MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1, SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5, SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5, SpringLayoutConstraints::EAST_EDGE, ToolTipPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5, SpringLayoutConstraints::WEST_EDGE, ToolTipPanel); //ToolTip Panel Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip()); ToolTipPanel->setBorders(DefaultToolTip->getBorder()); ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground()); ToolTipPanel->setForegrounds(DefaultToolTip->getForeground()); ToolTipPanel->setLayout(MainLayout); ToolTipPanel->pushToChildren(TypeLabel); ToolTipPanel->pushToChildren(MainSeparator); ToolTipPanel->pushToChildren(ConsumableLabel); ToolTipPanel->pushToChildren(DescriptionLabel); ToolTipPanel->pushToChildren(DescriptionPanel); Real32 Height(130.0f + DescriptionTextArea->getLineHeight() * (DescriptionTextArea->getText().size()/40)); ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height)); return ComponentTransitPtr(ToolTipPanel); }
/***************************************************************************\ * Instance methods * \***************************************************************************/ ComponentTransitPtr SceneComponentTreeComponentGenerator::getTreeComponent(Tree* const Parent, const boost::any& Value, bool IsSelected, bool Expanded, bool Leaf, UInt32 Row, bool HasFocus) { std::string Text; if(Value.type() == typeid(Scene* const)) { Text = "Scene"; } else if(Value.type() == typeid(UInt32)) { switch(boost::any_cast<UInt32>(Value)) { case SceneTreeModel::BasicComponent: //Basic Text = "Basic"; break; case SceneTreeModel::BackgroundComponent: //Background Text = "Background"; break; case SceneTreeModel::CameraComponent: //Camera Text = "Camera"; break; case SceneTreeModel::ForegroundsComponent: //Foregrounds Text = "Foregrounds"; break; case SceneTreeModel::SceneObjectsComponent: //Models Text = "SceneObjects"; break; case SceneTreeModel::LightsComponent: //Models Text = "Lights"; break; case SceneTreeModel::DynamicsComponent: //Dynamics Text = "Dynamics"; break; case SceneTreeModel::ScriptsComponent: //Scripts Text = "Scripts"; break; case SceneTreeModel::BehavioursComponent: //Behaviours Text = "Behaviours"; break; case SceneTreeModel::AnimationsComponent: //Animations Text = "Animations"; break; } } else if(Value.type() == typeid(Foreground* const)) { ForegroundRecPtr FG= boost::any_cast<Foreground* const>(Value); const Char8* Name(getName(FG)); Text = std::string(Name ? Name : "No Name" ) + " [" + FG->getType().getName() + "]"; } else if(Value.type() == typeid(SceneObject* const)) { SceneObjectRecPtr SO= boost::any_cast<SceneObject* const>(Value); const Char8* Name(getName(SO)); Text = (Name ? Name : "No Name" ); } else if(Value.type() == typeid(Light* const)) { LightRecPtr SceneLight= boost::any_cast<Light* const>(Value); const Char8* Name(getName(SceneLight)); Text = std::string(Name ? Name : "No Name" ) + " [" + SceneLight->getType().getName() + "]"; } ComponentRecPtr LabelComp = getTreeComponentText(Parent, Text, IsSelected, Expanded, Leaf, Row, HasFocus); if(Value.type() == typeid(UInt32)) { switch(boost::any_cast<UInt32>(Value)) { case SceneTreeModel::ForegroundsComponent: //Foregrounds { if(_AddForegroundButton == NULL) { _AddForegroundButton = MenuButton::create(); _AddForegroundButton->setText("+"); _AddForegroundButton->setToolTipText("Create new Foreground"); _AddForegroundButton->setPreferredSize(Vec2f(17.0f,17.0f)); _AddForegroundButton->setAlignment(Vec2f(0.5f,0.5f)); _AddForegroundButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont()); //Fill with all of the foreground types DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create(); MenuModel->editMFDerivedFieldContainerTypes()->push_back(Foreground::getClassType().getCName()); MenuModel->setIncludeAbstract(false); _AddForegroundButton->setModel(MenuModel); //Connect _AddForegroundConnection.disconnect(); _AddForegroundConnection = _AddForegroundButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddForeground, _SceneComponentTree, _1, _AddForegroundButton.get())); } SpringLayoutRecPtr TreeCompLayout = SpringLayout::create(); PanelRecPtr CompPanel = Panel::createEmpty(); TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddForegroundButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddForegroundButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel); CompPanel->setLayout(TreeCompLayout); CompPanel->pushToChildren(LabelComp); CompPanel->pushToChildren(_AddForegroundButton); return ComponentTransitPtr(CompPanel); } break; case SceneTreeModel::SceneObjectsComponent: //Models { if(_AddSceneObjectButton == NULL) { _AddSceneObjectButton = Button::create(); _AddSceneObjectButton->setText("+"); _AddSceneObjectButton->setToolTipText("Create new Scene Object"); _AddSceneObjectButton->setPreferredSize(Vec2f(17.0f,17.0f)); _AddSceneObjectButton->setAlignment(Vec2f(0.5f,0.5f)); _AddSceneObjectButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont()); //Connect _AddSceneObjectConnection.disconnect(); _AddSceneObjectConnection = _AddSceneObjectButton->connectActionPerformed(boost::bind(&SceneComponentTree::handleAddSceneObject, _SceneComponentTree, _1)); } SpringLayoutRecPtr TreeCompLayout = SpringLayout::create(); PanelRecPtr CompPanel = Panel::createEmpty(); TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddSceneObjectButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddSceneObjectButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel); CompPanel->setLayout(TreeCompLayout); CompPanel->pushToChildren(LabelComp); CompPanel->pushToChildren(_AddSceneObjectButton); return ComponentTransitPtr(CompPanel); } break; case SceneTreeModel::LightsComponent: //Lights { if(_AddLightButton == NULL) { _AddLightButton = MenuButton::create(); _AddLightButton->setText("+"); _AddLightButton->setToolTipText("Create new Light"); _AddLightButton->setPreferredSize(Vec2f(17.0f,17.0f)); _AddLightButton->setAlignment(Vec2f(0.5f,0.5f)); _AddLightButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont()); //Connect _AddLightConnection.disconnect(); _AddLightConnection = _AddLightButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddLight, _SceneComponentTree, _1, _AddLightButton.get())); } //Fill with all of the light types DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create(); MenuModel->editMFDerivedFieldContainerTypes()->push_back(Light::getClassType().getCName()); MenuModel->setIncludeAbstract(false); _AddLightButton->setModel(MenuModel); SpringLayoutRecPtr TreeCompLayout = SpringLayout::create(); PanelRecPtr CompPanel = Panel::createEmpty(); TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _AddLightButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel); TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddLightButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel); CompPanel->setLayout(TreeCompLayout); CompPanel->pushToChildren(LabelComp); CompPanel->pushToChildren(_AddLightButton); return ComponentTransitPtr(CompPanel); } break; } } else if(Value.type() == typeid(Foreground* const)) { return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveForeground, _SceneComponentTree, _1, boost::any_cast<Foreground* const>(Value))); } else if(Value.type() == typeid(SceneObject* const)) { return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveSceneObject, _SceneComponentTree, _1, boost::any_cast<SceneObject* const>(Value))); } else if(Value.type() == typeid(Light* const)) { return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveLight, _SceneComponentTree, _1, boost::any_cast<Light* const>(Value))); } return ComponentTransitPtr(LabelComp); }
PanelTransitPtr VideoFieldContainerEditor::createVideoPreviewPanel(void) { ChunkMaterialUnrecPtr VideoMaterial = ChunkMaterial::create(); //Video MaterialLayer _VideoMaterialLayer = MaterialLayer::create(); _VideoMaterialLayer->setMaterial(VideoMaterial); //Video Panel _VideoPanel = Panel::createEmpty(); _VideoPanel->setBackgrounds(_VideoMaterialLayer); //Filename Label _FileNameLabel = Label::create(); _FileNameLabel->setAlignment(Vec2f(0.5f, 0.5f)); //Total time Label _TotalTimeLabel = Label::create(); _TotalTimeLabel->setAlignment(Vec2f(0.0f, 1.0f)); _TotalTimeLabel->setBorders(NULL); _TotalTimeLabel->setBackgrounds(NULL); _TotalTimeLabel->setPreferredSize(Vec2f(50.0f,_TotalTimeLabel->getPreferredSize().y())); //Playback time Label _PlaybackTimeLabel = Label::create(); _PlaybackTimeLabel->setAlignment(Vec2f(1.0f, 1.0f)); _PlaybackTimeLabel->setPreferredSize(Vec2f(50.0f,_TotalTimeLabel->getPreferredSize().y())); _PlaybackTimeLabel->setBorders(NULL); _PlaybackTimeLabel->setBackgrounds(NULL); LabelRecPtr TimeSeparatorLabel = Label::create(); TimeSeparatorLabel->setAlignment(Vec2f(0.5f, 1.0f)); TimeSeparatorLabel->setPreferredSize(Vec2f(8.0f,_TotalTimeLabel->getPreferredSize().y())); TimeSeparatorLabel->setBorders(NULL); TimeSeparatorLabel->setBackgrounds(NULL); TimeSeparatorLabel->setText("/"); //PlayPause Button _PlayPauseButton = Button::create(); _PlayPauseButton->setText("Play"); _PlayPauseButton->setPreferredSize(Vec2f(40.0f,40.0f)); _PlayPauseButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handlePlayPauseAction, this, _1)); //Stop Button _StopButton = Button::create(); _StopButton->setText("Stop"); _StopButton->setPreferredSize(Vec2f(40.0f,40.0f)); _StopButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handleStopAction, this, _1)); //Load Button ButtonRecPtr LoadButton = Button::create(); LoadButton->setText("Load"); LoadButton->setPreferredSize(Vec2f(40.0f,40.0f)); LoadButton->connectActionPerformed(boost::bind(&VideoFieldContainerEditor::handleLoadAction, this, _1)); //Playback position slider _LocationSlider = Slider::create(); _LocationSlider->setOrientation(Slider::HORIZONTAL_ORIENTATION); _LocationSlider->setDrawLabels(false); _LocationSlider->setDrawMajorTicks(false); _LocationSlider->setDrawMinorTicks(false); _LocationSlider->setBorders(NULL); _LocationSlider->setBackgrounds(NULL); //_LocationSlider->getKnobButton()->setPreferredSize(Vec2f(15.0f, 8.0f)); _LocationSlider->getRangeModel()->connectStateChanged(boost::bind(&VideoFieldContainerEditor::handlePlaybackLocationStateChanged, this, _1)); //Layout PanelRecPtr VideoPanel = Panel::createEmpty(); SpringLayoutRecPtr MainLayout = SpringLayout::create(); //Video Panel MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _VideoPanel, 0, SpringLayoutConstraints::EAST_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _VideoPanel, 0, SpringLayoutConstraints::WEST_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _VideoPanel, 0, SpringLayoutConstraints::NORTH_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _VideoPanel, -1, SpringLayoutConstraints::NORTH_EDGE, _PlayPauseButton); //Filename Label MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _FileNameLabel, 0, SpringLayoutConstraints::EAST_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _FileNameLabel, 0, SpringLayoutConstraints::WEST_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _FileNameLabel, 0, SpringLayoutConstraints::NORTH_EDGE, VideoPanel); //Play/pause Button MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _PlayPauseButton, -3, SpringLayoutConstraints::WEST_EDGE, _StopButton); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _PlayPauseButton, 0, SpringLayoutConstraints::SOUTH_EDGE, VideoPanel); //Stop Button MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _StopButton, -3, SpringLayoutConstraints::WEST_EDGE, _LocationSlider); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _StopButton, 0, SpringLayoutConstraints::SOUTH_EDGE, VideoPanel); //Playback Slider MainLayout->putConstraint(SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, _LocationSlider, 0, SpringLayoutConstraints::HORIZONTAL_CENTER_EDGE, VideoPanel); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _LocationSlider, 0, SpringLayoutConstraints::SOUTH_EDGE, VideoPanel); //Total video length label MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _TotalTimeLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, LoadButton); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _TotalTimeLabel, 0, SpringLayoutConstraints::EAST_EDGE, _LocationSlider); //Separator label MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TimeSeparatorLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, LoadButton); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TimeSeparatorLabel, -2, SpringLayoutConstraints::WEST_EDGE, _TotalTimeLabel); //Playback time label MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _PlaybackTimeLabel, 0, SpringLayoutConstraints::SOUTH_EDGE, LoadButton); MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _PlaybackTimeLabel, -2, SpringLayoutConstraints::WEST_EDGE, TimeSeparatorLabel); //Load Button MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LoadButton, 3, SpringLayoutConstraints::EAST_EDGE, _LocationSlider); MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LoadButton, 0, SpringLayoutConstraints::SOUTH_EDGE, VideoPanel); //Main Video Panel VideoPanel->setLayout(MainLayout); VideoPanel->pushToChildren(_VideoPanel); VideoPanel->pushToChildren(_FileNameLabel); VideoPanel->pushToChildren(_PlayPauseButton); VideoPanel->pushToChildren(_StopButton); VideoPanel->pushToChildren(LoadButton); VideoPanel->pushToChildren(_PlaybackTimeLabel); VideoPanel->pushToChildren(TimeSeparatorLabel); VideoPanel->pushToChildren(_TotalTimeLabel); VideoPanel->pushToChildren(_LocationSlider); return PanelTransitPtr(VideoPanel); }