2537db81be43c0554dd5675d554dbb809836fcd0
[livewp] / applet / src / livewp-multiactor.c
1 /* vim: set sw=4 ts=4 et: */
2 /*
3  * This file is part of Live Wallpaper (livewp)
4  * 
5  * Copyright (C) 2010 Vlad Vasiliev
6  * Copyright (C) 2010 Tanya Makova
7  *       for the code
8  * 
9  * This software is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public License
11  * as published by the Free Software Foundation; either version 2.1 of
12  * the License, or (at your option) any later version.
13  * 
14  * This software is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this software; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23 */
24 /*******************************************************************************/
25 #include "livewp-multiactor.h"
26
27 MultiActor * multiactor_init(gchar * name, GSList * child, gint x, gint y, gint z, double scale, gboolean visible)
28 {
29     MultiActor *ma = NULL;
30     ma = g_new0(MultiActor, 1);
31     ma->name = name;
32     ma->child = child;
33     ma->x = x;
34     ma->y = y;
35     ma->z = z;
36     ma->scale = scale;
37     ma->visible = visible;
38     fprintf(stderr, "multiator init name=%s\n", ma->name);
39     return ma;
40 }
41
42 void multiactor_set_visible(MultiActor *ma, gboolean visible)
43 {
44     GSList * tmp = ma->child;
45     gboolean cur_visible;
46     while (tmp != NULL){
47         if (visible == FALSE){
48             // hide all
49             hildon_animation_actor_set_show(tmp->data, visible);
50         }else {
51             // show only needed
52             cur_visible = g_object_get_data(G_OBJECT(tmp->data), "visible");
53             if (cur_visible) hildon_animation_actor_set_show(tmp->data, visible);
54         }
55         tmp = g_slist_next(tmp);
56     }
57     ma->visible = visible;
58 }
59 void multiactor_set_scale(MultiActor *ma, double scale)
60 {
61     GSList * tmp = ma->child;
62     while (tmp != NULL){
63         hildon_animation_actor_set_scale(tmp->data, scale, scale);
64         tmp = g_slist_next(tmp);
65     }
66     ma->scale = scale;
67 }
68 void multiactor_set_position(MultiActor *ma, gint dx, gint dy, gint dz)
69 {
70     GSList *tmp = ma->child;
71     gint x, y, z;
72     while (tmp != NULL){
73         x = g_object_get_data(G_OBJECT(tmp->data), "x");
74         y = g_object_get_data(G_OBJECT(tmp->data), "y");
75         z = g_object_get_data(G_OBJECT(tmp->data), "z");
76         actor_set_position_full(tmp->data, x + dx, y + dy, z + dz);        
77         tmp = g_slist_next(tmp);
78     }
79     ma->x = dx;
80     ma->y = dy;
81     ma->z = dz;
82 }