Compare commits

...

4 Commits

Author SHA1 Message Date
Mike Blumenkrantz cf88a77c84 fix test 2020-01-02 14:01:15 -05:00
Marcel Hollerbach 2553005a96 asdf 2020-01-02 17:48:16 +01:00
Marcel Hollerbach 93cc296b23 efl_ui_spin_button: test wraparround
this tests the wraparround feature.
2020-01-02 17:48:15 +01:00
Marcel Hollerbach d5f5e3596b theme: make spin button work better
this is now using the EFL_UI_CLICKABLE_PART_BIND macro, which makes
multiple clicks work correctly, which improves the overall usability of
the widget.

Differential Revision: https://phab.enlightenment.org/D11000
2020-01-02 17:48:15 +01:00
4 changed files with 59 additions and 63 deletions

View File

@ -279,10 +279,6 @@ group { "efl/spin_button/horizontal/inc_button";
images.image: "sym_right_light_normal.png" COMP;
images.image: "sym_right_glow_normal.png" COMP;
images.image: "sym_right_dark_normal.png" COMP;
script {
public mouse_down = 0;
public multi_down = 0;
}
parts {
part { name: "arrow.image";
scale: 1;
@ -321,64 +317,31 @@ group { "efl/spin_button/horizontal/inc_button";
}
}
programs {
EFL_UI_CLICKABLE_PART_BIND(over)
program { name: "button_press";
signal: "mouse,down,1";
source: "over";
script {
if ((get_int(multi_down) == 0) &&
(get_int(mouse_down) == 0)) {
set_int(mouse_down, 1);
run_program(PROGRAM:"button_press2");
}
}
}
program { name: "button_press2";
action: SIGNAL_EMIT "efl,action,press" "";
after: "button_press_anim";
}
program { name: "button_press_anim";
action: STATE_SET "pressed" 0.0;
target: "arrow.image";
}
program { name: "button_unpress";
signal: "mouse,up,1";
source: "over";
script {
if (get_int(mouse_down) == 1) {
set_int(mouse_down, 0);
run_program(PROGRAM:"button_unpress2");
run_program(PROGRAM:"button_unpress_anim");
}
}
}
program { name: "button_unpress2";
action: SIGNAL_EMIT "efl,action,unpress" "";
}
program { name: "button_unpress_anim";
action: STATE_SET "default" 0.0;
target: "arrow.image";
}
program { name: "button_click";
signal: "mouse,clicked,1";
source: "over";
script {
if (get_int(multi_down) == 0) {
run_program(PROGRAM:"button_click2");
}
}
}
program { name: "action_unpressed";
signal: "efl,action,unpressed";
source: "efl";
after: "button_unpress_anim";
action: STATE_SET "default" 0.0;
target: "arrow.image";
}
program { name: "action_pressed";
signal: "efl,action,pressed";
source: "efl";
after: "button_press_anim";
}
program { name: "button_click2";
action: SIGNAL_EMIT "efl,action,click" "";
action: STATE_SET "pressed" 0.0;
target: "arrow.image";
}
program { name: "access_pressed";
signal: "efl,state,animation,activated";
@ -406,22 +369,6 @@ group { "efl/spin_button/horizontal/inc_button";
target: "arrow.image";
target: "disabler";
}
program {
name: "multi_down";
signal: "efl,action,multi,down";
source: "efl";
script {
set_int(multi_down, 1);
}
}
program {
name: "multi_up";
signal: "efl,action,multi,up";
source: "efl";
script {
set_int(multi_down, 0);
}
}
}
}

View File

@ -406,8 +406,12 @@ _spin_value(Efl_Ui_Spin *obj, Eina_Bool inc)
{
Efl_Ui_Spin_Button_Data *pd = efl_data_scope_get(obj, EFL_UI_SPIN_BUTTON_CLASS);
printf("1.: %f\n", pd->step);
double absolut_value = efl_ui_range_value_get(obj) + (inc ? pd->step : -pd->step);
printf("2.: %f\n", absolut_value);
_value_set(obj, absolut_value);
}
@ -416,6 +420,8 @@ _inc_dec_button_clicked_cb(void *data, const Efl_Event *event)
{
Efl_Ui_Spin_Button_Data *sd = efl_data_scope_get(data, MY_CLASS);
printf("--> PRESSED\n");
if (sd->entry_visible) _entry_value_apply(data);
_spin_value(data, sd->inc_button == event->object);

View File

@ -156,12 +156,53 @@ EFL_START_TEST (spin_value_dec_min)
}
EFL_END_TEST
EFL_START_TEST (spin_wraparound)
{
efl_ui_spin_button_wraparound_set(spin, EINA_TRUE);
efl_ui_range_limits_set(spin, 10, 30);
efl_ui_range_step_set(spin, 20);
efl_ui_range_value_set(spin, 20);
click_spin_part(spin, "efl.inc_button");
ck_assert_int_eq(efl_ui_range_value_get(spin), 10);
efl_ui_range_value_set(spin, 20);
click_spin_part(spin, "efl.dec_button");
ck_assert_int_eq(efl_ui_range_value_get(spin), 30);
}
EFL_END_TEST
EFL_START_TEST (spin_double_values)
{
double step = 0.1;
efl_ui_range_limits_set(spin, 10, 30);
efl_ui_range_value_set(spin, 20);
efl_ui_range_step_set(spin, step);
ck_assert(EINA_DBL_EQ(efl_ui_range_step_get(spin), step));
get_me_to_those_events(spin);
ck_assert(EINA_DBL_EQ(efl_ui_range_value_get(spin), 20.0));
printf("=======================================>\n");
for (int i = 0; i < 5; ++i)
{
printf("-> %d \n", i);
click_part(spin, "efl.inc_button");
get_me_to_those_events(spin);
}
printf("%g\n", efl_ui_range_value_get(spin));
ck_assert(EINA_DBL_EQ(efl_ui_range_value_get(spin), 20.5));
}
EFL_END_TEST
void efl_ui_test_spin_button(TCase *tc)
{
tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
tcase_add_checked_fixture(tc, spin_setup, NULL);
tcase_add_test(tc, spin_wheel_test);
tcase_add_test(tc, spin_value_inc);
tcase_add_test(tc, spin_value_inc_max);
tcase_add_test(tc, spin_value_dec_min);
//tcase_add_test(tc, spin_wheel_test);
//tcase_add_test(tc, spin_value_inc);
//tcase_add_test(tc, spin_value_inc_max);
//tcase_add_test(tc, spin_value_dec_min);
//tcase_add_test(tc, spin_wraparound);
tcase_add_test(tc, spin_double_values);
}

View File

@ -454,6 +454,7 @@ click_object_internal(Eo *obj, int dir, int flags)
{
Evas *e = evas_object_evas_get(obj);
Eina_Position2D pos = attempt_to_find_the_right_point_for_mouse_positioning(obj, dir);
printf("---> CLICKING %d %d\n", pos.x, pos.y);
evas_event_feed_mouse_move(e, pos.x, pos.y, 0, NULL);
evas_event_feed_mouse_down(e, 1, flags, 0, NULL);
evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
@ -492,6 +493,7 @@ click_part_flags(Eo *obj, const char *part, int flags)
else if (strstr(part, "bottom"))
dir |= BOTTOM;
}
printf("---> INTERNAL %p\n", content);
click_object_internal(content, dir, flags);
if (efl_isa(content, EFL_LAYOUT_SIGNAL_INTERFACE))
edje_object_message_signal_process(content);