1
0
Fork 0
Commit graph

235 commits

Author SHA1 Message Date
Emmanuele Bassi
1724536cda text: Add ::cursor-changed signal
Since we are trying to eliminate the ClutterGeometry type, we should
replace the only entry point still using it: the ::cursor-event signal
of ClutterText.

Instead of passing the cursor geometry, we should add an accessor
function.

The combination of signal and getter for the cursor geometry means that
we can deprecate ClutterText::cursor-event, and mark it for removal in
Clutter 2.0.

https://bugzilla.gnome.org/show_bug.cgi?id=682789
2013-04-04 11:53:39 +01:00
Emmanuele Bassi
315a73edf5 text: Clean up the set_font_description_internal() semantics
The current semantics are ridiculous, and clearly a case of (mistaken)
premature optimization. All setters should copy, not transfer ownership.

https://bugzilla.gnome.org/show_bug.cgi?id=695119
2013-03-04 13:06:39 +00:00
Nirbheek Chauhan
a783e6d3f2 clutter-text: Allow setting attributes for editable text
The behaviour imitates GtkEntry and ignores attributes from markup because Pango
barfs on invalid markup. Also add an example to the text-field interactive test.

https://bugzilla.gnome.org/show_bug.cgi?id=686477
2013-01-16 22:24:14 +00:00
Jasper St. Pierre
ea2b368af9 text: Fix font fallback
Spotted by Coverity.

https://bugzilla.gnome.org/show_bug.cgi?id=689496
2012-12-02 14:50:54 -05:00
Jasper St. Pierre
80eeac71f9 text: Prevent a relayout if font descriptions or attrs are equal
https://bugzilla.gnome.org/show_bug.cgi?id=689399
2012-12-02 14:49:31 -05:00
Rui Matos
ea50df6bb6 text: Don't accept new line characters in single line mode
Modified Return key presses don't trigger ::activate so we would end
up adding an unprintable character to a single paragraph mode pango
layout which renders it as a box.

https://bugzilla.gnome.org/show_bug.cgi?id=623344
2012-09-09 23:48:46 +02:00
Emmanuele Bassi
e9bcb4cf6e text: Clean up button press handling
Event handling should only apply to editable ClutterText actors, but we
also have the :selectable property to care about.

The button/touch press should position the cursor inside an editable
ClutterText; the :selectable property should be used to allow selecting
the text, either through pointer or touch dragging, via the keyboard, or
by multiple pointer clicks. If neither of these two conditions are met,
the ClutterText should just propagate the event handling further.
2012-08-19 10:05:34 +01:00
Jasper St. Pierre
f5a620ed3b clutter-text: Make sure to paint the background of a text actor
https://bugzilla.gnome.org/show_bug.cgi?id=682070
2012-08-17 13:17:01 -04:00
Emmanuele Bassi
d685e8a95a text: Add :cursor-position and deprecate :position
The :position property on ClutterText clashes with the same property on
ClutterActor; it's also badly named, given that it represents the
cursor's position inside the text; finally, it does not match its
accessors, violating the API style conventions.

https://bugzilla.gnome.org/show_bug.cgi?id=679457
2012-07-11 13:22:19 +01:00
Lionel Landwerlin
49dd99f9c1 text: add touch events support
https://bugzilla.gnome.org/show_bug.cgi?id=678278
2012-06-22 21:53:07 +01:00
Emmanuele Bassi
189a93677f text: Chain up in the ScriptableIface implementation
We need ClutterActor's implementation to run as well.
2012-06-08 14:33:01 +01:00
Emmanuele Bassi
75c3339c66 text: Use actor alignments when painting the layout
ClutterActor's x-align and y-align properties should be used to control
the alignment of the PangoLayout when painting it within a larger
allocation, and the ClutterText has the x-expand or the y-expand flags
set.
2012-06-08 12:05:50 +01:00
Bastian Winkler
58b13aa412 text: Enable implicit color animations
Implement the ClutterAnimatable interface to enable implicit animations
for :color, :cursor-color, :selected-text-color and :selection-color.

https://bugzilla.gnome.org/show_bug.cgi?id=676963
2012-05-28 15:22:47 +01:00
Dominique Bureau
a2d40fcf8c ClutterText: Cannot pass NULL string to clutter_text_set_text()
Passing a NULL buffer to clutter_text_set_text() does not behave the same
way as passing an empty string "" (as specified in the documentation).
This was working as expected previously, but somehow the behaviour changed
at some point and created 2 new issues:
- Passing a NULL pointer will not reset the string
- If the ClutterText is editable, it will segfault in strcmp

Validations have been added to prevent this.

https://bugzilla.gnome.org/show_bug.cgi?id=675890
2012-05-21 11:30:22 +01:00
Bastian Winkler
1f7ff75a5c text: Add missing introspection annotations
Add allow-none annotations where appropriate
2012-05-15 17:41:24 +02:00
Emmanuele Bassi
0dd74ca3fb docs: Annotation fixes
The introspection scanner has become slightly more annoying, in the hope
that people start fixing their annotations. As it turns out, it was the
right move.
2012-04-30 17:17:41 +01:00
Jasper St. Pierre
164c6ee741 text: Bubble up a click and quit early for just static text
Static text shouldn't need a cursor position or anything like that,
and it always eats a button press event.

https://bugzilla.gnome.org/show_bug.cgi?id=673190
2012-04-13 14:34:46 -04:00
Owen W. Taylor
bdf4b3a33a ClutterText: Fix length passed to clutter_text_buffer_set_text()
clutter_text_buffer_set_text() expects a char count, not a byte
count, so pass -1 rather than using strlen.

https://bugzilla.gnome.org/show_bug.cgi?id=673783
2012-04-09 16:11:49 -04:00
Emmanuele Bassi
620e57ac13 text: Use CoglFramebuffer API for the path-based clip 2012-03-09 16:26:53 +00:00
Emmanuele Bassi
477d399c31 text: Use the background color when painting
If the ClutterActor:background-color-set property is set to TRUE.
2012-03-06 15:10:04 +00:00
Emmanuele Bassi
663d6179ff text: Center the cursor caret
We remove 2 pixels from the height of the cursor, but we should also
remove the same amount from the position on the y axis, so that the
cursor caret appears centered in the allocated height.

https://bugzilla.gnome.org/show_bug.cgi?id=655491
2012-03-06 15:10:04 +00:00
Emmanuele Bassi
fb9df4bef2 Annotate all functions available since 1.10 2012-02-27 16:35:09 +00:00
Emmanuele Bassi
78b237b535 Clean up the included headers
Especially inside ClutterStage.
2012-02-23 17:21:57 +00:00
Emmanuele Bassi
cd118f0dc0 text: Fix regression
When the ClutterTextBuffer support inside ClutterText was merged, it
introduced a regression that was identified and fixed in bug 659116.

The optimization to not paint empty ClutterText actors is only valid
is the actor is not editable, or if the cursor is not visible.
2012-02-11 16:02:31 +00:00
Emmanuele Bassi
e7511dd469 text: Avoid changing the contents when possible
An editable ClutterText will reset the selection and cursor whenever the
contents are changed — even if those contents are the same. As this may
confuse the user, we should check if we're setting the exact same string,
and bail out if necessary.
2012-02-07 11:36:27 +00:00
Emmanuele Bassi
d509455de0 text: Fix annotations
Both set_text() and set_markup() have relaxed their preconditions on a
non-NULL string as their argument, so we need to update the annotations.
2012-02-07 11:33:12 +00:00
Emmanuele Bassi
15441bb280 text: Style cleanups
Inline wrapper functions, and remove deep nested if's.
2012-02-07 11:31:28 +00:00
Emmanuele Bassi
7ba9774572 text: Add the coords_to_position() method
The reverse of position_to_coords().

While providing documentation on how to implement it using the
PangoLayout API, I realized that the verbosity of it all, plus the usage
of the Pango API, was not worth it, and decided to expose the method we
are using internally.
2012-02-06 18:27:58 +00:00
Emmanuele Bassi
3305105a8c docs: Fix up Since annotation
We only use stable releases for "since" tags.
2012-02-06 17:34:26 +00:00
Emmanuele Bassi
696f9e84c9 text: Fix the buffer length check on paint 2012-01-17 14:29:45 +00:00
Stef Walter
c073764369 text: Implement ClutterTextBuffer
* Abstracts the buffer for text in ClutterText
 * Allows implementation of undo/redo.
 * Allows use of non-pageable memory for text
   in the case of sensitive passwords.
 * Implement a test with two ClutterText using the same
   buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=652653
2012-01-17 14:29:44 +00:00
Emmanuele Bassi
99f7d627af text: Use the event and source symbolic macros
Instead of boolean values.
2012-01-12 10:40:38 +00:00
Jasper St. Pierre
b882fcd825 clutter-text: Fix memory leak 2011-12-19 09:46:44 -05:00
Emmanuele Bassi
93ece6dd7b text: Implement password hint
A ClutterText in password mode should have the ability to show the last
input character. This feature allows easier password entry on platforms
with unreliable keyboards, such as touchscreens or small devices.

https://bugzilla.gnome.org/show_bug.cgi?id=652588
2011-09-19 20:26:37 +01:00
Rui Matos
41bd15226f text: We still have to paint the actor if the cursor is visible
https://bugzilla.gnome.org/show_bug.cgi?id=659116
2011-09-15 10:43:04 +01:00
Jasper St. Pierre
1883ee13f9 text: Take out a nonsense fallback
Invisible text is the best surprise for an update!

https://bugzilla.gnome.org/show_bug.cgi?id=659069
2011-09-14 21:49:45 -04:00
Emmanuele Bassi
a9a104e109 docs: Fixes for cross-references 2011-09-12 13:12:14 +01:00
Emmanuele Bassi
9f70ea8dee text: Pack all bitfields at the end of the private structure
Don't leave them in the middle, to avoid holes.
2011-09-07 15:37:09 +01:00
Emmanuele Bassi
0c22246bea text: Clear up priv->text checks
The priv->text field cannot ever be NULL, so we don't need to check for
that in a series of places. We also need to assert() that pre-condition
in the couple of places where we set the contents of the ClutterText
actor, namely in set_text_internal() and set_markup_internal().

Based on a patch by: Dan Winship <danw@gnome.org>

http://bugzilla.clutter-project.org/show_bug.cgi?id=2629
2011-09-07 15:37:09 +01:00
Emmanuele Bassi
320bdeac03 text: Consistently protect against NULL strings
When calling clutter_text_set_text_internal() or
clutter_text_set_markup_internal() we need to make sure to pass a
non-NULL string.
2011-09-07 15:37:09 +01:00
Emmanuele Bassi
0bd1e47b22 text: Make :use-markup set idempotent
Setting :use-markup and :text is currently not idempotent, and it
depends on the ordering, e.g.:

  g_object_set (actor, "use-markup", TRUE, "text", value, NULL);

does not yield the same results as:

  g_object_set (actor, "text", value, "use-markup", TRUE, NULL);

This is particularly jarring when using ClutterText from ClutterScript,
but in general GObject properties should not rely on the order when used
from g_object_set().

The fix is to store the contents of the ClutterText as a separate string
from the displayed text, and use the contents, instead of the displayed
text, when toggling the :use-markup property.

Let's also add a unit test for good measure, to try and catch
regressions.

https://bugzilla.gnome.org/show_bug.cgi?id=651940
2011-09-07 13:00:35 +01:00
Emmanuele Bassi
359ed2b29f text: Make :line-wrap actually work
When we paint a ClutterText we ask the actor for a PangoLayout that fits
inside the actor's allocation - both width and height.

Sadly, whenever a height is set on a PangoLayout, Pango will wrap its
contents - regardless of whether the layout should actually wrap or not.

This means that in certain easy to exploit cases, Clutter will paint a
Text actor with its contents wrapping even if the :wrap property is set
to FALSE.

In order to fix this we need to encode some more cases inside the
::paint implementation of ClutterText, and ask the cache for a layout
that is sized as the allocation's width, but not as its height; we also
need to perform a clip if we detect that the PangoLayout's logical size
is going to overflow the allocated size. This clip might cause some
performance issue, given that clipping breaks batching in the Cogl
journal; hopefully all clips for text are going to be screen-aligned, so
at the end of the batch it'll just scissor them out.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2339
2011-09-05 17:22:14 +01:00
Robert Bragg
397fe1b5b6 text: Implement Scriptable interface for font-description
This makes ClutterText implement the Scriptable interface so that we can
have a custom property parser and setter for the font-description
property. This works by simply passing the string description through
to clutter_text_set_font_name.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-08-16 18:06:44 +01:00
Evan Nemerson
a6bd11ac62 introspection: add missing introspection data from Vala bindings
https://bugzilla.gnome.org/show_bug.cgi?id=655387
2011-07-29 13:06:51 +01:00
Damien Lespiau
4d58534fbb text: Fix the default value of "editable"
The "editable" property is documented to default to TRUE, but is
initialized to FALSE in the _init() function.

Third party code would be affected if we changed the default to be
TRUE, so we have to change the default value in the GParamSpec.

https://bugzilla.gnome.org/show_bug.cgi?id=654726
2011-07-18 13:57:44 +01:00
Emmanuele Bassi
5d10a7141c text: Make sure that the selection box is big enough
Do not use integers to store the result of the PANGO_UNITS scaling to
avoid rounding issues with the default C rules. We should use cielf()
instead.
2011-07-10 10:24:40 +01:00
Jasper St. Pierre
037138d3bf clutter-text: Always update cursor positions when painting
The cursor's on-screen rectangle is defined in terms of the text
length, the current index, and text_x and text_y, which hold the text
offset in overflowing text fields.

When deleting large amounts of text, text_x is set to 0. In some
edge case branch paths, the cursor rectangle could be calculated
after the current index and text length were updated, but before
the text_x offset could be. This left a negative x position, which
consequently blew up Cogl and the widget.

https://bugzilla.gnome.org/show_bug.cgi?id=651079
2011-07-04 15:58:08 +01:00
Philippe Normand
494629d4b9 clutter-text: new clutter_text_get_layout_offsets API
This new function can be used to retrieve the coordinates where the
ClutterText will draw the PangoLayout representing the text.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2553
2011-06-13 16:15:22 +01:00
Neil Roberts
d151d789f6 clutter-text: Use the ink rect in the paint volume
Previously ClutterText was just reporting the allocation as the paint
volume. The preferred size of a ClutterText is just the logical
rectangle of the layout. A pango layout can sometimes draw outside of
its logical rectangle for example with an italicised font with large
serifs. Additionally, ClutterText doesn't make any attempt to clip the
text if the actor gets allocated a size too small for the text so it
would also end up drawing outside of the paint volume in that case. To
fix this, the paint volume is now reported as the ink rect of the
Pango layout. The rectangle for the cursor and selection is also
unioned into that because it won't necessarily be within the ink
rectangle.

The function for drawing the selection rectangles has been split up
into a generic function that calculates the rectangles that need to be
drawn and a function that draws them. That way the get_paint_volume
virtual can share the code to calculate the rectangles.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2599
2011-06-10 14:02:07 +01:00
Neil Roberts
a20a8071ed clutter-text: Don't move the cursor to the left when at pos 0
When the cursor is at the leftmost position in the text the drawn
pixel position is moved to the left by the size of the cursor. There's
no explanation for why this happens and it doesn't seem to make any
sense so this patch removes it. It makes multi-line texts looks odd
because the cursor ends up at a different horizontal position when it
is on the first line from any other line. It also makes using
priv->cursor_pos difficult in any other part of the code because the
paint function modifies it.

The original patch that added this can be traced back to Tidy commit
c356487c15. There's no explanation in the commit message either.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2599
2011-06-10 13:07:11 +01:00