Piano / src / player /
piano-impl.c
/*
* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "config.h"
#include "player/piano-player.h"
#include "logger.h"
#include "piano-structs.h"
#define PIANO_NOTE_BORDER_OFFSET 20
void piano_note_touch_down(void *data, Evas_Point coord_on_main_win, Eina_Bool check_collision)
{
RETM_IF(!data, "data is NULL");
note_struct *note = (note_struct *) data;
Evas_Coord button_left = 0, button_top = 0, button_width = 0, button_height = 0;
evas_object_geometry_get(note->button, &button_left, &button_top, &button_width, &button_height);
if (PIANO_NOTE_WHITE == note->type) {
if (check_collision && (coord_on_main_win.y - button_top) < PIANO_NOTE_BORDER_OFFSET) {
piano_note_touch_down(note->prev, coord_on_main_win, EINA_FALSE);
} else if (check_collision && button_height - (coord_on_main_win.y - button_top) < PIANO_NOTE_BORDER_OFFSET) {
piano_note_touch_down(note->next, coord_on_main_win, EINA_FALSE);
}
}
elm_object_signal_emit((Evas_Object *)note->button, "clicked", "*");
piano_player_play(note);
}
void piano_note_touch_up(void *data)
{
RETM_IF(!data, "data is NULL");
note_struct *note = (note_struct *) data;
RETM_IF(!note->ad, "note->ad is NULL");
Eina_List *l = NULL;
note_struct *list_item_note = NULL;
EINA_LIST_FOREACH(note->ad->buttonList, l, list_item_note) {
const Evas *evas_button = evas_object_evas_get(list_item_note->button);
if (evas_button && evas_pointer_button_down_mask_get(evas_button)) {
elm_object_signal_emit(list_item_note->button, "default", "*");
}
}
}