[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: koffice/libs/flake/tests
From: Thomas Zander <zander () kde ! org>
Date: 2009-09-26 20:52:03
Message-ID: 200909262252.04056.zander () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
On Friday 25. September 2009 19.38.15 jaham@gmx.net wrote:
> I don't think it is too complex, just a recursive function which gets a
> list of shapes to paint and when stumbling over a shape container calls
> itself with the containers child shapes.
> But if you have a better idea to get the same result by sorting the list
> of shapes, i am all for it. The important thing is that it works.
I think the attached patch is a good way to do it, sorting the list makes
sure the painting order is correct.
I committed a (failing) test to show the *painting* issue in the fullest.
What do you think about this patch?
--
Thomas Zander
["0001-Remove-incorrect-if-forcing-weird-zindex-and-fix-t.patch" (text/x-patch)]
From c3356c602a8c4f4e0bdb50a5a04522388e74035c Mon Sep 17 00:00:00 2001
From: Thomas Zander <zander@kde.org>
Date: Sat, 26 Sep 2009 22:47:27 +0200
Subject: [PATCH] Remove incorrect 'if' forcing weird zindex and fix the sorting method instead
---
libs/flake/KoShape.cpp | 48 +++++++++++++++++++++++++++++++++---------------
1 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/libs/flake/KoShape.cpp b/libs/flake/KoShape.cpp
index b019fcd..856a5aa 100644
--- a/libs/flake/KoShape.cpp
+++ b/libs/flake/KoShape.cpp
@@ -383,21 +383,41 @@ QMatrix KoShape::transformation() const
bool KoShape::compareShapeZIndex(KoShape *s1, KoShape *s2)
{
- int diff = s1->zIndex() - s2->zIndex();
- if (diff == 0) {
- KoShape *s = s1->parent();
- while (s) {
- if (s == s2) // s1 is a child of s2
- return false; // children are always on top of their parents.
- s = s->parent();
- }
- s = s2->parent();
- while (s) {
- if (s == s1) // s2 is a child of s1
- return true;
- s = s->parent();
+ bool foundCommonParent = false;
+ KoShape *parentShapeS1 = s1;
+ KoShape *parentShapeS2 = s2;
+ while (parentShapeS1 && !foundCommonParent) {
+ parentShapeS2 = s2;
+ while (parentShapeS2) {
+ if (parentShapeS2 == parentShapeS1) {
+ foundCommonParent = true;
+ break;
+ }
+ parentShapeS2 = parentShapeS2->parent();
}
+
+ if (!foundCommonParent)
+ parentShapeS1 = parentShapeS1->parent();
}
+
+ if (parentShapeS1 == 0 && parentShapeS2 == 0) {
+ // the two shapes are in different trees, compare root nodes instead.
+ while (s1->parent())
+ s1 = s1->parent();
+ while (s2->parent())
+ s2 = s2->parent();
+ } else if (parentShapeS1 == parentShapeS2) {
+ if (parentShapeS1 == s1) // s2 is a child of s1
+ return true;
+ if (parentShapeS1 == s2) // s1 is a child of s2
+ return false;
+ } else if (parentShapeS1 && parentShapeS2) {
+ // if s1 and s2 are not siblings, we should compare their parents zindex instead
+ s1 = parentShapeS1;
+ s2 = parentShapeS2;
+ }
+
+ int diff = s1->zIndex() - s2->zIndex();
return diff < 0;
}
@@ -421,8 +441,6 @@ void KoShape::setParent(KoShapeContainer *parent)
int KoShape::zIndex() const
{
Q_D(const KoShape);
- if (parent()) // we can't be under our parent...
- return qMax((int) d->zIndex, parent()->zIndex());
return d->zIndex;
}
--
1.6.0.4
["signature.asc" (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic