Skip to content

Commit

Permalink
fix #28041: image z-order
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Jul 21, 2014
1 parent d389ab2 commit 4b2bfef
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion libmscore/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ Image::Image(Score* s)
_lockAspectRatio = defaultLockAspectRatio;
_autoScale = defaultAutoScale;
_sizeIsSpatium = defaultSizeIsSpatium;
setZ(int(Element::Type::IMAGE) * 100);
_linkIsValid = false;
// set default Z order high so image is drawn on top of everything else
// but not above MEASURE, or it won't be selectable while on staff
// use of transparent background allows image to coexist with staff and other elements
setZ(int(Element::Type::MEASURE) * 100 - 1);
}

Image::Image(const Image& img)
Expand All @@ -64,6 +67,7 @@ Image::Image(const Image& img)
rasterDoc = img.rasterDoc;
else if (imageType == ImageType::SVG)
svgDoc = img.svgDoc;
setZ(img.z());
}

//---------------------------------------------------------
Expand Down
11 changes: 8 additions & 3 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@ extern MasterSynthesizer* synti;

static void paintElements(QPainter& p, const QList<const Element*>& el)
{
foreach(const Element* e, el) {
foreach (const Element* e, el) {
if (!e->visible())
continue;
QPointF pos(e->pagePos());
p.translate(pos);
e->draw(&p);
p.translate(-pos);
}

}

//---------------------------------------------------------
Expand Down Expand Up @@ -2087,7 +2088,9 @@ bool MuseScore::savePng(Score* score, const QString& name, bool screenshot, bool
p.setRenderHint(QPainter::TextAntialiasing, true);
p.scale(mag, mag);

paintElements(p, page->elements());
QList<const Element*> pel = page->elements();
qStableSort(pel.begin(), pel.end(), elementLessThan);
paintElements(p, pel);

if (format == QImage::Format_Indexed8) {
//convert to grayscale & respect alpha
Expand Down Expand Up @@ -2264,7 +2267,9 @@ bool MuseScore::saveSvg(Score* score, const QString& saveName)
p.scale(mag, mag);

foreach (Page* page, score->pages()) {
paintElements(p, page->elements());
QList<const Element*> pel = page->elements();
qStableSort(pel.begin(), pel.end(), elementLessThan);
paintElements(p, pel);
p.translate(QPointF(pf->width() * MScore::DPI, 0.0));
}

Expand Down
2 changes: 1 addition & 1 deletion vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
accidental-1 accidental-2 accidental-3 accidental-4\
accidental-5 accidental-6 accidental-7 accidental-8\
tie-1 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 beams-1 beams-2\
user-offset-1 user-offset-2 chord-space-1 tablature-1"
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1"
fi

DPI=130
Expand Down
2 changes: 1 addition & 1 deletion vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set SRC=mmrest-1,bravura-mmrest,mmrest-2,mmrest-4,mmrest-5,mmrest-6,mmrest-7,mmr
accidental-1,accidental-2,accidental-3,accidental-4, ^
accidental-5,accidental-6,accidental-7,accidental-8, ^
tie-1,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,beams-1,beams-2, ^
user-offset-1,user-offset-2,chord-space-1,tablature-1
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1

set MSCORE=..\win32install\bin\mscore.exe
set DPI=130
Expand Down
Binary file added vtest/image-1-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/image-1.mscz
Binary file not shown.

0 comments on commit 4b2bfef

Please sign in to comment.