Update the documentation of :font-name, to make it clear that by setting
it to NULL the Text actor will use the default font.
Also, set the annotation for the @font_name argument of the setter to be
allow-none, and allow passing NULL through bindings.
If a ClutterText actor is using the default font from the backend then
we should track font name changes and update it accordingly. This only
applies to ClutterText actors with the :font-name property unset or
explicitly set to NULL.
When converting the floating point allocation width to an integer
multiple of PANGO_SCALE to give to the PangoLayout it can sometimes
end up slightly short of the allocated size due to rounding
errors. This can cause some of the lines to be wrapped differently
when a non-integer-aligned position is used (such as when animating
text). It works better to round the number to the nearest integer by
adding 0.5 instead of letting the default float cast truncate it
downwards.
http://bugzilla.openedhand.com/show_bug.cgi?id=2170
The marshallers we use for the signals are declared in a private header,
and it stands to reason that they should also be hidden in the shared
object by using the common '_' prefix. We are also using some direct
g_cclosure_marshal_* symbol from GLib, instead of consistently use the
clutter_marshal_* symbol.
If a cached layout didn't actually match the layout we're looking for,
it would be returned anyway. Remove this return so that it can correctly
continue looking and get a cache miss if appropriate.
http://bugzilla.openedhand.com/show_bug.cgi?id=2109
This patch combines a number of fixes and improvements to the
layout caching logic in ClutterText.
* Fix: The width must always be set on the PangoLayout when painting.
This is necessary because the layout aligns in the width, and
even when we think we are left-aligned, the auto-dir feature
of PangoLayout may result in right-alignment.
* Fix: We should only ever try to reuse a cached layout based
on its logical width if layout.width was -1 when computing
that logical width. If the layout was already ellipsized,
then comparing the logical width to the new width we are
trying to wrap to doesn't make sense. (If "abc" ellipsizes
to a 15-pixel wide "..." for a width of 1 pixel, that doesn't
mean that we should use "..." for a width of 15 pixels. Maybe
"abc" itself is 15 pixels wide.)
* Improvement: rather than looking up cached layouts based on the
input allocation_width/allocation_height, look them up based
on the actual width/height/ellipsize that we pass to create
a layout. This is simpler and improves the chance we'll get
a cache hit when appropriate even if there are small floating
point differences.
Note because of the first fix this is less aggressive than dd40732
in caching layouts; get_preferred_width() and painting can't share
a layout since get_preferred_width() needs to pass a width of -1
to Pango and painting needs to pass the real width.
The patch has been updated from the clutter-1.2 branch to current
master; using the profiling instrumentation it is possible to verify
with test-text-field that the hit/miss counters go from:
Name Total Per Frame
---- ----- ---------
Text layout cache hit counter 13 6
Text layout cache miss counter 11 5
before applying the patch, to:
Name Total Per Frame
---- ----- ---------
Text layout cache miss counter 4 2
Text layout cache hit counter 3 1
after applying the patch.
https://bugzilla.gnome.org/show_bug.cgi?id=618104http://bugzilla.openedhand.com/show_bug.cgi?id=2109
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Currently, each ClutterText caches 3 Pango layouts:
» one for the preferred, unbounded width
» one for the preferred height for a given width
» one for the allocated size
Some layout managers do a double pass that could flush the whole cache
before it has a chance of actually storing relevant data, resulting in
a continuous series of misses.
We can try to counteract this by doubling the size of the cache, from
three slots to six. More than six would be pointless, as well as too
memory consuming; but we might get down to a number between 3 and 6 at
any later point.
By comparing the requested size against the computed sized for existing
Pango layouts we can avoid creating layouts where the requested size
matches that of a previously computed one.
In particular this optimisation means that when working with a fixed
positioning based layout (with no constraints on the size of the
ClutterText) the same PangoLayout can be used to calculate the preferred
width, height and also the layout used for the actual painting.
http://bugzilla.openedhand.com/show_bug.cgi?id=2078
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This replaces code like this:
if (CLUTTER_ACTOR_IS_VISIBLE (self))
clutter_actor_queue_redraw (self);
with:
clutter_actor_queue_redraw (self);
clutter_actor_queue_redraw internally knows what can be optimized when
the actor is not visible, but it also knows that the queue_redraw signal
must always be sent in case a ClutterClone is cloning a hidden actor.
Instead of returning a sub-pixel height round up the preferred height to
the nearest integral value that is not less than the size reported by
Pango, once converted in pixels.
Bind ctrl-backspace and ctrl-del to functions that delete a word before
or after the cursor, respectively.
Selection does not affect the deletion, but current selection is
preserved. This mimicks GTK+ functionality in GtkTextView and GtkEntry.
http://bugzilla.openedhand.com/show_bug.cgi?id=1767
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
High level toolkits might wish to construct a PangoFontDescription and
then set it directly on a ClutterText actor proxy or sub-class.
ClutterText should have a :font-description property to set (and get)
the PangoFontDescription.
http://bugzilla.openedhand.com/show_bug.cgi?id=1960
The commit ecbb7ce41a exposed some issues
when positioning the cursor with the mouse pointer: the selection is
not moved along with the cursor when inserting a single character or a
string.
Also, some freeze_notify() are called too early, leading to decoupling
from their respective thaw_notify().
http://bugzilla.openedhand.com/show_bug.cgi?id=1955
Added a "selection-bound" notify on clutter_text_clear_selection as it
changes the value.
Added utility function clutter_text_set_positions, in order to
change both cursor position and selection bound inside a
g_object_[freeze/thaw]_notify block
Added g_object_[freeze/thaw]_notify in other functions that changes
both cursor position and selection bound
Solves http://bugzilla.openedhand.com/show_bug.cgi?id=1955
Previously when the markup property is set it would generate an
attribute list from the markup and then merge it with the attributes
from the attribute property and store it as the effective
attributes. The markup attributes and the marked up text would then be
forgotten. This breaks if the application then later changes the
attributes property because it would try to regenerate the effective
attributes from the markup text but the stored text no longer contains
any markup. If the original markup text happened to contain entities
like '<' they would end up causing parse errors because they would
be converted to the actual symbols.
To fix this the attributes from the markup are now stored
independently from the effective attributes. The effective attributes
are now regenerated if either set of attributes changes right before a
layout is created.
http://bugzilla.openedhand.com/show_bug.cgi?id=1940
Both the ::insert-text and ::delete-text are "action" signals, that is
signals that are safe to (and should) be emitted using g_signal_emit()
directly.
* text-direction:
docs: Add text-direction accessors
Set the default language on the Pango context
actor: Set text direction on parenting
tests: Display the index inside text-box-layout
box-layout: Honour :text-direction
text: Dirty layout cache on text direction changes
actor: Add :text-direction property
Use the newly added ClutterTextDirection enumeration
Add ClutterTextDirection enumeration
When the text direction changes we should evict the cached layouts
to avoid stale entries in case the direction change produces a layout
with the same size.
cogl_clip_push, and cogl_clip_push_window_rect which are now deprecated were
used in various places internally so this just switches to using the
replacement functions.
The change in commit 3bbc96e17e moved the
:text property setter to use set_text_internal(); this function does not
invalidate the Layout cache and does not queue a relayout, thus breaking
the behaviour of ClutterText when setting the contents of the actor using
the property.
http://bugzilla.openedhand.com/show_bug.cgi?id=1851
Input Methods require to be able to set a "pre-edit string", that is
a string that it's just displayed into the Text actor without being
committed to the actor's buffer. The string might require custom Pango
attributes, and an update of the cursor position.
Currently, setting the :text property has the side-effect of
setting the :use-markup property to FALSE. This prevents
constructing a Text actor, or setting its properties, like:
g_object_set (text,
"use-markup", TRUE,
"text", some_string,
NULL);
as the ordering becomes important. Unfortunately, the ordering
of the properties cannot be enforced with ClutterScript or
with language bindings.
The documentation of the clutter_text_set_text() method should
be expanded to properly specify that the set_text() method will
change the :use-markup property to FALSE as a side effect.
clutter_text_move_word_backward/forward() calls did not use the
start argument consistently. Also, clutter_text_move_word_forward()
bound check checked the wrong end.
Fixes#1765
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
When a letter key is pressed with the control key held down one of
three things will happen :-
a) If the stage is embedded within a GtkClutterEmbed the unicode value
will be filled from gdk_keyval_to_unicode. This will be the same
value as if control was not pressed (so Ctrl+V will be 'v').
b) If the stage is not in a GtkClutterEmbed and Clutter is running on
the X11 backend then it will try to fill in the unicode value from
XLookupString. This *will* take into account the control so the
unicode value will represent a control character (Ctrl+V will be
'\x16').
c) Most other backends will not bother to fill in the unicode
value. Therefore clutter_keysym_to_unicode will be used which also
does not take into account the control key (so Ctrl+V will be 'v').
For cut and paste to work in Nbtk, the control keys need to bubble up
to the parent NbtkEntry container. This works fine for 'b' but not 'a'
and 'c'.
This patch makes ClutterText always allow the event to bubble if the
key is not handled by the binding pool and the control modifier is
down.
Ideally ClutterText would always get a unicode value that takes into
account the modifiers but this is probably best left up to the input
methods.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
If you select all the text in a ClutterText, there is an invisible
cursor position either at the beginning or end. If it's at the beginning,
the bug is that left arrow won't clear the selection. If it's at the end,
the bug is that the right arrow won't.
Here are the ways to reproduce it:
a. Ctrl-A selects all and moves the hidden cursor position to the left.
b. For single line: End, Shift-Home does the same.
c. Or manually moving to the end and doing Shift-Left Arrow to the
beginning.
These all put it in the state where right arrow will properly clear
selection and move to cursor position 1, but left arrow fails to clear
the selection.
For b and c above, the opposite will give you the end case where right
arrow doesn't work.
Anyway, it turns out clear_selection is getting called, it just doesn't
show up because it's not doing a queue_redraw. So the attached patch
seems to fix things.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
ClutterEvent is not really gobject-introspection friendly because
of the whole discriminated union thing. In particular, if you get
a ClutterEvent in a signal handler, you probably can't access the
event-type-specific fields, and you probably can't call methods
like clutter_key_event_symbol() either, because you can't cast the
ClutterEvent to a ClutterKeyEvent.
The cleanest solution is to turn every accessor into ClutterEvent
methods, accepting a ClutterEvent* and internally checking the event
type.
Fixes bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1585
Instead of passing a boolean value, the ::allocate virtual function
should use a bitmask and flags. This gives us room for expansion
without breaking API/ABI, and allows to encode more information to
the allocation process instead of just changes of absolute origin.