Ejemplo n.º 1
0
static void
make_ui (ClutterActor *stage)
{
  ClutterActor    *editable      = NULL;
  ClutterActor    *rectangle     = NULL;
  ClutterActor    *label         = NULL;
  ClutterColor     color_stage   = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor     color_text    = { 0xff, 0x00, 0x00, 0xff };
  ClutterColor     color_sel     = { 0x00, 0xff, 0x00, 0x55 };
  ClutterColor     color_label   = { 0x00, 0xff, 0x55, 0xff };
  ClutterColor     color_rect    = { 0x00, 0xff, 0xff, 0x55 };
  ClutterGeometry  editable_geom = {150, 50, 100, 75};
  ClutterActor    *full_entry    = NULL;
  ClutterActor    *cloned_entry  = NULL;


  clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  label = clutter_text_new_full ("Sans Bold 32px",
                                 "Entry",
                                 &color_label);
  clutter_actor_set_position (label, 0, 50);

  /* editable */
  editable = clutter_text_new_full ("Sans Bold 32px",
                                    "ddd",
                                    &color_text);
  clutter_actor_set_position (editable, 150, 50);
  clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
  clutter_text_set_selection_color (CLUTTER_TEXT (editable),
                                    &color_sel);
  clutter_actor_grab_key_focus (editable);
  clutter_actor_set_reactive (editable, TRUE);

  /* rectangle: to create a entry "feeling" */
  rectangle = clutter_rectangle_new_with_color (&color_rect);
  clutter_actor_set_geometry (rectangle, &editable_geom);

  full_entry = clutter_group_new ();
  clutter_actor_set_position (full_entry, 0, 50);
  clutter_actor_set_size (full_entry, 100, 75);
  clutter_group_add (CLUTTER_GROUP (full_entry), label);
  clutter_group_add (CLUTTER_GROUP (full_entry), editable);
  clutter_group_add (CLUTTER_GROUP (full_entry), rectangle);
  clutter_actor_show_all (full_entry);
  clutter_actor_set_scale (full_entry, 2, 1);
  clutter_group_add (CLUTTER_GROUP (stage), full_entry);

  /* Cloning! */
  cloned_entry = clutter_clone_new (full_entry);
  clutter_actor_set_position (cloned_entry, 50, 200);
  clutter_actor_set_scale (cloned_entry, 1, 2);
  clutter_actor_show_all (cloned_entry);
  clutter_actor_set_reactive (cloned_entry, TRUE);

  clutter_group_add (CLUTTER_GROUP (stage), cloned_entry);
}
Ejemplo n.º 2
0
static void
make_ui (ClutterActor *stage)
{
  gint             i             = 0;
  ClutterActor    *editable      = NULL;
  ClutterActor    *rectangle     = NULL;
  ClutterActor    *label         = NULL;
  ClutterColor     color_stage   = { 0x00, 0x00, 0x00, 0xff };
  ClutterColor     color_text    = { 0xff, 0x00, 0x00, 0xff };
  ClutterColor     color_sel     = { 0x00, 0xff, 0x00, 0x55 };
  ClutterColor     color_label   = { 0x00, 0xff, 0x55, 0xff };
  ClutterColor     color_rect    = { 0x00, 0xff, 0xff, 0x55 };
  ClutterGeometry  label_geom    = {0, 50, -1, -1};
  ClutterGeometry  editable_geom = {150, 50, 500, 75};


  clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  for (i = 0; i < NUM_ENTRIES; i++)
    {
      /* label */
      label = clutter_text_new_full ("Sans Bold 32px",
                                     "Entry",
                                     &color_label);
      clutter_actor_set_geometry (label, &label_geom);

      /* editable */
      editable = clutter_text_new_full ("Sans Bold 32px",
                                        "ddd",
                                        &color_text);
      clutter_actor_set_geometry (editable, &editable_geom);
      clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
      clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
      clutter_text_set_selection_color (CLUTTER_TEXT (editable),
                                        &color_sel);
      clutter_actor_grab_key_focus (editable);
      clutter_actor_set_reactive (editable, TRUE);

      /* rectangle: to create a entry "feeling" */
      rectangle = clutter_rectangle_new_with_color (&color_rect);
      clutter_actor_set_geometry (rectangle, &editable_geom);

      clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable);
      clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);

      label_geom.y += HEIGHT_STEP;
      editable_geom.y += HEIGHT_STEP;
    }
}
Ejemplo n.º 3
0
static ClutterActor *
make_button (char *text)
{
  ClutterActor *button, *button_bg, *button_text;
  ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
  ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
  gfloat width, height;

  button = clutter_actor_new ();

  button_bg = clutter_actor_new ();
  clutter_actor_set_background_color (button_bg, &white);
  clutter_actor_add_child (button, button_bg);
  clutter_actor_set_opacity (button_bg, 0xcc);

  button_text = clutter_text_new_full ("Sans 10", text, &black);
  clutter_actor_add_child (button, button_text);
  clutter_actor_get_size (button_text, &width, &height);

  clutter_actor_set_size (button_bg, width + PADDING * 2, height + PADDING * 2);
  clutter_actor_set_position (button_bg, 0, 0);
  clutter_actor_set_position (button_text, PADDING, PADDING);

  return button;
}
Ejemplo n.º 4
0
G_MODULE_EXPORT gint
test_text_main (gint    argc,
                gchar **argv)
{
  ClutterActor *stage;
  ClutterActor *text;
  ClutterColor  text_color       = { 0x33, 0xff, 0x33, 0xff };
  ClutterColor  cursor_color     = { 0xff, 0x33, 0x33, 0xff };
  ClutterColor  background_color = { 0x00, 0x00, 0x00, 0xff };

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);

  text = clutter_text_new_full (FONT, "·", &text_color);

  clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL);
  clutter_actor_set_position (text, 40, 30);
  clutter_actor_set_width (text, 1024);
  clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE);

  clutter_actor_set_reactive (text, TRUE);
  clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text);

  clutter_text_set_editable (CLUTTER_TEXT (text), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE);
  clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color);

  if (argv[1])
    {
      GError *error = NULL;
      gchar *utf8;

      g_file_get_contents (argv[1], &utf8, NULL, &error);
      if (error)
        {
          utf8 = g_strconcat ("Unable to open '", argv[1], "':\n",
                              error->message,
                              NULL);
          g_error_free (error);
        }

      clutter_text_set_text (CLUTTER_TEXT (text), utf8);
    }
  else
    clutter_text_set_text (CLUTTER_TEXT (text), runes);

  clutter_actor_set_size (stage, 1024, 768);
  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
static
gboolean
action_add_text (ClutterActor *action,
                 ClutterEvent *event,
                 gpointer      userdata)
{
  ClutterActor *group = CLUTTER_ACTOR (userdata);
  ClutterActor *title;
  ClutterColor  color;

  clutter_color_from_string (&color, "#888");

  title = clutter_text_new_full ("Sans 30px", "fnord", &color);

  clutter_actor_set_position (title, event->button.x, event->button.y);
  clutter_group_add (CLUTTER_GROUP (group), title);
  return FALSE;
}
Ejemplo n.º 6
0
void
gmc_button_set_label (GmcButton *self, const gchar *label)
{
  GmcButtonPrivate *priv;
  ClutterColor *color;

  priv = GMC_BUTTON_GET_PRIVATE (self);

  if (priv->label) {
    if (g_strcmp0 (label, clutter_text_get_text (CLUTTER_TEXT (priv->label))) == 0)
      return;
    clutter_text_set_text (CLUTTER_TEXT (priv->label), label);
    return;
  }

  color = clutter_color_new (0x80, 0x80, 0x80, 0xff);
  priv->label = clutter_text_new_full ("Comic Sans MS 12", label, color);
  clutter_actor_set_parent (priv->label, CLUTTER_ACTOR (self));
  clutter_color_free (color);
}
static ClutterActor*
_create_button (const gchar *text)
{
  ClutterActor *button     = NULL;
  ClutterActor *rectangle  = NULL;
  ClutterActor *label      = NULL;

  button = clutter_group_new ();
  rectangle = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
  clutter_actor_set_size (rectangle, 375, 35);

  label = clutter_text_new_full ("Sans Bold 32px",
                                 text,
                                 CLUTTER_COLOR_Black);
  clutter_container_add_actor (CLUTTER_CONTAINER (button), rectangle);
  clutter_container_add_actor (CLUTTER_CONTAINER (button), label);
  clutter_actor_set_reactive (button, TRUE);

  return button;
}
Ejemplo n.º 8
0
static ClutterActor*
_create_button (const gchar *text)
{
  ClutterActor *button     = NULL;
  ClutterActor *rectangle  = NULL;
  ClutterActor *label      = NULL;
  ClutterColor  color_rect = { 0x00, 0xff, 0xff, 0xff };
  ClutterColor  color_label = { 0x00, 0x00, 0x00, 0xff };

  button = clutter_group_new ();
  rectangle = clutter_rectangle_new_with_color (&color_rect);
  clutter_actor_set_size (rectangle, 375, 35);

  label = clutter_text_new_full ("Sans Bold 32px",
                                 text, &color_label);
  clutter_group_add (CLUTTER_GROUP (button), rectangle);
  clutter_group_add (CLUTTER_GROUP (button), label);
  clutter_actor_set_reactive (button, TRUE);

  return button;
}
Ejemplo n.º 9
0
static ClutterActor *
make_button (char *text)
{
  ClutterActor *button, *button_bg, *button_text;
  ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
  ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
  gfloat width, height;

  button = clutter_group_new ();

  button_bg = clutter_rectangle_new_with_color (&white);
  clutter_container_add_actor (CLUTTER_CONTAINER (button), button_bg);
  clutter_actor_set_opacity (button_bg, 0xcc);

  button_text = clutter_text_new_full ("Sans 10", text, &black);
  clutter_container_add_actor (CLUTTER_CONTAINER (button), button_text);
  clutter_actor_get_size (button_text, &width, &height);

  clutter_actor_set_size (button_bg, width + PADDING * 2, height + PADDING * 2);
  clutter_actor_set_position (button_bg, 0, 0);
  clutter_actor_set_position (button_text, PADDING, PADDING);

  return button;
}
Ejemplo n.º 10
0
static ClutterActor *
create_entry (const ClutterColor *color,
              const gchar        *text,
              PangoAttrList      *attrs,
              gunichar            password_char,
              gint                max_length)
{
  ClutterActor *retval = clutter_text_new_full (NULL, text, color);
  ClutterColor selection = { 0, };
  ClutterColor selected_text = { 0x00, 0x00, 0xff, 0xff };

  clutter_actor_set_reactive (retval, TRUE);

  clutter_color_darken (color, &selection);

  clutter_text_set_editable (CLUTTER_TEXT (retval), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (retval), TRUE);
  clutter_text_set_activatable (CLUTTER_TEXT (retval), TRUE);
  clutter_text_set_single_line_mode (CLUTTER_TEXT (retval), TRUE);
  clutter_text_set_password_char (CLUTTER_TEXT (retval), password_char);
  clutter_text_set_cursor_color (CLUTTER_TEXT (retval), &selection);
  clutter_text_set_max_length (CLUTTER_TEXT (retval), max_length);
  clutter_text_set_selected_text_color (CLUTTER_TEXT (retval), &selected_text);
  clutter_actor_set_background_color (retval, CLUTTER_COLOR_LightGray);
  if (attrs)
    clutter_text_set_attributes (CLUTTER_TEXT (retval), attrs);

  g_signal_connect (retval, "activate",
                    G_CALLBACK (on_entry_activate),
                    NULL);
  g_signal_connect (retval, "captured-event",
                    G_CALLBACK (on_captured_event),
                    NULL);

  return retval;
}
Ejemplo n.º 11
0
int main(int argc, char *argv[])
{
    ClutterActor *stage;
    WebKitWebView *web_view;
    
    ClutterConstraint *width_binding;
    ClutterConstraint *height_binding;
    ClutterConstraint *web_view_height_binding;
    
    gfloat stageWidth, stageHeight;
    ClutterActorBox stageAllocation;
    
    ClutterLayoutManager  *mainLayout;
    ClutterActor          *mainLayoutContainer;
    ClutterLayoutManager  *toolbarLayout;
    ClutterActor          *toolbarContainer;
    ClutterLayoutManager  *toolbarBinLayout;
    ClutterActor          *toolbarBinContainer;
    ClutterActor          *toolbarBgr;
    ClutterActor          *statusBar;
    ClutterActor *backFwdBtns;
    ClutterActor *backBtn;
    ClutterActor *fwdBtn;
    ClutterActor *uriGroup;
    ClutterActor *uriBgr;
    ClutterActor *uriText;
    ClutterActor *spacer;
    
    GError *error = NULL;
    
    ClutterColor whiteColor = { 255, 255, 255, 255 };
    ClutterColor blackColor = { 0, 0, 0, 255 };
    ClutterColor grayColor =  { 200, 200, 200, 255 };
    ClutterColor transparentColor = { 0, 0, 0, 0 };
    
    gchar *toolbarBgrPath = clutter_launcher_file_path("toolbar_bgr.png");
    gchar *backBtnPath = clutter_launcher_file_path("back_btn.png");
    gchar *fwdBtnPath = clutter_launcher_file_path("fwd_btn.png");
    
    g_thread_init(NULL);
    clutter_threads_init();
    
    clutter_init(&argc, &argv);
    
    stage = clutter_stage_get_default();
    clutter_actor_set_size(stage, 1024, 768);
    clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color);
    g_signal_connect (stage, "destroy", G_CALLBACK(clutter_main_quit), NULL);
    
    /* make the stage resizable */
    clutter_stage_set_user_resizable(CLUTTER_STAGE(stage), TRUE);
    
    clutter_actor_show(stage);
    
    mainLayout = clutter_box_layout_new();
    clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(mainLayout), TRUE);
    
    
    clutter_actor_get_allocation_box(stage, &stageAllocation);
    stageWidth = stageAllocation.x2 - stageAllocation.x1;
    stageHeight = stageAllocation.y2 - stageAllocation.y1;
    
    web_view = WEBKIT_WEB_VIEW(webkit_web_view_new((guint)stageWidth, (guint)stageHeight - (toolbarHeight + statusBarHeight)));
    g_object_set(web_view, "reactive", TRUE, NULL);
    
    mainLayoutContainer = clutter_box_new(mainLayout);
    clutter_actor_set_size(mainLayoutContainer, stageWidth, stageHeight);
    
    width_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_WIDTH, 0);
    height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, 0);
/*    web_view_height_binding = clutter_bind_constraint_new(stage, CLUTTER_BIND_HEIGHT, -(toolbarHeight + statusBarHeight));
  */  
    clutter_actor_add_constraint(mainLayoutContainer, width_binding);
    clutter_actor_add_constraint(mainLayoutContainer, height_binding);
/*    clutter_actor_add_constraint(CLUTTER_ACTOR(web_view), web_view_height_binding);
  */  
    toolbarBinLayout = clutter_bin_layout_new(CLUTTER_BIN_ALIGNMENT_FILL, CLUTTER_BIN_ALIGNMENT_CENTER);
    toolbarBinContainer = clutter_box_new(toolbarBinLayout);
    
    toolbarBgr = clutter_texture_new_from_file(toolbarBgrPath, &error);
    if (toolbarBgr == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", toolbarBgrPath);
      exit(1);
    }
    clutter_actor_set_height(toolbarBgr, toolbarHeight);
    clutter_texture_set_repeat(CLUTTER_TEXTURE(toolbarBgr), TRUE, FALSE);
    clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarBgr, NULL, NULL);
    
    toolbarLayout = clutter_box_layout_new();
    clutter_box_layout_set_vertical(CLUTTER_BOX_LAYOUT(toolbarLayout), FALSE);
    clutter_box_layout_set_spacing(CLUTTER_BOX_LAYOUT(toolbarLayout), 16);
    toolbarContainer = clutter_box_new(toolbarLayout);
    
    spacer = clutter_rectangle_new_with_color(&transparentColor);
    clutter_actor_set_size(spacer, 1, 1);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), spacer, NULL, NULL);
    
    backFwdBtns = clutter_group_new();
    
    backBtn = clutter_texture_new_from_file(backBtnPath, &error);
    if (backBtn == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", backBtnPath);
      exit(1);
    }
    clutter_actor_set_reactive(backBtn, TRUE);
    /* connect the release event */
    g_signal_connect (backBtn,
                      "button-release-event",
                      G_CALLBACK (on_back_release_cb),
                      web_view);
    
    fwdBtn = clutter_texture_new_from_file(fwdBtnPath, &error);
    if (fwdBtn == NULL) {
      fprintf(stderr, "Can't load file: %s. Aborting...\n", fwdBtnPath);
      exit(1);
    }
    clutter_actor_set_reactive(fwdBtn, TRUE);
    /* connect the release event */
    g_signal_connect (fwdBtn,
                      "button-release-event",
                      G_CALLBACK (on_fwd_release_cb),
                      web_view);
    
    clutter_actor_set_position(fwdBtn, 
                               clutter_actor_get_width(backBtn), 0);
    clutter_container_add(CLUTTER_CONTAINER(backFwdBtns), backBtn, fwdBtn, NULL);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), backFwdBtns, NULL, NULL);
    
    uriGroup = clutter_group_new();
    
    uriBgr = clutter_rectangle_new_with_color(&whiteColor);
    clutter_rectangle_set_border_color(CLUTTER_RECTANGLE(uriBgr), &blackColor);
    clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(uriBgr), 1);
    clutter_actor_set_size(uriBgr, 400, 25);
    
    uriText = clutter_text_new_full("Helvetica 11px", "http://www.google.com", &blackColor);
    clutter_text_set_editable(CLUTTER_TEXT(uriText), TRUE);
    clutter_text_set_single_line_mode(CLUTTER_TEXT(uriText), TRUE);
    clutter_actor_set_position(uriText, 5, 7);
    clutter_actor_set_size(uriText, 390, 17);
    clutter_actor_set_reactive(uriText, TRUE);
    g_signal_connect(uriText, "activate", G_CALLBACK(on_uri_activate_cb), web_view);
    
    clutter_container_add(CLUTTER_CONTAINER(uriGroup), uriBgr, uriText, NULL);
    clutter_box_pack(CLUTTER_BOX(toolbarContainer), uriGroup, NULL, NULL);
    
    clutter_box_pack(CLUTTER_BOX(toolbarBinContainer), toolbarContainer, NULL, NULL);
    
    clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), toolbarBinContainer, 
                     "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), toolbarBinContainer, TRUE, FALSE);
    
    statusBar = clutter_rectangle_new_with_color(&grayColor);
    clutter_actor_set_height(statusBar, statusBarHeight);
    
    clutter_box_pack(CLUTTER_BOX(mainLayoutContainer), statusBar, 
                     "y-align", CLUTTER_BOX_ALIGNMENT_END, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), statusBar, TRUE, FALSE);
    
    clutter_box_pack_after(CLUTTER_BOX(mainLayoutContainer), CLUTTER_ACTOR(web_view), toolbarBinContainer, 
                           "y-align", CLUTTER_BOX_ALIGNMENT_START, NULL);
    clutter_box_layout_set_expand(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE);
    clutter_box_layout_set_fill(CLUTTER_BOX_LAYOUT(mainLayout), CLUTTER_ACTOR(web_view), TRUE, TRUE);

    clutter_container_add(CLUTTER_CONTAINER(stage), mainLayoutContainer, NULL);
    
    g_signal_connect(web_view, "webkit-load-finished", G_CALLBACK(load_finished_cb), web_view);
    g_signal_connect(web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view);
    /*    g_signal_connect(stage, "delete-event", G_CALLBACK(delete_cb), web_view);*/
    g_signal_connect(web_view, "notify::uri", G_CALLBACK(notify_uri_cb), uriText);
    
    gchar *uri = (gchar*) (argc > 1 ? argv[1] : "http://www.google.com/");
    gchar *fileURL = filenameToURL(uri);

    webkit_web_view_load_uri(web_view, fileURL ? fileURL : uri);
    printf("%s\n", fileURL ? fileURL : uri);
    g_free(fileURL);
        
    g_timeout_add_full(G_PRIORITY_DEFAULT, 3000, timeout_cb, web_view, 0);
    
    clutter_threads_enter ();
    clutter_main();
    clutter_threads_leave ();
    
    return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterLayoutManager *layout;
  ClutterActor *box;
  ClutterActor *rect;
  ClutterActor *text;
  ClutterState *transitions;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "btn");
  clutter_actor_set_background_color (stage, &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FILL,
                                   CLUTTER_BIN_ALIGNMENT_FILL);

  box = clutter_actor_new ();
  clutter_actor_set_layout_manager (box, layout);
  clutter_actor_set_position (box, 25, 25);
  clutter_actor_set_reactive (box, TRUE);
  clutter_actor_set_size (box, 100, 30);

  /* background for the button */
  rect = clutter_rectangle_new_with_color (&yellow);
  clutter_actor_add_child (box, rect);

  /* text for the button */
  text = clutter_text_new_full ("Sans 10pt", "Hover me", &white);

  /*
   * NB don't set the height, so the actor assumes the height of the text;
   * then when added to the bin layout, it gets centred on it;
   * also if you don't set the width, the layout goes gets really wide;
   * the 10pt text fits inside the 30px height of the rectangle
   */
  clutter_actor_set_width (text, 100);
  clutter_bin_layout_add (CLUTTER_BIN_LAYOUT (layout),
                          text,
                          CLUTTER_BIN_ALIGNMENT_CENTER,
                          CLUTTER_BIN_ALIGNMENT_CENTER);

  /* animations */
  transitions = clutter_state_new ();
  clutter_state_set (transitions, NULL, "fade-out",
                     box, "opacity", CLUTTER_LINEAR, 180,
                     NULL);

 /*
  * NB you can't use an easing mode where alpha > 1.0 if you're
  * animating to a value of 255, as the value you're animating
  * to will possibly go > 255
  */
  clutter_state_set (transitions, NULL, "fade-in",
                     box, "opacity", CLUTTER_LINEAR, 255,
                     NULL);

  clutter_state_set_duration (transitions, NULL, NULL, 50);

  clutter_state_warp_to_state (transitions, "fade-out");

  g_signal_connect (box,
                    "enter-event",
                    G_CALLBACK (_pointer_enter_cb),
                    transitions);

  g_signal_connect (box,
                    "leave-event",
                    G_CALLBACK (_pointer_leave_cb),
                    transitions);

  /* bind the stage size to the box size + 50px in each axis */
  clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_HEIGHT, 50.0));
  clutter_actor_add_constraint (stage, clutter_bind_constraint_new (box, CLUTTER_BIND_WIDTH, 50.0));

  clutter_actor_add_child (stage, box);

  clutter_actor_show (stage);

  clutter_main ();

  g_object_unref (transitions);

  return 0;
}
Ejemplo n.º 13
0
int
main (int argc, char *argv[])
{
  ClutterActor    *stage;
  ClutterColor     stage_color = { 0x34, 0x39, 0x39, 0xff };
  ClutterColor     white = { 0x72, 0x9f, 0xcf, 0xff };
  gint             i = 0;
  Item            *item;
  App             *app;
  gdouble          ang = 0.0;
  ClutterBehaviour *behave;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 800, 600);

  app = g_new0(App, 1);
  app->off = 0.0;
  app->timeline = clutter_timeline_new (300);
  app->alpha_sine_inc
    = clutter_alpha_new_full (app->timeline, CLUTTER_EASE_OUT_SINE);

  app->alpha_ramp
    = clutter_alpha_new_with_func (app->timeline, label_opacity_alpha_func,
                                   NULL, NULL);

  for (i=0; i<N_ITEMS; i++)
    {
      item = g_new0 (Item, 1);

      item->actor = clutter_texture_new_from_file (ItemDetails[i].img, NULL);
      if (!item->actor)
	g_error ("Unable to load '%s'", ItemDetails[i].img);

      clutter_group_add (CLUTTER_GROUP(stage), item->actor);

      item->ellipse_behave
	= clutter_behaviour_ellipse_new (app->alpha_sine_inc,
					 CSW()/4,   /* center x */
					 CSH() - (CSH()/3),   /* center y */
					 CSW()/2,   /* width */
					 CSH() - (CSH()/4),   /* height */
					 CLUTTER_ROTATE_CW,
					 ang,
					 ang + STEP);
      item->opacity_behave
	= clutter_behaviour_opacity_new (app->alpha_sine_inc, 0x66, 0x66);

      item->scale_behave
	= clutter_behaviour_scale_new (app->alpha_sine_inc,
				       0.6, 0.6, 0.6, 0.6);

      clutter_behaviour_apply (item->ellipse_behave, item->actor);
      clutter_behaviour_apply (item->opacity_behave, item->actor);
      clutter_behaviour_apply (item->scale_behave, item->actor);

      app->items = g_slist_append (app->items, item);

      ang += STEP;
    }

  app->label = clutter_text_new_full ("Bitstream Vera Sans 60px", "", &white);
  clutter_actor_set_position (app->label, CSW()/2 - 30, CSH()/3 - 40);
  clutter_group_add (CLUTTER_GROUP(stage), app->label);

  behave = clutter_behaviour_opacity_new (app->alpha_ramp, 0xff, 0);
  clutter_behaviour_apply (behave, app->label);

  g_signal_connect (app->timeline,
		    "new-frame",
		    G_CALLBACK(on_timeline_new_frame),
		    app);

  g_signal_connect (stage,
		    "event",
		    G_CALLBACK (on_input),
		    app);

  introduce_items (app);

  clutter_actor_show_all (stage);

  clutter_main();

  return 0;
}
Ejemplo n.º 14
0
static void
load_controls (UserInterface * ui)
{
  // Check icon files exist
  gchar *vid_panel_png;
  gchar *icon_files[6];
  gchar *duration_str;
  gint c;
  ClutterColor control_color1 = { 0x12, 0x12, 0x12, 0xff };
  ClutterColor control_color2 = { 0xcc, 0xcc, 0xcc, 0xff };
  ClutterLayoutManager *controls_layout;
  ClutterLayoutManager *main_box_layout;
  ClutterLayoutManager *info_box_layout;
  ClutterLayoutManager *bottom_box_layout;
  ClutterLayoutManager *volume_box_layout;
  ClutterLayoutManager *seek_box_layout;
  ClutterLayoutManager *vol_int_box_layout;
  ClutterActor *seek_box;
  ClutterActor *bottom_box;
  ClutterActor *vol_int_box;
  GError *error = NULL;

  vid_panel_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR, "/vid-panel.png");
  ui->play_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR,
      "/media-actions-start.png");
  ui->pause_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR,
      "/media-actions-pause.png");
  ui->volume_low_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR,
      "/audio-volume-low.png");
  ui->volume_high_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR,
      "/audio-volume-high.png");
  ui->segment_png = g_strdup_printf ("%s%s", SNAPPY_DATA_DIR,
      "/media-actions-segment-point.png");

  icon_files[0] = vid_panel_png;
  icon_files[1] = ui->play_png;
  icon_files[2] = ui->pause_png;
  icon_files[3] = ui->volume_low_png;
  icon_files[4] = ui->volume_high_png;
  icon_files[5] = ui->segment_png;

  for (c = 0; c < 6; c++) {
    if (!g_file_test (icon_files[c], G_FILE_TEST_EXISTS)) {
      g_print ("Icon file doesn't exist, are you sure you have "
          " installed snappy correctly?\nThis file needed is: %s\n",
          icon_files[c]);
    }
  }

  // Controls layout management
  controls_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED,
      CLUTTER_BIN_ALIGNMENT_FIXED);
  ui->control_box = clutter_box_new (controls_layout);

  // Controls background
  ui->control_bg = clutter_texture_new_from_file (vid_panel_png, &error);
  if (!ui->control_bg && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }

  g_free (vid_panel_png);
  clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box),
      ui->control_bg);

  // Controls play toggle
  main_box_layout = clutter_box_layout_new ();
  clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (main_box_layout), FALSE);
  ui->main_box = clutter_box_new (main_box_layout);

  ui->control_play_toggle =
      clutter_texture_new_from_file (ui->pause_png, &error);
  if (!ui->control_play_toggle && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }

  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout),
      ui->control_play_toggle,
      FALSE,                            /* expand */
      FALSE,                            /* x-fill */
      FALSE,                            /* y-fill */
      CLUTTER_BOX_ALIGNMENT_START,      /* x-align */
      CLUTTER_BOX_ALIGNMENT_CENTER);    /* y-align */
  clutter_container_add_actor (CLUTTER_CONTAINER (ui->control_box),
      ui->main_box);
  g_assert (ui->control_bg && ui->control_play_toggle);

  // Controls title
  info_box_layout = clutter_box_layout_new ();
  clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (info_box_layout), TRUE);

  ui->info_box = clutter_box_new (info_box_layout);

  ui->control_title = clutter_text_new_full ("Sans 32px",
      cut_long_filename (ui->filename, ui->title_length), &control_color1);
  clutter_text_set_max_length (CLUTTER_TEXT (ui->control_title),
      ui->title_length);
  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout),
      ui->control_title,
      TRUE,                             /* expand */
      FALSE,                            /* x-fill */
      FALSE,                            /* y-fill */
      CLUTTER_BOX_ALIGNMENT_CENTER,     /* x-align */
      CLUTTER_BOX_ALIGNMENT_START);     /* y-align */

  // Controls seek
  seek_box_layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED,
      CLUTTER_BIN_ALIGNMENT_FIXED);
  seek_box = clutter_box_new (seek_box_layout);

  // In point
  ui->in_point = clutter_texture_new_from_file (ui->segment_png, &error);
  if (!ui->in_point && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }
  clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->in_point);

  // background box rectangle shows as the border
  ui->control_seek1 = clutter_rectangle_new_with_color (&control_color1);
  clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek1);

  // smaller background rectangle inside seek1 to create a border
  ui->control_seek2 = clutter_rectangle_new_with_color (&control_color2);
  clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->control_seek2);

  // progress rectangle
  ui->control_seekbar = clutter_rectangle_new_with_color (&control_color1);
  clutter_container_add_actor (CLUTTER_CONTAINER (seek_box),
      ui->control_seekbar);

  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), seek_box,
      TRUE,                             /* expand */
      FALSE,                            /* x-fill */
      FALSE,                            /* y-fill */
      CLUTTER_BOX_ALIGNMENT_CENTER,     /* x-align */
      CLUTTER_BOX_ALIGNMENT_CENTER);    /* y-align */

  // Out point
  ui->out_point = clutter_texture_new_from_file (ui->segment_png, &error);
  if (!ui->out_point && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }
  clutter_container_add_actor (CLUTTER_CONTAINER (seek_box), ui->out_point);

  // Controls bottom box
  bottom_box_layout = clutter_box_layout_new ();
  clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (bottom_box_layout),
      FALSE);
  bottom_box = clutter_box_new (bottom_box_layout);

  // Controls volume box
  volume_box_layout = clutter_box_layout_new ();
  clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (volume_box_layout),
      FALSE);
  clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (volume_box_layout), 0);
  ui->volume_box = clutter_box_new (volume_box_layout);

  clutter_box_pack (CLUTTER_BOX (bottom_box), ui->volume_box,
      "x-align", CLUTTER_BOX_ALIGNMENT_START, "expand", TRUE, NULL);

  // Controls volume low
  ui->volume_low = clutter_texture_new_from_file (ui->volume_low_png, &error);
  if (!ui->volume_low && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }
  clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_low, "x-align",
      CLUTTER_BOX_ALIGNMENT_START, NULL);

  // Controls volume intensity
  vol_int_box_layout =
      clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED,
      CLUTTER_BIN_ALIGNMENT_FIXED);
  vol_int_box = clutter_box_new (vol_int_box_layout);

  ui->vol_int_bg = clutter_rectangle_new_with_color (&control_color1);
  clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int_bg);

  ui->vol_int = clutter_rectangle_new_with_color (&control_color1);
  clutter_container_add_actor (CLUTTER_CONTAINER (vol_int_box), ui->vol_int);

  clutter_box_pack (CLUTTER_BOX (ui->volume_box), vol_int_box,
      "x-fill", FALSE,
      "y-fill", FALSE, "y-align", CLUTTER_BOX_ALIGNMENT_CENTER, NULL);

  // Controls volume high
  ui->volume_high = clutter_texture_new_from_file (ui->volume_high_png, &error);
  if (!ui->volume_high && error)
    g_debug ("Clutter error: %s\n", error->message);
  if (error) {
    g_error_free (error);
    error = NULL;
  }
  clutter_box_pack (CLUTTER_BOX (ui->volume_box), ui->volume_high, "x-align",
      CLUTTER_BOX_ALIGNMENT_END, NULL);

  // Controls position text
  duration_str = g_strdup_printf ("   0:00:00/%s", ui->duration_str);
  ui->control_pos = clutter_text_new_full ("Sans 22px", duration_str,
      &control_color1);
  clutter_box_pack (CLUTTER_BOX (bottom_box), ui->control_pos,
      "x-align", CLUTTER_BOX_ALIGNMENT_END, "expand", TRUE, NULL);

  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (info_box_layout), bottom_box,
      TRUE,                             /* expand */
      FALSE,                            /* x-fill */
      FALSE,                            /* y-fill */
      CLUTTER_BOX_ALIGNMENT_CENTER,     /* x-align */
      CLUTTER_BOX_ALIGNMENT_END);       /* y-align */

  clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (main_box_layout), ui->info_box,
      FALSE,                            /* expand */
      TRUE,                             /* x-fill */
      FALSE,                            /* y-fill */
      CLUTTER_BOX_ALIGNMENT_END,        /* x-align */
      CLUTTER_BOX_ALIGNMENT_CENTER);    /* y-align */

  clutter_actor_lower_bottom (ui->control_bg);

  size_change (CLUTTER_STAGE (ui->stage), ui);
}
Ejemplo n.º 15
0
EaseWelcomeActor* ease_welcome_actor_construct (GType object_type, EaseTheme* t) {
#line 152 "ease-welcome-actor.c"
	EaseWelcomeActor * self;
	ClutterRectangle* _tmp0_;
	ClutterColor _tmp1_;
	ClutterColor _tmp2_;
	ClutterRectangle* _tmp3_;
	ClutterColor _tmp4_ = {0};
	ClutterColor _tmp5_;
	ClutterColor _tmp6_;
	ClutterText* _tmp7_;
	ClutterCairoTexture* _tmp8_;
#line 94 "ease-welcome-actor.vala"
	g_return_val_if_fail (t != NULL, NULL);
#line 165 "ease-welcome-actor.c"
	self = g_object_newv (object_type, 0, NULL);
#line 96 "ease-welcome-actor.vala"
	ease_welcome_actor_set_theme (self, t);
#line 97 "ease-welcome-actor.vala"
	clutter_actor_set_reactive ((ClutterActor*) self, TRUE);
#line 100 "ease-welcome-actor.vala"
	self->priv->rect = (_tmp0_ = g_object_ref_sink ((ClutterRectangle*) clutter_rectangle_new ()), _g_object_unref0 (self->priv->rect), _tmp0_);
#line 101 "ease-welcome-actor.vala"
	clutter_rectangle_set_color (self->priv->rect, (_tmp1_ = EASE_WELCOME_ACTOR_RECT_BG, &_tmp1_));
#line 102 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_color (self->priv->rect, (_tmp2_ = EASE_WELCOME_ACTOR_RECT_B_C, &_tmp2_));
#line 103 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_width (self->priv->rect, (guint) EASE_WELCOME_ACTOR_RECT_B_W);
#line 104 "ease-welcome-actor.vala"
	clutter_actor_set_x ((ClutterActor*) self->priv->rect, (float) (-EASE_WELCOME_ACTOR_RECT_B_W));
#line 105 "ease-welcome-actor.vala"
	clutter_actor_set_y ((ClutterActor*) self->priv->rect, (float) (-EASE_WELCOME_ACTOR_RECT_B_W));
#line 106 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->rect);
#line 109 "ease-welcome-actor.vala"
	self->priv->hilight_rect = (_tmp3_ = g_object_ref_sink ((ClutterRectangle*) clutter_rectangle_new ()), _g_object_unref0 (self->priv->hilight_rect), _tmp3_);
#line 110 "ease-welcome-actor.vala"
	clutter_rectangle_set_color (self->priv->hilight_rect, (_tmp5_ = (_tmp4_.red = (guchar) 0, _tmp4_.green = (guchar) 0, _tmp4_.blue = (guchar) 0, _tmp4_.alpha = (guchar) 255, _tmp4_), &_tmp5_));
#line 111 "ease-welcome-actor.vala"
	clutter_actor_set_opacity ((ClutterActor*) self->priv->hilight_rect, (guint) 0);
#line 112 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_color (self->priv->hilight_rect, (_tmp6_ = EASE_WELCOME_ACTOR_HLRECT_C, &_tmp6_));
#line 113 "ease-welcome-actor.vala"
	clutter_rectangle_set_border_width (self->priv->hilight_rect, (guint) EASE_WELCOME_ACTOR_HLRECT_W);
#line 114 "ease-welcome-actor.vala"
	clutter_actor_set_x ((ClutterActor*) self->priv->hilight_rect, (float) (-EASE_WELCOME_ACTOR_HLRECT_W));
#line 115 "ease-welcome-actor.vala"
	clutter_actor_set_y ((ClutterActor*) self->priv->hilight_rect, (float) (-EASE_WELCOME_ACTOR_HLRECT_W));
#line 116 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->hilight_rect);
#line 119 "ease-welcome-actor.vala"
	self->priv->text = (_tmp7_ = g_object_ref_sink ((ClutterText*) clutter_text_new_full (EASE_WELCOME_ACTOR_FONT_NAME, self->priv->_theme->title, &EASE_WELCOME_ACTOR_TEXT_COLOR)), _g_object_unref0 (self->priv->text), _tmp7_);
#line 120 "ease-welcome-actor.vala"
	clutter_actor_set_height ((ClutterActor*) self->priv->text, EASE_WELCOME_ACTOR_TEXT_HEIGHT);
#line 121 "ease-welcome-actor.vala"
	clutter_text_set_line_alignment (self->priv->text, PANGO_ALIGN_RIGHT);
#line 122 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->text);
#line 125 "ease-welcome-actor.vala"
	self->priv->slide_actor = (_tmp8_ = g_object_ref_sink ((ClutterCairoTexture*) clutter_cairo_texture_new ((guint) 1024, (guint) 768)), _g_object_unref0 (self->priv->slide_actor), _tmp8_);
#line 126 "ease-welcome-actor.vala"
	clutter_container_add_actor ((ClutterContainer*) self, (ClutterActor*) self->priv->slide_actor);
#line 129 "ease-welcome-actor.vala"
	clutter_actor_set_opacity ((ClutterActor*) self, (guint) 0);
#line 130 "ease-welcome-actor.vala"
	clutter_actor_animate ((ClutterActor*) self, (gulong) EASE_WELCOME_ACTOR_FADE_EASE, (guint) EASE_WELCOME_ACTOR_FADE_INIT_TIME, "opacity", 255, NULL);
#line 133 "ease-welcome-actor.vala"
	g_signal_connect_object ((ClutterActor*) self, "button-press-event", (GCallback) __lambda55__clutter_actor_button_press_event, self, 0);
#line 219 "ease-welcome-actor.c"
	return self;
}
Ejemplo n.º 16
0
/* Update the clutter display with track information */
static gboolean update_display(ClutterActor *stage)
{
	static ClutterColor actor_color = { 0xff, 0xff, 0xff, 0xff };
	static ClutterActor *artist_text;
	static ClutterActor *album_text;
	static ClutterActor *title_text;
	static ClutterActor *time_text;
	char time_info[22];
	char time_data[80];

	if (mozart_get_player_state() != GST_STATE_PLAYING)
		return TRUE;

	if (!artist_text) {
		artist_text = clutter_text_new_full("Sans 14", "",
								&actor_color);
		clutter_actor_set_position(artist_text, 10, 0);
		clutter_container_add_actor(CLUTTER_CONTAINER(stage), 
								artist_text);
		clutter_actor_show(artist_text);
	}

	if (!album_text) {
		album_text = clutter_text_new_full("Sans 14", "",
								&actor_color);
		clutter_actor_set_position(album_text, 20, 22);
		clutter_container_add_actor(CLUTTER_CONTAINER(stage),
								album_text);
		clutter_actor_show(album_text);
	}

	if (!title_text) {
		title_text = clutter_text_new_full("Sans 14", "",
								&actor_color);
		clutter_actor_set_position(title_text, 30, 44);
		clutter_container_add_actor(CLUTTER_CONTAINER(stage),
								title_text);
		clutter_actor_show(title_text);
	}

	if (!time_text) {
		time_text = clutter_text_new_full("Sans 14", "",
								&actor_color);
		clutter_actor_set_position(time_text, 10, 100);
		clutter_container_add_actor(CLUTTER_CONTAINER(stage), 
								time_text);
		clutter_actor_show(time_text);
	}
	
	if (mozart_tags_updated()) {
		clutter_text_set_text(CLUTTER_TEXT(artist_text), 
						mozart_get_tag_artist());
		clutter_text_set_text(CLUTTER_TEXT(album_text),
						mozart_get_tag_album());
		clutter_text_set_text(CLUTTER_TEXT(title_text),
						mozart_get_tag_title());
		mozart_set_got_tags();
	}

	sprintf(time_data, "%s [%6.2f%%] [%2d / %d]", get_position(time_info),
						mozart_get_stream_progress(),
						mozart_get_playlist_position(),
						mozart_get_playlist_size());
	
	clutter_text_set_text(CLUTTER_TEXT(time_text), time_data);
	
	return TRUE;
}
static void
make_ui (ClutterActor *stage)
{
  ClutterActor *button      = NULL;

  clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEditable Test");
  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
  clutter_actor_set_size (stage, WIDTH, HEIGHT);

  /* text */
  text_actor = clutter_text_new_full ("Sans Bold 32px",
                                      "Lorem ipsum dolor sit amet",
                                      CLUTTER_COLOR_Red);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_actor);

  /* text_editable */
  text_editable_actor = clutter_text_new_full ("Sans Bold 32px",
                                               "consectetur adipisicing elit",
                                               CLUTTER_COLOR_Red);
  clutter_actor_set_position (text_editable_actor, 0, 100);
  clutter_text_set_editable (CLUTTER_TEXT (text_editable_actor), TRUE);
  clutter_text_set_selectable (CLUTTER_TEXT (text_editable_actor), TRUE);
  clutter_text_set_selection_color (CLUTTER_TEXT (text_editable_actor),
                                    CLUTTER_COLOR_Green);
  clutter_text_set_activatable (CLUTTER_TEXT (text_editable_actor),
                                TRUE);
  clutter_text_set_line_wrap (CLUTTER_TEXT (text_editable_actor), TRUE);
  clutter_actor_grab_key_focus (text_editable_actor);
  clutter_actor_set_reactive (text_editable_actor, TRUE);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), text_editable_actor);
  g_signal_connect (text_editable_actor, "activate",
                    G_CALLBACK (activate_cb), NULL);

  /* test buttons */
  button = _create_button ("Set");
  clutter_actor_set_position (button, 100, 200);

  g_signal_connect_after (button, "button-press-event",
                          G_CALLBACK (set_text_press_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);

  button = _create_button ("Delete");
  clutter_actor_set_position (button, 100, 250);

  g_signal_connect_after (button, "button-press-event",
                          G_CALLBACK (delete_text_press_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);

  button = _create_button ("Insert");
  clutter_actor_set_position (button, 100, 300);

  g_signal_connect_after (button, "button-press-event",
                          G_CALLBACK (insert_text_press_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);

  button = _create_button ("Activate/Deactivate");
  clutter_actor_set_position (button, 100, 350);

  g_signal_connect_after (button, "button-press-event",
                          G_CALLBACK (activate_deactivate_press_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);

  button = _create_button ("Cursor position");
  clutter_actor_set_position (button, 100, 450);

  g_signal_connect_after (button, "button-press-event",
                          G_CALLBACK (print_cursor_position_press_cb), NULL);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);

}
Ejemplo n.º 18
0
void
make_ui (App *app)
{
  gint          i, xpad, ypad, x ,y, xinit, xdpy, ydpy;
  ClutterActor *button_texture, *a;
  ClutterColor  text_color = { 0xff, 0xff, 0xff, 0xff },
                rect_color = { 0, 0, 0, 0x99 },
                black_color = { 0, 0, 0, 0xff };

  button_texture =  clutter_texture_new_from_file ("button.png", NULL);

  xpad = (CSW-(3*clutter_actor_get_width(button_texture)))/4;
  x = xinit = xpad;
  ypad = xpad/2;
  y = (CSH - (4 * (ypad + clutter_actor_get_height(button_texture))));

  /*
   * screen_dialpad (group)
   *  +----dpy (group)
   *        +---- (texture:display.png)
   *        +----dpy_entry (text)
   *        +----buttons[0:11]->actor (group)
   *              +---- (texture:button.png)
   *              +---- (text)
   */

  app->screen_dialpad = clutter_group_new();
  clutter_actor_set_size (app->screen_dialpad, CSW, CSH);
  clutter_actor_set_anchor_point_from_gravity (app->screen_dialpad, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (app->screen_dialpad, CSW/2, CSH/2);

  app->dpy = clutter_group_new();

  a = clutter_texture_new_from_file ("display.png", NULL);
  clutter_group_add (CLUTTER_GROUP(app->dpy), a);
  app->dpyx = xdpy = x;
  app->dpyy = ydpy = (y - clutter_actor_get_height(app->dpy))/2;
  clutter_actor_set_position (app->dpy, xdpy, ydpy);

  clutter_group_add(CLUTTER_GROUP(app->screen_dialpad), app->dpy);

  app->dpy_entry = clutter_text_new_full ("Sans Bold 32px", "", &text_color);
  clutter_text_set_editable (CLUTTER_TEXT(app->dpy_entry), TRUE);
  clutter_actor_set_position (app->dpy_entry, 8, 8);
  clutter_actor_set_size (app->dpy_entry, clutter_actor_get_width (app->dpy) - 16, 32);
  clutter_group_add (CLUTTER_GROUP(app->dpy), app->dpy_entry);

  for (i=0; i<12; i++)
    {
      gchar       buf[8];
      gchar       label[8];

      app->buttons[i] = g_new0(Button, 1);
      app->buttons[i]->actor = clutter_group_new ();
      g_snprintf (label, 8, "%d", i+1);
      clutter_actor_set_name (app->buttons[i]->actor, label);
      clutter_actor_set_reactive (app->buttons[i]->actor, TRUE);
      clutter_actor_set_anchor_point_from_gravity (app->buttons[i]->actor,
                                                   CLUTTER_GRAVITY_CENTER);
      
      if ( i == 0 )
        a = button_texture;
      else
        a = clutter_clone_new(button_texture);
      clutter_group_add(CLUTTER_GROUP(app->buttons[i]->actor), a);
      
      switch (i)
        {
        case 9:
          g_snprintf(buf, 8, "#");
          break;
        case 10:
          g_snprintf(buf, 8, "0");
          break;
        case 11:
          g_snprintf(buf, 8, "*");
          break;
        default:
          g_snprintf(buf, 8, "%i", i+1);
          break;
        }

      a = clutter_text_new_full("Sans Bold 32px", buf, &text_color);
      clutter_actor_set_position (a, 
        (clutter_actor_get_width (button_texture)  - clutter_actor_get_width (a))/2,
        (clutter_actor_get_height (button_texture) - clutter_actor_get_height (a))/2);
      clutter_group_add (CLUTTER_GROUP (app->buttons[i]->actor), a);

      clutter_group_add (CLUTTER_GROUP (app->screen_dialpad), app->buttons[i]->actor);

      /* need to remember positions for anim - sucky */
      app->buttons[i]->sx = x + clutter_actor_get_width (app->buttons[i]->actor)/2;
      app->buttons[i]->sy = y + clutter_actor_get_height (app->buttons[i]->actor)/2;
      clutter_actor_set_position (app->buttons[i]->actor,
                                  app->buttons[i]->sx,
                                  app->buttons[i]->sy);

      /* Really we should use a Clutter*Box here.. */
      if (i % 3 == 2)
        {
          x = xinit;
          y += (ypad + clutter_actor_get_height (button_texture));
        }
      else
        x += (xpad + clutter_actor_get_width(button_texture));

      app->buttons[i]->face = g_strdup (buf);
    }

    /*
     * screen_dial
     *  +---- (rectangle:black)
     *  +---- (texture:call-background.png)
     *  +---- (rectangle:semi transparent)
     *  +----dial_label (text:"Calling...")
     */

  app->screen_dial = clutter_group_new();
  clutter_actor_set_anchor_point_from_gravity (app->screen_dial, CLUTTER_GRAVITY_CENTER);
  clutter_actor_set_position (app->screen_dial, CSW/2, CSH/2);

  a = clutter_rectangle_new_with_color (&black_color);
  clutter_actor_set_size (a, CSW, CSH);
  clutter_group_add (CLUTTER_GROUP(app->screen_dial), a);

  a = clutter_texture_new_from_file ("call-background.png", NULL);
  clutter_group_add (CLUTTER_GROUP(app->screen_dial), a);

  a = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (a, CSW, CSH/6);
  clutter_actor_set_position (a, 0, (CSH - (CSH/6))/2);
  clutter_group_add (CLUTTER_GROUP(app->screen_dial), a);

  app->dial_label = clutter_text_new_full ("Sans Bold 32px", "Calling...", &text_color);
  clutter_actor_set_position (app->dial_label, 10, (CSH - (CSH/6))/2 + 10);
  clutter_group_add (CLUTTER_GROUP (app->screen_dial), app->dial_label);
}