コード例 #1
0
        void OnMainViewportVideoDragStoppedEvent(object o, ButtonReleaseEventArgs args)
        {
            if (ViewModel.Zoom == 1)
            {
                return;
            }
            if (dragTimerID != 0)
            {
                GLib.Source.Remove(dragTimerID);
                dragTimerID = 0;
            }

            mainviewport.VideoDragged -= OnMainViewportVideoDraggedEvent;
            moveStart = null;

            ChangeCursor(null);

            // If we actually dragged the ROI we don't want the default button release handler
            // to be called as this would toggle play pause. On the other hand if the ROI was
            // unchanged, the user expects the normal behaviour of play/pause when clicking the video.
            if (roiMoved == true)
            {
                args.RetVal = true;
            }
            if (wasPlaying == true)
            {
                playerVM.PlayCommand.Execute();
            }
        }
コード例 #2
0
        protected void RenderSelection(IDrawingToolkit tk, IContext context,
                                       Area backgroundArea, Area cellArea, CellState state, bool isChildElement)
        {
            int   selectionLineWidth = 1;
            Point pos = new Point(backgroundArea.Left, backgroundArea.Start.Y + selectionLineWidth);

            if (isChildElement)
            {
                pos.X += LEFT_OFFSET + COLOR_RECTANGLE_WIDTH;
            }
            double width  = backgroundArea.Width - pos.X;
            double height = backgroundArea.Height - selectionLineWidth;

            tk.Context = context;
            tk.Begin();
            tk.FillColor   = Color.Transparent;
            tk.StrokeColor = Color.Transparent;
            if (state.HasFlag(CellState.Selected))
            {
                tk.StrokeColor = App.Current.Style.ColorPrimary;
            }
            tk.LineWidth = selectionLineWidth;
            tk.DrawRectangle(pos, width, height);
            tk.StrokeColor = App.Current.Style.TextBase;
        }
コード例 #3
0
        public void DrawTriangle(Point corner, double width, double height,
                                 SelectionPosition position)
        {
            double x1, y1, x2, y2, x3, y3;

            x1 = corner.X;
            y1 = corner.Y;

            switch (position)
            {
            case SelectionPosition.Top:
                x2 = x1 + width / 2;
                y2 = y1 + height;
                x3 = x1 - width / 2;
                y3 = y1 + height;
                break;

            case SelectionPosition.Bottom:
            default:
                x2 = x1 + width / 2;
                y2 = y1 - height;
                x3 = x1 - width / 2;
                y3 = y1 - height;
                break;
            }

            SetColor(StrokeColor);
            CContext.MoveTo(x1, y1);
            CContext.LineTo(x2, y2);
            CContext.LineTo(x3, y3);
            CContext.ClosePath();
            StrokeAndFill();
        }
コード例 #4
0
 public void DrawLine(Point start, Point stop)
 {
     CContext.LineWidth = LineWidth;
     CContext.MoveTo(start.X, start.Y);
     CContext.LineTo(stop.X, stop.Y);
     StrokeAndFill();
 }
コード例 #5
0
        /// <summary>
        /// Returns the Area that should redraw based on X, Y positions
        /// </summary>
        /// <returns>The area to be redrawn, or null otherwise</returns>
        /// <param name="cellX">Cell x.</param>
        /// <param name="cellY">Cell y.</param>
        /// <param name="TotalY">Total y.</param>
        /// <param name="width">Width.</param>
        /// <param name="viewModel">View model.</param>
        public static Area ShouldRedraw(double cellX, double cellY, double TotalY, int width, IViewModel viewModel)
        {
            Point drawingImagePoint = null;

            cursor.X = cellX;
            cursor.Y = TotalY;
            double startY = VERTICAL_OFFSET + offsetY;
            double startX = width - offsetX - RIGTH_OFFSET - App.Current.Style.ButtonNormalWidth;
            double margin = cellY - startY;

            //Just to know if its inside PlayButton
            if (cellY > startY && cellY < startY + App.Current.Style.ButtonNormalHeight &&
                cellX > startX && cellX < startX + App.Current.Style.ButtonNormalWidth)
            {
                drawingImagePoint    = new Point(startX, TotalY - margin);
                playButtonPrelighted = true;
            }
            else if (playButtonPrelighted)
            {
                playButtonPrelighted = false;
                drawingImagePoint    = new Point(startX, TotalY - margin);
            }
            if (drawingImagePoint == null)
            {
                return(null);
            }
            return(new Area(drawingImagePoint, App.Current.Style.ButtonNormalWidth, App.Current.Style.ButtonNormalHeight));
        }
コード例 #6
0
        public void DrawImage(Point start, double width, double height, Image image, ScaleMode mode,
                              bool masked = false, float alpha = 1)
        {
            double scaleX, scaleY;
            Point  offset;

            BaseImage <Pixbuf> .ScaleFactor((int)(image.Width *image.DeviceScaleFactor),
                                            (int)(image.Height *image.DeviceScaleFactor),
                                            (int)width, (int)height, mode, out scaleX, out scaleY, out offset);

            CContext.Save();
            CContext.Translate(start.X + offset.X, start.Y + offset.Y);
            CContext.Scale(scaleX, scaleY);
            if (masked)
            {
                CContext.PushGroup();
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.PaintWithAlpha(alpha);
                var src = CContext.PopGroup();
                SetColor(FillColor);
                CContext.Mask(src);
                src.Dispose();
            }
            else
            {
                Gdk.CairoHelper.SetSourcePixbuf(CContext, image.Value, 0, 0);
                CContext.PaintWithAlpha(alpha);
            }
            CContext.Restore();
        }
コード例 #7
0
        public void DrawRoundedRectangle(Point start, double width, double height, double radius, bool strokeAndFill)
        {
            double x, y;

            x       = start.X + LineWidth / 2;
            y       = start.Y + LineWidth / 2;
            height -= LineWidth;
            width  -= LineWidth;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            if (strokeAndFill)
            {
                StrokeAndFill();
            }
        }
コード例 #8
0
        public void DrawSurface(Point start, double width, double height, ISurface surface, ScaleMode mode, bool masked = false)
        {
            //FIXME: This still needs support for masked surfaces
            double scaleX, scaleY;
            Point  offset;

            BaseImage <Pixbuf> .ScaleFactor((int)(surface.Width *surface.DeviceScaleFactor),
                                            (int)(surface.Height *surface.DeviceScaleFactor),
                                            (int)width, (int)height, mode, out scaleX, out scaleY, out offset);

            CContext.Save();
            CContext.Translate(offset.X + start.X, offset.Y + start.Y);
            CContext.Scale(scaleX, scaleY);
            if (masked)
            {
                CContext.PushGroup();
            }
            ImageSurface image = surface.Value as ImageSurface;

            CContext.SetSourceSurface(image, 0, 0);
            CContext.Rectangle(0, 0, image.Width, image.Height);
            CContext.Fill();
            if (masked)
            {
                var src = CContext.PopGroup();
                SetColor(FillColor);
                CContext.Mask(src);
                src.Dispose();
            }
            CContext.Restore();
        }
コード例 #9
0
 protected void RenderImage(IDrawingToolkit tk, Point p, VAS.Core.Common.Image image,
                            double width, double height)
 {
     if (image != null)
     {
         tk.DrawImage(p, width, height, image, ScaleMode.AspectFit);
     }
 }
コード例 #10
0
 public void DrawRectangle(Point start, double width, double height)
 {
     CContext.Rectangle(new global::Cairo.Rectangle(start.X + LineWidth / 2,
                                                    start.Y + LineWidth / 2,
                                                    width - LineWidth,
                                                    height - LineWidth));
     StrokeAndFill(false);
 }
コード例 #11
0
 public void DrawSurface(ISurface surface, Point p = null, bool masked = false)
 {
     if (p == null)
     {
         p = new Point(0, 0);
     }
     DrawSurface(p, surface.Width, surface.Height, surface, ScaleMode.AspectFit, masked);
 }
コード例 #12
0
 protected void RenderChildText(IDrawingToolkit tk, Point p, int width, int height, string text, Color textColor)
 {
     tk.StrokeColor   = textColor;
     tk.FontSize      = 12;
     tk.FontWeight    = FontWeight.Normal;
     tk.FontAlignment = FontAlignment.Left;
     tk.DrawText(p, width, height, text, false, true);
 }
コード例 #13
0
        protected void RenderColorStrip(IDrawingToolkit tk, Area backgroundArea, Color color)
        {
            Point p = new Point(backgroundArea.Left + LEFT_OFFSET, backgroundArea.Start.Y);

            //Draw Color strip
            tk.FillColor   = color;
            tk.StrokeColor = color;
            tk.DrawRectangle(p, COLOR_RECTANGLE_WIDTH, backgroundArea.Height);
        }
コード例 #14
0
 protected void RenderChildLongText(IDrawingToolkit tk, Area backgroundArea, Point textP, double textW, string text, Color textColor)
 {
     /* Text */
     tk.StrokeColor   = textColor;
     tk.FontSize      = 11;
     tk.FontWeight    = FontWeight.Light;
     tk.FontAlignment = FontAlignment.Left;
     tk.DrawText(textP, textW, backgroundArea.Height, text, false, true);
 }
コード例 #15
0
 public void DrawCircleImage(Point center, double radius, Image image)
 {
     DrawCircle(center, radius);
     CContext.Save();
     CContext.Arc(center.X, center.Y, radius, 0, 2 * Math.PI);
     CContext.Clip();
     DrawImage(new Point(center.X - radius, center.Y - radius), radius * 2, radius * 2, image,
               ScaleMode.AspectFill, false);
     CContext.Restore();
 }
コード例 #16
0
        protected void RenderEye(IDrawingToolkit tk, Area backgroundArea, Area cellArea, bool Playing)
        {
            Point p = new Point(backgroundArea.Right - RIGTH_OFFSET - EYE_IMAGE_WIDTH,
                                cellArea.Start.Y + VERTICAL_OFFSET + LOCATION_IMAGE_HEIGHT);

            if (Playing)
            {
                tk.DrawSurface(p, EYE_IMAGE_WIDTH, EYE_IMAGE_HEIGHT, Eye, ScaleMode.AspectFit);
            }
        }
コード例 #17
0
 protected void RenderPrelit(bool selected, IDrawingToolkit tk, IContext context,
                             Area backgroundArea, Area cellArea, CellState state)
 {
     if (!state.HasFlag(CellState.Prelit) && !(selected || state.HasFlag(CellState.Selected)))
     {
         Point pos = new Point(backgroundArea.Start.X + LEFT_OFFSET + COLOR_RECTANGLE_WIDTH, backgroundArea.Start.Y);
         tk.FillColor   = Color.BlackTransparent;
         tk.StrokeColor = Color.Transparent;
         tk.DrawRectangle(pos, backgroundArea.Width, backgroundArea.Height);
     }
 }
コード例 #18
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);
        }
コード例 #19
0
        public void DrawEllipse(Point center, double axisX, double axisY)
        {
            double max = Math.Max(axisX, axisY);

            CContext.Save();
            CContext.Translate(center.X, center.Y);
            CContext.Scale(axisX / max, axisY / max);
            CContext.Arc(0, 0, max, 0, 2 * Math.PI);
            StrokeAndFill();
            CContext.Restore();
        }
コード例 #20
0
        void RenderType(string name, int childsCount, Color color, IDrawingToolkit tk, IContext context,
                        Area backgroundArea, Area cellArea, CellState state)
        {
            Point textP = new Point(Sizes.ListTextOffset, backgroundArea.Start.Y);

            tk.Context = context;
            tk.Begin();
            RenderBackgroundAndTitleText(tk, backgroundArea, textP, cellArea.Width - textP.X, name, App.Current.Style.ScreenBase, color);
            RenderCount(childsCount, tk, backgroundArea, cellArea);
            RenderSeparationLine(tk, context, backgroundArea);
            tk.End();
        }
コード例 #21
0
        void RenderBackgroundAndTitleText(IDrawingToolkit tk, Area backgroundArea, Point textP, double textW, string text, Color backgroundColor, Color textColor)
        {
            /* Background */
            RenderBackground(tk, backgroundArea, backgroundColor);

            /* Text */
            tk.StrokeColor   = textColor;
            tk.FontSize      = Sizes.ListTextFontSize;
            tk.FontWeight    = FontWeight.Bold;
            tk.FontAlignment = FontAlignment.Left;
            tk.DrawText(textP, textW, backgroundArea.Height, text, false, true);
        }
コード例 #22
0
        public void DrawText(Point point, double width, double height, string text,
                             bool escape = false, bool ellipsize = false)
        {
            Layout layout = null;

            Pango.Rectangle inkRect, logRect;

            if (text == null)
            {
                return;
            }

            if (escape)
            {
                text = GLib.Markup.EscapeText(text);
            }

            if (context is CairoContext)
            {
                layout = (context as CairoContext).PangoLayout;
            }
            if (layout == null)
            {
                layout = Pango.CairoHelper.CreateLayout(CContext);
            }
            if (ellipsize)
            {
                layout.Ellipsize = EllipsizeMode.End;
            }
            else
            {
                layout.Ellipsize = EllipsizeMode.None;
            }

            layout.FontDescription = FontDescription.FromString(
                String.Format("{0} {1}px", FontFamily, FontSize));
            layout.FontDescription.Weight = fWeight;
            layout.FontDescription.Style  = fSlant;
            layout.Width = Units.FromPixels((int)width);
            layout.SetPangoLayoutHeight(Units.FromPixels((int)height));
            layout.Alignment = fAlignment;
            layout.SetMarkup(text);
            SetColor(StrokeColor);
            Pango.CairoHelper.UpdateLayout(CContext, layout);
            layout.GetPixelExtents(out inkRect, out logRect);
            CContext.MoveTo(point.X, point.Y + height / 2 - (double)logRect.Height / 2);
            Pango.CairoHelper.ShowLayout(CContext, layout);
            CContext.NewPath();
        }
コード例 #23
0
        void OnMainViewportVideoDraggedEvent(object o, MotionNotifyEventArgs args)
        {
            if (roiMoved == false)
            {
                ChangeCursor("hand_closed");
                wasPlaying = playerVM.Playing;
                playerVM.PauseCommand.Execute(false);
            }
            Point newStart = new Point(args.Event.X, args.Event.Y);
            Point diff     = newStart - moveStart;

            moveStart = newStart;
            playerVM.MoveROI(diff);
            roiMoved = true;
        }
コード例 #24
0
        void OnMainViewportVideoDragStartedEvent(object o, ButtonPressEventArgs args)
        {
            if (ViewModel.Zoom == 1)
            {
                return;
            }
            dragTimerID = GLib.Timeout.Add(200, delegate {
                mainviewport.VideoDragged += OnMainViewportVideoDraggedEvent;
                return(false);
            });

            moveStart  = new Point(args.Event.X, args.Event.Y);
            roiMoved   = false;
            wasPlaying = false;
        }
コード例 #25
0
        protected void RenderDrawingsIcon(IDrawingToolkit tk, Area backgroundArea, Area cellArea, bool HasDrawings)
        {
            Point p = new Point(backgroundArea.Right - RIGTH_OFFSET - DRAWINGS_IMAGE_WIDTH, cellArea.Start.Y + VERTICAL_OFFSET);

            if (HasDrawings)
            {
                if (cursor.IsInsideArea(p, DRAWINGS_IMAGE_WIDTH, DRAWINGS_IMAGE_HEIGHT))
                {
                    tk.DrawSurface(p, DRAWINGS_IMAGE_WIDTH, DRAWINGS_IMAGE_HEIGHT, PrelightDrawings, ScaleMode.AspectFit);
                }
                else
                {
                    tk.DrawSurface(p, DRAWINGS_IMAGE_WIDTH, DRAWINGS_IMAGE_HEIGHT, Drawings, ScaleMode.AspectFit);
                }
            }
        }
コード例 #26
0
        public void DrawArea(params Point [] vertices)
        {
            double x1, y1;
            Point  initial_point = vertices [0];

            CContext.MoveTo(initial_point.X, initial_point.Y);
            for (int i = 1; i < vertices.Length; i++)
            {
                x1 = vertices [i].X;
                y1 = vertices [i].Y;
                CContext.LineTo(x1, y1);
            }

            CContext.ClosePath();
            StrokeAndFill();
        }
コード例 #27
0
        protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
        {
            bool ret = true;

            pathClicked = null;
            TreeViewColumn column;
            int            cellX, cellY;

            IViewModel vm = GetViewModelAtPosition((int)evnt.X, (int)evnt.Y, out column, out cellX, out cellY);

            if (vm != null && ProcessViewModelClicked(vm, cellX, cellY, column.Width, evnt.State))
            {
                return(true);
            }

            TreePath [] paths = Selection.GetSelectedRows();

            if (Misc.RightButtonClicked(evnt))
            {
                // We don't want to unselect the play when several
                // plays are selected and we click the right button
                // For multiedition
                if (paths.Length <= 1)
                {
                    ret   = base.OnButtonPressEvent(evnt);
                    paths = Selection.GetSelectedRows();
                }

                ShowMenu();
            }
            else
            {
                ret = base.OnButtonPressEvent(evnt);
                if (paths.Length > 0 && enableDragSource && AllowDrag(vm))
                {
                    dragging    = true;
                    dragStarted = false;
                    dragStart   = new Point(evnt.X, evnt.Y);
                }
                int modifier = App.Current.Keyboard.ParseModifier(evnt);
                if (modifier == 0)
                {
                    GetPathAtPos((int)evnt.X, (int)evnt.Y, out pathClicked);
                }
            }
            return(ret);
        }
コード例 #28
0
        void RenderPlayButton(IDrawingToolkit tk, Area cellArea, bool insensitive, CellState state)
        {
            Point p = new Point(cellArea.Right - App.Current.Style.ButtonNormalWidth - RIGTH_OFFSET,
                                cellArea.Top + VERTICAL_OFFSET);
            ISurface background = BtnNormalBackground;

            if (insensitive)
            {
                background = BtnNormalBackgroundInsensitive;
            }
            else if (state.HasFlag(CellState.Prelit) && playButtonPrelighted)
            {
                background = BtnNormalBackgroundPrelight;
            }
            tk.DrawSurface(p, App.Current.Style.ButtonNormalWidth, App.Current.Style.ButtonNormalHeight, background, ScaleMode.AspectFit);
            tk.DrawSurface(p, App.Current.Style.IconLargeHeight, App.Current.Style.IconLargeHeight, PlayIcon, ScaleMode.AspectFit);
        }
コード例 #29
0
        void RenderPlaylistElement(PlaylistElementVM vm, IDrawingToolkit tk, IContext context, Area backgroundArea, Area cellArea, CellState state)
        {
            tk.Context = context;
            tk.Begin();
            Point textPoint = new Point(backgroundArea.Left + LEFT_OFFSET + (2 * SPACING) + COLOR_RECTANGLE_WIDTH +
                                        MINIATURE_WIDTH + SPACING, cellArea.Start.Y);
            double textWidth = (cellArea.Right - RIGTH_OFFSET - EYE_IMAGE_WIDTH - SPACING) - textPoint.X;

            RenderBackground(tk, backgroundArea, App.Current.Style.ThemeBase);
            RenderSelection(tk, context, backgroundArea, cellArea, state, true);
            RenderPrelit(vm.Playing, tk, context, backgroundArea, cellArea, state);
            RenderChildText(tk, textPoint, (int)textWidth, (int)cellArea.Height, vm.Description, App.Current.Style.TextBase);
            RenderColorStrip(tk, backgroundArea, App.Current.Style.TextBase);
            Point p = new Point(backgroundArea.Left + LEFT_OFFSET + COLOR_RECTANGLE_WIDTH + SPACING, cellArea.Start.Y + VERTICAL_OFFSET);

            RenderImage(tk, p, vm.Miniature, MINIATURE_WIDTH, MINIATURE_HEIGHT);
            RenderEye(tk, backgroundArea, cellArea, vm.Playing);
            tk.End();
        }
コード例 #30
0
        public void ClipRoundRectangle(Point start, double width, double height, double radius)
        {
            double x, y;

            x = start.X;
            y = start.Y;

            if ((radius > height / 2) || (radius > width / 2))
            {
                radius = Math.Min(height / 2, width / 2);
            }

            CContext.MoveTo(x, y + radius);
            CContext.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            CContext.LineTo(x + width - radius, y);
            CContext.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            CContext.LineTo(x + width, y + height - radius);
            CContext.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            CContext.LineTo(x + radius, y + height);
            CContext.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            CContext.ClosePath();
            CContext.Clip();
        }