Icon-O-Matic: Warn when exporting unsupported gradients to SVG
SVG does not support conic, diamond, xy, or sqrt_xy gradients. Show a one time warning and export them as linear approximations. Fixes #19533. Change-Id: Id49d9ea098a47088c0865d5a8609b657b0bcc45b Reviewed-on: https://review.haiku-os.org/c/haiku/+/9636 Reviewed-by: Zardshard Zardshard <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
Zardshard Zardshard
parent
59a481a049
commit
358e90524a
@@ -49,6 +49,7 @@ write_line(BPositionIO* stream, BString& string)
|
||||
// constructor
|
||||
SVGExporter::SVGExporter()
|
||||
: Exporter(),
|
||||
fShownUnsupportedGradientWarning(false),
|
||||
fGradientCount(0),
|
||||
fOriginalEntry(NULL)
|
||||
{
|
||||
@@ -156,6 +157,27 @@ SVGExporter::_DisplayWarning() const
|
||||
return alert->Go() == 1;
|
||||
}
|
||||
|
||||
// _DisplayUnsupportedGradientWarning
|
||||
void
|
||||
SVGExporter::_DisplayUnsupportedGradientWarning() const
|
||||
{
|
||||
if (fShownUnsupportedGradientWarning)
|
||||
return;
|
||||
|
||||
BAlert* alert = new BAlert(
|
||||
B_TRANSLATE("SVG export"),
|
||||
B_TRANSLATE("SVG does not support some gradient types "
|
||||
"(conic, diamond, xy, sqrt_xy).\n\n"
|
||||
"They will be exported as linear approximations and "
|
||||
"may look different in other viewers."),
|
||||
B_TRANSLATE("OK")
|
||||
);
|
||||
|
||||
alert->Go();
|
||||
fShownUnsupportedGradientWarning = true;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
// convert_join_mode_svg
|
||||
@@ -368,6 +390,13 @@ SVGExporter::_ExportGradient(const Gradient* gradient, BPositionIO* stream)
|
||||
{
|
||||
BString helper;
|
||||
|
||||
// display a warning if the gradient is unsupported
|
||||
if (gradient->Type() == GRADIENT_CONIC
|
||||
|| gradient->Type() == GRADIENT_DIAMOND
|
||||
|| gradient->Type() == GRADIENT_XY
|
||||
|| gradient->Type() == GRADIENT_SQRT_XY)
|
||||
_DisplayUnsupportedGradientWarning();
|
||||
|
||||
// start new gradient tag
|
||||
if (gradient->Type() == GRADIENT_CIRCULAR) {
|
||||
helper << " <radialGradient ";
|
||||
|
||||
@@ -40,6 +40,7 @@ class SVGExporter : public Exporter {
|
||||
|
||||
private:
|
||||
bool _DisplayWarning() const;
|
||||
void _DisplayUnsupportedGradientWarning() const;
|
||||
|
||||
status_t _ExportShape(const Shape* shape,
|
||||
BPositionIO* stream);
|
||||
@@ -52,6 +53,7 @@ class SVGExporter : public Exporter {
|
||||
char* string,
|
||||
BPositionIO* stream);
|
||||
|
||||
mutable bool fShownUnsupportedGradientWarning;
|
||||
int32 fGradientCount;
|
||||
entry_ref* fOriginalEntry;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user