/trunk/Scribus/scribus/CMakeLists.txt |
---|
138,6 → 138,7 |
ui/propertiespalette_groupbase.ui |
ui/propertiespalette_imagebase.ui |
ui/propertiespalette_linebase.ui |
ui/propertiespalette_shadowbase.ui |
ui/propertiespalette_shapebase.ui |
ui/propertiespalette_tablebase.ui |
ui/propertiespalette_textbase.ui |
404,6 → 405,7 |
ui/propertiespalette_group.h |
ui/propertiespalette_image.h |
ui/propertiespalette_line.h |
ui/propertiespalette_shadow.h |
ui/propertiespalette_shape.h |
ui/propertiespalette_table.h |
ui/propertiespalette_text.h |
850,6 → 852,7 |
ui/propertiespalette_image.cpp |
ui/propertiespalette_group.cpp |
ui/propertiespalette_line.cpp |
ui/propertiespalette_shadow.cpp |
ui/propertiespalette_shape.cpp |
ui/propertiespalette_table.cpp |
ui/propertiespalette_text.cpp |
/trunk/Scribus/scribus/documentchecker.cpp |
---|
153,7 → 153,7 |
itemError.clear(); |
if (((currItem->isAnnotation()) || (currItem->isBookmark)) && (checkerSettings.checkAnnotations)) |
itemError.insert(PDFAnnotField, 0); |
if (((currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0) || (currItem->fillBlendmode() != 0) || (currItem->lineBlendmode() != 0)) && (checkerSettings.checkTransparency)) |
if ((currItem->hasSoftShadow() || (currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0) || (currItem->fillBlendmode() != 0) || (currItem->lineBlendmode() != 0)) && (checkerSettings.checkTransparency)) |
itemError.insert(Transparency, 0); |
if ((currItem->GrType != 0) && (checkerSettings.checkTransparency)) |
{ |
444,7 → 444,7 |
if (!(currDoc->layerPrintable(currItem->LayerID)) && (checkerSettings.ignoreOffLayers)) |
continue; |
itemError.clear(); |
if (((currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0) || (currItem->fillBlendmode() != 0) || (currItem->lineBlendmode() != 0)) && (checkerSettings.checkTransparency)) |
if ((currItem->hasSoftShadow() || (currItem->fillTransparency() != 0.0) || (currItem->lineTransparency() != 0.0) || (currItem->fillBlendmode() != 0) || (currItem->lineBlendmode() != 0)) && (checkerSettings.checkTransparency)) |
itemError.insert(Transparency, 0); |
if ((currItem->GrType != 0) && (checkerSettings.checkTransparency)) |
{ |
/trunk/Scribus/scribus/pageitem.cpp |
---|
193,6 → 193,14 |
fill_gradient(other.fill_gradient), |
fillRule(other.fillRule), |
doOverprint(other.doOverprint), |
m_hasSoftShadow(other.m_hasSoftShadow), |
m_softShadowColor(other.m_softShadowColor), |
m_softShadowShade(other.m_softShadowShade), |
m_softShadowBlurRadius(other.m_softShadowBlurRadius), |
m_softShadowXOffset(other.m_softShadowXOffset), |
m_softShadowYOffset(other.m_softShadowYOffset), |
m_softShadowOpacity(other.m_softShadowOpacity), |
m_softShadowBlendMode(other.m_softShadowBlendMode), |
LeftLink(other.LeftLink), |
RightLink(other.RightLink), |
TopLink(other.TopLink), |
824,6 → 832,15 |
} |
isInlineImage = false; |
isTempFile = false; |
m_hasSoftShadow = false; |
m_softShadowColor = "Black"; |
m_softShadowShade = 100; |
m_softShadowBlurRadius = 5.0; |
m_softShadowXOffset = 5.0; |
m_softShadowYOffset = 5.0; |
m_softShadowOpacity = 0.0; |
m_softShadowBlendMode = 0; |
} |
PageItem::~PageItem() |
1633,6 → 1650,8 |
{ |
if (!isGroup()) |
{ |
if (hasSoftShadow()) |
DrawSoftShadow(p); |
p->setBlendModeFill(fillBlendmode()); |
p->setLineWidth(lwCorr); |
if (GrType != 0) |
2173,6 → 2192,39 |
p->newPath(); |
} |
void PageItem::DrawSoftShadow(ScPainter *p) |
{ |
if (m_softShadowColor == CommonStrings::None) |
return; |
if ((itemType() == PathText) || (itemType() == Symbol) || (itemType() == Group) || (itemType() == Line) || (itemType() == PolyLine) || (itemType() == Spiral)) |
return; |
double lwCorr = m_lineWidth; |
double sc = p->zoomFactor(); |
if ((m_lineWidth * sc) < 1) |
lwCorr = 0; |
const ScColor& col = m_Doc->PageColors[m_softShadowColor]; |
QColor tmp = ScColorEngine::getShadeColorProof(col, m_Doc, m_softShadowShade); |
if (m_Doc->viewAsPreview) |
{ |
VisionDefectColor defect; |
tmp = defect.convertDefect(tmp, m_Doc->previewVisual); |
} |
p->save(); |
FPointArray sh = PoLine.copy(); |
sh.translate(m_softShadowXOffset, m_softShadowYOffset); |
p->beginLayer(1.0 - m_softShadowOpacity, m_softShadowBlendMode); |
p->setupPolygon(&sh); |
p->setBrush(tmp); |
p->setFillMode(ScPainter::Solid); |
p->setStrokeMode(ScPainter::Solid); |
p->setPen(tmp, lwCorr, PLineArt, PLineEnd, PLineJoin); |
p->fillPath(); |
p->strokePath(); |
p->blurAlpha(m_softShadowBlurRadius); |
p->endLayer(); |
p->restore(); |
} |
QImage PageItem::DrawObj_toImage(double maxSize) |
{ |
bool isEmbedded_Old = isEmbedded; |
/trunk/Scribus/scribus/pageitem.h |
---|
261,6 → 261,7 |
QImage DrawObj_toImage(QList<PageItem*> &emG, double scaling); |
void DrawObj_Embedded(ScPainter *p, QRectF e, const CharStyle& style, PageItem* cembedded); |
void DrawStrokePattern(ScPainter *p, QPainterPath &path); |
void DrawSoftShadow(ScPainter *p); |
/** |
* @brief Set or get the redraw bounding box of the item, moved from the View |
*/ |
644,6 → 645,31 |
bool overprint() const { return doOverprint; } |
void setOverprint(bool val); |
// soft shadow |
void setHasSoftShadow(bool val) { m_hasSoftShadow = val; } |
bool hasSoftShadow() { return m_hasSoftShadow; } |
void setSoftShadowColor(const QString &newColor) { m_softShadowColor = newColor; } |
QString softShadowColor() { return m_softShadowColor; } |
void setSoftShadowShade(int val) { m_softShadowShade = val; } |
int softShadowShade() { return m_softShadowShade; } |
void setSoftShadowBlurRadius(double val) { m_softShadowBlurRadius = val; } |
double softShadowBlurRadius() { return m_softShadowBlurRadius; } |
void setSoftShadowXOffset(double val) { m_softShadowXOffset = val; } |
double softShadowXOffset() { return m_softShadowXOffset; } |
void setSoftShadowYOffset(double val) { m_softShadowYOffset = val; } |
double softShadowYOffset() { return m_softShadowYOffset; } |
void setSoftShadowOpacity(double val) { m_softShadowOpacity = val; } |
double softShadowOpacity() { return m_softShadowOpacity; } |
void setSoftShadowBlendMode(int val) { m_softShadowBlendMode = val; } |
double softShadowBlendMode() { return m_softShadowBlendMode; } |
int frameType() const { return FrameType; } ///< rect / oval / round / other |
void setFrameType(int val) { FrameType = val; } |
// |
1255,6 → 1281,14 |
VGradient fill_gradient; |
bool fillRule; |
bool doOverprint; |
bool m_hasSoftShadow; |
QString m_softShadowColor; |
int m_softShadowShade; |
double m_softShadowBlurRadius; |
double m_softShadowXOffset; |
double m_softShadowYOffset; |
double m_softShadowOpacity; |
int m_softShadowBlendMode; |
/* Additions for Table Support */ |
/* now deprecated with the new PageItem_Table */ |
PageItem* LeftLink; |
/trunk/Scribus/scribus/pdflib_core.cpp |
---|
3445,6 → 3445,130 |
return retString; |
} |
QString PDFLibCore::PDF_PutSoftShadow(PageItem* ite, const ScPage *pag) |
{ |
if (Options.Version < PDFOptions::PDFVersion_14 || !ite->hasSoftShadow() || ite->softShadowColor() == CommonStrings::None || !ite->printEnabled()) |
return ""; |
QString tmp("q\n"); |
double softShadowDPI = Options.Resolution; |
int pixelRadius = qRound(ite->softShadowBlurRadius() / 72.0 * softShadowDPI); |
tmp += "1 0 0 1 "; |
tmp += FToStr(ite->softShadowXOffset() - ite->softShadowBlurRadius())+" "; |
tmp += FToStr(-ite->softShadowYOffset() - ite->softShadowBlurRadius())+" cm\n"; |
tmp += "1 0 0 1 0 " + FToStr(-(ite->height() + ite->visualLineWidth()))+" cm\n"; |
tmp += FToStr(ite->width() + ite->visualLineWidth() + 2 * ite->softShadowBlurRadius()) + " 0 0 " + FToStr(ite->height() + ite->visualLineWidth() + 2 * ite->softShadowBlurRadius())+" 0 0 cm\n" ; |
double savRot = ite->rotation(); |
ite->setRotation(0, true); |
double maxSize = qMax(ite->visualWidth(), ite->visualHeight()); |
maxSize = qMin(3000.0, maxSize * (softShadowDPI / 72.0)); |
bool savedShadow = ite->hasSoftShadow(); |
ite->setHasSoftShadow(false); |
QImage imgC = ite->DrawObj_toImage(maxSize); |
ite->setRotation(savRot, true); |
ite->setHasSoftShadow(savedShadow); |
imgC = imgC.copy(-pixelRadius,-pixelRadius,imgC.width()+2*pixelRadius,imgC.height()+2*pixelRadius); // Add border |
ScImage img = imgC.alphaChannel().convertToFormat(QImage::Format_RGB32); |
ImageEffect eff; |
ScImageEffectList el; |
eff.effectCode = ScImage::EF_BLUR; |
eff.effectParameters = QString("%1 1.0").arg(pixelRadius); |
el.append(eff); |
img.applyEffect(el,ite->doc()->PageColors,false); |
uint maskObj = newObject(); |
StartObj(maskObj); |
PutDoc("<<\n/Type /XObject\n/Subtype /Image\n"); |
PutDoc("/Width "+QString::number(img.width())+"\n"); |
PutDoc("/Height "+QString::number(img.height())+"\n"); |
PutDoc("/ColorSpace /DeviceGray\n"); |
PutDoc("/BitsPerComponent 8\n"); |
uint lengthObj = newObject(); |
PutDoc("/Length "+QString::number(lengthObj)+" 0 R\n"); |
PutDoc("/Filter /FlateDecode\n"); |
PutDoc(">>\nstream\n"); |
int bytesWritten = WriteFlateImageToStream(img, maskObj, ColorSpaceGray, false); |
PutDoc("\nendstream\nendobj\n"); |
StartObj(lengthObj); |
PutDoc(QString(" %1\n").arg(bytesWritten)); |
PutDoc("endobj\n"); |
uint colObj = newObject(); |
StartObj(colObj); |
PutDoc("<<\n/Type /XObject\n/Subtype /Image\n"); |
PutDoc("/Width 1\n"); |
PutDoc("/Height 1\n"); |
PutDoc("/Interpolate false\n"); |
PutDoc("/BitsPerComponent 8\n"); |
PutDoc("/SMask "+QString::number(maskObj)+" 0 R\n"); |
ScImage col(1,1); |
QString colstr = SetColor(ite->softShadowColor(), ite->softShadowShade()); |
if (Options.isGrayscale) |
{ |
double gf; |
int g; |
QTextStream ts(&colstr, QIODevice::ReadOnly); |
ts >> gf; |
g = round(gf*255); |
col.imgInfo.colorspace = ColorSpaceGray; |
col.qImagePtr()->setPixel(0,0,qRgba(g,g,g,255)); |
PutDoc("/ColorSpace /DeviceGray\n"); |
PutDoc("/Length 1\n"); |
PutDoc(">>\nstream\n"); |
WriteImageToStream(col, colObj, ColorSpaceGray, true); |
PutDoc("\nendstream\nendobj\n"); |
} |
else if (Options.UseRGB) |
{ |
double r,g,b; |
QTextStream ts(&colstr, QIODevice::ReadOnly); |
ts >> r; |
ts >> g; |
ts >> b; |
col.imgInfo.colorspace = ColorSpaceRGB; |
col.qImagePtr()->setPixel(0,0,qRgba(round(r*255),round(g*255),round(b*255),255)); |
PutDoc("/ColorSpace /DeviceRGB\n"); |
PutDoc("/Length 3\n"); |
PutDoc(">>\nstream\n"); |
WriteImageToStream(col, colObj, ColorSpaceRGB, false); |
PutDoc("\nendstream\nendobj\n"); |
} |
else //CMYK |
{ |
double c,m,y,k; |
QTextStream ts(&colstr, QIODevice::ReadOnly); |
ts >> c; |
ts >> m; |
ts >> y; |
ts >> k; |
col.imgInfo.colorspace = ColorSpaceCMYK; |
col.qImagePtr()->setPixel(0,0,qRgba(round(c*255),round(m*255),round(y*255),round(k*255))); |
PutDoc("/ColorSpace /DeviceCMYK\n"); |
PutDoc("/Length 4\n"); |
PutDoc(">>\nstream\n"); |
WriteImageToStream(col, colObj, ColorSpaceCMYK, false); |
PutDoc("\nendstream\nendobj\n"); |
} |
QString colRes = ResNam+QString::number(ResCount); |
Seite.ImgObjects[colRes] = colObj; |
ResCount++; |
QString ShName = ResNam+QString::number(ResCount); |
ResCount++; |
Transpar[ShName] = writeGState("/ca "+FToStr(1.0 - ite->softShadowOpacity())+"\n" |
+ "/AIS false\n/OPM 1\n" |
+ "/BM /" + blendMode(ite->softShadowBlendMode()) + "\n"); |
tmp += "/"+ShName+" gs\n"; |
tmp += "/"+colRes+" Do Q\n"; |
return tmp; |
} |
/** |
* Fill this.output with the QString representation of the item. |
* Checks if the item can be represented in the chosen PDF version, based on some of its caracteristics |
3582,6 → 3706,7 |
sr = 0; |
tmp += FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n"; |
} |
tmp += PDF_PutSoftShadow(ite,pag); |
switch (ite->itemType()) |
{ |
case PageItem::ImageFrame: |
/trunk/Scribus/scribus/pdflib_core.h |
---|
154,6 → 154,7 |
QByteArray ComputeMD5(const QString& in); |
QByteArray ComputeRC4Key(int ObjNum); |
QString PDF_PutSoftShadow(PageItem* ite, const ScPage* pag); |
bool PDF_ProcessItem(QString& output, PageItem* ite, const ScPage* pag, uint PNr, bool embedded = false, bool pattern = false); |
void PDF_Bookmark(PageItem *currItem, double ypos); |
bool PDF_PatternFillStroke(QString& output, PageItem *currItem, int kind = 0, bool forArrow = false); |
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp |
---|
5235,6 → 5235,15 |
else |
currItem->inlineCharID = -1; |
currItem->setHasSoftShadow(attrs.valueAsBool("HASSOFTSHADOW", false)); |
currItem->setSoftShadowXOffset(attrs.valueAsDouble("SOFTSHADOWXOFFSET", 5.0)); |
currItem->setSoftShadowYOffset(attrs.valueAsDouble("SOFTSHADOWYOFFSET", 5.0)); |
currItem->setSoftShadowColor(attrs.valueAsString("SOFTSHADOWCOLOR", CommonStrings::None)); |
currItem->setSoftShadowShade(attrs.valueAsInt("SOFTSHADOWSHADE", 100)); |
currItem->setSoftShadowBlurRadius(attrs.valueAsDouble("SOFTSHADOWBLURRADIUS", 5.0)); |
currItem->setSoftShadowBlendMode(attrs.valueAsInt("SOFTSHADOWBLENDMODE", 0)); |
currItem->setSoftShadowOpacity(attrs.valueAsDouble("SOFTSHADOWOPACITY", 1.0)); |
//currItem->setRedrawBounding(); |
//currItem->OwnPage = view->OnPage(currItem); |
return currItem; |
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp |
---|
2721,6 → 2721,17 |
docu.writeAttribute("TransBlend", item->fillBlendmode()); |
if (item->lineBlendmode() != 0) |
docu.writeAttribute("TransBlendS", item->lineBlendmode()); |
if (item->hasSoftShadow()) |
{ |
docu.writeAttribute("HASSOFTSHADOW",item->hasSoftShadow() ? 1 : 0); |
docu.writeAttribute("SOFTSHADOWXOFFSET",item->softShadowXOffset()); |
docu.writeAttribute("SOFTSHADOWYOFFSET",item->softShadowYOffset()); |
docu.writeAttribute("SOFTSHADOWCOLOR",item->softShadowColor()); |
docu.writeAttribute("SOFTSHADOWBLURRADIUS",item->softShadowBlurRadius()); |
docu.writeAttribute("SOFTSHADOWSHADE",item->softShadowShade()); |
docu.writeAttribute("SOFTSHADOWBLENDMODE",item->softShadowBlendMode()); |
docu.writeAttribute("SOFTSHADOWOPACITY",item->softShadowOpacity()); |
} |
if (item->isTable()) |
{ |
/trunk/Scribus/scribus/plugins/import/pub/importpub.cpp |
---|
1448,6 → 1448,30 |
groupStack.top().Items.append(nite); |
groupStack.top().Items.append(ite); |
} |
/* |
double xof = 0.0; |
double yof = 0.0; |
if (m_style["draw:shadow-offset-x"]) |
xof = valueAsPoint(m_style["draw:shadow-offset-x"]); |
if (m_style["draw:shadow-offset-y"]) |
yof = valueAsPoint(m_style["draw:shadow-offset-y"]); |
QString shadowColor = CurrColorFill; |
double shadowTrans = 1.0; |
if (m_style["draw:shadow-color"]) |
{ |
shadowColor = parseColor(QString(m_style["draw:shadow-color"]->getStr().cstr())); |
if(m_style["draw:shadow-opacity"]) |
shadowTrans = 1.0 - qMin(1.0, qMax(fromPercentage(QString(m_style["draw:shadow-opacity"]->getStr().cstr())), 0.0)); |
} |
ite->setHasSoftShadow(true); |
ite->setSoftShadowColor(shadowColor); |
ite->setSoftShadowXOffset(xof); |
ite->setSoftShadowYOffset(yof); |
ite->setSoftShadowBlurRadius(5); |
ite->setSoftShadowShade(100); |
ite->setSoftShadowOpacity(shadowTrans); |
ite->setSoftShadowBlendMode(0); |
*/ |
} |
} |
/trunk/Scribus/scribus/plugins/xpsexport/xpsexplugin.cpp |
---|
517,12 → 517,12 |
path.lineTo(0, bounds.height()); |
path.closeSubpath(); |
QTransform mpx; |
if (Item->rotation() != 0.0) |
{ |
mpx.translate(xOffset * conversionFactor, yOffset * conversionFactor); |
mpx.rotate(Item->rotation()); |
mpx.translate(-xOffset * conversionFactor, -yOffset * conversionFactor); |
} |
// if (Item->rotation() != 0.0) |
// { |
// mpx.translate(xOffset * conversionFactor, yOffset * conversionFactor); |
// mpx.rotate(Item->rotation()); |
// mpx.translate(-xOffset * conversionFactor, -yOffset * conversionFactor); |
// } |
QTransform mpp; |
mpp.translate((Item->visualXPos() - m_Doc->currentPage()->xOffset()) * conversionFactor, (Item->visualYPos() - m_Doc->currentPage()->yOffset()) * conversionFactor); |
mpp.scale(conversionFactor, conversionFactor); |
535,8 → 535,8 |
else |
pa.prepend("F 1 "); |
ob.setAttribute("Data", pa); |
if (Item->rotation() != 0.0) |
ob.setAttribute("RenderTransform", MatrixToStr(mpx)); |
// if (Item->rotation() != 0.0) |
// ob.setAttribute("RenderTransform", MatrixToStr(mpx)); |
QDomElement obf = p_docu.createElement("Path.Fill"); |
QDomElement gr = p_docu.createElement("ImageBrush"); |
double maxSize = qMax(Item->visualWidth(), Item->visualHeight()); |
2771,6 → 2771,8 |
ret = true; |
if (Item->lineBlendmode() != 0) |
ret = true; |
if (Item->hasSoftShadow()) |
ret = true; |
return ret; |
} |
/trunk/Scribus/scribus/scpainter.cpp |
---|
1953,45 → 1953,345 |
closePath(); |
setBrush(light); |
fillPath(); |
} |
/* |
setStrokeMode(1); |
setLineWidth(1.2); |
if (sunken) |
setPen(shade, 1.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
else |
setPen(light, 1.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
int x1, y1, x2, y2, x3, y3; |
x1 = r.x(); |
x2 = r.x(); |
x3 = r.x() + r.width(); |
y1 = r.y() + r.height(); |
y2 = r.y(); |
y3 = r.y(); |
for (int i = 0; i < lineWidth; i++) |
void ScPainter::blurAlpha(int radius) |
{ |
if (radius < 1) |
return; |
cairo_surface_t *data = cairo_get_group_target(m_cr); |
QRgb *pix = (QRgb*)cairo_image_surface_get_data(data); |
int w = cairo_image_surface_get_width(data); |
int h = cairo_image_surface_get_height(data); |
int wm = w-1; |
int hm = h-1; |
int wh = w*h; |
int div = radius+radius+1; |
int *a = new int[wh]; |
int asum, x, y, i, yp, yi, yw; |
QRgb p; |
int *vmin = new int[qMax(w,h)]; |
int divsum = (div+1)>>1; |
divsum *= divsum; |
int *dv = new int[256*divsum]; |
for (i=0; i < 256*divsum; ++i) |
{ |
newPath(); |
moveTo(x1++, y1--); |
lineTo(x2++, y2++); |
lineTo(x3--, y3++); |
strokePath(); |
dv[i] = (i/divsum); |
} |
if (sunken) |
setPen(light, 1.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
else |
setPen(shade, 1.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); |
x1 = r.x(); |
x2 = r.x() + r.width(); |
x3 = r.x() + r.width(); |
y1 = r.y() + r.height(); |
y2 = r.y() + r.height(); |
y3 = r.y(); |
for (int i = 0; i < lineWidth; i++) |
yw = yi = 0; |
int **stack = new int*[div]; |
for(int i = 0; i < div; ++i) |
{ |
newPath(); |
moveTo(x1++, y1--); |
lineTo(x2--, y2--); |
lineTo(x3--, y3++); |
strokePath(); |
} */ |
stack[i] = new int[1]; |
} |
int stackpointer; |
int stackstart; |
int *sir; |
int rbs; |
int r1 = radius+1; |
int aoutsum; |
int ainsum; |
for (y = 0; y < h; ++y) |
{ |
ainsum = aoutsum = asum = 0; |
for(i =- radius; i <= radius; ++i) |
{ |
p = pix[yi+qMin(wm,qMax(i,0))]; |
sir = stack[i+radius]; |
sir[0] = qAlpha(p); |
rbs = r1-abs(i); |
asum += sir[0]*rbs; |
if (i > 0) |
ainsum += sir[0]; |
else |
aoutsum += sir[0]; |
} |
stackpointer = radius; |
for (x=0; x < w; ++x) |
{ |
a[yi] = dv[asum]; |
asum -= aoutsum; |
stackstart = stackpointer-radius+div; |
sir = stack[stackstart%div]; |
aoutsum -= sir[0]; |
if (y == 0) |
vmin[x] = qMin(x+radius+1,wm); |
p = pix[yw+vmin[x]]; |
sir[0] = qAlpha(p); |
ainsum += sir[0]; |
asum += ainsum; |
stackpointer = (stackpointer+1)%div; |
sir = stack[(stackpointer)%div]; |
aoutsum += sir[0]; |
ainsum -= sir[0]; |
++yi; |
} |
yw += w; |
} |
for (x=0; x < w; ++x) |
{ |
ainsum = aoutsum = asum = 0; |
yp =- radius * w; |
for(i=-radius; i <= radius; ++i) |
{ |
yi=qMax(0,yp)+x; |
sir = stack[i+radius]; |
sir[0] = a[yi]; |
rbs = r1-abs(i); |
asum += a[yi]*rbs; |
if (i > 0) |
ainsum += sir[0]; |
else |
aoutsum += sir[0]; |
if (i < hm) |
{ |
yp += w; |
} |
} |
yi = x; |
stackpointer = radius; |
for (y=0; y < h; ++y) |
{ |
pix[yi] = qRgba(qRed(pix[yi]), qGreen(pix[yi]), qBlue(pix[yi]), dv[asum]); |
asum -= aoutsum; |
stackstart = stackpointer-radius+div; |
sir = stack[stackstart%div]; |
aoutsum -= sir[0]; |
if (x==0) |
{ |
vmin[y] = qMin(y+r1,hm)*w; |
} |
p = x+vmin[y]; |
sir[0] = a[p]; |
ainsum += sir[0]; |
asum += ainsum; |
stackpointer = (stackpointer+1)%div; |
sir = stack[stackpointer]; |
aoutsum += sir[0]; |
ainsum -= sir[0]; |
yi += w; |
} |
} |
delete [] a; |
delete [] vmin; |
delete [] dv; |
for(int i = 0; i < div; ++i) |
{ |
delete [] stack[i]; |
} |
delete [] stack; |
cairo_surface_mark_dirty(data); |
} |
void ScPainter::blur(int radius) |
{ |
if (radius < 1) |
return; |
cairo_surface_t *data = cairo_get_group_target(m_cr); |
QRgb *pix = (QRgb*)cairo_image_surface_get_data(data); |
int w = cairo_image_surface_get_width(data); |
int h = cairo_image_surface_get_height(data); |
int wm = w-1; |
int hm = h-1; |
int wh = w*h; |
int div = radius+radius+1; |
int *r = new int[wh]; |
int *g = new int[wh]; |
int *b = new int[wh]; |
int *a = new int[wh]; |
int rsum, gsum, bsum, asum, x, y, i, yp, yi, yw; |
QRgb p; |
int *vmin = new int[qMax(w,h)]; |
int divsum = (div+1)>>1; |
divsum *= divsum; |
int *dv = new int[256*divsum]; |
for (i=0; i < 256*divsum; ++i) |
{ |
dv[i] = (i/divsum); |
} |
yw = yi = 0; |
int **stack = new int*[div]; |
for(int i = 0; i < div; ++i) |
{ |
stack[i] = new int[4]; |
} |
int stackpointer; |
int stackstart; |
int *sir; |
int rbs; |
int r1 = radius+1; |
int routsum, goutsum, boutsum, aoutsum; |
int rinsum, ginsum, binsum, ainsum; |
for (y = 0; y < h; ++y) |
{ |
rinsum = ginsum = binsum = ainsum = routsum = goutsum = boutsum = aoutsum = rsum = gsum = bsum = asum = 0; |
for(i =- radius; i <= radius; ++i) |
{ |
p = pix[yi+qMin(wm,qMax(i,0))]; |
sir = stack[i+radius]; |
sir[0] = qRed(p); |
sir[1] = qGreen(p); |
sir[2] = qBlue(p); |
sir[3] = qAlpha(p); |
rbs = r1-abs(i); |
rsum += sir[0]*rbs; |
gsum += sir[1]*rbs; |
bsum += sir[2]*rbs; |
asum += sir[3]*rbs; |
if (i > 0) |
{ |
rinsum += sir[0]; |
ginsum += sir[1]; |
binsum += sir[2]; |
ainsum += sir[3]; |
} |
else |
{ |
routsum += sir[0]; |
goutsum += sir[1]; |
boutsum += sir[2]; |
aoutsum += sir[3]; |
} |
} |
stackpointer = radius; |
for (x=0; x < w; ++x) |
{ |
r[yi] = dv[rsum]; |
g[yi] = dv[gsum]; |
b[yi] = dv[bsum]; |
a[yi] = dv[asum]; |
rsum -= routsum; |
gsum -= goutsum; |
bsum -= boutsum; |
asum -= aoutsum; |
stackstart = stackpointer-radius+div; |
sir = stack[stackstart%div]; |
routsum -= sir[0]; |
goutsum -= sir[1]; |
boutsum -= sir[2]; |
aoutsum -= sir[3]; |
if (y == 0) |
{ |
vmin[x] = qMin(x+radius+1,wm); |
} |
p = pix[yw+vmin[x]]; |
sir[0] = qRed(p); |
sir[1] = qGreen(p); |
sir[2] = qBlue(p); |
sir[3] = qAlpha(p); |
rinsum += sir[0]; |
ginsum += sir[1]; |
binsum += sir[2]; |
ainsum += sir[3]; |
rsum += rinsum; |
gsum += ginsum; |
bsum += binsum; |
asum += ainsum; |
stackpointer = (stackpointer+1)%div; |
sir = stack[(stackpointer)%div]; |
routsum += sir[0]; |
goutsum += sir[1]; |
boutsum += sir[2]; |
aoutsum += sir[3]; |
rinsum -= sir[0]; |
ginsum -= sir[1]; |
binsum -= sir[2]; |
ainsum -= sir[3]; |
++yi; |
} |
yw += w; |
} |
for (x=0; x < w; ++x) |
{ |
rinsum = ginsum = binsum = ainsum = routsum = goutsum = boutsum = aoutsum = rsum = gsum = bsum = asum = 0; |
yp =- radius * w; |
for(i=-radius; i <= radius; ++i) |
{ |
yi=qMax(0,yp)+x; |
sir = stack[i+radius]; |
sir[0] = r[yi]; |
sir[1] = g[yi]; |
sir[2] = b[yi]; |
sir[3] = a[yi]; |
rbs = r1-abs(i); |
rsum += r[yi]*rbs; |
gsum += g[yi]*rbs; |
bsum += b[yi]*rbs; |
asum += a[yi]*rbs; |
if (i > 0) |
{ |
rinsum += sir[0]; |
ginsum += sir[1]; |
binsum += sir[2]; |
ainsum += sir[3]; |
} |
else |
{ |
routsum += sir[0]; |
goutsum += sir[1]; |
boutsum += sir[2]; |
aoutsum += sir[3]; |
} |
if (i < hm) |
{ |
yp += w; |
} |
} |
yi = x; |
stackpointer = radius; |
for (y=0; y < h; ++y) |
{ |
pix[yi] = qRgba(dv[rsum], dv[gsum], dv[bsum], dv[asum]); |
rsum -= routsum; |
gsum -= goutsum; |
bsum -= boutsum; |
asum -= aoutsum; |
stackstart = stackpointer-radius+div; |
sir = stack[stackstart%div]; |
routsum -= sir[0]; |
goutsum -= sir[1]; |
boutsum -= sir[2]; |
aoutsum -= sir[3]; |
if (x==0) |
{ |
vmin[y] = qMin(y+r1,hm)*w; |
} |
p = x+vmin[y]; |
sir[0] = r[p]; |
sir[1] = g[p]; |
sir[2] = b[p]; |
sir[3] = a[p]; |
rinsum += sir[0]; |
ginsum += sir[1]; |
binsum += sir[2]; |
ainsum += sir[3]; |
rsum += rinsum; |
gsum += ginsum; |
bsum += binsum; |
asum += ainsum; |
stackpointer = (stackpointer+1)%div; |
sir = stack[stackpointer]; |
routsum += sir[0]; |
goutsum += sir[1]; |
boutsum += sir[2]; |
aoutsum += sir[3]; |
rinsum -= sir[0]; |
ginsum -= sir[1]; |
binsum -= sir[2]; |
ainsum -= sir[3]; |
yi += w; |
} |
} |
delete [] r; |
delete [] g; |
delete [] b; |
delete [] a; |
delete [] vmin; |
delete [] dv; |
for(int i = 0; i < div; ++i) |
{ |
delete [] stack[i]; |
} |
delete [] stack; |
cairo_surface_mark_dirty(data); |
} |
/trunk/Scribus/scribus/scpainter.h |
---|
96,6 → 96,8 |
virtual void drawText(QRectF area, QString text, bool filled = true, int align = 0); |
virtual void drawShadeCircle(const QRectF &re, const QColor color, bool sunken, int lineWidth); |
virtual void drawShadePanel(const QRectF &r, const QColor color, bool sunken, int lineWidth); |
virtual void blurAlpha(int radius); |
virtual void blur(int radius); |
// pen + brush |
virtual QColor pen(); |
/trunk/Scribus/scribus/scribusdoc.cpp |
---|
7750,6 → 7750,33 |
} |
} |
void ScribusDoc::itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend) |
{ |
if (color == CommonStrings::tr_NoneColor) |
color = CommonStrings::None; |
uint selectedItemCount = m_Selection->count(); |
if (selectedItemCount != 0) |
{ |
for (uint a = 0; a < selectedItemCount; ++a) |
{ |
PageItem *currItem = m_Selection->itemAt(a); |
currItem->setHasSoftShadow(has); |
currItem->setSoftShadowColor(color); |
currItem->setSoftShadowXOffset(dx); |
currItem->setSoftShadowYOffset(dy); |
currItem->setSoftShadowBlurRadius(radius); |
currItem->setSoftShadowShade(shade); |
currItem->setSoftShadowOpacity(opac); |
currItem->setSoftShadowBlendMode(blend); |
QRectF newRect = currItem->getVisualBoundingRect().adjusted(-dx, -dy, dx, dy); |
currItem->invalidateLayout(); |
regionsChanged()->update(newRect); |
} |
} |
changed(); |
} |
void ScribusDoc::itemSelection_SetLineWidth(double w) |
{ |
uint selectedItemCount=m_Selection->count(); |
/trunk/Scribus/scribus/scribusdoc.h |
---|
1046,6 → 1046,8 |
void itemSelection_SetNamedCharStyle(const QString & name, Selection* customSelection=0); |
void itemSelection_SetNamedLineStyle(const QString & name, Selection* customSelection=0); |
void itemSelection_SetSoftShadow(bool has, QString color, double dx, double dy, double radius, int shade, double opac, int blend); |
void itemSelection_SetLineWidth(double w); |
void itemSelection_SetLineArt(Qt::PenStyle w); |
void itemSelection_SetLineJoin(Qt::PenJoinStyle w); |
/trunk/Scribus/scribus/ui/propertiespalette.cpp |
---|
41,6 → 41,7 |
#include "propertiespalette_group.h" |
#include "propertiespalette_image.h" |
#include "propertiespalette_line.h" |
#include "propertiespalette_shadow.h" |
#include "propertiespalette_shape.h" |
#include "propertiespalette_table.h" |
#include "propertiespalette_text.h" |
91,6 → 92,9 |
xyzPal = new PropertiesPalette_XYZ( this ); |
idXYZItem = TabStack->addItem( xyzPal, "X, Y, &Z" ); |
shadowPal = new PropertiesPalette_Shadow( this ); |
idShadowItem = TabStack->addItem( shadowPal, "Soft Shadow" ); |
shapePal = new PropertiesPalette_Shape( this ); |
idShapeItem = TabStack->addItem( shapePal, "&Shape" ); |
132,7 → 136,7 |
connect(Tpal, SIGNAL(editGradient()), this, SLOT(toggleGradientEditM())); |
m_haveItem = false; |
for (int ws = 1; ws < 9; ++ws) |
for (int ws = 1; ws < 10; ++ws) |
TabStack->setItemEnabled(ws, false); |
TabStack->setCurrentIndex(0); |
TabStack->widget(0)->setEnabled(false); |
165,6 → 169,7 |
move(p2); |
this->xyzPal->setMainWindow(mw); |
this->shadowPal->setMainWindow(mw); |
this->shapePal->setMainWindow(mw); |
this->groupPal->setMainWindow(mw); |
this->imagePal->setMainWindow(mw); |
228,6 → 233,7 |
m_haveItem = false; |
xyzPal->setDoc(m_doc); |
shadowPal->setDoc(m_doc); |
shapePal->setDoc(m_doc); |
groupPal->setDoc(m_doc); |
imagePal->setDoc(m_doc); |
259,6 → 265,8 |
xyzPal->unsetItem(); |
xyzPal->unsetDoc(); |
shadowPal->unsetItem(); |
shadowPal->unsetDoc(); |
shapePal->unsetItem(); |
shapePal->unsetDoc(); |
groupPal->unsetItem(); |
390,6 → 398,7 |
if ((m_item->isGroup()) && (!m_item->isSingleSel)) |
{ |
TabStack->setItemEnabled(idXYZItem, true); |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, false); |
TabStack->setItemEnabled(idGroupItem, true); |
TabStack->setItemEnabled(idLineItem, false); |
425,6 → 434,7 |
if (m_item->asOSGFrame()) |
{ |
TabStack->setItemEnabled(idXYZItem, true); |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idGroupItem, false); |
TabStack->setItemEnabled(idLineItem, false); |
438,6 → 448,7 |
if (m_item->asSymbolFrame()) |
{ |
TabStack->setItemEnabled(idXYZItem, true); |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, false); |
TabStack->setItemEnabled(idGroupItem, true); |
TabStack->setItemEnabled(idLineItem, false); |
460,10 → 471,11 |
PageItem* currItem = currentItemFromSelection(); |
if (m_doc->m_Selection->count() > 1) |
{ |
for (int ws = 1; ws < 9; ++ws) |
for (int ws = 1; ws < 10; ++ws) |
TabStack->setItemEnabled(ws, false); |
TabStack->widget(0)->setEnabled(true); |
TabStack->setItemEnabled(idXYZItem, true); |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idLineItem, true); |
TabStack->setItemEnabled(idColorsItem, true); |
TabStack->setItemEnabled(idTransparencyItem, true); |
489,7 → 501,7 |
{ |
case -1: |
m_haveItem = false; |
for (int ws = 1; ws < 9; ++ws) |
for (int ws = 1; ws < 10; ++ws) |
TabStack->setItemEnabled(ws, false); |
TabStack->widget(0)->setEnabled(false); |
TabStack->setItemEnabled(idXYZItem, false); |
501,6 → 513,7 |
if (currItem->asOSGFrame()) |
{ |
TabStack->setItemEnabled(idXYZItem, true); |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idGroupItem, false); |
TabStack->setItemEnabled(idLineItem, false); |
518,6 → 531,7 |
} |
break; |
case PageItem::TextFrame: |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idTextItem, true); |
TabStack->setItemEnabled(idImageItem, false); |
524,6 → 538,7 |
TabStack->setItemEnabled(idLineItem, true); |
break; |
case PageItem::Line: |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, false); |
TabStack->setItemEnabled(idTextItem, false); |
TabStack->setItemEnabled(idImageItem, false); |
534,6 → 549,7 |
case PageItem::Polygon: |
case PageItem::RegularPolygon: |
case PageItem::Arc: |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idTextItem, false); |
TabStack->setItemEnabled(idImageItem, false); |
541,6 → 557,7 |
break; |
case PageItem::PolyLine: |
case PageItem::Spiral: |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idTextItem, false); |
TabStack->setItemEnabled(idImageItem, false); |
547,6 → 564,7 |
TabStack->setItemEnabled(idLineItem, true); |
break; |
case PageItem::PathText: |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idTextItem, true); |
TabStack->setItemEnabled(idImageItem, false); |
554,6 → 572,7 |
break; |
case PageItem::Symbol: |
case PageItem::Group: |
TabStack->setItemEnabled(idShadowItem, false); |
TabStack->setItemEnabled(idShapeItem, false); |
TabStack->setItemEnabled(idTextItem, false); |
TabStack->setItemEnabled(idImageItem, false); |
564,6 → 583,7 |
break; |
case PageItem::Table: |
TabStack->setItemEnabled(idTableItem, true); |
TabStack->setItemEnabled(idShadowItem, true); |
TabStack->setItemEnabled(idShapeItem, true); |
TabStack->setItemEnabled(idTextItem, m_doc->appMode == modeEditTable); |
TabStack->setItemEnabled(idImageItem, false); |
597,6 → 617,7 |
m_unitIndex = m_doc->unitIndex(); |
xyzPal->unitChange(); |
shadowPal->unitChange(); |
shapePal->unitChange(); |
groupPal->unitChange(); |
imagePal->unitChange(); |
860,6 → 881,7 |
tablePal->updateColorList(); |
Cpal->updateColorList(); |
Tpal->updateColorList(); |
shadowPal->updateColorList(); |
assert (m_doc->PageColors.document()); |
} |
889,6 → 911,7 |
TabStack->setItemText(idXYZItem, tr("X, Y, &Z")); |
TabStack->setItemText(idTextItem, tr("&Text")); |
TabStack->setItemText(idImageItem, tr("&Image")); |
TabStack->setItemText(idShadowItem, tr("Soft Shadow")); |
TabStack->setItemText(idShapeItem, tr("&Shape")); |
TabStack->setItemText(idLineItem, tr("&Line")); |
TabStack->setItemText(idColorsItem, tr("&Colors")); |
897,6 → 920,7 |
TabStack->setItemText(idTableItem, tr("T&able")); |
xyzPal->languageChange(); |
shadowPal->languageChange(); |
shapePal->languageChange(); |
groupPal->languageChange(); |
imagePal->languageChange(); |
/trunk/Scribus/scribus/ui/propertiespalette.h |
---|
36,6 → 36,7 |
class PropertiesPalette_Group; |
class PropertiesPalette_Image; |
class PropertiesPalette_Line; |
class PropertiesPalette_Shadow; |
class PropertiesPalette_Shape; |
class PropertiesPalette_Table; |
class PropertiesPalette_Text; |
74,6 → 75,7 |
PropertiesPalette_Group* groupPal; |
PropertiesPalette_Image* imagePal; |
PropertiesPalette_Line* linePal; |
PropertiesPalette_Shadow* shadowPal; |
PropertiesPalette_Shape* shapePal; |
PropertiesPalette_Table* tablePal; |
PropertiesPalette_Text* textPal; |
136,6 → 138,7 |
int idColorsItem; |
int idTransparencyItem; |
int idGroupItem; |
int idShadowItem; |
}; |
#endif |
/trunk/Scribus/scribus/ui/propertiespalette_shadow.cpp |
---|
0,0 → 1,325 |
/* |
For general Scribus (>=1.3.2) copyright and licensing information please refer |
to the COPYING file provided with the program. Following this notice may exist |
a copyright and/or license notice that predates the release of Scribus 1.3.2 |
for which a new license (GPL+exception) is in place. |
*/ |
#include "propertiespalette_shadow.h" |
#if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES) |
#define _USE_MATH_DEFINES |
#endif |
#include <cmath> |
#include "commonstrings.h" |
#include "sccolorengine.h" |
#include "pageitem.h" |
#include "propertiespalette_utils.h" |
#include "sccombobox.h" |
#include "scribus.h" |
#include "scribuscore.h" |
#include "scraction.h" |
#include "scribusview.h" |
#include "selection.h" |
#include "units.h" |
#include "undomanager.h" |
#include "util.h" |
#include "util_icon.h" |
#include "util_math.h" |
PropertiesPalette_Shadow::PropertiesPalette_Shadow( QWidget* parent) : QWidget(parent) |
{ |
m_ScMW = 0; |
m_doc = 0; |
m_haveDoc = false; |
m_haveItem = false; |
m_unitRatio = 1.0; |
setupUi(this); |
setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); |
_userActionOn = false; |
userActionSniffer = new UserActionSniffer(this); |
connect(userActionSniffer, SIGNAL(actionStart()), this, SLOT(spinboxStartUserAction())); |
connect(userActionSniffer, SIGNAL(actionEnd()), this, SLOT(spinboxFinishUserAction())); |
installSniffer(softShadowXOffset); |
installSniffer(softShadowYOffset); |
installSniffer(softShadowShade); |
installSniffer(softShadowOpacity); |
installSniffer(softShadowBlurRadius); |
languageChange(); |
connect(softShadowXOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowYOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowShade, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowOpacity, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowBlurRadius, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowBlendMode, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
connect(softShadowColor, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
connect(hasSoftShadow, SIGNAL(clicked()), this, SLOT(handleNewValues())); |
m_haveItem = false; |
softShadowXOffset->showValue(0); |
softShadowYOffset->showValue(0); |
softShadowShade->showValue(100); |
softShadowOpacity->showValue(1); |
softShadowBlurRadius->showValue(5); |
} |
void PropertiesPalette_Shadow::setMainWindow(ScribusMainWindow* mw) |
{ |
m_ScMW = mw; |
connect(m_ScMW, SIGNAL(UpdateRequest(int)), this, SLOT(handleUpdateRequest(int))); |
} |
void PropertiesPalette_Shadow::setDoc(ScribusDoc *d) |
{ |
if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) |
return; |
if (m_doc) |
{ |
disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
} |
m_doc = d; |
m_item = NULL; |
m_unitRatio = m_doc->unitRatio(); |
m_unitIndex = m_doc->unitIndex(); |
int precision = unitGetPrecisionFromIndex(m_unitIndex); |
//qt4 FIXME here |
double maxXYWHVal = 200 * m_unitRatio; |
double minXYVal = -200 * m_unitRatio; |
m_haveDoc = true; |
m_haveItem = false; |
QMap<QString, double>* docConstants = m_doc? &m_doc->constants() : NULL; |
softShadowXOffset->setValues( minXYVal, maxXYWHVal, precision, minXYVal); |
softShadowXOffset->setConstants(docConstants); |
softShadowYOffset->setValues( minXYVal, maxXYWHVal, precision, minXYVal); |
softShadowYOffset->setConstants(docConstants); |
softShadowOpacity->setValues(0, 100, 0, 100); |
softShadowBlurRadius->setValues(0, 20, 1, 5); |
softShadowShade->setValues(0, 100, 0, 100); |
updateSpinBoxConstants(); |
updateColorList(); |
connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
} |
void PropertiesPalette_Shadow::unsetDoc() |
{ |
if (m_doc) |
{ |
disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
} |
m_haveDoc = false; |
m_haveItem = false; |
m_doc = NULL; |
m_item = NULL; |
softShadowXOffset->setConstants(NULL); |
softShadowYOffset->setConstants(NULL); |
softShadowXOffset->showValue(0); |
softShadowYOffset->showValue(0); |
softShadowShade->showValue(100); |
softShadowOpacity->showValue(1); |
softShadowBlurRadius->showValue(5); |
setEnabled(false); |
} |
void PropertiesPalette_Shadow::unsetItem() |
{ |
m_haveItem = false; |
m_item = NULL; |
handleSelectionChanged(); |
} |
void PropertiesPalette_Shadow::handleUpdateRequest(int updateFlags) |
{ |
if (updateFlags & reqColorsUpdate) |
updateColorList(); |
} |
PageItem* PropertiesPalette_Shadow::currentItemFromSelection() |
{ |
PageItem *currentItem = NULL; |
if (m_doc) |
{ |
if (m_doc->m_Selection->count() > 1) |
currentItem = m_doc->m_Selection->itemAt(0); |
else if (m_doc->m_Selection->count() == 1) |
currentItem = m_doc->m_Selection->itemAt(0); |
} |
return currentItem; |
} |
void PropertiesPalette_Shadow::setCurrentItem(PageItem *i) |
{ |
if (!m_ScMW || m_ScMW->scriptIsRunning()) |
return; |
if (!m_doc) |
setDoc(i->doc()); |
m_haveItem = false; |
m_item = i; |
disconnect(softShadowXOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
disconnect(softShadowYOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
disconnect(softShadowShade, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
disconnect(softShadowOpacity, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
disconnect(softShadowBlurRadius, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
disconnect(softShadowBlendMode, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
disconnect(softShadowColor, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
disconnect(hasSoftShadow, SIGNAL(clicked()), this, SLOT(handleNewValues())); |
softShadowXOffset->setValue(i->softShadowXOffset() * m_unitRatio); |
softShadowYOffset->setValue(i->softShadowYOffset() * m_unitRatio); |
softShadowOpacity->setValue(qRound(100 - (i->softShadowOpacity() * 100))); |
softShadowBlurRadius->setValue(i->softShadowBlurRadius() * m_unitRatio); |
softShadowShade->setValue(i->softShadowShade()); |
setCurrentComboItem(softShadowColor, i->softShadowColor()); |
softShadowBlendMode->setCurrentIndex(i->softShadowBlendMode()); |
hasSoftShadow->setChecked(i->hasSoftShadow()); |
connect(softShadowXOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowYOffset, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowShade, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowOpacity, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowBlurRadius, SIGNAL(valueChanged(double)), this, SLOT(handleNewValues())); |
connect(softShadowBlendMode, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
connect(softShadowColor, SIGNAL(activated(int)), this, SLOT(handleNewValues())); |
connect(hasSoftShadow, SIGNAL(clicked()), this, SLOT(handleNewValues())); |
m_haveItem = true; |
updateSpinBoxConstants(); |
} |
void PropertiesPalette_Shadow::handleSelectionChanged() |
{ |
if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) |
return; |
PageItem* currItem = currentItemFromSelection(); |
if (currItem) |
setCurrentItem(currItem); |
updateGeometry(); |
} |
void PropertiesPalette_Shadow::unitChange() |
{ |
if (!m_haveDoc) |
return; |
bool tmp = m_haveItem; |
m_haveItem = false; |
m_unitRatio = m_doc->unitRatio(); |
m_unitIndex = m_doc->unitIndex(); |
softShadowXOffset->setNewUnit( m_unitIndex ); |
softShadowYOffset->setNewUnit( m_unitIndex ); |
softShadowBlurRadius->setNewUnit( m_unitIndex ); |
m_haveItem = tmp; |
} |
void PropertiesPalette_Shadow::updateColorList() |
{ |
if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) |
return; |
softShadowColor->updateBox(m_doc->PageColors, ColorCombo::fancyPixmaps, false); |
} |
void PropertiesPalette_Shadow::handleNewValues() |
{ |
if (m_haveItem) |
{ |
double x = softShadowXOffset->value() / m_unitRatio; |
double y = softShadowYOffset->value() / m_unitRatio; |
double r = softShadowBlurRadius->value() / m_unitRatio; |
double o = (100 - softShadowOpacity->value()) / 100.0; |
int b = softShadowBlendMode->currentIndex(); |
QString color = softShadowColor->currentText(); |
if (color == CommonStrings::tr_NoneColor) |
color = CommonStrings::None; |
double s = softShadowShade->value(); |
if (m_haveDoc) |
{ |
m_doc->itemSelection_SetSoftShadow(hasSoftShadow->isChecked(), color, x, y, r, s, o, b); |
} |
} |
} |
void PropertiesPalette_Shadow::installSniffer(ScrSpinBox *spinBox) |
{ |
const QList<QObject*> list = spinBox->children(); |
if (!list.isEmpty()) |
{ |
QListIterator<QObject*> it(list); |
QObject *obj; |
while (it.hasNext()) |
{ |
obj = it.next(); |
obj->installEventFilter(userActionSniffer); |
} |
} |
} |
bool PropertiesPalette_Shadow::userActionOn() |
{ |
return _userActionOn; |
} |
void PropertiesPalette_Shadow::spinboxStartUserAction() |
{ |
_userActionOn = true; |
} |
void PropertiesPalette_Shadow::spinboxFinishUserAction() |
{ |
_userActionOn = false; |
for (int i = 0; i < m_doc->m_Selection->count(); ++i) |
m_doc->m_Selection->itemAt(i)->checkChanges(true); |
if (m_ScMW->view->groupTransactionStarted()) |
{ |
m_ScMW->view->endGroupTransaction(); |
} |
} |
void PropertiesPalette_Shadow::changeEvent(QEvent *e) |
{ |
if (e->type() == QEvent::LanguageChange) |
{ |
languageChange(); |
} |
else |
QWidget::changeEvent(e); |
} |
void PropertiesPalette_Shadow::languageChange() |
{ |
hasSoftShadow->setText( tr("Object has a soft shadow")); |
label->setText( tr("X-Offset:")); |
label_2->setText( tr("Y-Offset:")); |
label_3->setText( tr("Blur:")); |
label_4->setText( tr("Color:")); |
label_5->setText( tr("Shade:")); |
label_6->setText( tr("Opacity:")); |
label_7->setText( tr("Blendmode:")); |
QString ptSuffix = tr(" pt"); |
QString ein = (m_haveDoc) ? unitGetSuffixFromIndex(m_doc->unitIndex()) : ptSuffix; |
softShadowXOffset->setSuffix(ein); |
softShadowYOffset->setSuffix(ein); |
softShadowBlurRadius->setSuffix(ein); |
} |
void PropertiesPalette_Shadow::updateSpinBoxConstants() |
{ |
if (!m_haveDoc) |
return; |
if(m_doc->m_Selection->count()==0) |
return; |
softShadowXOffset->setConstants(&m_doc->constants()); |
softShadowYOffset->setConstants(&m_doc->constants()); |
} |
/trunk/Scribus/scribus/ui/propertiespalette_shadow.h |
---|
0,0 → 1,80 |
/* |
For general Scribus (>=1.3.2) copyright and licensing information please refer |
to the COPYING file provided with the program. Following this notice may exist |
a copyright and/or license notice that predates the release of Scribus 1.3.2 |
for which a new license (GPL+exception) is in place. |
*/ |
#ifndef PROPERTIESPALETTE_SHADOW_H |
#define PROPERTIESPALETTE_SHADOW_H |
#include "ui_propertiespalette_shadowbase.h" |
#include "scribusapi.h" |
#include "scrspinbox.h" |
#include "sclistboxpixmap.h" |
#include "scguardedptr.h" |
class PageItem; |
class ScribusDoc; |
class Selection; |
class ScribusMainWindow; |
class UserActionSniffer; |
class SCRIBUS_API PropertiesPalette_Shadow : public QWidget, public Ui::PropertiesPalette_ShadowBase |
{ |
Q_OBJECT |
public: |
PropertiesPalette_Shadow(QWidget* parent); |
~PropertiesPalette_Shadow() {}; |
virtual void changeEvent(QEvent *e); |
/** @brief Returns true if there is a user action going on at the moment of call. */ |
bool userActionOn(); // not yet implemented!!! This is needed badly. |
// When user releases the mouse button or arrow key, changes must be checked |
// and if in ScribusView a groupTransaction has been started it must be also |
// commmited |
void updateColorList(); |
private: |
PageItem* currentItemFromSelection(); |
public slots: |
void setMainWindow(ScribusMainWindow *mw); |
void setDoc(ScribusDoc *d); |
void setCurrentItem(PageItem *i); |
void unsetDoc(); |
void unsetItem(); |
void languageChange(); |
void unitChange(); |
void handleSelectionChanged(); |
void handleUpdateRequest(int); |
private slots: |
void handleNewValues(); |
protected slots: |
void spinboxStartUserAction(); |
void spinboxFinishUserAction(); |
void updateSpinBoxConstants(); |
protected: |
ScribusMainWindow *m_ScMW; |
bool m_haveDoc; |
bool m_haveItem; |
double m_unitRatio; |
int m_unitIndex; |
PageItem *m_item; |
ScGuardedPtr<ScribusDoc> m_doc; |
bool _userActionOn; |
UserActionSniffer *userActionSniffer; |
void installSniffer(ScrSpinBox *spinBox); |
}; |
#endif |
/trunk/Scribus/scribus/ui/propertiespalette_shadowbase.ui |
---|
0,0 → 1,251 |
<?xml version="1.0" encoding="UTF-8"?> |
<ui version="4.0"> |
<class>PropertiesPalette_ShadowBase</class> |
<widget class="QWidget" name="PropertiesPalette_ShadowBase"> |
<property name="geometry"> |
<rect> |
<x>0</x> |
<y>0</y> |
<width>233</width> |
<height>232</height> |
</rect> |
</property> |
<property name="windowTitle"> |
<string>Form</string> |
</property> |
<layout class="QVBoxLayout" name="verticalLayout"> |
<item> |
<widget class="QCheckBox" name="hasSoftShadow"> |
<property name="text"> |
<string>Object has a soft shadow</string> |
</property> |
</widget> |
</item> |
<item> |
<layout class="QGridLayout" name="gridLayout"> |
<item row="0" column="0"> |
<widget class="QLabel" name="label"> |
<property name="text"> |
<string>X-Offset:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowXOffset</cstring> |
</property> |
</widget> |
</item> |
<item row="0" column="1"> |
<widget class="ScrSpinBox" name="softShadowXOffset"/> |
</item> |
<item row="1" column="0"> |
<widget class="QLabel" name="label_2"> |
<property name="text"> |
<string>Y-Offset:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowYOffset</cstring> |
</property> |
</widget> |
</item> |
<item row="1" column="1"> |
<widget class="ScrSpinBox" name="softShadowYOffset"/> |
</item> |
<item row="2" column="0"> |
<widget class="QLabel" name="label_4"> |
<property name="text"> |
<string>Color:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowColor</cstring> |
</property> |
</widget> |
</item> |
<item row="2" column="1"> |
<widget class="ColorCombo" name="softShadowColor"/> |
</item> |
<item row="3" column="0"> |
<widget class="QLabel" name="label_5"> |
<property name="text"> |
<string>Shade:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowShade</cstring> |
</property> |
</widget> |
</item> |
<item row="4" column="0"> |
<widget class="QLabel" name="label_6"> |
<property name="text"> |
<string>Opacity:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowOpacity</cstring> |
</property> |
</widget> |
</item> |
<item row="4" column="1"> |
<widget class="ScrSpinBox" name="softShadowOpacity"> |
<property name="suffix"> |
<string> %</string> |
</property> |
<property name="maximum"> |
<number>100</number> |
</property> |
<property name="value"> |
<number>100</number> |
</property> |
</widget> |
</item> |
<item row="5" column="0"> |
<widget class="QLabel" name="label_7"> |
<property name="text"> |
<string>Blendmode:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowBlendMode</cstring> |
</property> |
</widget> |
</item> |
<item row="5" column="1"> |
<widget class="ScComboBox" name="softShadowBlendMode"> |
<item> |
<property name="text"> |
<string>Normal</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Darken</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Lighten</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Multiply</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Screen</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Overlay</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Hard Light</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Soft Light</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Difference</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Exclusion</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Color Dodge</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Color Burn</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Hue</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Saturation</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Color</string> |
</property> |
</item> |
<item> |
<property name="text"> |
<string>Luminosity</string> |
</property> |
</item> |
</widget> |
</item> |
<item row="6" column="0"> |
<widget class="QLabel" name="label_3"> |
<property name="text"> |
<string>Blur:</string> |
</property> |
<property name="buddy"> |
<cstring>softShadowBlurRadius</cstring> |
</property> |
</widget> |
</item> |
<item row="6" column="1"> |
<widget class="ScrSpinBox" name="softShadowBlurRadius"> |
<property name="suffix"> |
<string> px</string> |
</property> |
<property name="maximum"> |
<number>20</number> |
</property> |
<property name="value"> |
<number>5</number> |
</property> |
</widget> |
</item> |
<item row="3" column="1"> |
<widget class="ScrSpinBox" name="softShadowShade"> |
<property name="suffix"> |
<string> %</string> |
</property> |
<property name="maximum"> |
<number>100</number> |
</property> |
<property name="value"> |
<number>100</number> |
</property> |
</widget> |
</item> |
</layout> |
</item> |
</layout> |
</widget> |
<customwidgets> |
<customwidget> |
<class>ScrSpinBox</class> |
<extends>QSpinBox</extends> |
<header location="global">ui/scrspinbox.h</header> |
</customwidget> |
<customwidget> |
<class>ScComboBox</class> |
<extends>QComboBox</extends> |
<header>ui/sccombobox.h</header> |
</customwidget> |
<customwidget> |
<class>ColorCombo</class> |
<extends>QComboBox</extends> |
<header>ui/colorcombo.h</header> |
</customwidget> |
</customwidgets> |
<resources/> |
<connections/> |
</ui> |