Piano / src / view /
piano-callbacks.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 "view/piano-callbacks.h"
- #include "logger.h"
- #include "player/piano-impl.h"
- #include "player/piano-player.h"
- #include "piano-structs.h"
- void piano_note_touch_down_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- note_struct *note = (note_struct *)data;
- Evas_Event_Multi_Down *ev = (Evas_Event_Multi_Down *)event_info;
- if (note->ad->previous_button == note) {
- return;
- }
- piano_note_touch_down(data, ev->output, EINA_TRUE);
- note->ad->previous_button = note;
- }
- void piano_note_touch_up_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- piano_note_touch_up(data);
- }
- void piano_note_mouse_down_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *)event_info;
- note_struct *note = (note_struct *)data;
- piano_note_touch_down(data, ev->output, EINA_TRUE);
- evas_object_focus_set(button, EINA_FALSE);
- note->ad->previous_button = note;
- }
- void piano_note_mouse_up_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- piano_note_touch_up(data);
- }
- void piano_note_mouse_out_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- piano_note_touch_up(data);
- }
- void piano_note_mouse_in_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- RETM_IF(!data, "data is NULL");
- Evas_Event_Mouse_In *ev = (Evas_Event_Mouse_In *)event_info;
- piano_note_touch_down(data, ev->output, EINA_FALSE);
- evas_object_focus_set(button, EINA_FALSE);
- }
- void piano_note_mouse_move_cb(void *data, Evas *e, Evas_Object *button, void *event_info)
- {
- Evas_Event_Mouse_In *ev = (Evas_Event_Mouse_In *)event_info;
- static int old_pos_y = 0;
- const int max_pos_y = 50;
- if (data && (abs(old_pos_y - ev->output.y) > max_pos_y)) {
- old_pos_y = ev->output.y;
- note_struct *note = (note_struct *)data;
- if (note->ad->previous_button == note) {
- return;
- }
- piano_note_touch_up(data);
- piano_note_touch_down(data, ev->output, EINA_FALSE);
- note->ad->previous_button = note;
- }
- }
- Eina_Bool piano_note_timer_cb(void *data)
- {
- RETVM_IF(!data, EINA_FALSE, "data is NULL");
- app_data *ad = (app_data *)data;
- Eina_List *l = NULL;
- note_struct *list_item_note = NULL;
- EINA_LIST_FOREACH(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", "*");
- }
- }
- return EINA_TRUE;
- }