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.

139 lines
3.8KB

  1. /*
  2. * Patchbay Canvas engine using QGraphicsView/Scene
  3. * Copyright (C) 2010-2012 Filipe Coelho <falktx@falktx.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_HPP
  18. #define PATCHCANVAS_API_HPP
  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 "patchcanvas/patchcanvas-theme.h"
  25. #include "patchcanvas/patchscene.h"
  26. START_NAMESPACE_PATCHCANVAS
  27. enum PortMode {
  28. PORT_MODE_NULL = 0,
  29. PORT_MODE_INPUT = 1,
  30. PORT_MODE_OUTPUT = 2
  31. };
  32. enum PortType {
  33. PORT_TYPE_NULL = 0,
  34. PORT_TYPE_AUDIO_JACK = 1,
  35. PORT_TYPE_MIDI_JACK = 2,
  36. PORT_TYPE_MIDI_A2J = 3,
  37. PORT_TYPE_MIDI_ALSA = 4
  38. };
  39. enum CallbackAction {
  40. ACTION_GROUP_INFO = 0, // group_id, N, N
  41. ACTION_GROUP_RENAME = 1, // group_id, N, new_name
  42. ACTION_GROUP_SPLIT = 2, // group_id, N, N
  43. ACTION_GROUP_JOIN = 3, // group_id, N, N
  44. ACTION_PORT_INFO = 4, // port_id, N, N
  45. ACTION_PORT_RENAME = 5, // port_id, N, new_name
  46. ACTION_PORTS_CONNECT = 6, // out_id, in_id, N
  47. ACTION_PORTS_DISCONNECT = 7 // conn_id, N, N
  48. };
  49. enum Icon {
  50. ICON_HARDWARE = 0,
  51. ICON_APPLICATION = 1,
  52. ICON_LADISH_ROOM = 2
  53. };
  54. enum SplitOption {
  55. SPLIT_UNDEF = 0,
  56. SPLIT_NO = 1,
  57. SPLIT_YES = 2
  58. };
  59. enum AntialiasingOption {
  60. ANTIALIASING_NONE = 0,
  61. ANTIALIASING_SMALL = 1,
  62. ANTIALIASING_FULL = 2
  63. };
  64. enum EyeCandyOption {
  65. EYECANDY_NONE = 0,
  66. EYECANDY_SMALL = 1,
  67. EYECANDY_FULL = 2
  68. };
  69. // Canvas options
  70. struct options_t {
  71. QString theme_name;
  72. bool auto_hide_groups;
  73. bool use_bezier_lines;
  74. AntialiasingOption antialiasing;
  75. EyeCandyOption eyecandy;
  76. };
  77. // Canvas features
  78. struct features_t {
  79. bool group_info;
  80. bool group_rename;
  81. bool port_info;
  82. bool port_rename;
  83. bool handle_group_pos;
  84. };
  85. typedef void (*Callback) (CallbackAction action, int value1, int value2, QString value_str);
  86. // API starts here
  87. void setOptions(options_t* options);
  88. void setFeatures(features_t* features);
  89. void init(PatchScene* scene, Callback callback, bool debug=false);
  90. void clear();
  91. void setInitialPos(int x, int y);
  92. void setCanvasSize(int x, int y, int width, int height);
  93. void addGroup(int group_id, QString group_name, SplitOption split=SPLIT_UNDEF, Icon icon=ICON_APPLICATION);
  94. void removeGroup(int group_id);
  95. void renameGroup(int group_id, QString new_group_name);
  96. void splitGroup(int group_id);
  97. void joinGroup(int group_id);
  98. QPointF getGroupPos(int group_id, PortMode port_mode=PORT_MODE_OUTPUT);
  99. void setGroupPos(int group_id, int group_pos_x, int group_pos_y);
  100. void setGroupPos(int group_id, int group_pos_x, int group_pos_y, int group_pos_xs, int group_pos_ys);
  101. void setGroupIcon(int group_id, Icon icon);
  102. void addPort(int group_id, int port_id, QString port_name, PortMode port_mode, PortType port_type);
  103. void removePort(int port_id);
  104. void renamePort(int port_id, QString new_port_name);
  105. void connectPorts(int connection_id, int port_out_id, int port_in_id);
  106. void disconnectPorts(int connection_id);
  107. void arrange();
  108. void updateZValues();
  109. // Theme
  110. Theme::List getDefaultTheme();
  111. QString getThemeName(Theme::List id);
  112. QString getDefaultThemeName();
  113. END_NAMESPACE_PATCHCANVAS
  114. #endif // PATCHCANVAS_API_HPP