Beispiel #1
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!CairoHelper.ShouldDrawWindow(cr, Window))
            {
                return(true);
            }

            if (HasFrame)
            {
                int y_mid = (int)Math.Round((Allocation.Height - renderer.Height) / 2.0);
                StyleContext.Save();
                StyleContext.AddClass("entry");
                StyleContext.RenderBackground(cr, 0, y_mid, Allocation.Width, renderer.Height);
                StyleContext.RenderFrame(cr, 0, y_mid, Allocation.Width, renderer.Height);
                StyleContext.Restore();
            }

            renderer.Render(cr, new Gdk.Rectangle(0, 0, Allocation.Width, Allocation.Height),
                            CairoExtensions.GdkRGBAToCairoColor(Parent.StyleContext.GetColor(StateFlags)),
                            AlwaysShowEmptyStars, PreviewOnHover && hover_value >= renderer.MinRating, hover_value,
                            State == StateType.Insensitive ? 1 : 0.90,
                            State == StateType.Insensitive ? 1 : 0.55,
                            State == StateType.Insensitive ? 1 : 0.45);

            return(true);
        }
Beispiel #2
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (CairoHelper.ShouldDrawWindow(cr, Window))
            {
                // Center the text vertically
                int lw, lh;
                layout.GetPixelSize(out lw, out lh);
                int y = (Allocation.Height - lh) / 2;

                StyleContext.State = StateFlags;
                StyleContext.RenderLayout(cr, 0, y, layout);
            }

            return(true);
        }
Beispiel #3
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!IsDrawable)
            {
                return(false);
            }

            if (CairoHelper.ShouldDrawWindow(cr, Window) && HasFocus)
            {
                int layout_width = 0, layout_height = 0;
                label.Layout.GetPixelSize(out layout_width, out layout_height);
                StyleContext.Save();
                StyleContext.AddClass("check");
                StyleContext.RenderFocus(cr, 0, 0, layout_width + 2 * padding, layout_height + 2 * padding);
                StyleContext.Restore();
            }

            if (Child != null)
            {
                PropagateDraw(Child, cr);
            }

            return(false);
        }
Beispiel #4
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!CairoHelper.ShouldDrawWindow(cr, Window))
            {
                return(base.OnDrawn(cr));
            }

            if (reflect)
            {
                cr.PushGroup();
            }

            cr.Operator = Operator.Over;
            cr.Translate(h_padding, 0);
            cr.Rectangle(0, 0, Allocation.Width - h_padding, Math.Max(2 * bar_height,
                                                                      bar_height + bar_label_spacing + layout_height));
            cr.Clip();

            using (var bar = RenderBar(Allocation.Width - 2 * h_padding, bar_height)) {
                cr.Save();
                cr.SetSource(bar);
                cr.Paint();
                cr.Restore();

                if (reflect)
                {
                    cr.Save();

                    cr.Rectangle(0, bar_height, Allocation.Width - h_padding, bar_height);
                    cr.Clip();

                    Matrix matrix = new Matrix();
                    matrix.InitScale(1, -1);
                    matrix.Translate(0, -(2 * bar_height) + 1);
                    cr.Transform(matrix);

                    cr.SetSource(bar);

                    using (var mask = new LinearGradient(0, 0, 0, bar_height)) {
                        mask.AddColorStop(0.25, new Color(0, 0, 0, 0));
                        mask.AddColorStop(0.5, new Color(0, 0, 0, 0.125));
                        mask.AddColorStop(0.75, new Color(0, 0, 0, 0.4));
                        mask.AddColorStop(1.0, new Color(0, 0, 0, 0.7));

                        cr.Mask(mask);
                    }

                    cr.Restore();

                    cr.PopGroupToSource();
                    cr.Paint();
                }

                if (show_labels)
                {
                    cr.Translate((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2,
                                 bar_height + bar_label_spacing);
                    RenderLabels(cr);
                }
            }

            return(true);
        }