1
0
Fork 0
Commit graph

146 commits

Author SHA1 Message Date
Emmanuele Bassi
09644e4bb6 analysis: ClutterText
Remove unused variables.
2010-02-12 14:50:11 +00:00
Robert Bragg
b898f0e227 never presume queuing redraws on invisible actors is redundant
This replaces code like this:
  if (CLUTTER_ACTOR_IS_VISIBLE (self))
    clutter_actor_queue_redraw (self);
with:
  clutter_actor_queue_redraw (self);

clutter_actor_queue_redraw internally knows what can be optimized when
the actor is not visible, but it also knows that the queue_redraw signal
must always be sent in case a ClutterClone is cloning a hidden actor.
2010-02-12 14:05:00 +00:00
Emmanuele Bassi
4208169ab4 text: Bump up the preferred height
Instead of returning a sub-pixel height round up the preferred height to
the nearest integral value that is not less than the size reported by
Pango, once converted in pixels.
2010-02-10 15:45:54 +00:00
Emmanuele Bassi
d2bdd3cb62 Fix some compiler warnings
GCC complains that some variable might be used uninitialized.
2010-02-09 16:58:03 +00:00
Jussi Kukkonen
cd3c5155d8 text: implement del_word_next/del_word_prev()
Bind ctrl-backspace and ctrl-del to functions that delete a word before
or after the cursor, respectively.

Selection does not affect the deletion, but current selection is
preserved. This mimicks GTK+ functionality in GtkTextView and GtkEntry.

http://bugzilla.openedhand.com/show_bug.cgi?id=1767

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-03 17:15:05 +00:00
Emmanuele Bassi
cb52581a24 text: Add :font-description
High level toolkits might wish to construct a PangoFontDescription and
then set it directly on a ClutterText actor proxy or sub-class.
ClutterText should have a :font-description property to set (and get)
the PangoFontDescription.

http://bugzilla.openedhand.com/show_bug.cgi?id=1960
2010-02-03 14:38:13 +00:00
Emmanuele Bassi
301863d43b text: Fixes for selection bound
The commit ecbb7ce41a exposed some issues
when positioning the cursor with the mouse pointer: the selection is
not moved along with the cursor when inserting a single character or a
string.

Also, some freeze_notify() are called too early, leading to decoupling
from their respective thaw_notify().

http://bugzilla.openedhand.com/show_bug.cgi?id=1955
2010-02-03 10:48:59 +00:00
Alejandro Piñeiro
ecbb7ce41a Fix problems with "position" and "selection-bound" change notification
Added a "selection-bound" notify on clutter_text_clear_selection as it
changes the value.

Added utility function clutter_text_set_positions, in order to
change both cursor position and selection bound inside a
g_object_[freeze/thaw]_notify block

Added g_object_[freeze/thaw]_notify in other functions that changes
both cursor position and selection bound

Solves http://bugzilla.openedhand.com/show_bug.cgi?id=1955
2010-02-01 11:22:58 +00:00
Emmanuele Bassi
bc8a80fee5 text: Zero out the cursor_pos member
Do not trust the zero-ing done by GObject on the private data structure,
and use memset() instead to zero the ClutterGeometry structure.
2010-01-11 17:10:00 +00:00
Neil Roberts
59105341bc text: Store the markup attributes separately
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 '&lt;' 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
2010-01-05 15:00:36 +00:00
Neil Roberts
32b456fc8c text: Free the Pango attribute list resources
The ClutterText owns three PangoAttrList resources which were not
being unref'd. This adds the unref calls to the finalize method.
2010-01-05 15:00:36 +00:00
Emmanuele Bassi
5d5c7142f7 text: Use G_SIGNAL_ACTION for ::insert-text and ::delete-text
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.
2010-01-04 12:03:47 +00:00
Alejandro Piñeiro
bf43cb6cdc Added ClutterText::insert-text and ClutterText::delete-text signals
* clutter/clutter-marshal.list: added new marshaller
* clutter/clutter-text.c
(clutter_text_class_init): added insert-text and delete-text signals
(clutter_text_insert_unichar): emits insert-text signal
(clutter_text_insert_text): emits insert-text signal
(clutter_text_delete_text): emits delete-text signal
(clutter_text_delete_chars): emits delete-text signal
(clutter_text_set_markup_internal): emits delete-text and insert-text signals
(clutter_text_set_text): emits delete-text and insert-text signals

http://bugzilla.openedhand.com/show_bug.cgi?id=1894
2010-01-04 12:01:51 +00:00
Emmanuele Bassi
586750751a Merge branch 'text-direction'
* 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
2009-12-01 14:55:19 +00:00
Neil Roberts
7a011af974 docs: Fix the 'Since' annotation for some functions
The 'Since' annotation needs to have a colon after it or gtk-doc won't
pick it up.
2009-11-19 11:51:21 +00:00
Emmanuele Bassi
adab87b520 text: Dirty layout cache on text direction changes
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.
2009-11-10 12:18:32 +00:00
Emmanuele Bassi
09c04d4c67 text: Add a NULL preedit string check
This commit avoids a critical warning introduced by commit
bc51b8ca47
2009-11-09 11:07:27 +00:00
Raymond Liu
bc51b8ca47 Fix cursor position in preedit status
http://bugzilla.openedhand.com/show_bug.cgi?id=1871

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-11-09 10:50:18 +00:00
Robert Bragg
abae6013e1 Remove all internal use of deprecated cogl_clip_* API
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.
2009-11-05 21:10:18 +00:00
Emmanuele Bassi
571df43b6d text: Invalidate caches and sizes in set_text_internal()
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
2009-10-20 22:09:21 +01:00
Emmanuele Bassi
473f7ee31e text: Take pre-edit cursor position into account
When determining the cursor position we also need to take into account
the pre-edit cursor position as set by the set_preedit_string()
function.
2009-10-19 15:31:29 +01:00
Emmanuele Bassi
2ff31dfbaa text: Notify :position when it changes
The :position property is not notified when changed.

http://bugzilla.openedhand.com/show_bug.cgi?id=1830
2009-10-16 14:24:07 +01:00
Emmanuele Bassi
bc424fb56c [text] NULL-ify strings to avoid double-frees 2009-10-16 12:45:38 +01:00
Emmanuele Bassi
6f43f4b805 [text] Do not apply unset preedit attributes
The pre-edit attributes are optional and thus should only be applied
if they have been set to avoid assertion failures.
2009-10-16 12:45:38 +01:00
Emmanuele Bassi
2883728387 [text] Add pre-edit string to ClutterText
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.
2009-10-16 12:45:29 +01:00
Emmanuele Bassi
3bbc96e17e text: Make the :text property not set the :use-markup one
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.
2009-10-07 21:55:54 +01:00
Øyvind Kolås
3cc56b2b13 [text] implement get_property for "use-markup" 2009-09-08 14:15:18 +01:00
Jussi Kukkonen
8c00d705c0 [text] move_word_backward/forward fixes
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>
2009-08-17 22:53:36 +01:00
Neil Roberts
99437c4761 [text] Don't interpret the unicode value when the control modifier is on
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>
2009-08-17 22:50:23 +01:00
Neil Roberts
1434d72134 Small doc fix to clutter_text_get_color
Bug reported by Rob Bradford.
2009-08-05 15:51:49 +01:00
Emmanuele Bassi
e860d939f9 [text] Allow key navigation by word
When pressing Ctrl with the left and right arrow keys we should
skip to (or select until) the previous and next word, respectively.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1713
2009-07-23 19:04:27 +01:00
Geoff Gustafson
6a1506bd5f [text] Queue a redraw when the selection is cleared
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>
2009-07-23 18:26:16 +01:00
Emmanuele Bassi
df839e22e6 [text] Do not leak the effective attributes
Thanks to Iain Holmes for catching the leak.
2009-06-10 16:23:35 +01:00
Emmanuele Bassi
41e85f3073 introspection-friendly ClutterEvent accessors
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
2009-06-08 12:05:20 +01:00
Emmanuele Bassi
c27f429819 [text] Fix Pango unit to pixels conversion
When going from Pango units to pixels we need to divide by 1024,
and not multiply by 1024.
2009-06-04 17:28:35 +01:00
Emmanuele Bassi
0187bb3965 [actor] Use flags to control allocations
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.
2009-06-04 16:30:31 +01:00
Emmanuele Bassi
046e571bae Remove usage of Units and macros
The ClutterUnit and relative macros should not be used when dealing
with pixels -- which is to say, all the time when inside Clutter.
2009-06-04 16:30:30 +01:00
Emmanuele Bassi
f8f54989be Merge commit 'origin/master' into 1.0-integration
Conflicts:
	clutter/clutter-texture.c
	clutter/cogl/gl/cogl-fbo.c
2009-05-20 16:49:22 +01:00
Emmanuele Bassi
21e3901d62 [text] Expose position_to_coords()
The clutter_text_position_to_coords() is useful for ClutterText
subclasses.

See bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1521

Based on a patch by: Raymond Liu <raymond.liu@intel.com>
2009-05-14 16:19:15 +01:00
Emmanuele Bassi
ca23838752 [text] Add ClutterText::delete_selection()
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>
2009-05-14 16:16:06 +01:00
Thomas Wood
81a536238d [text] fix problems with scrolling interaction
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.
2009-05-14 15:08:31 +01:00
Thomas Wood
a3a5fe5594 [text] scroll to the cursor position if it is outside the allocation
Adjust the text offset to keep the cursor within the allocation. This means
the text will scroll per character
2009-05-14 13:31:51 +01:00
Thomas Wood
cf6c2d9721 [text] account for scrolling in text selections
Account for any scrolling offset in single line mode when calculating the
area that should be selected.
2009-05-14 13:31:21 +01:00
Thomas Wood
e79fd1055d [text] account for scrolling in clutter_text_position_to_coords
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.
2009-05-14 13:31:21 +01:00
Thomas Wood
16185c78fc [text] take scrolling into account when calculating cursor position
Account for the scrolling in single line more when calculating the cursor
position from coordinates.
2009-05-14 13:31:20 +01:00
Thomas Wood
e162d0b060 [text] position the cursor correctly in single line mode
The position of the text should be increased by the value of TEXT_PADDING
and the cursor offset by the same value as the text offset.
2009-05-14 13:31:20 +01:00
Thomas Wood
cd86e70f41 [text] take text padding into account when in single line mode
In single line mode, extra padding is added to the text which must be
taken into account when reporting the natural size of the actor.
2009-05-14 13:31:20 +01:00
Emmanuele Bassi
0d43d81ee0 [text] Maintain the cursor at the end when deleting
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.
2009-05-14 12:00:51 +01:00
Emmanuele Bassi
8174f66cc6 [text] Reset the cursor when setting empty text
When setting the contents of Text to an empty string we should
reset the cursor position and selection bound to -1.
2009-05-14 11:50:42 +01:00
Emmanuele Bassi
447e04bdce [text] Return the correct minimum height
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>
2009-05-13 23:06:43 +01:00