Collection of tools useful for audio production
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.7KB

  1. /*
  2. * Patchbay Canvas engine using QGraphicsView/Scene
  3. * Copyright (C) 2010-2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the COPYING file
  16. */
  17. #ifndef PATCHCANVAS_API_H
  18. #define PATCHCANVAS_API_H
  19. #define START_NAMESPACE_PATCHCANVAS namespace PatchCanvas {
  20. #define END_NAMESPACE_PATCHCANVAS }
  21. #ifndef PATCHCANVAS_ORGANISATION_NAME
  22. #define PATCHCANVAS_ORGANISATION_NAME "PatchCanvas"
  23. #endif
  24. #include <QtCore/QString>
  25. #include "patchcanvas-theme.h"
  26. #include "patchscene.h"
  27. START_NAMESPACE_PATCHCANVAS
  28. enum PortMode {
  29. PORT_MODE_NULL = 0,
  30. PORT_MODE_INPUT = 1,
  31. PORT_MODE_OUTPUT = 2
  32. };
  33. enum PortType {
  34. PORT_TYPE_NULL = 0,
  35. PORT_TYPE_AUDIO_JACK = 1,
  36. PORT_TYPE_MIDI_JACK = 2,
  37. PORT_TYPE_MIDI_A2J = 3,
  38. PORT_TYPE_MIDI_ALSA = 4
  39. };
  40. enum CallbackAction {
  41. ACTION_GROUP_INFO = 0, // group_id, N, N
  42. ACTION_GROUP_RENAME = 1, // group_id, N, new_name
  43. ACTION_GROUP_SPLIT = 2, // group_id, N, N
  44. ACTION_GROUP_JOIN = 3, // group_id, N, N
  45. ACTION_PORT_INFO = 4, // port_id, N, N
  46. ACTION_PORT_RENAME = 5, // port_id, N, new_name
  47. ACTION_PORTS_CONNECT = 6, // out_id, in_id, N
  48. ACTION_PORTS_DISCONNECT = 7 // conn_id, N, N
  49. };
  50. enum Icon {
  51. ICON_HARDWARE = 0,
  52. ICON_APPLICATION = 1,
  53. ICON_LADISH_ROOM = 2
  54. };
  55. enum SplitOption {
  56. SPLIT_UNDEF = 0,
  57. SPLIT_NO = 1,
  58. SPLIT_YES = 2
  59. };
  60. enum AntialiasingOption {
  61. ANTIALIASING_NONE = 0,
  62. ANTIALIASING_SMALL = 1,
  63. ANTIALIASING_FULL = 2
  64. };
  65. enum EyeCandyOption {
  66. EYECANDY_NONE = 0,
  67. EYECANDY_SMALL = 1,
  68. EYECANDY_FULL = 2
  69. };
  70. // Canvas options
  71. struct options_t {
  72. QString theme_name;
  73. bool auto_hide_groups;
  74. bool use_bezier_lines;
  75. AntialiasingOption antialiasing;
  76. EyeCandyOption eyecandy;
  77. };
  78. // Canvas features
  79. struct features_t {
  80. bool group_info;
  81. bool group_rename;
  82. bool port_info;
  83. bool port_rename;
  84. bool handle_group_pos;
  85. };
  86. typedef void (*Callback) (CallbackAction action, int value1, int value2, QString value_str);
  87. // API starts here
  88. void setOptions(options_t* options);
  89. void setFeatures(features_t* features);
  90. void init(PatchScene* scene, Callback callback, bool debug=false);
  91. void clear();
  92. void setInitialPos(int x, int y);
  93. void setCanvasSize(int x, int y, int width, int height);
  94. void addGroup(int group_id, QString group_name, SplitOption split=SPLIT_UNDEF, Icon icon=ICON_APPLICATION);
  95. void removeGroup(int group_id);
  96. void renameGroup(int group_id, QString new_group_name);
  97. void splitGroup(int group_id);
  98. void joinGroup(int group_id);
  99. QPointF getGroupPos(int group_id, PortMode port_mode=PORT_MODE_OUTPUT);
  100. void setGroupPos(int group_id, int group_pos_x, int group_pos_y);
  101. void setGroupPos(int group_id, int group_pos_x, int group_pos_y, int group_pos_xs, int group_pos_ys);
  102. void setGroupIcon(int group_id, Icon icon);
  103. void addPort(int group_id, int port_id, QString port_name, PortMode port_mode, PortType port_type);
  104. void removePort(int port_id);
  105. void renamePort(int port_id, QString new_port_name);
  106. void connectPorts(int connection_id, int port_out_id, int port_in_id);
  107. void disconnectPorts(int connection_id);
  108. void arrange();
  109. END_NAMESPACE_PATCHCANVAS
  110. #endif // PATCHCANVAS_API_H