Ejemplo n.º 1
0
void App::makeColorList() {
    shared_ptr<GFont> iconFont = GFont::fromFile(System::findDataFile("icon.fnt"));

    // Characters in icon font that make a solid block of color
    static const char* block = "gggggg";

    float size = 18;
    int N = 10;
    colorList.append(GuiText(block, iconFont, size, Color3::black(), Color4::clear()));
    for (int i = 0; i < N; ++i) {
        colorList.append(GuiText(block, iconFont, size, Color3::rainbowColorMap((float)i / N), Color4::clear()));
    }
    colorList.append(GuiText(block, iconFont, size, Color3::white(), Color4::clear()));
}
Ejemplo n.º 2
0
void App::makeGUI() {
    createDeveloperHUD();

    debugWindow->setVisible(true);
    developerWindow->setVisible(false);
    developerWindow->cameraControlWindow->setVisible(false);
    showRenderingStats = false;

    // Show the G-buffers
    debugPane->setCaption(GuiText("GBuffer", GFont::fromFile(System::findDataFile("arial.fnt")), 16));
    debugPane->moveBy(2, 10);

    GuiTabPane* tabPane = dynamic_cast<GuiTabPane*>(GUI::makeGBufferPane(m_gbuffer, debugPane));
    tabPane->setWidth(800);
    debugPane->pack();
}
Ejemplo n.º 3
0
void App::makeGUI() {
    shared_ptr<GuiWindow> window = GuiWindow::create("Controls", debugWindow->theme(), Rect2D::xywh(0,0,0,0), GuiTheme::TOOL_WINDOW_STYLE);
    GuiPane* pane = window->pane();
    
	//pane->addButton("Restart", this, &App::onReset);
	//if (m_debugMode){
		pane->addButton("Filter", this, &App::onFilter);
		pane->addButton("SURE-Optimization", this, &App::onOptimize);
		pane->addButton("More samples", this, &App::onAddSamples);
	//}
	m_sampleCountPtrString = Pointer<String>(&m_sampleCountString);
	pane->addTextBox("Samples: ",m_sampleCountPtrString,G3D::GuiTextBox::DELAYED_UPDATE,G3D::GuiTheme::NO_BACKGROUND_UNLESS_FOCUSED_TEXT_BOX_STYLE );
    
    //pane->addNumberBox("Samples ppx", &m_samplesPerPixel, "", GuiTheme::LINEAR_SLIDER, 1, 5000, 1);
    //pane->addNumberBox("Max bounces", &m_maxBounces, "", GuiTheme::LINEAR_SLIDER, 1, 30, 1);

	window->pack();
    window->setVisible(true);
    addWidget(window);

	debugPane->moveBy(200, 10);
    debugPane->setCaption(GuiText("\t\t Mean\t\t\t\t\t Variance", GFont::fromFile(System::findDataFile("arial.fnt")), 16));
	
	debugPane->setVisible(true);
	debugPane->beginRow();
	GuiTabPane* tabPane = dynamic_cast<GuiTabPane*>(makeFeaturePane(debugPane,MEAN));
	tabPane->pack();

	GuiTabPane* tabPane2 = dynamic_cast<GuiTabPane*>(makeFeaturePane(debugPane,VAR));
	tabPane2->pack();
	tabPane2->moveRightOf(tabPane,50);
	debugPane->endRow();

	debugPane->pack();   

	char numStr[20];
	sprintf(numStr,"%d",m_sampleCount);
	m_sampleCountPtrString.setValue(String(numStr));	

	
}
Ejemplo n.º 4
0
void GuiTextBox::render(RenderDevice* rd, const shared_ptr<GuiTheme>& theme, bool ancestorsEnabled) const {
    (void)rd;
    (void)theme;
    GuiTextBox* me = const_cast<GuiTextBox*>(this);

    if (m_visible) {
        if (m_editing) {
            if (! focused()) {
                // Just lost focus
                if ((m_update == DELAYED_UPDATE) && (m_oldValue != m_userValue)) {
                    me->m_oldValue = m_userValue;
                    me->commit();
                    GEvent response;
                    response.gui.type = GEventType::GUI_CHANGE;
                    response.gui.control = me->m_eventSource;
                    m_gui->fireEvent(response);
                }
                me->m_editing = false;
            } else if (String(*m_value) != m_oldValue) {
                // The value has been changed by the program while we
                // were editing; override our copy with the
                // programmatic value.
                me->m_userValue = *m_value;
                me->m_cursorPos = min(m_cursorPos, (int)m_userValue.size());
            }
        } else if (focused()) {
            // Just gained focus
            me->m_userValue = *m_value;
            me->m_oldValue  = m_userValue;
            me->m_editing   = true;
        }

        static RealTime then = System::time();
        RealTime now = System::time();

        bool hasKeyDown = (m_repeatKeysym.sym != GKey::UNKNOWN);

        // Amount of time that the last simulation step took.  
        // This is used to limit the key repeat rate
        // so that it is not faster than the frame rate.
        RealTime frameTime = then - now;

        // If a key is being pressed, process it on a steady repeat schedule.
        if (hasKeyDown && (now > m_keyRepeatTime)) {
            me->processRepeatKeysym();
            me->m_keyRepeatTime = max(now + frameTime * 1.1, now + 1.0 / keyRepeatRate);
        }
        then = now;

        // Only blink the cursor when keys are not being pressed or
        // have not recently been pressed.
        bool solidCursor = hasKeyDown || (now - m_keyRepeatTime < 1.0 / blinkRate);
        if (! solidCursor) {
            static const RealTime zero = System::time();
            solidCursor = isOdd((int)((now - zero) * blinkRate));
        }

        // Note that textbox does not have a mouseover state
        theme->renderTextBox
           (m_rect,
            m_enabled && ancestorsEnabled,
            focused(), 
            m_caption,
            m_captionWidth,
            m_editing ? m_userValue : *m_value, 
            solidCursor ? m_cursor : GuiText(),
            m_cursorPos,
            m_style);
    }
}
Ejemplo n.º 5
0
void VideoRecordDialog::makeGUI() {
    pane()->addCheckBox("Record GUI (Surface2D)", &m_captureGUI);

    pane()->addLabel(GuiText("Video", shared_ptr<GFont>(), 12));
    GuiPane* moviePane = pane()->addPane("", GuiTheme::ORNATE_PANE_STYLE);

    GuiLabel* label = NULL;
    GuiDropDownList* formatList = moviePane->addDropDownList("Format", m_formatList, &m_templateIndex);

    const float width = 300.0f;
    // Increase caption size to line up with the motion blur box
    const float captionSize = 90.0f;

    formatList->setWidth(width);
    formatList->setCaptionWidth(captionSize);

    moviePane->addNumberBox("Quality", &m_quality, "", GuiTheme::LOG_SLIDER, 0.1f, 25.0f);
    
    if (false) {
        // For future expansion
        GuiCheckBox*  motionCheck = moviePane->addCheckBox("Motion Blur",  &m_enableMotionBlur);
        m_framesBox = moviePane->addNumberBox("", &m_motionBlurFrames, "frames", GuiTheme::LINEAR_SLIDER, 2, 20);
        m_framesBox->setUnitsSize(46);
        m_framesBox->moveRightOf(motionCheck);
        m_framesBox->setWidth(210);
    }

    GuiNumberBox<float>* recordBox   = moviePane->addNumberBox("Record as if",      &m_recordFPS, "fps", GuiTheme::NO_SLIDER, 1.0f, 120.0f, 0.1f);
    recordBox->setCaptionWidth(captionSize);

    GuiNumberBox<float>* playbackBox = moviePane->addNumberBox("Playback at",    &m_playbackFPS, "fps", GuiTheme::NO_SLIDER, 1.0f, 120.0f, 0.1f);
    playbackBox->setCaptionWidth(captionSize);

    const OSWindow* window = OSWindow::current();
    int w = window->width() / 2;
    int h = window->height() / 2;
    moviePane->addCheckBox(format("Half-size (%d x %d)", w, h), &m_halfSize);

    if (false) {
        // For future expansion
        moviePane->addCheckBox("Show cursor", &m_showCursor);
    }

    label = moviePane->addLabel("Hot key:");
    label->setWidth(captionSize);
    moviePane->addLabel(m_hotKeyString)->moveRightOf(label);

    // Add record on the same line as previous hotkey box
    m_recordButton = moviePane->addButton("Record Now (" + m_hotKeyString + ")");
    m_recordButton->moveBy(moviePane->rect().width() - m_recordButton->rect().width() - 5, -27);
    moviePane->pack();
    moviePane->setWidth(pane()->rect().width());

    ///////////////////////////////////////////////////////////////////////////////////
    pane()->addLabel(GuiText("Screenshot", shared_ptr<GFont>(), 12));
    GuiPane* ssPane = pane()->addPane("", GuiTheme::ORNATE_PANE_STYLE);

    m_ssFormatList.append("JPG", "PNG", "BMP", "TGA");
    GuiDropDownList* ssFormatList = ssPane->addDropDownList("Format", m_ssFormatList, &m_ssFormatIndex);
    m_ssFormatIndex = 0;

    ssFormatList->setWidth(width);
    ssFormatList->setCaptionWidth(captionSize);

    label = ssPane->addLabel("Hot key:");
    label->setWidth(captionSize);
    ssPane->addLabel(m_ssHotKeyString)->moveRightOf(label);

    ssPane->pack();
    ssPane->setWidth(pane()->rect().width());

    ///////////////////////////////////////////////////////////////////////////////////

    pack();
    setRect(Rect2D::xywh(rect().x0(), rect().y0(), rect().width() + 5, rect().height() + 2));
}
Ejemplo n.º 6
0
void GUIViewer::createGui(const std::string& filename) {
    GuiPane*			pane;
    
    skin = GuiTheme::fromFile(filename, parentApp->debugFont);
    
    window         = GuiWindow::create("Normal", skin, Rect2D::xywh(50,50,0,0),   
                                       GuiTheme::NORMAL_WINDOW_STYLE, GuiWindow::IGNORE_CLOSE);
    toolWindow     = GuiWindow::create("Tool",   skin, Rect2D::xywh(300,100,0,0), 
                                       GuiTheme::TOOL_WINDOW_STYLE,   GuiWindow::IGNORE_CLOSE);
    bgControl      = GuiWindow::create("Dialog", skin, Rect2D::xywh(550,100,0,0), 
                                       GuiTheme::DIALOG_WINDOW_STYLE, GuiWindow::IGNORE_CLOSE);
    dropdownWindow = GuiWindow::create("Normal", skin, Rect2D::xywh(400,400,0,0), 
                                       GuiTheme::NORMAL_WINDOW_STYLE, GuiWindow::IGNORE_CLOSE);

    text = "Hello";

    pane = window->pane();
    slider[0] = 1.5f;
    slider[1] = 1.8f;

    {
        GuiPane* p = pane->addPane("Pane (NO_PANE_STYLE)", GuiTheme::NO_PANE_STYLE);
        p->addSlider("Slider", &slider[0], 1.0f, 2.2f);
        p->addSlider("Slider Disabled", &slider[1], 1.0f, 2.2f)->setEnabled(false);
    }
    {
        GuiPane* p = pane->addPane("Pane (SIMPLE_PANE_STYLE)", GuiTheme::SIMPLE_PANE_STYLE);
        p->addLabel("RadioButton (RADIO_STYLE)");
        p->addRadioButton("Sel, Dis", 1, &radio[0])->setEnabled(false);
        p->addRadioButton("Desel, Dis", 2, &radio[0])->setEnabled(false);
        p->addRadioButton("Sel, Enabled", 3, &radio[1]);
        p->addRadioButton("Desel, Disabled", 4, &radio[1]);
    }

    {
        GuiPane* p = pane->addPane("Pane (SIMPLE_PANE_STYLE)", GuiTheme::SIMPLE_PANE_STYLE);
        p->addLabel("RadioButton (BUTTON_STYLE)");
        p->addRadioButton("Selected, Disabled", 5, &radio[2], GuiTheme::BUTTON_RADIO_BUTTON_STYLE)->setEnabled(false);
        p->addRadioButton("Deselected, Disabled", 6, &radio[2], GuiTheme::BUTTON_RADIO_BUTTON_STYLE)->setEnabled(false);
        p->addRadioButton("Selected, Enabled", 7, &radio[3], GuiTheme::BUTTON_RADIO_BUTTON_STYLE);
        p->addRadioButton("Deselected, Disabled", 8, &radio[3], GuiTheme::BUTTON_RADIO_BUTTON_STYLE);
        p->addButton("Button");
    }

    pane = toolWindow->pane();
    {
        GuiPane* p = pane->addPane("Pane (ORNATE_PANE_STYLE)", GuiTheme::ORNATE_PANE_STYLE);
        p->addLabel("CheckBox (NORMAL_CHECK_BOX_SYLE)");
        checkbox[0] = true;
        checkbox[1] = false;
        checkbox[2] = true;
        checkbox[3] = false;
        p->addCheckBox("Selected, Enabled", &checkbox[0]);
        p->addCheckBox("Deselected, Enabled", &checkbox[1]);
        p->addCheckBox("Selected, Disabled", &checkbox[2])->setEnabled(false);
        p->addCheckBox("Deselected, Disabled", &checkbox[3])->setEnabled(false);
    }

    {
        GuiPane* p = pane->addPane("", GuiTheme::SIMPLE_PANE_STYLE);
        p->addLabel("CheckBox (BUTTON_CHECK_BOX_STYLE)");
        checkbox[4] = true;
        checkbox[5] = false;
        checkbox[6] = true;
        checkbox[7] = false;
        p->addCheckBox("Selected, Disabled", &checkbox[4], GuiTheme::BUTTON_CHECK_BOX_STYLE)->setEnabled(false);
        p->addCheckBox("Deselected, Disabled", &checkbox[5], GuiTheme::BUTTON_CHECK_BOX_STYLE)->setEnabled(false);
        p->addCheckBox("Selected, Enabled", &checkbox[6], GuiTheme::BUTTON_CHECK_BOX_STYLE);
        p->addCheckBox("Deselected, Enabled", &checkbox[7], GuiTheme::BUTTON_CHECK_BOX_STYLE);
        p->addButton("Disabled")->setEnabled(false);
    }

    pane = dropdownWindow->pane();
    pane->addButton("Tool", GuiTheme::TOOL_BUTTON_STYLE);
    GuiButton* t2 = pane->addButton("Tool", GuiTheme::TOOL_BUTTON_STYLE);
    t2->setEnabled(false);
    static bool check = false;
    pane->addCheckBox("Check", &check, GuiTheme::TOOL_CHECK_BOX_STYLE);

    dropdownIndex[0] = 0;
    dropdownIndex[1] = 0;
    dropdown.append("Option 1");
    dropdown.append("Option 2");
    dropdown.append("Option 3");
    dropdownDisabled.append("Disabled");
    pane->addLabel("Dropdown List");
    pane->addDropDownList(GuiText("Enabled"), dropdown, &dropdownIndex[0]);
    pane->addDropDownList(GuiText("Disabled"), dropdownDisabled, &dropdownIndex[1])->setEnabled(false);
    pane->addTextBox("TextBox", &text);
    pane->addTextBox("Disabled", &text)->setEnabled(false);

    pane = bgControl->pane();
    windowControl = BGIMAGE2;
    pane->addLabel("Background Color");
    pane->addRadioButton(GuiText("White"), WHITE, &windowControl);
    pane->addRadioButton(GuiText("Blue"), BLUE, &windowControl);
    pane->addRadioButton(GuiText("Black"), BLACK, &windowControl);
    pane->addRadioButton(GuiText("background1.jpg"), BGIMAGE1, &windowControl)->setEnabled(background1.notNull());
    pane->addRadioButton(GuiText("background2.jpg"), BGIMAGE2, &windowControl)->setEnabled(background2.notNull());

    // Gets rid of any empty, unused space in the windows
    window->pack();
    toolWindow->pack();
    bgControl->pack();
    dropdownWindow->pack();

    parentApp->addWidget(window);
    parentApp->addWidget(toolWindow);
    parentApp->addWidget(bgControl);
    parentApp->addWidget(dropdownWindow);
}
Ejemplo n.º 7
0
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()));
}