Commit 8365f2f7 authored by Craig Watson's avatar Craig Watson

Fix saving of polygons' fill rule

Up until now, the fill rule of a polygon was always saved as even-odd,
despite the fact that in most if not all cases, polygons are drawn with
winding fill within OpenBoard.
Saving is now fixed, but there is no way to know upon loading whether
the polygon was correctly saved or whether; so for now, we just set the
fill rule to Winding when loading a polygon.
parent 1070251d
...@@ -1599,6 +1599,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo ...@@ -1599,6 +1599,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo
if (polygonItem->fillRule() == Qt::OddEvenFill) if (polygonItem->fillRule() == Qt::OddEvenFill)
mXmlWriter.writeAttribute("fill-rule", "evenodd"); mXmlWriter.writeAttribute("fill-rule", "evenodd");
else
mXmlWriter.writeAttribute("fill-rule", "winding");
if (!groupHoldsInfo) if (!groupHoldsInfo)
{ {
...@@ -1720,6 +1722,27 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol ...@@ -1720,6 +1722,27 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
color.setAlphaF(opacity); color.setAlphaF(opacity);
polygonItem->setColorOnLightBackground(color); polygonItem->setColorOnLightBackground(color);
} }
/*
Unfortunately the fill rule was never saved correctly until OpenBoard v1.4,
before then, it was always saved as even-odd. So we can't load it safely here.
Saving is now fixed, but any old documents would be loaded incorrectly if the code
below is used. It should be activated at some point in the future though.
QStringRef fillRule = mXmlReader.attributes().value("fill-rule");
if (!fillRule.isNull()) {
QString value = fillRule.toString();
if (value == "evenodd")
polygonItem->setFillRule(Qt::OddEvenFill);
else
polygonItem->setFillRule(Qt::WindingFill);
}
*/
polygonItem->setFillRule(Qt::WindingFill);
return polygonItem; return polygonItem;
} }
......
...@@ -171,6 +171,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const ...@@ -171,6 +171,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp->setBrush(this->brush()); cp->setBrush(this->brush());
cp->setPen(this->pen()); cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha; cp->mHasAlpha = this->mHasAlpha;
cp->setFillRule(this->fillRule());
cp->setColorOnDarkBackground(this->colorOnDarkBackground()); cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground()); cp->setColorOnLightBackground(this->colorOnLightBackground());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment