Example #1
0
        MyScreen(
            const std::shared_ptr<spdlog::logger>& logger,
            std::size_t n,
            std::size_t m,
            const shared_mutex_t& mGlobal,
            const shared_mem_t<unsigned char>& hTexture,
            const shared_atomic_t<bool>& shutdown
        ) : Screen(Eigen::Vector2i(800, 600), "s2015ocl"),
            log(logger),
            n(n),
            m(m),
            mGlobal(mGlobal),
            hTexture(hTexture),
            shutdown(shutdown){
            mainwindow = new nanogui::Window(this, "s2015ocl");
            mainwindow->setPosition(Eigen::Vector2i(100, 100));
            mainwindow->setLayout(new nanogui::GroupLayout());

            new nanogui::Label(mainwindow, "foo bar", "sans-bold");

            visualization = new nanogui::ImageView(mainwindow);
            visualization->setPolicy(nanogui::ImageView::SizePolicy::Expand);
            visualization->setFixedSize(Eigen::Vector2i(300, 300));

            performLayout();
        }
Example #2
0
/*
    protected invalidate() FORCES DRAW
    Invalidates the component
    FORCES DRAW
*/
void Component::invalidate(){
    m_shouldDraw            = true;
    m_shouldLayout          = true;
    m_valid                 = false;

    performLayout();

    RenderHandler::Get()->invalidate();
}
void DefaultLayoutable::setLayoutDirty()
{
    m_LayoutFlags |= eLayoutFlags_LayoutDirty;
    if (m_LayoutParent)
    {
        m_LayoutParent->requestLayoutUpdate();
    }
    if (m_LayoutFlags & eLayoutFlags_LayoutDirty)
    {
        if ((m_LayoutFlags & eLayoutFlags_LayoutSuspended) == 0)
            performLayout();
    }
}
Example #4
0
void Viewer::initializeGUI() {
    _window = new nanogui::Window(this, "Settings");
    _window->setPosition(Vector2i(15, 15));
    _window->setLayout(new nanogui::GroupLayout());

    new nanogui::Label(_window, "Actions", "sans-bold");
    nanogui::Button *createMeshButton = new nanogui::Button(_window, "Create Mesh");
    createMeshButton->setCallback([&] () { createMesh(); refreshGUI(); });
    nanogui::Button *clearMeshButton = new nanogui::Button(_window, "Clear Mesh");
    clearMeshButton->setCallback([&] () { clearMesh(); refreshGUI(); });
    nanogui::Button *cameraJsonButton = new nanogui::Button(_window, "Camera JSON");
    cameraJsonButton->setCallback([&] () { createCameraJson(); refreshGUI(); });

    new nanogui::Label(_window, "Display", "sans-bold");
    _showDomainCheckBox = new nanogui::CheckBox(_window, "Show Domain (G)");
    _showDomainCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showDomain = b; refreshGUI(); });
    _showFluidParticlesCheckBox = new nanogui::CheckBox(_window, "Show Fluid Particles (F)");
    _showFluidParticlesCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showFluidParticles = b; refreshGUI(); });
    _showFluidMeshCheckBox = new nanogui::CheckBox(_window, "Show Fluid Mesh (Shift+F)");
    _showFluidMeshCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showFluidMesh = b; refreshGUI(); });
    _showBoundaryParticlesCheckBox = new nanogui::CheckBox(_window, "Show Boundary Particles (B)");
    _showBoundaryParticlesCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showBoundaryParticles = b; refreshGUI(); });
    _showBoundaryMeshesCheckBox = new nanogui::CheckBox(_window, "Show Boundary Meshes (Shift+B)");
    _showBoundaryMeshesCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showBoundaryMeshes = b; refreshGUI(); });
    _showDebugCheckBox = new nanogui::CheckBox(_window, "Show Debug (D)");
    _showDebugCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showDebug = b; refreshGUI(); });
    _showCacheCheckBox = new nanogui::CheckBox(_window, "Show Cache (C)");
    _showCacheCheckBox->setCallback([&] (bool b) { _engine.viewOptions().showCache = b; refreshGUI(); });

    new nanogui::Label(_window, "Options", "sans-bold");
    nanogui::CheckBox *anisotropicMeshCheckBox = new nanogui::CheckBox(_window, "Anisotropic Mesh");
    anisotropicMeshCheckBox->setChecked(_anisotropicMesh);
    anisotropicMeshCheckBox->setCallback([&] (bool b) { _anisotropicMesh = b; refreshGUI(); });

    _transportPanel = new nanogui::Panel(this);
    _transportPanel->setPosition(nanogui::Vector2i(0, mSize.y() - 50));
    _transportPanel->setFixedSize(nanogui::Vector2i(mSize.x(), 50));
    _transportPanel->setLayout(new nanogui::GroupLayout());

    _transportSlider = new nanogui::Slider(_transportPanel);
    _transportSlider->setCallback([&] (float value) { _engine.setCachePosition(value); });

    performLayout(mNVGContext);
    setVisible(true);
}
Example #5
0
void WindowManagerViewer::graphicsContextResize(int width, int height) {
	m_ScreenWidth = width;
	m_ScreenHeight = height;

	Size screenSize;
	float screenScale;
	calculateScreenSizeAndScale(screenSize, screenScale);

	// Scale the ui if the screen resolution is lower than 1024x768
	osg::ref_ptr<osg::MatrixTransform> scaledGroup = dynamic_cast<osg::MatrixTransform*>(m_Group.get());
	osg::Matrix scale;
	scale.makeScale(osg::Vec3(screenScale, screenScale, screenScale));
	scaledGroup->setMatrix(scale);

    m_Camera->setProjectionMatrixAsOrtho(0, width, height, 0, -1000, 1000);

	WindowVector::iterator it = m_Windows.begin();
	for(;it != m_Windows.end();++it) {
		performLayout(it->get());
	}
}
Example #6
0
void ListBox::setSelectedItem(ListBoxItem* newItem) {
	// Do nothing if we select the same object again.
	if(m_SelectedItem.get() == newItem) {
		return;
	}
	
	// Remove the old selected state from the item.
	if(m_SelectedItem.valid()) {
		m_SelectedItem->removeState("selected");
	}
	
	m_SelectedItem = newItem;
	
	// Add the selected state to the new listbox item.
	if(m_SelectedItem.valid()) {
		m_SelectedItem->addState("selected");
	}
	
	// Fire event to any listeners.
	Ref<SignalData> data = new SignalData();
	m_SelectedItemChanged->emit(data.get());
	 
	performLayout();
}
void DefaultLayoutable::resumeLayout()
{
    m_LayoutFlags &= ~eLayoutFlags_LayoutSuspended;
    if (m_LayoutFlags & eLayoutFlags_LayoutDirty)
        performLayout();
}
Example #8
0
void FrameView::layout(bool allowSubtree)
{
    // We should never layout a Document which is not in a LocalFrame.
    ASSERT(m_frame);
    ASSERT(m_frame->view() == this);

    ScriptForbiddenScope forbidScript;

    if (isInPerformLayout() || !m_frame->document()->isActive())
        return;

    TRACE_EVENT0("blink", "FrameView::layout");
    TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "Layout");

    // Protect the view from being deleted during layout (in recalcStyle)
    RefPtr<FrameView> protector(this);

    m_hasPendingLayout = false;

    RELEASE_ASSERT(!isPainting());

    if (!allowSubtree && isSubtreeLayout()) {
        m_layoutSubtreeRoot->markContainingBlocksForLayout(false);
        m_layoutSubtreeRoot = 0;
    }

    performPreLayoutTasks();

    // If there is only one ref to this view left, then its going to be destroyed as soon as we exit,
    // so there's no point to continuing to layout
    if (protector->hasOneRef())
        return;

    Document* document = m_frame->document();
    bool inSubtreeLayout = isSubtreeLayout();
    RenderObject* rootForThisLayout = inSubtreeLayout ? m_layoutSubtreeRoot : document->renderView();
    if (!rootForThisLayout) {
        // FIXME: Do we need to set m_size here?
        ASSERT_NOT_REACHED();
        return;
    }

    FontCachePurgePreventer fontCachePurgePreventer;
    RenderLayer* layer;
    {
        TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);

        m_nestedLayoutCount++;

        if (!inSubtreeLayout) {
            if (m_firstLayout) {
                m_firstLayout = false;
                m_lastViewportSize = layoutSize();
            }

            m_size = LayoutSize(layoutSize());
        }

        layer = rootForThisLayout->enclosingLayer();

        performLayout(rootForThisLayout, inSubtreeLayout);

        m_layoutSubtreeRoot = 0;
    } // Reset m_layoutSchedulingEnabled to its previous value.

    layer->updateLayerPositionsAfterLayout();

    m_layoutCount++;

    ASSERT(!rootForThisLayout->needsLayout());

    scheduleOrPerformPostLayoutTasks();

    m_nestedLayoutCount--;
    if (m_nestedLayoutCount)
        return;

#if ENABLE(ASSERT)
    // Post-layout assert that nobody was re-marked as needing layout during layout.
    document->renderView()->assertSubtreeIsLaidOut();
#endif
}
Example #9
0
void ListBoxItem::setText(const std::string& text) {
	m_Text = text;
	performLayout();
}