[glide] Start implementing some geometry stuff



commit c7b431acf7f8c28e361863189cd4d307cc4943ec
Author: Robert Carr <racarr Valentine localdomain>
Date:   Sat May 1 22:58:44 2010 -0400

    Start implementing some geometry stuff

 src/glide-inspector-actor-priv.h |    5 ++
 src/glide-inspector-actor.c      |   81 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 85 insertions(+), 1 deletions(-)
---
diff --git a/src/glide-inspector-actor-priv.h b/src/glide-inspector-actor-priv.h
index 104fb99..cbc0ae7 100644
--- a/src/glide-inspector-actor-priv.h
+++ b/src/glide-inspector-actor-priv.h
@@ -29,6 +29,11 @@ struct _GlideInspectorActorPrivate
   GlideActor *actor;
   
   GtkWidget *name_entry;
+  
+  GtkWidget *x_spin;
+  GtkWidget *y_spin;
+  GtkWidget *width_spin;
+  GtkWidget *height_spin;
 };
 
 G_END_DECLS
diff --git a/src/glide-inspector-actor.c b/src/glide-inspector-actor.c
index 25bff64..20bb08a 100644
--- a/src/glide-inspector-actor.c
+++ b/src/glide-inspector-actor.c
@@ -33,6 +33,21 @@ enum {
 };
 
 static void
+glide_inspector_actor_update_geometry (GlideInspectorActor *ins)
+{
+  gfloat width, height;
+  gfloat x,y;
+  
+  clutter_actor_get_size (CLUTTER_ACTOR (ins->priv->actor), &width, &height);
+  clutter_actor_get_position (CLUTTER_ACTOR (ins->priv->actor), &x, &y);
+  
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->x_spin), x);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->y_spin), y);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->width_spin), width);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (ins->priv->height_spin), height);
+}
+
+static void
 glide_inspector_actor_update_name (GlideInspectorActor *ins)
 {
   gtk_entry_set_text (GTK_ENTRY (ins->priv->name_entry), clutter_actor_get_name (CLUTTER_ACTOR (ins->priv->actor)));
@@ -93,9 +108,70 @@ glide_inspector_actor_set_property (GObject *object,
 }
 
 static GtkWidget *
+glide_inspector_actor_make_geometry_control (GlideInspectorActor *ins, const gchar *text, GtkWidget **privloc)
+{
+  GtkWidget *ret = gtk_alignment_new (0,0,1,1);
+  GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+  GtkWidget *label = gtk_label_new(text);
+  // TODO: Range
+  GtkWidget *button = gtk_spin_button_new_with_range(0,1000,1);
+  
+  *privloc = button;
+
+  gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
+  
+  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+  
+  gtk_container_add (GTK_CONTAINER (ret),hbox);
+  return ret;
+}
+
+static GtkWidget *
+glide_inspector_actor_make_geometry_controls (GlideInspectorActor *ins)
+{
+  GtkWidget *ret = gtk_alignment_new (0.5,0,0.9,1);
+  GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
+  GtkWidget *hbox1;
+  
+  hbox1 = gtk_hbox_new (FALSE, 5);
+  
+  gtk_box_pack_start (GTK_BOX (hbox1), glide_inspector_actor_make_geometry_control (ins, "x:", &ins->priv->x_spin),
+		      TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox1), glide_inspector_actor_make_geometry_control (ins, "y:", &ins->priv->y_spin),
+		      TRUE, TRUE, 0);
+  
+  gtk_box_pack_start (GTK_BOX (vbox), hbox1, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), glide_inspector_actor_make_geometry_control (ins, "Width:", &ins->priv->width_spin),
+		      TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), glide_inspector_actor_make_geometry_control (ins, "Height:", &ins->priv->height_spin),
+		      TRUE, TRUE, 0);
+  
+  
+  gtk_container_add (GTK_CONTAINER (ret), vbox);
+  return ret;
+}
+
+static GtkWidget *
+glide_inspector_actor_make_geometry_box (GlideInspectorActor *ins)
+{
+  GtkWidget *ret = gtk_vbox_new (FALSE, 0);
+  GtkWidget *geometry_label = gtk_label_new (NULL);
+  GtkWidget *geometry_controls = glide_inspector_actor_make_geometry_controls (ins);
+  
+  gtk_label_set_markup (GTK_LABEL (geometry_label), "<b>Geometry:</b>");
+  gtk_misc_set_alignment (GTK_MISC (geometry_label), 0, 0);
+
+  gtk_box_pack_start (GTK_BOX (ret), geometry_label, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (ret), geometry_controls, FALSE, FALSE, 0);
+
+  return ret;
+}
+
+static GtkWidget *
 glide_inspector_actor_make_name_box (GlideInspectorActor *ins)
 {
-  GtkWidget *ret = gtk_hbox_new (FALSE, 10);
+  GtkWidget *ret = gtk_hbox_new (FALSE, 5);
   GtkWidget *name_label = gtk_label_new (NULL);
   GtkWidget *align = gtk_alignment_new (0, 0, 0.9, 1);
   
@@ -118,8 +194,10 @@ glide_inspector_actor_setup_ui (GlideInspectorActor *ins)
 {
   GtkWidget *vbox = gtk_vbox_new (FALSE, 2);
   GtkWidget *name_box = glide_inspector_actor_make_name_box (ins);
+  GtkWidget *geometry_box = glide_inspector_actor_make_geometry_box (ins);
   
   gtk_box_pack_start (GTK_BOX (vbox), name_box, FALSE, FALSE, 2);
+  gtk_box_pack_start (GTK_BOX (vbox), geometry_box, FALSE, FALSE, 2);
   
   gtk_container_add (GTK_CONTAINER (ins), vbox);
 }
@@ -182,6 +260,7 @@ glide_inspector_actor_set_actor (GlideInspectorActor *inspector,
     {
       gtk_widget_set_sensitive (GTK_WIDGET (inspector), TRUE);
       glide_inspector_actor_update_name (inspector);
+      glide_inspector_actor_update_geometry (inspector);
     }
   
   g_object_notify (G_OBJECT (inspector), "actor");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]