Mark Boorer | 23 May 01:50
Picon

Get relative position on scaled actor

Hi all,

Not sure if this has been answered before, and I couldn't find anything in my searches.

I'm using python-clutter, and I'm implementing a zoomable-scroll area using nested Group containers.

Like this:

viewArea = clutter.Group()
container = clutter.Group()
viewArea.add(container)

I'm nesting them, so that the top level group doesn't move, and receives all the mouse events, and it moves / scales the "container" inside.

I've hit a slight problem though. When scaling the "container", I want the user to have the area the mouse is under remain in the center of the zoom. I can use set_scale_full() and calculate the center coordinates relative to "viewArea" but these values don't work it the container is already scaled.

Is there a way to get the relative position of an actor when it's already scaled?

Thanks,
Mark

_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list
Tyson Neuroth | 21 May 06:40
Picon

Can't get out of fullscreen, can't set focus on stage.

I'm trying to set a second stage to fullscreen, with the option to hide/show it.  My problem is that after showing it I cannot hide it.  When I don't set to fullscreen, sometimes the window is active when shown and sometimes not.  I am able to click on the top boarder of the window to select it, and then can click my hide button.

I've tried setting the stage to accept key focus when shown, and have tried setting key focus to the stage manually, but it doesn't change anything.  

I feel like if I could somehow set the stage to be the active window, I think it might resolve my problem, but I cannot seem to do this.  

If I start the window in full screen, shown, then I can hide it, but then after showing it again, I cannot do anything with it. 

I am working on windows 7, and will be testing my linux version tomorrow.  

If anyone knows a way to make this work, I would appreciate the advice.  
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list
david.sale.75 | 19 May 19:56
Picon

How write touch screen drivers in clutter?

Hi, all:
I am trying write  a touch screen driver in clutter-1.6.20 application,
touch screen like ELO type, it's use serial send 10 bytes data to /dev/ttyS0
.

Now my way is:
Use clutter_texture_new_from_file() create a mouse actor,  create a thread
constantly from /dev/ttyS0 get data, conversion coordinate and then create a
new clutter event,  set mouse  actor position in thread, because clutter API
is not thread safe, so only can set the mouse actor position API a separate
place in a function, by clutter_thread_add_ide_full() calls.

This will cause some problems, hasn't dealt with the mouse position, the new
touch screen data have arrived, but thread haven't deal with the mouse place
of work, and the resulting events have delay, lead to the mouse action is
very slow.
Do you have any ideas method can improve efficiency ?

Here is my code:

static gfloat x=0, y=0;
static ClutterActor *mouse;
GTimer *timer;

static gboolean fun_setmouse_x(gpointer data)
{
	clutter_actor_set_position(mouse, x, y);
	clutter_actor_raise_top(mouse);
	return FALSE;
}

void change_abs(int abs_x, int abs_y, unsigned char up_down)
{
    ClutterEvent *event;
    static gfloat     last_x = 0, last_y = 0;
    static gboolean clicked = FALSE;

    clutter_threads_enter (); 

    if (!clutter_events_pending())
    {

        //if (last_x == abs_x && last_y == abs_y )
	        //goto out;

        last_x = abs_x;
        last_y = abs_y;
	        
		event = clutter_event_new (CLUTTER_NOTHING);
		event->any.stage = CLUTTER_STAGE(
clutter_stage_get_default() );
	
		x = (1280*abs_x)/4096;
		y = (720*abs_y)/4096; 
		  
		event->button.x = x;
		event->button.y = y;
	
		if ((up_down==0x81)  && !clicked)
		{
			event->button.type = event->type =
CLUTTER_BUTTON_PRESS;
			event->button.time =
g_timer_elapsed(timer,NULL)*1000;
			event->button.modifier_state = 0;
			event->button.button = 1;
	
			clicked = TRUE;
		}
		else if ((up_down==0x82) && clicked )
		{
			event->motion.type = event->type = CLUTTER_MOTION;
			event->motion.time =
g_timer_elapsed(timer,NULL)*1000;
			if (clicked)
				event->motion.modifier_state =
CLUTTER_BUTTON1_MASK;
			else
				event->motion.modifier_state = 0;
			
			//dbg("CLUTTER_MOTION!!!!\n");
		}
		else if ((up_down==0x84) && clicked)
		{
			event->button.type = event->type =
CLUTTER_BUTTON_RELEASE;
			event->button.time =
g_timer_elapsed(timer,NULL)*1000;
			if (clicked)
				event->button.modifier_state =
CLUTTER_BUTTON1_MASK;
			else
				event->motion.modifier_state = 0;
					
			event->button.button = 1;
			clicked = FALSE;
			//dbg("CLUTTER_BUTTON_RELEASE!!!!\n");
		}
		
		clutter_event_put(event);  
		clutter_event_free(event); 

	}
	
	event = clutter_event_get();  

	if (event)
	{
		/* forward the event into clutter for emission etc. */
		clutter_threads_add_idle(fun_setmouse_x, NULL);
		clutter_do_event (event);
		clutter_event_free (event);
	}
	
out:
    clutter_threads_leave ();
    return;
}

gpointer touchscreen_thread(gpointer data)
{
	int fd;
	int nread;
	unsigned char buff[64];
	char *dev ="/dev/ttyS0";

                fd_set fds;
	int retval;

	fd = OpenDev(dev);
	if (fd>0)
		set_speed(fd);
	else
	{
		  printf("Can't Open Serial Port!\n");
		  exit(0);
	}
	int idx=0;
	while (1)
	{	
	   FD_ZERO(&fds);
	    FD_SET(fd,&fds);
	    retval = select (fd+1, &fds, NULL, NULL, NULL);
	    if (FD_ISSET(fd, &fds)) 
	    {
			nread = read(fd, (char*)(buff), 10);
			if (nread < 0) 
			{
				continue;			
			}
				
			 change_abs( buff[3] | (buff[4]<<8), buff[5] |
(buff[6]<<8), buff[2]); 
		}					
	}
	close(fd);
}

void touchscreen_driver_create()
{
	timer = g_timer_new();
	g_timer_start(timer);

	mouse =
clutter_texture_new_from_file("../image/skin/mouse.png",NULL);
	clutter_container_add_actor(CLUTTER_CONTAINER(gStage), mouse);
	GThread *thread = g_thread_create(touchscreen_thread, NULL, FALSE,
NULL);
	
}

_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Tyson Neuroth | 16 May 16:40
Picon

Compatibility with cuda/openCL, or openMP

I'm just wondering if it's ok to use openCL/cuda, or openMP in a clutter project.  Specifically I want to use in a function launched by clutter_threads_add_timeout.  


Thanks
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list
Amy C | 15 May 03:11
Picon
Gravatar

Subclassing a Clutter Clone *from javascript bindings*

Hi all,
I'm trying to create a custom class that is a Clutter.Clone plus some
extra methods.
I'm using the GNOME javascript bindings (from gobject introspection)
to do this, and am having difficulty getting the inheritance working
properly.

I asked around at stackoverflow about this sort of thing first to
avoid spamming the list with javascript questions, but the answers
given there did not work on the Clutter classes, so I'm asking here.

First, in GNOME 3.4 I can do:

Toon = new Lang.Class({ // Lang is imports.lang
    Name: 'Toon',
    Extends: Clutter.Clone,
    other methods here.
});

This works fantastic - if I do `var toon = new Toon( a_clutter_texture
);` everything works fine.

However in GNOME 3.2 the `Lang.Class` method doesn't seem to be there,
and in my asking around I've been told the "standard" way to make a
subclass in JS is like so:

Toon = function() {
    Clutter.Clone.call(this,arguments); // this gives Toon all the
properties/methods of Clutter.Clone
    // toon-specific initialisation code here
}
Toon.prototype = new Clutter.Clone;
Toon.prototype.method = function... // add all the toon-specific methods here

However when I do `var toon = new Toon()` or `var toon = new Toon(
a_clutter_texture )`, I get "Constructor called as normal method. Use
'new SomeObject()' not 'SomeObject()'."

So then I tried replacing the `Clutter.Clone.call(this,arguments)`
with `Clutter.Clone.new.call(this,arguments)`. I now get the error
"Object 0xb681b1c0 proto 0xb6802078 doesn't have a
dynamically-registered class, it has Arguments".

I thought this might be somehow because of me using the special
`arguments` keyword, so I even tried `Clutter.Clone.new.call(this, new
Clutter.Texture())`, and I get the same message as above but instead
of "Arguments" I get "Object".

I've even tried:

Toon = function() {};
Toon.prototype = new Clutter.Clone;
Toon.prototype.method = function ... //toon-specific methods

In this case I get no errors on `var Toon = new Toon(
a_clutter_texture )`, but when I try using a non-toon method like
`Toon.set_position(0,0)`, I get the 'Object 0x... proto 0x... doesn't
have a dynamically-registered class, it has Object' message again,
which indicates to me that Toon is somehow not being recognised as a
Clutter.Clone.

Is anyone able to tell me where I'm going wrong?
Thanks in advance.
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Stefano Candori | 14 May 15:05
Picon

Problem with "long" Cairo drawing

Hello everybody,


My name is Stefano Candori and I'm the maintainer of the GNOME Activity Journal. In these days i'm trying to revamp it but I'm stuck with a problem.
Let me explain: I'm trying to implement a sort of scrollable timeline using a ClutterCairoTexture to paint a long line (similar to the Facebook one) in the center of the stage.
The strange thing is that the line is painted only if its height (the height of the clutter actor) is less than about 8000. When in "get_preferred_height" I set a natural_height and a minimum height of 9000-10000, the line is not painted.
What I'm doing wrong? Is there a limit for the height of an ClutterCairoTexture? I don't think so, but I can't find the error.
Here's the code:

private class Journal.VTimeline : Clutter.CairoTexture {

    private Gee.ArrayList<int> point_circle;
    private const int len_arrow = 20; // hardcoded
    private const int arrow_origin = 30;
    private const int timeline_width = 2;
    private const int radius = 6;
    
    public VTimeline () {
        this.point_circle = new Gee.ArrayList<int> ();
        this.auto_resize = true;
    }
    
    public void add_circle (int y) {
        this.point_circle.add (y + arrow_origin - len_arrow / 2 + radius * 2 - 2); 
    }
    
    public override bool draw (Cairo.Context ctx) {
        var bg =  Utils.get_timeline_bg_color ();
        Clutter.Color backgroundColor = Utils.gdk_rgba_to_clutter_color (bg);
        var color = Utils.get_timeline_circle_color ();
        Clutter.Color circleColor = Utils.gdk_rgba_to_clutter_color (color);

        var cr = ctx;
        this.clear ();
        uint height, width;
        get_surface_size (out width, out height);
        //Draw the timeline
        Clutter.cairo_set_source_color(cr, backgroundColor);
        ctx.rectangle (radius, 0, timeline_width , height);
        ctx.fill ();
        
        //Draw circles
        foreach (int y in point_circle) {
            // Paint the border cirle to start with.
            Clutter.cairo_set_source_color(cr, backgroundColor);
            ctx.arc (radius + timeline_width / 2 , y, radius, 0, 2*Math.PI);
            ctx.stroke ();
            // Paint the colored cirle to start with.
            Clutter.cairo_set_source_color(cr, circleColor);
            ctx.arc (radius + timeline_width / 2, y, radius - 1, 0, 2*Math.PI);
            ctx.fill ();
        }

        return true;
        }
        
  
   public override void get_preferred_width (float for_height,out float min_width, out float nat_width) {
       nat_width = min_width = 2 * radius + timeline_width;
   }
   
   public override void get_preferred_height (float for_width,out float min_height, out float nat_height) {
       nat_height = min_height = 8000;
   }


Thanks in advance.
Cheers,

Stefano 

P.S. Obviously my goal is not to hardcode the height value in the "get_preferred_height" method, but to constraint it to its parent actor that dynamically grows in height, using a BindCostraint. I've already tried it but the problem is the same: when the parent actor become too much "tall" the line disappears.

_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list
Amy C | 14 May 14:30
Picon
Gravatar

Clutter Clone not displaying

Hi all,

I've successfully made a Clutter.Texture & displayed it, and am trying
to now make a Clutter.Clone of it and display that.
However, the Clutter.Clone does not appear on the window (the Texture does).

Here is a minimal working example of my code using Clutter.Rectangle
instead of Clutter.Clone (for ease of running). I'm using Clutter's
gobject introspection bindings (in javascript in my case).

Could anyone tell me why the first Clutter.Rectangle is visible, but I
can't see its Clutter.Clone?

cheers!

-------------- START CODE (can run with `gjs file.js`) ----------------
const Clutter = imports.gi.Clutter;
Clutter.init(null);

var Stage = Clutter.Stage.new();
Stage.set_size( 200, 200 );
Stage.show()

/* create a rectangle */
let blue = new Clutter.Color({blue: 255, red:0, green:0, alpha:255});
let rect = new Clutter.Rectangle();
rect.set_color( blue );
rect.set_size( 50, 50 );
rect.set_position( 20, 20 );
Stage.add_actor( rect );
rect.show(); // this works; I can see the rectangle

/* create a clone of the rectangle */
let clone = new Clutter.Clone(rect);
clone.set_position(100,100);
Stage.add_actor( clone );
clone.show();  // this runs without error, but I do not see any second
rectangle!

Clutter.main();
-------------- END CODE ----------------
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Amy C | 12 May 08:31
Picon
Gravatar

Clutter Textures & efficiency

Hi all,

A bit of background to explain my question:

I'm currently writing a port of xpenguins in Clutter/gnome javascript
bindings (just for a bit of fun).
The idea is that I wish to spawn many toons (penguins) on the screen.
Each toon is basically a Clutter.Texture. It is 'animated' in the
sense that it has a single image (like a cartoon) and animation is
simulated by sliding the actor's clip box over each frame of the
cartoon.

However, even though there may be many (say 50) toons on the screen,
there are only (say) 5 different *types* of toon: each individual toon
is either a walker, runner, cycler, floater, or skateboarder. Each
type of toon has its own little filmstrip image to represent its
animation.

Now, I could spawn each of the 50 toons by having each *individual*
toon store a copy of its filmstrip image. This seems easiest (each
toon is just a Clutter.Texture), but also seems inefficient.

The way the original XPenguins does it and the way I'd like to try, is
to have some central ToonData object, one per type of toon. So in my
example I'll have 5 of them. Each ToonData has its image filmstrip
loaded up. Then, when an individual toon is drawn, it looks up the
ToonData corresponding to its type and picks out the frame of the
animation it is up to.

In this way, I only need to have 5 image filmstrips loaded up in
memory, instead of one filmstrip per toon.

My question is, how can I implement this situation? Could it be that
ToonData.image is a Clutter.Image, and each Toon is a Clutter.Texture,
but somehow each Toon stores a pointer to the corresponding
ToonData.image? How do I do that? I envisage someting like:

Toon.prototype = {
    __proto__: Clutter.Texture,
    _init: function() {
        // this.data is a pointer to the ToonData for the toon's type.
    }
    ...
}

var toon = new Toon();
Toon.set_image_pointer(  toon.data.image );

Is this possible? I basically want to just load the image once per
toon type rather than once per toon. Or do I have to make each Toon a
Clutter.Actor and somehow override the paint method to look up the
image & display?

Can anyone recommend how I can go about this?

cheers!
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

david.sale.75 | 12 May 07:28

Can not get actor width in the thread ?

Hi, all:

I write a test demo, use clutter_actor_get_width() get actor width, it is correct
if in the main thread call, but incorrect in then new thread.
used  clutter-1.6.20 and pango-1.28.4 and glib2-2.28.6

Pango:ERROR:pango-layout.c:3743:pango_layout_check_lines: assertion failed: (!layout->log_attrs)
The code is what problem? have any error?  Tks.

#include <glib.h>
#include <clutter/clutter.h>
ClutterActor *gStage, *acttext=NULL;
ClutterColor white = {255, 255, 255, 255};
ClutterColor black = {0, 0, 0, 0};

static gpointer test(gpointer data)
{
gfloat ww;
if (acttext)
clutter_container_remove_actor(CLUTTER_CONTAINER(gStage), acttext);
acttext = clutter_text_new_full("Monospace 20", (gchar*)data , &white);
clutter_text_set_single_line_mode(CLUTTER_TEXT(acttext), TRUE);
clutter_container_add_actor(CLUTTER_CONTAINER(gStage), acttext);
clutter_actor_set_position(acttext, 100, 100); 

//why not get width
//if use clutter_actor_get_width(acttext); 
//Pango:ERROR:pango-layout.c:3743:pango_layout_check_lines: assertion failed: (!layout->log_attrs)
clutter_actor_get_width(acttext); 
g_print("act width: %d \n", acttext);

}

int main(int argc, char* argv[])
{
GThread *threadid;
gchar text[128];
g_thread_init(NULL);
clutter_threads_init();
clutter_init(&argc, &argv);

gStage = clutter_stage_get_default();
clutter_actor_set_size(gStage, 600, 400);
clutter_stage_set_color(CLUTTER_STAGE(gStage), &black);
clutter_actor_show(gStage);
sprintf(text, "TEST TEST TEST TEST");
threadid = g_thread_create(test, (gpointer)text, FALSE, NULL);

clutter_main();

}

--------------
david.sale.75
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Moritz Renftle | 6 May 00:54

Applying two independent behaviours to an actor - alternative with implicit animations?

Hi folks,

my problem: i need to apply two independent animations to an actor:
1. turn around the z-axis infinitely within a given interval
2. ADDITIONALLY turn around the y-axis infinitely with a different speed, different mode ... at the same time

this works using the deprecated clutter.behaviour stuff, but i'd like to use implicit animations instead.
i tried:
actor.animatev(mode1, axis1, duration1, ...)
actor.animatev(mode2, axis2, duration2, ...)

this doesn't bring the expected result, it seems like the two animations are getting mixed up, sharing one
timeline and one animation mode, as the two movements happen in sync.
furthermore, i need to be able to add the y-axis-rotation some time after the z-axis-rotation, e.g. when
the user clicks the actor.
but doing this using the second line of the code above will actually reset the current animation to the
starting point and then start the "mixed" animation.

is there a solution for this problem? apart of using behaviours?

thanks for your support,
moritz

_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Stefan de Konink | 30 Apr 05:19
Picon
Gravatar

Raw access to seeking in ClutterMedia

Hi,

I figured out that ClutterMedia only supports seeking by a relative 
position between 0.0 - 1.0.

Is there any way to say: I want to seek to 10s?

Stefan
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list <at> clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list


Gmane