1
2/* This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Library General Public
4 * License as published by the Free Software Foundation; either
5 * version 2 of the License, or (at your option) any later version.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Library General Public License for more details.
11 *
12 * You should have received a copy of the GNU Library General Public
13 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
14 */
15#include "config.h"
16#include <gtk/gtk.h>
17
18static void
19hello (GtkButton *button)
20{
21 g_print (format: "Hello!\n");
22}
23
24static void
25quit_cb (GtkWidget *widget,
26 gpointer data)
27{
28 gboolean *done = data;
29
30 *done = TRUE;
31
32 g_main_context_wakeup (NULL);
33}
34
35int
36main (int argc, char *argv[])
37{
38 GtkWidget *window, *fixed, *button;
39 GtkWidget *fixed2, *frame;
40 gboolean done = FALSE;
41 GskTransform *transform;
42
43 gtk_init ();
44
45 window = gtk_window_new ();
46 gtk_window_set_title (GTK_WINDOW (window), title: "hello world");
47 g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
48
49 fixed = gtk_fixed_new ();
50 gtk_widget_set_halign (widget: fixed, align: GTK_ALIGN_FILL);
51 gtk_widget_set_valign (widget: fixed, align: GTK_ALIGN_FILL);
52 gtk_widget_set_hexpand (widget: fixed, TRUE);
53 gtk_widget_set_vexpand (widget: fixed, TRUE);
54
55 button = gtk_button_new ();
56 gtk_button_set_label (GTK_BUTTON (button), label: "Button");
57 g_signal_connect (button, "clicked", G_CALLBACK (hello), NULL);
58
59 gtk_fixed_put (GTK_FIXED (fixed), widget: button, x: 0, y: 0);
60
61 transform = NULL;
62 transform = gsk_transform_translate_3d (next: transform, point: &GRAPHENE_POINT3D_INIT (0, 0, 50));
63 transform = gsk_transform_perspective (next: transform, depth: 170);
64 transform = gsk_transform_translate_3d (next: transform, point: &GRAPHENE_POINT3D_INIT (50, 0, 50));
65 transform = gsk_transform_rotate (next: transform, angle: 20);
66 transform = gsk_transform_rotate_3d (next: transform, angle: 20, axis: graphene_vec3_y_axis ());
67 gtk_fixed_set_child_transform (GTK_FIXED (fixed), widget: button, transform);
68
69 frame = gtk_frame_new (label: "Frame");
70 gtk_widget_add_css_class (widget: frame, css_class: "view");
71 gtk_frame_set_child (GTK_FRAME (frame), child: fixed);
72
73 fixed2 = gtk_fixed_new ();
74
75 gtk_fixed_put (GTK_FIXED (fixed2), widget: frame, x: 0, y: 0);
76
77 transform = NULL;
78 transform = gsk_transform_translate_3d (next: transform, point: &GRAPHENE_POINT3D_INIT (0, 0, 50));
79 transform = gsk_transform_perspective (next: transform, depth: 170);
80 transform = gsk_transform_translate_3d (next: transform, point: &GRAPHENE_POINT3D_INIT (50, 0, 50));
81 transform = gsk_transform_rotate (next: transform, angle: 20);
82 transform = gsk_transform_rotate_3d (next: transform, angle: 20, axis: graphene_vec3_y_axis ());
83 gtk_fixed_set_child_transform (GTK_FIXED (fixed2), widget: frame, transform);
84
85 gtk_window_set_child (GTK_WINDOW (window), child: fixed2);
86
87 gtk_widget_show (widget: window);
88
89 while (!done)
90 g_main_context_iteration (NULL, TRUE);
91
92 return 0;
93}
94

source code of gtk/tests/testtransform.c