Ejemplo n.º 1
0
        public void QueueRender (CanvasItem item, Rect rect)
        {
            if (host == null) {
                return;
            }

            host.QueueRender (item, rect);
        }
Ejemplo n.º 2
0
        public virtual void Allocate (Rect actualAllocation)
        {
            ActualAllocation = actualAllocation;

            InvalidateChildSize ();
            InvalidateChildCollection ();
            InvalidateVirtualSize ();
            InvalidateChildLayout ();
        }
Ejemplo n.º 3
0
        public void Render (CellContext context, Rect allocation, IPhoto photo)
        {
            string caption = GetCaptionString (photo);

            var text_color = context.Theme.Colors.GetWidgetColor (GtkColorClass.Text, context.State);

            var layout = context.Layout;
            layout.Ellipsize = Pango.EllipsizeMode.End;
            layout.Alignment = Pango.Alignment.Center;
            layout.Width = (int)(allocation.Width * Pango.Scale.PangoScale);

            layout.SetText (caption);

            context.Context.Color = text_color;
            context.Context.MoveTo (allocation.X, allocation.Y);
            PangoCairoHelper.ShowLayout (context.Context, layout);
        }
Ejemplo n.º 4
0
        public static void Gradient(Cairo.Context cr, Theme theme, Rect rect, double opacity)
        {
            cr.Save ();
            cr.Translate (rect.X, rect.Y);

            var x = rect.Width / 2.0;
            var y = rect.Height / 2.0;
            using (var grad = new Cairo.RadialGradient (x, y, 0, x, y, rect.Width / 2.0)) {
                grad.AddColorStop (0, new Cairo.Color (0, 0, 0, 0.1 * opacity));
                grad.AddColorStop (1, new Cairo.Color (0, 0, 0, 0.35 * opacity));
                cr.SetSource (grad);
                CairoExtensions.RoundedRectangle (cr, rect.X, rect.Y, rect.Width, rect.Height, theme.Context.Radius);
                cr.Fill ();
            }

            cr.Restore ();
        }
Ejemplo n.º 5
0
 public void Invalidate (Rect area)
 {
     InvalidateRender (area);
 }
Ejemplo n.º 6
0
        public override void Arrange ()
        {
            if (BoundObject == null) {
                valid = false;
                return;
            }

            IPhoto photo = BoundObject as IPhoto;

            if (photo == null)
                throw new InvalidCastException ("PhotoGridViewChild can only bind IPhoto objects");

            valid = true;

            inner_allocation = new Rect () {
                X = Padding.Left,
                Y = Padding.Top,
                Width = Allocation.Width - Padding.X,
                Height = Allocation.Height - Padding.Y
            };

            thumbnail_allocation = new Rect () {
                Width = ThumbnailWidth,
                Height = ThumbnailHeight,
                X = 0,
                Y = 0
            };

            caption_allocation.Y = thumbnail_allocation.Height + CaptionSpacing;
            caption_allocation.Width = inner_allocation.Width;
        }
Ejemplo n.º 7
0
Archivo: Rect.cs Proyecto: dufoli/hyena
 public bool IntersectsWith(Rect rect)
 {
     return !(Left > rect.Right ||
         Right < rect.Left ||
         Top > rect.Bottom ||
         Bottom < rect.Top);
 }
Ejemplo n.º 8
0
Archivo: Rect.cs Proyecto: dufoli/hyena
        public void Union(Rect rect)
        {
            if (IsEmpty) {
                x = rect.x;
                y = rect.y;
                h = rect.h;
                w = rect.w;
            } else if (!rect.IsEmpty) {
                double new_x = Math.Min (Left, rect.Left);
                double new_y = Math.Min (Top, rect.Top);
                double new_w = Math.Max (Right, rect.Right) - new_x;
                double new_h = Math.Max (Bottom, rect.Bottom) - new_y;

                x = new_x;
                y = new_y;
                w = new_w;
                h = new_h;
            }
        }
Ejemplo n.º 9
0
        public void QueueRender(CanvasItem item, Rect rect)
        {
            double x = Allocation.X;
            double y = Allocation.Y;
            double w, h;

            if (rect.IsEmpty) {
                w = item.Allocation.Width;
                h = item.Allocation.Height;
            } else {
                x += rect.X;
                y += rect.Y;
                w = rect.Width;
                h = rect.Height;
            }

            while (item != null) {
                x += item.ContentAllocation.X;
                y += item.ContentAllocation.Y;
                item = item.Parent;
            }

            QueueDrawArea (
                (int)Math.Floor (x),
                (int)Math.Floor (y),
                (int)Math.Ceiling (w),
                (int)Math.Ceiling (h)
            );
        }
Ejemplo n.º 10
0
Archivo: Rect.cs Proyecto: dufoli/hyena
 public bool Equals(Rect value)
 {
     return this == value;
 }
 protected virtual void RenderImageSurface (CellContext context, Rect allocation, ImageSurface imageSurface)
 {
     ArtworkRenderer.RenderThumbnail (context.Context,
         imageSurface, false,
         allocation.X, allocation.Y, allocation.Width, allocation.Height,
         true, context.Theme.Context.Radius,
         imageSurface == null, new Color (0.8, 0.8, 0.8));
 }
        public override void Arrange ()
        {
            if (!HandleBoundObject (out image_surface, out lines)) {
                return;
            }

            inner_allocation = new Rect () {
                X = Padding.Left,
                Y = Padding.Top,
                Width = Allocation.Width - Padding.X,
                Height = Allocation.Height - Padding.Y
            };

            double width = ImageSize;
            double height = ImageSize;

            if (image_surface != null) {
                width = image_surface.Width;
                height = image_surface.Height;
            }

            image_allocation = new Rect () {
                Width = Math.Min (inner_allocation.Width, width),
                Height = Math.Min (inner_allocation.Height, height)
            };

            if (IsGridLayout) {
                image_allocation.X = Math.Round ((inner_allocation.Width - width) / 2.0);
            } else {
                image_allocation.Y = Math.Round ((inner_allocation.Height - height) / 2.0);
            }

            double allocated_image_size = Math.Max (image_allocation.Height, image_allocation.Width);
            if (IsGridLayout) {
                first_line_allocation.Y = allocated_image_size + ImageSpacing;
                first_line_allocation.Width = second_line_allocation.Width = inner_allocation.Width;
            } else {
                first_line_allocation.X = second_line_allocation.X = allocated_image_size + ImageSpacing;
                first_line_allocation.Width = second_line_allocation.Width =
                    inner_allocation.Width - allocated_image_size - ImageSpacing;
            }

            second_line_allocation.Y = first_line_allocation.Bottom + TextSpacing;
        }
Ejemplo n.º 13
0
 protected void InvalidateRender (Rect area)
 {
     if (Parent == null) {
         OnInvalidate (area);
     } else {
         var alloc = Parent.ContentAllocation;
         area.Offset (alloc.X, alloc.Y);
         Parent.Invalidate (area);
     }
 }
Ejemplo n.º 14
0
 protected Rect GetChildVirtualAllocation (Rect childAllocation)
 {
     return new Rect () {
         X = childAllocation.X - ActualAllocation.X,
         Y = childAllocation.Y - ActualAllocation.Y,
         Width = childAllocation.Width,
         Height = childAllocation.Height
     };
 }
Ejemplo n.º 15
0
        private void Invalidate()
        {
            double current_value = (IsValueUpdatePending ? PendingValue : Value);

            // FIXME: Something is wrong with the updating below causing an
            // invalid region when IsValueUpdatePending is true, so when
            // that is the case for now, we trigger a full invalidation
            if (last_invalidate_value < 0 || IsValueUpdatePending) {
                last_invalidate_value = current_value;
                InvalidateRender ();
                return;
            }

            double max = Math.Max (last_invalidate_value, current_value) * RenderSize.Width;
            double min = Math.Min (last_invalidate_value, current_value) * RenderSize.Width;

            Rect region = new Rect (
                InvalidationRect.X + min,
                InvalidationRect.Y,
                (max - min) + 2 * ThrobberSize,
                InvalidationRect.Height
            );

            last_invalidate_value = current_value;
            InvalidateRender (region);
        }
Ejemplo n.º 16
0
        public override bool GetTooltipMarkupAt (Point pt, out string markup, out Rect area)
        {
            if (base.GetTooltipMarkupAt (pt, out markup, out area)) {
                return true;
            }

            pt = ChildCoord (this, pt);
            CanvasItem child = FindChildAt (pt, false);
            return child == null ? false : child.GetTooltipMarkupAt (ChildCoord (child, pt), out markup, out area);
        }
Ejemplo n.º 17
0
        public override void Arrange()
        {
            if (!EnsureLayout ()) {
                return;
            }

            int layout_width = TextWrap == TextWrap.None
                ? -1
                : (int)(Pango.Scale.PangoScale * ContentAllocation.Width);
            if (layout.Width != layout_width) {
                layout.Width = layout_width;
            }

            int text_width, text_height;
            layout.GetPixelSize (out text_width, out text_height);

            Rect new_alloc = new Rect (
                Math.Round ((RenderSize.Width - text_width) * HorizontalAlignment),
                Math.Round ((RenderSize.Height - text_height) * VerticalAlignment),
                text_width,
                text_height);

            if (text_alloc.IsEmpty) {
                InvalidateRender (text_alloc);
            } else {
                invalidation_rect = text_alloc;
                invalidation_rect.Union (new_alloc);

                // Some padding, likely because of the pen size for
                // showing the actual text layout in the render pass
                invalidation_rect.X -= 2;
                invalidation_rect.Y -= 2;
                invalidation_rect.Width += 4;
                invalidation_rect.Height += 4;

                InvalidateRender (invalidation_rect);
            }

            text_alloc = new_alloc;
        }
Ejemplo n.º 18
0
        public void Union(Rect rect)
        {
            double new_x = Math.Min (x, rect.x);
            double new_y = Math.Min (y, rect.y);
            double new_w = Math.Max (Right, rect.Right) - x;
            double new_h = Math.Max (Bottom, rect.Bottom) - y;

            x = new_x;
            y = new_y;
            w = new_w;
            h = new_h;
        }
Ejemplo n.º 19
0
 public void QueueDirtyRegion (Rect region)
 {
     QueueDirtyRegion ((Gdk.Rectangle)region);
 }
Ejemplo n.º 20
0
        public override void Arrange()
        {
            if (!EnsureLayout ()) {
                return;
            }

            UpdateLayout (GetText (), RenderSize.Width, RenderSize.Height, true);

            int text_width, text_height;

            layout.GetPixelSize (out text_width, out text_height);

            Rect new_alloc = new Rect (
                Math.Round ((RenderSize.Width - text_width) * HorizontalAlignment),
                Math.Round ((RenderSize.Height - text_height) * VerticalAlignment),
                text_width,
                text_height);

            if (text_alloc.IsEmpty) {
                InvalidateRender (text_alloc);
            } else {
                invalidation_rect = text_alloc;
                invalidation_rect.Union (new_alloc);

                // Some padding, likely because of the pen size for
                // showing the actual text layout in the render pass
                invalidation_rect.X -= 2;
                invalidation_rect.Y -= 2;
                invalidation_rect.Width += 4;
                invalidation_rect.Height += 4;

                InvalidateRender (invalidation_rect);
            }

            text_alloc = new_alloc;
        }
Ejemplo n.º 21
0
 public void QueueRender (Hyena.Gui.Canvas.CanvasItem item, Rect rect)
 {
     QueueDirtyRegion (rect);
 }
Ejemplo n.º 22
0
        protected override void InvalidateChildLayout (bool arrange)
        {
            base.InvalidateChildLayout (arrange);

            if (ChildSize.Width <= 0 || ChildSize.Height <= 0) {
                // FIXME: empty/reset all child slots here?
                return;
            }

            // Compute where we should start and end in the model
            double offset = ActualAllocation.Y - YPosition % ChildSize.Height;
            int first_model_row = (int)Math.Floor (YPosition / ChildSize.Height) * Columns;
            int last_model_row = first_model_row + Rows * Columns;

            // Setup for the layout iteration
            int child_span_width = (int)Math.Floor (ActualAllocation.Width / Columns);
            int layout_child_index = 0;
            int view_row_index = 0;
            int view_column_index = 0;

            int flex_width = Fill ? 0 : (int)Math.Floor (Math.Max (0, child_span_width - ChildSize.Width) / (Columns + 1));

            // Allocation of the first child in the layout, this
            // will change as we iterate the layout children
            var child_allocation = new Rect () {
                X = ActualAllocation.X + flex_width,
                Y = offset,
                Width = Fill ? child_span_width : ChildSize.Width,
                Height = ChildSize.Height
            };

            // Iterate the layout children and configure them for the current
            // view state to be consumed by interaction and rendering phases
            for (int i = first_model_row; i < last_model_row; i++, layout_child_index++) {
                var child = Children[layout_child_index];
                child.Allocation = child_allocation;
                child.VirtualAllocation = GetChildVirtualAllocation (child_allocation);

                SetModelIndex (child, i);
                if (Model != null) {
                    child.Bind (Model.GetItem (i));
                }

                if (arrange) {
                    child.Arrange ();
                }

                // Update the allocation for the next child
                if (++view_column_index % Columns == 0) {
                    view_row_index++;
                    view_column_index = 0;

                    child_allocation.Y += ChildSize.Height;
                    child_allocation.X = ActualAllocation.X + flex_width;
                } else {
                    child_allocation.X += child_span_width;
                }

                // FIXME: clear any layout children that go beyond the model
            }
        }
Ejemplo n.º 23
0
 public virtual bool GetTooltipMarkupAt (Point pt, out string markup, out Rect area)
 {
     markup = TooltipMarkup;
     area = TopLevelAllocation;
     return markup != null;
 }
Ejemplo n.º 24
0
Archivo: Rect.cs Proyecto: dufoli/hyena
        public void Intersect(Rect rect)
        {
            if (IsEmpty || rect.IsEmpty) {
                this = Rect.Empty;
                return;
            }

            double new_x = Math.Max (x, rect.x);
            double new_y = Math.Max (y, rect.y);
            double new_w = Math.Min (Right, rect.Right) - new_x;
            double new_h = Math.Min (Bottom, rect.Bottom) - new_y;

            x = new_x;
            y = new_y;
            w = new_w;
            h = new_h;

            if (w < 0 || h < 0) {
                this = Rect.Empty;
            }
        }
Ejemplo n.º 25
0
 public void Invalidate (Rect area)
 {
     area.Offset (Allocation.X, Allocation.Y);
     OnInvalidate (area);
 }
Ejemplo n.º 26
0
Archivo: Rect.cs Proyecto: dufoli/hyena
 public void Offset(Rect rect)
 {
     x += rect.X;
     y += rect.Y;
 }
Ejemplo n.º 27
0
 protected override void OnInvalidate (Rect area)
 {
     ParentLayout.View.QueueDirtyRegion (area);
 }
Ejemplo n.º 28
0
 protected virtual void OnInvalidate (Rect area)
 {
 }
Ejemplo n.º 29
0
 private void OnInvalidate (Rect area)
 {
     CanvasItem root = RootAncestor;
     if (root != null && root.Manager != null) {
         root.Manager.QueueRender (this, area);
     } else {
         Hyena.Log.WarningFormat ("Asked to invalidate {0} for {1} but no CanvasManager!", area, this);
     }
 }