void UIStaticText::Draw(const UIGeometricData &geometricData) { textBlock->SetRectSize(size); textBlock->SetPosition(geometricData.position); textBlock->SetPivotPoint(geometricData.pivotPoint); PrepareSprite(); textBlock->PreDraw(); UIControl::Draw(geometricData); if(!FLOAT_EQUAL(shadowBg->GetDrawColor().a, 0.0f) && (!FLOAT_EQUAL(shadowOffset.dx, 0.0f) || !FLOAT_EQUAL(shadowOffset.dy, 0.0f))) { textBlock->Draw(GetShadowColor(), &shadowOffset); UIGeometricData shadowGeomData; shadowGeomData.position = shadowOffset; shadowGeomData.size = GetSize(); shadowGeomData.AddToGeometricData(geometricData); shadowBg->SetAlign(textBg->GetAlign()); shadowBg->SetPerPixelAccuracyType(background->GetPerPixelAccuracyType()); shadowBg->Draw(shadowGeomData); } textBlock->Draw(GetTextColor()); textBg->SetPerPixelAccuracyType(background->GetPerPixelAccuracyType()); textBg->Draw(geometricData); }
void PropertyLineEditControl::Draw(const UIGeometricData &geometricData) { RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 0.3f); RenderHelper::Instance()->FillRect(geometricData.GetUnrotatedRect()); RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); RenderHelper::Instance()->DrawRect(GetWorkZone()); RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); for (int32 k = 0; k < (int32)values.size() - 1; ++k) { RenderHelper::Instance()->DrawLine(CalcRealPosition(values[k]), CalcRealPosition(values[k + 1])); } Vector2 vlast = CalcRealPosition(values[(int32)values.size() - 1]); Vector2 vlast2 = CalcRealPosition(PropertyRect(maxX, maxY)); vlast2.y = vlast.y; RenderHelper::Instance()->DrawLine(vlast, vlast2); for (int32 k = 0; k < (int32)values.size(); ++k) { Vector2 pos = CalcRealPosition(values[k]); RenderHelper::Instance()->DrawRect(RectFromPosition(pos)); } RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); }
void UIScreen::FillScreenBorders(const UIGeometricData &geometricData) { RenderManager::Instance()->SetColor(0, 0, 0, 1.0f); UIGeometricData drawData; drawData.position = relativePosition; drawData.size = size; drawData.pivotPoint = pivotPoint; drawData.scale = scale; drawData.angle = angle; drawData.AddToGeometricData(geometricData); Rect drawRect = drawData.GetUnrotatedRect(); if (Core::Instance()->GetVirtualScreenXMin() < 0) { RenderHelper::Instance()->FillRect(Rect( Core::Instance()->GetVirtualScreenXMin() , 0 , -Core::Instance()->GetVirtualScreenXMin() , Core::Instance()->GetVirtualScreenHeight())); RenderHelper::Instance()->FillRect(Rect( Core::Instance()->GetVirtualScreenWidth() , 0 , Core::Instance()->GetVirtualScreenXMax() - Core::Instance()->GetVirtualScreenWidth() , Core::Instance()->GetVirtualScreenHeight())); } else { RenderHelper::Instance()->FillRect(Rect( 0 , Core::Instance()->GetVirtualScreenYMin() , Core::Instance()->GetVirtualScreenWidth()+1 , -Core::Instance()->GetVirtualScreenYMin())); RenderHelper::Instance()->FillRect(Rect( 0 , Core::Instance()->GetVirtualScreenHeight() , Core::Instance()->GetVirtualScreenWidth()+1 , Core::Instance()->GetVirtualScreenYMax() - Core::Instance()->GetVirtualScreenHeight())); } RenderManager::Instance()->ResetColor(); }
void InfoControl::Draw(const UIGeometricData &geometricData) { UIControl::Draw(geometricData); RenderManager::Instance()->SetColor(GetBackground()->color); RenderHelper::Instance()->DrawRect(geometricData.GetUnrotatedRect()); Rect outerRect(geometricData.GetUnrotatedRect()); outerRect.x -= 1.0f; outerRect.y -= 1.0f; outerRect.dx += 2.0f; outerRect.dy += 2.0f; Color outerColor(GetBackground()->color); outerColor.r = 1.0f - outerColor.r; outerColor.b = 1.0f - outerColor.b; RenderManager::Instance()->SetColor(outerColor); RenderHelper::Instance()->DrawRect(outerRect); RenderManager::Instance()->ResetColor(); }
void PropertyLineEditControl::Draw(const UIGeometricData &geometricData) { RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 0.3f); RenderHelper::Instance()->FillRect(geometricData.GetUnrotatedRect()); const Rect & cRect = GetWorkZone(); RenderManager::Instance()->SetColor(0.8f, 0.6f, 0.6f, 1.0f); RenderHelper::Instance()->DrawLine(CalcRealPosition(PropertyRect(curTime, maxY)), CalcRealPosition(PropertyRect(curTime, minY))); RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); RenderHelper::Instance()->DrawRect(cRect); RenderHelper::Instance()->DrawLine(Vector2(cRect.x - 3, cRect.y + cRect.dy/2), Vector2(cRect.x + 3, cRect.y + cRect.dy/2)); RenderHelper::Instance()->DrawLine(Vector2(cRect.x + cRect.dx - 3, cRect.y + cRect.dy/2), Vector2(cRect.x + cRect.dx + 3, cRect.y + cRect.dy/2)); RenderHelper::Instance()->DrawLine(Vector2(cRect.x + cRect.dx/2, cRect.y - 3), Vector2(cRect.x + cRect.dx/2, cRect.y + 3)); RenderHelper::Instance()->DrawLine(Vector2(cRect.x + cRect.dx/2, cRect.y + cRect.dy - 3), Vector2(cRect.x + cRect.dx/2, cRect.y + cRect.dy + 3)); RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); for (int32 k = 0; k < (int32)values.size() - 1; ++k) { RenderHelper::Instance()->DrawLine(CalcRealPosition(values[k]), CalcRealPosition(values[k + 1])); } Vector2 vlast = CalcRealPosition(values[(int32)values.size() - 1]); Vector2 vlast2 = CalcRealPosition(PropertyRect(maxX, maxY)); vlast2.y = vlast.y; RenderHelper::Instance()->DrawLine(vlast, vlast2); for (int32 k = 0; k < (int32)values.size(); ++k) { Vector2 pos = CalcRealPosition(values[k]); if(activeValueIndex == k) { RenderManager::Instance()->SetColor(0.6f, 0.6f, 0.6f, 1.0f); RenderHelper::Instance()->FillRect(RectFromPosition(pos)); } else if(selectedValueIndex == k) { RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); RenderHelper::Instance()->FillRect(RectFromPosition(pos)); } else { RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); RenderHelper::Instance()->DrawRect(RectFromPosition(pos)); } } }
void PaperControl::Draw(const UIGeometricData &geometricData) { UIControl::Draw(geometricData); const Rect &r = geometricData.GetUnrotatedRect(); int32 borderSize = Min(r.dx, r.dy); borderSize /= 70; borderRect.x = borderSize + r.x; borderRect.y = borderSize + r.y; borderRect.dx = r.dx - borderSize * 2; borderRect.dy = r.dy - borderSize * 2; RenderManager::Instance()->SetColor(0.f, 0.f, 0.f, 1.f); RenderHelper::Instance()->DrawRect(borderRect); RenderManager::Instance()->ResetColor(); for (int i = 0; i < shapes.size(); i++) { shapes[i]->Draw(geometricData); } }
void UI3DView::Draw(const UIGeometricData & geometricData) { #if 1 RenderManager::Instance()->SetRenderState(RenderState::RENDERSTATE_3D_BLEND); const Rect & viewportRect = geometricData.GetUnrotatedRect(); viewportRc = viewportRect; RenderManager::Instance()->PushDrawMatrix(); RenderManager::Instance()->PushMappingMatrix(); int32 renderOrientation = RenderManager::Instance()->GetRenderOrientation(); Rect viewportSave = RenderManager::Instance()->GetViewport(); RenderManager::Instance()->SetViewport(viewportRect, false); if (scene) scene->Draw(); RenderManager::Instance()->SetViewport(viewportSave, true); RenderManager::Instance()->SetRenderOrientation(renderOrientation); RenderManager::Instance()->PopDrawMatrix(); RenderManager::Instance()->PopMappingMatrix(); RenderManager::Instance()->SetRenderState(RenderState::RENDERSTATE_2D_BLEND); RenderManager::Instance()->Setup2DMatrices(); // modelViewSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW); // Logger::Info("Model matrix"); // modelViewSave.Dump(); // projectionSave = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_PROJECTION); // Logger::Info("Proj matrix"); // projectionSave.Dump(); #endif }
void UIControlBackground::Draw(const UIGeometricData &geometricData) { Rect drawRect = geometricData.GetUnrotatedRect(); // if(drawRect.x > RenderManager::Instance()->GetScreenWidth() || drawRect.y > RenderManager::Instance()->GetScreenHeight() || drawRect.x + drawRect.dx < 0 || drawRect.y + drawRect.dy < 0) // {//TODO: change to screen size from control system and sizes from sprite // return; // } RenderManager::Instance()->SetColor(drawColor.r, drawColor.g, drawColor.b, drawColor.a); Sprite::DrawState drawState; if (spr) { drawState.frame = frame; if (spriteModification) { drawState.flags = spriteModification; } // spr->Reset(); // spr->SetFrame(frame); // spr->SetModification(spriteModification); } switch (type) { case DRAW_ALIGNED: { if (!spr)break; if(align & ALIGN_LEFT) { drawState.position.x = drawRect.x; } else if(align & ALIGN_RIGHT) { drawState.position.x = drawRect.x + drawRect.dx - spr->GetWidth() * geometricData.scale.x; } else { drawState.position.x = drawRect.x + ((drawRect.dx - spr->GetWidth() * geometricData.scale.x) * 0.5f) ; } if(align & ALIGN_TOP) { drawState.position.y = drawRect.y; } else if(align & ALIGN_BOTTOM) { drawState.position.y = drawRect.y + drawRect.dy - spr->GetHeight() * geometricData.scale.y; } else { drawState.position.y = drawRect.y + ((drawRect.dy - spr->GetHeight() * geometricData.scale.y + spr->GetDefaultPivotPoint().y * geometricData.scale.y) * 0.5f) ; } if(geometricData.angle != 0) { float tmpX = drawState.position.x; drawState.position.x = (tmpX - geometricData.position.x) * geometricData.cosA + (geometricData.position.y - drawState.position.y) * geometricData.sinA + geometricData.position.x; drawState.position.y = (tmpX - geometricData.position.x) * geometricData.sinA + (drawState.position.y - geometricData.position.y) * geometricData.cosA + geometricData.position.y; // spr->SetAngle(geometricData.angle); drawState.angle = geometricData.angle; } // spr->SetPosition(x, y); drawState.scale = geometricData.scale; drawState.pivotPoint = spr->GetDefaultPivotPoint(); // spr->SetScale(geometricData.scale); //if (drawState.scale.x == 1.0 && drawState.scale.y == 1.0) { switch(perPixelAccuracyType) { case PER_PIXEL_ACCURACY_ENABLED: if(lastDrawPos == drawState.position) { drawState.usePerPixelAccuracy = true; } break; case PER_PIXEL_ACCURACY_FORCED: drawState.usePerPixelAccuracy = true; break; default: break; } } lastDrawPos = drawState.position; spr->Draw(&drawState); } break; case DRAW_SCALE_TO_RECT: { if (!spr)break; drawState.position = geometricData.position; drawState.flags = spriteModification; drawState.scale.x = drawRect.dx / spr->GetSize().dx; drawState.scale.y = drawRect.dy / spr->GetSize().dy; drawState.pivotPoint.x = geometricData.pivotPoint.x / (geometricData.size.x / spr->GetSize().dx); drawState.pivotPoint.y = geometricData.pivotPoint.y / (geometricData.size.y / spr->GetSize().dy); drawState.angle = geometricData.angle; { switch(perPixelAccuracyType) { case PER_PIXEL_ACCURACY_ENABLED: if(lastDrawPos == drawState.position) { drawState.usePerPixelAccuracy = true; } break; case PER_PIXEL_ACCURACY_FORCED: drawState.usePerPixelAccuracy = true; break; default: break; } } lastDrawPos = drawState.position; // spr->SetPosition(geometricData.position); // spr->SetScale(drawRect.dx / spr->GetSize().dx, drawRect.dy / spr->GetSize().dy); // spr->SetPivotPoint(geometricData.pivotPoint.x / (geometricData.size.x / spr->GetSize().dx), geometricData.pivotPoint.y / (geometricData.size.y / spr->GetSize().dy)); // spr->SetAngle(geometricData.angle); spr->Draw(&drawState); } break; case DRAW_SCALE_PROPORTIONAL: case DRAW_SCALE_PROPORTIONAL_ONE: { if (!spr)break; float32 w, h; w = drawRect.dx / (spr->GetWidth() * geometricData.scale.x); h = drawRect.dy / (spr->GetHeight() * geometricData.scale.y); float ph = spr->GetDefaultPivotPoint().y; if(w < h) { if(type==DRAW_SCALE_PROPORTIONAL_ONE) { w = spr->GetWidth() * h * geometricData.scale.y; ph *= h; h = drawRect.dy; } else { h = spr->GetHeight() * w * geometricData.scale.x; ph *= w; w = drawRect.dx; } } else { if(type==DRAW_SCALE_PROPORTIONAL_ONE) { h = spr->GetHeight() * w * geometricData.scale.x; ph *= w; w = drawRect.dx; } else { w = spr->GetWidth() * h * geometricData.scale.y; ph *= h; h = drawRect.dy; } } if(align & ALIGN_LEFT) { drawState.position.x = drawRect.x; } else if(align & ALIGN_RIGHT) { drawState.position.x = (drawRect.x + drawRect.dx - w); } else { drawState.position.x = drawRect.x + (int32)((drawRect.dx - w) * 0.5) ; } if(align & ALIGN_TOP) { drawState.position.y = drawRect.y; } else if(align & ALIGN_BOTTOM) { drawState.position.y = (drawRect.y + drawRect.dy - h); } else { drawState.position.y = (drawRect.y) + (int32)((drawRect.dy - h + ph) * 0.5) ; } drawState.scale.x = w / spr->GetWidth(); drawState.scale.y = h / spr->GetHeight(); // spr->SetScaleSize(w, h); if(geometricData.angle != 0) { float32 tmpX = drawState.position.x; drawState.position.x = ((tmpX - geometricData.position.x) * geometricData.cosA + (geometricData.position.y - drawState.position.y) * geometricData.sinA + geometricData.position.x); drawState.position.y = ((tmpX - geometricData.position.x) * geometricData.sinA + (drawState.position.y - geometricData.position.y) * geometricData.cosA + geometricData.position.y); drawState.angle = geometricData.angle; // spr->SetAngle(geometricData.angle); } // spr->SetPosition((float32)x, (float32)y); { switch(perPixelAccuracyType) { case PER_PIXEL_ACCURACY_ENABLED: if(lastDrawPos == drawState.position) { drawState.usePerPixelAccuracy = true; } break; case PER_PIXEL_ACCURACY_FORCED: drawState.usePerPixelAccuracy = true; break; default: break; } } lastDrawPos = drawState.position; spr->Draw(&drawState); } break; case DRAW_FILL: {//TODO: add rotation RenderHelper::Instance()->FillRect(drawRect); } break; case DRAW_STRETCH_BOTH: case DRAW_STRETCH_HORIZONTAL: case DRAW_STRETCH_VERTICAL: DrawStretched(drawRect); break; } RenderManager::Instance()->ResetColor(); }
void UIScrollView::SystemDraw(const UIGeometricData & geometricData) { float32 invScale = 1.0f;// / zoomScale; Vector2 drawPos; drawPos.x = (scrollOrigin.x + drawScrollPos.x) * invScale; drawPos.y = (scrollOrigin.y + drawScrollPos.y) * invScale; //Logger::Debug("dp %f %f", drawPos.x, drawPos.y); //Rect2f currRect = r + _parentRect.GetPosition() + drawPos; UIGeometricData drawData; drawData.position = relativePosition; drawData.size = size; drawData.pivotPoint = pivotPoint; drawData.scale = scale; drawData.angle = angle; drawData.AddToGeometricData(geometricData); if(clipContents) {//WARNING: for now clip contents don't work for rotating controls if you have any ideas you are welcome RenderManager::Instance()->ClipPush(); RenderManager::Instance()->ClipRect(drawData.GetUnrotatedRect()); } if (debugDrawEnabled) {//TODO: Add debug draw for rotated controls RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f); RenderHelper::Instance()->DrawRect(drawData.GetUnrotatedRect()); RenderManager::Instance()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); } // drawData.position = drawPos + relativePosition * invScale; drawData.position = drawPos + relativePosition; drawData.size = size; drawData.pivotPoint = pivotPoint; // drawData.scale = scale; drawData.scale = Vector2(zoomScale, zoomScale); drawData.angle = angle; drawData.AddToGeometricData(geometricData); if(visible) { Draw(drawData); } //isIteratorCorrupted = false; List<UIControl*>::iterator it = childs.begin(); for(; it != childs.end(); it++) { (*it)->SystemDraw(drawData); //DVASSERT(!isIteratorCorrupted); } if(visible) { DrawAfterChilds(drawData); } if(clipContents) { RenderManager::Instance()->ClipPop(); } /* if(clipContents) { RenderManager::ClipPush(); RenderManager::ClipRect(relativeRect + _parentRect.GetPosition()); } float32 invScale = 1.0f / zoomScale; Point2f drawPos; drawPos.x = (scrollOrigin.x + drawScrollPos.x) * invScale; drawPos.y = (scrollOrigin.y + drawScrollPos.y) * invScale; //Rect2f parentRect = _parentRect + drawPos; Rect2f r = relativeRect; r.x *= invScale; r.y *= invScale; Rect2f currRect = r + _parentRect.GetPosition() + drawPos; if(visible) { Draw(currRect); } List<UIControl*>::iterator it = childs.begin(); for(; it != childs.end(); it++) { UIControl * c = *it; c->SystemDraw(currRect); } if(visible) { DrawAfterChilds(currRect); } if(clipContents) { RenderManager::ClipPop(); } */ }