This follows the convention of GtkLabel/GtkEntry in GTK+ and the old
ClutterEntry.
It makes it easier to use strlen/strcmp etc on the output, since we can
assume that it is always a string.
This commit also updates the test unit for ClutterText to verify that
the clutter_text_get_text() function also returns an empty string when
a ClutterText actor has been created.
The clutter-private.h header already includes cogl-pango.h with
the correct inclusion path, because the main context stores a
pointer to the font map.
There is no need for clutter-text.c to include cogl-pango.h
again since it already includes clutter-private.h.
After fixing the cursor position issues around the initial
glyph of the layout, the selection position needs fixing as
well.
The fix is similar: check if the position of the selection
is 0 and provide a fast path by setting the offset to 0.
The GTest report output allows the developer to know where exactly
a test unit failure happened. The test-text-cache unit makes it
very hard to pinpoint the exact failure location because it relies
on the output to be printed out - which is not the case when the
tests are run as part of a make check.
This commit makes each sub-test inside the unit fail exactly where
the check function fails, which makes it easier to know which sub-test
did actually fail.
The clutter_text_set_selection() function is a convenience
method for setting the cursor position and the selection
boundary to a given position in a single call, with sanity
checks for the positions.
The clutter_text_get_selection() function was not checking the
passed argument, and was still accessing the contents of the
Text actor using clutter_text_get_text().
This commit also adds the last few gtk-doc annotations missing
from ClutterText.
Instead of repeating the same code for the ::activate signal
emission, use the clutter_text_activate() function inside the
'activate' key binding handler.
The clutter_text_activate() function will emit the ::activate
signal if the :activatable property is set.
This function is useful for subclasses or application code, for
example if we are going to use ::captured-event or ::key-press-event
signal handlers to intercept the Return key and emit the ::activate
signal ourselves.
Instead of installing the line-start and line-end key bindings
using the bare ClutterBindingPool API, we can use the internal
clutter_text_add_move_binding(), which automatically installs
the same key binding with the Shift modifier mask.
This allows selecting when pressing Shift+Home or Shift+End.
The selection behaviour is still incorrect around the zeroeth
position, with all the text after the first line being selected.
We can control the width of the cursor when painting by using
a simple property.
The magic -1 number passed to the setter method will reset the
cursor size to the default one of 2px.
The getter method will return an unsigned integer with the
current size.
Moving the text by a "page" depends on being able to define a
"page size" in terms of lines of text. Since we don't define
something similar to an Adjustment that allows us to handle this
behaviour, we should defer the paging implementation to a higher
level class based on ClutterText.
Another fix for the key navigation behaviour around the zeroeth
glyph in the layout.
This commit adds a fast path for for the zero index when the
cursor position is set as zero, in case we are using the line-start
or line-end key bindings, similarly to what we did in commit
be64cbcdc2 for the move-up and
move-down bindings.
The behaviour of ClutterText around the initial position is still
a little bit erratic.
This commit fixes the key navigation with Up and Down arrows around
the first line of text.
We loose precision with a direct conversion for PangoUnits to
pixels, so we should do the conversion as needed, inside the
callers of clutter_text_position_to_coords().
We don't allow changing the cursor geometry inside the ::cursor-event
signal handlers; for starters, it would make binding the signal a
huge mess, and it would also potentially break the whole actor.
Add all the unused API to the sections file; there are still
some undocumented bits, but clutter-unused.txt is empty for
the time being.
Also, add ClutterText to the main XML document and remove
ClutterLabel and ClutterEntry.
If we create the PangoContext for ClutterText inside the class
initialization we might not have a Clutter main context yet.
Ideally, we should store the Pango context inside the main context
and create it on clutter_init(), but for now we can lazily create
the PangoContext when we initialize a ClutterText instance for the
first time.
For the time being, just don't include them or compile them; the
files will be removed from the repository as soon as all the
documentation annotations have been ported over to ClutterText.
The test-opacity interactive test is superceded by the equivalent
units inside the conformance test suite.
The test-entry interactive test is superceded by the test-text one.
ClutterText behaviour with regards to the paint opacity has been
changed by commit 07e19fff5ffa9617413fa6c3715914513fec3793.
We need to update the test suite for the paint opacity to reflect
that change as well.
We allow KeyEvents with a key symbol of '0' to fall through only
if they are marked as synthetic. Otherwise we discard them without
mercy.
Synthetic events are useful to test ClutterText behaviour; in fact,
we do use them inside the test suite exactly for that reason.
I understand we are not Pascal developers, and we don't have to
use cute and cuddly names like "i_am_an_integer_counter", but
a ClutterButtonEvent should be stored inside an "event" variable.
Using "bev" instead? Mmmh, not so much.
ClutterText should use the paint opacity for both text and
cursor.
ClutterLabel had the wrong behaviour, as it set the actor's
opacity using the text color's alpha channel, and ClutterEntry
completely disregarded the actor's opacity when painting the
cursor.
This commit harmonizes the ClutterText behaviour to always
use a composition of the actor's paint opacity and the text
and cursor alpha channel values, thus behaving more
consistently with the rest of Clutter.
When inserting text on a key press event we should also truncate
the selection.
We should not truncate the selection when inserting any Unicode
character, since changing the selection also changes the cursor
position - and one of the invariants we inherited from ClutterEntry
is that inserting characters programmatically does not change the
cursor position.
If a selection has been truncated inside a key binding handler,
we should just return and let the usual key event handler continue.
This fixes the case where we deleted a selection using the Delete
or the Backspace keys.
ClutterText should use the newly added ClutterBindingPool API to
handle key events, instead of its homegrown code.
This commit removes the action/mapping code and defers the entire
key binding matching to a ClutterBindingPool created inside the
Text class initialization function.
The clutter_text_get_chars() function returns a section of the
contents of the Text actor, delimited by a start and an end position.
This commit adds the implementation for that function and a test
unit that guarantees the offset-to-bytes computations are correct.
Comment why we need to enable the editability of the Text actor
inside the test suite.
This should clarify commit ea508ea528d61ae478d8bc4c88f54a89304f18e8
Whenever we are sending specially crafted KeyEvents to a ClutterText
we also need to set it editable, since the event handling code depends
on the editability setting.