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.
Add a method for deleting the current selection inside a Text actor.
This is useful for subclasses.
See bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1521
Based on a patch by: Raymond Liu <raymond.liu@intel.com>
The cursor x position is already translated, so we do not need to take the
actors allocation into account when calculating scrolling.
Additionally, we need to update the text_x value before running
clutter_text_ensure_cursor_position.
Add any scrolling offset to the x value when in single line mode.
Now that the offset is taken into account in the position_to_coords
function, we do not need to adjust the cursor x manually in
clutter_text_paint.
If the cursor is already at the end of the Text contents then we
need to maintain its position when deleting the previous character
using the relative key binding.
If text is set, ClutterText should never return less than the layout
height for minimum and preferred heights.
This holds unless ellipsize and wrap are enabled, in which case the
minimum height should be the height of the first line -- which is
the height needed to at the very least show the ellipsization.
Based on a patch by: Thomas Wood <thomas@openedhand.com>
Fixes bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1598
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
I was seeing clutter_text_get_selection trying to malloc up to 4Gb due to
unexpected negative arithmetic for the start/end offsets which resulted
in a crash.
This just tests for positions of -1 before deciding if the start/end
positions need to be swapped. The conversion from position to byte offset
already works with -1.
Add a method for deleting the current selection inside a Text actor.
This is useful for subclasses.
See bug:
http://bugzilla.openedhand.com/show_bug.cgi?id=1521
Based on a patch by: Raymond Liu <raymond.liu@intel.com>
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
Setting the wrap mode on the PangoLayout seems to have disappeared
during the text-actor-layout-height branch merge so this brings it
back. The test for this in test-text-cache no longer needs to be
disabled.
We also shouldn't set the width on the layout if there is no wrapping
or ellipsizing because otherwise it implicitly enables wrapping. This
only matters if the actor gets allocated smaller than its natural
size.
The documentation for the ::cursor-event says that the signal
is emitted only when the cursor position changes. Right now it
is being emitted every time we ensure the cursor position during
the Text paint sequence.
The clutter_text_ensure_cursor_position() function should check
whether the stored cursor position has changed since the last
paint, and emit the ::cursor-event signal only when there has
been a change.