forked from enlightenment/efl
edje: Edje_Edit - add functions that allows user to set and get frequency value of tones in collection
Summary: This commit contains two new functions for tones editing: edje_edit_sound_tone_frequency_set() and edje_edit_sound_tone_frequency_det() To avoid code duplication the macross GET_TONE_BY_NAME is added and the lines that performed the search of tone by name are replaced with this macro. @feature Reviewers: cedric, Hermet, seoz, raster CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D1030 Signed-off-by: Cedric BAIL <c.bail@partner.samsung.com>
This commit is contained in:
parent
76d02d1e70
commit
ad1c183897
|
@ -3690,6 +3690,27 @@ EAPI double edje_edit_sound_compression_rate_get(Evas_Object *obj, const char* s
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool edje_edit_sound_compression_rate_set(Evas_Object *obj, const char* sound, double rate);
|
EAPI Eina_Bool edje_edit_sound_compression_rate_set(Evas_Object *obj, const char* sound, double rate);
|
||||||
|
|
||||||
|
/** Set the frequency of tone.
|
||||||
|
*
|
||||||
|
* @param obj Object being edited.
|
||||||
|
* @param name The name of the tone.
|
||||||
|
* @param frequency The value of frequency of tone. This value has to be in range of 20 to 20000 inclusive.
|
||||||
|
*
|
||||||
|
* @return EINA_TRUE if successful, EINA_FALSE otherwise.
|
||||||
|
* @see edje_edit_sound_tone_frequency_get()
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool edje_edit_sound_tone_frequency_set(Evas_Object *obj, const char *name, int frequency);
|
||||||
|
|
||||||
|
/** Get the frequency of tone.
|
||||||
|
*
|
||||||
|
* @param obj Object being edited.
|
||||||
|
* @param name The name of the tone.
|
||||||
|
*
|
||||||
|
* @return The frequency of tone if succesful, otherwise returns -1.
|
||||||
|
* @see edje_edit_sound_tone_frequency_set()
|
||||||
|
*/
|
||||||
|
EAPI int edje_edit_sound_tone_frequency_get(Evas_Object *obj, const char *name);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/************************* SPECTRUM API ***********************************/
|
/************************* SPECTRUM API ***********************************/
|
||||||
|
|
|
@ -1019,6 +1019,18 @@ _initialize_sound_dir(Edje *ed)
|
||||||
ed->file->sound_dir->tones_count = 0;
|
ed->file->sound_dir->tones_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GET_TONE_BY_NAME(_tone_p, _name) \
|
||||||
|
{ \
|
||||||
|
unsigned int i = 0; \
|
||||||
|
for (i = 0; i < ed->file->sound_dir->tones_count; ++i) \
|
||||||
|
{ \
|
||||||
|
_tone_p = ed->file->sound_dir->tones + i; \
|
||||||
|
if (!strcmp(_name, _tone_p->name)) \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
if (i == ed->file->sound_dir->tones_count) _tone_p = NULL; \
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
edje_edit_sound_sample_add(Evas_Object *obj, const char* name, const char* snd_src)
|
edje_edit_sound_sample_add(Evas_Object *obj, const char* name, const char* snd_src)
|
||||||
{
|
{
|
||||||
|
@ -1168,9 +1180,6 @@ edje_edit_sound_sample_del(Evas_Object *obj, const char* name)
|
||||||
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)
|
||||||
{
|
{
|
||||||
Edje_Sound_Tone *sound_tone = NULL;
|
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
GET_ED_OR_RETURN(EINA_FALSE);
|
GET_ED_OR_RETURN(EINA_FALSE);
|
||||||
|
|
||||||
if (!name) return EINA_FALSE;
|
if (!name) return EINA_FALSE;
|
||||||
|
@ -1183,17 +1192,13 @@ edje_edit_sound_tone_del(Evas_Object *obj, const char* name)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ed->file->sound_dir->tones_count; ++i)
|
Edje_Sound_Tone *sound_tone;
|
||||||
{
|
GET_TONE_BY_NAME(sound_tone, name);
|
||||||
sound_tone = ed->file->sound_dir->tones + i;
|
if (!sound_tone)
|
||||||
if (!strcmp(name, sound_tone->name))
|
{
|
||||||
break;
|
WRN("Unable to delete tone \"%s\". It does not exist.", name);
|
||||||
}
|
return EINA_FALSE;
|
||||||
if (i == ed->file->sound_dir->tones_count)
|
}
|
||||||
{
|
|
||||||
WRN("Unable to delete tone \"%s\". It does not exist.", name);
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Eet_File *eetf;
|
Eet_File *eetf;
|
||||||
|
@ -1242,6 +1247,32 @@ edje_edit_sound_tone_del(Evas_Object *obj, const char* name)
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
edje_edit_sound_tone_frequency_set(Evas_Object *obj, const char *name, int frequency)
|
||||||
|
{
|
||||||
|
Edje_Sound_Tone *tone;
|
||||||
|
if ((frequency < 20) || (frequency > 20000)) return EINA_FALSE;
|
||||||
|
GET_ED_OR_RETURN(EINA_FALSE);
|
||||||
|
GET_TONE_BY_NAME(tone, name);
|
||||||
|
if (tone)
|
||||||
|
{
|
||||||
|
tone->value = frequency;
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
edje_edit_sound_tone_frequency_get(Evas_Object *obj, const char *name)
|
||||||
|
{
|
||||||
|
Edje_Sound_Tone *tone;
|
||||||
|
GET_ED_OR_RETURN(-1);
|
||||||
|
GET_TONE_BY_NAME(tone, name);
|
||||||
|
if (tone)
|
||||||
|
return tone->value;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI double
|
EAPI double
|
||||||
edje_edit_sound_compression_rate_get(Evas_Object *obj, const char *sound)
|
edje_edit_sound_compression_rate_get(Evas_Object *obj, const char *sound)
|
||||||
{
|
{
|
||||||
|
@ -1291,6 +1322,8 @@ edje_edit_sound_compression_rate_set(Evas_Object *obj, const char *sound, double
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef GET_TONE_BY_NAME
|
||||||
|
|
||||||
/****************/
|
/****************/
|
||||||
/* GROUPS API */
|
/* GROUPS API */
|
||||||
/****************/
|
/****************/
|
||||||
|
|
Loading…
Reference in New Issue