summaryrefslogtreecommitdiff
path: root/main/src/effect/ivug-slide.c
blob: adb38f95964e9020c329949a27136468a60ec456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *	  http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ivug-common.h"
#include "ivug-effect.h"


typedef struct {
	Evas_Object *src;
	Evas_Object *dst;

	int screen_w;
	int screen_h;
} Priv_Data;


static Effect_Data __ivug_slide_init(Evas_Object *src, Evas_Object *dst, int screen_w, int screen_h, int rotation)
{
	Priv_Data *pData = calloc(1, sizeof(Priv_Data));
	IV_ASSERT(pData != NULL);

	pData->src = src;
	pData->dst = dst;

	pData->screen_w = screen_w;
	pData->screen_h = screen_h;

	evas_object_stack_below(dst, src);

	evas_object_move(pData->src, 0, 0);

// 	ivug_slider_item_move(sd->slide[NEXT_SLIDE],  x + sd->slide[CENTER_SLIDE]->w + IMAGE_BETWEEN_MARGIN , y);

	return (Effect_Data)pData;
}

static void __ivug_slide_anim(Effect_Data data, double percent)
{
	Priv_Data *pData = (Priv_Data *)data;

	int first = 0;
	int last = -pData->screen_w -IMAGE_BETWEEN_MARGIN;

	int value = (double)first * (1.0f - percent / 100.0f) + (double)last * (percent / 100.0f);

	MSG_EFFECT_MED("Slide animation. Value=%d %f", value, percent);

	Evas_Coord ox, oy, ow, oh;
	evas_object_geometry_get(pData->src, &ox, &oy, &ow, &oh);

	evas_object_move(pData->src, value, oy);
	evas_object_move(pData->dst, value + ow + IMAGE_BETWEEN_MARGIN, oy);

}

static void __ivug_slide_pause(Effect_Data data)
{

}

static void __ivug_slide_resume(Effect_Data data)
{

}

static void __ivug_slide_finialize(Effect_Data data)
{
	Priv_Data *pData = (Priv_Data *)data;

	free(pData);

}

static double __ivug_slide_get_duration(Effect_Data data)
{
	return 0.2f;
}



Effect_Engine *ivug_slide_add(void)
{
	Effect_Engine *eng_slide = calloc(1, sizeof(Effect_Engine));
	ivug_retvm_if(eng_slide == NULL, NULL, "calloc failed");

	eng_slide->func.init = __ivug_slide_init;
	eng_slide->func.animate = __ivug_slide_anim;
	eng_slide->func.pause = __ivug_slide_pause;
	eng_slide->func.resume = __ivug_slide_resume;
	eng_slide->func.finalize = __ivug_slide_finialize;
	eng_slide->func.get_duration = __ivug_slide_get_duration;

	return eng_slide;
}