[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Shape Container
From:       Johannes Simon <johannes.simon () gmail ! com>
Date:       2008-01-02 13:32:56
Message-ID: 1199280776.6116.9.camel () Speedstar
[Download RAW message or body]

Hello,

For the chart shape we decided to have an independent legend. That is, a
shape that can be moved and resized, but that the chart shape has
ownership of. I think the best solution for this is a KoShapeContainer.
I already tried it out, and it works pretty well. But as it is now,
every child of a shape container is moved when the container itself is
moved, because the children's positions are relative to the parent.

Now, I sometimes need the legend shape not to be bound to the chart
shape, so that it is not moved when the chart shape is. So here's my
proposal to have something like
KoShape::setPositionRelativeToParent( bool ), with the patch attached to
this email. You're welcome to give it a better name if you can think of
one :)

- Joh

["KoShape.diff" (KoShape.diff)]

Index: KoShape.h
===================================================================
--- KoShape.h	(Revision 752802)
+++ KoShape.h	(Arbeitskopie)
@@ -255,6 +255,8 @@
      */
     virtual void setPosition( const QPointF &position );
 
+    virtual void setPositionRelativeToParent( bool b );
+
     /**
      * @brief Get the position of the shape in pt
      *
Index: KoShape.cpp
===================================================================
--- KoShape.cpp	(Revision 752802)
+++ KoShape.cpp	(Arbeitskopie)
@@ -65,6 +65,7 @@
         keepAspect( false ),
         selectable( true ),
         detectCollision( false ),
+        positionRelativeToParent( true ),
         userData(0),
         appData(0),
         backgroundBrush(Qt::NoBrush),
@@ -111,6 +112,7 @@
     bool keepAspect;
     bool selectable;
     bool detectCollision;
+    bool positionRelativeToParent;
 
     QSet<KoShapeManager *> shapeManagers;
     KoShapeUserData *userData;
@@ -227,6 +229,11 @@
     d->shapeChanged(PositionChanged);
 }
 
+void KoShape::setPositionRelativeToParent( bool b )
+{
+    d->positionRelativeToParent = b;
+}
+
 bool KoShape::hitTest( const QPointF &position ) const
 {
     if(d->parent && d->parent->childClipped(this) && !d->parent->hitTest(position))
@@ -257,7 +264,7 @@
     QMatrix matrix;
     // apply parents matrix to inherit any transformations done there.
     KoShapeContainer * container = d->parent;
-    if( container ) {
+    if( container && d->positionRelativeToParent ) {
         if( container->childClipped(this) )
             matrix = container->absoluteTransformation(0);
         else {


_______________________________________________
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