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.

130 lines
3.2KB

  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_H
  18. #define PATCHCANVAS_H
  19. #include <QtGui/QGraphicsItem>
  20. #include "patchcanvas-api.h"
  21. #define foreach2(var, list) \
  22. for (int i=0; i < list.count(); i++) { var = list[i];
  23. class QSettings;
  24. class QTimer;
  25. class CanvasObject : public QObject {
  26. Q_OBJECT
  27. public:
  28. CanvasObject(QObject* parent=0);
  29. public slots:
  30. void CanvasPostponedGroups();
  31. void PortContextMenuDisconnect();
  32. };
  33. START_NAMESPACE_PATCHCANVAS
  34. class AbstractCanvasLine;
  35. class CanvasBox;
  36. class CanvasPort;
  37. class Theme;
  38. // object types
  39. enum CanvasType {
  40. CanvasBoxType = QGraphicsItem::UserType + 1,
  41. CanvasIconType = QGraphicsItem::UserType + 2,
  42. CanvasPortType = QGraphicsItem::UserType + 3,
  43. CanvasLineType = QGraphicsItem::UserType + 4,
  44. CanvasBezierLineType = QGraphicsItem::UserType + 5,
  45. CanvasLineMovType = QGraphicsItem::UserType + 6,
  46. CanvasBezierLineMovType = QGraphicsItem::UserType + 7
  47. };
  48. // object lists
  49. struct group_dict_t {
  50. int group_id;
  51. QString group_name;
  52. bool split;
  53. Icon icon;
  54. CanvasBox* widgets[2];
  55. };
  56. struct port_dict_t {
  57. int group_id;
  58. int port_id;
  59. QString port_name;
  60. PortMode port_mode;
  61. PortType port_type;
  62. CanvasPort* widget;
  63. };
  64. struct connection_dict_t {
  65. int connection_id;
  66. int port_in_id;
  67. int port_out_id;
  68. AbstractCanvasLine* widget;
  69. };
  70. // Main Canvas object
  71. class Canvas {
  72. public:
  73. Canvas();
  74. ~Canvas();
  75. PatchScene* scene;
  76. Callback callback;
  77. bool debug;
  78. unsigned long last_z_value;
  79. int last_connection_id;
  80. QPointF initial_pos;
  81. QRectF size_rect;
  82. QList<group_dict_t> group_list;
  83. QList<port_dict_t> port_list;
  84. QList<connection_dict_t> connection_list;
  85. CanvasObject* qobject;
  86. QSettings* settings;
  87. Theme* theme;
  88. bool initiated;
  89. };
  90. const char* bool2str(bool check);
  91. const char* port_mode2str(PortMode port_mode);
  92. const char* port_type2str(PortType port_type);
  93. const char* icon2str(Icon icon);
  94. const char* split2str(SplitOption split);
  95. QString CanvasGetGroupName(int group_id);
  96. int CanvasGetGroupPortCount(int group_id);
  97. QPointF CanvasGetNewGroupPos(bool horizontal=false);
  98. QString CanvasGetFullPortName(int port_id);
  99. QList<int> CanvasGetPortConnectionList(int port_id);
  100. int CanvasGetConnectedPort(int connection_id, int port_id);
  101. void CanvasPostponedGroups();
  102. void CanvasCallback(CallbackAction action, int value1, int value2, QString value_str);
  103. // global objects
  104. extern Canvas canvas;
  105. extern options_t options;
  106. extern features_t features;
  107. END_NAMESPACE_PATCHCANVAS
  108. #endif // PATCHCANVAS_H