Esempio n. 1
0
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea, Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            CellState state = (CellState)flags;

            using (IContext context = new CairoContext(window)) {
                Area bkg = new Area(new Point(backgroundArea.X, backgroundArea.Y),
                                    backgroundArea.Width, backgroundArea.Height);
                Area cell = new Area(new Point(cellArea.X, cellArea.Y),
                                     cellArea.Width, cellArea.Height);

                //Get the offset to properly calulate if needs tooltip or redraw
                offsetX = bkg.Right - cell.Right;
                offsetY = cell.Top - bkg.Top;

                if (ViewModel is EventTypeTimelineVM)
                {
                    var vm = (EventTypeTimelineVM)ViewModel;
                    RenderType(vm.EventTypeVM.Name, vm.VisibleChildrenCount, vm.EventTypeVM.Color, App.Current.DrawingToolkit, context, bkg, cell, state);
                    RenderPlayButton(App.Current.DrawingToolkit, cell, vm.VisibleChildrenCount == 0, state);
                }
                else if (ViewModel is PlaylistVM)
                {
                    var vm = (PlaylistVM)ViewModel;
                    RenderType(vm.Name, vm.Count(), App.Current.Style.TextBase, App.Current.DrawingToolkit, context, bkg, cell, state);
                    RenderSelection(App.Current.DrawingToolkit, context, bkg, cell, state, false);
                }
                else if (ViewModel is PlaylistImageVM || ViewModel is PlaylistVideoVM)
                {
                    RenderPlaylistElement((PlaylistElementVM)ViewModel, App.Current.DrawingToolkit, context, bkg, cell, state);
                }
            }
        }
Esempio n. 2
0
        protected override void Render(Gdk.Drawable window, Widget widget, Gdk.Rectangle backgroundArea,
                                       Gdk.Rectangle cellArea, Gdk.Rectangle exposeArea, CellRendererState flags)
        {
            IDrawingToolkit tk = App.Current.DrawingToolkit;

            using (IContext context = new CairoContext(window)) {
                cellWidth  = cellArea.Width;
                cellHeight = cellArea.Height;

                Point pos = new Point(cellArea.X + backgroundArea.Width / 2 - BUTTON_WIDTH / 2,
                                      cellArea.Y + Sizes.FilterTreeViewOnlyTopOffset);

                Point imagePos = new Point(pos.X + SPACING, pos.Y + Sizes.FilterTreeViewOnlyTopOffset);

                //Get the offset to properly calculate if needs tooltip or redraw
                offsetX = pos.X - backgroundArea.X;
                offsetY = pos.Y - backgroundArea.Y;

                tk.Context = context;
                tk.Begin();
                tk.StrokeColor = App.Current.Style.ThemeBase;
                tk.FillColor   = Color.Transparent;
                if (flags.HasFlag(CellRendererState.Prelit) && cursor.IsInsideArea(pos, BUTTON_WIDTH, BUTTON_HEIGHT))
                {
                    tk.StrokeColor = App.Current.Style.ColorPrimary;
                    tk.LineWidth   = LINE_WIDTH;
                }

                tk.DrawRectangle(pos, BUTTON_WIDTH, BUTTON_HEIGHT);
                tk.DrawImage(imagePos, BUTTON_WIDTH - (SPACING * 2), BUTTON_HEIGHT - (Sizes.FilterTreeViewOnlyTopOffset * 2), Icon, ScaleMode.AspectFit);
                tk.End();
                tk.Context = null;
            }
        }
Esempio n. 3
0
        protected override void Render(Drawable window, Widget widget, Rectangle background_area,
                                       Rectangle cell_area, Rectangle expose_area, CellRendererState flags)
        {
            var tk = App.Current.DrawingToolkit;

            using (IContext context = new CairoContext(window)) {
                tk.Context = context;

                if (viewModel != null)
                {
                    var fixedCanvas = view as FixedSizeCanvasObject;
                    if (fixedCanvas != null)
                    {
                        fixedCanvas.Width    = background_area.Width;
                        fixedCanvas.Height   = background_area.Height;
                        fixedCanvas.Position = new Point(background_area.X, background_area.Y);
                        fixedCanvas?.Draw(tk, new Area(new Point(background_area.X, background_area.Y), background_area.Width, background_area.Height));
                    }
                    else
                    {
                        view?.Draw(tk, new Area(new Point(background_area.X, background_area.Y), background_area.Width, background_area.Height));
                    }
                }

                tk.Context = null;
            }
        }
Esempio n. 4
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            if (image != null)
            {
                var alloc = Allocation;
                alloc.Inflate(-Xpad, -Ypad);
                using (var ctx = CairoHelper.Create(evnt.Window)) {
                    // FIXME: Use the ImageView canvas
                    var context = new CairoContext(ctx);
                    var width   = WidthRequest > 0 ? WidthRequest : image.Width;
                    var height  = HeightRequest > 0 ? HeightRequest : image.Height;
                    var point   = new Point(alloc.X, alloc.Y);

                    // If the image is smaller than the allocated size, center it without scalling it
                    if (alloc.Width > width && alloc.Height > height)
                    {
                        point.X += (alloc.Width - width) / 2;
                        point.Y += (alloc.Height - height) / 2;
                    }
                    // Otherwise use the whole allocated space and let DrawImage scale correctly to keep DAR
                    else
                    {
                        width  = alloc.Width;
                        height = alloc.Height;
                    }

                    App.Current.DrawingToolkit.Context = context;

                    Point  center = new Point(point.X + width / 2, point.Y + height / 2);
                    double radius = Math.Min(height, width) / 2;

                    // Apply shadow
                    if (HasShadow)
                    {
                        App.Current.DrawingToolkit.FillColor = ShadowColor;
                        App.Current.DrawingToolkit.LineWidth = 0;
                        App.Current.DrawingToolkit.DrawCircle(new Point(center.X + 1, center.Y + 1), radius);
                    }

                    // Give shape to the image
                    if (Circular)
                    {
                        App.Current.DrawingToolkit.ClipCircle(center, radius);
                    }

                    // Draw image
                    var alpha = IsParentUnsensitive ? 0.4f : 1f;
                    App.Current.DrawingToolkit.FillColor = MaskColor;
                    App.Current.DrawingToolkit.DrawImage(point, width, height, image,
                                                         ScaleMode.AspectFit, MaskColor != null, alpha);
                }
            }
            return(true);
        }
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea,
                                       Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            CellState state = (CellState)flags;

            using (IContext context = new CairoContext(window)) {
                Area bkg = new Area(new Point(backgroundArea.X, backgroundArea.Y),
                                    backgroundArea.Width, backgroundArea.Height);
                Area cell = new Area(new Point(cellArea.X, cellArea.Y),
                                     cellArea.Width, cellArea.Height);
                PlayslistCellRenderer.Render(Item, Project, Count, IsExpanded, App.Current.DrawingToolkit,
                                             context, bkg, cell, state);
            }
        }
Esempio n. 6
0
    public static void DrawEllipse(CairoContext cts, PointD start, PointD end)
    {
        double width = Math.Abs(start.X - end.X);
        double height = Math.Abs(start.Y - end.Y);
        double xcenter = start.X + (end.X - start.X) / 2.0;
        double ycenter = start.Y + (end.Y - start.Y) / 2.0;

        ctx.Save();
        ctx.Translate(xcenter, ycenter);
        cts.Scale(width/2.0, height/2.0);
        cts.Arc(0.0, 0.0, 1.0, 0.0, 2*Math.PI);
        cts.Restore();
        ctx.Stroke();
    }
Esempio n. 7
0
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea,
		                                Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            CellState state = (CellState)flags;

            using (IContext context = new CairoContext (window)) {
                Area bkg = new Area (new Point (backgroundArea.X, backgroundArea.Y),
                               backgroundArea.Width, backgroundArea.Height);
                Area cell = new Area (new Point (cellArea.X, cellArea.Y),
                                cellArea.Width, cellArea.Height);
                PlayslistCellRenderer.Render (Item, Project, Count, IsExpanded, App.Current.DrawingToolkit,
                    context, bkg, cell, state);
            }
        }
Esempio n. 8
0
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea,
                                       Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            IDrawingToolkit tk = App.Current.DrawingToolkit;

            imageView.Image     = Image;
            imageView.MaskColor = MaskColor;
            imageView.SetWidget(new NoWindowWidget {
                Width = cellArea.Width, Height = cellArea.Height
            });

            using (IContext context = new CairoContext(window)) {
                tk.Context = context;
                tk.TranslateAndScale(new Point(cellArea.X, cellArea.Y), new Point(1, 1));
                imageView.Draw(context, null);
            }
        }
Esempio n. 9
0
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea, Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            tk = App.Current.DrawingToolkit;
            this.backgroundArea = backgroundArea;
            this.cellArea       = cellArea;
            this.flags          = flags;

            using (IContext context = new CairoContext(window)) {
                tk.Context = context;
                tk.Begin();
                remainingWidth = cellArea.Width;
                pos            = new Point(cellArea.X, cellArea.Y);
                DrawTeamShield(homeShield);
                DrawTeamShield(awayShield);
                DrawDescription();
                tk.End();
                tk.Context = null;
            }
        }
Esempio n. 10
0
        protected override void Render(Drawable window, Widget widget, Rectangle backgroundArea,
                                       Rectangle cellArea, Rectangle exposeArea, CellRendererState flags)
        {
            IDrawingToolkit tk = App.Current.DrawingToolkit;

            using (IContext context = new CairoContext(window)) {
                int   width  = cellArea.Width - Sizes.FilterTreeViewOnlyRightOffset;
                int   height = cellArea.Height - Sizes.FilterTreeViewOnlyTopOffset * 2;
                Point pos    = new Point(cellArea.X + backgroundArea.Width - cellArea.Width,
                                         cellArea.Y + Sizes.FilterTreeViewOnlyTopOffset);
                tk.Context = context;
                tk.Begin();
                tk.FontSize    = 12;
                tk.FillColor   = null;
                tk.LineWidth   = 1;
                tk.StrokeColor = App.Current.Style.ThemeBase;
                tk.DrawRoundedRectangle(pos, width, height, 3);
                tk.StrokeColor   = App.Current.Style.TextBase;
                tk.FontAlignment = FontAlignment.Center;
                tk.DrawText(pos, width, height, Text);
                tk.End();
                tk.Context = null;
            }
        }