PhysicsFrameSplineEditor::PhysicsFrameSplineEditor(const GuiText& caption, GuiPane* dockPane, shared_ptr<GuiTheme> theme) : GuiWindow(caption, theme, Rect2D::xywh(0,0,100,40), GuiTheme::TOOL_WINDOW_STYLE, GuiWindow::HIDE_ON_CLOSE), m_selectedControlPointIndex(0), m_isDocked(dockPane != NULL) { m_cachedPhysicsFrameString = CFrame(m_cachedPhysicsFrameValue).toAny().unparse(); m_spline.append(CFrame()); m_surface.reset(new SplineSurface(this)); m_nodeManipulator = ThirdPersonManipulator::create(); m_nodeManipulator->setEnabled(false); GuiPane* p = dockPane; if (p == NULL) { // Place into the window p = pane(); } else { // No need to show the window setVisible(false); } GuiPane* cpPane = p->addPane("Control Point", GuiTheme::ORNATE_PANE_STYLE); cpPane->moveBy(0, -15); Array<std::string> indexList; getIndexRange(1, indexList); m_selectedControlPointDropDown = cpPane->addDropDownList("Control point: ", indexList, &m_selectedControlPointIndex, GuiControl::Callback(this, &PhysicsFrameSplineEditor::controlPointDropDownCallback)); cpPane->addNumberBox("Time", Pointer<float>(this, &PhysicsFrameSplineEditor::selectedNodeTime, &PhysicsFrameSplineEditor::setSelectedNodeTime), "s"); cpPane->addTextBox("", Pointer<std::string>(this, &PhysicsFrameSplineEditor::selectedNodePFrameAsString, &PhysicsFrameSplineEditor::setSelectedNodePFrameFromString)); cpPane->beginRow(); { GuiButton* b = cpPane->addButton("Add new", this, &PhysicsFrameSplineEditor::addControlPoint); b->moveBy(-2, -7); m_removeSelectedButton = cpPane->addButton("Remove", this, &PhysicsFrameSplineEditor::removeSelectedControlPoint); } cpPane->endRow(); cpPane->pack(); GuiPane* exPane = p->addPane("Extrapolation Mode", GuiTheme::NO_PANE_STYLE); exPane->beginRow(); { GuiControl* linearButton = exPane->addRadioButton("Linear", SplineExtrapolationMode::LINEAR, this, &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode); GuiControl* clampedButton = exPane->addRadioButton("Clamped", SplineExtrapolationMode::CLAMP, this, &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode); clampedButton->moveRightOf(linearButton); clampedButton->moveBy(-145, 0); GuiControl* cyclicButton = exPane->addRadioButton("Cyclic", SplineExtrapolationMode::CYCLIC, this, &PhysicsFrameSplineEditor::extrapolationMode, &PhysicsFrameSplineEditor::setExtrapolationMode); cyclicButton->moveRightOf(clampedButton); cyclicButton->moveBy(-140, 0); } exPane->endRow(); exPane->pack(); GuiPane* inPane = p->addPane("Interpolation Mode", GuiTheme::NO_PANE_STYLE); inPane->beginRow(); { GuiControl* linearButton = inPane->addRadioButton("Linear", SplineInterpolationMode::LINEAR, this, &PhysicsFrameSplineEditor::interpolationMode, &PhysicsFrameSplineEditor::setInterpolationMode); GuiControl* cubicButton = inPane->addRadioButton("Cubic", SplineInterpolationMode::CUBIC, this, &PhysicsFrameSplineEditor::interpolationMode, &PhysicsFrameSplineEditor::setInterpolationMode); cubicButton->moveRightOf(linearButton); cubicButton->moveBy(-145, 0); } inPane->endRow(); inPane->pack(); GuiPane* finalIntervalPane = p->addPane("Final Interval", GuiTheme::NO_PANE_STYLE); finalIntervalPane->moveRightOf(exPane); finalIntervalPane->moveBy(-100, -5); static int m_explicitFinalInterval = 0; m_finalIntervalChoice[0] = finalIntervalPane->addRadioButton("automatic", 0, &m_explicitFinalInterval); finalIntervalPane->beginRow(); { m_finalIntervalChoice[1] = finalIntervalPane->addRadioButton("", 1, &m_explicitFinalInterval); m_finalIntervalBox = finalIntervalPane->addNumberBox("", &m_spline.finalInterval, "s", GuiTheme::NO_SLIDER, -1.0f, 10000.0f, 0.001f); m_finalIntervalBox->setWidth(76); m_finalIntervalBox->moveBy(-2, 0); } finalIntervalPane->endRow(); pack(); setEnabled(false); }
PhysicsFrameSplineEditor::PhysicsFrameSplineEditor(const GuiText& caption, GuiPane* dockPane, GuiTheme::Ref theme) : GuiWindow(caption, theme, Rect2D::xywh(0,0,100,40), GuiTheme::TOOL_WINDOW_STYLE, GuiWindow::HIDE_ON_CLOSE), m_selectedControlPointIndex(0), m_isDocked(dockPane != NULL) { m_cachedPhysicsFrameString = CFrame(m_cachedPhysicsFrameValue).toAny().unparse(); m_spline.append(CFrame()); m_surface = new SplineSurface(this); m_nodeManipulator = ThirdPersonManipulator::create(); m_nodeManipulator->setEnabled(false); GuiPane* p = dockPane; if (p == NULL) { // Place into the window p = pane(); } else { // No need to show the window setVisible(false); } GuiPane* cpPane = p->addPane("Control Point", GuiTheme::ORNATE_PANE_STYLE); cpPane->moveBy(0, -15); if (false) { static float x,y,z; //static const float translationControlWidth = 80; static const float rotationControlWidth = 40; //static const float captionWidth = 10; static const float rotationPrecision = 0.1; //static const float translationPrecision = 0.001; static const std::string degrees = "\xba"; cpPane->beginRow(); { GuiNumberBox<float>* c = NULL; static std::string s = "100.0, 100.0, 100.0"; GuiControl* t = cpPane->addTextBox("xyz (", &s); t->setWidth(155); t->setCaptionWidth(26); cpPane->addLabel(") m"); c = cpPane->addNumberBox("", &x, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); c->moveBy(20, 0); c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8); c = cpPane->addNumberBox("", &y, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8); c = cpPane->addNumberBox("", &z, degrees, GuiTheme::NO_SLIDER, -finf(), finf(), rotationPrecision); c->setCaptionWidth(0); c->setWidth(rotationControlWidth); c->setUnitsSize(8); } cpPane->endRow(); } cpPane->addLabel("Control point: 0"); cpPane->addNumberBox("Time", Pointer<float>(this, &PhysicsFrameSplineEditor::selectedNodeTime, &PhysicsFrameSplineEditor::setSelectedNodeTime), "s"); cpPane->addTextBox("", Pointer<std::string>(this, &PhysicsFrameSplineEditor::selectedNodePFrameAsString, &PhysicsFrameSplineEditor::setSelectedNodePFrameFromString)); cpPane->beginRow(); { GuiButton* b = cpPane->addButton("Add new", this, &PhysicsFrameSplineEditor::addControlPoint); b->moveBy(-2, -7); m_removeSelectedButton = cpPane->addButton("Remove", this, &PhysicsFrameSplineEditor::removeSelectedControlPoint); } cpPane->endRow(); cpPane->pack(); GuiControl* prev = p->addCheckBox("Loop with final interval", Pointer<bool>(this, &PhysicsFrameSplineEditor::cyclic, &PhysicsFrameSplineEditor::setCyclic)); GuiPane* finalIntervalPane = p->addPane("", GuiTheme::NO_PANE_STYLE); finalIntervalPane->moveRightOf(prev); finalIntervalPane->moveBy(-1, -5); static int m_explicitFinalInterval = 0; m_finalIntervalChoice[0] = finalIntervalPane->addRadioButton("automatic", 0, &m_explicitFinalInterval); finalIntervalPane->beginRow(); { m_finalIntervalChoice[1] = finalIntervalPane->addRadioButton("", 1, &m_explicitFinalInterval); m_finalIntervalBox = finalIntervalPane->addNumberBox("", &m_spline.finalInterval, "s", GuiTheme::NO_SLIDER, -1.0f, 10000.0f, 0.001f); m_finalIntervalBox->setWidth(76); m_finalIntervalBox->moveBy(-2, 0); } finalIntervalPane->endRow(); pack(); setEnabled(false); }
CameraControlWindow::CameraControlWindow( const FirstPersonManipulatorRef& manualManipulator, const UprightSplineManipulatorRef& trackManipulator, const Pointer<Manipulator::Ref>& cameraManipulator, const GuiSkinRef& skin) : GuiWindow("Camera Control", skin, Rect2D::xywh(5, 54, 200, 0), GuiWindow::TOOL_FRAME_STYLE, GuiWindow::HIDE_ON_CLOSE), trackFileIndex(0), cameraManipulator(cameraManipulator), manualManipulator(manualManipulator), trackManipulator(trackManipulator), drawerButton(NULL), drawerButtonPane(NULL), m_expanded(false) { manualOperation = manualManipulator->active(); updateTrackFiles(); GuiPane* pane = GuiWindow::pane(); GFontRef iconFont = GFont::fromFile(System::findDataFile("icon.fnt")); GFontRef greekFont = GFont::fromFile(System::findDataFile("greek.fnt")); // The default G3D textbox label leaves too much space between // the box and the label, so we override it. pane->addLabel("xyz")->setPosition(5, 2); pane->addLabel(GuiCaption("qf", greekFont, 12))->setPosition(24, 2); cameraLocationTextBox = pane->addTextBox("", Pointer<std::string>(this, &CameraControlWindow::cameraLocation, &CameraControlWindow::setCameraLocation)); cameraLocationTextBox->setRect(Rect2D::xywh(-50, 2, 292, 24)); GuiPane* manualPane = pane->addPane(); manualPane->moveBy(-8, 0); manualPane->addCheckBox("Manual Control (F2)", &manualOperation)->moveBy(-2, -1); trackLabel = manualPane->addLabel("Path"); trackLabel->moveBy(0, -3); trackList = manualPane->addDropDownList("", &trackFileIndex, &trackFileArray); trackList->setRect(Rect2D::xywh(trackList->rect().x0y0() - Vector2(54, 25), Vector2(220, trackList->rect().height()))); visibleCheckBox = manualPane->addCheckBox("Visible", Pointer<bool>(trackManipulator, &UprightSplineManipulator::showPath, &UprightSplineManipulator::setShowPath)); visibleCheckBox->moveRightOf(trackList); visibleCheckBox->moveBy(6, 0); Vector2 buttonSize = Vector2(20, 20); recordButton = manualPane->addRadioButton (GuiCaption::Symbol::record(), UprightSplineManipulator::RECORD_KEY_MODE, trackManipulator.pointer(), &UprightSplineManipulator::mode, &UprightSplineManipulator::setMode, GuiRadioButton::TOOL_STYLE); recordButton->moveBy(38, 2); recordButton->setSize(buttonSize); playButton = manualPane->addRadioButton (GuiCaption::Symbol::play(), UprightSplineManipulator::PLAY_MODE, trackManipulator.pointer(), &UprightSplineManipulator::mode, &UprightSplineManipulator::setMode, GuiRadioButton::TOOL_STYLE); playButton->setSize(buttonSize); playButton->moveRightOf(recordButton); stopButton = manualPane->addRadioButton (GuiCaption::Symbol::stop(), UprightSplineManipulator::INACTIVE_MODE, trackManipulator.pointer(), &UprightSplineManipulator::mode, &UprightSplineManipulator::setMode, GuiRadioButton::TOOL_STYLE); stopButton->setSize(buttonSize); stopButton->moveRightOf(playButton); saveButton = manualPane->addButton("Save..."); saveButton->moveRightOf(stopButton); saveButton->setSize(saveButton->rect().wh() - Vector2(20, 1)); saveButton->moveBy(8, -3); saveButton->setEnabled(false); cyclicCheckBox = manualPane->addCheckBox("Cyclic", Pointer<bool>(trackManipulator, &UprightSplineManipulator::cyclic, &UprightSplineManipulator::setCyclic)); cyclicCheckBox->setPosition(visibleCheckBox->rect().x0(), saveButton->rect().y0() + 1); # ifdef G3D_OSX manualHelpCaption = GuiCaption("W,A,S,D and shift+left mouse to move.", NULL, 10); # else manualHelpCaption = GuiCaption("W,A,S,D and right mouse to move.", NULL, 10); # endif autoHelpCaption = ""; playHelpCaption = ""; recordHelpCaption = GuiCaption("Spacebar to place a control point.", NULL, 10); helpLabel = manualPane->addLabel(manualHelpCaption); helpLabel->moveBy(0, 2); manualPane->pack(); pack(); // Set the width here so that the client rect is correct below setRect(Rect2D::xywh(rect().x0y0(), bigSize)); // Make the pane width match the window width manualPane->setPosition(0, manualPane->rect().y0()); manualPane->setSize(clientRect().width(), manualPane->rect().height()); // Have to create the drawerButton last, otherwise the setRect // code for moving it to the bottom of the window will cause // layout to become broken. drawerCollapseCaption = GuiCaption("5", iconFont); drawerExpandCaption = GuiCaption("6", iconFont); drawerButtonPane = pane->addPane("", 0, GuiPane::NO_FRAME_STYLE); drawerButton = drawerButtonPane->addButton(drawerExpandCaption, GuiButton::TOOL_STYLE); drawerButton->setRect(Rect2D::xywh(0, 0, 12, 12)); drawerButtonPane->setSize(12, 12); // Resize the pane to include the drawer button so that it is not clipped pane->setSize(clientRect().wh()); setRect(Rect2D::xywh(rect().x0y0(), smallSize)); sync(); }
void App::makeGUI() { // Turn on the developer HUD debugWindow->setVisible(true); developerWindow->cameraControlWindow->setVisible(true); developerWindow->videoRecordDialog->setEnabled(true); GFont::Ref iconFont = GFont::fromFile(System::findDataFile("icon.fnt")); // Create a scene management GUI GuiPane* scenePane = debugPane->addPane("Scene", GuiTheme::ORNATE_PANE_STYLE); scenePane->moveBy(0, -10); scenePane->beginRow(); { // Example of using a callback; you can also listen for events in onEvent or bind controls to data m_sceneDropDownList = scenePane->addDropDownList("", Scene::sceneNames(), NULL, GuiControl::Callback(this, &App::loadScene)); static const char* reloadIcon = "q"; static const char* diskIcon = "\xcd"; scenePane->addButton(GuiText(reloadIcon, iconFont, 14), this, &App::loadScene, GuiTheme::TOOL_BUTTON_STYLE)->setWidth(32); scenePane->addButton(GuiText(diskIcon, iconFont, 18), this, &App::saveScene, GuiTheme::TOOL_BUTTON_STYLE)->setWidth(32); } scenePane->endRow(); const int w = 120; scenePane->beginRow(); { scenePane->addCheckBox("Axes", &m_showAxes)->setWidth(w); scenePane->addCheckBox("Light sources", &m_showLightSources); } scenePane->endRow(); scenePane->beginRow(); { scenePane->addCheckBox("Wireframe", &m_showWireframe)->setWidth(w); } scenePane->endRow(); static const char* lockIcon = "\xcf"; scenePane->addCheckBox(GuiText(lockIcon, iconFont, 20), &m_preventEntityDrag, GuiTheme::TOOL_CHECK_BOX_STYLE); scenePane->pack(); GuiPane* entityPane = debugPane->addPane("Entity", GuiTheme::ORNATE_PANE_STYLE); entityPane->moveRightOf(scenePane); entityPane->moveBy(10, 0); m_entityList = entityPane->addDropDownList("Name"); // Dock the spline editor m_splineEditor = PhysicsFrameSplineEditor::create("Spline Editor", entityPane); addWidget(m_splineEditor); developerWindow->cameraControlWindow->moveTo(Point2(window()->width() - developerWindow->cameraControlWindow->rect().width(), 0)); m_splineEditor->moveTo(developerWindow->cameraControlWindow->rect().x0y0() - Vector2(m_splineEditor->rect().width(), 0)); entityPane->pack(); GuiPane* infoPane = debugPane->addPane("Info", GuiTheme::ORNATE_PANE_STYLE); infoPane->moveRightOf(entityPane); infoPane->moveBy(10, 0); // Example of how to add debugging controls infoPane->addLabel("You can add more GUI controls"); infoPane->addLabel("in App::onInit()."); infoPane->addButton("Exit", this, &App::endProgram); infoPane->pack(); // More examples of debugging GUI controls: // debugPane->addCheckBox("Use explicit checking", &explicitCheck); // debugPane->addTextBox("Name", &myName); // debugPane->addNumberBox("height", &height, "m", GuiTheme::LINEAR_SLIDER, 1.0f, 2.5f); // button = debugPane->addButton("Run Simulator"); debugWindow->pack(); debugWindow->setRect(Rect2D::xywh(0, 0, window()->width(), debugWindow->rect().height())); }