ctxpopup: Support toggle candidate.
Summary: Support toggle candidate. @feature Reviewers: Hermet Differential Revision: https://phab.enlightenment.org/D1789
This commit is contained in:
parent
5fd165eaf4
commit
528389b95c
|
@ -1559,6 +1559,91 @@ group { name: "preview_layout";
|
|||
}
|
||||
}
|
||||
|
||||
group { name: "toggle_layout";
|
||||
parts {
|
||||
part { name: "base";
|
||||
type: RECT;
|
||||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
min: 150 1;
|
||||
color: 56 56 56 255;
|
||||
}
|
||||
description { state: "odd" 0.0;
|
||||
inherit: "default" 0.0;
|
||||
color: 64 64 64 255;
|
||||
}
|
||||
}
|
||||
part { name: "text_base";
|
||||
type: SPACER;
|
||||
description { state: "default" 0.0;
|
||||
rel1.to: "base";
|
||||
rel2.to: "base";
|
||||
rel2.relative: 0.0 1.0;
|
||||
align: 0.0 0.5;
|
||||
min: 35 0;
|
||||
fixed: 1 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.text.type";
|
||||
type: TEXT;
|
||||
description { state: "default" 0.0;
|
||||
rel1.to: "text_base";
|
||||
rel1.offset: 5 0;
|
||||
rel2.to: "text_base";
|
||||
align: 0.0 0.5;
|
||||
fixed: 1 0;
|
||||
text {
|
||||
font: FN;
|
||||
size: 10;
|
||||
align: 0.0 0.5;
|
||||
min: 1 0;
|
||||
ellipsis: -1;
|
||||
}
|
||||
color: COL_NM;
|
||||
}
|
||||
}
|
||||
part { name: "padding1";
|
||||
type: SPACER;
|
||||
description { state: "default" 0.0;
|
||||
rel1.to: "text_base";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel2.to: "text_base";
|
||||
align: 0.0 0.5;
|
||||
min: 5 0;
|
||||
fixed: 1 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.toggle";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
rel1.to: "padding1";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel2.to: "padding2";
|
||||
rel2.relative: 0.0 1.0;
|
||||
}
|
||||
}
|
||||
part { name: "padding2";
|
||||
type: SPACER;
|
||||
description { state: "default" 0.0;
|
||||
rel1.to: "base";
|
||||
rel1.relative: 1.0 0.0;
|
||||
rel2.to: "base";
|
||||
align: 1.0 0.5;
|
||||
min: 5 0;
|
||||
fixed: 1 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program { name: "odd_item_set";
|
||||
signal: "odd,item,set";
|
||||
source: "";
|
||||
action: STATE_SET "odd" 0.0;
|
||||
target: "base";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "slider_layout";
|
||||
parts {
|
||||
part { name: "base";
|
||||
|
|
|
@ -77,6 +77,37 @@ ctxpopup_it_cb(void *data, Evas_Object *obj, void *event_info)
|
|||
ctxdata->selected_cb(ctxdata->data, obj, (void *) candidate);
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_dismiss_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
attr_value *attr = data;
|
||||
Evas_Object *box = elm_object_content_get(obj);
|
||||
Evas_Object *layout;
|
||||
Evas_Object *toggle;
|
||||
Eina_List *box_children = elm_box_children_get(box);
|
||||
Eina_List *l;
|
||||
char candidate[512];
|
||||
char buf[128];
|
||||
|
||||
if (eina_list_count(box_children) == 0) return;
|
||||
|
||||
snprintf(candidate, sizeof(candidate), "%s", attr->prepend_str);
|
||||
|
||||
EINA_LIST_FOREACH(box_children, l, layout)
|
||||
{
|
||||
toggle = elm_object_part_content_get(layout,
|
||||
"elm.swallow.toggle");
|
||||
snprintf(buf, sizeof(buf), "%d", (int) elm_check_state_get(toggle));
|
||||
strcat(candidate, buf);
|
||||
strcat(candidate, " ");
|
||||
}
|
||||
candidate[strlen(candidate) - 1] = '\0'; //Remove last appended " ".
|
||||
strcat(candidate, attr->append_str);
|
||||
|
||||
ctxpopup_data *ctxdata = evas_object_data_get(obj, "ctxpopup_data");
|
||||
ctxdata->selected_cb(ctxdata->data, obj, candidate);
|
||||
}
|
||||
|
||||
static void
|
||||
slider_dismiss_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
@ -171,6 +202,60 @@ entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
|
|||
elm_slider_value_set(slider, val);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
toggle_layout_create(Evas_Object *parent, attr_value *attr,
|
||||
const char *type, Eina_Bool toggle_val)
|
||||
{
|
||||
//Layout
|
||||
Evas_Object *layout = elm_layout_add(parent);
|
||||
elm_layout_file_set(layout, EDJE_PATH, "toggle_layout");
|
||||
evas_object_show(layout);
|
||||
|
||||
//Type
|
||||
if (type)
|
||||
elm_object_part_text_set(layout, "elm.text.type", type);
|
||||
|
||||
//Toggle
|
||||
Evas_Object *toggle = elm_check_add(layout);
|
||||
elm_object_style_set(toggle, "toggle");
|
||||
elm_object_part_text_set(toggle, "on", "Enable");
|
||||
elm_object_part_text_set(toggle, "off", "Disable");
|
||||
elm_check_state_set(toggle, toggle_val);
|
||||
evas_object_data_set(toggle, "attr", attr);
|
||||
elm_object_part_content_set(layout, "elm.swallow.toggle", toggle);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_layout_set(Evas_Object *ctxpopup, attr_value *attr)
|
||||
{
|
||||
Eina_Stringshare *type;
|
||||
Eina_Array_Iterator itr;
|
||||
unsigned int i;
|
||||
|
||||
//Box
|
||||
Evas_Object *box = elm_box_add(ctxpopup);
|
||||
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(box);
|
||||
|
||||
//Layout
|
||||
Evas_Object *layout;
|
||||
EINA_ARRAY_ITER_NEXT(attr->strs, i, type, itr)
|
||||
{
|
||||
layout = toggle_layout_create(box, attr, type,
|
||||
(Eina_Bool) roundf(attr->val[i]));
|
||||
if (i % 2) elm_object_signal_emit(layout, "odd,item,set", "");
|
||||
elm_box_pack_end(box, layout);
|
||||
}
|
||||
|
||||
elm_object_content_set(ctxpopup, box);
|
||||
evas_object_smart_callback_add(ctxpopup, "dismissed", toggle_dismiss_cb,
|
||||
(void *) attr);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
slider_layout_create(Evas_Object *parent, attr_value *attr,
|
||||
const char *type, double slider_val, Eina_Bool integer)
|
||||
|
@ -533,6 +618,11 @@ ctxpopup_candidate_list_create(edit_data *ed, attr_value *attr,
|
|||
|
||||
switch (attr->type)
|
||||
{
|
||||
case ATTR_VALUE_BOOLEAN:
|
||||
{
|
||||
toggle_layout_set(ctxpopup, attr);
|
||||
break;
|
||||
}
|
||||
case ATTR_VALUE_INTEGER:
|
||||
{
|
||||
slider_layout_set(ctxpopup, attr, EINA_TRUE);
|
||||
|
|
|
@ -453,7 +453,7 @@ type_init_thread_blocking(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|||
attr.value.cnt = 1;
|
||||
attr.value.min = 0;
|
||||
attr.value.max = 1;
|
||||
attr.value.type = ATTR_VALUE_INTEGER;
|
||||
attr.value.type = ATTR_VALUE_BOOLEAN;
|
||||
attr.value.prepend_str = ATTR_PREPEND_COLON;
|
||||
attr.value.append_str = ATTR_APPEND_SEMICOLON;
|
||||
eina_inarray_push(td->attrs, &attr);
|
||||
|
@ -468,7 +468,7 @@ type_init_thread_blocking(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|||
attr.value.cnt = 2;
|
||||
attr.value.min = 0;
|
||||
attr.value.max = 1;
|
||||
attr.value.type = ATTR_VALUE_INTEGER;
|
||||
attr.value.type = ATTR_VALUE_BOOLEAN;
|
||||
attr.value.prepend_str = ATTR_PREPEND_COLON;
|
||||
attr.value.append_str = ATTR_APPEND_SEMICOLON;
|
||||
eina_inarray_push(td->attrs, &attr);
|
||||
|
@ -526,7 +526,7 @@ type_init_thread_blocking(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|||
attr.value.cnt = 1;
|
||||
attr.value.min = 0;
|
||||
attr.value.max = 1;
|
||||
attr.value.type = ATTR_VALUE_INTEGER;
|
||||
attr.value.type = ATTR_VALUE_BOOLEAN;
|
||||
attr.value.prepend_str = ATTR_PREPEND_COLON;
|
||||
attr.value.append_str = ATTR_APPEND_SEMICOLON;
|
||||
eina_inarray_push(td->attrs, &attr);
|
||||
|
|
|
@ -41,13 +41,14 @@ typedef struct editor_s edit_data;
|
|||
|
||||
typedef enum attr_value_type
|
||||
{
|
||||
ATTR_VALUE_INTEGER = 1,
|
||||
ATTR_VALUE_FLOAT = 2,
|
||||
ATTR_VALUE_CONSTANT = 4,
|
||||
ATTR_VALUE_PART = 8,
|
||||
ATTR_VALUE_STATE = 16,
|
||||
ATTR_VALUE_IMAGE = 32,
|
||||
ATTR_VALUE_PROGRAM = 64
|
||||
ATTR_VALUE_BOOLEAN = 1,
|
||||
ATTR_VALUE_INTEGER = 2,
|
||||
ATTR_VALUE_FLOAT = 4,
|
||||
ATTR_VALUE_CONSTANT = 8,
|
||||
ATTR_VALUE_PART = 16,
|
||||
ATTR_VALUE_STATE = 32,
|
||||
ATTR_VALUE_IMAGE = 64,
|
||||
ATTR_VALUE_PROGRAM = 128
|
||||
} attr_value_type;
|
||||
|
||||
struct attr_value_s
|
||||
|
|
Loading…
Reference in New Issue