Piano / src / player /

piano-impl.c

  1. /*
  2. * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the License);
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16.  
  17. #include "config.h"
  18. #include "player/piano-player.h"
  19. #include "logger.h"
  20. #include "piano-structs.h"
  21.  
  22. #define PIANO_NOTE_BORDER_OFFSET 20
  23.  
  24. void piano_note_touch_down(void *data, Evas_Point coord_on_main_win, Eina_Bool check_collision)
  25. {
  26. RETM_IF(!data, "data is NULL");
  27. note_struct *note = (note_struct *) data;
  28.  
  29. Evas_Coord button_left = 0, button_top = 0, button_width = 0, button_height = 0;
  30. evas_object_geometry_get(note->button, &button_left, &button_top, &button_width, &button_height);
  31.  
  32. if (PIANO_NOTE_WHITE == note->type) {
  33. if (check_collision && (coord_on_main_win.y - button_top) < PIANO_NOTE_BORDER_OFFSET) {
  34. piano_note_touch_down(note->prev, coord_on_main_win, EINA_FALSE);
  35. } else if (check_collision && button_height - (coord_on_main_win.y - button_top) < PIANO_NOTE_BORDER_OFFSET) {
  36. piano_note_touch_down(note->next, coord_on_main_win, EINA_FALSE);
  37. }
  38. }
  39.  
  40. elm_object_signal_emit((Evas_Object *)note->button, "clicked", "*");
  41.  
  42. piano_player_play(note);
  43. }
  44.  
  45. void piano_note_touch_up(void *data)
  46. {
  47. RETM_IF(!data, "data is NULL");
  48.  
  49. note_struct *note = (note_struct *) data;
  50.  
  51. RETM_IF(!note->ad, "note->ad is NULL");
  52.  
  53. Eina_List *l = NULL;
  54. note_struct *list_item_note = NULL;
  55. EINA_LIST_FOREACH(note->ad->buttonList, l, list_item_note) {
  56. const Evas *evas_button = evas_object_evas_get(list_item_note->button);
  57.  
  58. if (evas_button && evas_pointer_button_down_mask_get(evas_button)) {
  59. elm_object_signal_emit(list_item_note->button, "default", "*");
  60. }
  61. }
  62. }