Esempio n. 1
0
        public ToolbarToggleButton (String text_one, String text_two, bool auto_toggle, StyleSheet scheme, Border borders,
                                    uint width, uint height) : base (text_one, scheme, borders, width, height)
        {
            toggle = auto_toggle;

            CairoTexture texture = new CairoTexture (width, height);
            StyleSheet s = scheme;
            s.Foreground = scheme.Background;
            s.Background = scheme.Foreground;

            s.Standard = new Font () {
                Family = scheme.Standard.Family,
                Slant = scheme.Standard.Slant,
                Weight = scheme.Standard.Weight,
                Size = scheme.Standard.Size,
                Color = scheme.Background
            };

            s.Border = scheme.Foreground;
            Style = s;
            Text = text_two;
            Draw (texture);

            Style = scheme;
            Text = text_one;
            textures.Add (texture);
            texture.Hide ();
            this.Add (texture);

            InitializeHandlers ();
        }
        public ClutterSlider(float width, float height) : base()
        {
            //this.IsReactive = true;
            this.SetSize(width, height);

            handle = new ClutterSliderHandle((float)arrow_width * 0.5f + line_width * 2, 0, (float)SliderWidth, (float)Height, 0);
            handle.SliderHasChanged += HandleSliderHasChanged;
            handle.SliderHasMoved   += HandleSliderHasMoved;
            handle.BubbleEvents      = true;
            AddActor(handle);

            outline = new CairoTexture(SliderWidth, (uint)Height);
            AddActor(outline);
            outline.SetAnchorPoint(outline.Width * 0.5f, outline.Height * 0.5f);
            outline.SetPosition(Width * 0.5f, Height * 0.5f);

            arrow_left = new ClutterArrowButton((uint)arrow_width, (uint)arrow_height, 0, 0x03);
            arrow_left.ButtonPressed += HandleLeftArrowButtonPressEvent;
            AddActor(arrow_left);
            arrow_left.SetPosition(0, 0);

            arrow_right = new ClutterArrowButton((uint)arrow_width, (uint)arrow_height, 0, 0x01);
            arrow_right.ButtonPressed += HandleRightArrowButtonPressEvent;
            AddActor(arrow_right);
            arrow_right.SetPosition((float)(Width - arrow_width), 0);

            Update();
            ShowAll();
        }
        public ClutterSlider(float width, float height)
            : base()
        {
            //this.IsReactive = true;
            this.SetSize(width, height);

            handle = new ClutterSliderHandle((float) arrow_width*0.5f + line_width*2, 0, (float) SliderWidth, (float) Height, 0);
            handle.SliderHasChanged += HandleSliderHasChanged;
            handle.SliderHasMoved += HandleSliderHasMoved;
            handle.BubbleEvents = true;
            Add(handle);

            outline = new CairoTexture (SliderWidth, (uint) Height);
            Add(outline);
            outline.SetAnchorPoint (outline.Width*0.5f, outline.Height*0.5f);
            outline.SetPosition (Width*0.5f, Height*0.5f);

            arrow_left = new ClutterArrowButton((uint) arrow_width,(uint) arrow_height, 0, 0x03);
            arrow_left.ButtonPressEvent += HandleLeftArrowButtonPressEvent;
            Add (arrow_left);
            arrow_left.SetPosition (0,0);

            arrow_right = new ClutterArrowButton ((uint) arrow_width,(uint) arrow_height, 0, 0x01);
            arrow_right.ButtonPressEvent += HandleRightArrowButtonPressEvent;
            Add (arrow_right);
            arrow_right.SetPosition ((float) (Width-arrow_width),0);

            Update ();
            ShowAll ();
        }
        protected virtual void InitBackground()
        {
            background = new CairoTexture((uint)Width, (uint)Height);
            Add(background);

            SetupBackground();
            background.Show();
        }
        protected virtual void InitBackground()
        {
            background = new CairoTexture ((uint) Width,(uint) Height);
            Add (background);

            SetupBackground ();
            background.Show ();
        }
Esempio n. 6
0
        private void GenerateSpinners ()
        {
            spinner = new List<CairoTexture> ();

            for (int i=0; i < 8; i++) {
                CairoTexture current = new CairoTexture (height, height);
                DrawSpinner (current, i);
                spinner.Add (current);
                spinner_actor.Add (current);
                current.Hide ();
            }
        }
Esempio n. 7
0
        public ClutterWidgetBar (Actor[] actors) : base ()
        {
            foreach (Actor actor in actors) {
                this.Add (actor);
            }
            text = new CairoTexture ((uint) Width,(uint) Height);
            this.Add (text);

            UpdatePositions ();

            this.ActorAdded += HandleActorAdded;
            this.ActorRemoved += HandleActorRemoved;
        }
Esempio n. 8
0
        /// <summary>
        /// Generate the prototypes which are used for drawing.
        /// </summary>
        static public void GeneratePrototypes ()
        {
//            if (prototype_list.Count > 0)
//                return;

            prototype_list.Clear ();

            for (int i=0; i < max_prototypes; i++)
            {
                CairoTexture texture = new CairoTexture (circle_size,circle_size);
                prototype_list.Add (texture);
                UpdatePrototypeWithColor (texture, i);
            }
        }
        public ClutterWidgetBar(Actor[] actors)
            : base()
        {
            foreach (Actor actor in actors) {
                this.AddActor (actor);
            }
            text = new CairoTexture ((uint) Width,(uint) Height);
            this.AddActor (text);

            UpdatePositions ();

            this.ActorAdded += HandleActorAdded;
            this.ActorRemoved += HandleActorRemoved;
        }
Esempio n. 10
0
        public static void MakeReflection(Cairo.ImageSurface source, CairoTexture dest)
        {
            int w = source.Width + 4;
            int h = source.Height * 2 + 4;

            dest.SetSurfaceSize((uint)w, (uint)h);

            Cairo.Context context = dest.Create();

            MakeReflection(context, source, w, h);

            //((IDisposable) context.Target).Dispose ();
            ((IDisposable)context).Dispose();
        }
Esempio n. 11
0
        /// <summary>
        /// Draws the button into the texture
        /// </summary>
        /// <param name="actor">
        /// A <see cref="CairoTexture"/>
        /// </param>
        protected void Draw (CairoTexture actor)
        {
            double x = 0.5, y = 0.5;
            double r = (texture_height - x - y) / 2;

            Cairo.Context cr = actor.Create ();

            if ((Borders & Border.Right) == Border.Right)
                cr.Arc (-x+texture_width-r, y+r, r, -Math.PI/2, Math.PI/2);
            else {
                cr.MoveTo (x+r,y);
                cr.LineTo (-x+texture_width, y);
                cr.LineTo (-x+texture_width, y+2*r);
            }

            if ((Borders & Border.Left) == Border.Left)
                cr.Arc (x+r, y+r, r, Math.PI/2, -Math.PI/2);
            else {
                cr.LineTo (x, y+2*r);
                cr.LineTo (x, y);
            }

            cr.ClosePath ();

            cr.Color = Style.Background;
            cr.FillPreserve();

            cr.Color = Style.Border;
            cr.LineWidth = Style.BorderSize;
            cr.Stroke ();

            cr.Color = Style.Standard.Color;

            cr.SelectFontFace (Style.Standard.Family, Style.Standard.Slant, Style.Standard.Weight);
            cr.SetFontSize (Style.Standard.Size);

            TextExtents te = cr.TextExtents (Text);

            cr.MoveTo ((texture_width-te.Width)/2,2*r-texture_height/4);
            cr.FontOptions.HintStyle = HintStyle.Full;
            cr.ShowText (Text);

            ((IDisposable) cr.Target).Dispose ();
            ((IDisposable) cr).Dispose ();
        }
Esempio n. 12
0
        /// <summary>
        /// Generates the undlying texture
        /// </summary>
        protected override void GenerateTextures ()
        {
            double x = 5+0.5, y = 5+0.5;
            double r = (texture_width - x - y) / 2;

            CairoTexture actor = new CairoTexture (texture_width,texture_height);
            Cairo.Context context = actor.Create ();

            context.Arc (x+r, y+r, r, 0, 2*Math.PI);

            context.ClosePath ();

            context.Color = Style.Background;
            context.FillPreserve ();

            context.Color = Style.Border;
            context.LineWidth = Style.BorderSize;
            context.Stroke ();

            context.Color = Style.Foreground;

            context.MoveTo (x+5,texture_height /2);
            context.LineTo (texture_width-5-x, texture_height /2);
            context.LineWidth = 2.0;
            context.Stroke ();

            if (inward)
            {
                context.MoveTo (texture_width /2,y+5);
                context.LineTo (texture_width /2,texture_height-5-y);
                context.Stroke ();
            }

            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();

            textures.Add (actor);
        }
Esempio n. 13
0
        public StatusBox (StyleSheet style, uint width, uint height)
        {
            this.style = style;
            this.height = height;

            Text = "test";
            spinner = new List<CairoTexture> ();

            texture = new CairoTexture (width, height);
            spinner_actor = new Group ();
            GenerateSpinners ();

            spinner_actor.SetPosition (5, 0 );

            Add (texture);
            Add (spinner_actor);

            spinner_timer = new Timer ();
            spinner_timer.Interval = 150;
            spinner_timer.Elapsed += HandleSpinnerNextFrame;

//            Update ("",true);
        }
Esempio n. 14
0
        /// <summary>
        /// Updates the prototype whith the given color.
        /// </summary>
        /// <param name="actor">
        /// A <see cref="CairoTexture"/>
        /// </param>
        /// <param name="color_index">
        /// A <see cref="System.Int32"/>
        /// </param>
        static private void UpdatePrototypeWithColor (CairoTexture actor, int color_index)
        {
            color_index = color_index % max_prototypes;

            switch (color_index)
            {
            case (int)Color.Green:
                UpdatePrototype (actor,0.0, 1.0, 0.0, 0);
                break;

            case (int)Color.Red:
                UpdatePrototype (actor,1.0, 0.0, 0.0, 0.8);
                break;

            case (int)Color.LightRed:
                UpdatePrototype (actor,0.8, 0.1, 0.1, 0.55);
                break;

            case (int)Color.White:
                UpdatePrototype (actor,1.0, 1.0, 1.0, 0);
                break;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Sets the color of the actor (i.e. sets the prototype).
        /// </summary>
        /// <param name="color">
        /// A <see cref="Color"/>
        /// </param>
        public void SetPrototypeByColor (Color color)
        {
            if (color == current_color)
                return;

            Debug.Assert ((int)color < prototype_list.Count);

            Prototype = prototype_list[(int)color];
            current_color = color;
        }
Esempio n. 16
0
 /// <summary>
 /// Generates the textures of the button.
 /// </summary>
 protected override void GenerateTextures ()
 {
     CairoTexture actor1 = new CairoTexture (texture_width, texture_height);
     Draw (actor1);
     textures.Add (actor1);
 }
Esempio n. 17
0
        public void DrawSpinner (CairoTexture tex, int count)
        {
            Cairo.Context cr = tex.Create ();

            cr.Translate (height /2, height /2);
            cr.LineWidth = 3;

            for (int i = 0; i < 8; i ++) {
                cr.Color = new Cairo.Color (1,1,1,1-(double)((count+i)%8)/7);

                cr.MoveTo (0, -height/2.5+3);
                cr.LineTo (0, -height/2.5);
                cr.Rotate (-Math.PI / 4);
                cr.Stroke ();
            }

            ((IDisposable) cr.Target).Dispose ();
            ((IDisposable) cr).Dispose ();
        }
Esempio n. 18
0
    public Flower( )
    {
        int idx      = -1;
        int last_idx = -1;

        int petal_size = PETAL_MIN + rand() % PETAL_VAR;
        int size       = petal_size * 8;

        int n_groups = rand() % 3 + 1;

        this.ctex = new CairoTexture((uint)size, (uint)size);

        // the using statement make sure the cr is disposed at the end,
        // otherwise we get no bling
        using (Cairo.Context cr = this.ctex.Create())
        {
            cr.Tolerance = 0.1;

            // Clear
            cr.Operator = Operator.Clear;
            cr.Paint();
            cr.Operator = Operator.Over;

            cr.Translate(size / 2, size / 2);

            // petals
            for (int i = 0; i < n_groups; i++)
            {
                int n_petals = rand() % 5 + 4;
                cr.Save();

                cr.Rotate(rand() % 6);

                do
                {
                    idx = (rand() % (colors.Length / 3)) * 3;
                } while (idx == last_idx);

                cr.SetSourceRGBA(colors[idx], colors[idx + 1], colors[idx + 2], 0.5);

                int pm1 = rand() % 20;
                int pm2 = rand() % 4;

                for (int j = 0; j < n_petals; j++)
                {
                    cr.Save();

                    cr.Rotate(((2 * Math.PI) / n_petals) * j);

                    cr.NewPath();
                    cr.MoveTo(0, 0);

                    cr.RelCurveTo(petal_size, petal_size, (pm2 + 2) * petal_size,
                                  petal_size, (2 * petal_size) + pm1, 0);

                    cr.RelCurveTo(0 + (pm2 * petal_size), -petal_size, -petal_size,
                                  -petal_size, -((2 * petal_size) + pm1), 0);

                    cr.ClosePath();
                    cr.Fill();
                    cr.Restore();
                }

                petal_size -= rand() % (size / 8);

                cr.Restore();
            }

            // flower center
            do
            {
                idx = (rand() % (colors.Length / 4 / 3)) * 3;
            } while (idx == last_idx);

            if (petal_size < 0)
            {
                petal_size = rand() % 10;
            }

            cr.SetSourceRGBA(colors[idx], colors[idx + 1], colors[idx + 2], 0.5);

            cr.Arc(0, 0, petal_size, 0, Math.PI * 2);
            cr.Fill();
        }
    }
 protected virtual void CreateTexture(CairoTexture texture, int with_state)
 {
     throw new System.NotImplementedException();
 }
 protected virtual void CreateTexture(CairoTexture texture, int with_state)
 {
     throw new System.NotImplementedException ();
 }
Esempio n. 21
0
    public Flower( )
    {
        int idx = -1;
        int last_idx = -1;

        int petal_size = PETAL_MIN + rand () % PETAL_VAR;
        int size = petal_size * 8;

        int n_groups = rand () % 3 + 1;

        this.ctex = new CairoTexture ((uint)size, (uint)size);

        // the using statement make sure the cr is disposed at the end,
        // otherwise we get no bling
        using (Cairo.Context cr = this.ctex.Create ())
        {
            cr.Tolerance = 0.1;

            // Clear
            cr.Operator = Operator.Clear;
            cr.Paint ();
            cr.Operator = Operator.Over;

            cr.Translate (size/2, size/2);

            // petals
            for (int i = 0; i < n_groups; i++)
            {
             	int n_petals = rand () % 5 + 4;
                cr.Save ();

                cr.Rotate (rand () % 6);

                do {
                    idx = (rand () % (colors.Length / 3)) * 3;
                } while (idx == last_idx);

                cr.SetSourceRGBA (colors[idx], colors[idx+1], colors[idx+2], 0.5);

                int pm1 = rand () % 20;
                int pm2 = rand () % 4;

                for (int j = 0; j < n_petals; j++)
                {
                 	cr.Save ();

                    cr.Rotate (((2 * Math.PI) / n_petals) * j);

                    cr.NewPath ();
                    cr.MoveTo (0, 0);

                    cr.RelCurveTo (petal_size, petal_size, (pm2 + 2) * petal_size,
                        petal_size, (2 * petal_size) + pm1, 0);

                    cr.RelCurveTo (0 + (pm2 * petal_size), -petal_size, - petal_size,
                        -petal_size, -((2 * petal_size) + pm1), 0);

                    cr.ClosePath ();
                    cr.Fill ();
                    cr.Restore ();
                }

                petal_size -= rand () % (size / 8);

                cr.Restore ();
            }

            // flower center
            do {
                idx = (rand () % (colors.Length / 4 / 3)) * 3;
            } while (idx == last_idx);

            if (petal_size < 0)
             	petal_size = rand () % 10;

            cr.SetSourceRGBA (colors[idx], colors[idx+1], colors[idx+2], 0.5);

            cr.Arc (0, 0, petal_size, 0, Math.PI * 2);
            cr.Fill ();
        }
    }
Esempio n. 22
0
        /// <summary>
        /// Updates the prototype with the given color.
        /// </summary>
        /// <param name="actor">
        /// A <see cref="CairoTexture"/>
        /// </param>
        /// <param name="r">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <param name="g">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <param name="b">
        /// A <see cref="System.Double"/>
        /// </param>
        /// <param name="a">
        /// A <see cref="System.Double"/>
        /// </param>
        static private void UpdatePrototype (CairoTexture actor, double r, double g, double b, double a)
        {
            if ( a == 0)
                a = 0.55;

            UpdatePrototype (actor,r,g,b,a,0,0,0,0);
        }
Esempio n. 23
0
        /// <summary>
        /// Redraws the circle_prototype which is used for all circles as template.
        /// This means a new circle is drawn with cairo and stored in a texture.
        /// </summary>
        static private void UpdatePrototype (CairoTexture actor, double r, double g, double b, double a,
                                                   double arc, double a_r, double a_g, double a_b)
        {
            double size = (double)circle_size;

            actor.Clear();
            Cairo.Context context = actor.Create();


            Cairo.Gradient pattern = new Cairo.RadialGradient(size/2.0,size/2.0,size/3.0,
                                                            size/2.0,size/2.0,size/2.0);

            pattern.AddColorStop(0,new Cairo.Color (r,g,b,a));
            pattern.AddColorStop(1.0,new Cairo.Color (r,g,b,0.1));

            context.LineWidth = (double)size/5.0;
            context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,0,2*Math.PI);

            context.Save();

            context.Pattern = pattern;
            context.Fill();

            if (arc != 0) {

                context.LineWidth = (double)size/10.0;
                context.Arc (size/2.0, size/2.0,
                         size/2.0-context.LineWidth/2.0,-Math.PI/2.0,2*Math.PI*arc/100.0-Math.PI/2.0);

                Hyena.Log.Debug ("Arc prototype "+ arc);
                context.Color = new Cairo.Color (a_r,a_g,a_b,0.5);
                context.Stroke ();
            }
            ((IDisposable) context.Target).Dispose ();
            ((IDisposable) context).Dispose ();
        }