Fix many rendering bugs introduced in df83ee4 and 9f97e9a.

pull/97/head
EvilSpirit 2016-10-13 20:23:22 +07:00 committed by whitequark
parent ea52fcbce1
commit d2c250324b
5 changed files with 20 additions and 16 deletions

View File

@ -60,6 +60,7 @@ void GraphicsWindow::Selection::Draw(bool isHovered, Canvas *canvas) {
strokeEmphasis.layer = Canvas::Layer::FRONT;
strokeEmphasis.color = Style::Color(Style::HOVERED).WithAlpha(50);
strokeEmphasis.width = 40;
strokeEmphasis.unit = Canvas::Unit::PX;
Canvas::hStroke hcsEmphasis = canvas->GetStroke(strokeEmphasis);
Point2d topLeftScreen;
@ -545,6 +546,8 @@ void GraphicsWindow::DrawSnapGrid(Canvas *canvas) {
Canvas::Stroke stroke = {};
stroke.layer = Canvas::Layer::BACK;
stroke.color = Style::Color(Style::DATUM).WithAlpha(75);
stroke.unit = Canvas::Unit::PX;
stroke.width = 1.0f;
Canvas::hStroke hcs = canvas->GetStroke(stroke);
for(i = i0 + 1; i < i1; i++) {
@ -679,6 +682,7 @@ void GraphicsWindow::Draw(Canvas *canvas) {
SK.GetGroup(activeGroup)->DrawMesh(Group::DrawMeshAs::SELECTED, canvas);
Canvas::Stroke strokeDatum = Style::Stroke(Style::DATUM);
strokeDatum.unit = Canvas::Unit::PX;
strokeDatum.layer = Canvas::Layer::FRONT;
strokeDatum.width = 1;
Canvas::hStroke hcsDatum = canvas->GetStroke(strokeDatum);

View File

@ -463,32 +463,30 @@ void Entity::Draw(DrawAs how, Canvas *canvas) {
hs = Style::ForEntity(h);
}
Canvas::Stroke stroke = {};
Canvas::Stroke stroke = Style::Stroke(hs);
switch(how) {
case DrawAs::DEFAULT:
stroke = Style::Stroke(hs);
stroke.layer = Canvas::Layer::NORMAL;
stroke.layer = Canvas::Layer::NORMAL;
break;
case DrawAs::OVERLAY:
stroke.layer = Canvas::Layer::FRONT;
stroke.layer = Canvas::Layer::FRONT;
break;
case DrawAs::HIDDEN:
stroke = Style::Stroke(Style::HIDDEN_EDGE);
stroke.layer = Canvas::Layer::OCCLUDED;
stroke.layer = Canvas::Layer::OCCLUDED;
stroke.stipplePattern = Style::PatternType({ Style::HIDDEN_EDGE });
stroke.stippleScale = Style::Get({ Style::HIDDEN_EDGE })->stippleScale;
break;
case DrawAs::HOVERED:
stroke = Style::Stroke(hs);
stroke.layer = Canvas::Layer::FRONT;
stroke.color = Style::Color(Style::HOVERED);
stroke.layer = Canvas::Layer::FRONT;
stroke.color = Style::Color(Style::HOVERED);
break;
case DrawAs::SELECTED:
stroke = Style::Stroke(hs);
stroke.layer = Canvas::Layer::FRONT;
stroke.color = Style::Color(Style::SELECTED);
stroke.layer = Canvas::Layer::FRONT;
stroke.color = Style::Color(Style::SELECTED);
break;
}
stroke.zIndex = zIndex;

View File

@ -479,6 +479,7 @@ void Group::DrawMesh(DrawMeshAs how, Canvas *canvas) {
strokeTriangle.zIndex = 1;
strokeTriangle.color = RgbaColor::FromFloat(0.0f, 1.0f, 0.0f);
strokeTriangle.width = 1;
strokeTriangle.unit = Canvas::Unit::PX;
hcsTriangle = canvas->GetStroke(strokeTriangle);
}
@ -551,10 +552,8 @@ void Group::Draw(Canvas *canvas) {
}
if(SS.GW.showOutlines) {
Canvas::Stroke strokeOutline = {};
Canvas::Stroke strokeOutline = Style::Stroke(Style::OUTLINE);
strokeOutline.zIndex = 1;
strokeOutline.color = Style::Color(Style::OUTLINE);
strokeOutline.width = Style::Width(Style::OUTLINE);
Canvas::hStroke hcsOutline = canvas->GetStroke(strokeOutline);
canvas->DrawOutlines(displayOutlines, hcsOutline,

View File

@ -133,6 +133,7 @@ bool Canvas::Stroke::Equals(const Stroke &other) const {
zIndex == other.zIndex &&
color.Equals(other.color) &&
width == other.width &&
unit == other.unit &&
stipplePattern == other.stipplePattern &&
stippleScale == other.stippleScale);
}
@ -221,6 +222,7 @@ void UiCanvas::DrawLine(int x1, int y1, int x2, int y2, RgbaColor color, int wid
stroke.layer = Canvas::Layer::FRONT;
stroke.width = (double)width;
stroke.color = color;
stroke.unit = Canvas::Unit::PX;
Canvas::hStroke hcs = canvas->GetStroke(stroke);
canvas->DrawLine(va, vb, hcs);
@ -247,6 +249,7 @@ void UiCanvas::DrawRect(int l, int r, int t, int b,
stroke.layer = Canvas::Layer::FRONT;
stroke.width = 1.0;
stroke.color = outlineColor;
stroke.unit = Canvas::Unit::PX;
Canvas::hStroke hcs = canvas->GetStroke(stroke);
canvas->DrawLine(va, vb, hcs);

View File

@ -289,7 +289,7 @@ Canvas::Stroke Style::Stroke(hStyle hs) {
Style *style = Style::Get(hs);
stroke.color = style->color;
stroke.stipplePattern = style->stippleType;
stroke.stippleScale = Style::StippleScaleMm(hs);
stroke.stippleScale = style->stippleScale;
stroke.width = Style::Width(hs.v);
switch(style->widthAs) {
case Style::UnitsAs::PIXELS: