Commit Graph

203 Commits

Author SHA1 Message Date
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
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00
Neil Roberts
7d233241f1 Fix include location for cogl-pango.h
In Cogl, cogl-pango.h has moved to <cogl-pango/cogl-pango.h>. When
using the experimental 2.0 API (which Clutter does) it is no longer
possible to include it under the old name of <cogl/cogl-pango.h> so we
need to update the include location.
2011-05-16 16:04:27 +01:00
Emmanuele Bassi
ba4615cd4b text: Check the has_focus flag in selection_paint()
It is the only place were it is used, so it should only be checked
there, and not in the general paint() implementation.
2011-05-13 15:44:08 +01:00
Emmanuele Bassi
729e9985c1 text: Implement the ::has_overlaps virtual
Since ClutterText has overlapping primitives when selecting, or a
visible cursor, then we need to report that to Clutter, to avoid
bleeding colors through when a Text actor is non-fully opaque.
2011-05-13 15:44:08 +01:00
Jasper St. Pierre
94c9c07509 clutter-text: Add a selected-text-color
http://bugzilla.clutter-project.org/show_bug.cgi?id=2595
2011-05-13 15:44:08 +01:00
Jasper St. Pierre
0c576c0c33 Remove private helper #define's
Finish off the second half of 09a830d294.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2596
2011-03-03 11:47:49 +00:00
Emmanuele Bassi
4442ddde82 text: Round up the size
Converting from Pango units to pixels by using the C conventions might
cause us to lose a pixel; since we're doing the same for the height, we
should use ceilf() to round up the width and the line height.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2573
2011-02-21 17:34:45 +00:00
Emmanuele Bassi
bdb309cbd6 annotations: Use caller-allocates for color getters
This should avoid a separate initialization of a ClutterColor in
language bindings.
2011-02-14 18:41:18 +00:00
Emmanuele Bassi
b820e39406 text: Bind BackSpace + Shift as BackSpace
Follow this old GTK+ bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=80302

and ignore the Shift mask.
2011-01-30 23:00:00 +00:00
Bastian Winkler
5d8b6aa6fa introspection: Add missing (out) annotations for get_color()
Some actors are missing the (out) annotations for the get_color()
methods.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2518
2011-01-17 17:31:59 +00:00
Emmanuele Bassi
605e8d6fb5 text: Only paint cursor if we have key focus
If a Text actor does not have key focus then there's no point in showing
the cursor at all.
2010-12-21 10:50:24 +00:00
Mike Owens
def14e80cb ClutterText: Only grab keyboard focus if keyboard-interactive.
Previously, ClutterText took keyboard focus on mouse-down, regardless
if it were editable or selectable.  Now it checks these properties,
and behaves like other actors if it can't do anything useful with
the focus.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2462
2010-12-14 09:36:28 +00:00
Chris Lord
67143bd846 text: Optimise get_preferred_height for single-line-mode
Don't calculate an extra layout in clutter_text_get_preferred_height for
single-line strings, when it's unnecessary. There's no need to set the
width of a layout when in single-line mode, as wrapping will not happen.
2010-11-29 11:51:33 +00:00
Alexandre Quessy
01b93537ab Fixed "the the" repetitions in some doc strings
http://bugzilla.clutter-project.org/show_bug.cgi?id=2450
2010-11-25 18:18:51 +00:00
Emmanuele Bassi
e6bc65b5c3 text: Do not segfault with NULL :font-name
Make sure that we have a fall back in place for the default font name
string, and use g_strcmp0 to protect ourselves from NULL strings.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2417
2010-11-14 23:06:48 +00:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Damien Lespiau
2d56ed637c text: Rename the nick of the position property "Cursor Position"
the "position" property of ClutterText is really the position of the
cursor. Rename the nick accordingly not to confuse it with the position
of the actor itself and be consistent with all the other cursor-related
properties.
2010-10-05 08:25:06 +01:00
Emmanuele Bassi
5640a65046 text: Update get_paint_volume() implementation
In commit 9818eee4646e49e99beb5a43f1dafcbdcca41f94 I forgot to update
ClutterText as well as the other actors.
2010-09-29 15:13:00 +01:00
Robert Bragg
72eeb8e809 actor: make default get_paint_volume more conservative
There are too many examples where the default assumption that an actor
paints inside its allocation isn't true, so we now return FALSE in the
base implementation instead. This means that by default we are saying
"we don't know the paint volume of the actor", so developers need to
implement the get_paint_volume virtual to take advantage of culling and
clipped redraws with their actors.

This patch provides very conservative get_paint_volume implementations
for ClutterTexture, ClutterCairoTexture, ClutterRectangle and
ClutterText which all explicitly check the actor's object type to avoid
making any assumptions about subclasses.
2010-09-29 15:12:59 +01:00
Emmanuele Bassi
4ee05f8e21 keysyms: Update the macros to CLUTTER_KEY_*
The keysyms defines in clutter-keysyms.h are generated from the X11 key
symbols headers by doing the equivalent of a pass of sed from XK_* to
CLUTTER_*. This might lead to namespace collisions, down the road.
Instead, we should use the CLUTTER_KEY_* namespace.

This commit includes the script, taken from GDK, that parses the X11
key symbols and generates two headers:

  - clutter-keysyms.h: the default included header, with CLUTTER_KEY_*
  - clutter-keysyms-compat.h: the compatibility header, with CLUTTER_*

The compat.h header file is included if CLUTTER_DISABLE_DEPRECATED is
not defined - essentially deprecating all the old key symbols.

This does not change any ABI and, assuming that an application or
library is not compiling with CLUTTER_DISABLE_DEPRECATED, the source
compatibility is still guaranteed.
2010-09-10 17:54:52 +01:00
Emmanuele Bassi
d76f64a10c Do not use deprecated API internally 2010-09-10 17:51:13 +01:00
Owen W. Taylor
f1c44a27a1 introspection: Add missing (out) annotations
Comprehensively add (out) annotations to functions parameters
returning int/float/double.

Not handled here: structure out returns like ClutterColor or
ClutterPerspective or GValue that should get (out caller-allocates).

Not handled here: Cogl

http://bugzilla.clutter-project.org/show_bug.cgi?id=2302
2010-09-08 15:43:07 +01:00
Emmanuele Bassi
abef73bb58 Replace cogl_color_set_from_* with cogl_color_init_from_*
The former is not yet "officially" deprecated by the latter, but it's
confusing to have them both in the code base.
2010-09-03 16:58:47 +01:00
Neil Roberts
8d51617979 Conditionally use g_object_notify_by_pspec
This adds a wrapper macro to clutter-private that will use
g_object_notify_by_pspec if it's compiled against a version of GLib
that is sufficiently new. Otherwise it will notify by the property
name as before by extracting the name from the pspec. The objects can
then store a static array of GParamSpecs and notify using those as
suggested in the documentation for g_object_notify_by_pspec.

Note that the name of the variable used for storing the array of
GParamSpecs is obj_props instead of properties as used in the
documentation because some places in Clutter uses 'properties' as the
name of a local variable.

Mose of the classes in Clutter have been converted using the script in
the bug report. Some classes have not been modified even though the
script picked them up as described here:

json-generator:

 We probably don't want to modify the internal copy of JSON

behaviour-depth:
rectangle:
score:
stage-manager:

 These aren't using the separate GParamSpec* variable style.

blur-effect:
win32/device-manager:

 Don't actually define any properties even though it has the enum.

box-layout:
flow-layout:

  Have some per-child properties that don't work automatically with
  the script.

clutter-model:

  The script gets confused with ClutterModelIter

stage:

  Script gets confused because PROP_USER_RESIZE doesn't match
  "user-resizable"

test-layout:

  Don't really want to modify the tests

http://bugzilla.clutter-project.org/show_bug.cgi?id=2150
2010-08-10 17:12:06 +01:00
Emmanuele Bassi
d07a525ecc text: Do not set the markup unconditionally
When setting :use-markup we always pass the contents of the Text actor
to clutter_text_set_markup_internal(); if string contains any markup,
this ends up being parsed and used - even when :use-markup is set to
FALSE.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2239
2010-08-06 17:41:28 +01:00
Emmanuele Bassi
fd27ca7398 Mark property strings for translation
Both the nick and the blurb fields should be translatable, for UI
builders and other introspection-based tools.
2010-07-15 14:07:07 +01:00
Emmanuele Bassi
903560c6c8 text: Layouts for single-line-mode entries are boundless
A PangoLayout for an editable, single-line text entry is by definition
without a given width, since the actor will be clipped when being drawn.
2010-07-09 18:38:45 +01:00
Emmanuele Bassi
a20def9df6 text: Use the ::settings-changed signal
Instead of the ::font-changed one.
2010-06-28 10:43:13 +01:00
Emmanuele Bassi
31fc8e9664 text: Document and annotate :font-name for NULL values
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.
2010-06-26 23:05:36 +01:00
Emmanuele Bassi
809211588d text: Update actors using the default font
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.
2010-06-26 15:49:15 +01:00
Alejandro Piñeiro
d37dee8258 Improve clutter_text_get_chars doc
Explicitly explain that end_pos is not included with the resulting
string

http://bugzilla.clutter-project.org/show_bug.cgi?id=2081
2010-06-24 14:25:11 +01:00
Emmanuele Bassi
b8b10ef4db docs: Clarify the scope of Text:single-line-mode
Only editable text actors can be in single-line mode.
2010-06-14 14:05:49 +01:00