forked from enlightenment/efl
Rajeev Ranjan(in India) made a patch for elm_button.
Reasons for this patch are as follows. 1. Clicked signal is emitted from button when mouse release region coincides with button region and there has not been any drag outside the region during pressed state. (theme change) 2. Unpressed signal is emitted from button every time we press on button and unpress it irrespective of whether we unpress in button's region or outside. (theme change) 3. The unsetting of maximum size hint has been removed from _sizing_eval function as there is a possibility that some application may set this hint and if we unset it then this information set by application will be lost. 4. Modification in test code for button to show the difference between clicked and unpressed signal emission from this widget. Added a scroller in the heirarchy to show the effect of hold on clicked signal emission. SVN revision: 55687
This commit is contained in:
parent
ed8af1383f
commit
2696d9a740
|
@ -29,3 +29,4 @@ Otavio Pontes <otavio@profusion.mobi>
|
||||||
Viktor Kojouharov <vkojouharov@gmail.com>
|
Viktor Kojouharov <vkojouharov@gmail.com>
|
||||||
Daniel Juyung Seo (SeoZ) <juyung.seo@samsung.com> <seojuyung2@gmail.com>
|
Daniel Juyung Seo (SeoZ) <juyung.seo@samsung.com> <seojuyung2@gmail.com>
|
||||||
Sangho Park <sangho.g.park@samsung.com> <gouache95@gmail.com>
|
Sangho Park <sangho.g.park@samsung.com> <gouache95@gmail.com>
|
||||||
|
Rajeev Ranjan (Rajeev) <rajeev.r@samsung.com> <rajeev.jnnce@gmail.com>
|
||||||
|
|
|
@ -2094,7 +2094,6 @@ collections {
|
||||||
}
|
}
|
||||||
description { state: "clicked" 0.0;
|
description { state: "clicked" 0.0;
|
||||||
inherit: "default" 0.0;
|
inherit: "default" 0.0;
|
||||||
visible: 1;
|
|
||||||
color: 255 255 255 255;
|
color: 255 255 255 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2126,7 +2125,7 @@ collections {
|
||||||
program {
|
program {
|
||||||
name: "button_unclick";
|
name: "button_unclick";
|
||||||
signal: "mouse,up,1";
|
signal: "mouse,up,1";
|
||||||
source: "over2";
|
source: "over3";
|
||||||
action: SIGNAL_EMIT "elm,action,unpress" "";
|
action: SIGNAL_EMIT "elm,action,unpress" "";
|
||||||
after: "button_unclick_anim";
|
after: "button_unclick_anim";
|
||||||
}
|
}
|
||||||
|
@ -2168,7 +2167,7 @@ collections {
|
||||||
}
|
}
|
||||||
program {
|
program {
|
||||||
name: "button_unclick3";
|
name: "button_unclick3";
|
||||||
signal: "mouse,up,1";
|
signal: "mouse,clicked,1";
|
||||||
source: "over2";
|
source: "over2";
|
||||||
action: SIGNAL_EMIT "elm,action,click" "";
|
action: SIGNAL_EMIT "elm,action,click" "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,26 @@ _bt_repeated(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED_
|
||||||
elm_button_label_set(obj, buf);
|
elm_button_label_set(obj, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_bt_clicked(void *data, Evas_Object * obj, void *event_info)
|
||||||
|
{
|
||||||
|
int param = (int)(data);
|
||||||
|
|
||||||
|
printf("clicked event on Button:%d\n", param);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_bt_unpressed(void *data, Evas_Object * obj, void *event_info)
|
||||||
|
{
|
||||||
|
int param = (int)(data);
|
||||||
|
|
||||||
|
printf("unpressed event on Button:%d\n", param);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *bg, *bx, *ic, *bt;
|
Evas_Object *win, *bg, *scr, *bx, *ic, *bt;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
win = elm_win_add(NULL, "buttons", ELM_WIN_BASIC);
|
win = elm_win_add(NULL, "buttons", ELM_WIN_BASIC);
|
||||||
|
@ -30,9 +46,16 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_show(bg);
|
evas_object_show(bg);
|
||||||
|
|
||||||
|
scr = elm_scroller_add(win);
|
||||||
|
elm_scroller_bounce_set(scr, EINA_FALSE, EINA_TRUE);
|
||||||
|
elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
|
||||||
|
elm_win_resize_object_add(win, scr);
|
||||||
|
evas_object_show(scr);
|
||||||
|
evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
|
||||||
bx = elm_box_add(win);
|
bx = elm_box_add(win);
|
||||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
elm_win_resize_object_add(win, bx);
|
elm_scroller_content_set(scr, bx);
|
||||||
evas_object_show(bx);
|
evas_object_show(bx);
|
||||||
|
|
||||||
ic = elm_icon_add(win);
|
ic = elm_icon_add(win);
|
||||||
|
@ -42,17 +65,21 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_button_label_set(bt, "Icon sized to button");
|
elm_button_label_set(bt, "Icon sized to button");
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
|
||||||
ic = elm_icon_add(win);
|
ic = elm_icon_add(bx);
|
||||||
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
|
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
|
||||||
elm_icon_file_set(ic, buf, NULL);
|
elm_icon_file_set(ic, buf, NULL);
|
||||||
elm_icon_scale_set(ic, 0, 0);
|
elm_icon_scale_set(ic, 0, 0);
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_button_label_set(bt, "Icon no scale");
|
elm_button_label_set(bt, "Icon no scale");
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
@ -65,6 +92,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
elm_button_label_set(bt, "Disabled Button");
|
elm_button_label_set(bt, "Disabled Button");
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
elm_object_disabled_set(bt, 1);
|
elm_object_disabled_set(bt, 1);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
@ -76,12 +105,16 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
elm_object_disabled_set(bt, 1);
|
elm_object_disabled_set(bt, 1);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_button_label_set(bt, "Label Only");
|
elm_button_label_set(bt, "Label Only");
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)5);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)5);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
|
evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
|
||||||
elm_button_autorepeat_set(bt, 1);
|
elm_button_autorepeat_set(bt, 1);
|
||||||
|
@ -95,6 +128,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
elm_icon_scale_set(ic, 0, 0);
|
elm_icon_scale_set(ic, 0, 0);
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
@ -103,6 +138,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_object_style_set(bt, "anchor");
|
elm_object_style_set(bt, "anchor");
|
||||||
elm_button_label_set(bt, "Anchor style");
|
elm_button_label_set(bt, "Anchor style");
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)7);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)7);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
|
|
||||||
|
@ -113,6 +150,8 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
bt = elm_button_add(win);
|
bt = elm_button_add(win);
|
||||||
elm_object_style_set(bt, "anchor");
|
elm_object_style_set(bt, "anchor");
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
@ -126,10 +165,12 @@ test_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
||||||
elm_object_style_set(bt, "anchor");
|
elm_object_style_set(bt, "anchor");
|
||||||
elm_button_icon_set(bt, ic);
|
elm_button_icon_set(bt, ic);
|
||||||
elm_object_disabled_set(bt, 1);
|
elm_object_disabled_set(bt, 1);
|
||||||
|
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
|
||||||
|
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);
|
||||||
elm_box_pack_end(bx, bt);
|
elm_box_pack_end(bx, bt);
|
||||||
evas_object_show(bt);
|
evas_object_show(bt);
|
||||||
evas_object_show(ic);
|
evas_object_show(ic);
|
||||||
|
evas_object_resize(win, 320, 480);
|
||||||
evas_object_show(win);
|
evas_object_show(win);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -161,14 +161,13 @@ static void
|
||||||
_sizing_eval(Evas_Object *obj)
|
_sizing_eval(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
Evas_Coord minw = -1, minh = -1;
|
||||||
|
|
||||||
if (!wd) return;
|
if (!wd) return;
|
||||||
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||||
edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
|
edje_object_size_min_restricted_calc(wd->btn, &minw, &minh, minw, minh);
|
||||||
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||||
evas_object_size_hint_min_set(obj, minw, minh);
|
evas_object_size_hint_min_set(obj, minw, minh);
|
||||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -209,7 +208,6 @@ _activate(Evas_Object *obj)
|
||||||
}
|
}
|
||||||
wd->repeating = EINA_FALSE;
|
wd->repeating = EINA_FALSE;
|
||||||
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
||||||
_signal_unpressed(obj, wd->btn, NULL, NULL); /* safe guard when the theme does not emit the 'unpress' signal */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue