2019-11-20 20:46:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CLUTTER_PICK_CONTEXT_H
|
|
|
|
#define CLUTTER_PICK_CONTEXT_H
|
|
|
|
|
|
|
|
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
|
|
|
#error "Only <clutter/clutter.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
#include "clutter-macros.h"
|
|
|
|
#include "clutter-stage-view.h"
|
|
|
|
|
|
|
|
typedef struct _ClutterPickContext ClutterPickContext;
|
|
|
|
|
|
|
|
#define CLUTTER_TYPE_PICK_CONTEXT (clutter_pick_context_get_type ())
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
GType clutter_pick_context_get_type (void);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
ClutterPickContext * clutter_pick_context_ref (ClutterPickContext *pick_context);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_unref (ClutterPickContext *pick_context);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_destroy (ClutterPickContext *pick_context);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
2020-10-16 12:59:54 +00:00
|
|
|
ClutterPickMode clutter_pick_context_get_mode (ClutterPickContext *pick_context);
|
|
|
|
|
2020-10-16 22:13:12 +00:00
|
|
|
CLUTTER_EXPORT
|
Use graphene_ray_t to pick actors
This commit introduces a few important changes in order to
acommodate graphene_ray_t. Most of them are positive changes,
so don't panic :)
The first very visible change is that neither the actor box
nor the clip rectangles are projected before being pushed.
This required changing the parameters of the related functions
at both ClutterPickContext, and ClutterPickStack, to receive
boxes instead of vertices. These rectangles are projected on
demand now, so in the best case (first actor picked) only
one projection happens; and in the worst case, it projects
as much as it does now.
The second important change is that there are no more checks
for axis-alignment anymore. That's because picking now happens
in 3D space, using triangles.
Talking about triangles in 3D space, this is what is used now
for picking. We break down each actor rectangle in 2 triangles,
and check if the projected pick point is inside any one of them,
of if the ray intersects any one of them. The same check happens
for the clip rectangles.
Checking the projected pick point is both an optimization for the
2D case, and a workaround to graphene_ray_t problems with float
precision, which is specially visible on edges such as the top
bar.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-17 14:52:45 +00:00
|
|
|
void clutter_pick_context_log_pick (ClutterPickContext *pick_context,
|
|
|
|
const ClutterActorBox *box,
|
|
|
|
ClutterActor *actor);
|
2020-10-16 22:13:12 +00:00
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
Use graphene_ray_t to pick actors
This commit introduces a few important changes in order to
acommodate graphene_ray_t. Most of them are positive changes,
so don't panic :)
The first very visible change is that neither the actor box
nor the clip rectangles are projected before being pushed.
This required changing the parameters of the related functions
at both ClutterPickContext, and ClutterPickStack, to receive
boxes instead of vertices. These rectangles are projected on
demand now, so in the best case (first actor picked) only
one projection happens; and in the worst case, it projects
as much as it does now.
The second important change is that there are no more checks
for axis-alignment anymore. That's because picking now happens
in 3D space, using triangles.
Talking about triangles in 3D space, this is what is used now
for picking. We break down each actor rectangle in 2 triangles,
and check if the projected pick point is inside any one of them,
of if the ray intersects any one of them. The same check happens
for the clip rectangles.
Checking the projected pick point is both an optimization for the
2D case, and a workaround to graphene_ray_t problems with float
precision, which is specially visible on edges such as the top
bar.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1509
2020-10-17 14:52:45 +00:00
|
|
|
void clutter_pick_context_push_clip (ClutterPickContext *pick_context,
|
|
|
|
const ClutterActorBox *box);
|
2020-10-16 22:13:12 +00:00
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_pop_clip (ClutterPickContext *pick_context);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_push_transform (ClutterPickContext *pick_context,
|
|
|
|
const graphene_matrix_t *transform);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_get_transform (ClutterPickContext *pick_context,
|
|
|
|
graphene_matrix_t *out_matrix);
|
|
|
|
|
|
|
|
CLUTTER_EXPORT
|
|
|
|
void clutter_pick_context_pop_transform (ClutterPickContext *pick_context);
|
|
|
|
|
2019-11-20 20:46:41 +00:00
|
|
|
#endif /* CLUTTER_PICK_CONTEXT_H */
|