2
* Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
#include <champlain/champlain.h>
24
zoom_in (ClutterActor *actor,
25
ClutterButtonEvent *event,
28
champlain_view_zoom_in (view);
33
zoom_out (ClutterActor *actor,
34
ClutterButtonEvent *event,
37
champlain_view_zoom_out (view);
42
make_button (char *text)
44
ClutterActor *button, *button_bg, *button_text;
45
ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
46
ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
49
button = clutter_group_new ();
51
button_bg = clutter_rectangle_new_with_color (&white);
52
clutter_container_add_actor (CLUTTER_CONTAINER (button), button_bg);
53
clutter_actor_set_opacity (button_bg, 0xcc);
55
button_text = clutter_label_new_full ("Sans 10", text, &black);
56
clutter_container_add_actor (CLUTTER_CONTAINER (button), button_text);
57
clutter_actor_get_size (button_text, &width, &height);
59
clutter_actor_set_size (button_bg, width + PADDING * 2, height + PADDING * 2);
60
clutter_actor_set_position (button_bg, 0, 0);
61
clutter_actor_set_position (button_text, PADDING, PADDING);
70
ClutterActor* actor, *stage, *buttons, *button;
71
ChamplainPolygon *polygon;
72
guint width, total_width = 0;;
75
clutter_init (&argc, &argv);
77
stage = clutter_stage_get_default ();
78
clutter_actor_set_size (stage, 800, 600);
80
/* Create the map view */
81
actor = champlain_view_new ();
82
champlain_view_set_size (CHAMPLAIN_VIEW (actor), 800, 600);
83
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
85
/* Create the buttons */
86
buttons = clutter_group_new ();
87
clutter_actor_set_position (buttons, PADDING, PADDING);
89
button = make_button ("Zoom in");
90
clutter_container_add_actor (CLUTTER_CONTAINER (buttons), button);
91
clutter_actor_set_reactive (button, TRUE);
92
clutter_actor_get_size (button, &width, NULL);
93
total_width += width + PADDING;
94
g_signal_connect (button, "button-release-event",
98
button = make_button ("Zoom out");
99
clutter_container_add_actor (CLUTTER_CONTAINER (buttons), button);
100
clutter_actor_set_reactive (button, TRUE);
101
clutter_actor_set_position (button, total_width, 0);
102
clutter_actor_get_size (button, &width, NULL);
103
total_width += width + PADDING;
104
g_signal_connect (button, "button-release-event",
105
G_CALLBACK (zoom_out),
108
clutter_container_add_actor (CLUTTER_CONTAINER (stage), buttons);
111
polygon = champlain_polygon_new ();
112
/* Cheap approx of Highway 10 */
113
champlain_polygon_append_point (polygon, 45.4095, -73.3197);
114
champlain_polygon_append_point (polygon, 45.4104, -73.2846);
115
champlain_polygon_append_point (polygon, 45.4178, -73.2239);
116
champlain_polygon_append_point (polygon, 45.4176, -73.2181);
117
champlain_polygon_append_point (polygon, 45.4151, -73.2126);
118
champlain_polygon_append_point (polygon, 45.4016, -73.1926);
119
champlain_polygon_append_point (polygon, 45.3994, -73.1877);
120
champlain_polygon_append_point (polygon, 45.4000, -73.1815);
121
champlain_polygon_append_point (polygon, 45.4151, -73.1218);
122
champlain_polygon_set_stroke_width (polygon, 5.0);
123
champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
126
polygon = champlain_polygon_new ();
127
champlain_polygon_append_point (polygon, 45.1386, -73.9196);
128
champlain_polygon_append_point (polygon, 45.1229, -73.8991);
129
champlain_polygon_append_point (polygon, 45.0946, -73.9531);
130
champlain_polygon_append_point (polygon, 45.1085, -73.9714);
131
champlain_polygon_append_point (polygon, 45.1104, -73.9761);
132
champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
133
g_object_set (polygon, "closed-path", TRUE, NULL);
134
g_object_set (polygon, "fill", TRUE, NULL);
136
/* Finish initialising the map view */
137
g_object_set (G_OBJECT (actor), "zoom-level", 9,
138
"scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL);
139
champlain_view_center_on (CHAMPLAIN_VIEW (actor), 45.466, -73.75);
141
clutter_actor_show (stage);