Merge branch 'text-actor'
* text-actor: (108 commits)
Re-align ClutterText header file
[text] Fix cursor sizing
Comments and whitespace fixes to ClutterText
[docs] Add newly added :single-line-mode accessors
Update the ignore file
[tests] Add text field interactive test
[text] Add single-line-mode to ClutterText
[text] Fix the deletion actions
[text] Use cached length when possible
[tests] Add unit for the ClutterText:password-char property
[docs] Update the Text section
[text] Coalesce text visibility and password character
Allow localizations to change the text direction
Clean up the update_pango_context() function
Pass the PangoContext, not the MainContext
Revert the logic of the PangoContext check
Remove the binding pool entry from the list
Remove BindingPool::list_actions()
Add ClutterActor::create_pango_context()
Rename the PangoContext creation functions
...
The cursor should be slightly smaller than the height of the actor, to
allow for painting a border. Let's pad it by 1 pixel on the top and 1
on the bottom.
Also, we should use the cursor size everywhere and not use hardcoded
magic numbers.
Allow using ClutterText as a single line text field. This is useful for
text fields that accept just a single line of contents by default, and
respond to the Enter key press to execute some action.
The :single-line-mode property enables this behaviour inside ClutterText
by clipping and scrolling the contents of the PangoLayout if they do
not fit the allocated width of the Text actor.
When using the delete-prev action from the end of the text we end
up either missing the first glyph we have to delete or falling
through the last one in the text.
This commit fixes both issues.
Since clutter_text_set_text() measures the length of the text
each time, we should use the cached length instead of recomputing
the text length each time. This should save us some time when
dealing with long, multi-byte texts.
Check that the contents of the Text actor are unaffected by the
:password-char property; that the accessors are correct; and finally
that the initial value for a newly constructed Text actor is valid.
Using two properties to set a password entry can be construed as
both cumbersome and a gtk-ism. And rightly so on both counts.
The :text-visible property has also conflicting semantics with the
:cursor-visible one: while the latter hides the cursor, the former
changes the display of the contents of the Text actor. It is, thus,
not a matter of "visibility" but of "rendering".
Instead of setting the :text-visible and :invisible-char properties
to have a password text field, the Text actor should just have a
single :password-char property holding a Unicode character. If the
value of the :password-char is non-zero, the Text actor will use the
Unicode character to render the contents of the text entry.
This commit removes the following methods:
clutter_text_set_text_visible()
clutter_text_get_text_visible()
clutter_text_set_invisible_char()
clutter_text_get_invisible_char()
And the following properties:
ClutterText:text-visible
ClutterText:invisible-char
In favour of:
clutter_text_set_password_char()
clutter_text_get_password_char()
And:
ClutterText:password-char
Thus making obvious what use the property and accessor methods are
for and simplifying the process of creating a simple password text
field to:
text = clutter_text_new ();
clutter_text_set_password_char (CLUTTER_TEXT (text), '*');
The locale translators of Clutter are also the ones that should set
the default direction of the text in a Clutter user interface.
This commit adds a translatable string that defines the direction
of the text; the translation authors will change it to the correct
value and that will determine the default direction.
The default text direction can be overridden by using the
CLUTTER_TEXT_DIRECTION environment variable, or by using the
--clutter-text-direction command line switch. In any other case,
the locale will determine the text direction, as it should.
It was always reading one pixel lower than requested. If y was 0 then
it would try to read below the lowest line.
Thanks to Geoff Gustafson for spotting.
Clutter has a set of command line options that are added to every
application by means of clutter_init() or by obtaining the Clutter
GOptionGroup and using g_option_context_parse(). Thus, every Clutter
application will automatically have an --help command line switch
showing the list of options and their description.
At the moment, Clutter does not enable localization of the help,
thus making it less than useful on non-English locales.
This patch enables the machinery to create a localization file and
load it when initializing Clutter, by means of the GLib macros and
locale.h API we already use.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Instead of including GL/gl.h directly it now includes cogl/cogl.h
instead which should include the right GL header.
Instead of using dlopen to specifically open libGL it now tries to use
dlsym with RTLD_NEXT. This requires defining _GNU_SOURCE on GNU
systems. If RTLD_NEXT is not available it will try passing NULL which
is unlikely to work but it will at least catch the case where it
returns the wrapper version of glGetString to prevent infinite
recursion.
This should hopefully make it work on OS X where the name of the
header and library are different (although this is currently
untested).
When updating the PangoContext with the current options (font name,
options, resolution) pass the PangoContext instead of the Clutter
MainContext structure pointer.
When removing a binding entry from the binding pool we should not
only remove it from the hash table, but also from the linked list
we use to iterate over inside the block/unblock_action() pair.
The clutter_binding_pool_list_actions() was not implemented. The
utility of a call listing all the action names is also debatable:
all the functions related to the key bindings take the key symbol
and modifiers -- except the block_action() and unblock_action()
pair.
Sometimes an actor needs to set specific font rendering options on
the PangoContext without changing settings for every other text-rendering
actor.
In order to do this, we need a new public method to create a Pango
context object -- preset with all the default settings -- owned by the
developer and not shared with the rest of Clutter.
This new method is called clutter_actor_create_pango_context(); while
it does not strictly depend on a ClutterActor, it is a good idea to
have it inside the ClutterActor API to map the current get_pango_context()
method and in case we start storing screen-specific data to the Actor
itself during the 1.x API cycle.
The _clutter_context_create_pango_context() should create a new
context; the function returning the PangoContext stored inside the
MainContext structure should be named _get_pango_context() instead.
The following functions are fixed:
clutter_animation_set_actor
clutter_animation_set_timeline
clutter_animation_set_alpha
This is related to bug 1392 which discusses the problem for
behaviour_set_alpha.
Bug 1392 - behaviour_set_alpha set same alpha twice lead to warning
and destroy the input alpha
The following functions are fixed:
clutter_actor_set_shader
clutter_alpha_set_timeline
clutter_behaviour_set_alpha
clutter_clone_texture_set_parent_texture
They either now reference the new value before destroying the old
value, or just return immediately if the values are the same.
It previously attempted to set the mode on the alpha using
clutter_animation_set_mode_internal, but this was setting the mode on
priv->alpha. At that point in the code priv->alpha is always NULL.
clutter_animation_set_mode_internal now takes a parameter to specify
which alpha to modify.
As of now, a key binding installed into a BindingPool is always there
and cannot be changed.
This is problematic for sub-classes trying to override the callback
or the action for a given key binding.
This commit adds the ability to override the closure for an existing
key binding inside a binding pool -- assumed the caller knows the
key symbol and modifiers used to install the key binding in the first
place.
Otherwise the call to clutter_alpha_set_func sets the mode back to
CLUTTER_CUSTOM_MODE so clutter_alpha_get_mode won't get back the same
value that was set.
* units-rework:
[texture] Do not mix fixed point and units values
[tests] Fix the actor detection
[units] Do not use fixed point and units interchangeably
Removed trailing white space from the following files:
- clutter-clone-texture.c
- clutter-texture.c
- clutter-texture.h
- cogl/cogl-texture.h
- cogl/gl/cogl-context.c
- cogl/gl/cogl-texture.c
- cogl/gl/cogl-context.h
The direction of the text depends on the locale, and it is the
basic setting needed to enable internationalization of user
interfaces.
This commit allows setting the direction of the PangoContext instance
used by Clutter by using the CLUTTER_TEXT_DIRECTION environment
variable, or by passing the --clutter-text-direction command line
argument. Valid values are:
ltr - for left-to-right locales
rtl - for right-to-left locales
The default is LTR.
Ideally, this should be a value set by the localization teams on the
PO file, but this step requires some build system surgery to allow
the translation of the Clutter strings.
When calling clutter_backend_get_font_name(), if no default font
name has previously been set, we just set the default and return
a pointer to it - like we do for the font options.
Instead of storing the default font name and size as a pre-processor
macro, use the newly added ClutterBackend API to retrieve the current
default font from the backend.
The default backend stores some of the global defaults, like the
font options, text resolution, double click settings. It should also
store the default font name, to allow various text-based actors to
share the same settings.
When the font name changes, the ::font-changed signal is emitted,
to allow actors to pick up the change.
When the ClutterBackend notifies of changes in the resolution or
font options, update the PangoContext stored by Clutter's main
context. This allows changing the backend font-related settings at
runtime.
The PangoContext should be stored once, and inside the main
Clutter context. Each actor for which clutter_actor_get_pango_context()
has been called will hold a reference on the Pango context as well.
This makes it possible to update the text rendering for Clutter
by using only public API.
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.
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.