What's the best way, or Is there some guidelines to subclass a clutter
actor or a clutter container but using composition
 instead of pure hard rewriting paint()/pick() virtual methods. And
the question goes: because of the inability of Cogl of using
antialising, so I want to make cute rounded rectangle actor, i can't
use paint()/pick() approach to subclass.

Let say i need a CircleActor in order to put it in a lot places around
my app, the preferred way it's to encapsulate the Actor in a class,
so How do i can do this. I can pack a Clutter.CairoTexture (which do
allow me to make fancy graphics designs) into a class, but the
question arising here is, what about the definition of the
Clutter.CairoTexture object, where to put it in order to get repainted
every time its needed.

I had this sample: isn't working at all.

------------------------------------------------------------------------------
namespace Clutter {
        public class RR : Clutter.Actor {
                private Clutter.CairoTexture r_r;

                public uint radius { get; construct set; }
                public Clutter.Color color { get; construct set; }
                
                public RR() {
                        this.color = Clutter.Color.from_string("white");
                        this.radius = 5;
                }

                public RR.with_color_and_radius(Clutter.Color _color, uint 
_radius) {
                        Object(color: _color, radius: _radius);
                }
                
                public override void paint() {
                        
                        /* creating the rectangle */
                        this.r_r = new Clutter.CairoTexture((uint)this.width, 
(uint)this.height);
                        Cairo.Context* cr = this.r_r.create();
                        
                        cr->move_to(this.radius, 0);
                        cr->line_to(this.width - this.radius, 0);
                        cr->arc(this.width - this.radius, this.radius, 
this.radius, Math.PI
* 3 / 2, 2 * Math.PI);
                        
                        cr->line_to(this.width, this.height - this.radius);
                        cr->arc(this.width - this.radius, this.height - 
this.radius,
this.radius, 0, Math.PI / 2);
                        
                        cr->line_to(this.radius, this.height);
                        cr->arc(this.radius, this.height - this.radius, 
this.radius,
Math.PI / 2, Math.PI);
                        
                        cr->line_to(0, this.radius);
                        cr->arc(this.radius, this.radius, this.radius, Math.PI, 
Math.PI * 3 / 2);
                        
                        /* getting color from Clutter.Color _color */
                        cr->set_source_rgba(((float)_color.red) / 255.0,
((float)_color.green) / 255.0, ((float)_color.blue) / 255.0,
((float)_color.alpha) / 255.0);
                        cr->stroke_preserve();
                        cr->fill();
                        
                        delete cr;
                        
                        this.r_r.set_position(0, 0);
                        this.r_r.show_all();
                        
                        this.r_r.unparent();
                        this.r_r.set_parent(this);
                        
                        this.r_r.paint();
                }
        }
}

int main(string [] args) {

        /* init */
        Clutter.init (ref args);

        /* Stage definition */
    Clutter.Stage st = new Clutter.Stage();
    st.hide.connect(Clutter.main_quit);
    st.set_size(400, 600);
    st.color = Clutter.Color.from_string("grey");
    st.show_all();

        var rr = new Clutter.RR.with_color_and_radius({20, 20, 240, 200}, 10);
        rr.set_size(200, 60);
        rr.set_position(0, 0);
        rr.show_all();
        st.add(rr);

    /* Clutter loop */
    Clutter.main();

    return 0;
}
------------------------------------------------------------------------------

Oh, btw that's vala, it's like c but hotter. You sure already heard about it.

I got other issues, i first made this work by defining the
CairotTexture in the constructor, but
after that i can't change the color of the texture, or the size, or
anything like that, that's without talking
about the super long list of arguments of the constructor method. So
that approach, WRONG !!!.

What I'm trying to do moving the definition of the
Clutter.CairoTexture is get advantage of the already defined methods,
like
Clutter.Actor::set_size(), and so on.

Well, i hope i made clear (even if i don't think so).
Any helps please. !!!!

Thxs in advance.


BTW: Do someone knows when is plan to add antialiasing functionality to Cogl ?.
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to