EditCore.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * ImageMeter confidential
  3. *
  4. * Copyright (C) 2019 by Dirk Farin, Kronenstr. 49b, 70174 Stuttgart, Germany
  5. * All Rights Reserved.
  6. *
  7. * NOTICE: All information contained herein is, and remains the property
  8. * of Dirk Farin. The intellectual and technical concepts contained
  9. * herein are proprietary to Dirk Farin and are protected by trade secret
  10. * and copyright law.
  11. * Dissemination of this information or reproduction of this material
  12. * is strictly forbidden unless prior written permission is obtained
  13. * from Dirk Farin.
  14. */
  15. import Foundation
  16. public class EditCore {
  17. var editcore : OpaquePointer;
  18. init (ptr : OpaquePointer) {
  19. editcore = ptr
  20. }
  21. deinit {
  22. IM_EditCore_release(editcore)
  23. }
  24. func touchDown(id : Int32, x : Int32, y : Int32, timestamp_secs : Double) {
  25. IM_EditCore_touchDown(editcore, id, x,y, timestamp_secs)
  26. }
  27. func touchMove(id : Int32, x : Int32, y : Int32, timestamp_secs : Double) {
  28. IM_EditCore_touchMove(editcore, id, x,y, timestamp_secs)
  29. }
  30. func touchUp(id : Int32, x : Int32, y : Int32, timestamp_secs : Double) {
  31. IM_EditCore_touchUp(editcore, id, x,y, timestamp_secs)
  32. }
  33. func touchCancelled(id : Int32) {
  34. IM_EditCore_touchCancelled(editcore, id)
  35. }
  36. func start_interaction_addMeasure() {
  37. IM_EditCore_start_interaction_addMeasure(editcore, "")
  38. }
  39. // TODO: not fully working yet, because we need timer callbacks because of the double-click interactions
  40. func start_interaction_addAngle() {
  41. IM_EditCore_start_interaction_addAngle(editcore)
  42. }
  43. func start_interaction_addText() {
  44. IM_EditCore_start_interaction_addText(editcore)
  45. }
  46. func start_interaction_addFreehand() {
  47. IM_EditCore_start_interaction_addFreehand(editcore)
  48. }
  49. func end_current_interaction() {
  50. IM_EditCore_end_current_interaction(editcore)
  51. }
  52. func set_color_of_active_element(argb : UInt32) {
  53. IM_EditCore_set_color_of_active_element(editcore,argb)
  54. }
  55. func set_color_of_future_created_elements(argb : UInt32) {
  56. IM_EditCore_set_color_of_future_created_elements(editcore, argb)
  57. }
  58. func delete_active_element() {
  59. IM_EditCore_delete_active_element(editcore)
  60. }
  61. func undo() {
  62. IM_EditCore_undo(editcore)
  63. }
  64. func redo() {
  65. IM_EditCore_redo(editcore)
  66. }
  67. func undo_available() -> Bool {
  68. return IM_EditCore_undo_available(editcore)
  69. }
  70. func redo_available() -> Bool {
  71. return IM_EditCore_redo_available(editcore)
  72. }
  73. func audio_completed(audioFile : String) {
  74. IM_EditCore_audioCompleted(editcore, UnsafePointer(audioFile))
  75. }
  76. }