Beispiel #1
0
void CRender::SelectItemsWithin(const RectF &r)
{
	CComPtr<boost::scoped_lock_ref_counted> lock;
	CComPtr<IGraphItem> item;
	CComPtr<IUnknown> unk;
	CComQIPtr<IRenderer> ir;
	RectF box;

	IGraphItemVector results;
	m_graph->GetChildren(results);

	for(IGraphItemVector::iterator itr=results.begin(); itr!=results.end(); ++itr)
	{
		item=*itr;			
		unk=item->GetPropertyUnknown(0);

		if(unk)
		{
			ir=static_cast<IRenderer*>(unk.p);
			if(ir!=0)
			{
				ir->GetBoundsBox(box);
				if(box.IntersectsWith(r))
					ir->SetSelected(true, true);
			}
		}
	}
}
Beispiel #2
0
void GPDrawShadowTextSimple( Graphics&gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
	Gdiplus::Font& gcfont = fontIn;
	Rect rcText = CRect2Rect(rcIn);
	StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisWord);
	fmt.SetLineAlignment(StringAlignmentCenter);
	StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;

	GraphicsContainer  gcContainer = gc.BeginContainer();
	gc.SetSmoothingMode(SmoothingModeAntiAlias);
	CComBSTR btrTxtIn(strTxtIn);

	SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
	RectF rfText = Rect2RectF(rcText);
	if (shadowBrushClrIn != 0)
	{
		rfText.Offset(1.0, 1.0);
		gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	}

	textbrush.SetColor(ARGB2Color(BrushClrIn));
	gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	gc.EndContainer(gcContainer);
}
Beispiel #3
0
void GFXDrawUtil::drawBitmapSR( GFXTextureObject*texture, const Point2F &in_rAt, const RectF &srcRect, const GFXBitmapFlip in_flip /*= GFXBitmapFlip_None*/, const GFXTextureFilterType filter /*= GFXTextureFilterPoint */ , bool in_wrap /*= true*/ )
{
   AssertFatal( texture != 0, "No texture specified for drawBitmapSR()" );

   RectF stretch( in_rAt.x, in_rAt.y, srcRect.len_x(), srcRect.len_y() );
   drawBitmapStretchSR( texture, stretch, srcRect, in_flip, filter, in_wrap );
}
	void CoreLayer2D_Imp::DrawRotatedRectangleAdditionally(RectF drawingArea, Color color, Vector2DF rotationCenter, float angle, RectF uv, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;

		std::array<Color, 4> col = { color, color, color, color };

		SafeAddRef(texture);

		auto vertexes = drawingArea.GetVertexes();

		auto globalCenter = vertexes[0] + rotationCenter;

		for (auto& vert : vertexes)
		{
			vert -= globalCenter;
			auto deg = vert.GetDegree();
			deg += angle;
			vert.SetDegree(deg);
			vert += globalCenter;
		}


		sprite.pos = vertexes;
		sprite.col = col;
		sprite.uv = uv.GetVertexes();
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}
    void TreeInspectorPreview::init(spActor item)
    {
        //_item = item;
        STDRenderer r(&_videoCache);
        RenderState rs;
        rs.renderer = &r;
        rs.transform = item->getTransform();
        r.begin(0);
        //r.setTransform(rs.transform);
        item->doRender(rs);
        r.end();
        r.drawBatch();

        setSize(30, 30);

        RectF itemRect = _videoCache._bounds;
        if (itemRect.isEmpty())
        {
            itemRect = item->getDestRect();
            if (itemRect.isEmpty())
                itemRect.setSize(Vector2(10, 4));
        }

        Vector2 ns = fitSize(Vector2(50.0f, 50.0f), itemRect.size);
        float scale = ns.x / itemRect.size.x;

        _cacheTransform.identity();

        _cacheTransform.scale(Vector2(scale, scale));
        _cacheTransform.translate(-itemRect.pos);



        AnimationFrame fr = _tree->_resSystem->getResAnim("checker")->getFrame(0, 0);
        //Point itemSize(30, 30);// = _getItemRect().size;

        RectF srcRect = fr.getSrcRect();
        const Diffuse& df = fr.getDiffuse();
        srcRect.size.x = ns.x / (float)df.base->getWidth();
        srcRect.size.y = ns.y / (float)df.base->getHeight();
        RectF destRect = fr.getDestRect();
        destRect.size = ns;

        AnimationFrame cfr;
        cfr.init(0, df, srcRect, destRect, ns);

        setAnimFrame(cfr);


        /*
        spEventHandler bh = new EventHandler();

        bh->setCallbackEnter(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackExit(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackPressDown(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        bh->setCallbackPressUp(CLOSURE(this, &TreeInspectorPreview::_onEvent));
        addEventHandler(bh);
        */
    }
Beispiel #6
0
	RectF WidgetLayout::GetRect() const
	{
		RectF parentRect = GetParentRectangle();

		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		return rectangle;
	}
Beispiel #7
0
static RectF RectFUnion(RectF& r1, RectF& r2) {
    if (r2.IsEmptyArea())
        return r1;
    if (r1.IsEmptyArea())
        return r2;
    RectF ru;
    ru.Union(ru, r1, r2);
    return ru;
}
void GridLabel::deselect(void)
{
    RectF r;
    r.setLeft(-2);
    r.setRight(-2);
    r.setTop(-1);
    r.setBottom(-1);
    m_pEditData->setCatchRect(r);
    update();
}
void Graphics::FillRectangle(Brush* brush, const RectF& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private);
	cairo_set_source(cg, cp);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_fill(cg);
	cairo_restore(cg);
}
Beispiel #10
0
GTEST_TEST(RageRect, float_center)
{
	using namespace Rage;
	
	RectF test;
	
	RectF bigger{ -1, -1, 1, 1 };
	
	EXPECT_EQ(test.GetCenterX(), bigger.GetCenterX());
	EXPECT_EQ(test.GetCenterY(), bigger.GetCenterY());
}
Beispiel #11
0
	void WidgetLayout::SetRect(const RectF& rect)
	{
		RectF parentRect = GetParentRectangle();
		RectF parentAnchoredRect(parentRect.Size()*mData->anchorMin,
								 parentRect.Size()*mData->anchorMax);

		mData->offsetMin = rect.LeftBottom() - parentAnchoredRect.LeftBottom();
		mData->offsetMax = rect.RightTop() - parentAnchoredRect.RightTop();

		SetDirty();
	}
Beispiel #12
0
	void WidgetLayout::SetSize(const Vec2F& size)
	{
		RectF parentRect = GetParentRectangle();
		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		Vec2F szDelta = size - rectangle.Size();
		mData->offsetMax += szDelta*(Vec2F::One() - mData->pivot);
		mData->offsetMin -= szDelta*mData->pivot;

		SetDirty();
	}
Beispiel #13
0
	void WidgetLayout::SetHeight(float value)
	{
		RectF parentRect = GetParentRectangle();
		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		float szDelta = value - rectangle.Height();
		mData->offsetMax.y += szDelta*(1.0f - mData->pivot.y);
		mData->offsetMin.y -= szDelta*mData->pivot.y;

		SetDirty();
	}
void Graphics::DrawImage(Image* image, const RectF& rc, const ImageAttributes* attr) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private);

    if(attr!=0) {
        Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private);
        g->DrawImage(gdiImage, Gdiplus::RectF(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0.0f, 0.0f, (float)gdiImage->GetWidth(), (float)gdiImage->GetHeight(), Gdiplus::UnitPixel, ia);
    }
    else {
        g->DrawImage(gdiImage, ToGDIRect<RectF, Gdiplus::RectF>(rc));
    }
}
Beispiel #15
0
	void WidgetLayout::SetWidth(float value)
	{
		RectF parentRect = GetParentRectangle();
		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		float szDelta = value - rectangle.Width();
		mData->offsetMax.x += szDelta*(1.0f - mData->pivot.x);
		mData->offsetMin.x -= szDelta*mData->pivot.x;

		SetDirty();
	}
void Graphics::DrawRectangle(Pen* pen, const RectF& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	PenPrivate* pp = reinterpret_cast<PenPrivate*>(pen->_private);
	cairo_pattern_t* cp = pp->pattern;
	cairo_set_source(cg, cp);
	cairo_set_line_width(cg, pp->width);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_stroke(cg);
	cairo_restore(cg);
}
void UnwrappedSurface::zoom() {
  if (!m_viewImage)
    return;
  RectF newView = selectionRectUV();
  if (newView.isEmpty())
    return;
  m_zoomStack.push(m_viewRect);
  m_viewRect = newView;
  updateView();
  emptySelectionRect();
  emit updateInfoText();
}
Beispiel #18
0
	void WidgetLayout::SetPosition(const Vec2F& position)
	{
		RectF parentRect = GetParentRectangle();
		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		Vec2F delta = position - rectangle.LeftBottom() + rectangle.Size()*mData->pivot;
		mData->offsetMin += delta;
		mData->offsetMax += delta;

		SetDirty();
	}
void CRevisionGraphWnd::DrawShadow (GraphicsDevice& graphics, const RectF& rect,
									Color shadowColor, NodeShape shape)
{
	// draw the shadow

	RectF shadow = rect;
	shadow.Offset (2, 2);

	Pen pen (shadowColor);
	SolidBrush brush (shadowColor);

	DrawShape (graphics, shadowColor, 1, &pen, shadowColor, &brush, shadow, shape);
}
Beispiel #20
0
RectF Transformation::transformedBounds() const
{
  // Get transformed corners
  Corners corners;
  transformBox(corners);

  // Create a union of all corners
  RectF bounds;
  for (int i=0; i<Corners::NUM_OF_CORNERS; ++i)
    bounds = bounds.createUnion(RectF(corners[i].x, corners[i].y, 1, 1));

  return bounds;
}
Beispiel #21
0
void SonarMonitor::draw()
{
    Point point = m_hud->project(m_point);
    int radius = (m_hud->project(m_point + Point(0, m_radius)) - point).y;
    float scale = static_cast<float>(radius)/m_scale;
    PointF center = PointF(point) - PointF(1.5f);
    RectF rect = RectF(center, SizeF(4, 4));
    Matrix m(1);
    m = glm::scale(m, Vector3D(1, -1, 0));
    m = glm::rotate(m, m_hud->scenario()->yaw(), Vector3D(0, 0, 1));
    m = glm::translate(m, -m_hud->scenario()->position());

    m_hud->fontGreen().draw("T", point + Point(-2, -radius));
    m_hud->fontGreen().draw(QString("%1M").arg(m_scale), Rect(point + Point(-100, radius - 8), SizeF(200, -1)), true, false);
    m_center.draw(rect);

    for (fight::NavPoint *navPoint : m_hud->scenario()->navPoints())
        if (navPoint->isEnabled())
        {
            Vector2D dir = Vector2D(m * Vector4D(navPoint->position(), 1));
            float distance = glm::length(dir);
            if (distance < m_scale)
            {
                rect.setPos(center - dir*scale);
                m_nav.draw(rect);
            }
        }

    for (const auto &entry : m_hud->scenario()->sonar())
    {
        Vector2D dir = Vector2D(m * Vector4D(entry.object->position(), 1));
        float distance = glm::length(dir);
        if (distance < m_scale)
        {
            rect.setPos(center - dir*scale);
            (entry.isFriend ? m_friend : m_enemy).draw(rect);
        }
    }

    fight::Target &target = m_hud->scenario()->target();
    if (target.isLocked())
    {
        Vector2D dir = Vector2D(m * Vector4D(target.position(), 1));
        float distance = glm::length(dir);
        if (distance < m_scale)
        {
            rect.setPos(center - dir*scale);
            m_target.draw(rect);
        }
    }
}
	std::vector<Object*> &World::GetCullingObjects(RectF cullingRange)
	{
		tempObjects.clear();

		for (int r = 0; r <= resolution; ++r)
		{
			auto layer = layers[r];

			auto cellSize = layer->GetGrids()[0]->GetGridRange().GetSize();

			//分解能0の場合はワールド全部を探索
			RectF searchRange = (r != 0) ? RectF(cullingRange.X - cellSize.X / 2, cullingRange.Y - cellSize.Y / 2, cullingRange.Width + cellSize.X, cullingRange.Height + cellSize.Y)
				: layer->GetGrids()[0]->GetGridRange();

			Vector2DI upperLeft;
			Vector2DI lowerRight;

			//カリング対象のグリッド区間絞込
			{
				Vector2DF upperLeftRaw = (searchRange.GetPosition() - worldRange.GetPosition()) / cellSize;
				Vector2DF lowerRightRaw = (searchRange.GetPosition() + searchRange.GetSize() - worldRange.GetPosition()) / cellSize;

				upperLeftRaw.X = Max(0.0f, upperLeftRaw.X);
				upperLeftRaw.Y = Max(0.0f, upperLeftRaw.Y);

				lowerRightRaw.X = Min(worldRange.GetSize().X / cellSize.X - 1.0f, lowerRightRaw.X);
				lowerRightRaw.Y = Min(worldRange.GetSize().Y / cellSize.Y - 1.0f, lowerRightRaw.Y);

				upperLeft = Vector2DI((int)floor(upperLeftRaw.X), (int)floor(upperLeftRaw.Y));
				lowerRight = Vector2DI((int)floor(lowerRightRaw.X), (int)floor(lowerRightRaw.Y));
			}

			int xSize = 1 << r;

			for (int x = upperLeft.X; x <= lowerRight.X; ++x)
			{
				for (int y = upperLeft.Y; y <= lowerRight.Y; ++y)
				{
					auto grid = layer->GetGrids()[y*xSize + x];

					grid->GetCullingObjects(searchRange, tempObjects);
				}
			}
		}
		std::sort(tempObjects.begin(), tempObjects.end(), [](Object* obj1, Object* obj2)
		{
			return obj1->GetSortedKey() < obj2->GetSortedKey();
		});
		return tempObjects;
	}
void CRevisionGraphWnd::DrawStripes (GraphicsDevice& graphics, const CSize& offset)
{
	// we need to fill this visible area of the the screen
	// (even if there is graph in that part)

	RectF clipRect;
	if (graphics.graphics)
		graphics.graphics->GetVisibleClipBounds (&clipRect);

	// don't show stripes if we don't have multiple roots

	CSyncPointer<const ILayoutRectList> trees (m_state.GetTrees());
	if (trees->GetCount() < 2)
		return;

	// iterate over all trees

	for ( index_t i = 0, count = trees->GetCount(); i < count; ++i)
	{
		// screen coordinates covered by the tree

		CRect tree = trees->GetRect(i);
		REAL left = tree.left * m_fZoomFactor;
		REAL right = tree.right * m_fZoomFactor;
		RectF rect ( left - offset.cx
					, clipRect.Y
					, i+1 == count ? clipRect.Width : right - left
					, clipRect.Height);

		// relevant?

		if (rect.IntersectsWith (clipRect))
		{
			// draw the background stripe

			Color color (  (i & 1) == 0
						? m_Colors.GetColor (CColors::gdpStripeColor1)
						: m_Colors.GetColor (CColors::gdpStripeColor2));
			if (graphics.graphics)
			{
				SolidBrush brush (color);
				graphics.graphics->FillRectangle (&brush, rect);
			}
			else if (graphics.pSVG)
				graphics.pSVG->RoundedRectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height,
												color, 1, color);
		}
	}
}
void CRevisionGraphWnd::DrawGlyphs
	( GraphicsDevice& graphics
	, Image* glyphs
	, const CVisibleGraphNode* node
	, const RectF& nodeRect
	, DWORD state
	, DWORD allowed
	, bool upsideDown)
{
	// shortcut

	if ((state == 0) && (allowed == 0))
		return;

	// draw all glyphs

	PointF topCenter (0.5f * nodeRect.GetLeft() + 0.5f * nodeRect.GetRight(), nodeRect.GetTop());
	PointF rightCenter (nodeRect.GetRight(), 0.5f * nodeRect.GetTop() + 0.5f * nodeRect.GetBottom());
	PointF bottomCenter (0.5f * nodeRect.GetLeft() + 0.5f * nodeRect.GetRight(), nodeRect.GetBottom());

	DrawGlyphs ( graphics
				, glyphs
				, node
				, upsideDown ? bottomCenter : topCenter
				, (state & CGraphNodeStates::COLLAPSED_ABOVE) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_ABOVE) ? JoinGlyph : SplitGlyph
				, upsideDown ? Below : Above
				, CGraphNodeStates::COLLAPSED_ABOVE
				, CGraphNodeStates::SPLIT_ABOVE
				, (allowed & CGraphNodeStates::COLLAPSED_ABOVE) != 0);

	DrawGlyphs ( graphics
				, glyphs
				, node
				, rightCenter
				, (state & CGraphNodeStates::COLLAPSED_RIGHT) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_RIGHT) ? JoinGlyph : SplitGlyph
				, Right
				, CGraphNodeStates::COLLAPSED_RIGHT
				, CGraphNodeStates::SPLIT_RIGHT
				, (allowed & CGraphNodeStates::COLLAPSED_RIGHT) != 0);

	DrawGlyphs ( graphics
				, glyphs
				, node
				, upsideDown ? topCenter : bottomCenter
				, (state & CGraphNodeStates::COLLAPSED_BELOW) ? ExpandGlyph : CollapseGlyph
				, (state & CGraphNodeStates::SPLIT_BELOW) ? JoinGlyph : SplitGlyph
				, upsideDown ? Above : Below
				, CGraphNodeStates::COLLAPSED_BELOW
				, CGraphNodeStates::SPLIT_BELOW
				, (allowed & CGraphNodeStates::COLLAPSED_BELOW) != 0);

}
void Graphics::DrawRoundRectangle(Pen* pen, const RectF& rc, float d) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);

    Gdiplus::GraphicsPath gp;
    Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());

    gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
    gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
    gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);

    g->DrawPath(gdiPen, &gp);
}
void Graphics::FillRoundRectangle(Brush* brush, const RectF& rc, float d) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Brush* gdiBrush = reinterpret_cast<Gdiplus::Brush*>(brush->_private);

    Gdiplus::GraphicsPath gp;
    Gdiplus::RectF r(rc.GetLeft()-1.0f, rc.GetTop()-1.0f, rc.GetWidth(), rc.GetHeight());

    gp.AddArc(r.X, r.Y, d, d, 180.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y, d, d, 270.0f, 90.0f);
    gp.AddArc(r.X + r.Width - d, r.Y + r.Height - d, d, d, 0.0f, 90.0f);
    gp.AddArc(r.X, r.Y + r.Height - d, d, d, 90.0f, 90.0f);
    gp.AddLine(r.X, r.Y + r.Height - d, r.X, r.Y + d / 2.0f);

    g->FillPath(gdiBrush, &gp);
}
Beispiel #27
0
void CMap::Input(Vec2I position)
{
	Vec2I end_pos(position.x / GRID_WIDTH, position.y / GRID_HEIGHT);
	DEBUG_TRACE("start:%d,%d\tend:%d,%d\n", m_pos.x, m_pos.y, end_pos.x, end_pos.y);

	if (! IsFree(end_pos))
		return;

	QWORD start_time = GetTimer()->GetTime();
	if (m_Astar.FindPath(m_pos, end_pos))
	{
		QWORD end_time = GetTimer()->GetTime();
		DEBUG_TRACE("find path time:%f\n", GetTimer()->GetTimeMillisec(end_time - start_time));

		m_findPath.clear();
		std::vector<Vec2I>& vec = m_Astar.GetPath();
		m_findPath.reserve(vec.size());
		for (int i = 0; i < vec.size(); ++i)
		{
			Vec2I pt = vec[i];
			m_findPath.push_back(Grid2CenterPt(pt));
		}
		m_pos = end_pos;
		m_rect.SetRect(m_pos.x * GRID_WIDTH, m_pos.y * GRID_HEIGHT, (m_pos.x + 1) * GRID_WIDTH, (m_pos.y + 1) * GRID_HEIGHT);
	}
}
Beispiel #28
0
//---------------------------------------
void Widget::Draw( const Camera& camera )
{
	// If not visible, do not draw this Widget or its children.
	if( mIsVisible )
	{
		// Draw the Widget.
		OnDraw( camera );

		if( mDebugLayout )
		{
			// Draw debug visual.
			RectF bounds = CalculateBounds();
			DrawRectOutline( bounds.Left, bounds.Top, bounds.Width(), bounds.Height(), Color::PINK, 1.5f );
		}
	}
}
Beispiel #29
0
void TitleBar::OnDraw(const Context &context) {
  using namespace base;
  using namespace graphic;

  int scale = context.surface()->GetScale();

  const RectF bounds = GetBounds() * scale;
  float factor = 0.5f * scale;

  Paint paint;
  paint.SetAntiAlias(true);
  paint.SetStyle(Paint::kStyleFill);

  Point2F points[2] = {{factor, bounds.top + factor}, {factor, bounds.bottom}};
  uint32_t colors[2] = {0xFFE7E7E7, 0xFFD7D7D7};
  float pos[2] = {0.f, 1.f};

  Shader shader = GradientShader::MakeLinear(points, colors, pos, 2, Shader::kTileModeClamp);
  paint.SetShader(shader);

  context.canvas()->DrawRect(RectF::FromLTRB(bounds.left + factor,
                                             bounds.top + factor,
                                             bounds.right - factor,
                                             bounds.bottom), paint);

  paint.Reset();
  paint.SetAntiAlias(true);
  paint.SetStyle(Paint::kStyleFill);
  paint.SetFont(font_);
  paint.SetTextSize(font_.GetSize() * scale);

  paint.SetColor(Theme::GetData().title_bar.active.foreground.colors[0]);

  float text_width = paint.MeasureText(title_.c_str(), title_.length());

  SkTextBox text_box;
  // Put the foreground at the center
  text_box.setBox(bounds.l + (bounds.width() - text_width) / 2.f,
                  bounds.t + 1.f, // move down a little for better look
                  bounds.r - (bounds.width() - text_width) / 2.f,
                  bounds.b);
  text_box.setSpacingAlign(SkTextBox::kCenter_SpacingAlign);
  text_box.setText(title_.c_str(), title_.length(), paint.GetSkPaint());
  text_box.draw(context.canvas()->GetSkCanvas());

}
Beispiel #30
0
	void CoreLayer2D_Imp::DrawRectangleAdditionally(RectF drawingArea, Color color, RectF uv, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority)
	{
		Sprite sprite;

		std::array<Color, 4> col = { color, color, color, color };

		SafeAddRef(texture);

		sprite.pos = drawingArea.GetVertexes();
		sprite.col = col;
		sprite.uv = uv.GetVertexes();
		sprite.Texture_ = CreateSharedPtrWithReleaseDLL(texture);
		sprite.AlphaBlend_ = alphaBlend;
		sprite.Priority = priority;

		sprites.push_back(sprite);
	}