Dang It....  IT Works Now.. in simplified form! :/    see code below.
Must be one of the Glade Containers i plop the GtkClutterEmbed contrin into. 
:/Hmmmm......
Anyways... i guess i'm stuck debugging it more. :)


#include <gtk/gtk.h>//#include <clutter/clutter.h>#include 
<clutter-gtk/clutter-gtk.h>
ClutterColor    stage_color = { 128, 128, 128, 255 };ClutterColor       
rectSelection_Color = { 255, 255, 255, 128 };ClutterColor       
rectSelection_borderColor = { 255, 255, 255, 200 };ClutterActor *rectSelection;
/*  make private  */gboolean bButtonPress = FALSE;gfloat rectX_Press = 0;gfloat 
rectY_Press = 0;guint nMouseMove_times = 0;
static gboolean on_stage_capture (ClutterActor *stage, ClutterEvent *event, 
gpointer  *dataptr);static uint ShowWindow(int argc, char *argv[]);
int main(int argc, char *argv[]) {
        /* Call gtk_clutter_init() to init both clutter and gtk+ */     if 
(gtk_clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS)             g_error 
("Unable to initialize GtkClutter");
        /*      if (argc != 2)  {               g_error ("Usage: example <image 
file>");                return 1;       }       */
        if( ShowWindow(argc, argv) != 0 )               g_error ("Unable to 
initialize GtkBuilder UI");
        gtk_main();
        return 0;}
static uint ShowWindow(int argc, char *argv[]){ GtkWidget* window = 
gtk_window_new( GTK_WINDOW_TOPLEVEL );      g_signal_connect( G_OBJECT(window), 
"destroy", G_CALLBACK(gtk_main_quit), NULL );       
gtk_window_set_default_size( GTK_WINDOW( window ), 1024, 768 );
        // Create ClutterEmbed widget for the stage:    GtkWidget *embed1 = 
gtk_clutter_embed_new();    gtk_container_add( GTK_CONTAINER( window ), embed1 
);   gtk_widget_set_size_request( embed1, 1024, 768);        gtk_widget_show( 
embed1 );
        // get the Default Stage from ClutterEmbed widget:      ClutterActor 
*stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED (embed1));  
g_signal_connect( stage, "captured-event", G_CALLBACK (on_stage_capture), NULL 
);       clutter_stage_set_title( CLUTTER_STAGE( stage ), "MyDrawArea" );       
 clutter_stage_set_color(CLUTTER_STAGE (stage), &stage_color);   
clutter_actor_set_size(stage, 1024, 768);       
clutter_actor_set_position(stage, 0, 0);
        // Load image from first command line argument and add it to viewport:  
//ClutterActor *texture1 = clutter_texture_new_from_file( 
"/home/izzy/Pictures/stage.png", NULL );      // was argv[1]  
//clutter_container_add_actor( CLUTTER_CONTAINER( stage ), texture1 );  
//clutter_actor_set_position( texture1, 0, 0 );
        /* Must be added LAST.. has to be topmost */    rectSelection = 
clutter_rectangle_new_with_color( &rectSelection_Color );       
clutter_rectangle_set_border_width( CLUTTER_RECTANGLE( rectSelection ) , 1 );   
clutter_rectangle_set_border_color( CLUTTER_RECTANGLE( rectSelection ) , 
&rectSelection_borderColor );  clutter_actor_set_position( rectSelection , 0.f, 
0.f ); clutter_actor_set_size( rectSelection , 1.f, 1.f );     
clutter_actor_show( rectSelection );    clutter_container_add_actor( 
CLUTTER_CONTAINER( stage ), rectSelection );
        gtk_widget_show(window);
        return 0;}
static gboolean on_stage_capture (ClutterActor *stage, ClutterEvent *event, 
gpointer  *dataptr){        guint button_pressed = 0;       gfloat stage_x, 
stage_y;        gfloat newX = 0, newY = 0;      gfloat newW = 0, newH = 0;
        switch (event->type)    {       case CLUTTER_BUTTON_PRESS:
                if( bButtonPress == TRUE )                      break;
                clutter_event_get_coords( event, &stage_x, &stage_y );          
button_pressed = clutter_event_get_button (event);              g_debug 
("button %d Press", button_pressed);            rectX_Press = stage_x;          
rectY_Press = stage_y;          clutter_actor_set_position( rectSelection, 
stage_x, stage_y );          clutter_actor_set_size( rectSelection, 1.f, 1.f ); 
             clutter_actor_show( rectSelection );
                //clutter_grab_pointer( stage );
                bButtonPress = TRUE;            break;
        case CLUTTER_BUTTON_RELEASE:
                if( bButtonPress == FALSE )                     break;
                button_pressed = clutter_event_get_button (event);              
g_debug ("button %d Release", button_pressed);          rectX_Press = 0;        
        rectY_Press = 0;                bButtonPress = FALSE;
                clutter_actor_hide( rectSelection );
                //clutter_ungrab_pointer();
                break;
        case CLUTTER_MOTION:            clutter_event_get_coords( event, 
&stage_x, &stage_y );          //g_debug ("mouse moved..");
                if( bButtonPress )              {                       if( 
nMouseMove_times < 2 )                      {                               
nMouseMove_times++;                             break;                  }
                        if( stage_x > rectX_Press && stage_y > rectY_Press )    
        // bottom-right                 {                               newX = 
rectX_Press;                             newY = rectY_Press;                    
         newW = stage_x - rectX_Press;                           newH = stage_y 
- rectY_Press;                   }                       else if( stage_x < 
rectX_Press && stage_y < rectY_Press )       // top-left                     {  
                             newX = stage_x;                         newY = 
stage_y;                         newW = rectX_Press - stage_x;                  
         newH = rectY_Press - stage_y;                   }                      
 else if( stage_x > rectX_Press && stage_y < rectY_Press )               // 
top-right                    {                               newX = 
rectX_Press;                             newY = stage_y;                        
 newW = stage_x - rectX_Press;                           newH = rectY_Press - 
stage_y;                   }                       else if( stage_x < 
rectX_Press && stage_y > rectY_Press )               // bottom-left             
     {                               newX = stage_x;                         
newY = rectY_Press;                             newW = rectX_Press- stage_x;    
                        newH = stage_y - rectY_Press;                   }       
                else                            break;
                        clutter_actor_set_position( rectSelection, newX, newY 
);                        clutter_actor_set_size( rectSelection, newW, newH );
                        nMouseMove_times = 0;           }               break;
        default:                break;  }
        return TRUE;}


From: [email protected]
To: [email protected]
Subject: Mouse Movement in Stage
Date: Thu, 2 Jun 2011 23:30:09 -0400








Hi All...
Trying to Accomplish:    - Draw a Selection rectangle, like on the desktop, but 
in a GtkClutterEmbed stage.
Problem: - Top and Left allow for < 0 (values) for Mouse tracking, but bottom 
and right seem to constrain the mouse to the Stage width/height.
Question: - Is it possible to remove the Mouse input tracking constraint from 
the bottom and right sides?!?
An example can be provided if needed.
Thanks,Izzy.                                      

_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list                
                          
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to