Author: fejj
Date: 2007-06-14 13:18:51 -0400 (Thu, 14 Jun 2007)
New Revision: 79574

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/media.cpp
   trunk/moon/src/media.h
   trunk/moon/src/text.cpp
Log:
2007-06-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * text.cpp: Fixed Brush accessors for the NULL case.

        * media.cpp: Fixed accessors that could return NULL
        (media_init): init MediaBase and MediaElement items.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-14 17:13:01 UTC (rev 79573)
+++ trunk/moon/src/ChangeLog    2007-06-14 17:18:51 UTC (rev 79574)
@@ -1,3 +1,10 @@
+2007-06-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * text.cpp: Fixed Brush accessors for the NULL case.
+
+       * media.cpp: Fixed accessors that could return NULL
+       (media_init): init MediaBase and MediaElement items.
+
 2007-06-14  Jackson Harper  <[EMAIL PROTECTED]>
 
        * animation.cpp: C style constructor.

Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp    2007-06-14 17:13:01 UTC (rev 79573)
+++ trunk/moon/src/media.cpp    2007-06-14 17:18:51 UTC (rev 79574)
@@ -29,7 +29,9 @@
 char *
 media_base_get_source (MediaBase *media)
 {
-       return (char *) media->GetValue (MediaBase::SourceProperty)->AsString 
();
+       Value *value = media->GetValue (MediaBase::SourceProperty);
+       
+       return value ? (char *) value->AsString () : NULL;
 }
 
 void
@@ -157,7 +159,9 @@
 char *
 media_element_get_current_state (MediaElement *media)
 {
-       return (char *) media->GetValue 
(MediaElement::CurrentStateProperty)->AsString ();
+       Value *value = media->GetValue (MediaElement::CurrentStateProperty);
+       
+       return value ? (char *) value->AsString () : NULL;
 }
 
 double
@@ -187,12 +191,21 @@
 TimelineMarkerCollection *
 media_element_get_markers (MediaElement *media)
 {
-       return (TimelineMarkerCollection *) media->GetValue 
(MediaElement::MarkersProperty)->AsTimelineMarkerCollection ();
+       Value *value = media->GetValue (MediaElement::MarkersProperty);
+       
+       return value ? (TimelineMarkerCollection *) 
value->AsTimelineMarkerCollection () : NULL;
 }
 
 void
 media_element_set_markers (MediaElement *media, TimelineMarkerCollection 
*value)
 {
+       TimelineMarkerCollection *markers = media_element_get_markers (media);
+       
+       if (markers != NULL)
+               base_unref (markers);
+       
+       base_ref (value);
+       
        media->SetValue (MediaElement::MarkersProperty, Value (value));
 }
 
@@ -244,7 +257,8 @@
        media->SetValue (MediaElement::PositionProperty, Value (value));
 }
 
-double media_element_get_volume (MediaElement *media)
+double
+media_element_get_volume (MediaElement *media)
 {
        return (double) media->GetValue 
(MediaElement::VolumeProperty)->AsDouble ();
 }
@@ -400,8 +414,27 @@
 {
        /* MediaAttribute */
        MediaAttribute::ValueProperty = DependencyObject::Register 
(Value::MEDIAATTRIBUTE, "Value", new Value (""));
-
+       
+       /* MediaBase */
+       MediaBase::SourceProperty = DependencyObject::Register 
(Value::MEDIABASE, "Source", Value::STRING);
+       MediaBase::StretchProperty = DependencyObject::Register 
(Value::MEDIABASE, "Stretch", new Value (StretchNone));
+       
        /* Image */
-       Image::DownloadProgressProperty = DependencyObject::Register 
(Value::IMAGE, "DownloadProgress", new Value(0.0));
-
+       Image::DownloadProgressProperty = DependencyObject::Register 
(Value::IMAGE, "DownloadProgress", new Value (0.0));
+       
+       /* MediaElement */
+       MediaElement::AutoPlayProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "AutoPlay", new Value (true));
+       MediaElement::BalanceProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "Balance", new Value (0.0));
+       MediaElement::BufferingProgressProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "BufferingProgress", new Value (0.0));
+       MediaElement::BufferingTimeProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "BufferingTime", new Value (0));
+       MediaElement::CanSeekProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "CanSeek", new Value (false));
+       MediaElement::CurrentStateProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "CurrentState", Value::STRING);
+       MediaElement::DownloadProgressProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "DownloadProgress", new Value (0.0));
+       MediaElement::IsMutedProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "IsMuted", new Value (false));
+       MediaElement::MarkersProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "Markers", Value::TIMELINEMARKER_COLLECTION);
+       MediaElement::NaturalDurationProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "NaturalDuration", Value::DURATION);
+       MediaElement::NaturalVideoHeightProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "NaturalVideoHeight", Value::DOUBLE);
+       MediaElement::NaturalVideoWidthProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "NaturalVideoWidth", Value::DOUBLE);
+       MediaElement::PositionProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "Position", Value::DOUBLE);
+       MediaElement::VolumeProperty = DependencyObject::Register 
(Value::MEDIAELEMENT, "Volume", Value::DOUBLE);
 }

Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h      2007-06-14 17:13:01 UTC (rev 79573)
+++ trunk/moon/src/media.h      2007-06-14 17:18:51 UTC (rev 79574)
@@ -16,9 +16,10 @@
        MediaAttribute () { }
        virtual Value::Kind GetObjectType () { return Value::MEDIAATTRIBUTE; };
 };
-MediaAttribute* media_attribute_new ();
 
+MediaAttribute *media_attribute_new ();
 
+
 class MediaBase : public FrameworkElement {
 public:
        static DependencyProperty *SourceProperty;
@@ -37,15 +38,16 @@
 
 class Image : public MediaBase {
  public:
+       static DependencyProperty *DownloadProgressProperty;
+       
        Image ();
        virtual Value::Kind GetObjectType () { return Value::IMAGE; };
-
+       
        virtual void render (Surface *surface, int x, int y, int width, int 
height);
        virtual void getbounds ();
 
-       void SetSource (DependencyObject *Downloader, char* PartName);
-
-       static DependencyProperty *DownloadProgressProperty;
+       void SetSource (DependencyObject *Downloader, char *PartName);
+       
  private:
        void PixbufWrite (guchar *bug, gsize count);
        void LoaderSizePrepared (int width, int height);
@@ -83,12 +85,10 @@
        static DependencyProperty *PositionProperty;
        static DependencyProperty *VolumeProperty;
        
-       static DependencyProperty *AttributesProperty;
-       
        MediaElement () { }
        virtual Value::Kind GetObjectType () { return Value::MEDIAELEMENT; };
        
-       void SetSource (DependencyObject *downloader, char *name);
+       void SetSource (DependencyObject *Downloader, char *PartName);
        
        void Pause ();
        void Play ();

Modified: trunk/moon/src/text.cpp
===================================================================
--- trunk/moon/src/text.cpp     2007-06-14 17:13:01 UTC (rev 79573)
+++ trunk/moon/src/text.cpp     2007-06-14 17:18:51 UTC (rev 79574)
@@ -158,12 +158,21 @@
 Brush *
 inline_get_foreground (Inline *inline_)
 {
-       return (Brush *) inline_->GetValue 
(Inline::ForegroundProperty)->AsBrush ();
+       Value *value = inline_->GetValue (Inline::ForegroundProperty);
+       
+       return value ? (Brush *) value->AsBrush () : NULL;
 }
 
 void
 inline_set_foreground (Inline *inline_, Brush *value)
 {
+       Brush *fg = inline_get_foreground (inline_);
+       
+       if (fg != NULL)
+               base_unref (fg);
+       
+       base_ref (value);
+       
        inline_->SetValue (Inline::ForegroundProperty, Value (value));
 }
 
@@ -262,15 +271,16 @@
 {
        PangoFontDescription *font = NULL;
        PangoLayout *layout = NULL;
+       FontStretches stretch;
        char *family, *text;
-       FontStretches stretch;
        FontWeights weight;
+       Brush *foreground;
        FontStyles style;
        double size;
        
        cairo_set_matrix (s->cairo, &absolute_xform);
        
-       if ((text = textblock_get_text (this)) != NULL) {
+       if ((text = textblock_get_text (this))) {
                if (!layout)
                        layout = pango_cairo_create_layout (s->cairo);
                
@@ -297,6 +307,12 @@
                
                //pango_cairo_update_layout (cr, layout);
                pango_cairo_show_layout (s->cairo, layout);
+               
+               if ((foreground = textblock_get_foreground (this)))
+                       foreground->SetupBrush (s->cairo, this);
+               
+               if (render)
+                       cairo_fill (s->cairo);
        }
 }
 
@@ -395,12 +411,21 @@
 Brush *
 textblock_get_foreground (TextBlock *textblock)
 {
-       return (Brush *) textblock->GetValue 
(TextBlock::ForegroundProperty)->AsBrush ();
+       Value *value = textblock->GetValue (TextBlock::ForegroundProperty);
+       
+       return value ? (Brush *) value->AsBrush () : NULL;
 }
 
 void
 textblock_set_foreground (TextBlock *textblock, Brush *value)
 {
+       Brush *fg = textblock_get_foreground (textblock);
+       
+       if (fg != NULL)
+               base_unref (fg);
+       
+       base_ref (value);
+       
        textblock->SetValue (TextBlock::ForegroundProperty, Value (value));
 }
 

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

Reply via email to