summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-06-29 13:40:16 +0000
committerMichael BOUCHAUD <michael.bouchaud@gmail.com>2012-06-29 13:40:16 +0000
commit957c18566a04c395f3cde89c43e9f0e8c6660487 (patch)
tree71a85bc85a4f5ead8de3d10d40212a4a4e04a7f3
parent9c732061a4e6231f8d04bcf138f849a573a9433d (diff)
ekbd: add aspect_fixed to retain the original aspect ratio
SVN revision: 73038
-rw-r--r--src/bin/ekbd_test.c1
-rw-r--r--src/lib/ekbd_layout.c95
-rw-r--r--src/lib/ekbd_private.h1
-rw-r--r--src/lib/ekbd_smart.c16
4 files changed, 93 insertions, 20 deletions
diff --git a/src/bin/ekbd_test.c b/src/bin/ekbd_test.c
index 40fd83d..e9b0ebc 100644
--- a/src/bin/ekbd_test.c
+++ b/src/bin/ekbd_test.c
@@ -82,6 +82,7 @@ _keyboard_add()
82 _kbd = ekbd_object_add(evas_object_evas_get(_win)); 82 _kbd = ekbd_object_add(evas_object_evas_get(_win));
83 ekbd_object_theme_set(_kbd, PACKAGE_DATA_DIR"/themes/default.edj"); 83 ekbd_object_theme_set(_kbd, PACKAGE_DATA_DIR"/themes/default.edj");
84 84
85 ekbd_object_aspect_fixed_set(_kbd, EINA_TRUE);
85 len = eina_str_join_len(buf, sizeof(buf), '/', PACKAGE_DATA_DIR, 86 len = eina_str_join_len(buf, sizeof(buf), '/', PACKAGE_DATA_DIR,
86 sizeof(PACKAGE_DATA_DIR) - 1, 87 sizeof(PACKAGE_DATA_DIR) - 1,
87 "keyboards", 9); 88 "keyboards", 9);
diff --git a/src/lib/ekbd_layout.c b/src/lib/ekbd_layout.c
index 1bb8b5d..8487db6 100644
--- a/src/lib/ekbd_layout.c
+++ b/src/lib/ekbd_layout.c
@@ -515,6 +515,23 @@ ekbd_layout_add(Smart_Data *sd, const char *path)
515 return kil; 515 return kil;
516} 516}
517 517
518void
519ekbd_layout_aspect_fixed_set(Smart_Data *sd, Eina_Bool fixed)
520{
521 if (sd->aspect_fixed != fixed)
522 {
523 sd->aspect_fixed = fixed;
524 ekbd_layout_keys_calc(sd);
525 }
526}
527
528Eina_Bool
529ekbd_layout_aspect_fixed_get(const Smart_Data *sd)
530{
531 return sd->aspect_fixed;
532}
533
534
518 535
519void 536void
520ekbd_layouts_free(Smart_Data *sd) 537ekbd_layouts_free(Smart_Data *sd)
@@ -1148,16 +1165,32 @@ _ekbd_layout_tie_calc(Smart_Data *sd)
1148 x = x + ex; 1165 x = x + ex;
1149 y = y + ey; 1166 y = y + ey;
1150 1167
1151 EINA_LIST_FOREACH(sd->down.tie->keys, l, ky) 1168 if (sd->aspect_fixed)
1152 { 1169 {
1153 ky->x = x + (rw * ky->orig_x); 1170 EINA_LIST_FOREACH(sd->down.tie->keys, l, ky)
1154 ky->y = y + (rh * ky->orig_y); 1171 {
1155 ky->w = ky->orig_w * rw; 1172 ky->x = x + (rr * ky->orig_x);
1156 ky->h = ky->orig_h * rh; 1173 ky->y = y + (rr * ky->orig_y);
1157 edje_object_scale_set(ky->obj, rr); 1174 ky->w = ky->orig_w * rr;
1158 evas_object_move(ky->obj, ky->x, ky->y); 1175 ky->h = ky->orig_h * rr;
1159 evas_object_resize(ky->obj, ky->w, ky->h); 1176 edje_object_scale_set(ky->obj, rr);
1160 } 1177 evas_object_move(ky->obj, ky->x, ky->y);
1178 evas_object_resize(ky->obj, ky->w, ky->h);
1179 }
1180 }
1181 else
1182 {
1183 EINA_LIST_FOREACH(sd->down.tie->keys, l, ky)
1184 {
1185 ky->x = x + (rw * ky->orig_x);
1186 ky->y = y + (rh * ky->orig_y);
1187 ky->w = ky->orig_w * rw;
1188 ky->h = ky->orig_h * rh;
1189 edje_object_scale_set(ky->obj, rr);
1190 evas_object_move(ky->obj, ky->x, ky->y);
1191 evas_object_resize(ky->obj, ky->w, ky->h);
1192 }
1193 }
1161} 1194}
1162 1195
1163 1196
@@ -1184,18 +1217,40 @@ ekbd_layout_keys_calc(Smart_Data *sd)
1184 evas_object_move(sd->event_obj, sd->x, sd->y); 1217 evas_object_move(sd->event_obj, sd->x, sd->y);
1185 evas_object_resize(sd->event_obj, sd->w, sd->h); 1218 evas_object_resize(sd->event_obj, sd->w, sd->h);
1186 1219
1187 EINA_LIST_FOREACH(sd->layout.keys, l, ky) 1220
1188 { 1221 if (sd->aspect_fixed)
1189 ky->x = sd->x + (rw * ky->orig_x); 1222 {
1190 ky->y = sd->y + (rh * ky->orig_y); 1223 Evas_Coord ws, hs;
1191 ky->w = ky->orig_w * rw; 1224 ws = (sd->w - (rr * sd->layout.w)) / 2;
1192 ky->h = ky->orig_h * rh; 1225 hs = (sd->h - (rr * sd->layout.h)) / 2;
1193 edje_object_scale_set(ky->obj, rr); 1226 EINA_LIST_FOREACH(sd->layout.keys, l, ky)
1194 evas_object_move(ky->obj, ky->x, ky->y); 1227 {
1195 evas_object_resize(ky->obj, ky->w, ky->h); 1228 ky->x = ws + sd->x + (rr * ky->orig_x);
1196 } 1229 ky->y = hs + sd->y + (rr * ky->orig_y);
1230 ky->w = ky->orig_w * rr;
1231 ky->h = ky->orig_h * rr;
1232 edje_object_scale_set(ky->obj, rr);
1233 evas_object_move(ky->obj, ky->x, ky->y);
1234 evas_object_resize(ky->obj, ky->w, ky->h);
1235 }
1236 }
1237 else
1238 {
1239
1240 EINA_LIST_FOREACH(sd->layout.keys, l, ky)
1241 {
1242 ky->x = sd->x + (rw * ky->orig_x);
1243 ky->y = sd->y + (rh * ky->orig_y);
1244 ky->w = ky->orig_w * rw;
1245 ky->h = ky->orig_h * rh;
1246 edje_object_scale_set(ky->obj, rr);
1247 evas_object_move(ky->obj, ky->x, ky->y);
1248 evas_object_resize(ky->obj, ky->w, ky->h);
1249 }
1250 }
1251
1197 if (sd->down.tie) 1252 if (sd->down.tie)
1198 _ekbd_layout_tie_calc(sd); 1253 _ekbd_layout_tie_calc(sd);
1199} 1254}
1200 1255
1201static void 1256static void
diff --git a/src/lib/ekbd_private.h b/src/lib/ekbd_private.h
index 05a3649..db96e54 100644
--- a/src/lib/ekbd_private.h
+++ b/src/lib/ekbd_private.h
@@ -18,6 +18,7 @@ struct _Smart_Data
18 Eina_List *layouts; 18 Eina_List *layouts;
19 Evas_Coord x, y, w, h; 19 Evas_Coord x, y, w, h;
20 const char *theme; 20 const char *theme;
21 unsigned char aspect_fixed : 1;
21 struct { 22 struct {
22 char *directory; 23 char *directory;
23 const char *file; 24 const char *file;
diff --git a/src/lib/ekbd_smart.c b/src/lib/ekbd_smart.c
index f90f457..054d523 100644
--- a/src/lib/ekbd_smart.c
+++ b/src/lib/ekbd_smart.c
@@ -48,6 +48,22 @@ ekbd_object_layout_add(Evas_Object *obj, const char *path)
48} 48}
49 49
50EAPI void 50EAPI void
51ekbd_object_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
52{
53 Smart_Data *sd = evas_object_smart_data_get(obj);
54 if (!sd) return;
55 ekbd_layout_aspect_fixed_set(sd, fixed);
56}
57
58EAPI Eina_Bool
59ekbd_object_aspect_fixed_get(const Evas_Object *obj)
60{
61 Smart_Data *sd = evas_object_smart_data_get(obj);
62 if (!sd) return;
63 return ekbd_layout_aspect_fixed_get(sd);
64}
65
66EAPI void
51ekbd_object_layout_clear(Evas_Object *obj) 67ekbd_object_layout_clear(Evas_Object *obj)
52{ 68{
53 Smart_Data *sd = evas_object_smart_data_get(obj); 69 Smart_Data *sd = evas_object_smart_data_get(obj);