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

View File

@ -463,32 +463,30 @@ void Entity::Draw(DrawAs how, Canvas *canvas) {
hs = Style::ForEntity(h); hs = Style::ForEntity(h);
} }
Canvas::Stroke stroke = {}; Canvas::Stroke stroke = Style::Stroke(hs);
switch(how) { switch(how) {
case DrawAs::DEFAULT: case DrawAs::DEFAULT:
stroke = Style::Stroke(hs); stroke.layer = Canvas::Layer::NORMAL;
stroke.layer = Canvas::Layer::NORMAL;
break; break;
case DrawAs::OVERLAY: case DrawAs::OVERLAY:
stroke.layer = Canvas::Layer::FRONT; stroke.layer = Canvas::Layer::FRONT;
break; break;
case DrawAs::HIDDEN: 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; break;
case DrawAs::HOVERED: case DrawAs::HOVERED:
stroke = Style::Stroke(hs); stroke.layer = Canvas::Layer::FRONT;
stroke.layer = Canvas::Layer::FRONT; stroke.color = Style::Color(Style::HOVERED);
stroke.color = Style::Color(Style::HOVERED);
break; break;
case DrawAs::SELECTED: case DrawAs::SELECTED:
stroke = Style::Stroke(hs); stroke.layer = Canvas::Layer::FRONT;
stroke.layer = Canvas::Layer::FRONT; stroke.color = Style::Color(Style::SELECTED);
stroke.color = Style::Color(Style::SELECTED);
break; break;
} }
stroke.zIndex = zIndex; stroke.zIndex = zIndex;

View File

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

View File

@ -133,6 +133,7 @@ bool Canvas::Stroke::Equals(const Stroke &other) const {
zIndex == other.zIndex && zIndex == other.zIndex &&
color.Equals(other.color) && color.Equals(other.color) &&
width == other.width && width == other.width &&
unit == other.unit &&
stipplePattern == other.stipplePattern && stipplePattern == other.stipplePattern &&
stippleScale == other.stippleScale); 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.layer = Canvas::Layer::FRONT;
stroke.width = (double)width; stroke.width = (double)width;
stroke.color = color; stroke.color = color;
stroke.unit = Canvas::Unit::PX;
Canvas::hStroke hcs = canvas->GetStroke(stroke); Canvas::hStroke hcs = canvas->GetStroke(stroke);
canvas->DrawLine(va, vb, hcs); 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.layer = Canvas::Layer::FRONT;
stroke.width = 1.0; stroke.width = 1.0;
stroke.color = outlineColor; stroke.color = outlineColor;
stroke.unit = Canvas::Unit::PX;
Canvas::hStroke hcs = canvas->GetStroke(stroke); Canvas::hStroke hcs = canvas->GetStroke(stroke);
canvas->DrawLine(va, vb, hcs); canvas->DrawLine(va, vb, hcs);

View File

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