Listen for the font-changed signal on the backend in ClutterText
Whenever a ClutterText is created it now connects to the font-changed signal. When it is emitted the layout cache is dirtied and a relayout is queued. That way changes to the font options or resolution will cause an immediate update to the labels in the scene.
This commit is contained in:
parent
1b578fb9c7
commit
89b0b00dd1
@ -155,6 +155,9 @@ struct _ClutterTextPrivate
|
||||
gint max_length;
|
||||
|
||||
gunichar password_char;
|
||||
|
||||
/* Signal handler for when the backend changes its font settings */
|
||||
guint font_changed_id;
|
||||
};
|
||||
|
||||
enum
|
||||
@ -196,6 +199,8 @@ enum
|
||||
|
||||
static guint text_signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
static void clutter_text_font_changed_cb (ClutterText *text);
|
||||
|
||||
#define offset_real(t,p) ((p) == -1 ? g_utf8_strlen ((t), -1) : (p))
|
||||
|
||||
static gint
|
||||
@ -337,6 +342,13 @@ clutter_text_dirty_cache (ClutterText *text)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_text_font_changed_cb (ClutterText *text)
|
||||
{
|
||||
clutter_text_dirty_cache (text);
|
||||
clutter_actor_queue_relayout (CLUTTER_ACTOR (text));
|
||||
}
|
||||
|
||||
/*
|
||||
* clutter_text_create_layout:
|
||||
* @text: a #ClutterText
|
||||
@ -737,10 +749,18 @@ static void
|
||||
clutter_text_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterText *self = CLUTTER_TEXT (gobject);
|
||||
ClutterTextPrivate *priv = self->priv;
|
||||
|
||||
/* get rid of the entire cache */
|
||||
clutter_text_dirty_cache (self);
|
||||
|
||||
if (priv->font_changed_id)
|
||||
{
|
||||
g_signal_handler_disconnect (clutter_get_default_backend (),
|
||||
priv->font_changed_id);
|
||||
priv->font_changed_id = 0;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (clutter_text_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
@ -2092,6 +2112,12 @@ clutter_text_init (ClutterText *self)
|
||||
priv->max_length = 0;
|
||||
|
||||
priv->cursor_size = DEFAULT_CURSOR_SIZE;
|
||||
|
||||
priv->font_changed_id
|
||||
= g_signal_connect_swapped (clutter_get_default_backend (),
|
||||
"font-changed",
|
||||
G_CALLBACK (clutter_text_font_changed_cb),
|
||||
self);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user