1
0
Fork 0
Commit graph

2338 commits

Author SHA1 Message Date
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
608c3e3ab4 [build] Fix with --disable-introspection
The required "fake" libclutter-cogl.la upon with the main clutter
shared object depends is only built with introspection enabled
instead of being built unconditionally.
2009-05-14 10:03:31 +01:00
Owen W. Taylor
d8aa6827ee Don't build Cogl.gir against installed Clutter library
Passing:

 --library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@

to g-ir-scanner, when building Cogl was causing g-ir-scanner to
link the introspection program against the installed clutter library,
if it existed or fail otherwise. Instead copy the handling from
the json/ directory where we link against the convenience library
to scan, and do the generation of the typelib later in the
main clutter/directory.

Fixes bug:

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-13 23:31:43 +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
Emmanuele Bassi
aa1246e891 [backend] Abstract the GL context creation
This is the another step into abstracting the backend operations
that are currently spread all across the board back into the
backend implementations where they belong.

The GL context creation, for instance, is demanded to the stage
realization which makes it a critical path for every operation
that is GL-context bound. This usually does not make any difference
since we realize the default stage, but at some point we might
start looking into avoiding the default stage realization in order
to make the Clutter startup faster.

It also makes the code maintainable because every part is self
contained and can be reworked with the minimum amount of pain.
2009-05-13 22:21:48 +01:00
Emmanuele Bassi
1d7a79f343 Update the redraw priority
The master clock is using the redraw priority to create the source
that will be used to spin the paint sequence if something is being
animated using a timeline.

Unfortunately, the priority is too high and this causes starvation
when embedding into other toolkits -- like gtk+.

Thanks to Havoc Pennington for catching this.
2009-05-13 22:20:19 +01:00
Emmanuele Bassi
e59a19bd03 [x11] Abstract XVisualInfo creation
The XVisualInfo for GL is created when a stage is being realized.
When embedding Clutter inside another toolkit we might not want to
realize a stage to extract the XVisualInfo, then set the stage
window using a foreign X Window -- which will cause a re-realization.

Instead, we should abstract as much as possible into the X11 backend.

Unfortunately, the XVisualInfo for GL is requested using GLX API; for
this reason we have to create a ClutterBackendX11 method that we
override inside the ClutterBackendGLX implementation.

This also allows us to move a little bit of complexity from out of
the stage realization, which is currently a very delicate and hard
to debug section.
2009-05-13 21:49:45 +01:00
Robert Bragg
2b1759385e [text] Ensure clutter_text_get_selection copes with start/end positions of -1
I was seeing clutter_text_get_selection trying to malloc up to 4Gb due to
unexpected negative arithmetic for the start/end offsets which resulted
in a crash.

This just tests for positions of -1 before deciding if the start/end
positions need to be swapped.  The conversion from position to byte offset
already works with -1.
2009-05-13 14:34:00 +01:00
Owen W. Taylor
df85b70ab4 Fix chain-up in clutter_list_model_dispose()
Chain up to parent class's dispose() method not parent class's
finalize() method.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-12 16:31:41 +01:00
Robert Bragg
d1fa83039d [picking] Use cogl_clip_push_window_rect to greatly reduce the cost of picking.
cogl_clip_push_window_rect is implemented using GPU scissoring which allows
the GPU to cull anything that falls outside a given rectangle.  Since in the
case of picking we only ever care about a single pixel we can get the GPU to
ignore all geometry that doesn't intersect that pixel and only rasterize for
one pixel.
2009-05-12 15:44:34 +01:00
Robert Bragg
e80fcbc298 [cogl-clip-stack] Support pushing rectangles onto the stack using window coords
Previously clipping could only be specified in object coordinates, now
rectangles can also be pushed in window coordinates.

Internally rectangles pushed this way are intersected and then clipped using
scissoring.  We also transparently try to convert rectangles pushed in
object coordinates into window coordinates as we anticipate the scissoring
path will be faster then the clip planes and undoubtably it will be faster
than using the stencil buffer.
2009-05-12 15:44:33 +01:00
Neil Roberts
e9b863eba2 Don't clear the stencil buffer before painting and picking
The stencil buffer is always cleared the first time a clip is used
that needs it and the stencil test is disabled otherwise so there is
no need to clear before a paint.
2009-05-12 15:36:16 +01:00
Robert Bragg
36cfb60307 [cogl] Remove the COGL{enum,int,uint} typedefs
COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint}
have been removed from the API and replaced with specialised enum typedefs, int
and unsigned int. These were causing problems for generating bindings and also
considered poor style.

The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now replaced
by a namespaced typedef 'CoglTextureFilter' so they should be replaced with
COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc.

The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled by
a CoglShaderType typedef and should be replaced with COGL_SHADER_TYPE_VERTEX and
COGL_SHADER_TYPE_FRAGMENT.

cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and
cogl_shader_is_compiled. More getters can be added later if desired.
2009-05-12 14:53:44 +01:00
Robert Bragg
cea711cc7e [ClutterTexture] Remove a spurious line I accidentally committed in 741c4bb5
I accidentally changed clutter_texture_set_cogl_texture to always set the
filter quality for the new Cogl texture to medium.
2009-05-12 14:53:43 +01:00
Robert Bragg
08a73a215f Don't call glFinish in _clutter_do_pick
Calling glReadPixels is bad enough in forcing us to synchronize the CPU with
the GPU, but glFinish has even stronger synchonization semantics than
glReadPixels which may negate some driver optimizations possible in
glReadPixels.
2009-05-12 14:53:43 +01:00
Neil Roberts
10783e053b [build] Fix out-of-tree builds for Cogl
Commit 43fa38fcf5 broke out-of-tree builds by removing some of the
builddir directories from the include path. builddir/clutter/cogl and
builddir/clutter are needed because cogl.h and cogl-defines-gl.h are
automatically generated by the configure script. The main clutter
headers are in the srcdir so this needs to be in the path too.
2009-05-12 14:16:46 +01:00
Raymond Liu
dd95939d26 Emit key focus signal when stage state changes
When the stage state changes between active/deactive, send out
key-focus-in/key-focus-out signal for the current key focused
actor on the stage.

Fixes bug:

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-12 13:47:17 +01:00
Emmanuele Bassi
4b285e02bc [x11] Unset the GL context when re-realizing
Setting the stage window using the set_stage_foreign() method will
lead to a re-realization. We need to make sure that the Drawable
currently associated to the GL context is set to None, to avoid a
BadDrawable error or, if we're unlucky, a segfault in the X server.
2009-05-11 18:17:30 +01:00
Emmanuele Bassi
0b7e459d48 Add more debugging notes 2009-05-11 12:45:33 +01:00
Emmanuele Bassi
8b7c6955de [backend] Unset the current stage if it is unrealized
This commit reverts part of commit 5bcde25c - specifically the
part that forced a realization of the stage if we are ensuring
the GL context with it. This makes Clutter behave like it did
prior to commit 5bcde25c: if we are asked to ensure the GL context
with an unrealized stage we simply pass NULL to the backend
implementation.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
d19f6feb45 [stage] Chain up ::show before showing the implementation
When showing a Stage for the first time we end up realizing the stage
implementation before realizing the wrapper. This leads to segmentation
faults or errors coming from the backend because we're fumbling the
state and realization sequence.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
9582fddb24 [x11] Do not needlessly check XVisualInfo
Since we are destroying any previously set VisualInfo we keep we know
for sure that stage->xvisinfo is going to be None; hence, no reason to
check this condition.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
0acb98e987 [actor] Conditionally verify the map state
The verify_map_state() internal method is conditionally compiled
if we have CLUTTER_ENABLE_DEBUG set; for this reason, all calls to
that method should be made conditional.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
d00cac6353 [build] Unbreak compilation
When building Clutter with introspection enabled everything stops
at Cogl GIR generation because it depends on the installed library
to work. Since we still require some changes in the API to be able
to build the GIR and the typelib for Cogl we should disable the
generation of the GIR as well.
2009-05-10 00:44:10 +01:00
Emmanuele Bassi
5bcde25cbb Tentative fix for multi-stage support on GLX
The fix for bug 1138 broke multi-stage support on GLX, causing
X11 to segfault with the following stack trace:

Backtrace:
0: /usr/X11R6/bin/X(xf86SigHandler+0x7e) [0x80c91fe]
1: [0xb7eea400]
2: /usr/lib/xorg/modules/extensions//libglx.so [0xb7ae880c]
3: /usr/lib/xorg/modules/extensions//libglx.so [0xb7aec0d6]
4: /usr/X11R6/bin/X [0x8154c24]
5: /usr/X11R6/bin/X(Dispatch+0x314) [0x808de54]
6: /usr/X11R6/bin/X(main+0x4b5) [0x8074795]
7: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7c75775]
8: /usr/X11R6/bin/X(FontFileCompleteXLFD+0x21d) [0x8073a81]

which I can only track down to clutter_backend_glx_ensure_current()
being passed a NULL stage -- something that happens when a stage
is not correct realized. That should lead to a glXMakeCurrent(None)
and not to a segmentation fault, though.
2009-05-08 17:17:48 +01:00
Emmanuele Bassi
91126558d3 [actor] Relax some of the invariants checks
When destroying a top-level actor we can actually relax the verification
of the map state, since it might be fully asynchronous and we might not
re-enter inside the mainloop in time to receive the unmap notification.
2009-05-08 17:14:49 +01:00
Rob Bradford
692c50ba67 [list-model] Return NULL for first row in a fully filtered model
If the filter means that the there should be no rows left in the model,
clutter_model_get_iter_at_row (model, 0) should return NULL.

Howevever the currene implementation misbehaves and returns a bad iterator.
This change resolves the issue by tracking if we actually found any
non-filtered rows in our pass through the sequence.

OH Bugzilla: 1591
2009-05-08 12:33:44 +01:00
Emmanuele Bassi
9f3927c460 [stage] Chain up to the correct vfunc when picking
The stage is chaining up to the ClutterGroup::paint instead of
the ClutterGroup::pick method. This works anyway because we
detect the stage by default, but it's not a reliable solution
in case we decide to change the picking further on.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
533c9c5365 [debug] Show the actor name/type on queue_redraw() 2009-05-07 19:25:24 +01:00
Emmanuele Bassi
86bc31bd55 [clock] Rework the master clock
The master clock is currently advanced using a frame source driven
by the default frame rate. This breaks the sync to vblank because
the vblanking rate could be different than 60 Hz -- or it might be
completely disabled (e.g. with CLUTTER_VBLANK=none).

We should be using the main loop to check if we have timelines
playing, and if so queue a redraw on the stages we own.

We should also prepare the subsequent frame at the end of the redraw
process, so if there are new redraw we will have the scene already
in place.

This makes Clutter redraw at the maximum frame rate, which is
limited by the vblanking frequency.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
ab9c7671f5 [group] Implement pick
Currently, picking in ClutterGroup pollutes the CLUTTER_DEBUG=paint
logs since it just calls the paint function. Reimplementing the pick
doesn't make us lose anything -- it might even be slightly faster
since we don't have to do a (typed) cast and a class dereference.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
081813fd61 [animation] Do not leak timelines
The timeline created when calling set_timeline(NULL) is referenced
even though we implicitly own it. When the Animation is destroyed,
the timeline is then leaked.

Thanks to: Richard Heatley <richard.heatley@starleaf.com>

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1548
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
33ef1675f5 [script] Allow parsing units in em
When creating an actor, using "em" as a unit should result
in an implicit conversion, like for "mm" and "pt".
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
f2c25fd4f7 Allow specifying the font for the em conversion
Currently, the conversion from em to units is done by using the
default font name inside the backend. For actors using their own
font/text layout we need a way to specify the font name along
with the quantity we wish to transform.
2009-05-07 19:25:18 +01:00
Emmanuele Bassi
8ec1c3e2fb Fix remaining ::focus-in signal emission
Commit 515350a7 renamed ::focus-in and ::focus-out to ::key-focus-in
and ::key-focus-out respectively. One signal emission for ::focus-out
escaped the renaming in ClutterStage.
2009-05-07 11:18:51 +01:00
Emmanuele Bassi
2ae9d84a2a [x11] Use -1 as the default screen guard
Currently, the default screen guard value is 0, which is a valid
screen number on X11, and it might not be the default.

Patch suggested by: Owen W. Taylor <otaylor@redhat.com>
2009-05-06 18:32:17 +01:00
Emmanuele Bassi
8ca46d728d [build] Build Cogl introspection data
Currently, the introspection data for Cogl is built right into
Clutter's own typelib. This makes functions like:

  cogl_path_round_rectangle()

Appear as:

  Clutter.cogl_path_round_rectangle()

It should be possible, instead, to have a Cogl namespace and:

  Cogl.path_round_rectangle()

This means building introspection data for Cogl alone. Unfortunately,
there are three types defined in Cogl that confuse the introspection
scanner, and make it impossible to build a typelib:

  COGLint
  COGLuint
  COGLenum

These three types should go away before 1.0, substituted by int,
unsigned int and proper enumeration types. For this reason, we can
just set up the GIR build and wait until the last moment to create
the typelib. Once that has been done, we will be able to safely
remove the Cogl API from the Clutter GIR and typelib and let
people import Cogl if they want to use the Cogl API via introspection.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
43fa38fcf5 [build] Clean up the makefile
Split out the files into their own variables to clean up the
Makefile template; also use top_srcdir with the header files
instead of top_builddir.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
c065524b9f Fix inclusion guards and headers
The C++ inclusion guards G_BEGIN_DECLS and G_END_DECLS are
defined by GLib; so we need to include glib.h before using
them.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
515350a77f [actor] Rename focus-in and focus-out signals
For consistency, and since those signals are key-related, the
::focus-in signal is not ::key-focus-in and the ::focus-out
signal is now ::key-focus-out.
2009-05-06 17:56:40 +01:00
Emmanuele Bassi
d0ad5a8abb [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-06 17:18:12 +01:00
Emmanuele Bassi
a28b9f31eb [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-06 17:13:33 +01:00
Emmanuele Bassi
ab1dcb8033 [animation] Remove InitiallyUnowned from Animation
ClutterAnimation currently inherits the initial floating reference
semantics from GInitiallyUnowned. An Animation is, though, meant to
be used as a top-level object, like a Timeline or a Behaviour, and
not "owned" by another object. For this reason, the initial floating
reference does not make any sense.
2009-05-06 17:01:44 +01:00
Emmanuele Bassi
d6d208da7d Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.

ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.

So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:

  - we have to maintain twice the amount of entry points in ClutterActor
  - we still do an integer-to-float implicit conversion
  - we introduce a weird impedance between pixels and "pixels with
    fractionary bits"
  - language bindings will have to choose what to bind, and resort
    to manually overriding the API
    + *except* for language bindings based on GObject-Introspection, as
      they cannot do manual overrides, thus will replicate the entire
      set of entry points

For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:

  void clutter_actor_set_x (ClutterActor *self,
                            gfloat        x);
  void clutter_actor_get_size (ClutterActor *self,
                               gfloat       *width,
                               gfloat       *height);
  gfloat clutter_actor_get_height (ClutterActor *self);

etc.

The issues I have identified are:

  - we'll have a two cases of compiler warnings:
    - printf() format of the return values from %d to %f
    - clutter_actor_get_size() taking floats instead of unsigned ints
  - we'll have a problem with varargs when passing an integer instead
    of a floating point value, except on 64bit platforms where the
    size of a float is the same as the size of an int

To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:

  - we remove ambiguity in the API with regard to pixels and units
  - we remove entry points we get to maintain for the whole 1.0
    version of the API
  - we make things simpler to bind for both manual language bindings
    and automatic (gobject-introspection based) ones
  - we have the simplest API possible while still exposing the
    capabilities of the underlying GL implementation
2009-05-06 16:44:47 +01:00
Emmanuele Bassi
7afdfb080b [docs] Document the destructor for Timeline
The rest of the API reference lists the destructor for the class
inside the constructor's return value -- except Timeline.
2009-05-06 16:42:57 +01:00
Rob Bradford
41bb885486 [model] Add a private row mutator to ClutterModelIter
When calling clutter_model_iter_next () / clutter_model_iter_prev () we need
to update the row for the iterator. In order to improve the peformance of
iterating this change adds a private row mutator and switches ClutterListModel
to use it.
2009-05-05 20:18:28 +01:00
Rob Bradford
b2fbc2c95c [list-model] Use an internal iterator for comparisons
In order to carry out various comparisons for e.g. identifying the first
iterator in the model we need a ClutterModelIter. This change switches from
creating a new iterator each time to reusing an existing iterator.
2009-05-05 19:39:26 +01:00
Emmanuele Bassi
72562cda58 [actor] Add ActorFlags accessor methods
The flags field of ClutterActor should have accessor methods for,
language bindings.

Also, the set_flags() and unset_flags() methods should actively
emit notifications for the changed properties.
2009-05-05 18:08:53 +01:00
Emmanuele Bassi
fc991e9b67 [actor] Add the :realized property
The :realized property is the only missing property for an actor flag.
2009-05-05 15:36:29 +01:00
Robert Bragg
353187ce49 [cogl-material] Adds a cogl_material_set_color4f convenience function
This is simply a wrapper around cogl_color_set_from_4f and
cogl_material_set_color. We already had a prototype for this, it was
an oversight that it wasn't already implemented.
2009-05-02 04:12:26 +01:00
Robert Bragg
a5cdfdfd87 [cogl-offscreen] Cleans up the cogl offscreen API and adds documentation
There were several functions I believe no one is currently using that were
only implemented in the GL backend (cogl_offscreen_blit_region and
cogl_offscreen_blit) that have simply been removed so we have a chance to
think about design later with a real use case.

There was one nonsense function (cogl_offscreen_new_multisample) that
sounded exciting but in all cases it just returned COGL_INVALID_HANDLE
(though at least for GL it checked for multisampling support first!?)
it has also been removed.

The MASK draw buffer type has been removed. If we want to expose color
masking later then I think it at least would be nicer to have the mask be a
property that can be set on any draw buffer.

The cogl_draw_buffer and cogl_{push,pop}_draw_buffer function prototypes
have been moved up into cogl.h since they are for managing global Cogl state
and not for modifying or creating the actual offscreen buffers.

This also documents the API so for example desiphering the semantics of
cogl_offscreen_new_to_texture() should be a bit easier now.
2009-05-02 04:12:26 +01:00
Havoc Pennington
e47b198225 add cogl_push_draw_buffer() and cogl_pop_draw_buffer()
These are necessary if nesting redirections to an fbo,
otherwise there's no way to know how to restore
previous state.

glPushAttrib(GL_COLOR_BUFFER_BIT) would save draw buffer
state, but also saves a lot of other stuff, and
cogl_draw_buffer() relies on knowing about all draw
buffer state changes. So we have to implement a
draw buffer stack ourselves.

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-05-02 04:12:26 +01:00
Robert Bragg
d5fc61102f [cogl] Only expose CoglBitmap as a CoglHandle
It was inconsistent that we exposed the CoglBitmap struct instead of an
opaque CoglHandle.
2009-05-02 04:12:26 +01:00
Robert Bragg
ee57192f47 [cogl-material] make _cogl_material_layer_free check for an invalid texture handle
It is valid in some situations to have a material layer with an invalid texture
handle (e.g. if you setup a texture combine mode before setting the texture)
and so _cogl_material_layer_free needs to check for a valid handle before
attempting to unref it.
2009-05-02 04:12:25 +01:00
Robert Bragg
f85377372c [cogl] Updates all file headers and removes lots of trailing white space
Adds missing notices, and ensures all the notices are consistent. The Cogl
blurb also now reads:

 * Cogl
 *
 * An object oriented GL/GLES Abstraction/Utility Layer
2009-05-02 04:12:25 +01:00
Robert Bragg
741c4bb5e9 [cogl] Adds a bitfield argument to cogl_clear for specifying which buffers to clear
Redundant clearing of depth and stencil buffers every render can be very
expensive, so cogl now gives control over which auxiliary buffers are
cleared.

Note: For now clutter continues to clear the color, depth and stencil buffer
each paint.
2009-05-02 04:12:12 +01:00
Neil Roberts
fa9efe4828 Accumulate small deltas
The clutter frame source tries to average out the frame deltas so that
if one frame takes 1 interval plus a little bit of extra time then the
next frame will be 1 interval minus that little bit of extra
time. Therefore the deltas can sometimes be less than the frame
interval. ClutterTimeline should accumulate these small differences
otherwise it will end up missing out frames so the total duration of
the timeline will be a lot longer.

For example this was causing test-actors to appear to run very slow.
2009-05-01 15:12:08 +01:00
Emmanuele Bassi
5be29cf9bc [timeline] Expose the msec advancement
The method of ClutterTimeline that advances the timeline by a
delta (in millisecond) is going to be useful for testing the
timeline's behaviour -- and unbreak the timeline test suite that
was broken by the MasterClock merge.
2009-05-01 15:05:51 +01:00
Emmanuele Bassi
1a87e4e252 [clone] Allow painting hidden source actors
With the introduction of the map/unmap flags and the split of the
visible state from the mapped state we require that every part of
a scene graph branch is mapped in order to be painted. This breaks
the ability of a ClutterClone to paint an hidden source actor.

In order to fix this we need to introduce an override flag, similar
in spirit to the current modelview and paint opacity overrides that
Clone is already using.

The override flag, when set, will force a temporary map on a
Clone source (and its children).
2009-05-01 12:33:42 +01:00
Emmanuele Bassi
5d2d8297e2 [actor] Use foreach_with_internals()
ClutterContainer provides a foreach_with_internals() vfunc for
iterating over all of a container's children, be them added using
the Container API or be them internal to the container itself.

We should be using the foreach_with_internals() function instead
of the plain foreach().
2009-05-01 12:31:06 +01:00
Neil Roberts
20cd885c3d [ClutterTexture] Check before unrefing the fbo_handle
When replacing the fbo_handle with a new handle it first unrefs the
old handle. This was previously a call to cogl_offscreen_unref which
silently ignored attempts to unref COGL_INVALID_HANDLE. However the
new cogl_handle_unref does check for this so we should make sure the
handle is valid to avoid the warning.
2009-04-30 15:09:04 +01:00
Neil Roberts
4f692cc3ee [ClutterTexture] Attach the FBO texture to a layer in the material
Bug 1565 - test-fbo case failed in many platform

clutter_texture_new_from_actor was broken because it created the FBO
texture but then never attached it to the material so it was never
used for rendering. The old behaviour in Clutter 0.8 was to assign the
texture directly to priv->tex. In 0.9 priv->tex is replaced with
priv->material which has a reference to the tex in layer 0. So putting
the FBO texture directly in layer 0 more closely matches the original
behaviour.
2009-04-30 15:09:04 +01:00
Øyvind Kolås
8e6e09c8ef [events] Added handling of missing type to clutter_event_get_state
clutter_event_get_state wasn't returning the state for
CLUTTER_BUTTON_RELEASE, the information was there it just needed to
be returned correctly.
2009-04-30 11:54:09 +01:00
Neil Roberts
bb156970de Render pango layouts with vertex buffers
When rendering a pango layout CoglPangoRenderer now records the
operations into a list called a CoglPangoDisplayList. The entries in
the list are either glyph renderings from a texture, rectangles or
trapezoids. Multiple consecutive glyph renderings from the same glyph
cache texture are combined into a single entry. Note the
CoglPangoDisplayList has nothing to do with a GL display list.

After the display list is built it is attached to the PangoLayout with
g_object_set_qdata so that next time the layout is rendered it can
bypass rebuilding it.

The glyph rendering entries are drawn via a VBO. The VBO is attached
to the display list so it can be used multiple times. This makes the
common case of rendering a PangoLayout contained in a single texture
subsequent times usually boil down to a single call to glDrawArrays
with an already uploaded VBO.

The VBOs are accessed via the cogl_vertex_buffer API so if VBOs are
not available in GL it will resort to a fallback.

Note this will fall apart if the pango layout is altered after the
first render. I can't find a way to detect when the layout is
altered. However this won't affect ClutterText because it creates a
new PangoLayout whenever any properties are changed.
2009-04-29 19:53:24 +01:00
Emmanuele Bassi
01d172293c [model] Rework Model behaviour with a filter
Currently ClutterModel::get_iter_at_row() ignores whether we have
a filter in place. This also extends to the get_n_rows() method.

The more consistent, more intuitive and surely more correct way to
handle a Model with a filter in place is to take into account the
presence of the filter itself -- that is:

  - get_n_rows() should take into account the filter and return the
    number of *filtered* rows

  - get_iter_at_row() should also take the filter into account and
    get the first non-filtered row

These two changes make the ClutterModel with a filter function
behave like a subset of the original Model without a filter in
place.

For instance, given a model with three rows:

  - [row 0]     <does not match filter>
  - [row 1]     <matches filter>
  - [row 2]     <matches filter>
  - [row 3]     <does not match filter>

The get_n_rows() method will return "2", since only two rows will
match the filter; the get_first_iter() method will ask for the
zero-eth row, which will return an iterator pointing to the contents
of row 1 (but the :row property of the iterator will be set to 0);
the get_last_iter() method will ask for the last row, which will
return an iterator pointing to the contents of row 2 (but the :row
property of the iterator will be set to 1).

This changes will hopefully make the Model API more consistent
in its usage whether there is a filter in place or not.
2009-04-29 15:26:05 +01:00
Emmanuele Bassi
44fefa2afe [model] Add :filter-set
Currently, there is no way for implementations of the ClutterModel
abstract class to know whether there is a filter in place. Since
subclasses might implement some optimization in case there is no
filter present, we need a simple (and public) API to ask the model
itself.
2009-04-29 15:14:40 +01:00
Neil Roberts
9fdc9ca583 [ClutterText] Fix actors with a width but no wrapping and the wrap modes
Setting the wrap mode on the PangoLayout seems to have disappeared
during the text-actor-layout-height branch merge so this brings it
back. The test for this in test-text-cache no longer needs to be
disabled.

We also shouldn't set the width on the layout if there is no wrapping
or ellipsizing because otherwise it implicitly enables wrapping. This
only matters if the actor gets allocated smaller than its natural
size.
2009-04-27 17:43:48 +01:00
Owen W. Taylor
e260296cb5 [clone] Redraw when the source changes
Bug 1484 - Redraw ClutterClone when the source changes, even for
           !visible sources

Connect to ::queue-redraw on the clone source and queue a redraw.
This allows redrawing the Clone when the source changes, even in
case of a non visible source actor.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:30:59 +01:00
Emmanuele Bassi
678f99677f Use a single master "clock" to drive timelines
Currently, all timelines install a timeout inside the TimeoutPool
they share. Every time the main loop spins, all the timeouts are
updated. This, in turn, will usually lead to redraws being queued
on the stages.

This behaviour leads to the potential starvation of timelines and
to excessive redraws.

One lesson learned from the games developers is that the scenegraph
should be prepared in its entirety before the GL paint sequence is
initiated. This means making sure that every ::new-frame signal
handler is called before clutter_redraw() is invoked.

In order to do so a TimeoutPool is not enough: we need a master
clock. The clock will be responsible for advancing all the active
timelines created inside a scene, but only when the stage is
being redrawn.

The sequence is:

  + queue_redraw() is invoked on an actor and bubbles up
    to the stage

  + if no redraw() has already been scheduled, install an
    idle handler with a known priority

  + inside the idle handler:

    - advance the master clock, which will in turn advance
      every playing timeline by the amount of milliseconds
      elapsed since the last redraw; this will make every
      playing timeline emit the ::new-frame signal

    - queue a relayout

    - call the redraw() method of the backend

This way we trade multiple timeouts with a single frame source
that only runs if a timeline is playing and queues redraws on
the various stages.
2009-04-24 15:28:15 +01:00
Johan Bilien
51f4e9680b Relinquish the focus when unmapped while owning it
Bug 1547 - when an actor is unmapped while owning the focus, it should
           release it

When an actor is unmapped while owning the focus, the should release it.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:47 +01:00
Havoc Pennington
125bded814 Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state

* Add a VISIBLE flag tracking application programmer's
  expected showing-state for the actor, allowing us to
  always ensure we keep what the app wants while tracking
  internal implementation state separately.

* Make MAPPED reflect whether the actor will be painted;
  add notification on a ClutterActor::mapped property.
  Keep MAPPED state updated as the actor is shown,
  ancestors are shown, actor is reparented, etc.

* Require a stage and realized parents to realize; this means
  at realization time the correct window system and GL resources
  are known. But unparented actors can no longer be realized.

* Allow children to be unrealized even if parent is realized.
  Otherwise in effect either all actors or no actors are realized,
  i.e. it becomes a stage-global flag.

* Allow clutter_actor_realize() to "fail" if not inside a toplevel

* Rework clutter_actor_unrealize() so internally we have
  a flavor that does not mess with visibility flag

* Add _clutter_actor_rerealize() to encapsulate a somewhat
  tricky operation we were doing in a couple of places

* Do not realize/unrealize children in ClutterGroup,
  ClutterActor already does it

* Do not realize impl by hand in clutter_stage_show(),
  since showing impl already does that

* Do not unrealize in various dispose() methods, since
  ClutterActor dispose implementation already does it
  and chaining up is mandatory

* ClutterTexture uses COGL while unrealizable (before it's
  added to a stage). Previously this breakage was affecting
  ClutterActor because we had to allow realize outside
  a stage. Move the breakage to ClutterTexture, by making
  ClutterTexture just use COGL while not realized.

* Unrealize before we set parent to NULL in clutter_actor_unparent().
  This means unrealize() implementations can get to the stage.
  Because actors need the stage in order to detach from stage.

* Update clutter-actor-invariants.txt to reflect latest changes

* Remove explicit hide/unrealize from ClutterActor::dispose since
  unparent already forces those
  Instead just assert that unparent() occurred and did the right thing.

* Check whether parent implements unrealize before chaining up
  Needed because ClutterGroup no longer has to implement unrealize.

* Perform unrealize in the default handler for the signal.
  This allows non-containers that have children to work properly,
  and allows containers to override how it's done.

* Add map/unmap virtual methods and set MAPPED flag on self and
  children in there. This allows subclasses to hook map/unmap.
  These are not signals, because notify::mapped is better for
  anything it's legitimate for a non-subclass to do.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:19 +01:00
Johan Bilien
b73ee6992c Unnecessary glColorMask on alpha drops performance
Bug 1228 - Unnecessary glColorMask on alpha drops performance

With DRI2, alpha is allowed in the window's framebuffer

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:26:32 +01:00
Emmanuele Bassi
08ba42a5ab Allow passing the pick mode to get_actor_at_pos()
Bug 1513 - Allow passing in ClutterPickMode to
           clutter_stage_get_actor_at_pos()

At the moment, clutter_stage_get_actor_at_pos() uses CLUTTER_PICK_ALL
internally to find an actor. It would be useful to allow passing in
ClutterPickMode to clutter_stage_get_actor_at_pos(), so that the caller
can specify CLUTTER_PICK_REACTIVE as a criteria.
2009-04-24 15:25:58 +01:00
Emmanuele Bassi
6064572703 [x11] Use XWithdrawWindow()
Bug 1516 - Does not withdraw toplevels correctly

clutter_stage_x11_hide() needs to use XWithdrawWindow(), not
XUnmapWindow().

As it stands now, if the window is already unmapped (say the WM has
minimized it), then the WM will not know that Clutter has closed the
window and will keep the window managed, showing it in the task list
and so forth.
2009-04-24 15:25:31 +01:00
Havoc Pennington
4f663384c7 Add ClutterContainer::foreach_with_internals()
Bug 1517 - clutter_container_foreach_with_internals()

This allows us to iterate over all children (for things like maintaining
map/realize invariants) or only children that apps added and care about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:25:08 +01:00
Emmanuele Bassi
d6ccecd79e [alpha] Sanitize easing equations
Bug 1561 - Bad code in clutter-alpha.c

The implementation of the easing modes equations followed closely
the JavaScript and ActionScript counterparts. Obviously, JS and AS
are not C-compatible, so later versions of gcc (4.4.0 for instance)
would complain about uninitialized variables and such. The code is
also obfuscated and hard to debug/understand.

For these reasons, the implementation should be unobfuscated and
sanitized.
2009-04-23 11:35:10 +01:00
Robert Bragg
1d2ac51ea3 [x11-texture-pixmap] Fixes a reported lockup due to an undesireable X server grab
A lockup was reported by fargoilas on #clutter and removing the server grab in
clutter_x11_texture_pixmap_sync_window fixed the problem.

We were doing an x server grab to guarantee that if the XGetWindowAttributes
request reported that our redirected window was viewable then we would also
be able to get a valid pixmap name.  (the composite protocol says it's an
error to request a name for a window if it's not viewable) Without the grab
there would be a race condition.

Instead we now handle error conditions gracefully.
2009-04-22 13:43:53 +01:00
Emmanuele Bassi
ffefbe4661 [text] Avoid a Pango warning with empty markup
When the markup string is empty Pango complains about invalid
characters.
2009-04-21 14:08:55 +01:00
Emmanuele Bassi
1c42e6334e [text] Emit ::cursor-event only on changes
The documentation for the ::cursor-event says that the signal
is emitted only when the cursor position changes. Right now it
is being emitted every time we ensure the cursor position during
the Text paint sequence.

The clutter_text_ensure_cursor_position() function should check
whether the stored cursor position has changed since the last
paint, and emit the ::cursor-event signal only when there has
been a change.
2009-04-21 12:11:42 +01:00
Emmanuele Bassi
368f61fa65 [text] Return the correct minimum height
The correct minimum height in case of ellipsis is still 1px.
2009-04-21 12:11:41 +01:00
Emmanuele Bassi
5c8263ecb7 [text] Limit the Layout width
We only want to eschew the pango_layout_set_width() on editable,
single-line Text actors because they can "scroll" the PangoLayout.

This fixes the ellipsization on entries.
2009-04-21 12:11:41 +01:00
Robert Bragg
e4d3b0536f [gl/cogl.c] #include <gmodule.h> for OS X builds
In unifying the {gl,gles}/cogl.c code recently, moving most of the code into
common/cogl.c the gmodule.h include was also mistakenly moved.

Thanks to Felix Rabe for reporting this issue.

Note: I haven't tested this fix myself, as I'm not set up to be able to
build for OS X
2009-04-20 14:20:37 +01:00
Robert Bragg
46c20f1523 [cogl vertex buffers] Adds fallbacks for drivers without VBO support
Buffer objects aren't currently available for glx indirect contexts, so we
now have a fallback that simply allocates fake client side vbos to store the
attributes.
2009-04-20 13:04:34 +01:00
Robert Bragg
ac21e7b182 [cogl debug] --cogl-debug=rectangles now outlines all cogl rectangles
This makes the #if 0'd debug code that was in _cogl_journal_flush_quad_batch
- which we have repeatedly found usefull for debugging various geometry
issues in Clutter apps - a runtime debug option.

The outline colors rotate in order from red to green to blue which can also
help confirm the order that your geometry really drawn.

The outlines are not affected by the current material state, so if you e.g.
have a blending bug where geometry mysteriously disappears this can confirm
if the underlying rectangles are actually being emitted but blending is
causing them to be invisible.
2009-04-17 15:25:28 +01:00
Robert Bragg
169d472d17 Use $(MAINTAINER_CFLAGS) in clutter/{x11,glx}/Makefile.am
These makefile weren't resulting in the addition of the maintainer flags while
building clutter.
2009-04-17 14:53:24 +01:00
Bastian Winkler
5c50be1bdc Prevent a possible zero division
A zero division might occur in clutter_path_get_position if the length
of a curved node is zero.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2009-04-16 17:16:31 +01:00
Chris Lord
56ac4baf17 [ClutterText] Return 1 for min width when editable
Editable ClutterText will scroll when allocated less width than is
necessary to lay out the entire layout on a single line, so return 1 for
the minimum width in this case.

Approved by Emmanuele Bassi, fixes bug #1555.
2009-04-16 16:34:15 +01:00
Emmanuele Bassi
425fa78a27 Merge branch 'text-actor-layout-height'
* text-actor-layout-height:
  [clutter-text] Fix ellipsizing
  Support pango_layout_set_height() in ClutterText

Conflicts:
	clutter/clutter-text.c
2009-04-15 18:08:14 +01:00
Emmanuele Bassi
d4b47af153 [stage] Warn if perspective's z_far - z_near is 0
Since we have to do (z_far - z_near) and use it in a division we
should check that the user is not passing a value that would
cause a division by zero.
2009-04-15 17:27:04 +01:00
Emmanuele Bassi
709bb69970 Add debug annotations for the layout process
If we need to check that the layout sequence is correct in
terms of order of execution and with respect to caching, then
having a CLUTTER_DEBUG_LAYOUT debug flag would make things
easier.
2009-04-15 17:25:50 +01:00
Emmanuele Bassi
f8256e4b23 [text] Do not ellipsize non-editable layouts
If a ClutterText is set as non-editable then its PangoLayout
will occupy as much width as its contents and ignore the
ellipsization setting.
2009-04-15 17:23:45 +01:00
Neil Roberts
fbd9c59c7c [clutter-text] Fix ellipsizing
Ellipsizing was effectively broken for two reasons. There was a typo
in the code to set the width so it always ended up being some massive
value. If no height should be set on the layout it was being set to
G_MAXINT. Setting a height greater than 0 enables wrapping which so
ellipsizing is not performed. It should be left at the default of -1
instead.
2009-04-15 14:46:45 +01:00
Emmanuele Bassi
5af99660cb [json] Avoid leaks on error code paths
Bug 1476 - JSON Parser memory leak

Static analysis of the code showed that the in-tree copy of
the JsonParser object leaks objects and arrays on parse errors.

Thanks to Gordon Williams <gordon.williams@collabora.co.uk>
2009-04-15 12:18:55 +01:00
Øyvind Kolås
269598a2cf [group] avoid double evaluation of arguments in clutter_group_add
clutter_group_add would evaluate the actor argument twice, which is
bad if this is a function call creating a new actor and not a variable.
2009-04-08 18:19:46 +01:00
Neil Roberts
a9f24351e9 Fix fullscreening when the stage is unrealized and on dual-head
If the stage is unrealized (such as will be the case if the stage was
created with clutter_stage_new) then it would set the size of the
stage display but it was not setting the fullscreen_on_map flag so it
never got the _NET_WM_STATE_FULLSCREEN property. Now it always sets
the flag regardless of whether the window is created yet.

There was also problems with dual-headed displays because in that case
DisplayWidth/Height will return the size of the combined display but
Metacity (and presumably other WMs) will sensibly try fit the window
to only one of the monitors. However we were setting the size hints so
that the minimum size is that of the combined display. Metacity tries
to honour this by setting the minimum size but then it no longer
positions the window at the top left of the screen.

The patch makes it avoid setting the minimum size when the stage is
fullscreen by checking the fullscreen_on_map flag. This also means we
can remove the static was_resizable flag which would presumably have
caused problems for multi-stage.
2009-04-07 15:24:48 +01:00
Neil Roberts
1edc19d1d3 [clutter-text] Add a separate property for the selection color
Adds a new property so that the selection color can be different from
the cursor color. If no selection color is specified it will use the
cursor color as before. If no cursor color is specified either it will
use the text color.
2009-04-06 15:22:31 +01:00
Neil Roberts
3fdacf9762 [cogl-handle] Fix the broken debug macros
The debug macros for tracking reference counting of CoglHandles had
some typos introduced in c3d9f0 which meant it failed to compile when
COGL_DEBUG is 1.
2009-04-06 12:44:15 +01:00
Robert Bragg
e464acff7a [cogl] cogl_is_*(): Don't dereference an invalid handle; just return FALSE
An invalid handle is implicitly not of any type.
2009-04-06 11:35:10 +01:00
Neil Roberts
fff5585b5f [cogl-pango-render] Fix returning to default color after a color attribute
Since the Cogl material branch merge when changing the color of a part
using pango attributes (such as using <span color="red" /> markup)
then it wouldn't return to the default color for the rest of the
layout. pango_renderer_get_color returns NULL if there is no color
override in which case it needs to revert to the color specified as
the argument to cogl_pango_render_layout. The 'color' member of
CoglPangoRenderer has been reinstated to store that default color and
now cogl_pango_render_set_color_for_part is the only place that sets
the material color.
2009-04-06 11:14:43 +01:00
Emmanuele Bassi
a1cc1f57ac [animation] Do not connect to ::completed multiple times
The clutter_actor_animate*() family of functions should only connect
to the Animation::completed signal once, during the construction of
the Animation object attached to the Actor. Otherwise, the completed
signal handler will be run multiple times, and will try to unref()
the Animation for each call -- leading to a segmentation fault.
2009-04-05 20:32:15 +01:00
Emmanuele Bassi
6bf883da6c [animation] Add the ::started signal
The Animation class is missing a ::started signal matching the
::completed one. A ::started signal is useful for debugging,
initial state set up, and checks.
2009-04-03 14:19:20 +01:00
Emmanuele Bassi
1762795990 [group] Fix compilation
A case of rebase FAIL. The sorting of the children was still
done using the now removed group function call instead of the
Container one.
2009-04-03 13:36:30 +01:00
Emmanuele Bassi
df738d0a8c [animation] Do not unref on ::complete by default
Bug 1535 - Complete animation always unrefs ClutterAnimation (even
           after g_object_ref_sink)

Animations created through clutter_animation_new() should not
automagically unref themselves by default on ::complete. We
only want that behaviour for Animations created by the
clutter_actor_animate* family of functions, since those provide
the automagic memory management.
2009-04-03 12:47:21 +01:00
Emmanuele Bassi
bd8d3f6bd8 [group] Remove long deprecated API
ClutterGroup still ships with API deprecated since 0.4. We did
promise to keep it around for a minor release cycle -- not for 3.

Since we plan on shipping 1.0 without the extra baggage of the
deprecated entry points, here's the chance to remove the accumulated
cruft.

All the removed methods and signals have a ClutterContainer
counterpart.
2009-04-03 12:47:21 +01:00
Emmanuele Bassi
9d0ce68c2f [shader] Remove deprecated set_uniform_1f()
Since we're planning to release 1.0 without any of the deprecated
API baggage, we can simply remove the set_uniform_1f() method from
ClutterShader public API and add it to the deprecated header.
2009-04-03 12:47:21 +01:00
Robert Bragg
c3d9f0bed4 [cogl-handle] Optimize how we define cogl handles
The cogl_is_* functions were showing up quite high on profiles due to
iterating through arrays of cogl handles.

This does away with all the handle arrays and implements a simple struct
inheritance scheme. All cogl objects now add a CoglHandleObject _parent;
member to their main structures. The base object includes 2 members a.t.m; a
ref_count, and a klass pointer. The klass in turn gives you a type and
virtual function for freeing objects of that type.

Each handle type has a _cogl_##handle_type##_get_type () function
automatically defined which returns a GQuark of the handle type, so now
implementing the cogl_is_* funcs is just a case of comparing with
obj->klass->type.

Another outcome of the re-work is that cogl_handle_{ref,unref} are also much
more efficient, and no longer need extending for each handle type added to
cogl. The cogl_##handle_type##_{ref,unref} functions are now deprecated and
are no longer used internally to Clutter or Cogl. Potentially we can remove
them completely before 1.0.
2009-04-02 11:58:43 +01:00
Robert Bragg
04ebd6be44 [cogl] handle_automatic_blend_enable(): consider layers with invalid textures
A layer object may be instantiated when setting a combine mode, but before a
texture is associated. (e.g. this is done by the pango renderer) if this is the
case we shouldn't call cogl_texture_get_format() with an invalid cogl handle.

This patch skips over layers without a texture handle when determining if any
textures have an alpha channel.
2009-04-02 11:50:44 +01:00
Robert Bragg
8a1b4f8326 Unifies 90% of the code in {gl,gles}/cogl.c in common/cogl.c
This code keeps on diverging and we get bugs and fixes in one version but
not the other. This should make things a bit more maintainable.
2009-04-01 13:19:35 +01:00
Robert Bragg
50c1fc6291 Removes cogl_blend_func prototype from cogl-internal.h
cogl_blend_func was removed a while ago so this was just a left over from then
2009-03-30 18:02:03 +01:00
Bastian Winkler
34467e5c6a [docs] Fix some inconsistency in Animation
For some examples of clutter_actor_animate the parameters of @mode and
@duration are swapped.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 17:34:07 +01:00
Havoc Pennington
077e3192fd [texture] Queue a relayout when changing :keep-aspect-ratio
Bug 1528 - queue relayout when setting ClutterTexture:keep-aspect-ratio

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 17:32:54 +01:00
Raymond Liu
a362a4a889 [text] Use the base class binding pool
Bug 1518 - [Patch] Widget derivied from ClutterText will crash on
           key_press_event

In clutter_text_key_press() we are using G_OBJECT_TYPE_NAME to find
out the actor's type name. However, if some widget is derived from
ClutterText, when the key press handler is called, G_OBJECT_TYPE_NAME
will return the name of the derived widget.

The default implementation should get the binding pool for the base
class.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 16:57:11 +01:00
Emmanuele Bassi
02ea81ce02 [text] Different selection modes with multiple clicks
ClutterText should offer multiple selection modes depending on the
number of pointer clicks.

Following the GTK+ conventions:

  - double click selects the current word
  - triple click selects the current line
2009-03-30 16:50:26 +01:00
Øyvind Kolås
f6d938a0db [animation] add varargs support for signal::completed
Added support for registering a handler for the completed signal
directly amongst the varargs making it easier to attach code
to be executed when animations complete.
2009-03-30 12:10:41 +01:00
Emmanuele Bassi
a1a8193179 [text] Check text length in ::button-press-event
Bug 1529 - Selection bound out of sync with an empty Text actor

When the user clicks on a Text actor the cursor position and the
selection bound are set using bytes_to_offset(); if the Text is
empty, this means placing them both to 0. Setting the selection
bound to 0 means that when the user inserts a character by typing
it into the Text, the selection will be [0,1]; this will select
the first character, which will then be overwritten when typing
a new character.

The Text actor should, instead, check if there are no contents
and set the cursor position and the selection bound to -1.

The clutter_text_set_selection_bound() method should also validate
the value passed, in case it's bigger than the text lenght, or
smaller than -1.
2009-03-30 07:54:42 +01:00
Emmanuele Bassi
0de0e869a9 [docs] Fix typo in the AnimationMode name 2009-03-27 14:28:08 +00:00
Chris Lord
cc21a4aa5f [ClutterTimeline] Fix clutter_timeline_set_delay
When setting a delay, timeout_add was being used with msecs. timeout_add
takes fps since the fix to bug #1495. Delay now uses g_timeout_add
instead.
2009-03-26 20:29:23 +00:00
Neil Roberts
68ab2c6024 [doc] Fix two small typos in cogl-vertex-buffer
The symbol name for cogl_vertex_buffer_draw_elements was wrong so it
ended up with no documentation. The name for the vertex attribute was
incorrect in cogl_vertex_buffer_add.
2009-03-25 14:53:58 +00:00
Robert Bragg
3d81f0c08e [build] Fixes a cogl-vertex-buffer.c warning when building for GLES
GLES 1 doesn't support GLSL so it never needs to use the generic_index
variable for generic attributes which was flagging a warning.
2009-03-23 16:32:17 +00:00
Robert Bragg
891ed53564 [cogl] Move rect and poly drawing code from cogl-texture.c to cogl-primitives.c
None of this code directly related to implementing CoglTextures, and the
code was needlessly duplicated between the GL and GLES backends. This moves
the cogl_rectangle* and cogl_polygon* code into common/cogl-primitives.c
makes which makes lot of sense since the two copies keep needlessly
diverging introducing or fixing bugs in one but not the other. For instance
I came accross one such bug regarding the enabling of texture units when
unifying the code.
2009-03-23 16:32:07 +00:00
Robert Bragg
b30bb575a1 [cogl_rectangles] A minor doc fix, and missing newline between functions
The gtk-doc had a copy and paste error, saying the float array should be 8
elements per rectangle instead of 4. There was also no newline in the gles
code before the new function.
2009-03-23 12:41:42 +00:00
Johan Bilien
13e5bd9e8b Allow using array of vertices even without textures
It's often nice to be able to draw a batch of vertices, even if these
have no texture coordinates. This add a cogl_rectangles, similar to
cogl_rectangles_with_texture_coords, only without.
2009-03-23 12:41:41 +00:00
Robert Bragg
5a06f1d1d0 Removes a hack in gles/cogl.c that was already fixed in gl/cogl.c
It removes the need to cast a CoglMatrix to a float * for transforming
a vertex manually instead of using cogl_matrix_transform_point.
2009-03-23 12:41:41 +00:00
Emmanuele Bassi
d6937b797e [doc] Update the should_pick_paint() documentation
The should_pick_paint() method of ClutterActor is not clearly
documented.
2009-03-21 20:40:22 +00:00
Neil Roberts
0a48a52ba1 [glx-texture-pixmap] Don't enable the texture target when binding the texture
There's no need to enable the texture target unless it is going to be
used for rendering. Enabling it directly with glEnable calls confuses
Cogl's state caching.

This is a replacement for the patch in bug 1483 which was reverted.
2009-03-19 17:54:17 +00:00
Neil Roberts
c4dcbb6bdb Revert "Use COGL to establish GL state for ClutterGLXTexturePixmap"
This reverts commit f9d996a460.

The change from calling glBindTexture to using the material API with
cogl_material_flush_gl_state does not always work because it doesn't
necessarily leave the active texture unit as GL_TEXTURE0. For example,
if the previously rendered texture was multi-layered then the last
thing cogl_material_flush_gl_state will do is select GL_TEXTURE1 just
to disable it.
2009-03-19 17:48:15 +00:00
Øyvind Kolås
e94e5ad65b [actor] use an epsilon whens sanity checking sizes
Clutter was complaining about netural width smaller than minimum widths
(differences around 0.0005) by using an epsilon value of 1e-4 for these
floating point comparisons, these warnings have now been silenced.
2009-03-19 14:46:23 +00:00
Emmanuele Bassi
7d8da0e830 [docs] Remove unused arguments
The documentation for some X11TexturePixmap method does not reflect
the actual API.
2009-03-18 17:07:50 +00:00
Emmanuele Bassi
ccca24ab76 Remove usage of the grave accent as quotation mark
See:

  http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This should make Thomas happy.
2009-03-17 14:13:31 +00:00
Robert Bragg
39e2b43b22 [cogl] Apply the fix from 2c1c836417 (Flush matrix before clip planes) to GLES
glClipPlane() is affected by modelview matrix so we need to flush before
calling it.
2009-03-17 11:37:29 +00:00
Robert Bragg
bb93a98762 [clutter-color] Use a different hls->rgb algorithm + use floating point
Using test-cogl-vertex-buffer as a test case which is CPU bound due to
hls -> rgb conversions this alternative algorithm looked to be ~10%
faster when tested on an X61s Lenovo.
2009-03-17 11:37:29 +00:00
Emmanuele Bassi
567a96c96a [docs] More information on animation queueing
Queuing an animation on an actor cannot be done from within the
::completed signal handler, because we guarantee that the Animation
instance is valid and attached to the actor it animates for the
whole duration of the signal emission chain.

In order to queue animations you have to install an idle handler
on the main loop, and call clutter_actor_animate() inside it.

The documentation should be more clear about this caveat in the
memory management of ClutterAnimations created by the animate()
family of functions.
2009-03-16 18:20:58 +00:00
Emmanuele Bassi
e8785fef07 [docs] Fix naming of the interval parameter
The interval parameter is now expressed in frames per second and not
in milliseconds.
2009-03-16 16:56:51 +00:00
Robert Bragg
ca3bfe2cea [cogl] Don't endlessly print the same warning regarding layer fallbacks
There are various constraints for when we can support multi-texturing and
when they can't be met we try and print a clear warning explaining why the
operation isn't supported, but we shouldn't endlessly repeat the warning for
every primitive of every frame. This patch fixes that.
2009-03-16 16:19:51 +00:00
Robert Bragg
71d65b629b [cogl-vertex-buffer] fix cogl_vertex_buffer_draw_elements prototype
This function was renamed a while ago in the .c file from
cogl_vertex_buffer_draw_range_elements  but the corresponding .h and
doc/reference/cogl changes weren't made.
2009-03-16 16:19:39 +00:00
Robert Bragg
14e6323554 [cogl-vertex-buffer] Allow querying back the number of vertices a buffer represents
This may be convenient e.g. at draw time if you are simply drawing all vertices
2009-03-16 16:17:02 +00:00
Robert Bragg
075ae9c4a7 [cogl-vertex-buffer] Add a flush of attribute changes in the *_draw() functions
For convenience it is now valid to avoid a seperate call to
cogl_vertex_buffer_submit() and assume that the _draw() calls will do this
for you (though of course if you do this you still need to ensure the
attribute pointers remain valid until your draw call.)
2009-03-16 16:14:17 +00:00
Neil Roberts
a93a93d007 Count timeline frames using the FPS instead of an integer interval
Bug 1495 - Timelines run 4% short

Previously the timelines were timed by calculating the interval
between each frame stored as an integer number of milliseconds so some
precision is lost. For example, requesting 60 frames per second gets
converted to 16 ms per frame which is actually 62.5 frames per
second. This makes the timeline shorter by 4%.

This patch merges the common code for timing from the timeout pools
and frame sources into an internal clutter-timeout-interval file. This
stores the interval directly as the FPS and counts the number of
frames that have been reached instead of the elapsed time.
2009-03-16 15:40:18 +00:00
Havoc Pennington
2c1c836417 [cogl] Flush matrix before clip planes
glClipPlane() is affected by modelview matrix so we need to flush
before calling it.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 15:10:33 +00:00
Emmanuele Bassi
9229fb6114 [docs] Bring down the undocumented symbols to 2%
The usual pre-release documentation blitzing. Most of the remaining
symbols are either COGL or X11 specific, or dummy interface typedefs.
2009-03-16 15:00:55 +00:00
Emmanuele Bassi
216373047b [animation] Enhance consistency of the Animation API
The Animation API should follow this pattern:

  - functions with an Interval as part of the arguments should have
    "interval" inside their name, e.g.:

      clutter_animation_bind_interval
      clutter_animation_update_interval

  - functions dealing with property names should have "property"
    inside their name, e.g.:

      clutter_animation_has_property
      clutter_animation_unbind_property

    - unless -

  - functions dealing with a property and its value should not
    have any modifier, e.g.:

      clutter_animation_bind

The change from update_property() to update_interval() frees up
clutter_animation_update(), to be added at a later date.
2009-03-16 14:16:18 +00:00
Emmanuele Bassi
0942fac573 [docs] Add description of queue_redraw 2009-03-16 14:01:43 +00:00
Havoc Pennington
961aac3fb3 [actor] Add ::queue-redraw signal
Bug 1454 - move queue_redraw virtualization to ClutterActor

The ClutterActor::queue-redraw signal allows parent containers to
track whether their children need a redraw.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Havoc Pennington
5706105123 [actor] Add :clip-to-allocation property
A common use of setting clip is to keep an actor inside its allocation;
right now to do this you have to set up a callback on notify::allocation.

There's no overhead added by sticking another bit in ClutterActor
clip-to-allocation that will clip painting to the allocation if set.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Colin Walters
0cb0a841cc [animation] Enhance the bind API
Bug 1419 - Add clutter_animation_bind, rename clutter_animation_bind_interval

This is a different approach from the clutter_actor_animatev
vector variant.  The single call should be even easier on
automatic bindings, since calls can be chained like:

  new Clutter.Animation({object: myactor}).bind("x", 42).bind("y", 43);

Note clutter_animation_bind_property which took a ClutterInterval
is renamed to clutter_animation_bind_interval for clarity, and to
discourage use since there are friendlier APIs about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
156589fe3f [animation] Add Animation getter
If we are animating an actor using the clutter_actor_animate*() family
of functions we might want to expose a getter for the Animation instance
we are using, to avoid excessing bookkeeping.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
44d0733665 [animation] Add an emitter for ::completed
The ::completed signal requires an emitter in case we want to stop
the animation and safely dispose it inside application code without
breaking invariants.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
a5c88e62f2 [docs] Clarify Animation memory management
The memory management of the ClutterAnimation instances should be
heavily documented, given its "automagical" nature, so that other
people might understand it and avoid breaking it in the future.
2009-03-16 12:13:55 +00:00
Øyvind Kolås
0674fded7f Merge branch 'async-texture-thread-pool' 2009-03-16 00:40:27 +00:00
Øyvind Kolås
56568db3b0 [clutter-texture] fixed gtk-doc formatting, and init threads in test.
Fixed markup to actually work with gtk-doc, also do a g_thread_init
in the test.
2009-03-16 00:40:02 +00:00
Neil Roberts
7f2ef2f1e0 [cogl-path] Minor fix to gtk-doc
Fix the parameters in cogl_path_curve_to and cogl_path_rel_curve_to to
match the actual names otherwise they won't appear correctly in the
docs.
2009-03-13 15:43:19 +00:00
Emmanuele Bassi
89060a9bb3 [cogl] Avoid shadowing math.h symbols
As usual, y1 and y2 end up shadowing symbols exported by math.h.
2009-03-13 15:28:20 +00:00
Owen W. Taylor
e1742af368 Avoid drawing twice if relayout queues a draw
It's reasonably normal for a relayout of the stage to cause the stage
to be queued for drawing; for this reason we should do the relayout before
we clear stage->update_idle. (But want to clear update_idle() before actually
doing the redraw to handle the corner case where the draw queues another
redraw.)
2009-03-13 15:20:50 +00:00
Emmanuele Bassi
72f9646804 Do not cause more size requisitions than necessary
Bug 1499 - clutter_actor_notify_if_geometry_changed causes sync
           layout cycles

Whenever clutter_actor_set_{width,height,x,y,size...} is used, extra
synchronous size requests are triggered in
clutter_actor_notify_if_geometry_changed.

If the get_preferred_width() and get_preferred_height() implementations
are particularly costly (e.g. ClutterText) this will result in a performance
impact.

To avoid excessive allocation or requisition cycles we use the
cached values and flags. If we don't have an allocation, we assume
that we need to notify all the properties; if we don't have a size
requisition we notify only width and height; finally, if we do have
a valid allocation we notify only on the changed values.
2009-03-13 15:20:49 +00:00
Emmanuele Bassi
786161c75f [deprecated] Add Effect deprecation
The ClutterEffect API has been deprecated during 0.9, so it should be
added to the deprecation macros.
2009-03-13 14:29:27 +00:00
Emmanuele Bassi
ed2fe41b32 Add more deprecation notices
Most of the deprecated API does not have an entry inside
clutter-deprecated.h, thus making porting a tad more difficult.
2009-03-13 14:29:27 +00:00
Neil Roberts
cde05288b7 Change cogl_path_rectangle and cogl_path_round_rectangle to take x1,y1,x2,y2
This matches the changes to cogl_rectangle to improve consistency.
2009-03-13 12:20:26 +00:00
Robert Bragg
ca2844013e Maintain the Cogl assumption that the modelview matrix is normally current
_cogl_add_path_to_stencil_buffer and _cogl_add_stencil_clip were leaving
the projection matrix current when calling cogl_rectangle which was
upsetting _cogl_current_matrix_state_flush.
2009-03-12 18:55:41 +00:00
Robert Bragg
0580dbe015 Finish GLES{1,2} support for client side matrix stacks
Adds glFrustum wrappers (GLES only accepts floats not doubles, and GLES2
needs to use our internal cogl_wrap_glFrustumf)

Adds GL_TEXTURE_MATRIX getter code in cogl_wrap_glGetFloatv

Adds a GL_TEXTURE_MATRIX define for GLES2
2009-03-12 18:55:41 +00:00
Robert Bragg
3a9b18ef51 Use Cogl enum when making modelview-matrix current in cogl_{rotate,transform,etc}
My previous patch incorrectly used the GL enum with the _cogl_set_current_matrix
API.
2009-03-12 18:55:40 +00:00
Robert Bragg
2f34d14cb4 Explicitly make the modelview-matrix current in cogl_{rotate,transform,etc}
Its not intended that users should use these with any other matrix mode, and
internally we now have the _cogl_current_matrix API if we need to play with
other modes.
2009-03-12 18:55:40 +00:00
Robert Bragg
0d88ecb459 Avoid casting CoglMatrix to a GLfloat * when calling glGetFloatv
If we later add internal flags to CoglMatrix then this code wouldn't
initialize those flags. The ways it's now done adds a redundant copy, but
if that turns out to be something worth optimizing we can look again at
using a cast but adding another way for initializing internal flags.
2009-03-12 18:55:40 +00:00
Robert Bragg
61b867442b 80 char fix 2009-03-12 18:55:40 +00:00
Robert Bragg
20a2f76e1f Removes need for casting (const float *) to (GLfloat *) in _cogl_set_clip_planes
This removes cogl.c:apply_matrix(), and makes cogl.c:project_vertex() use
cogl_matrix_transform_point instead.
2009-03-12 18:53:22 +00:00
Havoc Pennington
08932584b5 Virtualize GL matrix operations and use a client-side matrix when GL is indirect
This is useful because sometimes we need to get the current matrix, which
is too expensive when indirect rendering.

In addition, this virtualization makes it easier to clean up the API in
the future.
2009-03-12 18:32:45 +00:00
Øyvind Kolås
5895048f65 [clutter-texture] updated documentation.
Rewrote documentation, with the smallest amount of documentation for
load-data-async which is considered a special case of load-async.
2009-03-12 11:48:44 +00:00
Øyvind Kolås
25d54a650d Merge commit 'origin/async-texture-thread-pool' into async-size 2009-03-12 11:18:11 +00:00
Øyvind Kolås
93d8f62f6b [clutter-texture] remove load-size-async property
Only have load-data-async and load-async properties, both are construct
only and the latter adds the former load-size-async behavior on top of
load-data-async.
2009-03-12 10:38:39 +00:00
Øyvind Kolås
d3b68298ac [clutter-texture] add option to not block on size for loaded images
Added a construct time property to indicate that we do not want
to block on loading images.
2009-03-12 10:30:09 +00:00
Øyvind Kolås
5d3d971389 [tests] Added test-texture-async 2009-03-12 10:17:08 +00:00
Geoff Gustafson
2c95b378a5 [animation] Broken fixed:: properties
This commit yesterday:

89e3e3a4cc
[animation] Add vector variants for ::animate()

broke the "fixed::" attribute on properties in clutter_actor_animate(),
because the fixed:: part is still on the string when it checks to see if
it's a valid property the class knows about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-11 22:09:05 +00:00
Owen W. Taylor
d88bc30b87 Allow NULL for clutter_text_set_text()
As a convenience, if NULL is passed for the text argument of
clutter_text_set_text() (and for consistency,
clutter_text_set_markup()), treat that the same as "".
2009-03-11 18:20:42 +00:00
Gordon Williams
0d874312d3 [group] Output the group name when debugging paint
Bug 1480 - Clutter groups don't output their name when
           CLUTTER_DEBUG=paint

This is a really useful thing to do debugging-wise - as you can see
istantly when (and if) clutter objects are being drawn - as often
there's quite a hierarchy of objects in groups.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-11 18:16:21 +00:00
Owen W. Taylor
02b2b664d8 Add (out) annotations for ClutterActor
Add missing (out) annotations to the doc comments for ClutterActor methods
with multiple return values.

Fix the definition of clutter_actor_get_allocation_vertices() to be
consistent with the declaration and have verts[4] rather than verts[].x

http://bugzilla.openedhand.com/show_bug.cgi?id=1481
2009-03-11 18:14:49 +00:00
Raymond Liu
75e5b805ab [text] Insertion of multi-byte characters broken
Bug 1501 - clutter_text_insert_text not working right with non-onebyte
           character

In clutter_text_insert_text(), the position is expressed in characters, not
in bytes.

Actually, it turns out to be working on bytes, so when there are already
multi-byte character in the text buffer, insert text at the position after
the multi-byte character will not work right.

Also, the position is not updated after the insert work is done.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-11 18:00:21 +00:00
Raymond Liu
039e282a40 [text] Crash when multi-byte utf8 text exceeds max_length
Bug 1500 - [Patch] clutter_text crash with non one-byte utf8 text exceed
           max_length

In clutter_text_set_text_internal(), when text length in character is greater
than max_length, and there are multi-byte character in it, then the new text
string buffer is not malloc()'ed with right length. This will cause the app to
crash with segmention fault.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-11 17:50:51 +00:00
Emmanuele Bassi
7a5cea44dd [docs] Calling g_object_ref() will not dispose an object
The right way to dispose a PangoContext is to call g_object_unref(),
not g_object_ref().
2009-03-11 13:58:31 +00:00
Emmanuele Bassi
e430903acd [color] Fixed HLS to RGB conversion
The fixed-point values are converted to integers, which obviously
messes up the conversion. Instead, they should be converted to
floating point values before normalizing to bytes for the assignment
to ClutterColor components.
2009-03-11 13:58:31 +00:00
Neil Roberts
5e9894fbac Remove use of $(builddir)
$(builddir) isn't always defined in earlier versions of Automake
(although I can't track down exactly which version it appeared
in). According to the autoconf docs it is "rigorously equal to `.'" so
we might as well not use it.
2009-03-10 19:24:17 +00:00
Emmanuele Bassi
a41361269f [cogl] Initialize all members of CoglContext
Some members of CoglContext still escape initialization.
2009-03-10 18:05:08 +00:00
Emmanuele Bassi
d3245c6624 [cogl] Initialize boolean flag in CoglContext
The private CoglContext is created using g_malloc() and not
zeroed; this means we have to initialize the values we are
going to check, to avoid hitting garbage.

Thanks to Tommi Komulainen.
2009-03-10 17:53:51 +00:00
Neil Roberts
57c3e84289 Fix out of tree builds
Commit a383929 added the $(srcdir) prefix to all of the source files
but some files are generated by the configure script and other make
rules so they actually live in $(builddir). Out-of-tree builds
therefore broke.
2009-03-10 14:40:33 +00:00
Øyvind Kolås
e744066e7d Change the default size of thread pool from 3 to 1
Concurrently decoding three image files can stall animations even on a
dual core system, reducing to 1 concurrent image decoding thread.
2009-03-10 13:00:57 +00:00
Emmanuele Bassi
89e3e3a4cc [animation] Add vector variants for ::animate()
Bug 1438 - Implicit Animation API could use animatev variants

The clutter_actor_animate* family of functions use va_lists to
handle the property/value pairs for the final state of the
animation.

Language bindings have problems with variadic arguments functions,
and usually prefer vector-based API which allow a greater level
of control and conversion from native data types.

For each variadic arguments function in the clutter_actor_animate*
family there should be a vector-based version that takes:

  - the number of property/value pairs
  - a constant array of constant strings
  - an array of GValues

Most of the internal implementation can be refactored from the
current one, thus both the var_args and the vector entry points
share a common implementation of the code; then, both versions
of the API are just loops over a list of arguments.

Based on a patch by: Robert Carr <carrr@rpi.edu>
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
c46106f6dd [docs] Update API reference
The API reference was still listing some symbols that have been
removed.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
f1b237b2ec [docs] Remove ClutterFixed from the documentation
Now that ClutterFixed has finally gone the way of the Dodo, we
can safely remove it from the API reference as well.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
bb83bf282d [cogl] Fix hardcoded paths in the pc file
The commit 24ce193836 fixed the Clutter pkg-config file. Since
COGL now ships its own, we need to fix that as well.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
9b83a6f291 [fixed] Remove ClutterFixed API
Since the switch from fixed point to floating point, and the introduction
of CoglFixed, ClutterFixed has been typedef'd into a float. This makes
ClutterFixed the worst fixed point API ever.

Now that Clutter has been migrated to CoglFixed and gfloat whenever needed,
ClutterFixed can be safely removed.

The only thing that Clutter should still provide is ClutterParamSpecFixed,
for installing fixed point properties into GObject classes.

The ClutterFixed symbols have been entirely removed from the API.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
d1f3190f5b [units] Add more conversion functions
A GValue containing a ClutterUnit should be transformable into a
GValue holding an integer, a floating point value or a fixed point
value.

This means adding more transformation functions when registering
the ClutterUnit GType.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
f82c9e7dba [text] Convert units to the right type
The COGL API expects a floating point value, so Units should be
converted to floats, not to ClutterFixed.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
97d0a4845a [texture] Fix ClutterFixed usage
Do not use ClutterFixed and its macros inside the Texture.
2009-03-10 12:38:04 +00:00
Emmanuele Bassi
52811b240f [stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:

  - the floating point version, using values

  - the fixed point version, using structures

The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.

Thus:

  clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
  clutter_stage_get_fog (ClutterStage*, ClutterFog*)

  clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
  clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)

Which supercedes the fixed point and floating point variants.

More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.

ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.

Finally, there is no ClutterStage:fog so it should be added.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
628e54fa9f [interval] Update fixed-point handling
Do not use ClutterFixed when dealing with fixed point values. Use
CoglFixed instead.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
9911033505 [cogl-fixed] Implement the CoglFixed fundamental GType
The type machinery for CoglFixed should be implemented by COGL
itself, now that COGL exports the GType of its types.

This allows moving most of what ClutterFixed did directly to
CoglFixed where it belongs.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
720341b301 Move ClutterTimeline to CoglFixed
The ClutterTimeline::get_progressx() method should return a
CoglFixed, now that ClutterFixed is being deprecated.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
849e916d6f Move ClutterBehaviourRotate to CoglFixed
Remove the wrong usage of ClutterFixed and use CoglFixed instead
in the API and the implementation.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
764dc3bac4 Move ClutterBehaviourEllipse to CoglFixed
Remove the wrong usage of ClutterFixed, and use CoglFixed instead
in the API and the implementation.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
045ad21921 Move BehaviourScale to CoglFixed
ClutterFixed as a type is going away, superceded by CoglFixed. The
fixed point entry points in the API should be ported to the
CoglFixed type so that they are useful again.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
7bf385a067 [cogl-fixed] Add a double-to-fixed conversion macro
Since the conversion of a floating point value to a fixed point
value is already done in double precision we can safely expose
a macro that converts a double precision floating point value to
a CoglFixed one.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
4e98fc5e79 [docs] Note that grabs are evil
Grabs are an entirely evil way to override the whole event delivery
machinery that Clutter has in place.

A pointer grab can be effectively replaced by a much more reliable
::captured-event signal handler, for instance.

Sometimes, grabs are a necessary evil -- and that is why Clutter
exposes them in the API; that should not fool anyone into thinking
that they should be used unless strictly necessary.
2009-03-10 12:38:03 +00:00
Emmanuele Bassi
c0adf4582c [docs] Clarify clutter_actor_animate() behaviour
When calling clutter_actor_animate() on an actor that is being
currently animated the default behaviour is to update the duration
of the animation; the easing mode; update all the common properties;
and finally add the new properties.

This:

  clutter_actor_animate (actor, 500, CLUTTER_LINEAR,
                         "width", 100,
                         "height", 100,
                         NULL);

  clutter_actor_animate (actor, 250, CLUTTER_EASE_IN_CUBIC,
                         "x", 100,
                         "y", 100,
                         "height", 200,
                         NULL);

Is logically equivalent to:

  clutter_actor_animate (actor, 250, CLUTTER_EASE_IN_CUBIC,
                         "x", 100,
                         "y", 100,
                         "width", 100,
                         "height", 200,
                         NULL);

The documentation of the function should be slightly more verbose
in describing the default behaviour.
2009-03-10 12:38:02 +00:00
Emmanuele Bassi
a3839296c4 [build] Various fixes for distcheck
The generation of the GObject introspection data has broken
the distcheck phase.

The location of the header and source files should always be
depending on the $(top_srcdir) and $(srcdir) variables,
respectively; the special handling of the COGL API inside the
GIR generation should also take those two variables into
account.
2009-03-10 12:38:02 +00:00
Emmanuele Bassi
4a3a3e1cf3 Add pkg-config file for COGL
COGL should ship its own pkg-config file, obviously still pointing
to Clutter's compiler flags and linking options, for COGL-specific
variables that might be queried at configure time.

For instance, it's easier (and less verbose) to do:

  PKG_CHECK_EXISTS([cogl-gl-1.0],
                   [has_gl_backend=yes],
                   [has_gl_backend=no])

Than doing:

  AC_MSG_CHECKING([for GL support in COGL])
  cogl_backend=`$PKG_CONFIG --variable=cogl clutter-0.9`
  if test x$cogl_backend = xgl; then
    has_gl_backend=yes
    AC_MSG_RESULT([found])
  else
    has_gl_backend=no
    AC_MSG_RESULT([not found])
  fi
2009-03-10 12:38:02 +00:00
Emmanuele Bassi
b030756dca [shader] Unify code paths
ClutterShader contains a lot of duplication, as the vertex and fragment
shader code paths are mostly the same.

The code should be simplified by adding new internal functions that can
be called with a value from the already present ClutterShaderType
enumeration.

In the future it'll also be possible to deprecate the current split API
and expose the generic accessors instead.
2009-03-10 12:38:02 +00:00
Emmanuele Bassi
7d674db9d2 Clean up of the ClutterColor API
The ClutterColor API has some inconsistencies:

  - the string deserialization function does not match the rest of
    the conversion function naming policy; the naming should be:

        clutter_color_parse()   ->      clutter_color_from_string()

    and the first parameter should be the ClutterColor that will
    be set from the string, not the string itself (a GDK-ism).

  - the fixed point API should not be exposed, especially in the
    form of ClutterFixed values

  - the non-fixed point HLS conversion functions do not make any
    sense. The values returned should be:

      hue        := range [ 0, 360 ]
      luminance  := range [ 0,   1 ]
      saturation := range [ 0,   1 ]

    like the current fixed point API does. Returning a value in
    the [ 0, 255 ] range is completely useless

  - the clutter_color_equal() should be converted for its use inside
    a GHashTable; a clutter_color_hash() should be added as well

  - the second parameter of the clutter_color_shade() function should
    be the shading factor, not the result (another GDK-ism). this way
    the function call can be translated from this:

      color.shade(out result, factor)

    to the more natural:

      color.shade(factor, out result)

This somewhat large commit fixes all these issues and updates the
internal users of the API.
2009-03-10 12:38:02 +00:00
Emmanuele Bassi
8a1eca7287 [cogl] Add a PANGO debug flag for CoglPango use
The CoglPango code falls under the COGL "jurisdiction"; this means
that it cannot include Clutter headers unless strictly necessary.

The CoglPangoRenderer code was using the CLUTTER_NOTE() macro. Now
that COGL has it's own COGL_NOTE() similar macro, CoglPango should
use that and avoid including clutter-debug.h (which pulls in
clutter-private.h which in turn pulls in clutter-actor.h).

A new flag, COGL_DEBUG_PANGO, has been added to the COGL debug
flags.
2009-03-10 12:38:02 +00:00
Colin Walters
3a4538e4f2 Typo in clutter-win32.pc.in introduced by commit 24ce19383 2009-03-10 12:16:53 +00:00
Neil Roberts
ee6145c795 Set the mapped flag on the stage in the SDL and eglnative backends
Bug 1493 - GL ES does not work since Jan 9 in PowerVR SGX 535, Intel

The mapped flag needs to be set on the stage otherwise
clutter_actor_queue_redraw will never queue a redraw and never draw
anything.

In these two backends there is not really a way to hide the stage so
they both set the mapped flag immediatly when clutter_actor_show is
called.
2009-03-09 18:53:31 +00:00
Owen W. Taylor
f9d996a460 Use COGL to establish GL state for ClutterGLXTexturePixmap
Using glEnable() directly confuses COGL and can result in problems
like subsequent pick operations not working correctly. Get the
material for the ClutterTexture and call cogl_material_flush_gl_state()
instead.

http://bugzilla.openedhand.com/show_bug.cgi?id=1483
2009-03-09 15:42:23 +00:00
Neil Roberts
65c5188c7e [eglnative] Add -I flags for the clutter dir in the src and build dirs
These are required to include the Cogl header files.
2009-03-09 12:34:18 +00:00
Neil Roberts
67523ddc6e Fix warning in clutter-backend-sdl
Removed direct use of SDL_GetError as a format string for g_set_error
to fix a compiler warning.
2009-03-09 12:34:18 +00:00
Colin Walters
24ce193836 Bug 1491 - Fix hardcoded lib path in .pc files
We should instead use @libdir@ from configure to be correct
on multilib systems.
2009-03-09 10:45:09 +00:00
Øyvind Kolås
9df3fb993c Add a warning for recursive emit_event
When event delivery is invoked by synthetic events through
clutter_do_event from inside an event handler clutter was silently
ignoring it, this warning will hopefully help resolving some issues.
2009-02-27 17:59:16 +00:00
Robert Bragg
af0726480c [cogl-matrix] Documents that CoglMatrix members should be considered read only
In the future if we want to annotate matrices with internal flags, and add
caching of the inverse matrix then we need to ensure that all matrix
modifications are done by cogl_matrix API so we'd know when to dirty the
cache or update the flags.

This just adds documentation to that effect, and assuming the most likley
case where someone would try and directly write to matrix members would
probably be to load a constant matrix other than the identity matrix; I
renamed cogl_matrix_init_from_gl_matrix to cogl_matrix_init_from_array to
make it seem more general purpose.
2009-02-26 16:42:32 +00:00
Robert Bragg
0a218a64e2 [cogl-matrix] Adds padding to CoglMatrix
This adds enough padding to allow us to potentially add a cache of the inverse
matrix in the future and private flags to annotate matrices.
2009-02-26 16:42:32 +00:00
Emmanuele Bassi
b39223d8cb [backend] Constify font options
The font options accessors in ClutterBackend only deal with const
cairo_font_options_t values, since:

  - set_font_options() will copy the font options
  - get_font_options() will return a pointer to the internal
    font options

Not using const in these cases makes the API confusing and might lead
to erroneous calls to cairo_font_options_destroy().
2009-02-26 15:32:48 +00:00
Emmanuele Bassi
8354295986 Intern the ClutterScriptable type name
Like we do for other types, use the I_() macro to intern the
type name during the GType registration for ClutterScriptable.
2009-02-26 14:57:58 +00:00
Bastian Winkler
28a3cbf38e Remove redundant declaration in clutter-text.h
clutter-text.h declares clutter_text_get_layout twice.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-26 12:49:50 +00:00
Emmanuele Bassi
0fc9452b03 [build] Do not shave typelib generation
Bug 1478 - typelib creation shaved out of existence

Add a 'GEN' output rule for the typelib files created when
introspection is enabled.
2009-02-26 12:46:36 +00:00
Owen W. Taylor
402e2e0d82 Fix x/y confusion for GL_TEXTURE_RECTANGLE_ARB
When "denormalizing" for texture rectangles, multiple X coordinates
by the X size and Y coordinates by the Y size.

http://bugzilla.openedhand.com/show_bug.cgi?id=1479
2009-02-26 11:27:21 +00:00
Neil Roberts
ce83007c1d [cogl-pango-glyph-cache] Fix compiler warning on 64-bit
gcc warns about casting a pointer to a guint because it is a different
size on 64-bit machines. However the pointer is only used as a hash so
it doesn't matter if we lose the most significant bits. The patch
makes it use GPOINTER_TO_UINT instead which first casts it to a gulong
and avoids the warning.
2009-02-26 10:56:42 +00:00
Neil Roberts
1626d6132e [clutter-texture] Use a GThreadPool for loading async textures
Instead of creating a separate thread for each texture load, the loads
are now queued in a thread pool which will use at most 3 textures at a
time. This avoids the potentially large overhead of creating and
destroying a thread for every image while still avoiding throttling
the CPU if a large number of textures are loaded at the same time.

If the load is cancelled the old code needed to join the thread which
effectively meant it had to wait for the load to finish. With this
model the threads are owned by the thread pool so there is no need to
wait for them to finish. Instead, each thread is given its own thread
data which we can use to mark the thread as aborted. Once the load is
finished the thread will check whether it is aborted before setting
the texture data. That way the ClutterTexture can just disown threads
that it needs to cancel.
2009-02-25 17:52:14 +00:00
Emmanuele Bassi
bff6ce414a [media] Add sub-second resolution for the duration
The duration in ClutterMedia is currently expressed in integer multiples
of a second. This does not offer enough granularity for media playback
that has fractionary durations -- 2.3 seconds; 1 minute, 23.4 seconds;
1 hour, 23 minutes, 4.5 seconds; etc.

The duration value should be expressed in seconds with a sub-second
granularity; for this reason, a double should be used insted of an
unsigned integer.

The semantics haven't changed: the :duration property still exposes
seconds.
2009-02-24 16:22:02 +00:00
Bastian Winkler
dd3c760cc5 [media] Fix the interface cast macro
Bug 1474 - ClutterMedia interface

The GET_INTERFACE() macro is still using the old type name of
the ClutterMedia interface structure in the cast.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-24 16:00:18 +00:00
Jonathan Matthew
eaf202c886 Declare the EnumValues for PixelFormat static
Bug 1473 - CoglPixelFormat enum data must be declared static

When registering an enumeration GType, the GEnumValue or GFlagsValue
arrays must be declared static; otherwise, you get a segmentation
fault when calling the function again.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-24 09:29:08 +00:00
Emmanuele Bassi
3409a941a4 Use a dynamic array for the actors when delivering events
Instead of using a fixed size array for storing the scenegraph sub-node
during event delivery we should use a GPtrArray. The benefits are:

  - a smaller allocation
  - no undocumented yet binding constraint on the scenegraph size
2009-02-24 09:29:08 +00:00
Emmanuele Bassi
64db7896db Remove stray fixed point macro usage
The CoglPango renderer is using a CLUTTER_FIXED macro, but the
whole code has been Clutter-free for a while, now.
2009-02-24 09:29:07 +00:00
Emmanuele Bassi
7d181636ed Make fuzzy picking a command line switch
The CLUTTER_FUZZY_PICK environment variable is the last one used
by Clutter without a corresponding command line switch.
2009-02-23 13:17:06 +00:00
Emmanuele Bassi
42fa1e035b Make disable text mipmapping a command line switch
The environment variable to disable mipmapping should also be
a command line switch, and be handled like the rest of Clutter's
environment variables/command line switches.
2009-02-23 13:08:59 +00:00
Emmanuele Bassi
a1f0b25d14 [actor] Remove usage of ClutterFixed
The ClutterFixed type and symbols are now equivalent to the native
float type. In order to remove ambiguity and clean up the code, any
usage of ClutterFixed and relative macros has been removed.
2009-02-23 13:00:52 +00:00
Emmanuele Bassi
605dfb8fd0 Add runtime debug messages for COGL
Clutter is able to show debug messages written using the CLUTTER_NOTE()
macro at runtime, either by using an environment variable:

  CLUTTER_DEBUG=...

or by using a command line switch:

  --clutter-debug=...
  --clutter-no-debug=...

Both are parsed during the initialization process by using the
GOption API.

COGL would benefit from having the same support.

In order to do this, we need a cogl_get_option_group() function in
COGL that sets up a GOptionGroup for COGL and adds a pre-parse hook
that will check the COGL_DEBUG environment variable. The OptionGroup
will also install two command line switches:

  --cogl-debug
  --cogl-no-debug

With the same semantics of the Clutter ones.

During Clutter initialization, the COGL option group will be attached
to the GOptionContext used to parse the command line options passed
to a Clutter application.

Every debug message written using:

  COGL_NOTE (SECTION, "message format", arguments);

Will then be printed only if SECTION was enabled at runtime.

This whole machinery, like the equivalent one in Clutter, depends on
a compile time switch, COGL_ENABLE_DEBUG, which is enabled at the same
time as CLUTTER_ENABLE_DEBUG. Having two different symbols allows
greater granularity.
2009-02-23 13:00:52 +00:00
Neil Roberts
a4c8e78477 Add an environment variable to disable mipmapped text
Mipmapped text is enabled by default in Clutter but it can cause
problems on some drivers so it is convenient to have an environment
variable to disable it for all apps.
2009-02-23 11:36:03 +00:00
Robert Bragg
8d04fbb05e [Cogl] Remove a debugging assert that was triggering on false positives
An assert to verify there was no error when generating a buffer object
for the vertex buffer API was being hit when running the GLES1 conformance
tests.
2009-02-23 10:49:35 +00:00
Robert Bragg
5e956a88b8 [cogl-material] Always glBindTexture when flushing material state
Bug #1457 - Creating a new texture messes up the cogl material state
            cache; reported by Neil Roberts

We still don't have caching of bound texture state so we always have to
re-bind the texture when flushing the GL state of any material layers.
2009-02-23 10:49:35 +00:00
Robert Bragg
d13b9de2e2 [Cogl] Fixes automatic handling of the GL blend enable state.
Bug #1460 - Handling of flags in cogl_material_set_color

Cogl automatically enables/disables blending based on whether the source color
has an alhpa < 1.0, or if any textures with an alpha component are in use, but
it wasn't doing it quite right.

At the same time I removed some of the dirty flags which on second thought
are nothing more than micro-optimsations that only helped clutter the code.

thanks to Owen Taylor for reporting the bug
2009-02-23 10:49:35 +00:00
Robert Bragg
34e53736ed [Cogl] the cogl_get_*_matrix functions now work with CoglMatrix types
Since the CoglMatrix type was added for supporting texture matrices recently
it made sense to be consistent accross the Cogl API and use the Cogl type
over the GL style GLfloat m[16] arrays.
2009-02-23 10:49:35 +00:00
Emmanuele Bassi
82f83ffbfb [build] Move all the compiler flags to AM_CFLAGS
The INCLUDES directive should only contain pre-processor flags, since
we're passing it also to the introspection scanner.

Using AM_CFLAGS for compiler flags, like debug flags and maintainer
flags, is more indicated.
2009-02-21 13:44:14 +00:00
Emmanuele Bassi
f4df307ddd [backend] Update the viewport when updating the GL context
Bug 1442 - multistage, same-window resize events invalidate stage

When ensuring that the GL context is attached to the correct
ClutterStage we need to set the SYNC_MATRICES flag on the stage
itself. This is needed in case the size of the new stage does
not match the size of the old -- thus requiring a call to
glViewport() when the paint cycle starts.
2009-02-20 16:40:57 +00:00
Neil Roberts
fa996734cf [cogl-gles2-wrapper] Actually call glActiveTexture
cogl_wrap_glActiveTexture needs to call the GL version of
glActiveTexture otherwise the subsequent calls to glBindTexture will
all be using texture unit 0. This fixes test-cogl-multitexture.
2009-02-20 16:37:20 +00:00
Neil Roberts
b0df99fbad [cogl-gles2-wrapper] Convert texture unit settings to be a static sized array
Previously the texture unit settings were stored in growable GArrays
and every time a new texture unit was encountered it would expand the
arrays. However the array wasn't copied when stored in a
CoglGles2WrapperSettings struct so all settings had the same
array. This meant that it wouldn't detect that a different program is
needed if a texture unit is disabled or enabled.

The texture unit settings arrays are all now a fixed size and the
enabledness of each unit is stored in a bit mask. Therefore the
settings can just be copied around by assignment as before.

This puts a limit on the number of texture units accessible by Cogl
but I think it is worth it to make the code simpler and more
efficient. The material API already poses a limit on the number of
texture units it can use.
2009-02-20 15:59:13 +00:00
Emmanuele Bassi
21aa09748c Add build machinery for gobject-introspection data
configure.ac: Check for gobject-introspection

build/introspection.m4: Include the file that defines the
GOBJECT_CHECK_INTROSPECTION m4 macro in case we want to disable
the introspection data generation.

clutter/json/Makefile.am: Build the .gir for "ClutterJson"
  (json-glib as part of the Clutter library)

clutter/Makefile.am: Build the .gir for clutter, compile the
  Clutter and ClutterJson girs into typelibs, and install them.
  Also move GCC_FLAGS from $(INCLUDES) to $(AM_CFLAGS) since it includes
  non-preprocessor flag like -Wall.

See also:

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

Based on a patch by: Owen W. Taylor <otaylor@fishsoup.net>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-20 14:39:51 +00:00
Owen W. Taylor
c5afd98416 Add gobject-introspection annotations
Add annotations such as (transfer-none) (out) (element-type ClutterActor),
and so forth to the doc comments as appropriate.

The annotations added here are a combination of the annotations previously
in gir-repository for Clutter and annotations found in a review of all
return values with that were being parsed with a transfer of "full".

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-20 12:09:07 +00:00
Emmanuele Bassi
3bfbcedec8 Do not use GL types in Clutter headers
Bug 1451 - clutter_value_get_shader_matrix() return value

The return value of the get_shader_matrix() function should be
gfloat, not GLfloat.
2009-02-20 11:47:14 +00:00
Emmanuele Bassi
1816106047 [timeline] Set the n_markers out paramater
Bug 1464 - clutter_timeline_list_markers should set n_markers=0 when
           there are no markers

If no markers are registered and we bail out we should also set the
n_markers out parameter to 0 so that code checking the number of
markers will still work.
2009-02-20 11:47:14 +00:00
Emmanuele Bassi
effbbe2e1e [path] Do not accept NULL descriptions
Bug 1465 - clutter_path_parse_description should check p==NULL

When accepting a stringified path description, ClutterPath methods
and the parser should not accept NULL or empty strings.
2009-02-20 11:47:14 +00:00
Emmanuele Bassi
96317854c8 [behaviour] Do not notify empty behaviours
If a behaviour does not have actors associated to it then it should
not invoke the ::alpha_notify() implementation.
2009-02-20 11:47:13 +00:00
Neil Roberts
97431b4670 Replaced ClutterFixed constants in color_{darken,lighten} with float
Bug 1463 - clutter_color_lighten(darken) unexpected because of
           ClutterFixed=>float

These two functions contained ClutterFixed constants represented as
integers which are no longer valid since the cogl-float branch
merge. They are now converted to ClutterFixed from float constants
using CLUTTER_FLOAT_TO_FIXED (which is now a no-op).

Thanks to Zhang Wei for reporting.
2009-02-20 11:07:23 +00:00
Emmanuele Bassi
5123608e22 [build] Reference the headers with their full path
Do not assume locality of the files, but use their whole path.
2009-02-19 17:22:21 +00:00
Øyvind Kolås
84ecb5081f Bail early in clutter_texture_paint if opacity == 0
This causes clutter to skip all the GL work of state changes and
texturing if the opacity was 0. This is done in ClutterTexture and not
ClutterActor to ensure that pre and post paint signals work correctly.
Other expensive actors should be doing the same thing.
2009-02-19 15:44:16 +00:00
Emmanuele Bassi
3009d029ba Remove type functions for removed types
The CoglHandle wrapper GTypes have been removed in commit a0800b44
so we can safely remove the declarations.
2009-02-19 15:00:23 +00:00
Emmanuele Bassi
cf48935cf5 [build] Pass the -s switch to cmp
The call to "cmp" to compare a built file with its current version
should use the -s (silent) command line switch. This avoids a ugly
message on the console when building Clutter the first time.
2009-02-19 14:57:43 +00:00
Emmanuele Bassi
4aecece48d [docs] Add a missing "return" annotation
The documentation for the get_anchor_point_gravity() method is
missing the "Return value:" section.
2009-02-19 14:56:07 +00:00
Emmanuele Bassi
9bdbe8a06a Merge branch 'build-enhancements'
* build-enhancements:
  [build] Fix dist for the newly introduced m4 macro directory
  [build] Fix interaction between shave, gtk-doc and libtool 1.x
  [build] Add dolt
  [build] Beautify autotools' output
  [gitignore] update gitignore files for tests/
2009-02-19 14:42:40 +00:00
Emmanuele Bassi
c18e756267 [docs] Clarify the set_cogl_texture() documentation
When setting the COGL texture handle for a ClutterTexture the
texture will be set as the first layer of the material used
by the ClutterTexture. The documentation should clarify this
point.
2009-02-19 13:44:29 +00:00
Emmanuele Bassi
a0800b44ad [texture] Use COGL_TYPE_HANDLE for the handle properties
The :texture and :material properties of ClutterTexture use a
Clutter-provided GType shielding from CoglHandle. Since CoglHandle
now has a GType we can use COGL_TYPE_HANDLE instead.

This commit also removes the conditional compilation of the
:material property, as it makes little sense now that the
Materials API has landed.
2009-02-19 12:05:20 +00:00
Emmanuele Bassi
3c073d82c7 [cogl] Provide GTypes for COGL types
COGL types should be registered inside the GType system, for
bindings and type checking inside properties and signals.

CoglHandle is a boxed type with a ref+unref semantics; slightly evil
from a bindings perspective (we cannot associate custom data to it),
but better than nothing.

The rest of the exposed types are enumerations or bitmasks.
2009-02-19 12:02:42 +00:00
Emmanuele Bassi
63ae25972e [cogl] Add cogl_is_material to cogl-material.h
The COGL_DEFINE_HANDLE macro generates a cogl_is_<type> function
as well, to check whether a CoglHandle opaque pointer is of type
<type>.

The handle for CoglMaterial does not export cogl_is_material() in
its installed header.
2009-02-19 11:55:54 +00:00
Emmanuele Bassi
5bdcfd288c Initialize a variable to avoid warnings
The gl_mode variable was not initialized, and the compiler complained
when using the anal-retentive compiler flags.
2009-02-18 18:45:58 +00:00
Neil Roberts
a86b9834d3 [ClutterBehaviourRotate] Fix up some breakage from the cogl-float branch merge
The rotation angle calculated in clutter_behaviour_rotate_alpha_notify
gets applied to each actor using clutter_behaviour_actors_foreach. The
angle is a ClutterFixed value. Before the cogl float branch merge it
was stuffed into a gpointer using GPOINTER_TO_UINT. The pointer was
then converted back to a uint and cast to a ClutterFixed which worked
out fine even for negative numbers.

After the cogl-float merge the angle is effectively a gfloat. This
gets cast to a uint and stored in a pointer and converted back to a
float via a uint at the other end. However this fails for negative
numbers because a uint -> float conversion can't take advantage of
overflow to preserve the sign so you end up with a large number.

It also had the side effect that it only rotated in whole degrees.

This commit fixes the problem by just passing the ClutterFixed value
inside a closure struct instead of trying to stuff it into a pointer.
2009-02-18 18:30:58 +00:00
Damien Lespiau
8eec75efde [build] Beautify autotools' output
Use shave (http://git.lespiau.name/cgit/shave) to make compilation more
human friendly.
2009-02-18 17:38:34 +00:00
Neil Roberts
deed85035f Allow rotation angle properties to be negative
Bug 1167 - clutter_effect_rotate improperly clamps negative angles

The rotation angle properties had a minimum value of 0.0 but the
rotation works fine with a negative value so the limitation is
unnecessary. This makes rotation using the ClutterAnimation API more
flexible because it was previously not possible to rotate
counter-clockwise from the 0.0 position.
2009-02-18 17:32:23 +00:00
Neil Roberts
99248fa90f Override the opacity when painting a clone instead of combining
When rendering a clone before this commit the clone's opacity was
combined with the opacity of the source but this is not usually the
desired effect. Instead the clone's opacity (combined with its
parents) should completely override the opacity of the source.
2009-02-18 17:01:12 +00:00
Tomas Frydrych
c0672b6683 [x11] Only update cached last event time if we have a real timestamp.
Ignore the timestamp if it is set to CurrentTime (e.g., when the last event
did not carry a timestamp).
2009-02-18 16:56:39 +00:00
Robert Bragg
d2fe1fda31 [cogl-color.c] #include fix for the cogl_set_source_color prototype
cogl.h wasn't being included so we got a compiler warning
2009-02-18 16:19:14 +00:00
Robert Bragg
03018f0c2a [Cogl] Renames cogl_paint_init to cogl_clear and adds a cogl_disable_fog function
cogl_paint_init was a bit too miscellaneous; it mainly cleared the color, depth
and stencil buffers but arbitrarily it also disabled fogging and lighting.

It no longer disables lighting, since we know Cogl never enables lighting and
disabling of fog is now handled with a seperate function.

Since I noticed cogl_set_fog was taking a density argument documented as
"Ignored" I've also added a mode argument to cogl_set_fog which exposes the
exponential fog modes which can make use of the density.
2009-02-18 16:00:52 +00:00
Robert Bragg
2b5a72dde5 [Cogl] cogl_clip_{set*,unset} renamed to cogl_clip_{push*,pop}
This is so they self document the stacking semantics of the cogl clip API
2009-02-18 16:00:51 +00:00
Øyvind Kolås
57ffcdf014 Added a mutex for clutter asynchronous textures threads.
Bug #1453 - Asynchronous texture loading can starve cpu.

Add a mutex that is held in the loader threads during the image
decoding. We were spawning and starting a thread for each asynchronously
loaded texture. This can cause cpu / memory starvation when many pixbuf
loaders allocate their temporary memory at the same time.

Also added -fno-strict-aliasing to MAINTAINER_CFLAGS in configure.ac
to avoid incorrect warnings caused by the static mutex code.
2009-02-18 10:35:45 +00:00
Emmanuele Bassi
2fe0228f92 [x11] Add backend-specific get_current_event_time()
The clutter_get_current_event_time() function will return the event
timestamp coming from a Clutter event. Clutter might synthesize or
throttle events, so the function cannot be used when dealing with
backend-specific use cases.

The X11 backend is the only backend supported by Clutter that makes
use of timestamps, so it's altogether fitting that it should come
with a specific function to deal with the timestamps of the X events.
2009-02-18 10:07:12 +00:00
Neil Roberts
747233a8ac [clutter-main] Fix the input device passed to set_motion_last_actor
In generate_enter_leave_events it passes the device pointer from the
event to set_motion_last_actor but it was reading it directly from
event->motion.device. However the function is also used to process
button events so it would read from the wrong location in this case.

The device location in the union happened to be in the same place as
the click_count field of ClutterButtonEvent so it only mattered if the
click_count is non-zero. The X11 backend doesn't set this but
Clutter-GTK does so it was causing a crash.
2009-02-16 16:36:46 +00:00
Neil Roberts
1fcddb3b10 [win32] Track mouse leave messages
Bug 1178 - No enter / leave events on actors when pointer leaves the
           stage window

This patch causes the Win32 backend to emit CLUTTER_LEAVE events when
a WM_MOUSELEAVE event is received in the same way that f505536 does
for the X11 backend.

Windows will only send WM_MOUSELEAVE events if they are previously
requested using TrackMouseEvent so this needs to be called whenever
the mouse enters the window. There is no WM_MOUSELEAVE event but we
can detect when the mouse enters because we get a WM_MOUSEMOVE event.
2009-02-16 12:46:37 +00:00
Neil Roberts
9e10dc402f Call glActiveTexture and glClientActiveTexture through cogl_get_proc_address
All GL functions that are defined in a version later than 1.1 need to
be called through cogl_get_proc_address because the Windows GL DLL
does not export them to directly link against.
2009-02-16 12:46:36 +00:00
Neil Roberts
5d6a11e1bf Emit CLUTTER_LEAVE events when the pointer leaves the stage
Bug 1178 - No enter / leave events on actors when pointer leaves the
           stage window

The patch is mostly thanks to Johan Bilien with small modifications
based on suggestions by Owen Taylor.

The X11 backend now listens for enter and leave notifications. Leave
notifications get translated directly to a CLUTTER_LEAVE
event. Clutter can detect these special events because the source
actor is NULL in which case it sets the source actor to the last known
actor and then sets the last known actor to NULL.

Enter notifications just get translated to CLUTTER_MOTION events which
will cause Clutter to generate an enter event through the usual code
path.
2009-02-16 12:46:36 +00:00
Emmanuele Bassi
0c7e4172ab [animation] Do not bind construct-only properties
ClutterAnimation should not try to bind construct-only properties,
since it only manipulates existing instances.
2009-02-16 11:02:20 +00:00
Emmanuele Bassi
8f59f25beb [actor] Revert part of commit 402e022c
An unintended chunk of commit 402e022c got committed before I looked
at the diff.
2009-02-14 13:11:13 +00:00
Christian Persch
839d1e00b1 Bug 1429 - Redundant declaration in clutter-x11.h
clutter-x11.h declares clutter_x11_set_display twice, which means code using
clutter doesn't compile cleanly with -Wredundant-decls.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-14 12:55:20 +00:00
Shane Bryan
46ce2ee737 Bug 1434 - _NET_WM_NAME not set before realize
Moved clutter_stage_set_title() before call to clutter_actor_realize()
to ensure _NET_WM_NAME is set early enough for use by interested WM's,

Signed-off-by: Shane Bryan <shane.bryan@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-14 12:49:25 +00:00
Emmanuele Bassi
9da564b391 Bug 1440 - Add clutter_get_current_event_time()
The clutter_get_current_event_time() is a global function for
retrieving the timestamp of the current event being propagated
by Clutter. Such function avoids the need to propagate the
timestamp from within user code.
2009-02-14 11:38:16 +00:00
Emmanuele Bassi
0ac6d6637e [list-model] Make ClutterListModel subclassable
ClutterListModel has been added as a terminal class in case we
decided to change API or implementation.

Apparently, it's a lot more resilient than we expected -- or far
too few are using it and reporting bugs. Once common issue, though,
is that it cannot be subclassed, hence it's fairly limited in its
usage.

In the hope that more developers will start using it, here's a
patch that makes ListModel a fully subclassable object.

May whatever god you believe in have mercy on your eventual soul.
2009-02-14 11:31:00 +00:00
Robert Staudinger
f17437124e [build] Add cogl.h to the built sources list
The main COGL header file is generated at configure time. If something
changes in the template, though, the file will not be regenerated.

Adding cogl.h to the BUILT_SOURCES list will allow the regeneration to
happen.
2009-02-12 12:42:58 +00:00
Emmanuele Bassi
402e022c36 [actor] Check out parameters before setting them
The clutter_actor_get_rotation() out parameters may be NULL, so
we need to check before dereferencing them.
2009-02-11 17:57:44 +00:00
Emmanuele Bassi
82db27874b [event] Extend KeyEvent for multi-input support
Key events can come from different input devices, so they need a
ClutterInputDevice member like the pointer-related events. This
field is reserved for future use.
2009-02-11 17:57:44 +00:00
Emmanuele Bassi
5590958102 [texture] Check if the material is valid
The CoglMaterial handle might be invalid when we are disposing
the ClutterTexture, so we need to check before calling any
cogl_material_* API on it.
2009-02-11 17:57:44 +00:00
Emmanuele Bassi
29bff6890a [texture] Consolidate the quality to filter conversions
To convert from a TextureQuality to a COGL filter enumeration
we need to perform two function calls. Since we need both filters
when calling cogl_texture_set_filters() we can safely consolidate
the two conversion functions into one. This also allows using a
shorter function name, thus reducing the lenght of the lines
involved and, more importantly preventing Emmanuele from crying.
2009-02-11 17:57:43 +00:00
Robert Bragg
b4f9c8204d [docs] Various gtk-doc updates for Cogl
This hides a number of internal structs and enums from the docs, and moves
some functions to more appropriate sections as well as misc description
updates (mostly for the vertex buffer api)
2009-02-09 14:33:14 +00:00
Robert Bragg
d01e3cd802 [cogl-vertex-buffer] Some fixes for texturing and color arrays
Fixes some blending issues when using color arrays since we were
conflicting with the cogl_enable state + fixes a texture layer
validation bug.

Adds a basic textured triangle to test-vertex-buffer-contiguous.
2009-02-09 14:15:06 +00:00
Robert Bragg
4a110afe08 [cogl-material] Fixes some dirty flag checks
Flushing material layers wasn't clearing the right dirty flag and
some of the tests used to avoid re-submitting GL state weren't
complete.
2009-02-09 14:15:06 +00:00
Robert Bragg
fa55c096d8 [Cogl] Renames cogl_fog_set to cogl_set_fog for consistency
More things follow the <object>_set_<property> convention.
2009-02-09 14:15:06 +00:00
Neil Roberts
0be6f42070 [cogl-texture] Fix uninitialised priv var in texture_finalize
Fix my failure to initialise the priv var which was some causing
crashes.
2009-02-05 23:02:38 +00:00
Neil Roberts
a2168686b9 [cogl-texture] Move the destruction of the material to _finalize
Otherwise if the dipose method is called twice the material will
already be destroyed when texture_free_gl_resources is called so it
will issue a warning about an invalid handle.
2009-02-05 20:29:25 +00:00
Neil Roberts
05c7e5a97c [cogl-texture] Fix offset to next quad when flushing the log
When the quad log contains multiple textures (such as when a sliced
texture is drawn) it dispatches the log with multiple calls to
flush_quad_batch and walks a pointer along the list of vertices.
However this pointer was being incremented by only one vertex so the
next quad would be drawn with three of the vertices from the last
quad.
2009-02-05 20:29:25 +00:00
Neil Roberts
a4de12dbe8 [clutter-texture] Fix the no_slice property
The 'no_slice' property means the texture should never be sliced. We
want cogl to create a texture with any amount of waste so we pass
max_waste as -1. However this got broken in commit 168d55 so that the
meaning got negated (no_slice enabled slicing).
2009-02-05 20:29:25 +00:00
Chris Lord
6bc7f4c723 [actor] Force a relayout on set_parent()
The current code that handles the invariant that the new parent
of an actor needing a layout should also be queued for relayout
is hitting the short-circuiting we do in the queue_relayout()
method.

In order to fix this we can forcibly set the actor to need a
width/height request and an allocation; then we queue a relayout
on the parent.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-02-05 19:54:48 +00:00
Emmanuele Bassi
9cf02bfdb9 [text] Rename :alignment to :line-alignment
The :alignment property is prone to generate confusion: developers
will set it thinking that the contents of a ClutterText will
automagically align themselves.

Instead of using the generic term :alignment, and following the
GTK+ convention, we should use a more specific term, conveying the
actual effect of the property: alignment of the lines with respect
to each other, and not to the overall allocated area.

See bug 1428:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1428
2009-02-05 19:54:48 +00:00
Neil Roberts
e349642937 [clutter-texture] Unref the Cogl material on dispose
The material is created in the _init function and is owned by the
ClutterTexture so it will be leaked if not freed.
2009-02-05 18:27:04 +00:00
Neil Roberts
ee0bf5e26d [clutter-texture] Release the temporary ref taken when setting a texture
When setting the cogl texture, the ClutterTexture takes a reference to
the Cogl handle but the material takes an additional reference when it
is set as the layer. Nothing was unrefing the temporary reference so
the textures were being leaked.
2009-02-05 18:26:08 +00:00
Neil Roberts
8feb99722c [clutter-clone] Override the parent opacity to self not self->parent
The opacity of the source actor when painted from the clone should be
combined with the opacity of the clone as well as the clone's parents,
instead of just the parents.
2009-02-04 00:14:16 +00:00
Neil Roberts
8e44874a93 [cogl-gles2-wrapper] Remove the FIXME to adjust the fragment color
Removed some debugging code which sets the r and g values to 1 in the
fragment shader.
2009-02-02 22:02:47 +00:00
Neil Roberts
49359407b0 [cogl-texture] Fix the count for the number of enabled arrays
The quad drawing code keeps track of the number of texture units that
have the tex coord array enabled so that in the next call it can
disabled any that are no longer enabled. However it was using 'i+1' as
the count but 'i' is already set to 'n_layers' from the previous for
loop.

Therefore it was disabling an extra texture unit. This doesn't
normally matter but it was causing GLES 2 to pointlessly realize an
extra unit.
2009-02-02 22:01:47 +00:00
Neil Roberts
e88de5f5fd Fix building GLES 2 after the material branch merge
- In cogl-material.h it directly sets the values of the
  CoglMaterialLayerCombineFunc to some GL_* constants. However these
  aren't defined in GLES 2 beacuse it has no fixed function texture
  combining. Instead the CGL_* versions are now used. cogl-defines.h
  now sets these to either the GL_* version if it is available,
  otherwise it directly uses the number.

- Under GLES 2 cogl-material.c needs to access the CoglTexture struct
  so it needs to include cogl-texture-private.h

- There are now #define's in cogl-gles2-wrapper.h to remap the GL
  function names to the wrapper names. These are disabled in
  cogl-gles2-wrapper.c by defining COGL_GLES2_WRAPPER_NO_REMAP.

- Added missing wrappers for glLoadMatrixf and glMaterialfv.

- Renamed the TexEnvf wrapper to TexEnvi because the latter is used
  instead from the material API.
2009-02-02 21:57:41 +00:00
Neil Roberts
edbe9a0377 [cogl-material] Always bind the new texture handle
Cogl previously tried to cache the currently bound texture when
drawing through the material API to avoid excessive GL calls. However,
a few other places in Cogl and Clutter rebind the texture as well so
this can cause problems.

This was causing shaped windows to fail in Mutter because
ClutterGLXTexturePixmap was binding a different texture to update it
while the second texture unit was still active which meant the mask
texture would not be selected when the shaped window was drawn
subsequent times.

Ideally we would fix this by providing a wrapper around glBindTexture
which would affect the cached value. The cache would also have to be
cleared if a selected texture was deleted.
2009-02-02 14:53:23 +00:00
Emmanuele Bassi
2747aa7be2 [text] Use create_pango_layout()
Since we added clutter_actor_get_pango_layout() it would be a
good idea to use it in the ClutterText actor to cut down the
PangoContext-related calls.
2009-02-02 12:07:29 +00:00
Emmanuele Bassi
6e12722a9b [clone] Allow cloning unparented actors
If the source of a ClutterClone does not have a parent actor the
clone will be unable to paint it because it's missing an allocation.

A simple way to fix it is to make the ClutterClone act like a
"foster parent": when it is allocated it will check if the source
actor has a parent and if not it will allocate the source with
its preferred size.
2009-02-02 12:07:29 +00:00
Emmanuele Bassi
801e535e94 Add Actor::create_pango_layout()
Final bit of integration between ClutterActor and Pango: a simple
method for creating a PangoLayout, pre-filled with text and ready
to be rendered using cogl_pango_render_layout().

This should make writing new Actors rendering custom text in their
paint() implementation easy and reliable.
2009-02-02 12:07:28 +00:00
Emmanuele Bassi
488de99fc6 [text] Merge the attributes with markup enabled
ClutterText should merge the PangoAttributes set by using
clutter_text_set_attributes() with the attributes generated by
parsing Pango markup.

For this to work we must parse the markup and merge the attributes
we get out of pango_parse_markup() with the attributes set by
the user.

Setting the markup or the attributes on an editable text should
not work for the time being.
2009-02-02 12:07:28 +00:00
Tomas Frydrych
e8ef5153b1 Fix clutter_x11_texture_pixmap_get/set_property() following change of PROP_WINDOW type.
PROP_WINDOW is now gulong, so we need to use appropriate GValue accessors.
2009-02-02 07:37:08 +00:00
Tomas Frydrych
c1de33fafe Fixed handling of enter and leave events in clutter_x11_handle_event()
When processing a motion event, we need to spin the event loop two extra
  times to ensure that any enter/leave events that might have been synthesized
  are pumped through (otherwise they end up being pushed down the queue and
  never processed).
2009-02-02 07:36:36 +00:00
Emmanuele Bassi
bb6202a1a1 Add cogl-material-private.h to the source files
The material-private.h file was not added to the dist files and
caused a build failure.
2009-01-29 16:00:15 +00:00
Emmanuele Bassi
86aba661bd Fix a variable masking warning
The usual issue with math.h defined symbols.
2009-01-29 13:31:51 +00:00
Neil Roberts
f1bae778ce [cogl] Add an NULL terminator to the call to material_flush_gl_state
This fixes a compiler warning and a potential crash.
2009-01-29 12:21:56 +00:00
Robert Bragg
6516dd3033 Another Cogl gl vs gles normalizaion pass
This tries to make a number of files more comparable with the intention of
moving some code into cogl/common/

Files normalized:
 cogl.c
 cogl-context.c
 cogl-context.h
 cogl-texture.c
2009-01-28 17:20:16 +00:00
Robert Bragg
081f2056bc Removes cogl_color_set_from_4d as it may mislead people.
Someone not sure which cogl_color_set_from_* version is "best" may use
set_from_4d because taking doubles implies higher precision. Currently
it doesn't have any advantage.
2009-01-28 17:20:15 +00:00
Robert Bragg
ef4052c18d Changes cogl_rectangle to take x1, y1, x2, y2 args not x1, y1, width, height
This makes it consistent with cogl_rectangle_with_{multi,}texture_coords.
Notably the reason cogl_rectangle_with_{multi,}texture_coords wasn't changed
instead is that the former approach lets you describe back facing rectangles.
(though technically you could pass negative width/height values to achieve
 this; it doesn't seem as neat.)
2009-01-28 17:20:15 +00:00
Robert Bragg
6048a0544a Adds some debug code to _cogl_journal_flush_quad_batch
The code is #if 0 guarded, but when uncommented it outlines all drawn
rectangles with an un-blended red, green or blue border. This may e.g. help
with debugging texture slicing issues or blending issues, plus it looks quite
cool.
2009-01-28 17:20:15 +00:00
Neil Roberts
e30c5b33b9 Undeprecate clutter_actor_set_scale_with_gravity
The scale center has returned so this function is available again but
it was still deprecated so you couldn't use it.
2009-01-28 16:24:02 +00:00
Neil Roberts
3e68b23ea8 Merge branch 'scale-center'
Bug 1349 - Using the anchor point to set the scale center is messy

The branch adds an extra center point for scaling which can be used
for example to set a scale about the center without affecting the
position of the actor.

The scale center can be specified as a unit offset from the origin or
as a gravity. If specified as a gravity it will be stored as a
fraction of the actor's size so that the position will track when the
actor changes size.

The anchor point and rotation centers have been modified so they can
be set with a gravity in the same way. However, only the Z rotation
exposes a property to set using a gravity because the other two
require a Z coordinate which doesn't make sense to interpret as a
fraction of the actor's width or height.

Conflicts:

	clutter/clutter-actor.c
2009-01-28 15:39:51 +00:00
Neil Roberts
1cd313477b [clutter-actor] Use G_STMT_START/END instead of do { } while (0)
In the TRANSFORM_ABOUT_ANCHOR_COORD macro it now uses G_STMT_START and
G_STMT_END instead of directly using do/while because it's more
readable.
2009-01-28 15:33:34 +00:00
Neil Roberts
d7c275f5e5 [cogl-texture] Fix order of tex coords when compensating for waste
When drawing a texture with waste in _cogl_multitexture_unsliced_quad
it scales the texture coordinates so that the waste is not
included. However the formula was the wrong way around so it was
calculating as if the texture coordinates are ordered x1,x2,y1,y2 but
it is actually x1,y1,x2,y2.
2009-01-28 12:57:06 +00:00
Neil Roberts
e72042648c [cogl-texture] Reset size of vertex log after drawing a polygon
Otherwise trying to render a rectangle after a polygon doesn't work
because it expects the array to be empty when it starts logging
vertices.
2009-01-28 12:24:11 +00:00
Neil Roberts
eda1d08f76 Fix rectangles_with_multitexture_coords for sliced without tex coords
When the texture is sliced it drops back to a fallback function and
passes it the texture coordinates from the rectangle. However if no
tex coords are given it would crash. Now it passes the default
0.0->1.0 tex coords instead.
2009-01-28 12:24:10 +00:00
Neil Roberts
7df1987652 Fix _cogl_texture_unsliced_quad when no texture coordinates are given
If no texture coordinates are given then texture_unsliced_quad tries
to generate its own coordinates. However it also tries to read the
texture coordinates to check if they are in [0.0,1.0] range so it will
crash before it reaches that.
2009-01-28 12:24:10 +00:00
Emmanuele Bassi
9b7fa2cb04 Reuse the layers list
Instead of getting the layers list twice from the Material, we
can reuse the list when we need to retrieve the first layer.
2009-01-28 11:57:49 +00:00
Emmanuele Bassi
b3e02869cd Remove gtk-doc annotation
The _cogl_material_flush_layers_gl_state() function is static,
so it should not have a gtk-doc annotation.
2009-01-28 11:57:49 +00:00
Emmanuele Bassi
b08a011512 Fix typo in the :clone getter method
The :clone property getter method, clutter_clone_get_source(), was
defined using the wrong name of clutter_clone_get_clone_source().
2009-01-28 11:57:49 +00:00
Neil Roberts
2722909b76 Fix building GLES after _cogl_texture_handle_from_pointer got removed
Commit a688b1db removed the function and replaced it with a direct
cast. This was also being used in the GL ES so the build broke.
2009-01-28 10:56:47 +00:00
Neil Roberts
6b9da72ab0 Directly set backend font options in clutter_set_font_flags
Instead of having a separate set of font options that override the
backend options when clutter_set_font_flags is called, it now just
directly sets the backend font options. So now the font flags are just
a convenience wrapper around the backend font options.

This also makes the ClutterText labels automatically update when the
font flags are changed because they will respond to the 'font-changed'
signal from the backend.
2009-01-27 17:11:02 +00:00
Neil Roberts
89b0b00dd1 Listen for the font-changed signal on the backend in ClutterText
Whenever a ClutterText is created it now connects to the font-changed
signal. When it is emitted the layout cache is dirtied and a relayout
is queued. That way changes to the font options or resolution will
cause an immediate update to the labels in the scene.
2009-01-27 17:07:02 +00:00
Emmanuele Bassi
1b578fb9c7 [docs] Documentation fixes
Update the COGL API reference to avoid a lot of warnings coming
from gtk-doc.
2009-01-27 16:53:01 +00:00
Emmanuele Bassi
865f04decd Removed unused conditional
USE_COGL_MATERIAL is a left-over from the development branch.
2009-01-27 16:40:51 +00:00
Emmanuele Bassi
3cfc7fb1ca Merge branch 'generic-actor-clone'
* generic-actor-clone:
  Remove CloneTexture from the API
  [tests] Clean up the Clone interactive test
  Rename ActorClone to Clone/2
  Rename ActorClone to Clone/1
  Improves the unit test to verify more awkward scaling and some corresponding fixes
  Implements a generic ClutterActorClone that doesn't need fbos.
2009-01-27 16:14:35 +00:00
Emmanuele Bassi
a688b1db01 Fallout from cogl-material merge
When enabling the maintainer CFLAGS the compiler got very angry
at the code that has been merged.
2009-01-27 16:02:04 +00:00
Robert Bragg
840941fdfe Adds padding to CoglColor to future proof it a bit
This adds enough padding to allow us to change to an internal float storage
for the color components if needs be in the future.
2009-01-27 15:20:16 +00:00
Robert Bragg
70d7d16f13 Support scaling on the z axis with cogl_scale
This simply adds a z argument to cogl_scale and updates clutter-actor.c
to pass 1.0 for the z scale.
2009-01-27 15:20:13 +00:00
Robert Bragg
e9a45c7744 Merge branch 'cogl-material'
Conflicts:

	clutter/cogl/gl/cogl-texture.c
	clutter/cogl/gles/cogl-primitives.c

* cogl-material:
 clutter-{clone-,}texture weren't updating their material opacity.
 Updates GLES1 support for CoglMaterial
 Normalizes gl vs gles code in preperation for synching material changes
 Removes cogl_blend_func and cogl_alpha_func
 Fully integrates CoglMaterial throughout the rest of Cogl
 [cogl-material] Restore the GL_TEXTURE_ENV_MODE after material_rectangle
 [cogl-material] Make the user_tex_coords parameter of _rectangle const
 [test-cogl-material] Remove return value from material_rectangle_paint
 Add cogl-material.h and cogl-matrix.h to libclutterinclude_HEADERS
 [cogl-material] improvements for cogl_material_rectangle
 [cogl-material] Adds a cogl_material_set_color function
 [cogl-material] Some improvements for how we sync CoglMaterial state with OpenGL
 [cogl-material] Converts clutter-texture/clutter-clone-texture to the material API
 [doc] Hooks up cogl-material reference documentation
 Updates previous GLES multi-texturing code to use CoglMaterial
 Adds a CoglMaterial abstraction, which includes support for multi-texturing
 [doc] Hooks up cogl-matrix reference documentation
 Adds CoglMatrix utility code
 [tests] Adds an interactive unit test for multi-texturing
 [multi-texturing] This adds a new cogl_multi_texture API for GL,GLES1 + GLES2
2009-01-27 15:19:34 +00:00
Emmanuele Bassi
86e95a779a Remove CloneTexture from the API
ClutterClone supercedes ClutterCloneTexture, since it can clone
every kind of actor -- including composite ones.

This is another "brain surgery with a shotgun" kind of commit: it
removes CloneTexture and updates every test case using CloneTexture
to ClutterClone. The API fallout is minimal, luckily for us.
2009-01-27 15:18:45 +00:00
Neil Roberts
418fb995c8 Replace clutter_set_use_mipmapped_text with clutter_set_font_flags
The hope is that this function makes it easier to extend the font
settings with more flags without having to add a function for every
setting.

A new flag for enabling hinting has been added. If set, this changes
the font options on the global PangoContext and any newly created
PangoContexts. The options are only set if the flag is changed from
the default so it won't override any detailed setting chosen by the
backend.
2009-01-27 14:43:44 +00:00
Robert Bragg
28f9749e8e clutter-{clone-,}texture weren't updating their material opacity.
cogl_set_source_color4ub was previously used to set a transparent
white source color according to the actors opacity, but since
cogl_set_source_color now always implies you want a solid fill we
we use cogl_material_set_color4ub to achieve the same result.
2009-01-27 14:26:50 +00:00
Robert Bragg
4a7fa6d0fa Updates GLES1 support for CoglMaterial
This updates cogl/gles in line with the integration of CoglMaterial throughout
Cogl that has been done for cogl/gl.

Note: This is still buggy, but at least it builds again and test-actors works.
Some GLES2 specific changes were made, but these haven't been tested yet.
2009-01-27 14:26:50 +00:00
Robert Bragg
60e81f0fda Normalizes gl vs gles code in preperation for synching material changes
This changes all GLES code to use the OpenGL function names instead of
the cogl_wrap_* names. For GLES2 we now define the OpenGL name to point
to the wrapper, as opposed to defining the wrapper to point to the
OpenGL name for GLES1.

I've also done a quick pass through gl/cogl.c and gles/cogl.c to make
them more easily comparable. (most of the code is now identical)
2009-01-27 14:26:50 +00:00
Robert Bragg
427fff032e Removes cogl_blend_func and cogl_alpha_func
The GL blend function and alpha function are now controlled by the material
code, and even internally Cogl should now be using the material API when
it needs control of these.
2009-01-27 14:26:49 +00:00
Robert Bragg
5985eef44c Fully integrates CoglMaterial throughout the rest of Cogl
This glues CoglMaterial in as the fundamental way that Cogl describes how to
fill in geometry.

It adds cogl_set_source (), which is used to set the material which will be
used by all subsequent drawing functions

It adds cogl_set_source_texture as a convenience for setting up a default
material with a single texture layer, and cogl_set_source_color is now also
a convenience for setting up a material with a solid fill.

"drawing functions" include, cogl_rectangle, cogl_texture_rectangle,
cogl_texture_multiple_rectangles, cogl_texture_polygon (though the
cogl_texture_* funcs have been renamed; see below for details),
cogl_path_fill/stroke and cogl_vertex_buffer_draw*.

cogl_texture_rectangle, cogl_texture_multiple_rectangles and
cogl_texture_polygon no longer take a texture handle; instead the current
source material is referenced. The functions have also been renamed to:
cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords
and cogl_polygon respectivly.

Most code that previously did:
  cogl_texture_rectangle (tex_handle, x, y,...);
needs to be changed to now do:
  cogl_set_source_texture (tex_handle);
  cogl_rectangle_with_texture_coords (x, y,....);

In the less likely case where you were blending your source texture with a color
like:
  cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */
  cogl_texture_rectangle (tex_handle, x, y,...);
you will need your own material to do that:
  mat = cogl_material_new ();
  cogl_material_set_color4ub (r,g,b,a);
  cogl_material_set_layer (mat, 0, tex_handle));
  cogl_set_source_material (mat);

Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use
cog_rectangle_with_texure_coords since these are the coordinates that
cogl_rectangle will use.

For cogl_texture_polygon; as well as dropping the texture handle, the
n_vertices and vertices arguments were transposed for consistency. So
code previously written as:
  cogl_texture_polygon (tex_handle, 3, verts, TRUE);
need to be written as:
  cogl_set_source_texture (tex_handle);
  cogl_polygon (verts, 3, TRUE);

All of the unit tests have been updated to now use the material API and
test-cogl-material has been renamed to test-cogl-multitexture since any
textured quad is now technically a test of CoglMaterial but this test
specifically creates a material with multiple texture layers.

Note: The GLES backend has not been updated yet; that will be done in a
following commit.
2009-01-27 14:26:39 +00:00
Emmanuele Bassi
86e4e89bf1 Rename ActorClone to Clone/2
Step two: rename the object and its methods.

While we're at it, adhere more strictly to the coding style
practises; rename :clone-source to :source; add a setter method
for the :source property; take a reference on the source actor
to avoid it disappearing while we're still accessing it.
2009-01-27 14:24:31 +00:00
Emmanuele Bassi
2138b1cbb2 Bug 1388 - Clarify signal emission for advance_to_marker()
Like clutter_timeline_advance(), calling advance_to_marker() will
not emit ::new-frame for the frame where the marker is set on; it
will also not emit ::marker-reached for the marker we are advancing
the timeline to.
2009-01-27 11:25:06 +00:00
Emmanuele Bassi
8608d103f8 Bug 1387 - Clarify new-frame signal emission with advance()
When calling clutter_timeline_advance(), a timeline will not emit
the ::new-frame signal for the frame we are advancing to, as this
would break the invariants of the timeline behaviour.

The documentation should make this clear.
2009-01-27 11:18:09 +00:00
Emmanuele Bassi
43bd4e5d3f [timeline] Check the fps property range in the ctor
The clutter_timeline_new() constructor is not checking the full
range of the passed :fps property. The ParamSpec of the property
and the setter method perform this check, so the ctor should as
well.
2009-01-27 10:35:50 +00:00
Emmanuele Bassi
f753847851 [timeline] Move a complex condition into its own function
The "is-timeline-complete" condition is pretty long, spanning
four lines and four logical sub-conditions. It is possible to
neatly move it into an is_complete() function and make the
code more readable.
2009-01-27 10:33:44 +00:00
Emmanuele Bassi
092db1098c [timeline] Intern signal names
The signal names are static string and thus should be interned
so that Glib can do a simple pointer comparison whenever needed,
instead of a strcmp().
2009-01-27 10:32:15 +00:00
Emmanuele Bassi
7863ca4a55 [timeline] Whitespace fixes 2009-01-27 10:31:53 +00:00
Emmanuele Bassi
2be9cdc267 [timeline] Documentation and comment fixes
The long description of the ClutterTimeline class is very C
developer-oriented. Since many language bindings will refer to
the C API reference we should probably be more verbose and
language agnostic -- at least in the class description.

The methods documentation also requires a little pass to increase
the consistency of the terminology, the grammar and the syntax.

Finally, comments never killed anyone.
2009-01-27 10:27:33 +00:00
Emmanuele Bassi
763de185e9 [timeline] Create markers hash tables on demand
Since not every timeline will have markers it's unfair to make
all of them crete two empty hash tables (with a preallocated
fixed size).

This commit moves the responsibility of creating the hash tables
to the marker API itself, and adds the relative checks.
2009-01-27 09:51:45 +00:00
Emmanuele Bassi
1e071ed859 [timeline] Limit timelines to 1000 frames per second
Since we are using milliseconds granularity to integrate timelines
with the GLib main loop, we cannot allow values of the :fps
property bigger than 1000. This means validating the fps value both
in the GParamSpec and the clutter_timeline_set_speed() accessor
function.

This should also fix floating point exceptions when trying to
perform "n_frames = milliseconds / (1000 / fps)".

See bug 1354:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1354
2009-01-27 09:51:45 +00:00
Havoc Pennington
81f642d4b7 Bug 1414 - avoid relayout of ClutterTexture if not syncing size
If a ClutterTexture does not sync size, it should be possible to
change the texture size without causing a relayout.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-26 16:25:53 +00:00
Havoc Pennington
9ccae46bc1 Bug 1415 - short-circuit setting same clip again
There is some GL work and a repaint anytime the clip is set
or unset, so avoid that if it isn't really changed.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-26 16:22:39 +00:00
Neil Roberts
54f4ed775c Set the SYNC_MATRICES flag when a stage is first realized
The stage will usually be painted before the first ConfigureNotify
arrives so we need to set the SYNC_MATRICES flag to ensure that the
viewport will be correct for that paint. Unfortunately this means that
the viewport will be set again once the ConfigureNotify is received
but compared to rendering an initial invalid scene I think it is the
lesser of two evils.
2009-01-26 10:58:40 +00:00
Emmanuele Bassi
9197646d25 Rename ActorClone to Clone/1
Step one of the ActorClone -> Clone renaming: rename the files.
2009-01-26 10:32:53 +00:00
Emmanuele Bassi
cdb360107b Whitespace fixes for BehaviourEllipse
Simple fallout from the automated conversion scripts that
switched from ClutterFixed to float.
2009-01-24 14:32:10 +00:00
Emmanuele Bassi
171a7647b9 Bug 1395 - apply and get_nth_actor are inconsistent
When calling clutter_behaviour_apply() the new actor is prepended
to the list of actors to which a behaviour is applied; this breaks
the rest of methods working on the actors list, e.g.:

  # adding actors
  apply(actor_0);
  apply(actor_1);
  apply(actor_2);

  # expected: [ actor_0, actor_1, actor_2 ]
  [ actor_2, actor_1, actor_0 ] = get_actors();

  # expected: actor_2
  actor_0 = get_nth_actor(2);

This commit fixes the inconsistency in the returned values.
2009-01-24 14:32:09 +00:00
Neil Roberts
ba068f6bc9 Fix the Cogl primitives for the GLES backend
The Cogl primitives broke for GLES 1.1 and 2 after the cogl-float
branch merge.

CoglPathNode was still being declared as GLfixed for the GLES backend
but it was being filled with float values so they were all ending up
as numbers < 1.

glDrawArrays was being called with GL_FIXED so this has been changed
to GL_FLOAT.

The scanline rasterizer had a leftover hardcoded ClutterFixed constant
to add a small amount to the height of each line.

struct _CoglFloatVec2 has been removed because it is no longer used
anywhere.
2009-01-24 00:26:51 +00:00
Neil Roberts
4d7caa4bd5 [clutter-timeline] Remove the code for backwards timelines in get_progress
The special check to invert the progress when the timeline direction
is backwards is not necessary because the actual frame number will be
decreasing in that case. Inverting just makes it progress forwards
again.

This is more apparent since the float-alpha-value branch merge because
the clutter_linear function directly returns the value from
get_progress. For example in test-depth, the animations loop instead
of oscillating back and forth.
2009-01-23 22:57:36 +00:00
Neil Roberts
9ea6ab76fb Fix gtk-doc reference since the anchor point changes
The documentation has been updated to reflect the fact that the anchor
point will move when the actor changes size if it was specified using
a gravity value. The new functions for setting the scale center and z
rotation gravity are also documented.
2009-01-23 18:41:41 +00:00
Neil Roberts
d5e5d35316 Convert the rotation centers to be AnchorCoords
Currently only the Z axis rotation center can be set using a gravity
but the other rotations also store their center as an AnchorCoord for
consistency. Specifying the center as a gravity makes less sense for
the other axes because the actors have no size along the Z axis.

The rotation angles are now stored as gdoubles and the fixed point *x
entry points have been removed.

The Z rotation can now be set with a gravity center using the
following new function:

void clutter_actor_set_z_rotation_from_gravity (ClutterActor   *self,
                                                gdouble         angle,
                                                ClutterGravity  gravity);
2009-01-23 18:41:41 +00:00
Neil Roberts
e10d255b83 Add a scale center property to ClutterActor
This sets the center point from which the scaling will occur. This can
be used insetad of the anchor point to avoid moving the actor. Like
the anchor point, it can be specified as either a coordinate in units
or a gravity enum.

To set the center you can use two new variants of set_scale:

clutter_actor_set_scale_full (ClutterActor *self,
                              gdouble       scale_x,
                              gdouble       scale_y,
                              int           center_x,
                              int           center_y);

or

clutter_actor_set_scale_with_gravity (ClutterActor   *self,
                                      gdouble         scale_x,
                                      gdouble         scale_y,
                                      ClutterGravity  gravity);

The ClutterFixed variants of the set_scale functions have been removed
and the scale value is now always stored as a double.
2009-01-23 18:41:40 +00:00
Neil Roberts
a24b9a32e5 Store when the anchor point is set from a gravity
This makes it so when the anchor point is set using a gravity enum
then the anchor point moves when the actor changes size. A new
property is added for the anchor point gravity. If the anchor point is
set from gravity then the position in units can also be retreived with
the regular API.

A new union type is used to store the anchor point with helper
accessor functions. The hope is these can be reused for the scale and
rotation center points.
2009-01-23 18:41:40 +00:00
Robert Bragg
3d07e34cc5 Merge commit 'origin/master' into cogl-material
Conflicts:

	clutter/clutter-texture.c
	clutter/cogl/cogl-texture.h
	clutter/cogl/cogl.h.in
	clutter/cogl/common/Makefile.am
	clutter/cogl/gl/Makefile.am
	clutter/cogl/gles/Makefile.am
	clutter/cogl/gles/cogl-gles2-wrapper.c
	clutter/cogl/gles/cogl-gles2-wrapper.h
2009-01-23 15:23:49 +00:00
Emmanuele Bassi
134edac82c Bug 1361 - Unused ClutterStage::get_resolution() methods
The clutter_stage_get_resolution() and fixed-point API are just
shorthands for:

        clutter_backend_get_resolution (default_backend);

And as such do not fit at all in the ClutterStage class. The only
reason for their existence was the ClutterUnit conversion macros,
which have now been fixed to use the default backend through a
function call instead.

Thus, we can safely remove the stage entry points.
2009-01-23 15:16:21 +00:00
Emmanuele Bassi
915d9ec7ca Split maintainer-flags from the compiler flags
The maintainer compiler flags we use trigger warnings and errors
in the autogenerated code that gtk-doc creates to scan the header
and source files. Since we cannot control that, and we must run
a distcheck with both --enable-gtk-doc and --enable-maintainer-flags
turned on, we need to use less-strict compiler flags when inside
the doc/reference subdirectories.

The way to do this is to split the maintainer compiler flags into
their own Makefile variable, called MAINTAINER_CFLAGS. The we
can use $(MAINTAINER_CFLAGS) in the INCLUDES or _CFLAGS sections
of each part of the source directories we wish to check with the
anal retentiveness suited for maintainers.
2009-01-23 13:09:51 +00:00
Emmanuele Bassi
20973bd29f Fix compiler warnings
The maintainer-flags option discovered the usual amount of
collisions and compiler warnings we have to fix in order to
get distcheck to pass.
2009-01-23 13:08:46 +00:00
Emmanuele Bassi
792ffa1538 Merge branch 'float-alpha-value'
* float-alpha-value:
  [script] Parse easing modes by name
  [docs] Update the easing modes documentation
  [animation] Implement new easing functions
  [animation] Move the alpha value to floating point
2009-01-23 12:10:50 +00:00
Emmanuele Bassi
f19dd4b2b0 [actor] Add the ::pick signal to the Actor class
Since we allow overriding the paint() implementation through the
::paint signal to change the way an actor is being painted, we
should also allow overriding the pick() implementation using a
::pick signal.
2009-01-23 11:34:13 +00:00
Neil Roberts
634cdeab1f Fix some failures from the fixed-to-float script in cogl-texture
The script converted calls to COGL_FIXED_MUL(x,y) to (x*y). However
this fails for cases like this:

 COGL_FIXED_MUL(a + b, c)

which become

 (a + b * c)

The meaning of this is of course different because multiplication has
a higher precedence than addition.

This was causing breakages in cogl_texture_quad_sw when the vertex
coordinates are not in increasing order. This was the case in
test-backface-culling when NPOTs are not available.
2009-01-22 17:44:24 +00:00
Emmanuele Bassi
e7d533f176 Improve accuracy of clutter_sinx()
Improve clutter_sinx() by replacing the low precision CFX_SIN_STEP
with a multiply/divide pair. This reduces the maximum error from
1.8e-04 to 2.4e-05.

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

Based on a patch by Owen W. Taylor <otaylor@fishsoup.net>
2009-01-22 15:59:23 +00:00
Emmanuele Bassi
a1e493fadb Use the allocation to get the pick area
Since a pick is really a paint operation, we can safely get
the allocation box, instead of using get_width() and get_height().

This should help cutting down the function calls. If we were
feeling adventurous, we could even use the allocation directly
from the private data structure.

Based on a patch by Gwenole Beauchesne <gbeauchesne@splitted-desktop.org>
2009-01-22 15:55:43 +00:00
Emmanuele Bassi
e1ab6f972e [gles] Fix computation of camera distance
Port the fix in commit f409b58e to the GLES implementation of
COGL.
2009-01-22 14:52:34 +00:00
Owen W. Taylor
f409b58e89 Fix computation of camera distance
Compute the value of the camera distance as exactly half the xx
component of the projection matrix. The heuristically derived
value for 60 degrees was off by about 0.016%, causing noticeable
blurring, and other field of view angles which didn't have the
heuristic adjustment off by much more.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-22 14:17:16 +00:00
Emmanuele Bassi
a74369e309 Avoid needlessly queue redraws for invisible actors
If an actor is not set as visible, or if it is in a section of
the scenegraph that it's set as not visible (e.g. one of the
parents is not visible) then we should not queue a redraw for
it.

Patch based on code from Michael Boccara <michael@graphtech.co.il>
2009-01-22 13:58:50 +00:00
Jason Tackaberry
c998462c9f Bug 1409 - Use G_SIGNAL_RUN_LAST with ::queue-redraw signal
The intention behind ::queue-redraw is to be able to block the
default handler by attaching a callback and calling one of the
g_signal_stop_emission variants.

However this doesn't work, because ::queue-redraw has the
G_SIGNAL_RUN_FIRST flag instead of G_SIGNAL_RUN_LAST.
2009-01-22 13:38:32 +00:00
Emmanuele Bassi
01a5cb8430 Fix typo in the flags update
Epic en_GB keyboard FAIL.
2009-01-22 13:24:20 +00:00
Emmanuele Bassi
6ca40faaec [units] Fix Units in GValue and ClutterParamSpecUnit
The GValue and GParamSpec integration of ClutterUnit was still
using the old, fixed-point based logic.

Storing ClutterUnits in a GValue should use floating point values,
and ClutterParamSpecUnit should follow suit.
2009-01-22 12:11:25 +00:00
Emmanuele Bassi
1876785d12 Fix the format for a floating point value
The debug annotation was still expecting an integer after
we switched the angle to float.
2009-01-22 11:46:23 +00:00
Emmanuele Bassi
355555c1bf Store the units-per-em inside the Backend
Instead of recomputing the number of units needed to fit in
an em each time clutter_units_em() is called, we can store this
value into the default Backend along with the resolution and
font name. The value should also be updated each time the
resolution and font are changed, to keep it up to date.
2009-01-22 11:42:11 +00:00
Emmanuele Bassi
c5aca39c69 [docs] Specify the coordinate space of ButtonEvent
The coordinates of each ButtonEvent are relative to the stage that
received the event, so we should document this in the structure
annotation.

It should also be mentioned that the coordinates can be transformed
into actor-relative coordinates by using transform_stage_point().
2009-01-21 22:03:31 +00:00
Emmanuele Bassi
ee883f30d4 Add units-from-em conversion
An em is a unit of measurement in typography, equal to the point
size of the current font.

It should be possible to convert a value expressed in em to
ClutterUnits by using the current font and the current DPI as
stored by the default backend.
2009-01-21 17:35:47 +00:00
Emmanuele Bassi
93a0454c09 Remove the single-stage units converters
The stage-with/height-percentage converters had been broken by
the multiple-stages support of Clutter 0.8. They are also made
useless by the fact that Units are now floating point values.

The millimeters and typographic points converters also depended
on the default stage, but they can be reworked to use the default
DPI coming from the default Backend instead.
2009-01-21 17:10:36 +00:00
Emmanuele Bassi
0be613109e [docs] Remove sources of warnings in API references 2009-01-21 16:41:18 +00:00
Emmanuele Bassi
c9739e6aef Change the COGL texture constructor to use flags
Boolean arguments for functions are pretty evil and usually
lead to combinatorial explosion of parameters in case multiple
settings are added.

In the case of the COGL texture constructors we have a boolean
argument for enabling the auto-mipmapping; it is conceivable that
we might want to add more settings for a COGL texture without
breaking API or ABI compatibility, so the boolean argument should
become a bitmask.

The internals have not been changed: instead of checking for
a non-zero value, we check for a bitmask being set.
2009-01-21 10:14:29 +00:00
Emmanuele Bassi
5a4f9c5050 Bug 1404 - ClutterMedia issues
ClutterMedia was a rough cut at a simple media API; it needs some
re-evaluation before 1.0 in order to keep it simple to use, and
simple to implement.

- ClutterMedia:position

  The position property accessors collide with the corresponding
  ClutterActor methods, which make it impossible to bind them in
  high-level languages:

    video_texture.set_position()
    video_texture.get_position()

  In order to resolve the collision, we have to go through the
  GObject properties API:

    video_texture.set('position', value)
    value = video_texture.get('position')

  A :position in seconds is also a GStreamer-ism, and should rather
  be converted to a :progress property, with a normalized value
  between 0 and 1. the current position in seconds would then simply
  be progress*duration. For non-seekable streams, 0.0 would always
  be returned. This makes it easier to use the progress inside
  animations, Timelines or ClutterPath instances.

- ClutterMedia:volume should be renamed to :audio-volume and normalized
  as well, instead of being a floating point value between 0 and 100.

- ClutterMedia:buffer-percent should just be :buffer-fill and normalized
  between 0.0 and 1.0
2009-01-20 23:40:25 +00:00
Robert Bragg
e338245827 Renames the mesh api to the "vertex buffer api".
This better reflects the fact that the api manages sets of vertex attributes,
and the attributes really have no implied form. It is only when you use the
attributes to draw that they become mesh like; when you specify how they should
be interpreted, e.g. as triangle lists or fans etc. This rename frees up the
term "mesh", which can later be applied to a concept slightly more fitting.
E.g. at some point it would be nice to have a higher level abstraction that
sits on top of cogl vertex buffers that adds the concept of faces. (Somthing
like Blender's mesh objects.) There have also been some discussions over
particle engines, and these can be defined in terms of emitter faces; so some
other kind of mesh abstraction might be usefull here.
2009-01-20 22:29:35 +00:00
Robert Bragg
3014d4ff8a Merge branch 'cogl-float'
Okey; to summarise the changes...

We have converted Clutter and Cogl over to using floating point internally
instead of 16.16 fixed, but we have maintained the cogl-fixed API as a
utility to applications in case they want to implement their own optimizations.

The Clutter API has not changed (though ClutterFixed and ClutterUnit are now
internally floats) but all Cogl entry points have been changed to accept floats
now instead of CoglFixed.

To summarise the rationale...

There have been a number of issues with using fixed point though out Clutter
and Cogl including: lack of precision, lack of range, excessive format
conversion (GPUs tend to work nativly with IEEE floats) and maintainability.
One of the main arguments for fixed point - performance - hasn't shown
itself to be serious in practice so far since we seem to be more limited
by GPU performance and making improvements regarding how we submit data to
OpenGL[ES]/the GPU has had a more significant impact.

Ref: The recent multiple rectangle queuing changes + the
cogl-texture-agressive-batching branch which show significant performance
gains, and that recent tests on the ipodtouch (ARM + MBX) also showed no
loss of performance running with floats.

So finally; please forgive the inevitable fallout, this is a far reaching
change. There are still a few known issues with the fixed to float
conversion but enough works for all our conformance tests to pass, and the
remaining issues hopefully wont be too tricky to solve. For reference two
tags will be available either side of this change: "cogl-fixed-end" and
"cogl-float-start"
2009-01-20 18:47:50 +00:00
Emmanuele Bassi
ac1a0d568e [script] Parse easing modes by name
The easing modes for a ClutterAlpha can either be parsed by using
the enumeration "nickname" (the shorthand form of the enumeration
value) or by using the common naming policy used in other
animation frameworks, like:

        easeInCubic
        easeOutElastic
        easeInOutBounce
2009-01-20 18:24:58 +00:00
Emmanuele Bassi
268abcd786 [docs] Update the easing modes documentation
The ClutterAlpha API reference page should also list the
easing modes Clutter provides by default, by showing the
curves used by each entry in the AnimationMode enumeration.

We can also remove the incomplete graph showing the old
alpha functions.
2009-01-20 18:13:36 +00:00
Emmanuele Bassi
ec3b1a7b90 [animation] Implement new easing functions
Instead of using our own homegrown alpha functions, we should
use the easing functions also shared by other animation frameworks,
like jQuery and Tween, in the interests of code portability.

The easing functions have been defined by Robert Penner and
are divided into three categories:

        In    Out     InOut

Each category has a particular curve:

        Quadratic
        Cubic
        Quartic
        Quintic
        Sinusoidal
        Exponential
        Circular

In addition, there are "physical" curves:

        Elastic
        Back (overshooting cubic)
        Bounce (exponentially decaying parabolic)

Finally, the Linear curve is also provided as a reference.

The functions are private, and are meant to be used only
through their logical id as provided by the AnimationMode
enumeration.

The tests should be updated as well to match the new
easing functions.
2009-01-20 17:57:30 +00:00
Emmanuele Bassi
7d7372af43 [animation] Move the alpha value to floating point
The current Alpha value is an unsigned integer that can be used
implicitly as a fixed point value. This makes writing an alpha
function overshooting below and above the current range basically
impossible without complicating an already complex code, and
creating weird corner cases.

For this reason, the Alpha value should be defined as a floating
point normalized value, spanning a range between 0.0 and 1.0; in
order to allow overshooting, the valid range is extended one unit
below and one unit above, thus making it -1.0 .. 2.0.

This commit updates the various users of the ClutterAlpha API
and the tests cases.

This commit also removes all the current alpha functions exposed
in the public API.
2009-01-20 16:42:49 +00:00
Robert Bragg
c29a3b4dee [Automatic fixed-to-float.sh change] Hand coded changes for clutter-{fixed,units}
To avoid clashing with all the scripted changes, clutter-fixed.h and
clutter-units.h were manually converted to internally use floats instead of
16.16 fixed numbers.

Note: again no API changes were made in Clutter.
2009-01-20 16:20:55 +00:00
Robert Bragg
a2cf7e4a19 [Automatic fixed-to-float.sh change] Applies a number fixed to float patches
To deal with all the corner cases that couldn't be scripted a number of patches
were written for the remaining 10% of the effort.

Note: again no API changes were made in Clutter, only in Cogl.
2009-01-20 16:20:54 +00:00
Robert Bragg
e82f656590 [Automatic fixed-to-float.sh change] Applies all scripted changes
This is the result of running a number of sed and perl scripts over the code to
do 90% of the work in converting from 16.16 fixed to single precision floating
point.

Note: A pristine cogl-fixed.c has been maintained as a standalone utility API
      so that applications may still take advantage of fixed point if they
      desire for certain optimisations where lower precision may be acceptable.

Note: no API changes were made in Clutter, only in Cogl.

Overview of changes:
- Within clutter/* all usage of the COGL_FIXED_ macros have been changed to use
the CLUTTER_FIXED_ macros.

- Within cogl/* all usage of the COGL_FIXED_ macros have been completly stripped
and expanded into code that works with single precision floats instead.

- Uses of cogl_fixed_* have been replaced with single precision math.h
alternatives.

- Uses of COGL_ANGLE_* and cogl_angle_* have been replaced so we use a float for
angles and math.h replacements.
2009-01-20 16:20:54 +00:00
Robert Bragg
8b39bfec7f Improves the unit test to verify more awkward scaling and some corresponding fixes
This simplifies the mucking about with the model-view matrix that was previously
done which improves its efficiency when scaling is necessary.

Notably: There should now be no performance advantage to using
ClutterCloneTexture as a special case clone actor since this method is just as
efficient.

The unit test was renamed to test-actor-clone.
2009-01-20 11:03:50 +00:00
Robert Bragg
df7480090d Implements a generic ClutterActorClone that doesn't need fbos.
Many use cases for clonning an actor don't require running a shader on the
resulting clone image and so requiring FBOs in these cases is overkill and
in-efficient as it requires kicking and synchronizing a render for each clone.

This approach basically just uses the paint function of another actor to
implement the painting for the clone actor with some fiddling of the model-
view matrix to scale according to the different allocation box sizes of
each of the actors.

A simple unit test called test-actors2 was added for testing.
2009-01-19 16:23:49 +00:00
Owen W. Taylor
6d4cd416ec Change default tile-waste from 64 to 63
It's more sensible to use 2^n-1 for a max tile-waste value rather
than 2^n, so change the value default from 64 to 63. Example:
191 and 192 will both be sliced to 128+64 rather than having
191=>128+64, 192=>256.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-16 23:45:36 +00:00
Owen W. Taylor
b716d32000 Fix properties that have X11 types to be 'long'
While X11 Pixmap and Window types only have 32-bits of data, they
are actually 'unsigned long'. Change the "window" and "pixmap"
property of ClutterX11TexturePixmaps to be ulong.

This fixes 64-bit bugs where ClutterGLXTexturePixmap passed a
reference to Pixmap to g_object_get("pixmap", &pixmap, ...);

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-01-16 23:44:32 +00:00
Emmanuele Bassi
10f1f6587e [eglnative] Set the SYNC_MATRICES on stage realization
Since the stage in the EGL native backend only has one size, and it
is determined at realization, we can simply set the SYNC_MATRICES
private flag and let _clutter_stage_maybe_setup_viewport() set up
the GL viewport at the first redraw.
2009-01-16 22:13:44 +00:00
Emmanuele Bassi
7c93565902 [docs] Clarify what API registers a global alpha function
Both clutter_alpha_new_with_func() and clutter_alpha_set_func()
will not register a global alpha function, so we need to update
the documentation to explicitly say so.
2009-01-16 14:53:42 +00:00
Emmanuele Bassi
c096f41e70 [doc] Clarify the animation mode meaning
The animation mode parameters and properties are now slightly
anonymous unsigned longs, so we need to clarify in the documentation
that the user should either pass a ClutterAnimationMode value or
the result of registering an alpha function.
2009-01-16 14:37:42 +00:00
Emmanuele Bassi
d02819949d Remove AnimationMode from the Animation API
The animation mode symbolic id might come from the AnimationMode
enumeration or from the clutter_alpha_register_*() family of
functions. For this reason, we should use a gulong instead of
ClutterAnimationMode whenever we have an "animation mode" parameter
or property.
2009-01-16 14:37:42 +00:00
Emmanuele Bassi
74213e0ee3 [alpha] Allow registering alpha functions
In order to unify alpha functions and animation modes in ClutterAlpha
we should be able to register alpha functions and get a logical id
for them; the logical id will then be available to be used by
clutter_alpha_set_mode().

The registration requires API changes in ClutterAlpha constructors
and methods. It also provides the chance to shift ClutterAlpha
towards the use of animations modes only, and to alpha functions
as a convenience API for language bindings alone.
2009-01-16 14:37:35 +00:00
Neil Roberts
52d7b7be73 [fixed-to-float-patches] Move the changes to gles2-wrapper.h into the patch
It looks like the changes to cogl-gles2-wrapper.h were accidentally
committed to the actual file instead of the patch in commit
de27da0e. This commit moves the changes back into the patch so
cogl-gles2-wrapper.h is reverted back to master.
2009-01-16 10:50:53 +00:00
Neil Roberts
4e94500a2a Merge branch 'master' into cogl-float
The patches have been updated to apply cleanly.

The patches for the g_warnings in clutter-actor.c have been removed
because master now uses CLUTTER_UNITS_FORMAT so they aren't
necessary. The clutter-units.h patch now sets CLUTTER_UNITS_FORMAT to
'f'.
2009-01-15 18:26:22 +00:00
Neil Roberts
9339334a43 Fix GLES backends after merging the async-textures branch
The changes from the GL version of cogl-texture.c have been mirrored
in the GLES version. This adds the cogl_texture_new_from_bitmap
function and fixes the build errors.
2009-01-15 18:09:54 +00:00
Emmanuele Bassi
22183c7a8f Bug 1380 - Return booleans from CLUTTER_ACTOR_IS_* macros
If you try to use the CLUTTER_ACTOR_IS_* macros defined in ClutterActor
like this:

  typedef struct { unsigned int reactive : 1; } foo_t;

  foo_t f; f.reactive = CLUTTER_ACTOR_IS_REACTIVE (actor);

It will blow up because while the macros evaluate to 0 they can also
evaluate to non-zero values. Since most of the boolean flags in
Clutter and Clutter-based code are going to be stored like in the
example above, we should change the macros and let them evaluate
stricly either to 0 or to 1.
2009-01-14 18:18:20 +00:00
Emmanuele Bassi
41386a5f72 Remove the Effects API
The Effects API and all related symbols have been superceded by
the newly added Animation API and clutter_actor_animate().

This commit removes the Effects implementation, the documentation
and the interactive test/example code.
2009-01-14 16:56:21 +00:00
Emmanuele Bassi
5d346cca57 Emit ::load-finished for every texture load
The ::load-finished signal is emitted only when loading a texture
using clutter_texture_set_from_file(). Since this breaks user
expectations and consistency, we should also emit ::load-finished
when loading a texture from image data.
2009-01-14 15:38:04 +00:00
Emmanuele Bassi
110489ee58 Merge branch 'async-textures'
* async-textures:
  Whitespace fixes in ClutterTexture
  [async-loading] Do not force the texture size on async load
  [async-loading] Update asynchronous image loading
  Add API for extracting image size from a file
  Update/clean and apply the async-texture patch from bug #1144
2009-01-14 15:16:41 +00:00
Neil Roberts
d454bfcc87 [ClutterStageX11] Remove the handling_configure flag
Since Clutter changed to using a layout scheme the handling_configure
flag no longer works because the allocate method is not invoked
immediately during the call to set_size from the ConfigureNotify
handler. However it is also no longer neccessary because the resizes
are effectively batched up until a relayout is run so it won't cause
an infinite loop of resize and notify events anyway.
2009-01-14 15:10:50 +00:00
Emmanuele Bassi
df62a037b0 Fix compile warning for a possible uninitialized variable 2009-01-14 15:04:28 +00:00
Emmanuele Bassi
0e1bbcdc02 Add declaration of clutter_binding_pool_get_type()
The function is automagically created by G_DEFINE_TYPE(), but
it should also be declared in the header.
2009-01-14 15:03:30 +00:00
Emmanuele Bassi
a074106ded Merge branch 'animation-improvements'
* animation-improvements:
  [docs] Add ClutterAnimatable to the API reference
  Add license notice to ClutterAnimation files
  [docs] Update the ClutterAnimation section
  [animation] Extend ClutterAnimation support to all objects
  [animation] Use ClutterAnimatable inside Animation
  [animation] Add ClutterAnimatable
  [animation] Allow registering custom progress function
  [animation] Interval::compute_value should return a boolean
  Animate ClutterColor properties
2009-01-14 15:00:44 +00:00
Neil Roberts
ffc15e0962 [clutter-text] Fix x-position of cursor when moving up or down
ClutterText already has code to try to preserve the x position when
moving up or down. A target x-position is stored and the cursor is
positioned at the nearest point to that in the appropriate line when
up or down is pressed. However the target position was never cleared
so it would always target the x-position of the cursor from the first
time you pressed up or down.

To fix this the patch clears the target position in set_position and
then sets it after the call in real_move_up/down. That way pressing
up or down sets the target position and any other movement will clear
it.

To get an index for the pixel position in the line
pango_layout_line_x_to_index is used. However when x is greater than
the length of the line then the index before the last grapheme is
returned which was causing it to jump to the penultimate
character. The patch makes it add on the trailing value so that it
will jump to the last character.
2009-01-14 11:12:02 +00:00
Neil Roberts
b57c7e12d4 [clutter-text] Fix offset_to_bytes to work when pos == 0
The old function ended up returning the length of the string when pos
was zero. This caused it to insert characters at the end when the
cursor was at the beginning of the string.
2009-01-13 18:42:50 +00:00
Neil Roberts
e93c266647 [clutter-text] Don't allow control characters to be inserted
If an unbound control key is pressed (such as Ctrl+R) it would insert
a rectangle into the text.

Also zero is considered a valid unicode character by
g_unichar_validate so pressing a key such as shift would cause the
current selection to be deleted. The character isn't actually inserted
because insert_unichar disallows zeroes.
2009-01-13 18:17:17 +00:00
Neil Roberts
de114dead7 Fix GLES 2 after the multiple-texture-rectangle branch merge
The GLES 2 wrapper needs to set up some state before each
draw. Previously this was acheived by wrapping glDrawArrays. Since the
multiple-texture-rectangle branch merge, glDrawElements is used
instead so we also need a wrapper for that.

It was also directly calling glBindTexture. GLES 2 uses a wrapper for
this function so that it can cope with GL_ALPHA format textures. The
format of the current texture needs to be stored as well as the target
and object number for this to work.
2009-01-13 16:52:39 +00:00
Neil Roberts
453697fcad Update gtk-doc 'Since' field for cogl_texture_multiple_rectangles
The function has been backported to the 0.8 branch so it will also be
available in Clutter 0.8.6
2009-01-13 16:44:31 +00:00
Robert Bragg
616c082a7c Merge commit 'origin/master' into cogl-material
Conflicts:

	clutter/clutter-texture.c
	clutter/cogl/cogl-texture.h
	clutter/cogl/gles/cogl-context.c
	clutter/cogl/gles/cogl-context.h
2009-01-13 13:37:38 +00:00
Emmanuele Bassi
a9ae1c65c3 Add ClutterBindingPool:name
The BindingPool constructor should only check for duplicate pools
and then set the :name constructor-only property. If a BindingPool
is created without a name we also make a fuss about it.

It is also possible to simply dispose of a binding pool using
g_object_unref(), as long as it has been created by using
clutter_binding_pool_new() or directly with g_object_new(). Only
BindingPools attached to a class are not owned by the user.
2009-01-13 12:51:03 +00:00
Emmanuele Bassi
a4c8a70c83 Turn ClutterBindingPool a GObject
ClutterBindingPool is already "problematic" in terms of memory
management for language bindings and gobject-introspection. It
also lacks a GType.

Turning ClutterBindingPool into a GBoxed would not make much
sense, since it does not adhere to the copy/free semantics. It
could be referenced/unreferenced, but in that case we can just
as well use GObject as a base class instead of reimplemeting
a ref-counted object and then boxing it.

ClutterBindingPool is obviously a terminal class, so we just
hide the instance and class structures.
2009-01-13 12:34:59 +00:00
Robert Bragg
de27da0e5b [cogl/gles] Fixes for building for GLES 1 using floats
* This adds GLfixed -> GLfloat conversion
* redefines cogl_wrap_glBlahx macros as glBlahf
* Other misc fixes (mostly corresponding to cogl/gl equivalents)
2009-01-12 17:21:09 +00:00
Emmanuele Bassi
e730cd70b1 Whitespace fixes in ClutterTexture
Small whitespace fixes patch; ClutterTexture requires much more
love than I can provide at the moment.
2009-01-12 17:12:24 +00:00
Emmanuele Bassi
5ed62aaf76 [async-loading] Do not force the texture size on async load
The size of the texture as retrieved by the filename should
be set as the image size, not as the actor size, in order to
respect the :sync-size property.

When the asynchronous loading process terminates, we queue
a relayout so that the scene is updated.
2009-01-12 17:09:47 +00:00
Emmanuele Bassi
168d558bcf [async-loading] Update asynchronous image loading
Provide a main loop-based fallback to the asynchronous loading in
case the GLib threading support hasn't been enabled. This also
allows us to clean up the asynchronous loading machinery and have
it behave consistently across different scenarios.

Emit the ::load-finished even if the asynchronous loading from
disk was not enabled.

Finally, block clutter_texture_set_from_file() until we have an
image width and height, so that querying the texture actor size
after set_from_file() will still yield the correct result even
when asynchronous loading is set.
2009-01-12 17:00:06 +00:00
Emmanuele Bassi
1c114be31a Add API for extracting image size from a file
For the asynchronous loading we need a function call that parses
a file, given its path, and retrieves the image width and height.

This commit adds cogl_bitmap_get_size_from_file() to the CoglBitmap
API.
2009-01-12 16:52:20 +00:00
Emmanuele Bassi
946c075a2a Merge branch 'master' into async-textures 2009-01-12 14:43:53 +00:00
Havoc Pennington
be462b2ea8 Bug 1087 - virtualize stage_queue_redraw
Add a ClutterStage::queue-redraw signal.

The purpose of this signal is to allow combining the Clutter redraw
idle with another redraw idle such as gtk's (or any other one really;
this is desirable anytime Clutter is not the only thing drawing to
a toplevel window).

To override the default, you would connect to ::queue-redraw and then
stop the signal emission.
2009-01-12 14:28:39 +00:00
Robert Bragg
f09b221ade [ClutterGLXTexturePixmap] Use an RGB texture (not ARGB) for 24bpp pixmaps
By creating an ARGB texture for 24bpp pixmaps we were exposing an undefined
alpha channel to the blending and texture combine stages which resulted in
nasty artefacts. (This issue was seen on i945 + DRI2)
2009-01-12 13:15:32 +00:00
Emmanuele Bassi
ed991fe3c5 Declare G_LOG_DOMAIN for COGL
In order to get properly namespaced debug and warning messages
inside COGL code we need to define the G_LOG_DOMAIN macro.
2009-01-12 11:21:06 +00:00
Emmanuele Bassi
f911a3a7a1 Allow ensuring that a stage viewport is updated
Since we only update the GL viewport when we receive a ConfigureNotify
event on X11, we also need a function to allow other toolkits to tell
a stage that the viewport should be updated.

This commit adds clutter_stage_ensure_viewport(), a function that simply
sets the private SYNC_MATRICES flag on the stage and then queues a
redraw.

This function should be called by libraries integrating Clutter with
other toolkits, like clutter-gtk or clutter-qt.
2009-01-12 11:18:11 +00:00
Emmanuele Bassi
4f6cc0b25f [x11] Proper fix for the ClutterStage resize race
Continuation of the fix in commit 00a3c69868.

Instead of using a separate flag for the resize process, just
delay the setting of the CLUTTER_ACTOR_SYNC_MATRICES flag on the
stage to the point when we receive a ConfigureNotify event from
X11.

This commit will break the stage embedding into other toolkits.
2009-01-12 11:15:41 +00:00
Emmanuele Bassi
2693ea3ddc [docs] Documentation warnings
Fix the various warnings issued by gtk-doc when enabling the API
reference generation for both COGL and Clutter.
2009-01-09 14:26:35 +00:00
Emmanuele Bassi
00a3c69868 [x11] Fix a race condition when resizing a stage
There is a race condition when we resize a stage before showing
it on X11.

The race goes like this:

  - clutter_init() creates the default stage and realize it, which
    will cause a 640x480 Window to be created
  - call set_size(800, 600) on the stage will cause the Window to be
    resized to 800x600
  - call show() on the stage for the first time will cause COGL
    to set up an 800 by 600 GL viewport
  - the Window will be mapped, which will cause X to notify the
    window manager that the Window should be resized to 800x600
  - the window manager will approve the resize
  - X resizes the drawable to 800x600

To fix the race, we need to defer COGL from setting up the viewport
until we receive a ConfigureNotify event and the X server has resized
the Drawable.

In order to defer the call to cogl_setup_viewport() we add a new
private flag, CLUTTER_STAGE_IN_RESIZE; the flag is checked whenever
we need to change the viewport size along with the SYNC_MATRICES
private flag. Thus, cogl_setup_viewport() will be called only if
SYNC_MATRICES is set and IN_RESIZE is not set.
2009-01-09 12:06:46 +00:00
Emmanuele Bassi
efd7ad7e55 [text] Fix GObject properties in ClutterText
Some of the read-write properties of ClutterText were missing
an implementation in clutter_text_get_property(), as well as
the :position and :selection-bound properties being wrongly
converted from fixed point to integer, passing through floating
point values.
2009-01-08 17:06:04 +00:00
Emmanuele Bassi
e9ee7f049d Fix last improper usage of ClutterUnits
ClutterUnits should not be used interchangeably as, or with
ClutterFixed values. ClutterUnits should also not be assumed
to be integers.

This commit fixes the last few improper usages of ClutterUnit
values, and adds a CLUTTER_UNITS_FORMAT macro for safely printing
ClutterUnit values with printf().
2009-01-08 16:00:47 +00:00
Emmanuele Bassi
db3d2e9568 Merge branch 'animatable-iface' into animation-improvements
* animatable-iface:
  [docs] Add ClutterAnimatable to the API reference
  Add license notice to ClutterAnimation files
  [animation] Use ClutterAnimatable inside Animation
  [animation] Add ClutterAnimatable
2009-01-08 13:38:51 +00:00
Emmanuele Bassi
d340de8e00 Add license notice to ClutterAnimation files 2009-01-08 13:18:00 +00:00
Emmanuele Bassi
068ba1caf0 [animation] Extend ClutterAnimation support to all objects
Instead of limiting the use of ClutterAnimation to ClutterActor
instances, relax the constraint to include all GObject classes.

ClutterAnimation is not using actor-specific API, since it is
only using properties.

The only actor-based API is the clutter_actor_animate() family
of functions.
2009-01-08 13:13:39 +00:00
Emmanuele Bassi
60cfa5edb2 [animation] Use ClutterAnimatable inside Animation
ClutterAnimation should check if the object is implementing the
Animatable interface, and if so delegate to it the computation
of the value along the interval initial and final value, depending
on the progress.
2009-01-08 12:59:16 +00:00
Emmanuele Bassi
24808e20b3 [animation] Add ClutterAnimatable
The ClutterAnimatable interface is meant to be used by GObject
classes to override the value computation for an animatable
property within the boundaries of an interval.

It is composed of a single virtual function, animate_property();
its implementation will receive the ClutterAnimation used to
animate the object; the property name; the initial and final
interval values; and the progress factor as retrieved by the
Alpha object bound to the Animation instance.
2009-01-08 12:56:46 +00:00
Emmanuele Bassi
28b0f432b7 [animation] Allow registering custom progress function
A ClutterInterval can change the way the progress is computed
by subclassing and overriding the ::compute_value() virtual function.

It should also be possible to register a custom progress function
in the same way it is possible to register a custom transformation
function between two GValues.

This commit adds an internal, global hash table that maintains a
GType <-> progress function association; each ClutterInterval
will check if there is a progress function registered for the
GType of the initial and final values of the interval and, if
it has been found, it will call it to compute the value of the
interval depending on the progress factor.
2009-01-08 11:15:09 +00:00
Emmanuele Bassi
ff48c3ef7c [animation] Interval::compute_value should return a boolean
If the computation of the interval value depending on the progress
was not successful, ClutterInterval::compute_value() should return
this information to the caller.
2009-01-07 18:18:59 +00:00
Chris Lord
2cea22e6a0 Update/clean and apply the async-texture patch from bug #1144 2009-01-07 17:02:43 +00:00
Emmanuele Bassi
5d5b93bd2a Rename a variable masking index()
The maintainer CFLAGS found another masking of the index() function
by an helpless variable.
2009-01-07 16:41:17 +00:00
Neil Roberts
805b88d4c0 Merge branch multiple-texture-rectangle into master
Bug 1289 - Draw multiple glyphs at once

The multiple-texture-rectangle branch adds a new Cogl texture function
called cogl_texture_multiple_rectangles which is used to draw multiple
rectangles out of a texture using a single GL call. This is
significantly faster than drawing the rectangles with individual calls
on some platforms. The Pango renderer now uses this to speed up
rendering.

The conflicts are just due to the whitespace fixes in cb569a5.

Conflicts:

	clutter/cogl/gl/cogl-context.c
	clutter/cogl/gl/cogl-context.h
	clutter/cogl/gl/cogl-texture.c
2009-01-07 16:25:26 +00:00
Emmanuele Bassi
0d9c07f824 [docs] Documentation fixes
Remove the causes of warnings from the Clutter gtk-doc API reference
generation process.
2009-01-07 14:53:54 +00:00
Emmanuele Bassi
c1c7131199 [text] Do not use markup on an editable Text
An editable ClutterText should not use pango_layout_set_markup(),
as the contents of the text actor will not match the text.

Only read-only text actors should parse the contents for Pango
markup.
2009-01-07 13:48:45 +00:00
Emmanuele Bassi
368df450b2 [text] Do not ensure the cursor if not needed
If the Text actor is neither editable nor has its cursor set
to visible, then we should not be ensuring the cursor position.

This fixes a failure in the conformance test unit for the
layout cache.
2009-01-07 13:16:11 +00:00
Emmanuele Bassi
c54bd99097 Merge the ClutterText actor
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
  ...
2009-01-07 12:06:33 +00:00
Emmanuele Bassi
ad7d1b54bc Re-align ClutterText header file
The addition of the single line mode accessor methods caused the
re-alignment of the entire file.
2009-01-07 11:46:22 +00:00
Emmanuele Bassi
328534fc95 [text] Fix cursor sizing
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.
2009-01-07 11:44:54 +00:00
Emmanuele Bassi
f3142a70dc Comments and whitespace fixes to ClutterText 2009-01-07 00:43:24 +00:00
Emmanuele Bassi
43f82332dd [text] Add single-line-mode to ClutterText
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.
2009-01-07 00:25:24 +00:00
Emmanuele Bassi
8182b354b1 [text] Fix the deletion actions
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.
2009-01-06 20:54:20 +00:00
Emmanuele Bassi
3d32d464e9 [text] Use cached length when possible
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.
2009-01-06 20:52:03 +00:00
Neil Roberts
12ea2933bd [cogl-material] Restore the GL_TEXTURE_ENV_MODE after material_rectangle
The rest of Cogl expects the texture mode to be GL_MODULATE so it
needs to be restored after calling cogl_material_rectangle. Otherwise
cogl_texture_rectangle will fail to blend with the Cogl color properly
and all of the labels will be black.
2009-01-06 18:24:57 +00:00
Neil Roberts
606d34f2aa [cogl-material] Make the user_tex_coords parameter of _rectangle const
The array is only used for input so it should be const.
2009-01-06 16:09:55 +00:00
Neil Roberts
f5288b1918 Add cogl-material.h and cogl-matrix.h to libclutterinclude_HEADERS
Otherwise they won't get installed
2009-01-06 15:53:35 +00:00
Emmanuele Bassi
979b6794bb [text] Coalesce text visibility and password character
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), '*');
2009-01-06 15:22:31 +00:00
Emmanuele Bassi
854cf5d499 Animate ClutterColor properties
We can animate a ClutterColor-based property between an interval
of two colors by simply applying the factor to each color component.
2009-01-06 12:53:30 +00:00
Emmanuele Bassi
1892f8cb1d Allow localizations to change the text direction
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.
2009-01-06 12:35:19 +00:00
Neil Roberts
e4272fba69 Fix off-by-one error in clutter_stage_read_pixels
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.
2009-01-06 12:27:13 +00:00
Takao Fujiwara
8e6423a1b6 Bug 1397 - Allow localizing the command line help
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>
2009-01-06 12:15:02 +00:00
Emmanuele Bassi
1187004099 Clean up the update_pango_context() function
Logically split the various operations with whitespace so that
it's clear what does what.
2009-01-05 16:48:46 +00:00
Emmanuele Bassi
a5f9c72694 Pass the PangoContext, not the MainContext
When updating the PangoContext with the current options (font name,
options, resolution) pass the PangoContext instead of the Clutter
MainContext structure pointer.
2009-01-05 16:45:59 +00:00
Emmanuele Bassi
c79112bd3c Revert the logic of the PangoContext check
The branch that creates the global PangoContext should only run
if there is no global PangoContext already.
2009-01-05 16:44:52 +00:00
Emmanuele Bassi
700b34148b Remove the binding pool entry from the list
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.
2009-01-05 16:29:49 +00:00
Emmanuele Bassi
c988b7b736 Remove BindingPool::list_actions()
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.
2009-01-05 16:25:50 +00:00
Emmanuele Bassi
982a678053 Add ClutterActor::create_pango_context()
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.
2009-01-05 15:29:10 +00:00
Emmanuele Bassi
d622a4dd89 Rename the PangoContext creation functions
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.
2009-01-05 15:27:33 +00:00
Emmanuele Bassi
33459f63d6 Whitespace fixes 2009-01-05 15:26:57 +00:00
Neil Roberts
ff73fe3e1f Fix some animation_set_* functions so they cope if the value is the same
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.
2009-01-05 13:19:40 +00:00
Neil Roberts
39f4848b93 Fix some *_set functions so they work if the object is the same value
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.
2009-01-05 13:19:40 +00:00
Neil Roberts
62cfc6487f Fix setting the mode on a ClutterAlpha created with animation_set_alpha(NULL)
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.
2009-01-05 12:52:46 +00:00
Emmanuele Bassi
e56fe478ef Allow overriding actions inside a BindingPool
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.
2009-01-05 12:49:01 +00:00
Neil Roberts
2ed60a5270 In clutter_alpha_set_mode, set priv->mode after setting the func
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.
2009-01-05 12:47:10 +00:00
Emmanuele Bassi
55a22d5750 [text] Add select-all binding
Bind Ctrl+A to the "select all" action.
2009-01-05 12:27:45 +00:00
Emmanuele Bassi
fd2d78918b Merge branch 'units-rework'
* 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
2009-01-05 11:11:10 +00:00
Robert Bragg
377f114046 [cogl-material] improvements for cogl_material_rectangle
The API has been changed to take an explicit length for the number of
texture coordinates passed, and it's now documented that if there are
more layers to the current material than the number of texture coords
passed, then default coordinates will be generated for the other
layers.

cogl_material_rectangle should now handle the case where a single
sliced texture is supplied as a material layer by falling back to
cogl_texture_rectangle. We are nearly at the point that
cogl_texture_rectangle could be deprecated. A few issues remain
though, such as not considering waste in cogl_material_rectangle.
2008-12-24 01:35:33 +00:00
Robert Bragg
e77a784714 [cogl-material] Adds a cogl_material_set_color function
The other colors of a material; such as the ambient and diffuse color are
only relevent when we can enable lighting. This adds a basic unlit
color property.

Later cogl_set_source_color can be integrated to either modify the color
of the current source material, or maintain a special singlton CoglMaterial
that is modified by calls to cogl_set_source_color and implicitly made
current.
2008-12-24 01:35:02 +00:00
Robert Bragg
462c45da3c [cogl-material] Some improvements for how we sync CoglMaterial state with OpenGL
This flattens the three functions: cogl_material_flush_gl_material_state,
.._flush_gl_alpha_func and .._flush_gl_blend_func into one:
cogl_flush_material_gl_state which doesn't takes a material handle. (the handle
is instead taken from the context.)

This has allows us to avoid re-submitting some state to OpenGL when the
material has not been replaced.

Note: Avoiding redundant state changes for material layers isn't dealt with
in this patch.
2008-12-24 01:33:23 +00:00
Robert Bragg
4e57972bd6 [cogl-material] Converts clutter-texture/clutter-clone-texture to the material API
This converts clutter-texture to use the new CoglMaterial API instead of
cogl_texture_rectangle.

This change does not add multi-texturing support to Clutter, it's more about
aiming to deprecate cogl_texture_rectangle, and moving everything over to the
cogl_set_source(material); cogl_draw_somthing(); coding pattern.

With this patch, the code can be built with/without CoglMaterial support so we
can do comparisons of the old/new code for a transient period. (look for the
USE_COGL_MATERIAL define)

Note: The FBO paths haven't currently been tested, so they may need some
tweaks.
2008-12-24 01:31:00 +00:00
Robert Bragg
bb938ac4ff Merge branch 'master' into cogl-material
Conflicts:

	clutter/cogl/gl/cogl-context.c
	clutter/cogl/gl/cogl-context.h
2008-12-24 00:59:13 +00:00
Robert Bragg
cb569a5443 White space clean up across a number of files (only removing trailing spaces)
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
2008-12-24 00:48:32 +00:00
Emmanuele Bassi
c9cdf1ef0a Fix an empty block
Remove a stray ';' that prevented the get_bounds() method of the
ClutterBehaviourRotate to correctly return the start angle value.
2008-12-23 20:55:35 +00:00
Emmanuele Bassi
f777bc629a [docs] Document the newly added functions
Document the ClutterBackend font name accessors, and the
clutter_actor_get_pango_context() getter method.
2008-12-23 16:59:14 +00:00
Emmanuele Bassi
9389d9755d Add the ability to set the text direction
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.
2008-12-23 16:40:26 +00:00
Emmanuele Bassi
b4a3944b2b Return the default font name if no font name is set
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.
2008-12-23 16:27:54 +00:00
Emmanuele Bassi
e3785f4f45 Use the default font from the Backend
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.
2008-12-23 15:05:16 +00:00
Emmanuele Bassi
7262542155 Store the default font name inside ClutterBackend
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.
2008-12-23 15:03:11 +00:00