Merge commit 'origin/master' into cogl-material

Conflicts:

	clutter/clutter-texture.c
	clutter/cogl/cogl-texture.h
	clutter/cogl/gles/cogl-context.c
	clutter/cogl/gles/cogl-context.h
This commit is contained in:
Robert Bragg
2009-01-13 13:37:38 +00:00
80 changed files with 6668 additions and 5027 deletions

View File

@ -17,15 +17,15 @@ test_conformance_SOURCES = \
test-mesh-mutability.c \
test-path.c \
test-pick.c \
test-label-cache.c \
test-clutter-entry.c \
test-clutter-rectangle.c \
test-clutter-fixed.c \
test-actor-invariants.c \
test-paint-opacity.c \
test-backface-culling.c \
test-binding-pool.c \
$(NULL)
test-clutter-text.c \
test-text-cache.c \
$(NULL)
# For convenience, this provides a way to easily run individual unit tests:
.PHONY: wrappers clean-wrappers

View File

@ -1,370 +0,0 @@
#include <glib.h>
#include <clutter/clutter.h>
#include <string.h>
#include "test-conform-common.h"
typedef struct {
gunichar unichar;
const char bytes[6];
gint nbytes;
} TestData;
const TestData
test_data[] = {
{ 0xe4, "\xc3\xa4", 2 }, /* LATIN SMALL LETTER A WITH DIAERESIS */
{ 0x2665, "\xe2\x99\xa5", 3 } /* BLACK HEART SUIT */
};
void
test_entry_utf8_validation (TestConformSimpleFixture *fixture,
gconstpointer data)
{
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
gunichar unichar;
char bytes[6];
int nbytes;
g_assert (g_unichar_validate (t->unichar));
nbytes = g_unichar_to_utf8 (t->unichar, bytes);
bytes[nbytes] = '\0';
g_assert (nbytes == t->nbytes);
g_assert (memcmp (t->bytes, bytes, nbytes) == 0);
unichar = g_utf8_get_char_validated (bytes, nbytes);
g_assert (unichar == t->unichar);
}
}
static int
get_nbytes (ClutterEntry *entry)
{
const char *s = clutter_entry_get_text (entry);
return strlen (s);
}
static int
get_nchars (ClutterEntry *entry)
{
const char *s = clutter_entry_get_text (entry);
g_assert (g_utf8_validate (s, -1, NULL));
return g_utf8_strlen (s, -1);
}
#define DONT_MOVE_CURSOR (-2)
static void
insert_unichar (ClutterEntry *entry, gunichar unichar, int position)
{
if (position > DONT_MOVE_CURSOR)
{
clutter_entry_set_cursor_position (entry, position);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, position);
}
clutter_entry_insert_unichar (entry, unichar);
}
void
test_entry_empty (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
g_assert (clutter_entry_get_text (entry) == NULL);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_set_empty (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
/* annoyingly slightly different from initially empty */
clutter_entry_set_text (entry, "");
g_assert_cmpint (get_nchars (entry), ==, 0);
g_assert_cmpint (get_nbytes (entry), ==, 0);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_set_text (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
clutter_entry_set_text (entry, "abcdef");
g_assert_cmpint (get_nchars (entry), ==, 6);
g_assert_cmpint (get_nbytes (entry), ==, 6);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
clutter_entry_set_cursor_position (entry, 5);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 5);
clutter_entry_set_text (entry, "");
/* FIXME: cursor position should be -1?
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
*/
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_append_some (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
int j;
for (j = 1; j <= 4; j++)
{
insert_unichar (entry, t->unichar, DONT_MOVE_CURSOR);
g_assert_cmpint (get_nchars (entry), ==, j);
g_assert_cmpint (get_nbytes (entry), ==, j * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
}
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_prepend_some (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
int j;
clutter_entry_insert_unichar (entry, t->unichar);
g_assert_cmpint (get_nchars (entry), ==, 1);
g_assert_cmpint (get_nbytes (entry), ==, 1 * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
for (j = 2; j <= 4; j++)
{
insert_unichar (entry, t->unichar, 0);
g_assert_cmpint (get_nchars (entry), ==, j);
g_assert_cmpint (get_nbytes (entry), ==, j * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 1);
}
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_insert (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
clutter_entry_insert_unichar (entry, t->unichar);
clutter_entry_insert_unichar (entry, t->unichar);
insert_unichar (entry, t->unichar, 1);
g_assert_cmpint (get_nchars (entry), ==, 3);
g_assert_cmpint (get_nbytes (entry), ==, 3 * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 2);
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_delete_chars (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
int j;
for (j = 0; j < 4; j++)
clutter_entry_insert_unichar (entry, t->unichar);
clutter_entry_set_cursor_position (entry, 2);
clutter_entry_delete_chars (entry, 1);
g_assert_cmpint (get_nchars (entry), ==, 3);
g_assert_cmpint (get_nbytes (entry), ==, 3 * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 1);
clutter_entry_set_cursor_position (entry, 2);
clutter_entry_delete_chars (entry, 1);
g_assert_cmpint (get_nchars (entry), ==, 2);
g_assert_cmpint (get_nbytes (entry), ==, 2 * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 1);
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_delete_text (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
int j;
for (j = 0; j < 4; j++)
clutter_entry_insert_unichar (entry, t->unichar);
clutter_entry_set_cursor_position (entry, 3);
clutter_entry_delete_text (entry, 2, 4);
g_assert_cmpint (get_nchars (entry), ==, 2);
g_assert_cmpint (get_nbytes (entry), ==, 2 * t->nbytes);
/* FIXME: cursor position should be -1?
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
*/
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
static void
init_event (ClutterKeyEvent *event)
{
event->type = CLUTTER_KEY_PRESS;
event->time = 0; /* not needed */
event->flags = CLUTTER_EVENT_FLAG_SYNTHETIC;
event->stage = NULL; /* not needed */
event->source = NULL; /* not needed */
event->modifier_state = 0;
event->hardware_keycode = 0; /* not needed */
}
static void
send_keyval (ClutterEntry *entry, int keyval)
{
ClutterKeyEvent event;
init_event (&event);
event.keyval = keyval;
event.unicode_value = 0; /* should be ignored for cursor keys etc. */
clutter_entry_handle_key_event (entry, &event);
}
static inline void
send_unichar (ClutterEntry *entry, gunichar unichar)
{
ClutterKeyEvent event;
init_event (&event);
event.keyval = 0; /* should be ignored for printable characters */
event.unicode_value = unichar;
clutter_entry_handle_key_event (entry, &event);
}
void
test_entry_cursor (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
int j;
for (j = 0; j < 4; ++j)
clutter_entry_insert_unichar (entry, t->unichar);
clutter_entry_set_cursor_position (entry, 2);
/* test cursor moves and is clamped */
send_keyval (entry, CLUTTER_Left);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 1);
send_keyval (entry, CLUTTER_Left);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 0);
send_keyval (entry, CLUTTER_Left);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 0);
/* delete text containing the cursor */
clutter_entry_set_cursor_position (entry, 3);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, 3);
clutter_entry_delete_text (entry, 2, 4);
send_keyval (entry, CLUTTER_Left);
/* FIXME: cursor position should be -1?
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
*/
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}
void
test_entry_event (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterEntry *entry = CLUTTER_ENTRY (clutter_entry_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_data); i++)
{
const TestData *t = &test_data[i];
send_unichar (entry, t->unichar);
g_assert_cmpint (get_nchars (entry), ==, 1);
g_assert_cmpint (get_nbytes (entry), ==, 1 * t->nbytes);
g_assert_cmpint (clutter_entry_get_cursor_position (entry), ==, -1);
clutter_entry_set_text (entry, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (entry));
}

View File

@ -0,0 +1,431 @@
#include <glib.h>
#include <clutter/clutter.h>
#include <string.h>
#include "test-conform-common.h"
typedef struct {
gunichar unichar;
const char bytes[6];
gint nbytes;
} TestData;
static const TestData
test_text_data[] = {
{ 0xe4, "\xc3\xa4", 2 }, /* LATIN SMALL LETTER A WITH DIAERESIS */
{ 0x2665, "\xe2\x99\xa5", 3 } /* BLACK HEART SUIT */
};
void
test_text_utf8_validation (TestConformSimpleFixture *fixture,
gconstpointer data)
{
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
gunichar unichar;
char bytes[6];
int nbytes;
g_assert (g_unichar_validate (t->unichar));
nbytes = g_unichar_to_utf8 (t->unichar, bytes);
bytes[nbytes] = '\0';
g_assert (nbytes == t->nbytes);
g_assert (memcmp (t->bytes, bytes, nbytes) == 0);
unichar = g_utf8_get_char_validated (bytes, nbytes);
g_assert (unichar == t->unichar);
}
}
static int
get_nbytes (ClutterText *text)
{
const char *s = clutter_text_get_text (text);
return strlen (s);
}
static int
get_nchars (ClutterText *text)
{
const char *s = clutter_text_get_text (text);
g_assert (g_utf8_validate (s, -1, NULL));
return g_utf8_strlen (s, -1);
}
#define DONT_MOVE_CURSOR (-2)
static void
insert_unichar (ClutterText *text, gunichar unichar, int position)
{
if (position > DONT_MOVE_CURSOR)
{
clutter_text_set_cursor_position (text, position);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, position);
}
clutter_text_insert_unichar (text, unichar);
}
void
test_text_empty (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
g_assert_cmpstr (clutter_text_get_text (text), ==, "");
g_assert_cmpint (*clutter_text_get_text (text), ==, '\0');
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_set_empty (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
/* annoyingly slightly different from initially empty */
clutter_text_set_text (text, "");
g_assert_cmpint (get_nchars (text), ==, 0);
g_assert_cmpint (get_nbytes (text), ==, 0);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_set_text (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
clutter_text_set_text (text, "abcdef");
g_assert_cmpint (get_nchars (text), ==, 6);
g_assert_cmpint (get_nbytes (text), ==, 6);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
clutter_text_set_cursor_position (text, 5);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 5);
/* FIXME: cursor position should be -1?
clutter_text_set_text (text, "");
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
*/
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_append_some (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
int j;
for (j = 1; j <= 4; j++)
{
insert_unichar (text, t->unichar, DONT_MOVE_CURSOR);
g_assert_cmpint (get_nchars (text), ==, j);
g_assert_cmpint (get_nbytes (text), ==, j * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
}
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_prepend_some (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
int j;
clutter_text_insert_unichar (text, t->unichar);
g_assert_cmpint (get_nchars (text), ==, 1);
g_assert_cmpint (get_nbytes (text), ==, 1 * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
for (j = 2; j <= 4; j++)
{
insert_unichar (text, t->unichar, 0);
g_assert_cmpint (get_nchars (text), ==, j);
g_assert_cmpint (get_nbytes (text), ==, j * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 1);
}
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_insert (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
clutter_text_insert_unichar (text, t->unichar);
clutter_text_insert_unichar (text, t->unichar);
insert_unichar (text, t->unichar, 1);
g_assert_cmpint (get_nchars (text), ==, 3);
g_assert_cmpint (get_nbytes (text), ==, 3 * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 2);
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_delete_chars (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
int j;
for (j = 0; j < 4; j++)
clutter_text_insert_unichar (text, t->unichar);
clutter_text_set_cursor_position (text, 2);
clutter_text_delete_chars (text, 1);
g_assert_cmpint (get_nchars (text), ==, 3);
g_assert_cmpint (get_nbytes (text), ==, 3 * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 1);
clutter_text_set_cursor_position (text, 2);
clutter_text_delete_chars (text, 1);
g_assert_cmpint (get_nchars (text), ==, 2);
g_assert_cmpint (get_nbytes (text), ==, 2 * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 1);
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_get_chars (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
gchar *chars;
clutter_text_set_text (text, "00abcdef11");
g_assert_cmpint (get_nchars (text), ==, 10);
g_assert_cmpint (get_nbytes (text), ==, 10);
g_assert_cmpstr (clutter_text_get_text (text), ==, "00abcdef11");
chars = clutter_text_get_chars (text, 2, -1);
g_assert_cmpstr (chars, ==, "abcdef11");
g_free (chars);
chars = clutter_text_get_chars (text, 0, 8);
g_assert_cmpstr (chars, ==, "00abcdef");
g_free (chars);
chars = clutter_text_get_chars (text, 2, 8);
g_assert_cmpstr (chars, ==, "abcdef");
g_free (chars);
chars = clutter_text_get_chars (text, 8, 12);
g_assert_cmpstr (chars, ==, "11");
g_free (chars);
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_delete_text (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
int j;
for (j = 0; j < 4; j++)
clutter_text_insert_unichar (text, t->unichar);
clutter_text_set_cursor_position (text, 3);
clutter_text_delete_text (text, 2, 4);
g_assert_cmpint (get_nchars (text), ==, 2);
g_assert_cmpint (get_nbytes (text), ==, 2 * t->nbytes);
/* FIXME: cursor position should be -1?
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
*/
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_password_char (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
g_assert_cmpint (clutter_text_get_password_char (text), ==, 0);
clutter_text_set_text (text, "hello");
g_assert_cmpstr (clutter_text_get_text (text), ==, "hello");
clutter_text_set_password_char (text, '*');
g_assert_cmpint (clutter_text_get_password_char (text), ==, '*');
g_assert_cmpstr (clutter_text_get_text (text), ==, "hello");
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
static void
init_event (ClutterKeyEvent *event)
{
event->type = CLUTTER_KEY_PRESS;
event->time = 0; /* not needed */
event->flags = CLUTTER_EVENT_FLAG_SYNTHETIC;
event->stage = NULL; /* not needed */
event->source = NULL; /* not needed */
event->modifier_state = 0;
event->hardware_keycode = 0; /* not needed */
}
static void
send_keyval (ClutterText *text, int keyval)
{
ClutterKeyEvent event;
init_event (&event);
event.keyval = keyval;
event.unicode_value = 0; /* should be ignored for cursor keys etc. */
clutter_actor_event (CLUTTER_ACTOR (text), (ClutterEvent *) &event, FALSE);
}
static void
send_unichar (ClutterText *text, gunichar unichar)
{
ClutterKeyEvent event;
init_event (&event);
event.keyval = 0; /* should be ignored for printable characters */
event.unicode_value = unichar;
clutter_actor_event (CLUTTER_ACTOR (text), (ClutterEvent *) &event, FALSE);
}
void
test_text_cursor (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
/* only editable entries listen to events */
clutter_text_set_editable (text, TRUE);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
int j;
for (j = 0; j < 4; ++j)
clutter_text_insert_unichar (text, t->unichar);
clutter_text_set_cursor_position (text, 2);
/* test cursor moves and is clamped */
send_keyval (text, CLUTTER_Left);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 1);
send_keyval (text, CLUTTER_Left);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 0);
send_keyval (text, CLUTTER_Left);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 0);
/* delete text containing the cursor */
clutter_text_set_cursor_position (text, 3);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, 3);
clutter_text_delete_text (text, 2, 4);
send_keyval (text, CLUTTER_Left);
/* FIXME: cursor position should be -1?
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
*/
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}
void
test_text_event (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i;
/* only editable entries listen to events */
clutter_text_set_editable (text, TRUE);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{
const TestData *t = &test_text_data[i];
send_unichar (text, t->unichar);
g_assert_cmpint (get_nchars (text), ==, 1);
g_assert_cmpint (get_nbytes (text), ==, 1 * t->nbytes);
g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1);
clutter_text_set_text (text, "");
}
clutter_actor_destroy (CLUTTER_ACTOR (text));
}

View File

@ -68,22 +68,21 @@ main (int argc, char **argv)
TEST_CONFORM_SIMPLE ("/picking", test_pick);
TEST_CONFORM_SIMPLE ("/label", test_label_cache);
TEST_CONFORM_SIMPLE ("/entry", test_entry_utf8_validation);
TEST_CONFORM_SIMPLE ("/entry", test_entry_empty);
TEST_CONFORM_SIMPLE ("/entry", test_entry_set_empty);
TEST_CONFORM_SIMPLE ("/entry", test_entry_set_text);
TEST_CONFORM_SIMPLE ("/entry", test_entry_append_some);
TEST_CONFORM_SIMPLE ("/entry", test_entry_prepend_some);
TEST_CONFORM_SIMPLE ("/entry", test_entry_insert);
TEST_CONFORM_SIMPLE ("/entry", test_entry_delete_chars);
TEST_CONFORM_SIMPLE ("/entry", test_entry_delete_text);
TEST_CONFORM_SIMPLE ("/entry", test_entry_cursor);
TEST_CONFORM_SIMPLE ("/entry", test_entry_event);
/* ClutterText */
TEST_CONFORM_SIMPLE ("/text", test_text_utf8_validation);
TEST_CONFORM_SIMPLE ("/text", test_text_empty);
TEST_CONFORM_SIMPLE ("/text", test_text_set_empty);
TEST_CONFORM_SIMPLE ("/text", test_text_set_text);
TEST_CONFORM_SIMPLE ("/text", test_text_append_some);
TEST_CONFORM_SIMPLE ("/text", test_text_prepend_some);
TEST_CONFORM_SIMPLE ("/text", test_text_insert);
TEST_CONFORM_SIMPLE ("/text", test_text_delete_chars);
TEST_CONFORM_SIMPLE ("/text", test_text_delete_text);
TEST_CONFORM_SIMPLE ("/text", test_text_cursor);
TEST_CONFORM_SIMPLE ("/text", test_text_event);
TEST_CONFORM_SIMPLE ("/text", test_text_get_chars);
TEST_CONFORM_SIMPLE ("/text", test_text_cache);
TEST_CONFORM_SIMPLE ("/text", test_text_password_char);
TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_size);
TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_color);

View File

@ -14,12 +14,12 @@ test_label_opacity (TestConformSimpleFixture *fixture,
stage = clutter_stage_get_default ();
label = clutter_label_new_with_text ("Sans 18px", "Label, 50% opacity");
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
label = clutter_text_new_with_text ("Sans 18px", "Label, 50% opacity");
clutter_text_set_color (CLUTTER_TEXT (label), &label_color);
if (g_test_verbose ())
g_print ("label 50%%.get_color()/1\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
clutter_text_get_color (CLUTTER_TEXT (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (stage), label, NULL);
@ -27,12 +27,16 @@ test_label_opacity (TestConformSimpleFixture *fixture,
if (g_test_verbose ())
g_print ("label 50%%.get_color()/2\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
clutter_text_get_color (CLUTTER_TEXT (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
if (g_test_verbose ())
g_print ("label 50%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (label));
g_print ("label 50%%.get_paint_opacity()/1\n");
g_assert (clutter_actor_get_paint_opacity (label) == 255);
if (g_test_verbose ())
g_print ("label 50%%.get_paint_opacity()/2\n");
clutter_actor_set_opacity (label, 128);
g_assert (clutter_actor_get_paint_opacity (label) == 128);
clutter_actor_destroy (label);
@ -66,8 +70,7 @@ test_rectangle_opacity (TestConformSimpleFixture *fixture,
g_assert (color_check.alpha == rect_color.alpha);
if (g_test_verbose ())
g_print ("rect 100%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (rect));
g_print ("rect 100%%.get_paint_opacity()\n");
g_assert (clutter_actor_get_paint_opacity (rect) == 255);
clutter_actor_destroy (rect);
@ -91,25 +94,24 @@ test_paint_opacity (TestConformSimpleFixture *fixture,
clutter_actor_set_position (group1, 10, 30);
clutter_actor_show (group1);
label = clutter_label_new_with_text ("Sans 18px", "Label+Group, 25% opacity");
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
label = clutter_text_new_with_text ("Sans 18px", "Label+Group, 25% opacity");
clutter_text_set_color (CLUTTER_TEXT (label), &label_color);
if (g_test_verbose ())
g_print ("label 50%% + group 50%%.get_color()/1\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
clutter_text_get_color (CLUTTER_TEXT (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (group1), label, NULL);
if (g_test_verbose ())
g_print ("label 50%% + group 50%%.get_color()/2\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
clutter_text_get_color (CLUTTER_TEXT (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
if (g_test_verbose ())
g_print ("label 50%% + group 50%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (label));
g_assert (clutter_actor_get_paint_opacity (label) == 64);
g_print ("label 50%% + group 50%%.get_paint_opacity() = 128\n");
g_assert (clutter_actor_get_paint_opacity (label) == 128);
clutter_actor_destroy (label);
@ -133,9 +135,7 @@ test_paint_opacity (TestConformSimpleFixture *fixture,
g_assert (color_check.alpha == rect_color.alpha);
if (g_test_verbose ())
g_print ("rect 100%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (rect));
g_print ("rect 100%%.get_paint_opacity()\n");
g_assert (clutter_actor_get_paint_opacity (rect) == 128);
clutter_actor_destroy (rect);

View File

@ -34,7 +34,7 @@ on_paint (ClutterActor *label, CallbackData *data)
/* Check whether the layout used for this paint is different from
the layout used for the last paint */
new_layout = clutter_label_get_layout (CLUTTER_LABEL (data->label));
new_layout = clutter_text_get_layout (CLUTTER_TEXT (data->label));
data->layout_changed = data->old_layout != new_layout;
if (data->old_layout)
@ -71,7 +71,17 @@ check_result (CallbackData *data, const char *note,
if (memcmp (&test_extents, &data->label_extents, sizeof (PangoRectangle)))
{
if (g_test_verbose ())
g_print ("extents are different, ");
g_print ("extents are different: expected: %d, %d, %d, %d "
"-> text: %d, %d, %d, %d\n",
test_extents.x / 1024,
test_extents.y / 1024,
test_extents.width / 1024,
test_extents.height / 1024,
data->label_extents.x / 1024,
data->label_extents.y / 1024,
data->label_extents.width / 1024,
data->label_extents.height / 1024);
fail = TRUE;
}
else
@ -119,29 +129,29 @@ do_tests (CallbackData *data)
PangoAttribute *attr;
/* TEST 1: change the text */
clutter_label_set_text (CLUTTER_LABEL (data->label), "Counter 0");
clutter_text_set_text (CLUTTER_TEXT (data->label), "Counter 0");
pango_layout_set_text (data->test_layout, "Counter 0", -1);
check_result (data, "Change text", TRUE);
g_assert (check_result (data, "Change text", TRUE) == FALSE);
/* TEST 2: change a single character */
clutter_label_set_text (CLUTTER_LABEL (data->label), "Counter 1");
clutter_text_set_text (CLUTTER_TEXT (data->label), "Counter 1");
pango_layout_set_text (data->test_layout, "Counter 1", -1);
check_result (data, "Change a single character", TRUE);
g_assert (check_result (data, "Change a single character", TRUE) == FALSE);
/* TEST 3: move the label */
clutter_actor_set_position (data->label, 10, 0);
check_result (data, "Move the label", FALSE);
g_assert (check_result (data, "Move the label", FALSE) == FALSE);
/* TEST 4: change the font */
clutter_label_set_font_name (CLUTTER_LABEL (data->label), "Serif 15");
clutter_text_set_font_name (CLUTTER_TEXT (data->label), "Serif 15");
fd = pango_font_description_from_string ("Serif 15");
pango_layout_set_font_description (data->test_layout, fd);
pango_font_description_free (fd);
check_result (data, "Change the font", TRUE);
g_assert (check_result (data, "Change the font", TRUE) == FALSE);
/* TEST 5: change the color */
clutter_label_set_color (CLUTTER_LABEL (data->label), &red);
check_result (data, "Change the color", FALSE);
clutter_text_set_color (CLUTTER_TEXT (data->label), &red);
g_assert (check_result (data, "Change the color", FALSE) == FALSE);
/* TEST 6: change the attributes */
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
@ -150,23 +160,23 @@ do_tests (CallbackData *data)
attr_list = pango_attr_list_new ();
pango_attr_list_insert (attr_list, attr);
attr_list_copy = pango_attr_list_copy (attr_list);
clutter_label_set_attributes (CLUTTER_LABEL (data->label), attr_list);
clutter_text_set_attributes (CLUTTER_TEXT (data->label), attr_list);
pango_layout_set_attributes (data->test_layout, attr_list_copy);
pango_attr_list_unref (attr_list_copy);
pango_attr_list_unref (attr_list);
check_result (data, "Change the attributes", TRUE);
g_assert (check_result (data, "Change the attributes", TRUE) == FALSE);
/* TEST 7: change the text again */
clutter_label_set_attributes (CLUTTER_LABEL (data->label), NULL);
clutter_label_set_text (CLUTTER_LABEL (data->label), long_text);
clutter_text_set_attributes (CLUTTER_TEXT (data->label), NULL);
clutter_text_set_text (CLUTTER_TEXT (data->label), long_text);
pango_layout_set_attributes (data->test_layout, NULL);
pango_layout_set_text (data->test_layout, long_text, -1);
check_result (data, "Change the text again", TRUE);
g_assert (check_result (data, "Change the text again", TRUE) == FALSE);
/* TEST 8: enable markup */
clutter_label_set_use_markup (CLUTTER_LABEL (data->label), TRUE);
clutter_text_set_use_markup (CLUTTER_TEXT (data->label), TRUE);
pango_layout_set_markup (data->test_layout, long_text, -1);
check_result (data, "Enable markup", TRUE);
g_assert (check_result (data, "Enable markup", TRUE) == FALSE);
/* This part can't be a test because Clutter won't restrict the
width if wrapping and ellipsizing is disabled so the extents will
@ -178,39 +188,39 @@ do_tests (CallbackData *data)
force_redraw (data);
/* TEST 9: enable ellipsize */
clutter_label_set_ellipsize (CLUTTER_LABEL (data->label),
clutter_text_set_ellipsize (CLUTTER_TEXT (data->label),
PANGO_ELLIPSIZE_END);
pango_layout_set_ellipsize (data->test_layout, PANGO_ELLIPSIZE_END);
check_result (data, "Enable ellipsize", TRUE);
clutter_label_set_ellipsize (CLUTTER_LABEL (data->label),
g_assert (check_result (data, "Enable ellipsize", TRUE) == FALSE);
clutter_text_set_ellipsize (CLUTTER_TEXT (data->label),
PANGO_ELLIPSIZE_NONE);
pango_layout_set_ellipsize (data->test_layout, PANGO_ELLIPSIZE_NONE);
force_redraw (data);
/* TEST 10: enable line wrap */
clutter_label_set_line_wrap (CLUTTER_LABEL (data->label), TRUE);
clutter_text_set_line_wrap (CLUTTER_TEXT (data->label), TRUE);
pango_layout_set_wrap (data->test_layout, PANGO_WRAP_WORD);
check_result (data, "Enable line wrap", TRUE);
g_assert (check_result (data, "Enable line wrap", TRUE) == FALSE);
/* TEST 11: change wrap mode */
clutter_label_set_line_wrap_mode (CLUTTER_LABEL (data->label),
clutter_text_set_line_wrap_mode (CLUTTER_TEXT (data->label),
PANGO_WRAP_CHAR);
pango_layout_set_wrap (data->test_layout, PANGO_WRAP_CHAR);
check_result (data, "Change wrap mode", TRUE);
g_assert (check_result (data, "Change wrap mode", TRUE) == FALSE);
/* TEST 12: enable justify */
clutter_label_set_justify (CLUTTER_LABEL (data->label), TRUE);
clutter_text_set_justify (CLUTTER_TEXT (data->label), TRUE);
pango_layout_set_justify (data->test_layout, TRUE);
/* Pango appears to have a bug which means that you can't change the
justification after setting the text but this fixes it.
See http://bugzilla.gnome.org/show_bug.cgi?id=551865 */
pango_layout_context_changed (data->test_layout);
check_result (data, "Enable justify", TRUE);
g_assert (check_result (data, "Enable justify", TRUE) == FALSE);
/* TEST 13: change alignment */
clutter_label_set_alignment (CLUTTER_LABEL (data->label), PANGO_ALIGN_RIGHT);
clutter_text_set_alignment (CLUTTER_TEXT (data->label), PANGO_ALIGN_RIGHT);
pango_layout_set_alignment (data->test_layout, PANGO_ALIGN_RIGHT);
check_result (data, "Change alignment", TRUE);
g_assert (check_result (data, "Change alignment", TRUE) == FALSE);
clutter_main_quit ();
@ -218,7 +228,7 @@ do_tests (CallbackData *data)
}
static PangoLayout *
make_layout_like_label (ClutterLabel *label)
make_layout_like_label (ClutterText *label)
{
PangoLayout *label_layout, *new_layout;
PangoContext *context;
@ -226,7 +236,7 @@ make_layout_like_label (ClutterLabel *label)
/* Make another layout using the same context as the layout from the
label */
label_layout = clutter_label_get_layout (label);
label_layout = clutter_text_get_layout (label);
context = pango_layout_get_context (label_layout);
new_layout = pango_layout_new (context);
fd = pango_font_description_from_string (TEST_FONT);
@ -237,8 +247,8 @@ make_layout_like_label (ClutterLabel *label)
}
void
test_label_cache (TestConformSimpleFixture *fixture,
gconstpointer _data)
test_text_cache (TestConformSimpleFixture *fixture,
gconstpointer _data)
{
CallbackData data;
@ -246,9 +256,9 @@ test_label_cache (TestConformSimpleFixture *fixture,
data.stage = clutter_stage_get_default ();
data.label = clutter_label_new_with_text (TEST_FONT, "");
data.label = clutter_text_new_with_text (TEST_FONT, "");
data.test_layout = make_layout_like_label (CLUTTER_LABEL (data.label));
data.test_layout = make_layout_like_label (CLUTTER_TEXT (data.label));
g_signal_connect (data.label, "paint", G_CALLBACK (on_paint), &data);

View File

@ -6,7 +6,6 @@ UNIT_TESTS = \
test-scale.c \
test-actors.c \
test-behave.c \
test-entry.c \
test-project.c \
test-perspective.c \
test-rotate.c \
@ -22,7 +21,6 @@ UNIT_TESTS = \
test-unproject.c \
test-viewport.c \
test-fbo.c \
test-opacity.c \
test-multistage.c \
test-cogl-primitives.c \
test-cogl-tex-tile.c \
@ -40,7 +38,9 @@ UNIT_TESTS = \
test-layout.c \
test-animation.c \
test-easing.c \
test-binding-pool.c
test-binding-pool.c \
test-text.c \
test-text-field.c
if X11_TESTS
UNIT_TESTS += test-pixmap.c

View File

@ -15,7 +15,7 @@ typedef enum
struct _Clip
{
ClipType type;
gint x1, y1, x2, y2;
gint x1, y1, x2, y2;
};
struct _CallbackData
@ -24,7 +24,7 @@ struct _CallbackData
CoglHandle hand;
Clip current_clip;
GSList *clips;
};
@ -122,7 +122,7 @@ on_paint (ClutterActor *actor, CallbackData *data)
{
int i;
ClutterGeometry stage_size;
guint hand_width, hand_height;
gint hand_width, hand_height;
GSList *node;
clutter_actor_get_allocation_geometry (data->stage, &stage_size);
@ -242,7 +242,7 @@ on_motion (ClutterActor *stage, ClutterMotionEvent *event,
{
data->current_clip.x2 = event->x;
data->current_clip.y2 = event->y;
clutter_actor_queue_redraw (stage);
}
@ -305,8 +305,8 @@ test_clip_main (int argc, char **argv)
data.hand = cogl_texture_new_from_file ("redhand.png", 64, FALSE,
COGL_PIXEL_FORMAT_ANY, NULL);
label = clutter_label_new_with_text ("Sans 12px", instructions);
clutter_label_set_line_wrap (CLUTTER_LABEL (label), TRUE);
label = clutter_text_new_with_text ("Sans 12px", instructions);
clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE);
clutter_actor_set_width (label, clutter_actor_get_width (data.stage) - 310);
clutter_actor_set_y (label,
clutter_actor_get_height (data.stage)

View File

@ -297,16 +297,16 @@ frame_cb (ClutterTimeline *timeline,
}
static void
update_toggle_text (ClutterLabel *button, gboolean val)
update_toggle_text (ClutterText *button, gboolean val)
{
clutter_label_set_text (button, val ? "Enabled" : "Disabled");
clutter_text_set_text (button, val ? "Enabled" : "Disabled");
}
static gboolean
on_toggle_click (ClutterActor *button, ClutterEvent *event,
gboolean *toggle_val)
{
update_toggle_text (CLUTTER_LABEL (button), *toggle_val = !*toggle_val);
update_toggle_text (CLUTTER_TEXT (button), *toggle_val = !*toggle_val);
return TRUE;
}
@ -315,12 +315,12 @@ static ClutterActor *
make_toggle (const char *label_text, gboolean *toggle_val)
{
ClutterActor *group = clutter_group_new ();
ClutterActor *label = clutter_label_new_with_text ("Sans 14", label_text);
ClutterActor *button = clutter_label_new_with_text ("Sans 14", "");
ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text);
ClutterActor *button = clutter_text_new_with_text ("Sans 14", "");
clutter_actor_set_reactive (button, TRUE);
update_toggle_text (CLUTTER_LABEL (button), *toggle_val);
update_toggle_text (CLUTTER_TEXT (button), *toggle_val);
clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0);
clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL);
@ -373,7 +373,7 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
clutter_actor_set_position (filtering_toggle, 0,
clutter_actor_get_y (slicing_toggle)
- clutter_actor_get_height (filtering_toggle));
note = clutter_label_new_with_text ("Sans 10", "<- Click to change");
note = clutter_text_new_with_text ("Sans 10", "<- Click to change");
clutter_actor_set_position (note,
clutter_actor_get_width (filtering_toggle) + 10,
(clutter_actor_get_height (stage)

View File

@ -26,7 +26,7 @@ raise_top (gpointer ignored)
static ClutterActor *
clone_box (ClutterTexture *original)
{
guint width, height;
gint width, height;
ClutterActor *group;
ClutterActor *clone;
@ -83,10 +83,10 @@ janus_group (const gchar *front_text,
group = clutter_group_new ();
rectangle = clutter_rectangle_new_with_color (&slide_color);
front = clutter_label_new_with_text ("Sans 50px", front_text);
back = clutter_label_new_with_text ("Sans 50px", back_text);
clutter_label_set_color (CLUTTER_LABEL (front), &red);
clutter_label_set_color (CLUTTER_LABEL (back), &green);
front = clutter_text_new_with_text ("Sans 50px", front_text);
back = clutter_text_new_with_text ("Sans 50px", back_text);
clutter_text_set_color (CLUTTER_TEXT (front), &red);
clutter_text_set_color (CLUTTER_TEXT (back), &green);
clutter_actor_get_size (front, &width, &height);
clutter_actor_get_size (back, &width2, &height2);
@ -134,7 +134,7 @@ test_depth_main (int argc, char *argv[])
clutter_stage_add (stage, group);
clutter_actor_show (group);
label = clutter_label_new_with_text ("Mono 26", "Clutter");
label = clutter_text_new_with_text ("Mono 26", "Clutter");
clutter_actor_set_position (label, 120, 200);
clutter_actor_show (label);

View File

@ -41,7 +41,7 @@ on_button_press (ClutterActor *actor,
current_mode + 1,
n_easing_modes);
clutter_label_set_text (CLUTTER_LABEL (easing_mode_label), text);
clutter_text_set_text (CLUTTER_TEXT (easing_mode_label), text);
g_free (text);
clutter_actor_get_size (main_stage, &stage_width, &stage_height);
@ -97,10 +97,10 @@ test_easing_main (int argc, char *argv[])
current_mode + 1,
n_easing_modes);
label = clutter_label_new ();
label = clutter_text_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
clutter_label_set_font_name (CLUTTER_LABEL (label), "Sans 18px");
clutter_label_set_text (CLUTTER_LABEL (label), text);
clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 18px");
clutter_text_set_text (CLUTTER_TEXT (label), text);
clutter_actor_get_size (label, &label_width, &label_height);
clutter_actor_set_position (label,
stage_width - label_width - 10,

View File

@ -43,9 +43,9 @@ make_source(void)
clutter_group_add (source, actor);
actor = clutter_label_new_with_text ("Sans Bold 50px", "Clutter");
actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter");
clutter_label_set_color (CLUTTER_LABEL (actor), &yellow);
clutter_text_set_color (CLUTTER_TEXT (actor), &yellow);
clutter_actor_set_y (actor, clutter_actor_get_height(source) + 5);
clutter_group_add (source, actor);

View File

@ -787,7 +787,7 @@ test_layout_main (int argc, char *argv[])
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
instructions = clutter_label_new_with_text ("Sans 14",
instructions = clutter_text_new_with_text ("Sans 14",
"<b>Instructions:</b>\n"
"a - add a new item\n"
"d - remove last item\n"
@ -799,7 +799,7 @@ test_layout_main (int argc, char *argv[])
"s - use transformed box\n"
"q - quit");
clutter_label_set_use_markup (CLUTTER_LABEL (instructions), TRUE);
clutter_text_set_use_markup (CLUTTER_TEXT (instructions), TRUE);
clutter_actor_set_position (instructions, 450, 10);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), instructions);

View File

@ -50,10 +50,10 @@ on_button_press (ClutterActor *actor,
clutter_container_add_actor (CLUTTER_CONTAINER (new_stage), tex);
stage_label = g_strdup_printf ("<b>Stage: %d</b>", ++n_stages);
label = clutter_label_new_with_text ("Mono 12", stage_label);
label = clutter_text_new_with_text ("Mono 12", stage_label);
clutter_label_set_color (CLUTTER_LABEL (label), &white);
clutter_label_set_use_markup (CLUTTER_LABEL (label), TRUE);
clutter_text_set_color (CLUTTER_TEXT (label), &white);
clutter_text_set_use_markup (CLUTTER_TEXT (label), TRUE);
width = (clutter_actor_get_width (new_stage)
- clutter_actor_get_width (label)) / 2;
height = (clutter_actor_get_height (new_stage)
@ -110,7 +110,7 @@ test_multistage_main (int argc, char *argv[])
G_CALLBACK (on_button_press),
NULL);
label = clutter_label_new_with_text ("Mono 16", "Default stage");
label = clutter_text_new_with_text ("Mono 16", "Default stage");
width = (clutter_actor_get_width (stage_default)
- clutter_actor_get_width (label))
/ 2;

View File

@ -1,116 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
G_MODULE_EXPORT int
test_opacity_main (int argc, char *argv[])
{
ClutterActor *stage, *group1, *group2, *label, *rect;
ClutterColor label_color = { 255, 0, 0, 128 };
ClutterColor rect_color = { 0, 0, 255, 255 };
ClutterColor color_check = { 0, };
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
label = clutter_label_new_with_text ("Sans 18px", "Label, 50% opacity");
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
g_print ("label 50%%.get_color()/1\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (stage), label, NULL);
clutter_actor_set_position (label, 10, 10);
g_print ("label 50%%.get_color()/2\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
g_print ("label 50%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (label));
g_assert (clutter_actor_get_paint_opacity (label) == 128);
clutter_actor_show (label);
group1 = clutter_group_new ();
clutter_actor_set_opacity (group1, 128);
clutter_container_add (CLUTTER_CONTAINER (stage), group1, NULL);
clutter_actor_set_position (group1, 10, 30);
clutter_actor_show (group1);
label = clutter_label_new_with_text ("Sans 18px", "Label+Group, 25% opacity");
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
g_print ("label 50%% + group 50%%.get_color()/1\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (group1), label, NULL);
g_print ("label 50%% + group 50%%.get_color()/2\n");
clutter_label_get_color (CLUTTER_LABEL (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
g_print ("label 50%% + group 50%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (label));
g_assert (clutter_actor_get_paint_opacity (label) == 64);
clutter_actor_show (label);
group2 = clutter_group_new ();
clutter_container_add (CLUTTER_CONTAINER (group1), group2, NULL);
clutter_actor_set_position (group2, 10, 60);
clutter_actor_show (group2);
rect = clutter_rectangle_new_with_color (&rect_color);
clutter_actor_set_size (rect, 128, 128);
g_print ("rect 100%% + group 100%% + group 50%%.get_color()/1\n");
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &color_check);
g_assert (color_check.alpha == rect_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (group2), rect, NULL);
g_print ("rect 100%% + group 100%% + group 50%%.get_color()/2\n");
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &color_check);
g_assert (color_check.alpha == rect_color.alpha);
g_print ("rect 100%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (rect));
g_assert (clutter_actor_get_paint_opacity (rect) == 128);
clutter_actor_show (rect);
rect = clutter_rectangle_new_with_color (&rect_color);
clutter_actor_set_size (rect, 128, 128);
clutter_actor_set_position (rect, 150, 90);
g_print ("rect 100%%.get_color()/1\n");
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &color_check);
g_assert (color_check.alpha == rect_color.alpha);
clutter_container_add (CLUTTER_CONTAINER (stage), rect, NULL);
g_print ("rect 100%%.get_color()/2\n");
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &color_check);
g_assert (color_check.alpha == rect_color.alpha);
g_print ("rect 100%%.get_paint_opacity() = %d\n",
clutter_actor_get_paint_opacity (rect));
g_assert (clutter_actor_get_paint_opacity (rect) == 255);
clutter_actor_show (rect);
clutter_actor_show_all (stage);
clutter_main ();
return EXIT_SUCCESS;
}

View File

@ -21,19 +21,19 @@ init_handles ()
clutter_actor_set_position (p[i], 0, 0);
clutter_group_add (CLUTTER_GROUP (main_stage), p[i]);
clutter_actor_set_position (p[i],
CLUTTER_FIXED_TO_INT (v[i].x) -
clutter_actor_get_width (p[i])/2,
CLUTTER_FIXED_TO_INT (v[i].y) -
clutter_actor_get_height (p[i])/2);
clutter_actor_set_positionu (p[i],
v[i].x -
clutter_actor_get_widthu (p[i])/2,
v[i].y -
clutter_actor_get_heightu (p[i])/2);
clutter_actor_raise_top (p[i]);
clutter_actor_show (p[i]);
}
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
v1.x = clutter_actor_get_widthu (rect) / 2;
v1.y = clutter_actor_get_heightu (rect) / 2;
v1.z = 0;
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
@ -41,11 +41,11 @@ init_handles ()
clutter_actor_set_size (p[4], 5, 5);
clutter_actor_set_position (p[4], 0, 0);
clutter_group_add (CLUTTER_GROUP (main_stage), p[4]);
clutter_actor_set_position (p[4],
CLUTTER_FIXED_TO_INT (v2.x) -
clutter_actor_get_width (p[4])/2,
CLUTTER_FIXED_TO_INT (v2.y) -
clutter_actor_get_height (p[4])/2);
clutter_actor_set_positionu (p[4],
v2.x -
clutter_actor_get_widthu (p[4])/2,
v2.y -
clutter_actor_get_heightu (p[4])/2);
clutter_actor_raise_top (p[4]);
@ -62,23 +62,21 @@ place_handles ()
clutter_actor_get_abs_allocation_vertices (rect, v);
for (i = 0; i < 4; ++i)
{
clutter_actor_set_position (p[i],
CLUTTER_FIXED_TO_INT (v[i].x) -
clutter_actor_get_width (p[i])/2,
CLUTTER_FIXED_TO_INT (v[i].y) -
clutter_actor_get_height (p[i])/2);
clutter_actor_set_positionu (p[i],
v[i].x -
clutter_actor_get_widthu (p[i])/2,
v[i].y -
clutter_actor_get_heightu (p[i])/2);
}
v1.x = CLUTTER_INT_TO_FIXED (clutter_actor_get_width (rect)/2);
v1.y = CLUTTER_INT_TO_FIXED (clutter_actor_get_height (rect)/2);
v1.x = clutter_actor_get_widthu (rect)/2;
v1.y = clutter_actor_get_heightu (rect)/2;
v1.z = 0;
clutter_actor_apply_transform_to_point (rect, &v1, &v2);
clutter_actor_set_position (p[4],
CLUTTER_FIXED_TO_INT (v2.x) -
clutter_actor_get_width (p[4])/2,
CLUTTER_FIXED_TO_INT (v2.y) -
clutter_actor_get_height (p[4])/2);
clutter_actor_set_positionu (p[4],
v2.x - clutter_actor_get_widthu (p[4])/2,
v2.y - clutter_actor_get_heightu (p[4])/2);
}
#define M(m,row,col) (m)[col*4+row]
@ -127,7 +125,7 @@ on_event (ClutterStage *stage,
gint x, y;
gint i;
ClutterActorBox box1, box2;
ClutterFixed xp, yp;
ClutterUnit xp, yp;
i = find_handle_index (dragging);
@ -139,25 +137,24 @@ on_event (ClutterStage *stage,
clutter_actor_get_allocation_box (dragging, &box1);
clutter_actor_get_allocation_box (rect, &box2);
xp = CLUTTER_INT_TO_FIXED (x-3) - box1.x1;
yp = CLUTTER_INT_TO_FIXED (y-3) - box1.y1;
xp = CLUTTER_UNITS_FROM_DEVICE (x - 3) - box1.x1;
yp = CLUTTER_UNITS_FROM_DEVICE (y - 3) - box1.y1;
if (i == 4)
{
g_debug ("moving box by %f, %f",
CLUTTER_FIXED_TO_FLOAT (xp),
CLUTTER_FIXED_TO_FLOAT (yp));
CLUTTER_UNITS_TO_FLOAT (xp),
CLUTTER_UNITS_TO_FLOAT (yp));
clutter_actor_move_by (rect,
CLUTTER_FIXED_TO_INT(xp),
CLUTTER_FIXED_TO_INT(yp));
clutter_actor_move_byu (rect, xp, yp);
}
else
{
g_debug ("adjusting box by %f, %f, handle %d",
CLUTTER_FIXED_TO_FLOAT (xp),
CLUTTER_FIXED_TO_FLOAT (yp),
CLUTTER_UNITS_TO_FLOAT (xp),
CLUTTER_UNITS_TO_FLOAT (yp),
i);
switch (i)
{
case 0:
@ -224,8 +221,8 @@ test_project_main (int argc, char *argv[])
clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, 60, 0, 0, 0);
clutter_group_add (CLUTTER_GROUP (main_stage), rect);
label = clutter_label_new_with_text ("Mono 8pt", "Drag the blue rectangles");
clutter_label_set_color (CLUTTER_LABEL (label), &white);
label = clutter_text_new_with_text ("Mono 8pt", "Drag the blue rectangles");
clutter_text_set_color (CLUTTER_TEXT (label), &white);
clutter_actor_set_position (label, 10, 10);
clutter_group_add (CLUTTER_GROUP (main_stage), label);

View File

@ -45,7 +45,7 @@ on_idle (gpointer data)
font_names[rand () % FONT_NAME_COUNT],
rand () % (MAX_FONT_SIZE - MIN_FONT_SIZE) + MIN_FONT_SIZE);
label = clutter_label_new_with_text (font_name, text);
label = clutter_text_new_with_text (font_name, text);
if (clutter_actor_get_height (label) > line_height)
line_height = clutter_actor_get_height (label);

View File

@ -33,8 +33,8 @@ test_rotate_main (int argc, char *argv[])
clutter_actor_show (hand);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);
label = clutter_label_new_with_text ("Mono 16", "The Wonder of the Spinning Hand");
clutter_label_set_alignment (CLUTTER_LABEL (label), PANGO_ALIGN_CENTER);
label = clutter_text_new_with_text ("Mono 16", "The Wonder of the Spinning Hand");
clutter_text_set_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER);
clutter_actor_set_position (label, 150, 150);
clutter_actor_set_size (label, 500, 100);
clutter_actor_show (label);

View File

@ -29,7 +29,7 @@ set_next_gravity (ClutterActor *actor)
eclass = g_type_class_ref (CLUTTER_TYPE_GRAVITY);
evalue = g_enum_get_value (eclass, gravity);
clutter_label_set_text (CLUTTER_LABEL (label), evalue->value_nick);
clutter_text_set_text (CLUTTER_TEXT (label), evalue->value_nick);
g_type_class_unref (eclass);
if (++gindex >= G_N_ELEMENTS (gravities))
@ -59,8 +59,8 @@ test_scale_main (int argc, char *argv[])
clutter_group_add (CLUTTER_GROUP (stage), rect);
label = clutter_label_new_with_text ("Sans 20px", "");
clutter_label_set_color (CLUTTER_LABEL (label),
label = clutter_text_new_with_text ("Sans 20px", "");
clutter_text_set_color (CLUTTER_TEXT (label),
&(ClutterColor) { 0xff, 0xff, 0xff, 0xff });
clutter_actor_set_position (label,
clutter_actor_get_x (rect),

View File

@ -354,7 +354,7 @@ test_shader_main (gint argc, gchar *argv[])
if (!child2)
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
child3 = clutter_rectangle_new ();
child4 = clutter_label_new_with_text ("Sans 20px", "Shady stuff");
child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff");
clutter_rectangle_set_color (child3, &color);
clutter_actor_set_size (child3, 50, 50);

View File

@ -23,14 +23,14 @@ make_label (void)
gchar *text;
gchar *argv[] = { "ls", "--help", NULL };
label = clutter_label_new ();
clutter_label_set_font_name (CLUTTER_LABEL (label), "Sans 10");
label = clutter_text_new ();
clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 10");
if (g_spawn_sync (NULL, argv, NULL,
G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH,
NULL, NULL, &text, NULL, NULL, NULL))
{
clutter_label_set_text (CLUTTER_LABEL (label), text);
clutter_text_set_text (CLUTTER_TEXT (label), text);
g_free (text);
}

View File

@ -0,0 +1,117 @@
#include <stdlib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
#define FONT "Mono Bold 14px"
static void
on_entry_paint (ClutterActor *actor,
gpointer data)
{
ClutterActorBox allocation = { 0, };
ClutterUnit width, height;
clutter_actor_get_allocation_box (actor, &allocation);
width = allocation.x2 - allocation.x1;
height = allocation.y2 - allocation.y1;
cogl_set_source_color4ub (255, 255, 255, 255);
cogl_path_round_rectangle (0, 0,
CLUTTER_UNITS_TO_FIXED (width),
CLUTTER_UNITS_TO_FIXED (height),
COGL_FIXED_FROM_INT (4),
COGL_ANGLE_FROM_DEG (1.0));
cogl_path_stroke ();
}
static void
on_entry_activate (ClutterText *text,
gpointer data)
{
g_print ("Text activated: %s\n", clutter_text_get_text (text));
}
static ClutterActor *
create_label (const ClutterColor *color,
const gchar *text)
{
ClutterActor *retval = clutter_text_new_full (FONT, text, color);
clutter_text_set_editable (CLUTTER_TEXT (retval), FALSE);
clutter_text_set_selectable (CLUTTER_TEXT (retval), FALSE);
return retval;
}
static ClutterActor *
create_entry (const ClutterColor *color,
const gchar *text,
gunichar password_char,
gint max_length)
{
ClutterActor *retval = clutter_text_new_full (FONT, text, color);
ClutterColor selection = { 0, };
clutter_actor_set_width (retval, 200);
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);
g_signal_connect (retval, "activate",
G_CALLBACK (on_entry_activate),
NULL);
g_signal_connect (retval, "paint",
G_CALLBACK (on_entry_paint),
NULL);
return retval;
}
G_MODULE_EXPORT gint
test_text_field_main (gint argc,
gchar **argv)
{
ClutterActor *stage;
ClutterActor *text;
ClutterColor entry_color = {0x33, 0xff, 0x33, 0xff};
ClutterColor label_color = {0xff, 0xff, 0xff, 0xff};
ClutterColor background_color = {0x00, 0x00, 0x00, 0xff};
gint height;
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);
text = create_label (&label_color, "Input field: ");
clutter_actor_set_position (text, 10, 10);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
height = clutter_actor_get_height (text);
text = create_entry (&entry_color, "some text", 0, 0);
clutter_actor_set_position (text, 200, 10);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
text = create_label (&label_color, "Password field: ");
clutter_actor_set_position (text, 10, height + 12);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
text = create_entry (&entry_color, "password", '*', 8);
clutter_actor_set_position (text, 200, height + 12);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
clutter_actor_show (stage);
clutter_main ();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,89 @@
#include <stdlib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
#define FONT "Mono Bold 22px"
static gchar *runes =
"ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ\n"
"ᛋᚳᛖᚪᛚ᛫ᚦᛖᚪᚻ᛫ᛗᚪᚾᚾᚪ᛫ᚷᛖᚻᚹᛦᛚᚳ᛫ᛗᛁᚳᛚᚢᚾ᛫ᚻᛦᛏ᛫ᛞᚫᛚᚪᚾ\n"
"ᚷᛁᚠ᛫ᚻᛖ᛫ᚹᛁᛚᛖ᛫ᚠᚩᚱ᛫ᛞᚱᛁᚻᛏᚾᛖ᛫ᛞᚩᛗᛖᛋ᛫ᚻᛚᛇᛏᚪᚾ᛬\n";
static void
cursor_event (ClutterText *text,
ClutterGeometry *geometry)
{
gint y;
y = clutter_actor_get_y (CLUTTER_ACTOR (text));
if (y + geometry->y < 50)
{
clutter_actor_set_y (CLUTTER_ACTOR (text), y + 100);
}
else if (y + geometry->y > 720)
{
clutter_actor_set_y (CLUTTER_ACTOR (text), y - 100);
}
}
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);
g_signal_connect (text, "cursor-event", G_CALLBACK (cursor_event), NULL);
clutter_actor_set_size (stage, 1024, 768);
clutter_actor_show (stage);
clutter_main ();
return EXIT_SUCCESS;
}

View File

@ -42,7 +42,7 @@ test_thread_done_idle (gpointer user_data)
g_print ("Thread completed\n");
clutter_label_set_text (CLUTTER_LABEL (data->label), "Completed");
clutter_text_set_text (CLUTTER_TEXT (data->label), "Completed");
clutter_timeline_stop (data->timeline);
test_thread_data_free (data);
@ -67,7 +67,7 @@ update_label_idle (gpointer data)
text = g_strdup_printf ("Count to %d", update->count);
clutter_label_set_text (CLUTTER_LABEL (update->thread_data->label), text);
clutter_text_set_text (CLUTTER_TEXT (update->thread_data->label), text);
clutter_actor_set_width (update->thread_data->label, -1);
if (update->count == 0)
@ -151,7 +151,7 @@ on_key_press_event (ClutterStage *stage,
switch (clutter_key_event_symbol (event))
{
case CLUTTER_s:
clutter_label_set_text (CLUTTER_LABEL (help_label), "Press 'q' to quit");
clutter_text_set_text (CLUTTER_TEXT (help_label), "Press 'q' to quit");
clutter_timeline_start (timeline);
@ -191,10 +191,10 @@ test_threads_main (int argc, char *argv[])
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
clutter_actor_set_size (stage, 600, 300);
count_label = clutter_label_new_with_text ("Mono 12", "Counter");
count_label = clutter_text_new_with_text ("Mono 12", "Counter");
clutter_actor_set_position (count_label, 350, 50);
help_label = clutter_label_new_with_text ("Mono 12", "Press 's' to start");
help_label = clutter_text_new_with_text ("Mono 12", "Press 's' to start");
clutter_actor_set_position (help_label, 50, 50);
rect = clutter_rectangle_new_with_color (&rect_color);

View File

@ -5,13 +5,15 @@
#include <string.h>
#include <gmodule.h>
ClutterActor *label;
#define RECT_L 200
#define RECT_T 150
#define RECT_W 320
#define RECT_H 240
static ClutterActor *test_rectangle = NULL;
static ClutterActor *label = NULL;
static gboolean
on_event (ClutterStage *stage,
ClutterEvent *event,
@ -29,15 +31,14 @@ on_event (ClutterStage *stage,
actor = clutter_stage_get_actor_at_pos (stage, x, y);
if (clutter_actor_transform_stage_point (actor,
CLUTTER_UNITS_FROM_DEVICE (x),
CLUTTER_UNITS_FROM_DEVICE (y),
&xu2, &yu2))
CLUTTER_UNITS_FROM_DEVICE (x),
CLUTTER_UNITS_FROM_DEVICE (y),
&xu2, &yu2))
{
gchar *txt;
if (actor != CLUTTER_ACTOR (stage))
if (actor == test_rectangle)
txt = g_strdup_printf ("Click on rectangle\n"
"Screen coords: [%d, %d]\n"
"Local coords : [%d, %d]",
@ -52,12 +53,11 @@ on_event (ClutterStage *stage,
CLUTTER_UNITS_TO_DEVICE (xu2),
CLUTTER_UNITS_TO_DEVICE (yu2));
clutter_label_set_text (CLUTTER_LABEL (label), txt);
clutter_text_set_text (CLUTTER_TEXT (label), txt);
g_free (txt);
}
else
clutter_label_set_text (CLUTTER_LABEL (label),
"Unprojection failed.");
clutter_text_set_text (CLUTTER_TEXT (label), "Unprojection failed.");
}
break;
@ -75,9 +75,9 @@ test_unproject_main (int argc, char *argv[])
gchar *txt;
ClutterActor *rect, *stage, *label0;
int i, rotate_x = 0, rotate_y = 60, rotate_z = 0;
ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
white = { 0xff, 0xff, 0xff, 0xff },
blue = { 0, 0xff, 0xff, 0xff };
blue = { 0x0, 0xff, 0xff, 0xff };
for (i = 0; i < argc; ++i)
{
@ -95,11 +95,12 @@ test_unproject_main (int argc, char *argv[])
}
else if (!strncmp (argv[i], "--help", 6))
{
printf ("%s [--rotage-x=degrees] [--rotage-y=degrees] "
"[--rotage-z=degrees]\n",
argv[0]);
g_print ("%s [--rotage-x=degrees] "
"[--rotage-y=degrees] "
"[--rotage-z=degrees]\n",
argv[0]);
exit (0);
return EXIT_FAILURE;
}
}
@ -117,6 +118,7 @@ test_unproject_main (int argc, char *argv[])
clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, rotate_y, 0, 0, 0);
clutter_actor_set_rotation (rect, CLUTTER_Z_AXIS, rotate_z, 0, 0, 0);
clutter_group_add (CLUTTER_GROUP (stage), rect);
test_rectangle = rect;
txt = g_strdup_printf ("Rectangle: L %d, R %d, T %d, B %d\n"
"Rotation : x %d, y %d, z %d",
@ -124,8 +126,8 @@ test_unproject_main (int argc, char *argv[])
RECT_T, RECT_T + RECT_H,
rotate_x, rotate_y, rotate_z);
label0 = clutter_label_new_with_text ("Mono 8pt", txt);
clutter_label_set_color (CLUTTER_LABEL (label0), &white);
label0 = clutter_text_new_with_text ("Mono 8pt", txt);
clutter_text_set_color (CLUTTER_TEXT (label0), &white);
clutter_actor_set_position (label0, 10, 10);
clutter_group_add (CLUTTER_GROUP (stage), label0);
@ -133,9 +135,9 @@ test_unproject_main (int argc, char *argv[])
g_free (txt);
label =
clutter_label_new_with_text ("Mono 8pt", "Click around!");
clutter_text_new_with_text ("Mono 8pt", "Click around!");
clutter_label_set_color (CLUTTER_LABEL (label), &blue);
clutter_text_set_color (CLUTTER_TEXT (label), &blue);
clutter_actor_set_position (label, 10, 50);
clutter_group_add (CLUTTER_GROUP (stage), label);
@ -146,5 +148,8 @@ test_unproject_main (int argc, char *argv[])
clutter_main();
test_rectangle = NULL;
label = NULL;
return EXIT_SUCCESS;
}

View File

@ -80,14 +80,14 @@ main (int argc, char *argv[])
scale = 1.0;
}
label = clutter_label_new_with_text (font_name, text);
clutter_label_set_color (CLUTTER_LABEL (label), &label_color);
label = clutter_text_new_with_text (font_name, text);
clutter_text_set_color (CLUTTER_TEXT (label), &label_color);
clutter_actor_set_position (label, (1.0*STAGE_WIDTH/COLS)*col,
(1.0*STAGE_HEIGHT/ROWS)*row);
/*clutter_actor_set_clip (label, 0,0, (1.0*STAGE_WIDTH/COLS),
(1.0*STAGE_HEIGHT/ROWS));*/
clutter_actor_set_scale (label, scale, scale);
clutter_label_set_line_wrap (CLUTTER_LABEL (label), FALSE);
clutter_text_set_line_wrap (CLUTTER_TEXT (label), FALSE);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
}
}

View File

@ -10,6 +10,12 @@ libdisable_npots_la_SOURCES = disable-npots.c
libdisable_npots_la_LIBADD = -ldl
INCLUDES = \
-I$(top_srcdir)/clutter \
-I$(top_builddir)/clutter \
$(CLUTTER_CFLAGS) \
-D_GNU_SOURCE
all-local : disable-npots.sh
clean-local :

View File

@ -4,13 +4,22 @@
* overrides glGetString and removes the extension strings.
*/
#include <GL/gl.h>
/* This is just included to get the right GL header */
#include <cogl/cogl.h>
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
/* If RTLD_NEXT isn't available then try just using NULL */
#ifdef RTLD_NEXT
#define LIB_HANDLE RTLD_NEXT
#else
#define LIB_HANDLE NULL
#endif
typedef const GLubyte * (* GetStringFunc) (GLenum name);
static const char * const bad_strings[]
@ -23,16 +32,14 @@ const GLubyte *
glGetString (GLenum name)
{
const GLubyte *ret = NULL;
static void *gl_lib = NULL;
static GetStringFunc func = NULL;
static GLubyte *extensions = NULL;
if (gl_lib == NULL
&& (gl_lib = dlopen ("libGL.so", RTLD_LAZY)) == NULL)
fprintf (stderr, "dlopen: %s\n", dlerror ());
else if (func == NULL
&& (func = (GetStringFunc) dlsym (gl_lib, "glGetString")) == NULL)
if (func == NULL
&& (func = (GetStringFunc) dlsym (LIB_HANDLE, "glGetString")) == NULL)
fprintf (stderr, "dlsym: %s\n", dlerror ());
else if (func == glGetString)
fprintf (stderr, "dlsym returned the wrapper of glGetString\n");
else
{
ret = (* func) (name);