rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=0477d6f5d00ef39178fc186db387863859a83746
commit 0477d6f5d00ef39178fc186db387863859a83746 Author: Elizabeth Shevchenko <[email protected]> Date: Wed Nov 18 09:35:43 2015 +0200 Property: fill sound sample/tone info content into property --- src/bin/ui/editors/sound_editor.c | 141 ++++-------------------- src/bin/ui/editors/sound_editor.h | 12 +++ src/bin/ui/property_sound.c | 220 ++++++++++++++++++++++++++++---------- 3 files changed, 192 insertions(+), 181 deletions(-) diff --git a/src/bin/ui/editors/sound_editor.c b/src/bin/ui/editors/sound_editor.c index f4a79e7..6e53ff6 100644 --- a/src/bin/ui/editors/sound_editor.c +++ b/src/bin/ui/editors/sound_editor.c @@ -753,86 +753,7 @@ _grid_del(void *data, eina_stringshare_del(it->format); free(it); } -/* -static Evas_Object * -_sound_info_label_add(Evas_Object *box, - const char *label) -{ - Evas_Object *item; - INFO_ADD(box, item, label, "item"); - elm_box_pack_end(box, item); - return item; -} - -static void -_sample_info_create(Evas_Object *parent, Sound_Editor *edit) -{ - Evas_Object *item; - - assert(parent != NULL); - assert(edit != NULL); - - BOX_ADD(parent, edit->sample_box, false, false); - elm_box_align_set(edit->sample_box, 0.5, 0.5); - - edit->snd_data.file_name = _sound_info_label_add(edit->sample_box, _("file name:")); - edit->snd_data.duration = _sound_info_label_add(edit->sample_box, _("duration:")); - edit->snd_data.type = _sound_info_label_add(edit->sample_box, _("type:")); - edit->snd_data.size = _sound_info_label_add(edit->sample_box, _("size:")); - - INFO_ADD(edit->sample_box, item, _("compression:"), "item"); - - EWE_COMBOBOX_ADD(item, edit->snd_data.comp); - ewe_combobox_item_add(edit->snd_data.comp, "NONE"); - ewe_combobox_item_add(edit->snd_data.comp, "RAW"); - ewe_combobox_item_add(edit->snd_data.comp, "COMP"); - ewe_combobox_item_add(edit->snd_data.comp, "LOSSY"); - ewe_combobox_item_add(edit->snd_data.comp, "AS_IS"); - elm_object_disabled_set(edit->snd_data.comp, true); - - elm_object_part_text_set(item, "label.property", _("quality:")); - SPINNER_ADD(item, edit->snd_data.quality, 45, 1000, 1, false); - elm_object_disabled_set(edit->snd_data.quality, true); - elm_object_part_content_set(item, "swallow.first", edit->snd_data.comp); - elm_object_part_content_set(item, "swallow.second", edit->snd_data.quality); - - elm_box_pack_end(edit->sample_box, item); - evas_object_hide(edit->sample_box); -} - -static void -_tone_info_create(Evas_Object *parent, Sound_Editor *edit) -{ - Evas_Object *item; - - assert(parent != NULL); - assert(edit != NULL); - - BOX_ADD(parent, edit->tone_box, false, false); - elm_box_align_set(edit->tone_box, 0.5, 0.5); - edit->snd_data.tone_name = _sound_info_label_add(edit->tone_box, _("name:")); - - INFO_ADD(edit->tone_box, item, "frequency:", "item"); - SPINNER_ADD(edit->tone_box, edit->snd_data.tone_frq, 20, 20000, 10, false); - elm_object_disabled_set(edit->snd_data.tone_frq, true); - elm_object_part_content_set(item, "swallow.first", edit->snd_data.tone_frq); - - edit->snd_data.tone_duration = _sound_info_label_add(edit->tone_box, _("duration:")); - elm_box_pack_end(edit->tone_box, item); - evas_object_hide(edit->tone_box); -} - -static void -_sound_info_create(Evas_Object *parent, Sound_Editor *edit) -{ - assert(parent != NULL); - assert(edit != NULL); - - _sample_info_create(parent, edit); - _tone_info_create(parent, edit); -} -*/ Eina_Stringshare * _sound_format_get(Eina_Stringshare *snd_src) { @@ -859,65 +780,39 @@ _sample_info_setup(Sound_Editor *edit, Eina_Stringshare *snd_src, double len) { - Eina_Stringshare *duration, *type, *type_show; - Evas_Object *content; + Selected_Sound_Data *snd_data = mem_calloc(1, sizeof(Selected_Sound_Data)); assert(edit != NULL); assert(it != NULL); assert(snd_src != NULL); - content = elm_object_part_content_unset(edit->markup, "sound_info"); - evas_object_hide(content); - - duration = eina_stringshare_printf("%.2f s", len); - elm_icon_standard_set(edit->snd_data.teg, "sound"); - elm_object_part_content_set(edit->markup, "sound_info", edit->sample_box); - - type = _sound_format_get(snd_src); - type_show = eina_stringshare_printf(_("%s Format Sound (.%s)"), it->format, type); - - elm_object_part_text_set(edit->snd_data.file_name, "label.value", it->sound_name); - elm_object_part_text_set(edit->snd_data.duration, "label.value", duration); - elm_object_part_text_set(edit->snd_data.type, "label.value", type_show); + snd_data->sound_type = SOUND_TYPE_SAMPLE; + snd_data->file_name = it->sound_name; + snd_data->duration = len; + snd_data->snd_src = _sound_format_get(snd_src);//snd_src; + snd_data->format = it->format; #ifdef HAVE_AUDIO - Eina_Stringshare *size = eina_stringshare_printf("%.2f KB", edit->io.length / 1024.0); - elm_object_part_text_set(edit->snd_data.size, "label.value", size); - eina_stringshare_del(size); + snd_data->length = edit->io.length; #endif - ewe_combobox_select_item_set(edit->snd_data.comp, it->comp); - elm_spinner_value_set(edit->snd_data.quality, it->rate); - evas_object_show(edit->sample_box); + snd_data->compression_type = it->comp; + snd_data->quality = it->rate; - eina_stringshare_del(duration); - eina_stringshare_del(type); - eina_stringshare_del(type_show); - - evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECTED, (void *)SOUND_TYPE_SAMPLE); + evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECTED, snd_data); } static void -_tone_info_setup(Sound_Editor *edit, const Item *it) +_tone_info_setup(Sound_Editor *edit __UNUSED__, const Item *it) { - Evas_Object *content; - Eina_Stringshare *duration; + Selected_Sound_Data *snd_data = mem_calloc(1, sizeof(Selected_Sound_Data)); - assert(edit != NULL); assert(it != NULL); - content = elm_object_part_content_unset(edit->markup, "sound_info"); - evas_object_hide(content); - - duration = eina_stringshare_printf("%.1f s", TONE_PLAYING_DURATION); - elm_icon_standard_set(edit->snd_data.teg, "sound"); - elm_object_part_content_set(edit->markup, "sound_info", edit->tone_box); + snd_data->sound_type = SOUND_TYPE_TONE; + snd_data->file_name = it->sound_name; + snd_data->duration = TONE_PLAYING_DURATION; + snd_data->tone_frq = it->tone_frq; - elm_object_part_text_set(edit->snd_data.tone_name, "label.value", it->sound_name); - elm_spinner_value_set(edit->snd_data.tone_frq, it->tone_frq); - elm_object_part_text_set(edit->snd_data.tone_duration, "label.value", duration); - evas_object_show(edit->tone_box); - eina_stringshare_del(duration); - - evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECTED, (void *)SOUND_TYPE_TONE); + evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECTED, snd_data); } #ifdef HAVE_AUDIO @@ -987,6 +882,8 @@ _grid_sel_sample(void *data, } #endif } + else + evas_object_smart_callback_call(ap.win, SIGNAL_SOUND_SELECTED, NULL); } static void diff --git a/src/bin/ui/editors/sound_editor.h b/src/bin/ui/editors/sound_editor.h index 817d26b..6f3ec2b 100644 --- a/src/bin/ui/editors/sound_editor.h +++ b/src/bin/ui/editors/sound_editor.h @@ -42,6 +42,18 @@ typedef enum { SOUND_TYPE_TONE } Sound_Type; +typedef struct { + Sound_Type sound_type; + Eina_Stringshare *file_name; + double duration; + Eina_Stringshare *snd_src; + Eina_Stringshare *format; + int length; + Edje_Edit_Sound_Comp compression_type; + double quality; + int tone_frq; +} Selected_Sound_Data; + /** * Delete added sounds from list * diff --git a/src/bin/ui/property_sound.c b/src/bin/ui/property_sound.c index e3c203b..e35554f 100644 --- a/src/bin/ui/property_sound.c +++ b/src/bin/ui/property_sound.c @@ -47,8 +47,11 @@ struct _Sound_Prop_Data { Evas_Object *box; Evas_Object *sound_player; + Evas_Object *sound_player_frame; + Evas_Object *sample_box; Evas_Object *tone_box; + Evas_Object *info_frame; struct { Evas_Object *tone_name; @@ -58,27 +61,81 @@ struct _Sound_Prop_Data Evas_Object *duration; Evas_Object *type; Evas_Object *size; - Evas_Object *comp; - Evas_Object *quality; + Evas_Object *compression_type; + Evas_Object *compression_quality; } snd_data; }; typedef struct _Sound_Prop_Data Sound_Prop_Data; -#define INFO_ADD(PARENT, ITEM, TEXT, STYLE) \ - ITEM = elm_layout_add(PARENT); \ - evas_object_size_hint_weight_set(ITEM, EVAS_HINT_EXPAND, 0.0); \ - evas_object_size_hint_align_set(ITEM, EVAS_HINT_FILL, 0.0); \ - elm_layout_theme_set(ITEM, "layout", "sound_editor", STYLE); \ - elm_object_part_text_set(ITEM, "elm.text", TEXT); \ - evas_object_show(ITEM); +/* accroding to Edje_Edit.h */ +static const char *edje_sound_compression[] = { N_("RAW"), + N_("COMP"), + N_("LOSSY"), + N_("AS_IS"), + NULL}; + +static Evas_Object * +prop_sound_editor_compression_type_add(Evas_Object *property, Sound_Prop_Data *pd); static Evas_Object * -_sound_info_label_add(Evas_Object *box, - const char *label) +prop_item_label_add(Evas_Object *parent, + Evas_Object **label, + const char *lab_text, + const char *text) { - Evas_Object *item; - INFO_ADD(box, item, label, "item"); - elm_box_pack_end(box, item); + assert(parent != NULL); + assert(label != NULL); + + PROPERTY_ITEM_ADD(parent, lab_text, "1swallow") + LABEL_ADD(item, *label, text) + elm_object_part_content_set(item, "elm.swallow.content", *label); + return item; +} + +static Evas_Object * +prop_sound_editor_compression_quality_add(Evas_Object *parent, + Sound_Prop_Data *pd) +{ + PROPERTY_ITEM_ADD(parent, _("compression quality/rate"), "2swallow") + SPINNER_ADD(item, pd->snd_data.compression_quality, 0, 100, 1, false) + elm_layout_content_set(item, "swallow.content1", pd->snd_data.compression_quality); + elm_object_disabled_set(pd->snd_data.compression_quality, true); + elm_spinner_value_set(pd->snd_data.compression_quality, 0); + return item; +} + +static Evas_Object * +prop_sound_editor_tone_frequency_add(Evas_Object *parent, + Sound_Prop_Data *pd) +{ + PROPERTY_ITEM_ADD(parent, _("tone frequency"), "2swallow") + SPINNER_ADD(item, pd->snd_data.tone_frq, 200, 20000, 10, false) + elm_layout_content_set(item, "swallow.content1", pd->snd_data.tone_frq); + elm_object_disabled_set(pd->snd_data.tone_frq, true); + elm_spinner_value_set(pd->snd_data.tone_frq, 200); + return item; +} + +static void +_on_sound_compression_type_change(void *data __UNUSED__, + Evas_Object *obj __UNUSED__, + void *event_info __UNUSED__) +{ +} + +static Evas_Object * +prop_sound_editor_compression_type_add(Evas_Object *parent, Sound_Prop_Data *pd) +{ + int i; + PROPERTY_ITEM_ADD(parent, _("compression type"), "1swallow"); + EWE_COMBOBOX_ADD(parent, pd->snd_data.compression_type); + /* disable for now */ + elm_object_disabled_set(pd->snd_data.compression_type, true); + for (i = 0; edje_sound_compression[i]; ewe_combobox_item_add(pd->snd_data.compression_type, edje_sound_compression[i]), i++); + + evas_object_smart_callback_add(pd->snd_data.compression_type, "selected", _on_sound_compression_type_change, pd); + elm_layout_content_set(item, "elm.swallow.content", pd->snd_data.compression_type); + return item; } @@ -90,35 +147,60 @@ _sample_info_create(Evas_Object *parent, Sound_Prop_Data *edit) assert(parent != NULL); assert(edit != NULL); - BOX_ADD(parent, edit->sample_box, false, false); - elm_box_align_set(edit->sample_box, 0.5, 0.5); - - edit->snd_data.file_name = _sound_info_label_add(edit->sample_box, _("file name:")); - edit->snd_data.duration = _sound_info_label_add(edit->sample_box, _("duration:")); - edit->snd_data.type = _sound_info_label_add(edit->sample_box, _("type:")); - edit->snd_data.size = _sound_info_label_add(edit->sample_box, _("size:")); + BOX_ADD(edit->info_frame, edit->sample_box, false, false); + elm_box_align_set(edit->sample_box, 0.5, 0.0); - INFO_ADD(edit->sample_box, item, _("compression:"), "item"); + edit->snd_data.file_name = prop_item_label_add(edit->sample_box, &edit->snd_data.file_name, _("file name:"), _(" - ")); + elm_box_pack_end(edit->sample_box, edit->snd_data.file_name); + edit->snd_data.duration = prop_item_label_add(edit->sample_box, &edit->snd_data.duration, _("duration:"), _(" - ")); + elm_box_pack_end(edit->sample_box, edit->snd_data.duration); + edit->snd_data.type = prop_item_label_add(edit->sample_box, &edit->snd_data.type, _("type:"), _(" - ")); + elm_box_pack_end(edit->sample_box, edit->snd_data.type); + edit->snd_data.size = prop_item_label_add(edit->sample_box, &edit->snd_data.size, _("size:"), _(" - ")); + elm_box_pack_end(edit->sample_box, edit->snd_data.size); - EWE_COMBOBOX_ADD(item, edit->snd_data.comp); - ewe_combobox_item_add(edit->snd_data.comp, "NONE"); - ewe_combobox_item_add(edit->snd_data.comp, "RAW"); - ewe_combobox_item_add(edit->snd_data.comp, "COMP"); - ewe_combobox_item_add(edit->snd_data.comp, "LOSSY"); - ewe_combobox_item_add(edit->snd_data.comp, "AS_IS"); - elm_object_disabled_set(edit->snd_data.comp, true); - - elm_object_part_text_set(item, "label.property", _("quality:")); - SPINNER_ADD(item, edit->snd_data.quality, 45, 1000, 1, false); - elm_object_disabled_set(edit->snd_data.quality, true); - elm_object_part_content_set(item, "swallow.first", edit->snd_data.comp); - elm_object_part_content_set(item, "swallow.second", edit->snd_data.quality); + item = prop_sound_editor_compression_type_add(edit->sample_box, edit); + elm_box_pack_end(edit->sample_box, item); + item = prop_sound_editor_compression_quality_add(edit->sample_box, edit); elm_box_pack_end(edit->sample_box, item); + evas_object_hide(edit->sample_box); } static void +_sample_info_update(Sound_Prop_Data *pd, Selected_Sound_Data *snd_data) +{ + Evas_Object *item; + Eina_Stringshare *duration, *type; + + evas_object_show(pd->sample_box); + evas_object_hide(pd->tone_box); + + elm_object_content_unset(pd->info_frame); + elm_object_content_set(pd->info_frame, pd->sample_box); + + duration = eina_stringshare_printf("%.2f s", snd_data->duration); + type = eina_stringshare_printf(_("%s Format Sound (.%s)"), snd_data->format, snd_data->snd_src); + + item = elm_object_part_content_get(pd->snd_data.file_name, "elm.swallow.content"); + elm_object_text_set(item, snd_data->file_name); + + item = elm_object_part_content_get(pd->snd_data.duration, "elm.swallow.content"); + elm_object_text_set(item, duration); + + item = elm_object_part_content_get(pd->snd_data.type, "elm.swallow.content"); + elm_object_text_set(item, type); + + Eina_Stringshare *size = eina_stringshare_printf("%.2f KB", snd_data->length / 1024.0); + item = elm_object_part_content_get(pd->snd_data.size, "elm.swallow.content"); + elm_object_text_set(item, size); + + eina_stringshare_del(duration); + eina_stringshare_del(type); +} + +static void _tone_info_create(Evas_Object *parent, Sound_Prop_Data *edit) { Evas_Object *item; @@ -126,21 +208,44 @@ _tone_info_create(Evas_Object *parent, Sound_Prop_Data *edit) assert(parent != NULL); assert(edit != NULL); - BOX_ADD(parent, edit->tone_box, false, false); - elm_box_align_set(edit->tone_box, 0.5, 0.5); + BOX_ADD(edit->info_frame, edit->tone_box, false, false); + elm_box_align_set(edit->tone_box, 0.5, 0.0); - edit->snd_data.tone_name = _sound_info_label_add(edit->tone_box, _("name:")); + edit->snd_data.tone_name = prop_item_label_add(edit->tone_box, &edit->snd_data.tone_name, _("name:"), _(" - ")); + elm_box_pack_end(edit->tone_box, edit->snd_data.tone_name); - INFO_ADD(edit->tone_box, item, "frequency:", "item"); - SPINNER_ADD(edit->tone_box, edit->snd_data.tone_frq, 20, 20000, 10, false); - elm_object_disabled_set(edit->snd_data.tone_frq, true); - elm_object_part_content_set(item, "swallow.first", edit->snd_data.tone_frq); - - edit->snd_data.tone_duration = _sound_info_label_add(edit->tone_box, _("duration:")); + item = prop_sound_editor_tone_frequency_add(edit->tone_box, edit); elm_box_pack_end(edit->tone_box, item); + + edit->snd_data.tone_duration = prop_item_label_add(edit->tone_box, &edit->snd_data.tone_duration, _("duration:"), _(" - ")); + elm_box_pack_end(edit->tone_box, edit->snd_data.tone_duration); + evas_object_hide(edit->tone_box); } +static void +_tone_info_update(Sound_Prop_Data *pd, Selected_Sound_Data *snd_data) +{ + Evas_Object *item; + Eina_Stringshare *duration; + + evas_object_hide(pd->sample_box); + evas_object_show(pd->tone_box); + + elm_object_content_unset(pd->info_frame); + elm_object_content_set(pd->info_frame, pd->tone_box); + + duration = eina_stringshare_printf("%.1f s", snd_data->duration); + + item = elm_object_part_content_get(pd->snd_data.tone_name, "elm.swallow.content"); + elm_object_text_set(item, snd_data->file_name); + + item = elm_object_part_content_get(pd->snd_data.duration, "swallow.content1"); + elm_object_text_set(item, duration); + + eina_stringshare_del(duration); +} + #undef INFO_ADD static void @@ -158,29 +263,21 @@ _on_sound_selected(void *data, Evas_Object *obj __UNUSED__, void *event_info) { - Sound_Type sound_type = (Sound_Type)event_info; + Selected_Sound_Data *snd_data = (Selected_Sound_Data *)event_info; Evas_Object *property = data; SOUND_PROP_DATA_GET() - switch (sound_type) + switch (snd_data->sound_type) { case SOUND_TYPE_SAMPLE: { - evas_object_show(pd->sample_box); - evas_object_hide(pd->tone_box); - - elm_box_unpack(pd->box, pd->tone_box); - elm_box_pack_end(pd->box, pd->sample_box); + _sample_info_update(pd, snd_data); } break; case SOUND_TYPE_TONE: { - evas_object_hide(pd->sample_box); - evas_object_show(pd->tone_box); - - elm_box_unpack(pd->box, pd->sample_box); - elm_box_pack_end(pd->box, pd->tone_box); + _tone_info_update(pd, snd_data); } break; } @@ -199,17 +296,22 @@ ui_property_sound_add(Evas_Object *parent) BOX_ADD(parent, pd->box, EINA_FALSE, EINA_FALSE); elm_box_align_set(pd->box, 0.5, 0.0); evas_object_hide(pd->box); + evas_object_data_set(pd->box, SOUND_PROP_DATA, pd); + /* Frame with sound player */ + FRAME_PROPERTY_ADD(pd->box, pd->sound_player_frame, true, _("Preview"), pd->box) pd->sound_player = elm_layout_add(parent); elm_layout_theme_set(pd->sound_player, "layout", "sound_editor", "player"); - elm_box_pack_end(pd->box, pd->sound_player); evas_object_size_hint_weight_set(pd->sound_player, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(pd->sound_player, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(pd->sound_player); + elm_object_content_set(pd->sound_player_frame, pd->sound_player); + elm_box_pack_end(pd->box, pd->sound_player_frame); + /* Frame with info */ + FRAME_PROPERTY_ADD(pd->box, pd->info_frame, true, _("Info"), pd->box) _sound_info_create(parent, pd); - - evas_object_data_set(pd->box, SOUND_PROP_DATA, pd); + elm_box_pack_end(pd->box, pd->info_frame); evas_object_smart_callback_add(ap.win, SIGNAL_SOUND_SELECTED, _on_sound_selected, pd->box); --
