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.

143 lines
3.6KB

  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 AnimationIdle();
  31. void AnimationHide();
  32. void AnimationDestroy();
  33. void CanvasPostponedGroups();
  34. void PortContextMenuDisconnect();
  35. };
  36. START_NAMESPACE_PATCHCANVAS
  37. class AbstractCanvasLine;
  38. class CanvasFadeAnimation;
  39. class CanvasBox;
  40. class CanvasPort;
  41. class Theme;
  42. // object types
  43. enum CanvasType {
  44. CanvasBoxType = QGraphicsItem::UserType + 1,
  45. CanvasIconType = QGraphicsItem::UserType + 2,
  46. CanvasPortType = QGraphicsItem::UserType + 3,
  47. CanvasLineType = QGraphicsItem::UserType + 4,
  48. CanvasBezierLineType = QGraphicsItem::UserType + 5,
  49. CanvasLineMovType = QGraphicsItem::UserType + 6,
  50. CanvasBezierLineMovType = QGraphicsItem::UserType + 7
  51. };
  52. // object lists
  53. struct group_dict_t {
  54. int group_id;
  55. QString group_name;
  56. bool split;
  57. Icon icon;
  58. CanvasBox* widgets[2];
  59. };
  60. struct port_dict_t {
  61. int group_id;
  62. int port_id;
  63. QString port_name;
  64. PortMode port_mode;
  65. PortType port_type;
  66. CanvasPort* widget;
  67. };
  68. struct connection_dict_t {
  69. int connection_id;
  70. int port_in_id;
  71. int port_out_id;
  72. AbstractCanvasLine* widget;
  73. };
  74. struct animation_dict_t {
  75. CanvasFadeAnimation* animation;
  76. QGraphicsItem* item;
  77. };
  78. // Main Canvas object
  79. class Canvas {
  80. public:
  81. Canvas();
  82. ~Canvas();
  83. PatchScene* scene;
  84. Callback callback;
  85. bool debug;
  86. unsigned long last_z_value;
  87. int last_connection_id;
  88. QPointF initial_pos;
  89. QRectF size_rect;
  90. QList<group_dict_t> group_list;
  91. QList<port_dict_t> port_list;
  92. QList<connection_dict_t> connection_list;
  93. QList<animation_dict_t> animation_list;
  94. CanvasObject* qobject;
  95. QSettings* settings;
  96. Theme* theme;
  97. bool initiated;
  98. };
  99. const char* bool2str(bool check);
  100. const char* port_mode2str(PortMode port_mode);
  101. const char* port_type2str(PortType port_type);
  102. const char* icon2str(Icon icon);
  103. const char* split2str(SplitOption split);
  104. QString CanvasGetGroupName(int group_id);
  105. int CanvasGetGroupPortCount(int group_id);
  106. QPointF CanvasGetNewGroupPos(bool horizontal=false);
  107. QString CanvasGetFullPortName(int port_id);
  108. QList<int> CanvasGetPortConnectionList(int port_id);
  109. int CanvasGetConnectedPort(int connection_id, int port_id);
  110. void CanvasRemoveAnimation(CanvasFadeAnimation* f_animation);
  111. void CanvasPostponedGroups();
  112. void CanvasCallback(CallbackAction action, int value1, int value2, QString value_str);
  113. void CanvasItemFX(QGraphicsItem* item, bool show, bool destroy=false);
  114. void CanvasRemoveItemFX(QGraphicsItem* item);
  115. // global objects
  116. extern Canvas canvas;
  117. extern options_t options;
  118. extern features_t features;
  119. END_NAMESPACE_PATCHCANVAS
  120. #endif // PATCHCANVAS_H