2006-05-29 04:59:36 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-06-21 18:34:25 -04:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-label
|
|
|
|
* @short_description: Actor for displaying text
|
|
|
|
*
|
2007-11-19 16:14:16 -05:00
|
|
|
* #ClutterLabel is a #ClutterActor that displays text using Pango.
|
2006-06-21 18:34:25 -04:00
|
|
|
*/
|
|
|
|
|
2007-10-12 04:17:00 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2006-05-29 04:59:36 -04:00
|
|
|
#include "config.h"
|
2007-10-12 04:17:00 -04:00
|
|
|
#endif
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
#include "clutter-label.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-enum-types.h"
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 16:27:53 -05:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2007-05-22 05:31:40 -04:00
|
|
|
#include "clutter-units.h"
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
#include "pangoclutter.h"
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
#define DEFAULT_FONT_NAME "Sans 10"
|
|
|
|
|
2007-11-28 08:50:24 -05:00
|
|
|
G_DEFINE_TYPE (ClutterLabel, clutter_label, CLUTTER_TYPE_ACTOR)
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
/* Probably move into main */
|
|
|
|
static PangoContext *_context = NULL;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
PROP_FONT_NAME,
|
2006-05-29 04:59:36 -04:00
|
|
|
PROP_TEXT,
|
2006-10-03 17:59:30 -04:00
|
|
|
PROP_COLOR,
|
|
|
|
PROP_ATTRIBUTES,
|
|
|
|
PROP_USE_MARKUP,
|
2007-11-19 16:14:16 -05:00
|
|
|
PROP_ALIGNMENT,
|
2006-10-03 17:59:30 -04:00
|
|
|
PROP_WRAP,
|
|
|
|
PROP_WRAP_MODE,
|
2007-11-19 16:14:16 -05:00
|
|
|
PROP_JUSTIFY,
|
2006-10-03 17:59:30 -04:00
|
|
|
PROP_ELLIPSIZE,
|
2006-05-29 04:59:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define CLUTTER_LABEL_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_LABEL, ClutterLabelPrivate))
|
|
|
|
|
|
|
|
struct _ClutterLabelPrivate
|
|
|
|
{
|
|
|
|
PangoContext *context;
|
2007-11-19 16:14:16 -05:00
|
|
|
PangoFontDescription *font_desc;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
|
|
|
ClutterColor fgcol;
|
2007-06-07 10:41:35 -04:00
|
|
|
|
2007-10-22 11:47:07 -04:00
|
|
|
ClutterActorBox allocation;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
gchar *text;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
gchar *font_name;
|
|
|
|
|
|
|
|
gint extents_width;
|
|
|
|
gint extents_height;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
guint alignment : 2;
|
|
|
|
guint wrap : 1;
|
|
|
|
guint use_underline : 1;
|
|
|
|
guint use_markup : 1;
|
|
|
|
guint ellipsize : 3;
|
|
|
|
guint single_line_mode : 1;
|
|
|
|
guint wrap_mode : 3;
|
2007-11-19 16:14:16 -05:00
|
|
|
guint justify : 1;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
PangoAttrList *attrs;
|
|
|
|
PangoAttrList *effective_attrs;
|
|
|
|
PangoLayout *layout;
|
|
|
|
gint width_chars;
|
2007-11-19 16:14:16 -05:00
|
|
|
gint wrap_width;
|
2006-10-03 17:59:30 -04:00
|
|
|
};
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
static gint
|
|
|
|
get_label_char_width (ClutterLabel *label)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
ClutterLabelPrivate *priv = label->priv;
|
|
|
|
PangoContext *context;
|
|
|
|
PangoFontMetrics *metrics;
|
|
|
|
gint char_width, digit_width, char_pixels, w;
|
|
|
|
|
|
|
|
context = pango_layout_get_context (priv->layout);
|
|
|
|
metrics = pango_context_get_metrics (context, priv->font_desc,
|
|
|
|
pango_context_get_language (context));
|
|
|
|
char_width = pango_font_metrics_get_approximate_char_width (metrics);
|
|
|
|
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
|
|
|
|
char_pixels = MAX (char_width, digit_width);
|
|
|
|
pango_font_metrics_unref (metrics);
|
|
|
|
|
|
|
|
if (priv->width_chars < 0)
|
|
|
|
{
|
|
|
|
PangoRectangle rect;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
pango_layout_set_width (priv->layout, -1);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL, &rect);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
w = char_pixels * 5;
|
|
|
|
w = MIN (rect.width, w);
|
|
|
|
}
|
|
|
|
else
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
/* enforce minimum width for ellipsized labels at ~5 chars */
|
|
|
|
w = char_pixels * MAX (priv->width_chars, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
return w;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
static gint
|
|
|
|
get_label_wrap_width (ClutterLabel *label)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
ClutterLabelPrivate *priv = label->priv;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->wrap_width < 0)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->width_chars > 0)
|
|
|
|
priv->wrap_width = get_label_char_width (label);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PangoLayout *tmp;
|
|
|
|
|
|
|
|
tmp = pango_layout_new (_context);
|
|
|
|
pango_layout_set_font_description (tmp, priv->font_desc);
|
|
|
|
pango_layout_set_text (tmp, "This is a very long string, which "
|
|
|
|
"should be enough for a wrap width.",
|
|
|
|
-1);
|
|
|
|
pango_layout_get_size (tmp, &priv->wrap_width, NULL);
|
|
|
|
g_object_unref (tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return priv->wrap_width;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
static void
|
2007-11-19 16:14:16 -05:00
|
|
|
clutter_label_ensure_layout (ClutterLabel *label)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
2007-12-21 08:18:19 -05:00
|
|
|
ClutterUnit raw_width;
|
2007-11-19 16:14:16 -05:00
|
|
|
gint width;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
/* use the last size requested, if any */
|
2007-12-21 08:18:19 -05:00
|
|
|
raw_width = priv->allocation.x2 - priv->allocation.x1;
|
|
|
|
width = CLUTTER_UNITS_TO_DEVICE (raw_width);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
if (!priv->layout)
|
|
|
|
{
|
|
|
|
priv->layout = pango_layout_new (_context);
|
|
|
|
|
|
|
|
if (priv->effective_attrs)
|
|
|
|
pango_layout_set_attributes (priv->layout, priv->effective_attrs);
|
|
|
|
|
|
|
|
pango_layout_set_alignment (priv->layout, priv->alignment);
|
|
|
|
pango_layout_set_ellipsize (priv->layout, priv->ellipsize);
|
|
|
|
pango_layout_set_single_paragraph_mode (priv->layout,
|
|
|
|
priv->single_line_mode);
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
pango_layout_set_font_description (priv->layout, priv->font_desc);
|
|
|
|
pango_layout_set_justify (priv->layout, priv->justify);
|
2007-09-28 06:54:42 -04:00
|
|
|
|
|
|
|
if (priv->text)
|
|
|
|
{
|
|
|
|
if (!priv->use_markup)
|
|
|
|
pango_layout_set_text (priv->layout, priv->text, -1);
|
|
|
|
else
|
|
|
|
pango_layout_set_markup (priv->layout, priv->text, -1);
|
|
|
|
}
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2007-12-21 08:18:19 -05:00
|
|
|
if (priv->ellipsize != PANGO_ELLIPSIZE_NONE)
|
2008-01-09 06:00:54 -05:00
|
|
|
pango_layout_set_width (priv->layout, raw_width > 0 ? CLUTTER_UNITS_TO_PANGO_UNIT (raw_width)
|
|
|
|
: -1);
|
2007-11-19 16:14:16 -05:00
|
|
|
else if (priv->wrap)
|
|
|
|
{
|
|
|
|
pango_layout_set_wrap (priv->layout, priv->wrap_mode);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (width > 0)
|
2007-12-21 08:18:19 -05:00
|
|
|
pango_layout_set_width (priv->layout, CLUTTER_UNITS_TO_PANGO_UNIT (raw_width));
|
2007-11-19 16:14:16 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this was adapted from the GtkLabel code */
|
|
|
|
ClutterActor *stage = clutter_stage_get_default ();
|
|
|
|
gint stage_width = clutter_actor_get_width (stage);
|
|
|
|
gint longest_paragraph, height, wrap_width;
|
|
|
|
PangoRectangle logical_rect;
|
|
|
|
|
|
|
|
pango_layout_set_width (priv->layout, -1);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL, &logical_rect);
|
|
|
|
|
|
|
|
width = logical_rect.width;
|
|
|
|
|
|
|
|
longest_paragraph = width;
|
|
|
|
|
|
|
|
wrap_width = get_label_wrap_width (label);
|
|
|
|
width = MAX (width, wrap_width);
|
|
|
|
width = MIN (width, PANGO_SCALE * (stage_width + 1) / 2);
|
|
|
|
|
|
|
|
pango_layout_set_width (priv->layout, width);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL, &logical_rect);
|
|
|
|
width = logical_rect.width;
|
|
|
|
height = logical_rect.height;
|
|
|
|
|
|
|
|
if (longest_paragraph > 0)
|
|
|
|
{
|
|
|
|
gint n_lines, perfect_width;
|
|
|
|
|
|
|
|
n_lines = pango_layout_get_line_count (priv->layout);
|
|
|
|
perfect_width = (longest_paragraph + n_lines - 1) / n_lines;
|
|
|
|
|
|
|
|
if (perfect_width < width)
|
|
|
|
{
|
|
|
|
pango_layout_set_width (priv->layout, perfect_width);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL,
|
|
|
|
&logical_rect);
|
|
|
|
|
|
|
|
if (logical_rect.height <= height)
|
|
|
|
width = logical_rect.width = width;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint mid_width = (perfect_width + width) / 2;
|
|
|
|
|
|
|
|
if (mid_width > perfect_width)
|
|
|
|
{
|
|
|
|
pango_layout_set_width (priv->layout, mid_width);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL,
|
|
|
|
&logical_rect);
|
|
|
|
|
|
|
|
if (logical_rect.height <= height);
|
|
|
|
width = logical_rect.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pango_layout_set_width (priv->layout, width);
|
|
|
|
}
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
else
|
2008-01-09 06:00:54 -05:00
|
|
|
pango_layout_set_width (priv->layout, raw_width > 0 ? CLUTTER_UNITS_TO_PANGO_UNIT (raw_width)
|
|
|
|
: -1);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
|
|
|
|
/* Prime the glyph cache */
|
|
|
|
pango_clutter_ensure_glyph_cache_for_layout (priv->layout);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
2007-11-19 16:14:16 -05:00
|
|
|
|
|
|
|
CLUTTER_NOTE (ACTOR, "Label width set to %d pixels", width);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_label_clear_layout (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
if (label->priv->layout)
|
|
|
|
{
|
|
|
|
g_object_unref (label->priv->layout);
|
|
|
|
label->priv->layout = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
static void
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_paint (ClutterActor *self)
|
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
ClutterLabel *label = CLUTTER_LABEL (self);
|
|
|
|
ClutterLabelPrivate *priv = label->priv;
|
2008-02-20 05:59:47 -05:00
|
|
|
ClutterColor color = { 0, };
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->font_desc == NULL || priv->text == NULL)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
CLUTTER_NOTE (ACTOR, "layout: %p, desc: %p, text %p",
|
2006-11-22 15:52:27 -05:00
|
|
|
priv->layout,
|
2007-11-19 16:14:16 -05:00
|
|
|
priv->font_desc ? priv->font_desc : 0x0,
|
|
|
|
priv->text ? priv->text : 0x0);
|
2006-10-03 17:59:30 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
CLUTTER_NOTE (PAINT, "painting label (text:`%s')", priv->text);
|
2007-10-22 11:47:07 -04:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
clutter_label_ensure_layout (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2008-02-20 05:59:47 -05:00
|
|
|
memcpy (&color, &priv->fgcol, sizeof (ClutterColor));
|
|
|
|
color.alpha = clutter_actor_get_abs_opacity (self);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2008-02-20 05:59:47 -05:00
|
|
|
pango_clutter_render_layout (priv->layout, 0, 0, &color, 0);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-19 16:14:16 -05:00
|
|
|
clutter_label_query_coords (ClutterActor *self,
|
|
|
|
ClutterActorBox *box)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
ClutterLabel *label = CLUTTER_LABEL(self);
|
2008-01-25 16:41:50 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
ClutterActorBox layout_box = { 0, };
|
2007-11-19 16:14:16 -05:00
|
|
|
PangoRectangle logical_rect;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
priv = label->priv;
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->wrap)
|
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
|
|
|
clutter_label_ensure_layout (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
pango_layout_get_extents (priv->layout, NULL, &logical_rect);
|
|
|
|
|
2008-01-25 16:41:50 -05:00
|
|
|
layout_box.x1 = box->x1;
|
|
|
|
layout_box.x2 = box->x1 + CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.width);
|
|
|
|
layout_box.y1 = box->y1;
|
|
|
|
layout_box.y2 = box->y1 + CLUTTER_UNITS_FROM_PANGO_UNIT (logical_rect.height);
|
|
|
|
|
|
|
|
if ((priv->allocation.x2 - priv->allocation.x1) > 0)
|
|
|
|
{
|
|
|
|
ClutterUnit alloc_width, alloc_height;
|
|
|
|
|
|
|
|
alloc_width = priv->allocation.x2 - priv->allocation.x1;
|
|
|
|
alloc_height = priv->allocation.y2 - priv->allocation.y1;
|
|
|
|
|
|
|
|
if ((alloc_width >= (layout_box.x2 - layout_box.x1)) &&
|
|
|
|
(alloc_height >= (layout_box.y2 - layout_box.y1)))
|
|
|
|
*box = priv->allocation;
|
|
|
|
else
|
|
|
|
*box = layout_box;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*box = layout_box;
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-11-19 16:14:16 -05:00
|
|
|
clutter_label_request_coords (ClutterActor *self,
|
|
|
|
ClutterActorBox *box)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2007-10-22 11:47:07 -04:00
|
|
|
ClutterLabel *label = CLUTTER_LABEL (self);
|
|
|
|
ClutterLabelPrivate *priv = label->priv;
|
|
|
|
|
|
|
|
if (priv->ellipsize)
|
|
|
|
{
|
|
|
|
if (priv->layout)
|
|
|
|
{
|
|
|
|
gint width;
|
|
|
|
PangoRectangle logical;
|
|
|
|
|
2007-12-21 08:18:19 -05:00
|
|
|
width = CLUTTER_UNITS_TO_PANGO_UNIT (box->x2 - box->x1);
|
2007-10-22 11:47:07 -04:00
|
|
|
|
|
|
|
pango_layout_set_width (priv->layout, -1);
|
|
|
|
pango_layout_get_extents (priv->layout, NULL, &logical);
|
|
|
|
|
|
|
|
if (logical.width > width)
|
|
|
|
pango_layout_set_width (priv->layout, width);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
clutter_label_clear_layout (label);
|
2007-11-19 16:14:16 -05:00
|
|
|
|
|
|
|
priv->allocation = *box;
|
2007-11-23 12:12:27 -05:00
|
|
|
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_label_parent_class)->request_coords (self, box);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_label_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterLabel *self = CLUTTER_LABEL(object);
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
priv = self->priv;
|
2007-11-19 16:14:16 -05:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
if (priv->layout)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
g_object_unref (priv->layout);
|
|
|
|
priv->layout = NULL;
|
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
if (priv->context)
|
|
|
|
{
|
|
|
|
g_object_unref (priv->context);
|
|
|
|
priv->context = NULL;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_label_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_label_finalize (GObject *object)
|
|
|
|
{
|
2007-11-06 09:35:22 -05:00
|
|
|
ClutterLabel *self = CLUTTER_LABEL(object);
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
priv = self->priv;
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->font_desc)
|
|
|
|
pango_font_description_free (priv->font_desc);
|
2007-11-06 09:35:22 -05:00
|
|
|
|
|
|
|
g_free (priv->text);
|
|
|
|
g_free (priv->font_name);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
G_OBJECT_CLASS (clutter_label_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
static void
|
|
|
|
clutter_label_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterLabel *label;
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
label = CLUTTER_LABEL(object);
|
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_FONT_NAME:
|
|
|
|
clutter_label_set_font_name (label, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_TEXT:
|
|
|
|
clutter_label_set_text (label, g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_COLOR:
|
|
|
|
clutter_label_set_color (label, g_value_get_boxed (value));
|
|
|
|
break;
|
|
|
|
case PROP_ATTRIBUTES:
|
|
|
|
clutter_label_set_attributes (label, g_value_get_boxed (value));
|
|
|
|
break;
|
|
|
|
case PROP_ALIGNMENT:
|
|
|
|
clutter_label_set_alignment (label, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
case PROP_USE_MARKUP:
|
|
|
|
clutter_label_set_use_markup (label, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_WRAP:
|
|
|
|
clutter_label_set_line_wrap (label, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_JUSTIFY:
|
|
|
|
clutter_label_set_justify (label, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
case PROP_WRAP_MODE:
|
|
|
|
clutter_label_set_line_wrap_mode (label, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
clutter_label_set_ellipsize (label, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_label_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterLabel *label;
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
ClutterColor color;
|
|
|
|
|
|
|
|
label = CLUTTER_LABEL (object);
|
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_FONT_NAME:
|
|
|
|
g_value_set_string (value, priv->font_name);
|
|
|
|
break;
|
|
|
|
case PROP_TEXT:
|
|
|
|
g_value_set_string (value, priv->text);
|
|
|
|
break;
|
|
|
|
case PROP_COLOR:
|
|
|
|
clutter_label_get_color (label, &color);
|
|
|
|
g_value_set_boxed (value, &color);
|
|
|
|
break;
|
|
|
|
case PROP_ATTRIBUTES:
|
|
|
|
g_value_set_boxed (value, priv->attrs);
|
|
|
|
break;
|
|
|
|
case PROP_ALIGNMENT:
|
|
|
|
g_value_set_enum (value, priv->alignment);
|
|
|
|
break;
|
|
|
|
case PROP_USE_MARKUP:
|
|
|
|
g_value_set_boolean (value, priv->use_markup);
|
|
|
|
break;
|
|
|
|
case PROP_JUSTIFY:
|
|
|
|
g_value_set_boolean (value, priv->justify);
|
|
|
|
break;
|
|
|
|
case PROP_WRAP:
|
|
|
|
g_value_set_boolean (value, priv->wrap);
|
|
|
|
break;
|
|
|
|
case PROP_WRAP_MODE:
|
|
|
|
g_value_set_enum (value, priv->wrap_mode);
|
|
|
|
break;
|
|
|
|
case PROP_ELLIPSIZE:
|
|
|
|
g_value_set_enum (value, priv->ellipsize);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-07 10:41:35 -04:00
|
|
|
}
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
static void
|
|
|
|
clutter_label_class_init (ClutterLabelClass *klass)
|
|
|
|
{
|
2007-12-21 08:18:19 -05:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
actor_class->paint = clutter_label_paint;
|
|
|
|
actor_class->request_coords = clutter_label_request_coords;
|
2007-06-13 19:24:59 -04:00
|
|
|
actor_class->query_coords = clutter_label_query_coords;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-12-21 08:18:19 -05:00
|
|
|
gobject_class->finalize = clutter_label_finalize;
|
|
|
|
gobject_class->dispose = clutter_label_dispose;
|
2006-05-29 04:59:36 -04:00
|
|
|
gobject_class->set_property = clutter_label_set_property;
|
|
|
|
gobject_class->get_property = clutter_label_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
(gobject_class, PROP_FONT_NAME,
|
|
|
|
g_param_spec_string ("font-name",
|
|
|
|
"Font Name",
|
2006-05-29 04:59:36 -04:00
|
|
|
"Pango font description",
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
NULL,
|
2007-11-20 11:05:56 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-05-29 04:59:36 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_TEXT,
|
|
|
|
g_param_spec_string ("text",
|
|
|
|
"Text",
|
|
|
|
"Text to render",
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
NULL,
|
2007-11-20 11:05:56 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-05-29 04:59:36 -04:00
|
|
|
g_object_class_install_property
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
(gobject_class, PROP_COLOR,
|
|
|
|
g_param_spec_boxed ("color",
|
|
|
|
"Font Colour",
|
|
|
|
"Font Colour",
|
|
|
|
CLUTTER_TYPE_COLOR,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_ATTRIBUTES,
|
|
|
|
g_param_spec_boxed ("attributes",
|
|
|
|
"Attributes",
|
2008-02-15 11:26:00 -05:00
|
|
|
"A list of style attributes to apply to the "
|
2006-10-03 17:59:30 -04:00
|
|
|
"text of the label",
|
|
|
|
PANGO_TYPE_ATTR_LIST,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_USE_MARKUP,
|
|
|
|
g_param_spec_boolean ("use-markup",
|
|
|
|
"Use markup",
|
2008-02-15 11:26:00 -05:00
|
|
|
"The text of the label includes XML markup. "
|
2006-10-03 17:59:30 -04:00
|
|
|
"See pango_parse_markup()",
|
|
|
|
FALSE,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_WRAP,
|
|
|
|
g_param_spec_boolean ("wrap",
|
|
|
|
"Line wrap",
|
|
|
|
"If set, wrap lines if the text becomes too wide",
|
2007-11-19 16:14:16 -05:00
|
|
|
FALSE,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_WRAP_MODE,
|
|
|
|
g_param_spec_enum ("wrap-mode",
|
|
|
|
"Line wrap mode",
|
2008-02-15 11:26:00 -05:00
|
|
|
"If wrap is set, controls how line-wrapping is done",
|
2006-10-03 17:59:30 -04:00
|
|
|
PANGO_TYPE_WRAP_MODE,
|
|
|
|
PANGO_WRAP_WORD,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_ELLIPSIZE,
|
|
|
|
g_param_spec_enum ( "ellipsize",
|
|
|
|
"Ellipsize",
|
2008-02-15 11:26:00 -05:00
|
|
|
"The preferred place to ellipsize the string, "
|
2006-10-03 17:59:30 -04:00
|
|
|
"if the label does not have enough room to "
|
|
|
|
"display the entire string",
|
|
|
|
PANGO_TYPE_ELLIPSIZE_MODE,
|
|
|
|
PANGO_ELLIPSIZE_NONE,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_ALIGNMENT,
|
|
|
|
g_param_spec_enum ( "alignment",
|
|
|
|
"Alignment",
|
2007-11-19 16:14:16 -05:00
|
|
|
"The preferred alignment for the string",
|
2006-10-03 17:59:30 -04:00
|
|
|
PANGO_TYPE_ALIGNMENT,
|
|
|
|
PANGO_ALIGN_LEFT,
|
2006-12-04 11:26:35 -05:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2007-11-19 16:14:16 -05:00
|
|
|
/**
|
|
|
|
* ClutterLabel:justify:
|
|
|
|
*
|
|
|
|
* Whether the contents of the label should be justified on both
|
|
|
|
* margins.
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_JUSTIFY,
|
|
|
|
g_param_spec_boolean ("justify",
|
|
|
|
"Justify",
|
|
|
|
"Whether the contents of the label should be justified",
|
|
|
|
FALSE,
|
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
g_type_class_add_private (gobject_class, sizeof (ClutterLabelPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_label_init (ClutterLabel *self)
|
|
|
|
{
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
self->priv = priv = CLUTTER_LABEL_GET_PRIVATE (self);
|
|
|
|
|
2007-08-02 05:58:18 -04:00
|
|
|
if (G_UNLIKELY (_context == NULL))
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
|
|
|
PangoClutterFontMap *font_map = CLUTTER_CONTEXT ()->font_map;
|
2007-08-02 05:58:18 -04:00
|
|
|
gdouble resolution;
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
cairo_font_options_t *font_options;
|
|
|
|
|
|
|
|
_context = pango_clutter_font_map_create_context (font_map);
|
2007-08-02 05:58:18 -04:00
|
|
|
|
|
|
|
resolution = clutter_backend_get_resolution (backend);
|
2008-06-06 10:44:49 -04:00
|
|
|
if (resolution < 0)
|
|
|
|
resolution = 96.0;
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
pango_cairo_context_set_resolution (_context, resolution);
|
2007-08-02 05:58:18 -04:00
|
|
|
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
font_options = clutter_backend_get_font_options (backend);
|
|
|
|
pango_cairo_context_set_font_options (_context, font_options);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
priv->alignment = PANGO_ALIGN_LEFT;
|
2007-11-19 16:14:16 -05:00
|
|
|
priv->wrap = FALSE;
|
2006-10-03 17:59:30 -04:00
|
|
|
priv->wrap_mode = PANGO_WRAP_WORD;
|
|
|
|
priv->ellipsize = PANGO_ELLIPSIZE_NONE;
|
|
|
|
priv->use_underline = FALSE;
|
|
|
|
priv->use_markup = FALSE;
|
2007-11-19 16:14:16 -05:00
|
|
|
priv->justify = FALSE;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
priv->layout = NULL;
|
|
|
|
priv->text = NULL;
|
|
|
|
priv->attrs = NULL;
|
2007-11-19 16:14:16 -05:00
|
|
|
|
|
|
|
priv->width_chars = -1;
|
|
|
|
priv->wrap_width = -1;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
priv->fgcol.red = 0;
|
|
|
|
priv->fgcol.green = 0;
|
|
|
|
priv->fgcol.blue = 0;
|
|
|
|
priv->fgcol.alpha = 255;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
priv->font_name = g_strdup (DEFAULT_FONT_NAME);
|
2007-11-19 16:14:16 -05:00
|
|
|
priv->font_desc = pango_font_description_from_string (priv->font_name);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_new_with_text:
|
|
|
|
* @font_name: the name (and size) of the font to be used
|
|
|
|
* @text: the text to be displayed
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterLabel displaying @text using @font_name.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterLabel
|
|
|
|
*/
|
2006-06-20 16:29:45 -04:00
|
|
|
ClutterActor*
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
clutter_label_new_with_text (const gchar *font_name,
|
|
|
|
const gchar *text)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
return g_object_new (CLUTTER_TYPE_LABEL,
|
|
|
|
"font-name", font_name,
|
|
|
|
"text", text,
|
|
|
|
NULL);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2007-01-04 14:56:01 -05:00
|
|
|
/**
|
|
|
|
* clutter_label_new_full:
|
|
|
|
* @font_name: the name (and size) of the font to be used
|
|
|
|
* @text: the text to be displayed
|
|
|
|
* @color: #ClutterColor for text
|
|
|
|
*
|
2008-02-15 12:11:50 -05:00
|
|
|
* Creates a new #ClutterLabel displaying @text with @color
|
2007-01-04 14:56:01 -05:00
|
|
|
* using @font_name.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterLabel
|
|
|
|
*/
|
|
|
|
ClutterActor*
|
2007-11-18 19:02:13 -05:00
|
|
|
clutter_label_new_full (const gchar *font_name,
|
|
|
|
const gchar *text,
|
|
|
|
const ClutterColor *color)
|
2007-01-04 14:56:01 -05:00
|
|
|
{
|
2007-11-19 16:14:16 -05:00
|
|
|
return g_object_new (CLUTTER_TYPE_LABEL,
|
|
|
|
"font-name", font_name,
|
|
|
|
"text", text,
|
2007-11-22 08:41:00 -05:00
|
|
|
"color", color,
|
|
|
|
NULL);
|
2007-01-04 14:56:01 -05:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_new:
|
|
|
|
*
|
|
|
|
* Creates a new, empty #ClutterLabel.
|
|
|
|
*
|
2006-06-22 05:24:15 -04:00
|
|
|
* Returns: the newly created #ClutterLabel
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
*/
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActor *
|
2006-05-29 04:59:36 -04:00
|
|
|
clutter_label_new (void)
|
|
|
|
{
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
return g_object_new (CLUTTER_TYPE_LABEL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_text:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Retrieves the text displayed by @label
|
|
|
|
*
|
|
|
|
* Return value: the text of the label. The returned string is
|
2006-10-03 17:59:30 -04:00
|
|
|
* owned by #ClutterLabel and should not be modified or freed.
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
|
|
|
clutter_label_get_text (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), NULL);
|
|
|
|
|
|
|
|
return label->priv->text;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_set_text:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @text: the text to be displayed
|
|
|
|
*
|
|
|
|
* Sets @text as the text to be displayed by @label.
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
void
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
clutter_label_set_text (ClutterLabel *label,
|
|
|
|
const gchar *text)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
|
|
|
|
priv = label->priv;
|
2006-12-17 11:52:40 -05:00
|
|
|
|
|
|
|
g_object_ref (label);
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
g_free (priv->text);
|
|
|
|
priv->text = g_strdup (text);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_clear_layout (label);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
/* Recreate the layout now so that the glyph cache will be primed
|
|
|
|
outside of the paint run */
|
|
|
|
clutter_label_ensure_layout (label);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR(label));
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "text");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_get_font_name:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Retrieves the font used by @label.
|
|
|
|
*
|
|
|
|
* Return value: a string containing the font name, in a format
|
|
|
|
* understandable by pango_font_description_from_string(). The
|
2008-02-15 11:26:00 -05:00
|
|
|
* string is owned by @label and should not be modified
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
* or freed.
|
|
|
|
*/
|
|
|
|
G_CONST_RETURN gchar *
|
|
|
|
clutter_label_get_font_name (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), NULL);
|
|
|
|
|
|
|
|
return label->priv->font_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_font_name:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @font_name: a font name and size, or %NULL for the default font
|
|
|
|
*
|
|
|
|
* Sets @font_name as the font used by @label.
|
|
|
|
*
|
|
|
|
* @font_name must be a string containing the font name and its
|
|
|
|
* size, similarly to what you would feed to the
|
|
|
|
* pango_font_description_from_string() function.
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
void
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
clutter_label_set_font_name (ClutterLabel *label,
|
|
|
|
const gchar *font_name)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
PangoFontDescription *desc;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
|
|
|
if (!font_name || font_name[0] == '\0')
|
|
|
|
font_name = DEFAULT_FONT_NAME;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
priv = label->priv;
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (strcmp (priv->font_name, font_name) == 0)
|
|
|
|
return;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
desc = pango_font_description_from_string (font_name);
|
|
|
|
if (!desc)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
{
|
|
|
|
g_warning ("Attempting to create a PangoFontDescription for "
|
|
|
|
"font name `%s', but failed.",
|
2006-12-17 11:52:40 -05:00
|
|
|
font_name);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
return;
|
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
g_free (priv->font_name);
|
|
|
|
priv->font_name = g_strdup (font_name);
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (priv->font_desc)
|
|
|
|
pango_font_description_free (priv->font_desc);
|
2006-12-17 11:52:40 -05:00
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
priv->font_desc = desc;
|
|
|
|
priv->wrap_width = -1;
|
2006-12-17 11:52:40 -05:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
if (label->priv->text && label->priv->text[0] != '\0')
|
|
|
|
{
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_clear_layout (label);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
/* Recreate the layout now so that the glyph cache will be
|
|
|
|
primed outside of the paint run */
|
|
|
|
clutter_label_ensure_layout (label);
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (label))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "font-name");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_set_color:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @color: a #ClutterColor
|
|
|
|
*
|
|
|
|
* Sets the color of @label.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_label_set_color (ClutterLabel *label,
|
|
|
|
const ClutterColor *color)
|
|
|
|
{
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActor *actor;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
priv = label->priv;
|
2006-12-17 11:52:40 -05:00
|
|
|
|
|
|
|
g_object_ref (label);
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
priv->fgcol.red = color->red;
|
|
|
|
priv->fgcol.green = color->green;
|
|
|
|
priv->fgcol.blue = color->blue;
|
|
|
|
priv->fgcol.alpha = color->alpha;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
actor = CLUTTER_ACTOR (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_actor_set_opacity (actor, priv->fgcol.alpha);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (actor))
|
|
|
|
clutter_actor_queue_redraw (actor);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "color");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
/**
|
|
|
|
* clutter_label_get_color:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @color: return location for a #ClutterColor
|
|
|
|
*
|
|
|
|
* Retrieves the color of @label.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_label_get_color (ClutterLabel *label,
|
|
|
|
ClutterColor *color)
|
|
|
|
{
|
|
|
|
ClutterLabelPrivate *priv;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
color->red = priv->fgcol.red;
|
|
|
|
color->green = priv->fgcol.green;
|
|
|
|
color->blue = priv->fgcol.blue;
|
|
|
|
color->alpha = priv->fgcol.alpha;
|
|
|
|
}
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_ellipsize:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @mode: a #PangoEllipsizeMode
|
|
|
|
*
|
|
|
|
* Sets the mode used to ellipsize (add an ellipsis: "...") to the text
|
|
|
|
* if there is not enough space to render the entire string.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_label_set_ellipsize (ClutterLabel *label,
|
|
|
|
PangoEllipsizeMode mode)
|
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
2006-12-17 11:52:40 -05:00
|
|
|
g_return_if_fail (mode >= PANGO_ELLIPSIZE_NONE &&
|
|
|
|
mode <= PANGO_ELLIPSIZE_END);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
if ((PangoEllipsizeMode) priv->ellipsize != mode)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
priv->ellipsize = mode;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
clutter_label_clear_layout (label);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
/* Recreate the layout now so that the glyph cache will be
|
|
|
|
primed outside of the paint run */
|
|
|
|
clutter_label_ensure_layout (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR(label));
|
2006-12-17 11:52:40 -05:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "ellipsize");
|
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_ellipsize:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Returns the ellipsizing position of the label.
|
|
|
|
* See clutter_label_set_ellipsize().
|
|
|
|
*
|
|
|
|
* Return value: #PangoEllipsizeMode
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
PangoEllipsizeMode
|
|
|
|
clutter_label_get_ellipsize (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), PANGO_ELLIPSIZE_NONE);
|
|
|
|
|
|
|
|
return label->priv->ellipsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_line_wrap:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @wrap: the setting
|
|
|
|
*
|
2006-12-17 11:52:40 -05:00
|
|
|
* Toggles line wrapping within the #ClutterLabel widget. %TRUE makes
|
|
|
|
* it break lines if text exceeds the widget's size. %FALSE lets the
|
|
|
|
* text get cut off by the edge of the widget if it exceeds the widget
|
|
|
|
* size.
|
2006-10-03 17:59:30 -04:00
|
|
|
*
|
2006-12-17 11:52:40 -05:00
|
|
|
* Since: 0.2
|
|
|
|
*/
|
2006-10-03 17:59:30 -04:00
|
|
|
void
|
|
|
|
clutter_label_set_line_wrap (ClutterLabel *label,
|
|
|
|
gboolean wrap)
|
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
2006-12-17 11:52:40 -05:00
|
|
|
|
|
|
|
priv = label->priv;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
wrap = wrap != FALSE;
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (priv->wrap != wrap)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
priv->wrap = wrap;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "wrap");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_line_wrap:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Returns whether lines in the label are automatically wrapped.
|
|
|
|
* See clutter_label_set_line_wrap ().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the lines of the label are automatically wrapped.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_label_get_line_wrap (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), FALSE);
|
|
|
|
|
|
|
|
return label->priv->wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_line_wrap_mode:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @wrap_mode: the line wrapping mode
|
|
|
|
*
|
|
|
|
* If line wrapping is on (see clutter_label_set_line_wrap()) this controls how
|
|
|
|
* the line wrapping is done. The default is %PANGO_WRAP_WORD which means
|
|
|
|
* wrap on word boundaries.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_label_set_line_wrap_mode (ClutterLabel *label,
|
|
|
|
PangoWrapMode wrap_mode)
|
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
2006-12-17 11:52:40 -05:00
|
|
|
|
|
|
|
priv = label->priv;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (priv->wrap_mode != wrap_mode)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
priv->wrap_mode = wrap_mode;
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "wrap-mode");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_line_wrap_mode:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
2006-12-17 11:52:40 -05:00
|
|
|
* Returns line wrap mode used by the label.
|
|
|
|
* See clutter_label_set_line_wrap_mode ().
|
2006-10-03 17:59:30 -04:00
|
|
|
*
|
|
|
|
* Return value: %TRUE if the lines of the label are automatically wrapped.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
PangoWrapMode
|
|
|
|
clutter_label_get_line_wrap_mode (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), FALSE);
|
|
|
|
|
|
|
|
return label->priv->wrap_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_layout:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Gets the #PangoLayout used to display the label.
|
|
|
|
* The layout is useful to e.g. convert text positions to
|
|
|
|
* pixel positions.
|
|
|
|
* The returned layout is owned by the label so need not be
|
|
|
|
* freed by the caller.
|
|
|
|
*
|
|
|
|
* Return value: the #PangoLayout for this label
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
PangoLayout*
|
|
|
|
clutter_label_get_layout (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), NULL);
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
clutter_label_ensure_layout (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
return label->priv->layout;
|
|
|
|
}
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
static inline void
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_set_attributes_internal (ClutterLabel *label,
|
|
|
|
PangoAttrList *attrs)
|
|
|
|
{
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
priv = label->priv;
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
if (attrs)
|
|
|
|
pango_attr_list_ref (attrs);
|
|
|
|
|
|
|
|
if (priv->attrs)
|
|
|
|
pango_attr_list_unref (priv->attrs);
|
|
|
|
|
|
|
|
if (!priv->use_markup)
|
|
|
|
{
|
|
|
|
if (attrs)
|
|
|
|
pango_attr_list_ref (attrs);
|
|
|
|
if (priv->effective_attrs)
|
|
|
|
pango_attr_list_unref (priv->effective_attrs);
|
|
|
|
priv->effective_attrs = attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
label->priv->attrs = attrs;
|
|
|
|
g_object_notify (G_OBJECT (label), "attributes");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_attributes:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @attrs: a #PangoAttrList
|
|
|
|
*
|
|
|
|
* Sets a #PangoAttrList; the attributes in the list are applied to the
|
|
|
|
* label text. The attributes set with this function will be ignored
|
|
|
|
* if the "use_markup" property
|
|
|
|
* is %TRUE.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_label_set_attributes (ClutterLabel *label,
|
|
|
|
PangoAttrList *attrs)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
|
|
|
|
clutter_label_set_attributes_internal (label, attrs);
|
|
|
|
|
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR(label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR(label));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_attributes:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Gets the attribute list that was set on the label using
|
|
|
|
* clutter_label_set_attributes(), if any.
|
|
|
|
*
|
|
|
|
* Return value: the attribute list, or %NULL if none was set.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
**/
|
|
|
|
PangoAttrList *
|
|
|
|
clutter_label_get_attributes (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), NULL);
|
|
|
|
|
|
|
|
return label->priv->attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_use_markup:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @setting: %TRUE if the label's text should be parsed for markup.
|
|
|
|
*
|
|
|
|
* Sets whether the text of the label contains markup in <link
|
|
|
|
* linkend="PangoMarkupFormat">Pango's text markup
|
2007-03-19 13:02:48 -04:00
|
|
|
* language</link>.
|
2006-10-03 17:59:30 -04:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_label_set_use_markup (ClutterLabel *label,
|
|
|
|
gboolean setting)
|
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
if (priv->use_markup != setting)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
priv->use_markup = setting;
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_clear_layout (label);
|
2008-05-28 Emmanuele Bassi <ebassi@openedhand.com>
Bug #919 - Replacement pango renderer (Neil Roberts)
* clutter/clutter-backend.h:
* clutter/clutter-backend.c:
(clutter_backend_set_font_options),
(clutter_backend_get_font_options): Add the ability to set
the cairo_font_options_t* for the backend at construction
time, so that backend implementations can have their own
options.
* clutter/clutter-color.c: Include pango/pango-attributes.h
for the pango_color_parse() function.
* clutter/clutter-label.c:
(clutter_label_ensure_layout),
(clutter_label_init), (clutter_label_set_text),
(clutter_label_set_font_name), (clutter_label_set_ellipsize),
(clutter_label_set_use_markup): Ensure that the cache is
always primed when the Label changes; this makes sure that
the cache is rebuilt outside the paint run, which should
make the painting perform better especially on embedded
devices.
* clutter/clutter-entry.c:
(clutter_entry_ensure_layout),
(clutter_entry_init), (clutter_entry_set_text),
(clutter_entry_set_font_name): Ditto as above.
* clutter/clutter-private.h:
* clutter/clutter-main.[ch]: Create the font-map inside the
main context; add two new functions:
clutter_clear_glyph_cache()
clutter_set_use_mipmapped_text()
that control the glyphs cache.
* clutter/pango/Makefile.am:
* clutter/pango/pangoclutter-fontmap.c:
* clutter/pango/pangoclutter-private.h:
* clutter/pango/pangoclutter-render.c:
* clutter/pango/pangoclutter.h: Rewrite the Pango renderer
using a PangoCairo context and saving the glyphs inside a
more efficient cache.
* configure.ac: Depend on pangocairo instead of pangoft2.
2008-05-28 10:03:28 -04:00
|
|
|
/* Recreate the layout now so that the glyph cache will be
|
|
|
|
primed outside of the paint run */
|
|
|
|
clutter_label_ensure_layout (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "use-markup");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_use_markup:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Returns whether the label's text is interpreted as marked up with
|
|
|
|
* the <link linkend="PangoMarkupFormat">Pango text markup
|
|
|
|
* language</link>. See clutter_label_set_use_markup ().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the label's text will be parsed for markup.
|
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
clutter_label_get_use_markup (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), FALSE);
|
|
|
|
|
|
|
|
return label->priv->use_markup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_set_alignment:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @alignment: A #PangoAlignment
|
|
|
|
*
|
|
|
|
* Sets text alignment of the label.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
clutter_label_set_alignment (ClutterLabel *label,
|
|
|
|
PangoAlignment alignment)
|
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
2006-10-03 17:59:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
if (priv->alignment != alignment)
|
2006-10-03 17:59:30 -04:00
|
|
|
{
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_ref (label);
|
|
|
|
|
|
|
|
priv->alignment = alignment;
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
2006-12-17 11:52:40 -05:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (label)))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
2006-10-03 17:59:30 -04:00
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "alignment");
|
2006-12-17 11:52:40 -05:00
|
|
|
g_object_unref (label);
|
2006-10-03 17:59:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_alignment:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Returns the label's text alignment
|
|
|
|
*
|
2008-02-15 11:26:00 -05:00
|
|
|
* Return value: The label's #PangoAlignment
|
2006-10-03 17:59:30 -04:00
|
|
|
*
|
|
|
|
* Since 0.2
|
|
|
|
**/
|
2007-07-25 10:25:01 -04:00
|
|
|
PangoAlignment
|
2006-10-03 17:59:30 -04:00
|
|
|
clutter_label_get_alignment (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), FALSE);
|
|
|
|
|
|
|
|
return label->priv->alignment;
|
|
|
|
}
|
|
|
|
|
2007-11-19 16:14:16 -05:00
|
|
|
/**
|
|
|
|
* clutter_label_set_justify:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
* @justify: whether the text should be justified
|
|
|
|
*
|
|
|
|
* Sets whether the text of the @label actor should be justified
|
|
|
|
* on both margins. This setting is ignored if Clutter is compiled
|
2008-02-15 11:26:00 -05:00
|
|
|
* against Pango < 1.18.
|
2007-11-19 16:14:16 -05:00
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_label_set_justify (ClutterLabel *label,
|
|
|
|
gboolean justify)
|
|
|
|
{
|
|
|
|
ClutterLabelPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_LABEL (label));
|
|
|
|
|
|
|
|
priv = label->priv;
|
|
|
|
|
|
|
|
if (priv->justify != justify)
|
|
|
|
{
|
|
|
|
priv->justify = justify;
|
|
|
|
|
|
|
|
clutter_label_clear_layout (label);
|
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (label))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (label));
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (label), "justify");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_label_get_justify:
|
|
|
|
* @label: a #ClutterLabel
|
|
|
|
*
|
|
|
|
* Retrieves whether the label should justify the text on both margins.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the text should be justified
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_label_get_justify (ClutterLabel *label)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_LABEL (label), FALSE);
|
|
|
|
|
|
|
|
return label->priv->justify;
|
|
|
|
}
|