forked from enlightenment/efl
edje: Edje_Edit - add edje_edit_sound_tone_add() function that allows user to add new tone to collection
Summary: New function provides the ability to add new tones to currently loaded collection. It takes the name that will define new tone in collection and its frequency as parameters. @feature Reviewers: cedric, Hermet, seoz, raster CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D1023 Signed-off-by: Cedric BAIL <c.bail@partner.samsung.com>
This commit is contained in:
parent
244d42b280
commit
7c1a78cfd2
|
@ -4398,9 +4398,26 @@ edje_edit_sound_sample_add(Evas_Object *obj, const char* name, const char* snd_s
|
||||||
* @param name The name of the sound to be deleted from the edje.
|
* @param name The name of the sound to be deleted from the edje.
|
||||||
*
|
*
|
||||||
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
|
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
|
||||||
|
* @see edje_edit_sound_sample_add()
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool edje_edit_sound_sample_del(Evas_Object *obj, const char *name);
|
EAPI Eina_Bool edje_edit_sound_sample_del(Evas_Object *obj, const char *name);
|
||||||
|
|
||||||
|
/** Add new tone to the collection
|
||||||
|
*
|
||||||
|
* This function adds new tone with given frequency to the edje collection.
|
||||||
|
* The added sound sample could be used by PLAY_TONE action in any program
|
||||||
|
* of any group that is in the current collection.
|
||||||
|
*
|
||||||
|
* @param obj Object being edited.
|
||||||
|
* @param name The name that will identify tone.
|
||||||
|
* @param frequency Frequency of added tone. This value should be in range of 20 to 20000 inclusive.
|
||||||
|
*
|
||||||
|
* @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise.
|
||||||
|
* @see edje_edit_sound_tone_del()
|
||||||
|
* @since 1.11
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool edje_edit_sound_tone_add(Evas_Object *obj, const char* name, int frequency);
|
||||||
|
|
||||||
/** Delete tone from the collection
|
/** Delete tone from the collection
|
||||||
*
|
*
|
||||||
* Deletes tone from collection by its name. After successfull deletion
|
* Deletes tone from collection by its name. After successfull deletion
|
||||||
|
@ -4410,7 +4427,9 @@ EAPI Eina_Bool edje_edit_sound_sample_del(Evas_Object *obj, const char *name);
|
||||||
* @param obj Object being edited.
|
* @param obj Object being edited.
|
||||||
* @param name The name of the tone to be deleted from the edje.
|
* @param name The name of the tone to be deleted from the edje.
|
||||||
*
|
*
|
||||||
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
|
* @return @c EINA_TRUE if successful, @c EINA_FALSE otherwise.
|
||||||
|
* @see edje_edit_sound_tone_add()
|
||||||
|
* @since 1.11
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool edje_edit_sound_tone_del(Evas_Object *obj, const char* name);
|
EAPI Eina_Bool edje_edit_sound_tone_del(Evas_Object *obj, const char* name);
|
||||||
|
|
||||||
|
|
|
@ -1206,6 +1206,51 @@ edje_edit_sound_sample_del(Evas_Object *obj, const char* name)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
edje_edit_sound_tone_add(Evas_Object *obj, const char* name, int frequency)
|
||||||
|
{
|
||||||
|
if (!name) return EINA_FALSE;
|
||||||
|
if ((frequency < 20) || (frequency > 20000))
|
||||||
|
return EINA_FALSE;
|
||||||
|
|
||||||
|
GET_ED_OR_RETURN(EINA_FALSE);
|
||||||
|
|
||||||
|
Edje_Sound_Tone *sound_tone = NULL;
|
||||||
|
Edje_Sound_Tone *sound_tones_array = NULL;
|
||||||
|
unsigned int i = 0;
|
||||||
|
int id = 0;
|
||||||
|
|
||||||
|
_initialize_sound_dir(ed);
|
||||||
|
|
||||||
|
for (i = 0; i < ed->file->sound_dir->tones_count; ++i)
|
||||||
|
{
|
||||||
|
sound_tone = ed->file->sound_dir->tones + i;
|
||||||
|
if (!strcmp(name, sound_tone->name))
|
||||||
|
{
|
||||||
|
WRN("Can not add new tone because"
|
||||||
|
"tone named \"%s\" already exists.", name);
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ed->file->sound_dir->tones_count++;
|
||||||
|
|
||||||
|
sound_tones_array = realloc(ed->file->sound_dir->tones,
|
||||||
|
sizeof(Edje_Sound_Tone) *
|
||||||
|
ed->file->sound_dir->tones_count);
|
||||||
|
if (sound_tones_array)
|
||||||
|
ed->file->sound_dir->tones = sound_tones_array;
|
||||||
|
else return EINA_FALSE;
|
||||||
|
|
||||||
|
sound_tone = ed->file->sound_dir->tones +
|
||||||
|
ed->file->sound_dir->tones_count - 1;
|
||||||
|
sound_tone->name = (char*)eina_stringshare_add(name);
|
||||||
|
sound_tone->value = frequency;
|
||||||
|
sound_tone->id = id;
|
||||||
|
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
edje_edit_sound_tone_del(Evas_Object *obj, const char* name)
|
edje_edit_sound_tone_del(Evas_Object *obj, const char* name)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue