Respecting finger size in Color Selector

SVN revision: 55358
This commit is contained in:
Otávio Pontes 2010-12-07 15:55:25 +00:00
parent 4cc750c869
commit a773649445
2 changed files with 118 additions and 72 deletions

View File

@ -33273,56 +33273,21 @@ collections {
group { name: "elm/colorselector/base/default";
parts {
part { name: "elm.l_button";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description { state: "default" 0.0;
min: 24 24;
max: 24 24;
fixed: 1 0;
rel1 {
relative: 0.0 0.33;
}
rel2 {
relative: 0.0 0.66;
}
align: 0.0 0.5;
}
}
part { name: "elm.r_button";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description {
state: "default" 0.0;
min: 24 24;
max: 24 24;
fixed: 1 0;
rel1 {
relative: 1.0 0.33;
}
rel2 {
relative: 1.0 0.66;
}
align: 1.0 0.5;
}
}
part { name: "elm.bar_bg";
type: SWALLOW;
mouse_events: 0;
description { state: "default" 0.0;
max: 99999 22;
min: 60 22;
rel1 {
relative: 0.0 0.33;
relative: 0.0 0.8;
to_x: "elm.arrow_bg";
offset: 11 0;
to_y: "elm.arrow_icon";
offset: 0 0;
}
rel2 {
relative: 1.0 0.66;
relative: 1.0 0.83;
to_x: "elm.arrow_bg";
offset: -11 0;
offset: 0 0;
}
}
}
@ -33340,36 +33305,111 @@ collections {
description { state: "default" 0.0;
rel1 {
relative: 1.0 0.17;
offset: -8 0;
offset: 3 0;
to_x: "elm.l_button";
}
rel2 {
relative: 0.0 0.83;
offset: 7 0;
offset: -4 0;
to_x: "elm.r_button";
}
}
}
part { name: "elm.arrow";
type: RECT;
mouse_events: 1;
scale: 1;
description { state: "default" 0.0;
min: 1 1;
fixed: 1 1;
align: 0 0;
rel1 {
to_x: "elm.arrow_bg";
}
rel2 {
relative: 0.0 0.17;
to_x: "elm.arrow_bg";
}
color: 0 0 0 0;
visible: 0;
}
dragable {
confine: "elm.arrow_bg";
x: 1 1 0;
y: 0 0 0;
}
}
part { name: "elm.arrow_icon";
type: SWALLOW;
mouse_events: 0;
description { state: "default" 0.0;
min: 25 15;
max: 25 15;
fixed: 1 1;
align: 0.5 0;
rel1 {
to_x: "elm.arrow";
}
rel2 {
relative: 1.0 0.0;
offset: 0 10;
to_x: "elm.arrow";
}
}
}
part { name: "event";
type: RECT;
mouse_events: 1;
description { state: "default" 0.0;
rel1 {
to: "elm.arrow_icon";
}
rel2 {
to_x: "elm.arrow_icon";
to_y: "elm.arrow_bg";
offset: 0 0;
}
color: 0 0 0 0;
}
dragable {
events: "elm.arrow";
}
}
part { name: "elm.l_button";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description { state: "default" 0.0;
min: 25 10;
min: 24 24;
fixed: 1 1;
rel1 {
relative: 0.0 0.17;
to_x: "elm.arrow_bg";
relative: 0.0 0.0;
to_y: "elm.bar_bg";
}
rel2 {
relative: 0.0 0.87;
to_x: "elm.arrow_bg";
relative: 0.0 1.0;
to_y: "elm.bar_bg";
}
align: 0.0 0.5;
}
dragable {
confine: "elm.arrow_bg";
x: 1 1 1530;
y: 0 0 0;
}
part { name: "elm.r_button";
type: SWALLOW;
mouse_events: 1;
scale: 1;
description {
state: "default" 0.0;
min: 24 24;
fixed: 1 1;
rel1 {
relative: 1.0 0.0;
to_y: "elm.bar_bg";
}
rel2 {
relative: 1.0 1.0;
to_y: "elm.bar_bg";
}
align: 1.0 0.5;
}
}
}
@ -33471,7 +33511,6 @@ collections {
type: IMAGE;
mouse_events: 1;
description { state: "default" 0.0;
rel2.offset: 0.0 -30.0;
image.normal: "icon_arrow_down.png";
}
}

View File

@ -71,7 +71,6 @@ static void _color_with_lightness(void *data);
static void _draw_rects(void *data, double x);
static void _arrow_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _colorbar_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _arrow_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool _mv_timer(void *data);
static Eina_Bool _long_press_timer(void *data);
static void _left_button_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
@ -138,13 +137,39 @@ _theme_hook(Evas_Object *obj)
_sizing_eval(obj);
}
static void
_colorselector_set_size_hints(Evas_Object *obj, int timesw, int timesh)
{
Evas_Coord minw = -1, minh = -1;
elm_coords_finger_size_adjust(timesw, &minw, timesh, &minh);
edje_object_size_min_restricted_calc(obj, &minw, &minh,
minw, minh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, -1, -1);
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1;
int i;
if (!wd) return;
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
for (i = 0; i < 4; i++)
{
if (wd->cp[i]->bg_rect)
_colorselector_set_size_hints(wd->cp[i]->bg_rect, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->bar, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->rbt, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->lbt, 1, 1);
_colorselector_set_size_hints(wd->cp[i]->colorbar, 4, 1);
}
elm_coords_finger_size_adjust(4, &minw, 4, &minh);
edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh);
evas_object_size_hint_min_set(obj, minw, minh);
@ -438,19 +463,6 @@ _colorbar_cb(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *event_info)
evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
}
static void
_arrow_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Colorselector_Data *cp = data;
Evas_Coord arrow_w, arrow_h;
evas_object_geometry_get(cp->touch_area, NULL, NULL, NULL, &arrow_h);
evas_object_geometry_get(cp->arrow, NULL, NULL, &arrow_w, NULL);
evas_object_size_hint_min_set(cp->arrow, arrow_w, arrow_h);
evas_object_size_hint_max_set(cp->arrow, arrow_w, arrow_h);
}
static Eina_Bool
_mv_timer(void *data)
{
@ -680,9 +692,6 @@ _add_colorbar(Evas_Object *obj)
evas_object_event_callback_add(wd->cp[i]->touch_area,
EVAS_CALLBACK_MOUSE_DOWN, _colorbar_cb,
wd->cp[i]);
evas_object_event_callback_add(wd->cp[i]->touch_area,
EVAS_CALLBACK_RESIZE, _arrow_resize_cb,
wd->cp[i]);
evas_object_show(wd->cp[i]->touch_area);
elm_widget_sub_object_add(obj, wd->cp[i]->touch_area);
@ -715,10 +724,8 @@ _add_colorbar(Evas_Object *obj)
_elm_theme_object_set(obj, wd->cp[i]->arrow, "colorselector", "image",
"updown");
evas_object_show(wd->cp[i]->arrow);
edje_object_part_swallow(wd->cp[i]->colorbar, "elm.arrow",
edje_object_part_swallow(wd->cp[i]->colorbar, "elm.arrow_icon",
wd->cp[i]->arrow);
evas_object_event_callback_add(wd->cp[i]->arrow, EVAS_CALLBACK_RESIZE,
_arrow_resize_cb, wd->cp[i]);
elm_widget_sub_object_add(obj, wd->cp[i]->arrow);
if (i == 2)
evas_object_color_set(wd->cp[i]->arrow, 0, 0, 0, 255);