OSDN Git Service

Add Bluray support
[handbrake-jp/handbrake-jp-git.git] / gtk / src / composite_example.c
1 #include <gtk/gtk.h>
2 #include "ghbcompositor.h"
3
4 // GhbCompositor example
5 int
6 main(gint argc, gchar *argv[])
7 {
8     GtkWidget *window;
9     GtkWidget *blender;
10     GtkWidget *eb_bottom;
11     GtkWidget *eb_top1;
12     GtkWidget *eb_top2;
13     GtkWidget *eb_top3;
14     GtkWidget *bottom;
15     GtkWidget *top1;
16     GtkWidget *top2;
17     GtkWidget *top3;
18     GtkWidget *table;
19     GtkWidget *image;
20
21     gtk_init(&argc, &argv);
22
23     // Make the top level window
24     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
25
26     // Only widgets that have a GdkDrawing area can be composited
27     // These would be GtkEventBox or GtkDrawingArea
28     // Create the widgets that will be composited
29     eb_bottom = gtk_event_box_new();
30     eb_top1 = gtk_event_box_new();
31     eb_top2 = gtk_event_box_new();
32     eb_top3 = gtk_event_box_new();
33
34     // Create the compositor
35     blender = ghb_compositor_new();
36
37     // Create an button to put on the bottom layer
38     bottom = gtk_button_new_with_label("Bottom");
39     image = gtk_image_new_from_stock("gtk-help", 6);
40     gtk_button_set_image(GTK_BUTTON(bottom), image);
41
42     // The button must be placed inside an event box since
43     // buttons do not have their own window.
44     gtk_container_add(GTK_CONTAINER(eb_bottom), bottom);
45
46     // Create the buttons that will be visible on the top layer
47     top1 = gtk_button_new_with_label("Top 1");
48     top2 = gtk_button_new_with_label("Top 2");
49     top3 = gtk_button_new_with_label("Top 3");
50
51     // The buttons must be placed inside an event box since
52     // buttons do not have their own window.
53     gtk_container_add(GTK_CONTAINER(eb_top1), top1);
54     gtk_container_add(GTK_CONTAINER(eb_top2), top2);
55     gtk_container_add(GTK_CONTAINER(eb_top3), top3);
56
57     // Create the table that will be the top layer
58     // Using a layout widget gives flexibility in the layout of the layer
59     table = gtk_table_new(3, 3, TRUE);
60     gtk_table_attach(GTK_TABLE(table), eb_top1, 0, 1, 0, 1, 0, 0, 0, 0);
61     gtk_table_attach(GTK_TABLE(table), eb_top2, 1, 2, 1, 2, 0, 0, 0, 0);
62     gtk_table_attach(GTK_TABLE(table), eb_top3, 2, 3, 2, 3, 0, 0, 0, 0);
63
64     // Add the blender to the main window.
65     gtk_container_add(GTK_CONTAINER(window), blender);
66
67     // Set the blenders zlist, with opacity values
68     // Bottom layer is opaque, top layer 60%
69     ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), eb_bottom, 1, 1);
70     ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), table, 2, 0.6);
71
72     // Start the show
73     gtk_widget_show_all(window);
74
75     gtk_main();
76     return 0;
77 }
78