Commit Graph

1772 Commits

Author SHA1 Message Date
Emmanuele Bassi
a865a5d4ea Create the PangoContext of the Text actor
Instead of creating a single, private PangoContext for every
Text actor, use the newly added clutter_actor_get_pango_context()
function.
2008-12-23 14:11:27 +00:00
Emmanuele Bassi
78628edf2f Add a per-actor PangoContext
Rendering text inside an actor is pretty much impossible without
using internal API to create the various pieces like the PangoContext
and the font map.

Each actor should have the ability to create a PangoContext, which
is the only object needed to generate layouts and change the various
Pango settings.

This commit adds a clutter_actor_get_pango_context() function that
creates a PangoContext inside the ClutterActor private data and allows
the creation of PangoLayouts when needed. If the actor already
has a PangoContext, the same instance is returned.

The PangoContext is created only on demand.
2008-12-23 14:06:55 +00:00
Emmanuele Bassi
b8b8b155c4 Add signals for Backend options
The ClutterBackend instance at the moment lacks the ability to
notify runtime changes of the font options and the resolution.

For this reason, this commit adds a ::resolution-changed and a
::font-changed signals to the Backend class.

The ::resolution-changed signal is emitted when set_resolution()
is called with a different DPI; ::font-changed is emitted when the
cairo_font_options_t* changes from the default.
2008-12-23 13:55:51 +00:00
Emmanuele Bassi
b021f518c1 Use "" as the default value for the :text property
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.
2008-12-22 13:43:41 +00:00
Emmanuele Bassi
4a934c363c Do not include cogl-pango.h multiple times
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.
2008-12-22 13:24:52 +00:00
Emmanuele Bassi
6b782ce4e7 Fix the selection behaviour around the 0th glyph
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.
2008-12-16 15:53:57 +00:00
Emmanuele Bassi
ba586b46b3 [tests] Make the layout cache fail at the right place
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.
2008-12-16 13:58:54 +00:00
Emmanuele Bassi
d85a1cb5a1 [docs] Add clutter_text_set_selection to gtk-doc
Insert the newly added symbol to the ClutterText section in
the API reference.
2008-12-16 12:42:44 +00:00
Emmanuele Bassi
a3fbdb5949 Add ClutterText::set_selection()
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.
2008-12-16 12:41:20 +00:00
Emmanuele Bassi
2209e17432 Fix ClutterText::get_selection()
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.
2008-12-16 12:25:45 +00:00
Emmanuele Bassi
e28fb9ae10 [docs] Add more gtk-doc annotations
Almost reaching full documentation.
2008-12-16 12:25:15 +00:00
Emmanuele Bassi
4a43b582ac Use clutter_text_activate()
Instead of repeating the same code for the ::activate signal
emission, use the clutter_text_activate() function inside the
'activate' key binding handler.
2008-12-16 12:05:10 +00:00
Emmanuele Bassi
93d96dca52 Add ClutterText::activate()
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.
2008-12-16 12:02:58 +00:00
Emmanuele Bassi
87f38475ae [docs] Add more gtk-doc annotations for ClutterText
Document the ClutterText constructors and the :editable, :selectable
and :activatable properties accessors.
2008-12-16 11:52:57 +00:00
Emmanuele Bassi
e3ba2ddf0a [docs] Annotate properties and fix signals docs
Annotate the properties without gtk-doc description, to get the
"Since" attribute.

Also, fix the ::cursor-event and ::activate signals documentation.
2008-12-16 11:30:47 +00:00
Emmanuele Bassi
32896d9aee [docs] Add :cursor-size property accessors
Add the ClutterText:cursor-size property accessors to the
known gtk-doc symbols for the ClutterText section.
2008-12-16 10:43:05 +00:00
Emmanuele Bassi
7ebb9ff6b7 Allow selecting with line-start and line-end bindings
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.
2008-12-16 10:39:52 +00:00
Emmanuele Bassi
ea5a6abd9d Add :cursor-size property to ClutterText
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.
2008-12-16 10:37:45 +00:00
Emmanuele Bassi
ffb500d3a6 Remove unused page up/down key bindings
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.
2008-12-16 10:19:56 +00:00
Emmanuele Bassi
dc49dab350 Fix line start and line end key binding behaviour
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.
2008-12-16 10:15:57 +00:00
Emmanuele Bassi
be64cbcdc2 Fix up/down key navigation
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.
2008-12-15 18:46:08 +00:00
Emmanuele Bassi
e615b8cc6b Use units in position_to_coords()
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().
2008-12-15 18:24:42 +00:00
Emmanuele Bassi
2714397fd5 Constify the cursor geometry in ::cursor-event
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.
2008-12-15 18:23:25 +00:00
Emmanuele Bassi
2d166b250c [docs] Add annotations for ClutterText structures
ClutterText and ClutterTextClass were missing annotations for
gtk-doc to pick up.
2008-12-15 15:10:55 +00:00
Emmanuele Bassi
39b575e6b4 Remove ClutterLabel and ClutterEntry
Both ClutterLabel and ClutterEntry have been deprecated by
ClutterText.
2008-12-15 15:08:12 +00:00
Emmanuele Bassi
c8dbbfaacf [docs] Update the API reference
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.
2008-12-11 15:01:28 +00:00
Emmanuele Bassi
a50dfefbc3 Fix documentation issues
Provide a description for the ClutterText section, and fix some
misnamed arguments inside the header file.
2008-12-11 15:00:22 +00:00
Emmanuele Bassi
0ac1590378 Lazily create the PangoContext on Text::init
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.
2008-12-11 14:57:46 +00:00
Emmanuele Bassi
5a1837bc9e Remove ClutterEntry and ClutterLabel from the build
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.
2008-12-11 13:49:39 +00:00
Emmanuele Bassi
ffa37dec20 Update the micro-bench tests to ClutterText
Test the ClutterText rendering speed instead of ClutterLabel's.
2008-12-11 13:48:45 +00:00
Emmanuele Bassi
5c14044e52 Update the interactive tests to ClutterText
Instead of using ClutterLabel, use ClutterText to display some
text where needed.
2008-12-11 13:48:01 +00:00
Emmanuele Bassi
24a6163688 Do not compile the opacity and entry interactive tests
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.
2008-12-11 13:45:22 +00:00
Emmanuele Bassi
45de6df615 Update ignore file
Add the conformance test units for ClutterText.
2008-12-11 13:39:35 +00:00
Emmanuele Bassi
edd6b65743 Update the paint opacity unit test
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.
2008-12-11 12:26:47 +00:00
Emmanuele Bassi
786bc4d4d5 Allow only synthetic events with keyval 0
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.
2008-12-11 12:24:45 +00:00
Emmanuele Bassi
77b3b9d5f4 Do not use contractions when not needed
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.
2008-12-11 12:21:57 +00:00
Emmanuele Bassi
2ca7cb46f9 Use the paint opacity when painting a ClutterText
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.
2008-12-11 12:18:26 +00:00
Emmanuele Bassi
e9c369f86d Add documentation annotations
ClutterText is heavily under-documented. This commit ports most of
the API documentation from ClutterLabel and ClutterEntry to
ClutterText.
2008-12-11 12:17:11 +00:00
Emmanuele Bassi
cfb6022831 Code style fixes
Fix the arguments alignment whenever not consistent with the
coding style rules.
2008-12-11 12:15:49 +00:00
Emmanuele Bassi
7a93bcb64e Remove unused types
Since ClutterText now uses ClutterBindingPool there is no more
need for the internal key mapping types.
2008-12-11 12:14:53 +00:00
Emmanuele Bassi
06b00f9dfc Remove units for Entry and Label
ClutterText should supercede all unit tests for ClutterLabel and
ClutterEntry.
2008-12-11 12:13:26 +00:00
Emmanuele Bassi
f13e00b411 Truncate selections on text insertion
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.
2008-12-11 12:10:46 +00:00
Emmanuele Bassi
35172a7615 Change the binding propagation when truncating a selection
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.
2008-12-11 12:08:20 +00:00
Emmanuele Bassi
ec4c15f8e7 Comment out the mapping API
The test-text interactive test for ClutterText should not use
the mapping API, since ClutterText does not have it anymore.
2008-12-11 12:07:20 +00:00
Emmanuele Bassi
eae98800d2 Use ClutterBindPool inside ClutterText
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.
2008-12-11 12:03:17 +00:00
Emmanuele Bassi
b1c366a143 Add Text::get_chars() implementation and tests
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.
2008-12-11 11:59:50 +00:00
Emmanuele Bassi
2fedd3263c Do not namespace internal data structures
Since the internal data structures are not exported (duh!), we
can eschew the namespacing and save us some characters.
2008-12-11 11:57:46 +00:00
Emmanuele Bassi
e93a7e243c Add comments in the test suite
Comment why we need to enable the editability of the Text actor
inside the test suite.

This should clarify commit ea508ea528d61ae478d8bc4c88f54a89304f18e8
2008-12-11 11:56:44 +00:00
Emmanuele Bassi
4a1f4d6f9a Move internal data structures on top
Try to keep the declarations section of the source files clean and
possibly consistent.
2008-12-11 11:55:39 +00:00
Emmanuele Bassi
d84a88ac3b Coding style consistency
Channel mitch's spirit.

This is also how I get to have the highest commit count on Clutter's
repository.
2008-12-11 11:54:32 +00:00