Add combo_item widget, custom layout for the combo is working again.

This commit is contained in:
Jaime Thomas 2008-12-24 18:59:22 +00:00
parent ae938125cf
commit 5ee6ba6380
7 changed files with 99 additions and 35 deletions

View File

@ -1,7 +1,12 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */ /* vim: set sw=3 ts=3 sts=3 expandtab: */
group { group {
name: "ecdb/button"; name: "ecdb/button";
min: 50 30; alias: "ecdb/combo_item";
data {
item: "ecdb/combo_item/minw" 50;
item: "ecdb/combo_item/minh" 30;
}
parts { parts {
part { part {

View File

@ -394,12 +394,12 @@ group {
} }
rel2 { rel2 {
relative: 1.0 1.0; relative: 1.0 0.0;
offset: -1 -1; offset: -1 -1;
} }
box { box {
layout: "vertical"; layout: "min_size";
padding: 0 2; padding: 0 2;
align: 0.0 0.5; align: 0.0 0.5;
} }
@ -409,6 +409,16 @@ group {
state: "active" 0.0; state: "active" 0.0;
inherit: "default" 0.0; inherit: "default" 0.0;
color: 255 255 255 255; color: 255 255 255 255;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
} }
} }
} }

View File

@ -135,7 +135,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
if ((drive->write_speeds[i]) <= 0) if ((drive->write_speeds[i]) <= 0)
continue; continue;
b = ecdb_button_add(c2, NULL); b = ecdb_combo_item_add(c2, NULL);
if ((drive->profile_name) && (drive->profile_name[0] != '\0')) if ((drive->profile_name) && (drive->profile_name[0] != '\0'))
{ {
@ -152,7 +152,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
} }
snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]); snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]);
ecdb_button_label_set(b, buf); ecdb_combo_item_label_set(b, buf);
ecdb_combo_append(c2, b); ecdb_combo_append(c2, b);
evas_object_show(b); evas_object_show(b);
} }
@ -214,8 +214,8 @@ ecdb_burn_data_page_show(void)
EINA_LIST_FOREACH(em->drives, l, drive) EINA_LIST_FOREACH(em->drives, l, drive)
{ {
b = ecdb_button_add(c1, NULL); b = ecdb_combo_item_add(c1, NULL);
ecdb_button_label_set(b, drive->product); ecdb_combo_item_label_set(b, drive->product);
evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, c2); evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, c2);
ecdb_combo_append(c1, b); ecdb_combo_append(c1, b);
evas_object_show(b); evas_object_show(b);

View File

@ -147,7 +147,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
if ((drive->write_speeds[i]) <= 0) if ((drive->write_speeds[i]) <= 0)
continue; continue;
b = ecdb_button_add(c2, NULL); b = ecdb_combo_item_add(c2, NULL);
if ((drive->profile_name) && (drive->profile_name[0] != '\0')) if ((drive->profile_name) && (drive->profile_name[0] != '\0'))
{ {
@ -164,7 +164,7 @@ _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
} }
snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]); snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]);
ecdb_button_label_set(b, buf); ecdb_combo_item_label_set(b, buf);
ecdb_combo_append(c2, b); ecdb_combo_append(c2, b);
evas_object_show(b); evas_object_show(b);
} }
@ -229,8 +229,8 @@ ecdb_burn_image_page_show(void)
EINA_LIST_FOREACH(em->drives, l, drive) EINA_LIST_FOREACH(em->drives, l, drive)
{ {
b = ecdb_button_add(c1, NULL); b = ecdb_combo_item_add(c1, NULL);
ecdb_button_label_set(b, drive->product); ecdb_combo_item_label_set(b, drive->product);
evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, c2); evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, c2);
ecdb_combo_append(c1, b); ecdb_combo_append(c1, b);
evas_object_show(b); evas_object_show(b);

View File

@ -131,8 +131,8 @@ ecdb_erase_page_show(void)
EINA_LIST_FOREACH(em->drives, l, drive) EINA_LIST_FOREACH(em->drives, l, drive)
{ {
d = ecdb_button_add(b, NULL); d = ecdb_combo_item_add(b, NULL);
ecdb_button_label_set(d, drive->product); ecdb_combo_item_label_set(d, drive->product);
ecdb_combo_append(b, d); ecdb_combo_append(b, d);
evas_object_show(d); evas_object_show(d);
} }

View File

@ -117,6 +117,49 @@ ecdb_button_label_get(Evas_Object *b)
return edje_object_part_text_get(b, "ecdb.label"); return edje_object_part_text_get(b, "ecdb.label");
} }
/************************* COMBO ITEM ****************************************/
void
_combo_item_click_cb_call(void *data, Evas_Object *obj, const char *emission,
const char *source)
{
evas_object_smart_callback_call(obj, "clicked", NULL);
}
Evas_Object *
ecdb_combo_item_add(Evas_Object *parent, const char *name)
{
Evas_Object *ci;
ci = ecdb_widget_add(parent, name);
edje_object_file_set(ci, em->theme_path, "ecdb/combo_item");
edje_object_signal_callback_add(ci, "clicked", "ecdb",
_combo_item_click_cb_call, ci);
return ci;
}
void
ecdb_combo_item_label_set(Evas_Object *ci, const char *label)
{
edje_object_part_text_set(ci, "ecdb.label", label);
}
void
ecdb_combo_item_icon_set(Evas_Object *ci, const char *group)
{
Evas_Object *icon;
icon = ecdb_widget_add(ci, "ecdb.swallow.icon");
edje_object_file_set(icon, em->theme_path, group);
evas_object_show(icon);
}
const char *
ecdb_combo_item_label_get(Evas_Object *ci)
{
return edje_object_part_text_get(ci, "ecdb.label");
}
/************************* CHECK *********************************************/ /************************* CHECK *********************************************/
typedef struct _Check_Data Check_Data; typedef struct _Check_Data Check_Data;
@ -412,33 +455,31 @@ struct _Combo_Data
Evas_Object *, int); Evas_Object *, int);
}; };
/*
static void static void
_combo_min_size(Evas_Object *o, Evas_Object_Box_Data *p, void *data) _combo_min_size(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
{ {
Eina_List *l; Eina_List *l;
Evas_Object_Box_Option *opt; Evas_Object_Box_Option *opt;
int offset_x, offset_y; int x, y, w, h;
int w, h, y; int xc, yc, wc, hc;
int wt, ht, xt, yt;
if (eina_list_count(p->children) <= 0) if (eina_list_count(p->children) <= 0)
return; return;
evas_object_geometry_get(o, &offset_x, &offset_y, &w, &h); evas_object_geometry_get(o, &x, &y, &w, &h);
y = offset_y + (h / 2);
p->children = eina_list_nth_list(p->children, 0); p->children = eina_list_nth_list(p->children, 0);
opt = eina_list_nth(p->children, 0); h /= eina_list_count(p->children);
h = 30; if (h < 1) h = 1;
edje_object_size_min_get(opt->obj, NULL, &h);
EINA_LIST_FOREACH(p->children, l, opt) EINA_LIST_FOREACH(p->children, l, opt)
{ {
evas_object_geometry_get(opt->obj, &xc, &yc, &wc, &hc);
if ((wc != w) || (hc != h))
evas_object_resize(opt->obj, w, h); evas_object_resize(opt->obj, w, h);
evas_object_move(opt->obj, offset_x, y); if ((xc != x) || (yc != y))
evas_object_move(opt->obj, x, y);
y += h; y += h;
} }
} }
*/
// Axis preferential -- for now vertical // Axis preferential -- for now vertical
const char * const char *
@ -579,8 +620,8 @@ ecdb_combo_add(Evas_Object *parent, const char *name)
edje_object_file_set(cd->popup, em->theme_path, "ecdb/combo/popup"); edje_object_file_set(cd->popup, em->theme_path, "ecdb/combo/popup");
edje_object_signal_callback_add(cd->back, "ecdb,combo,back,dismiss", "ecdb", edje_object_signal_callback_add(cd->back, "ecdb,combo,back,dismiss", "ecdb",
_combo_moveable_click_cb, c); _combo_moveable_click_cb, c);
//edje_box_layout_register("min_size", _combo_min_size, NULL, NULL, NULL, edje_box_layout_register("min_size", _combo_min_size, NULL, NULL, NULL,
// NULL); NULL);
evas_object_pass_events_set(cd->popup, 1); evas_object_pass_events_set(cd->popup, 1);
evas_object_show(cd->popup); evas_object_show(cd->popup);
@ -621,7 +662,7 @@ ecdb_combo_expand(Evas_Object *c)
Eina_Iterator *it; Eina_Iterator *it;
Evas_Object *o; Evas_Object *o;
const Evas_Object *box; const Evas_Object *box;
const char *location; const char *location, *min_size;
char buf[1024]; char buf[1024];
int x, y, w, h, h2, padding; int x, y, w, h, h2, padding;
@ -647,17 +688,20 @@ ecdb_combo_expand(Evas_Object *c)
evas_object_box_padding_get(box, NULL, &padding); evas_object_box_padding_get(box, NULL, &padding);
h2 = -padding; h2 = -padding;
/* Now resize the attached object... There is code to do this in the
* layout, which makes more sense. However, it goes into an infinite loop,
* so resize here for now
*/
it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup, it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup,
"ecdb.box")); "ecdb.box"));
while (eina_iterator_next(it, (void **)&o)) while (eina_iterator_next(it, (void **)&o))
{ {
edje_object_size_min_get(o, NULL, &h); min_size = edje_object_data_get(o, "ecdb/combo_item/minh");
evas_object_resize(o, w, h); if (min_size)
h2 += h + padding; {
h2 += atoi(min_size);
}
else
{
printf("THEME ERROR! MISSING REQUIRED MINIMUM DATA VALUE\n");
}
h2 += padding;
} }
if (!strcmp(location, "top")) if (!strcmp(location, "top"))

View File

@ -9,6 +9,11 @@ void ecdb_button_label_set(Evas_Object *b, const char *label);
void ecdb_button_icon_set(Evas_Object *b, const char *group); void ecdb_button_icon_set(Evas_Object *b, const char *group);
const char *ecdb_button_label_get(Evas_Object *b); const char *ecdb_button_label_get(Evas_Object *b);
Evas_Object *ecdb_combo_item_add(Evas_Object *parent, const char *name);
void ecdb_combo_item_label_set(Evas_Object *ci, const char *label);
void ecdb_combo_item_icon_set(Evas_Object *ci, const char *group);
const char *ecdb_combo_item_label_get(Evas_Object *ci);
Evas_Object *ecdb_check_add(Evas_Object *parent, const char *name); Evas_Object *ecdb_check_add(Evas_Object *parent, const char *name);
void ecdb_check_label_set(Evas_Object *c, const char *label); void ecdb_check_label_set(Evas_Object *c, const char *label);
void ecdb_check_states_set(Evas_Object *c, const char *ystate, void ecdb_check_states_set(Evas_Object *c, const char *ystate,