Beispiel #1
0
/*************************************************************************
	Return the ListboxItem under the given window local pixel co-ordinate.
*************************************************************************/
ListboxItem* Listbox::getItemAtPoint(const Point& pt) const
{
	Rect renderArea(getListRenderArea());

	// point must be within the rendering area of the Listbox.
	if (renderArea.isPointInRect(pt))
	{
		float y = renderArea.d_top - getVertScrollbar()->getScrollPosition();

		// test if point is above first item
		if (pt.d_y >= y)
		{
			for (size_t i = 0; i < getItemCount(); ++i)
			{
				y += d_listItems[i]->getPixelSize().d_height;

				if (pt.d_y < y)
				{
					return d_listItems[i];
				}

			}
		}
	}

	return 0;
}
Beispiel #2
0
void Renderer::renderMetaTile(RenderAttributes& map, const shared_ptr<MetaTile>& tile)
{
	const shared_ptr<MetaIdentifier>& id = tile->getIdentifier();
	int width = id->getWidth() * TILE_SIZE;
	int height = id->getHeight() * TILE_SIZE;
	int zoom = id->getZoom();
	TileIdentifier::Format format = id->getIdentifiers()[0]->getImageFormat();

	shared_ptr<ImageWriter> writer = getWriter(format, width, height);

	FixedRect area;
	tileToMercator(id->getX(), id->getY(), zoom, area.minX, area.minY);
	tileToMercator(id->getX() + id->getWidth(),
				   id->getY() + id->getHeight(),
				   zoom, area.maxX, area.maxY);

#if OLD_CAIRO
	renderLock.lock();
#endif

	AssetCache cache;

	CairoLayer layers[LAYER_NUM];
	setupLayers(layers, writer, cache);

	paintBackground(layers[0], map.getCanvasStyle());

	renderArea(area, layers, width, height, map, cache);

#if OLD_CAIRO
	renderLock.unlock();
#endif

	tile->setData(layers[0].surface);
}
 void setRenderArea(ToonzScene *scene) {
   TDimension cameraRes = scene->getCurrentCamera()->getRes();
   double rx = cameraRes.lx * 0.5, ry = cameraRes.ly * 0.5;
   TRectD renderArea(-rx, -ry, rx, ry);
   TRenderPort::setRenderArea(renderArea);
   m_cameraDpi = scene->getCurrentCamera()->getDpi();
 }
Beispiel #4
0
    void FalagardMenubar::sizeToContent_impl(void)
    {
        Rect renderArea(getItemRenderArea());
        Rect wndArea(getAbsoluteRect());

        // get size of content
        Size sz(getContentSize());

        // calculate the full size with the frame accounted for and resize the window to this
        sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
        sz.d_height += wndArea.getHeight() - renderArea.getHeight();
        setSize(Absolute,sz);
    }
Beispiel #5
0
/************************************************************************
    Resize to fit content
************************************************************************/
void ItemListBase::sizeToContent_impl(void)
{
    Rect renderArea(getItemRenderArea());
    Rect wndArea(getArea().asAbsolute(getParentPixelSize()));

    // get size of content
    Size sz(getContentSize());

    // calculate the full size with the frame accounted for and resize the window to this
    sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
    sz.d_height += wndArea.getHeight() - renderArea.getHeight();
    setSize(UVector2(cegui_absdim(sz.d_width), cegui_absdim(sz.d_height)));
}
Beispiel #6
0
/*************************************************************************
    Return the TreeItem under the given window local pixel co-ordinate.
*************************************************************************/
TreeItem* Tree::getItemAtPoint(const Vector2f& pt) const
{
    Rectf renderArea(getTreeRenderArea());
    
    // point must be within the rendering area of the Tree.
    if (renderArea.isPointInRect(pt))
    {
        float y = renderArea.top() - d_vertScrollbar->getScrollPosition();
        
        // test if point is above first item
        if (pt.d_y >= y)
            return getItemFromListAtPoint(d_listItems, &y, pt);
    }
    
    return 0;
}
Beispiel #7
0
    void FalagardPopupMenu::sizeToContent_impl(void)
    {
        Rect renderArea(getItemRenderArea());
        Rect wndArea(getAbsoluteRect());

        // get size of content
        Size sz(getContentSize());

        // calculate the full size with the frame accounted for and resize the window to this
        sz.d_width  += wndArea.getWidth() - renderArea.getWidth();
        sz.d_height += wndArea.getHeight() - renderArea.getHeight();

		sz.d_width /= System::getSingleton().getRenderer()->getSize().d_width;
		sz.d_height /= System::getSingleton().getRenderer()->getSize().d_height;

		setSize(Relative,sz);
    }
Beispiel #8
0
void ToolRender::render(SDL_Surface *on) {

  if(tool == -1) {
    return;
  }

  if(tool == SIMULTY_CLIENT_TOOL_ZONE_COM
      || tool == SIMULTY_CLIENT_TOOL_ZONE_RES
      || tool == SIMULTY_CLIENT_TOOL_ZONE_IND
      || tool == SIMULTY_CLIENT_TOOL_BULLDOZER
      || tool == SIMULTY_CLIENT_TOOL_LAND) {

    renderArea(on, mr, *camera, toolStartPos, toolEndPos);

  } else if(tool == SIMULTY_CLIENT_TOOL_ROAD) {
    renderTrail(on, mr, *camera, toolStartPos, toolEndPos);
  }
}
Beispiel #9
0
	void FalagardChatHistory::configureScrollbars()
	{
		// no scrollbars?  Can't configure then!
		if(!d_vertScrollbar) return;

		Rect initialArea(getTextRenderArea());

		//
		// Set up scroll bar values
		//
		Rect renderArea(getTextRenderArea());

		d_vertScrollbar->setDocumentSize(d_totalHeight);
		d_vertScrollbar->setPageSize(renderArea.getHeight());
		d_vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
		d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition());

		requestRedraw();
		d_parentWindow->requestRedraw();
	}
Beispiel #10
0
/*************************************************************************
	display required integrated scroll bars according to current state
	of the list box and update their values.
*************************************************************************/
void Listbox::configureScrollbars(void)
{
    Scrollbar* vertScrollbar = getVertScrollbar();
    Scrollbar* horzScrollbar = getHorzScrollbar();

	float totalHeight	= getTotalItemsHeight();
	float widestItem	= getWidestItemWidth();

	//
	// First show or hide the scroll bars as needed (or requested)
	//
	// show or hide vertical scroll bar as required (or as specified by option)
	if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
	{
		vertScrollbar->show();

		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();
		}
		else
		{
			horzScrollbar->hide();
		}

	}
	else
	{
		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();

			// show or hide vertical scroll bar as required (or as specified by option)
			if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
			{
				vertScrollbar->show();
			}
			else
			{
				vertScrollbar->hide();
			}

		}
		else
		{
			vertScrollbar->hide();
			horzScrollbar->hide();
		}

	}

	//
	// Set up scroll bar values
	//
	Rect renderArea(getListRenderArea());

	vertScrollbar->setDocumentSize(totalHeight);
	vertScrollbar->setPageSize(renderArea.getHeight());
	vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
	vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());

	horzScrollbar->setDocumentSize(widestItem);
	horzScrollbar->setPageSize(renderArea.getWidth());
	horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
	horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
/*************************************************************************
	display required integrated scroll bars according to current state
	of the edit box and update their values.
*************************************************************************/
void MultiLineEditbox::configureScrollbars(void)
{
	float totalHeight	= (float)d_lines.size() * getFont()->getLineSpacing();
	float widestItem	= d_widestExtent;

	//
	// First show or hide the scroll bars as needed (or requested)
	//
	// show or hide vertical scroll bar as required (or as specified by option)
	if ((totalHeight > getTextRenderArea().getHeight()) || d_forceVertScroll)
	{
		d_vertScrollbar->show();

		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getTextRenderArea().getWidth()) || d_forceHorzScroll)
		{
			d_horzScrollbar->show();
		}
		else
		{
			d_horzScrollbar->hide();
		}

	}
	else
	{
		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getTextRenderArea().getWidth()) || d_forceHorzScroll)
		{
			d_horzScrollbar->show();

			// show or hide vertical scroll bar as required (or as specified by option)
			if ((totalHeight > getTextRenderArea().getHeight()) || d_forceVertScroll)
			{
				d_vertScrollbar->show();
			}
			else
			{
				d_vertScrollbar->hide();
			}

		}
		else
		{
			d_vertScrollbar->hide();
			d_horzScrollbar->hide();
		}

	}

	//
	// Set up scroll bar values
	//
	Rect renderArea(getTextRenderArea());

	d_vertScrollbar->setDocumentSize(totalHeight);
	d_vertScrollbar->setPageSize(renderArea.getHeight());
	d_vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
	d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition());

	d_horzScrollbar->setDocumentSize(widestItem);
	d_horzScrollbar->setPageSize(renderArea.getWidth());
	d_horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
	d_horzScrollbar->setScrollPosition(d_horzScrollbar->getScrollPosition());
}
Beispiel #12
0
QRegion QSGAbstractSoftwareRenderer::optimizeRenderList()
{
    // Iterate through the renderlist from front to back
    // Objective is to update the dirty status and rects.
    for (auto i = m_renderableNodes.rbegin(); i != m_renderableNodes.rend(); ++i) {
        auto node = *i;
        if (!m_dirtyRegion.isEmpty()) {
            // See if the current dirty regions apply to the current node
            node->addDirtyRegion(m_dirtyRegion, true);
        }

        if (!m_obscuredRegion.isEmpty()) {
            // Don't try to paint things that are covered by opaque objects
            node->subtractDirtyRegion(m_obscuredRegion);
        }

        // Keep up with obscured regions
        if (node->isOpaque()) {
            m_obscuredRegion += node->boundingRectMin();
        }

        if (node->isDirty()) {
            // Don't paint things outside of the rendering area
            if (!m_background->rect().toRect().contains(node->boundingRectMax(), /*proper*/ true)) {
                // Some part(s) of node is(are) outside of the rendering area
                QRegion renderArea(m_background->rect().toRect());
                QRegion outsideRegions = node->dirtyRegion().subtracted(renderArea);
                if (!outsideRegions.isEmpty())
                    node->subtractDirtyRegion(outsideRegions);
            }

            // Get the dirty region's to pass to the next nodes
            if (node->isOpaque()) {
                // if isOpaque, subtract node's dirty rect from m_dirtyRegion
                m_dirtyRegion -= node->boundingRectMin();
            } else {
                // if isAlpha, add node's dirty rect to m_dirtyRegion
                m_dirtyRegion += node->dirtyRegion();
            }
            // if previousDirtyRegion has content outside of boundingRect add to m_dirtyRegion
            QRegion prevDirty = node->previousDirtyRegion();
            if (!prevDirty.isNull())
                m_dirtyRegion += prevDirty;
        }
    }

    if (m_obscuredRegion.contains(m_background->rect().toAlignedRect())) {
        m_isOpaque = true;
    } else {
        m_isOpaque = false;
    }

    // Empty dirtyRegion (for second pass)
    m_dirtyRegion = QRegion();
    m_obscuredRegion = QRegion();

    // Iterate through the renderlist from back to front
    // Objective is to make sure all non-opaque items are painted when an item under them is dirty
    for (auto j = m_renderableNodes.begin(); j != m_renderableNodes.end(); ++j) {
        auto node = *j;

        if (!node->isOpaque() && !m_dirtyRegion.isEmpty()) {
            // Only blended nodes need to be updated
            node->addDirtyRegion(m_dirtyRegion, true);
        }

        m_dirtyRegion += node->dirtyRegion();
    }

    QRegion updateRegion = m_dirtyRegion;

    // Empty dirtyRegion
    m_dirtyRegion = QRegion();
    m_obscuredRegion = QRegion();

    return updateRegion;
}
Beispiel #13
0
/*************************************************************************
	display required integrated scroll bars according to current state
	of the list box and update their values.
*************************************************************************/
void Listbox::configureScrollbars(void)
{
    Scrollbar* vertScrollbar;
    Scrollbar* horzScrollbar;

    try
    {
        vertScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_vscrollbar__"));
        horzScrollbar = static_cast<Scrollbar*>(WindowManager::getSingleton().getWindow(getName() + "__auto_hscrollbar__"));
    }
    catch (UnknownObjectException)
    {
        // no scrollbars?  Can't configure then!
        return;
    }

	float totalHeight	= getTotalItemsHeight();
	float widestItem	= getWidestItemWidth();

	//
	// First show or hide the scroll bars as needed (or requested)
	//
	// show or hide vertical scroll bar as required (or as specified by option)
	if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
	{
		vertScrollbar->show();

		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();
		}
		else
		{
			horzScrollbar->hide();
		}

	}
	else
	{
		// show or hide horizontal scroll bar as required (or as specified by option)
		if ((widestItem > getListRenderArea().getWidth()) || d_forceHorzScroll)
		{
			horzScrollbar->show();

			// show or hide vertical scroll bar as required (or as specified by option)
			if ((totalHeight > getListRenderArea().getHeight()) || d_forceVertScroll)
			{
				vertScrollbar->show();
			}
			else
			{
				vertScrollbar->hide();
			}

		}
		else
		{
			vertScrollbar->hide();
			horzScrollbar->hide();
		}

	}

	//
	// Set up scroll bar values
	//
	Rect renderArea(getListRenderArea());

	vertScrollbar->setDocumentSize(totalHeight);
	vertScrollbar->setPageSize(renderArea.getHeight());
	vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
	vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());

	horzScrollbar->setDocumentSize(widestItem);
	horzScrollbar->setPageSize(renderArea.getWidth());
	horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
	horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
Beispiel #14
0
/*************************************************************************
    display required integrated scroll bars according to current state
    of the tree and update their values.
*************************************************************************/
void Tree::configureScrollbars(void)
{
    Rectf renderArea(getTreeRenderArea());
    
    //This is becuase CEGUI IS GAY! and fires events before the item is initialized
    if(!d_vertScrollbar)
        d_vertScrollbar = createVertScrollbar("__auto_vscrollbar__");
    if(!d_horzScrollbar)
        d_horzScrollbar = createHorzScrollbar("__auto_hscrollbar__");
    
    float totalHeight = getTotalItemsHeight();
    float widestItem  = getWidestItemWidth() + 20;
    
    //
    // First show or hide the scroll bars as needed (or requested)
    //
    // show or hide vertical scroll bar as required (or as specified by option)
    if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll)
    {
        d_vertScrollbar->show();
        renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset + d_vertScrollbar->getXPosition().d_offset;
        // show or hide horizontal scroll bar as required (or as specified by option)
        if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll)
        {
            d_horzScrollbar->show();
            renderArea.d_max.d_y -= d_horzScrollbar->getHeight().d_offset;
        }
        else
        {
            d_horzScrollbar->hide();
            d_horzScrollbar->setScrollPosition(0);
        }
    }
    else
    {
        // show or hide horizontal scroll bar as required (or as specified by option)
        if ((widestItem > renderArea.getWidth()) || d_forceHorzScroll)
        {
            d_horzScrollbar->show();
            renderArea.d_max.d_y -= d_vertScrollbar->getHeight().d_offset;
            
            // show or hide vertical scroll bar as required (or as specified by option)
            if ((totalHeight > renderArea.getHeight()) || d_forceVertScroll)
            {
                d_vertScrollbar->show();
                //            renderArea.d_right -= d_vertScrollbar->getAbsoluteWidth();
                renderArea.d_max.d_x -= d_vertScrollbar->getWidth().d_offset;
            }
            else
            {
                d_vertScrollbar->hide();
                d_vertScrollbar->setScrollPosition(0);
            }
        }
        else
        {
            d_vertScrollbar->hide();
            d_vertScrollbar->setScrollPosition(0);
            d_horzScrollbar->hide();
            d_horzScrollbar->setScrollPosition(0);
        }
    }
    
    //
    // Set up scroll bar values
    //
    
    float itemHeight;
    if (!d_listItems.empty())
        itemHeight = d_listItems[0]->getPixelSize().d_height;
    else
        itemHeight = 10;
    
    d_vertScrollbar->setDocumentSize(totalHeight);
    d_vertScrollbar->setPageSize(renderArea.getHeight());
    d_vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / itemHeight));
    d_vertScrollbar->setScrollPosition(d_vertScrollbar->getScrollPosition());
    
    d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getWidth().d_offset);
    //   d_horzScrollbar->setDocumentSize(widestItem + d_vertScrollbar->getAbsoluteWidth());
    d_horzScrollbar->setPageSize(renderArea.getWidth());
    d_horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / HORIZONTAL_STEP_SIZE_DIVISOR));
    d_horzScrollbar->setScrollPosition(d_horzScrollbar->getScrollPosition());
}
Beispiel #15
0
void MovieRenderer::Imp::prepareForStart()
{
	struct locals {
		static void eraseUncompatibleExistingLevel(const TFilePath &fp, const TDimension &imageSize) // nothrow
		{
			assert(!fp.isEmpty());

			if (TSystem::doesExistFileOrLevel(fp)) {
				bool remove = false;

				// In case the raster specifics are different from those of a currently
				// existing movie, erase it
				try {
					TLevelReaderP lr(fp);
					lr->loadInfo();

					const TImageInfo *info = lr->getImageInfo();
					if (!info || info->m_lx != imageSize.lx || info->m_ly != imageSize.ly)
						TSystem::removeFileOrLevel(fp); // nothrow
				} catch (...) {
					// Same if the level could not be read/opened
					TSystem::removeFileOrLevel(fp); // nothrow
				}

				// NOTE: The level removal procedure could still fail.
				// In this case, no signaling takes place. The level readers will throw
				// when the time to write on the file comes, leading to a render failure.
			}
		}
	};

	TOutputProperties *oprop = m_scene->getProperties()->getOutputProperties();
	double frameRate = (double)oprop->getFrameRate();

	/*-- Frame rate の stretch --*/
	double stretchFactor = oprop->getRenderSettings().m_timeStretchTo / oprop->getRenderSettings().m_timeStretchFrom;
	frameRate *= stretchFactor;

	// Get the shrink
	int shrinkX = m_renderSettings.m_shrinkX, shrinkY = m_renderSettings.m_shrinkY;

	//Build the render area
	TPointD cameraPos(-0.5 * m_frameSize.lx, -0.5 * m_frameSize.ly);
	TDimensionD cameraRes(double(m_frameSize.lx) / shrinkX, double(m_frameSize.ly) / shrinkY);
	TDimension cameraResI(cameraRes.lx, cameraRes.ly);

	TRectD renderArea(cameraPos.x, cameraPos.y, cameraPos.x + cameraRes.lx, cameraPos.y + cameraRes.ly);
	setRenderArea(renderArea);

	if (!m_fp.isEmpty()) {
		try // Construction of a LevelUpdater may throw (well, almost ANY operation on a LevelUpdater
		{   // could throw). But due to backward compatibility this function is assumed to be non-throwing.
			if (!m_renderSettings.m_stereoscopic) {
				locals::eraseUncompatibleExistingLevel(m_fp, cameraResI);

				m_levelUpdaterA.reset(new LevelUpdater(m_fp, oprop->getFileFormatProperties(m_fp.getType())));
				m_levelUpdaterA->getLevelWriter()->setFrameRate(frameRate);
			} else {
				TFilePath leftFp = m_fp.withName(m_fp.getName() + "_l");
				TFilePath rightFp = m_fp.withName(m_fp.getName() + "_r");

				locals::eraseUncompatibleExistingLevel(leftFp, cameraResI);
				locals::eraseUncompatibleExistingLevel(rightFp, cameraResI);

				m_levelUpdaterA.reset(new LevelUpdater(leftFp, oprop->getFileFormatProperties(leftFp.getType())));
				m_levelUpdaterA->getLevelWriter()->setFrameRate(frameRate);

				m_levelUpdaterB.reset(new LevelUpdater(rightFp, oprop->getFileFormatProperties(rightFp.getType())));
				m_levelUpdaterB->getLevelWriter()->setFrameRate(frameRate);
			}
		} catch (...) {
			// If we get here, it's because one of the LevelUpdaters could not be created. So, let's say
			// that if one could not be created, then ALL OF THEM couldn't (ie saving is not possible at all).
			m_levelUpdaterA.reset();
			m_levelUpdaterB.reset();
		}
	}
}