gtk: Add GtkMatrix
This is a new object (well, boxed type, but I'm calling it object) for dealing with matrices in a more constructive way than graphene_matrix_t by keeping track of how the matrix was created. This way, reasoning about the matrix becomes easier, and we can create better ways to print it or transition from one matrix to another one. An example of this is that while a 0 degree and a 360degree rotation are both the identity matrix, doing a transition between the two would cause a rotation.
This commit is contained in:
@@ -140,6 +140,7 @@
|
||||
#include <gtk/gtkliststore.h>
|
||||
#include <gtk/gtklockbutton.h>
|
||||
#include <gtk/gtkmain.h>
|
||||
#include <gtk/gtkmatrix.h>
|
||||
#include <gtk/gtkmaplistmodel.h>
|
||||
#include <gtk/gtkmediacontrols.h>
|
||||
#include <gtk/gtkmediafile.h>
|
||||
|
||||
1086
gtk/gtkmatrix.c
Normal file
1086
gtk/gtkmatrix.c
Normal file
File diff suppressed because it is too large
Load Diff
105
gtk/gtkmatrix.h
Normal file
105
gtk/gtkmatrix.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright © 2019 Benjamin Otte
|
||||
*
|
||||
* 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.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_MATRIX_H__
|
||||
#define __GTK_MATRIX_H__
|
||||
|
||||
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <graphene.h>
|
||||
#include <gtk/gtktypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_MATRIX (gtk_matrix_get_type ())
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_MATRIX_TYPE_IDENTITY,
|
||||
GTK_MATRIX_TYPE_TRANSFORM,
|
||||
GTK_MATRIX_TYPE_TRANSLATE,
|
||||
GTK_MATRIX_TYPE_ROTATE,
|
||||
GTK_MATRIX_TYPE_SCALE
|
||||
} GtkMatrixType;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_matrix_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_ref (GtkMatrix *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_matrix_unref (GtkMatrix *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_matrix_print (GtkMatrix *self,
|
||||
GString *string);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
char * gtk_matrix_to_string (GtkMatrix *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_matrix_compute (GtkMatrix *self,
|
||||
graphene_matrix_t *out_matrix);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_matrix_equal (GtkMatrix *first,
|
||||
GtkMatrix *second) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_transition (GtkMatrix *from,
|
||||
GtkMatrix *to,
|
||||
double progress);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_get_identity (void) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_identity (GtkMatrix *next);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_transform (GtkMatrix *next,
|
||||
const graphene_matrix_t *matrix);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_translate (GtkMatrix *next,
|
||||
const graphene_point_t *point);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_translate_3d (GtkMatrix *next,
|
||||
const graphene_point3d_t *point);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_rotate (GtkMatrix *next,
|
||||
float angle);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_rotate_3d (GtkMatrix *next,
|
||||
float angle,
|
||||
const graphene_vec3_t *axis);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_scale (GtkMatrix *next,
|
||||
float factor_x,
|
||||
float factor_y);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_scale_3d (GtkMatrix *next,
|
||||
float factor_x,
|
||||
float factor_y,
|
||||
float factor_z);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrixType gtk_matrix_get_matrix_type (GtkMatrix *self) G_GNUC_PURE;
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkMatrix * gtk_matrix_get_next (GtkMatrix *self) G_GNUC_PURE;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_MATRIX_H__ */
|
||||
36
gtk/gtkmatrixprivate.h
Normal file
36
gtk/gtkmatrixprivate.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright © 2019 Benjamin Otte
|
||||
*
|
||||
* 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.1 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/>.
|
||||
*
|
||||
* Authors: Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GTK_MATRIX_PRIVATE_H__
|
||||
#define __GTK_MATRIX_PRIVATE_H__
|
||||
|
||||
#include "gtkmatrix.h"
|
||||
|
||||
#include <gsk/gsk.h>
|
||||
#include "gsk/gskrendernodeprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GskMatrixCategory gtk_matrix_categorize (GtkMatrix *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_MATRIX_PRIVATE_H__ */
|
||||
|
||||
@@ -38,6 +38,7 @@ typedef struct _GtkBuilder GtkBuilder;
|
||||
typedef struct _GtkClipboard GtkClipboard;
|
||||
typedef struct _GtkEventController GtkEventController;
|
||||
typedef struct _GtkGesture GtkGesture;
|
||||
typedef struct _GtkMatrix GtkMatrix;
|
||||
typedef struct _GtkRequisition GtkRequisition;
|
||||
typedef struct _GtkRoot GtkRoot;
|
||||
typedef struct _GtkSelectionData GtkSelectionData;
|
||||
|
||||
@@ -117,6 +117,7 @@ gtk_private_sources = files([
|
||||
'gtkkineticscrolling.c',
|
||||
'gtkkeyhash.c',
|
||||
'gtkmagnifier.c',
|
||||
'gtkmatrix.c',
|
||||
'gtkmenusectionbox.c',
|
||||
'gtkmenutracker.c',
|
||||
'gtkmenutrackeritem.c',
|
||||
|
||||
Reference in New Issue
Block a user