Author: toshok
Date: 2008-01-16 14:17:11 -0500 (Wed, 16 Jan 2008)
New Revision: 93084

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/collection.cpp
   trunk/moon/src/collection.h
   trunk/moon/src/stylus.cpp
   trunk/moon/src/stylus.h
Log:
2008-01-16  Chris Toshok  <[EMAIL PROTECTED]>

        * stylus.h, stylus.cpp: a few changes.  Move the
        StylusPointCollection and StrokeCollection classes here from
        collection.h/collection.cpp.  I didn't like the addition of
        stylus.cpp logic in two places.  Convert Stroke::GetBounds use use
        the new DrawingAttributes::ComputeBounds{WithoutDrawingAttributes}
        methods, and build up the bounds for the StrokeCollection by
        unioning all the Stroke bounds (these should be cached, but aren't
        yet.)  StrokeCollection::HitTest has been implemented, just
        looping over the strokes.  Stroke::HitTest is missing its guts at
        the moment, since hit testing is going to be a little bit of a
        pain for it.

        * collection.h, collection.cpp: remove StylusPointCollection and
        StrokeCollection.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2008-01-16 19:13:41 UTC (rev 93083)
+++ trunk/moon/src/ChangeLog    2008-01-16 19:17:11 UTC (rev 93084)
@@ -1,3 +1,20 @@
+2008-01-16  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * stylus.h, stylus.cpp: a few changes.  Move the
+       StylusPointCollection and StrokeCollection classes here from
+       collection.h/collection.cpp.  I didn't like the addition of
+       stylus.cpp logic in two places.  Convert Stroke::GetBounds use use
+       the new DrawingAttributes::ComputeBounds{WithoutDrawingAttributes}
+       methods, and build up the bounds for the StrokeCollection by
+       unioning all the Stroke bounds (these should be cached, but aren't
+       yet.)  StrokeCollection::HitTest has been implemented, just
+       looping over the strokes.  Stroke::HitTest is missing its guts at
+       the moment, since hit testing is going to be a little bit of a
+       pain for it.
+
+       * collection.h, collection.cpp: remove StylusPointCollection and
+       StrokeCollection.
+
 2008-01-16  Larry Ewing  <[EMAIL PROTECTED]>
 
        * uielement.cpp, uielement.h: Rework the way we handle opacity to

Modified: trunk/moon/src/collection.cpp
===================================================================
--- trunk/moon/src/collection.cpp       2008-01-16 19:13:41 UTC (rev 93083)
+++ trunk/moon/src/collection.cpp       2008-01-16 19:17:11 UTC (rev 93084)
@@ -19,6 +19,7 @@
 #include "animation.h"
 #include "transform.h"
 #include "namescope.h"
+#include "stylus.h"
 
 Collection::Node::Node (DependencyObject *dob, DependencyObject *parent)
 {
@@ -415,13 +416,6 @@
        }
 }
 
-class UIElementNode : public List::Node {
-public:
-       UIElement *item;
-       
-       UIElementNode (UIElement *v) : item (v) { }
-};
-
 static int
 UIElementZIndexComparer (gconstpointer ui1, gconstpointer ui2)
 {
@@ -765,64 +759,9 @@
        return new ResourceDictionary ();
 }
 
-StrokeCollection *
-stroke_collection_new (void)
-{
-       return new StrokeCollection ();
-}
 
-Rect
-StrokeCollection::GetBounds ()
-{
-       // XXX
-       return Rect (0,0,0,0);
-}
 
-StrokeCollection*
-StrokeCollection::HitTest (StylusPointCollection *stylusPoints)
-{
-       // XXX
-       return new StrokeCollection ();
-}
 
-void
-stroke_collection_get_bounds (StrokeCollection *col, Rect *bounds)
-{
-       *bounds = col->GetBounds();
-}
-
-StrokeCollection* 
-stroke_collection_hit_test (StrokeCollection* col, StylusPointCollection* 
stylusPointCollection)
-{
-       return col->HitTest (stylusPointCollection);
-}
-
-
-StylusPointCollection *
-stylus_point_collection_new (void)
-{
-       return new StylusPointCollection ();
-}
-
-double
-stylus_point_collection_add_stylus_points (StylusPointCollection *col, 
StylusPointCollection *stylusPointCollection)
-{
-       return col->AddStylusPoints (stylusPointCollection);
-}
-
-double
-StylusPointCollection::AddStylusPoints (StylusPointCollection 
*stylusPointCollection)
-{
-       if (!stylusPointCollection)
-               return 1.0; // documented as such, needs testing
-
-       int count = collection_count (stylusPointCollection);
-       for (int i=0; i < count; i++) {
-               collection_add (this, collection_get_value_at 
(stylusPointCollection, i));
-       }
-       return collection_count (this) - 1;
-}
-
 TimelineMarkerCollection *
 timeline_marker_collection_new (void)
 {

Modified: trunk/moon/src/collection.h
===================================================================
--- trunk/moon/src/collection.h 2008-01-16 19:13:41 UTC (rev 93083)
+++ trunk/moon/src/collection.h 2008-01-16 19:17:11 UTC (rev 93084)
@@ -123,25 +123,6 @@
        virtual Type::Kind GetElementType () { return Type::DEPENDENCY_OBJECT; }
 };
 
-class StrokeCollection : public Collection {
- public:
-       StrokeCollection () {}
-       virtual Type::Kind GetObjectType () { return Type::STROKE_COLLECTION; }
-       virtual Type::Kind GetElementType () { return Type::STROKE; }
-
-       Rect GetBounds ();
-       StrokeCollection* HitTest (StylusPointCollection *stylusPoints);
-};
-
-class StylusPointCollection : public Collection {
- public:
-       StylusPointCollection () {}
-       virtual Type::Kind GetObjectType () { return 
Type::STYLUSPOINT_COLLECTION; }
-       virtual Type::Kind GetElementType () { return Type::STYLUSPOINT; }
-
-       double AddStylusPoints (StylusPointCollection *stylusPointCollection);
-};
-
 class TimelineMarkerCollection : public Collection {
  public:
        TimelineMarkerCollection () {}
@@ -196,13 +177,6 @@
 GradientStopCollection *gradient_stop_collection_new (void);
 Inlines *inlines_new (void);
 
-StrokeCollection *stroke_collection_new (void);
-void              stroke_collection_get_bounds (StrokeCollection *col, Rect 
*bounds);
-StrokeCollection *stroke_collection_hit_test (StrokeCollection *col, 
StylusPointCollection *stylusPointCollection);
-
-StylusPointCollection *stylus_point_collection_new (void);
-double stylus_point_collection_add_stylus_points (StylusPointCollection *col, 
StylusPointCollection *stylusPointCollection);
-
 MediaAttributeCollection *media_attribute_collection_new (void);
 MediaAttribute *media_attribute_collection_get_item_by_name 
(MediaAttributeCollection *collection, const char *name);
 

Modified: trunk/moon/src/stylus.cpp
===================================================================
--- trunk/moon/src/stylus.cpp   2008-01-16 19:13:41 UTC (rev 93083)
+++ trunk/moon/src/stylus.cpp   2008-01-16 19:17:11 UTC (rev 93084)
@@ -92,6 +92,32 @@
 }
 
 
+StylusPointCollection *
+stylus_point_collection_new (void)
+{
+       return new StylusPointCollection ();
+}
+
+double
+stylus_point_collection_add_stylus_points (StylusPointCollection *col, 
StylusPointCollection *stylusPointCollection)
+{
+       return col->AddStylusPoints (stylusPointCollection);
+}
+
+double
+StylusPointCollection::AddStylusPoints (StylusPointCollection 
*stylusPointCollection)
+{
+       if (!stylusPointCollection)
+               return 1.0; // documented as such, needs testing
+
+       int count = collection_count (stylusPointCollection);
+       for (int i=0; i < count; i++) {
+               collection_add (this, collection_get_value_at 
(stylusPointCollection, i));
+       }
+       return collection_count (this) - 1;
+}
+
+
 Stroke::Stroke ()
 {
        this->SetValue (Stroke::StylusPointsProperty, Value::CreateUnref (new 
StylusPointCollection ()));
@@ -101,14 +127,26 @@
 Rect
 Stroke::GetBounds ()
 {
-       // XXX
-       return Rect (0,0,0,0);
+       DrawingAttributes *da = stroke_get_drawing_attributes (this);
+       StylusPointCollection *spc = stroke_get_stylus_points (this);
+
+       if (da)
+               return da->ComputeBounds (spc);
+       else
+               return DrawingAttributes::ComputeBoundsWithoutDrawingAttributes 
(spc);
 }
 
 bool
 Stroke::HitTest (StylusPointCollection *stylusPoints)
 {
-       // XXX
+       Collection::Node *n;
+
+       Rect bounds = GetBounds();
+
+       for (n = (Collection::Node *) stylusPoints->list->First (); n; n = 
(Collection::Node *) n->next) {
+               StylusPoint *sp = (StylusPoint*)n->obj;
+       }
+
        return false;
 }
 
@@ -158,7 +196,59 @@
 
 
 
+StrokeCollection *
+stroke_collection_new (void)
+{
+       return new StrokeCollection ();
+}
 
+Rect
+StrokeCollection::GetBounds ()
+{
+       Rect r = Rect (0, 0, 0, 0);
+       
+       Collection::Node *n;
+       for (n = (Collection::Node *) list->First (); n; n = (Collection::Node 
*) n->next)
+               r = r.Union (((Stroke*)n->obj)->GetBounds());
+       
+       return r;
+}
+
+StrokeCollection*
+StrokeCollection::HitTest (StylusPointCollection *stylusPoints)
+{
+       Collection::Node *n;
+
+       StrokeCollection *result = new StrokeCollection ();
+
+       if (stylusPoints->list->Length () == 0)
+               return result;
+
+       for (n = (Collection::Node *) list->First (); n; n = (Collection::Node 
*) n->next) {
+               Stroke *s = (Stroke*)n->obj;
+
+               if (s->HitTest(hit_points))
+                       result->Add (s);
+       }
+
+       return result;
+}
+
+void
+stroke_collection_get_bounds (StrokeCollection *col, Rect *bounds)
+{
+       *bounds = col->GetBounds();
+}
+
+StrokeCollection* 
+stroke_collection_hit_test (StrokeCollection* col, StylusPointCollection* 
stylusPointCollection)
+{
+       return col->HitTest (stylusPointCollection);
+}
+
+
+
+
 DrawingAttributes*
 drawing_attributes_new ()
 {
@@ -281,7 +371,20 @@
        drawing_attributes_quick_render (cr, 2.0, NULL, collection);
 }
 
+Rect
+DrawingAttributes::ComputeBounds (StylusPointCollection *stylusPointCollection)
+{
+       // XXX
+       return Rect (0,0,0,0);
+}
 
+Rect
+DrawingAttributes::ComputeBoundsWithoutDrawingAttributes 
(StylusPointCollection *stylusPointCollection)
+{
+       // XXX
+       return Rect (0,0,0,0);
+}
+
 InkPresenter::InkPresenter ()
 {
        this->SetValue (InkPresenter::StrokesProperty, Value::CreateUnref (new 
StrokeCollection ()));

Modified: trunk/moon/src/stylus.h
===================================================================
--- trunk/moon/src/stylus.h     2008-01-16 19:13:41 UTC (rev 93083)
+++ trunk/moon/src/stylus.h     2008-01-16 19:17:11 UTC (rev 93084)
@@ -15,6 +15,7 @@
 #define MOON_STYLUS_H
 
 #include "canvas.h"
+#include "collection.h"
 
 G_BEGIN_DECLS
 
@@ -61,6 +62,18 @@
 double stylus_point_get_pressure_factor (StylusPoint *stylus_point);
 void   stylus_point_set_pressure_factor (StylusPoint *stylus_point, double 
pressure);
 
+class StylusPointCollection : public Collection {
+ public:
+       StylusPointCollection () {}
+       virtual Type::Kind GetObjectType () { return 
Type::STYLUSPOINT_COLLECTION; }
+       virtual Type::Kind GetElementType () { return Type::STYLUSPOINT; }
+
+       double AddStylusPoints (StylusPointCollection *stylusPointCollection);
+};
+
+StylusPointCollection *stylus_point_collection_new (void);
+double stylus_point_collection_add_stylus_points (StylusPointCollection *col, 
StylusPointCollection *stylusPointCollection);
+
 class DrawingAttributes : public DependencyObject {
  public:
        DrawingAttributes () { }
@@ -71,6 +84,9 @@
        void Render (cairo_t *cr, StylusPointCollection* collection);
        static void RenderWithoutDrawingAttributes (cairo_t *cr, 
StylusPointCollection* collection);
 
+       Rect ComputeBounds (StylusPointCollection *collection);
+       static Rect ComputeBoundsWithoutDrawingAttributes 
(StylusPointCollection* collection);
+
        static DependencyProperty* ColorProperty;
        static DependencyProperty* OutlineColorProperty;
        static DependencyProperty* HeightProperty;
@@ -109,6 +125,21 @@
 void                   stroke_get_bounds (Stroke *stroke, Rect* bounds);
 bool                   stroke_hit_test (Stroke *stroke, StylusPointCollection 
*stylusPointCollection);
 
+class StrokeCollection : public Collection {
+ public:
+       StrokeCollection () {}
+       virtual Type::Kind GetObjectType () { return Type::STROKE_COLLECTION; }
+       virtual Type::Kind GetElementType () { return Type::STROKE; }
+
+       Rect GetBounds ();
+       StrokeCollection* HitTest (StylusPointCollection *stylusPoints);
+};
+
+StrokeCollection *stroke_collection_new (void);
+void              stroke_collection_get_bounds (StrokeCollection *col, Rect 
*bounds);
+StrokeCollection *stroke_collection_hit_test (StrokeCollection *col, 
StylusPointCollection *stylusPointCollection);
+
+
 class InkPresenter : public Canvas {
  public:
        InkPresenter ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to