1
////////////////////////////////////////////////////////////////////////////////
2
//3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3
// 10 20 30 40 50 60 70 80
5
// Copyright 2010 Canonical Ltd.
7
// This program is free software: you can redistribute it and/or modify it
8
// under the terms of either or both of the following licenses:
10
// 1) the GNU Lesser General Public License version 3, as published by the
11
// Free Software Foundation; and/or
12
// 2) the GNU Lesser General Public License version 2.1, as published by
13
// the Free Software Foundation.
15
// This program is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranties of
17
// MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
18
// PURPOSE. See the applicable version of the GNU Lesser General Public
19
// License for more details.
21
// You should have received a copy of both the GNU Lesser General Public
22
// License version 3 and version 2.1 along with this program. If not, see
23
// <http://www.gnu.org/licenses/>
25
// Authored by: Mirco Müller <mirco.mueller@canonical.com>
27
////////////////////////////////////////////////////////////////////////////////
31
// gcc -Wall -Werror -g -std=c99 `pkg-config --cflags --libs gtk+-2.0
32
// clutter-1.0 clutter-gtk-0.10 clutk-0.3` test-ctk-menu-expandable.c
33
// -o test-ctk-menu-expandable
36
#include <clutter/clutter.h>
37
#include <clutk/clutk.h>
41
anim_func (gpointer data)
43
CtkMenuExpandable* menu = NULL;
44
static gfloat factor = 0.0f;
45
static gfloat step = 1.0f / 60.0f;
47
menu = CTK_MENU_EXPANDABLE (data);
49
if (factor + step > 1.0f)
52
if (factor + step < 0.0f)
57
ctk_menu_expandable_set_expansion_size_factor (menu, factor);
59
clutter_actor_queue_redraw (CLUTTER_ACTOR (menu));
70
ClutterColor green = {0, 128, 0, 255};
71
ClutterColor white = {255, 255, 255, 255};
72
ClutterActor* item_1 = NULL;
73
ClutterActor* item_2 = NULL;
74
ClutterActor* item_3 = NULL;
75
ClutterActor* item_4 = NULL;
76
ClutterActor* item_5 = NULL;
77
CtkMenuExpandable* menu = NULL;
78
CtkMenuSeperator* separator_1 = NULL;
79
CtkMenuSeperator* separator_2 = NULL;
81
cairo_surface_t* surf = NULL;
82
gfloat rgba[4] = {0.25f, 0.5f, 1.0f, 1.0f};
83
//gfloat rgba2[4] = {1.0f, 0.5f, 0.25f, 0.5f};
84
gfloat rgba_tint[4] = {0.2f, 0.2f, 0.2f, 1.0f};
85
gfloat rgba_hl[4] = {1.0f, 1.0f, 1.0f, 0.65f};
86
gfloat rgba_line[4] = {0.8f, 0.8f, 0.8f, 1.0f};
87
gfloat rgba_shadow[4] = {0.0f, 0.0f, 0.0f, 0.75f};
91
gfloat tooltip_height;
95
// don't sync to vblank, needs to be _before_ clutter_init () !!!
96
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
98
clutter_init (&dummy, NULL);
99
ctk_init (&dummy, NULL);
101
stage = clutter_stage_get_default ();
102
clutter_stage_set_color (CLUTTER_STAGE (stage), &green);
104
item_1 = clutter_text_new_full ("Coconut Medium 9", "Open...", &white);
105
clutter_actor_set_reactive (item_1, TRUE);
106
item_2 = clutter_text_new_full ("Coconut Medium 9", "Save...", &white);
107
clutter_actor_set_reactive (item_2, TRUE);
108
item_3 = clutter_text_new_full ("Coconut Medium 9", "Info...", &white);
109
clutter_actor_set_reactive (item_3, TRUE);
110
item_4 = clutter_text_new_full ("Coconut Medium 9", "Settings...", &white);
111
clutter_actor_set_reactive (item_4, TRUE);
112
item_5 = clutter_text_new_full ("Coconut Medium 9", "Quit", &white);
113
clutter_actor_set_reactive (item_5, TRUE);
115
menu = ctk_menu_expandable_new ();
116
clutter_actor_set_reactive (CLUTTER_ACTOR (menu), TRUE);
118
ctk_menu_append (CTK_MENU (menu), item_1, FALSE);
119
ctk_menu_append (CTK_MENU (menu), item_2, FALSE);
120
separator_1 = ctk_menu_seperator_new ();
121
ctk_menu_append (CTK_MENU (menu), CLUTTER_ACTOR (separator_1), FALSE);
122
ctk_menu_append (CTK_MENU (menu), item_3, FALSE);
123
ctk_menu_append (CTK_MENU (menu), item_4, FALSE);
124
separator_2 = ctk_menu_seperator_new ();
125
ctk_menu_append (CTK_MENU (menu), CLUTTER_ACTOR (separator_2), FALSE);
126
ctk_menu_append (CTK_MENU (menu), item_5, FALSE);
127
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
128
CLUTTER_ACTOR (menu));
131
ctk_menu_set_spacing (CTK_MENU (menu), 2);
132
ctk_menu_expandable_set_content_padding (menu, 4);
133
ctk_menu_expandable_set_padding (menu, 16);
134
ctk_menu_expandable_compute_style_textures (menu);
136
ctk_menu_expandable_set_anchor_position (menu, 0, 100, 40);
138
ctk_menu_expandable_set_expansion_size_factor (menu, 1.0f);
140
g_timeout_add (1000/100, anim_func, (gpointer) menu);
142
clutter_actor_show_all (stage);
b'\\ No newline at end of file'