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.

109 lines
2.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 CANVASBOX_H
  18. #define CANVASBOX_H
  19. #include "patchcanvas.h"
  20. class QGraphicsSceneContextMenuEvent;
  21. class QGraphicsSceneMouseEvent;
  22. class QPainter;
  23. START_NAMESPACE_PATCHCANVAS
  24. class AbstractCanvasLine;
  25. class CanvasBoxShadow;
  26. class CanvasPort;
  27. class CanvasIcon;
  28. struct cb_line_t {
  29. AbstractCanvasLine* line;
  30. int connection_id;
  31. };
  32. class CanvasBox : public QGraphicsItem
  33. {
  34. public:
  35. CanvasBox(int group_id, QString group_name, Icon icon, QGraphicsItem* parent=0);
  36. virtual ~CanvasBox();
  37. int getGroupId();
  38. QString getGroupName();
  39. bool isSplitted();
  40. PortMode getSplittedMode();
  41. int getPortCount();
  42. QList<int> getPortList();
  43. void setIcon(Icon icon);
  44. void setSplit(bool split, PortMode mode=PORT_MODE_NULL);
  45. void setGroupName(QString group_name);
  46. void setShadowOpacity(float opacity);
  47. CanvasPort* addPortFromGroup(int port_id, QString port_name, PortMode port_mode, PortType port_type);
  48. void removePortFromGroup(int port_id);
  49. void addLineFromGroup(AbstractCanvasLine* line, int connection_id);
  50. void removeLineFromGroup(int connection_id);
  51. void checkItemPos();
  52. void removeIconFromScene();
  53. void updatePositions();
  54. void repaintLines(bool forced=false);
  55. void resetLinesZValue();
  56. virtual int type() const;
  57. private:
  58. int m_group_id;
  59. QString m_group_name;
  60. int p_width;
  61. int p_height;
  62. QList<int> m_port_list_ids;
  63. QList<cb_line_t> m_connection_lines;
  64. QPointF m_last_pos;
  65. bool m_splitted;
  66. PortMode m_splitted_mode;
  67. bool m_forced_split;
  68. bool m_cursor_moving;
  69. bool m_mouse_down;
  70. QFont m_font_name;
  71. QFont m_font_port;
  72. CanvasIcon* icon_svg;
  73. CanvasBoxShadow* shadow;
  74. virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
  75. virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
  76. virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
  77. virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
  78. virtual QRectF boundingRect() const;
  79. virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
  80. };
  81. END_NAMESPACE_PATCHCANVAS
  82. #endif // CANVASBOX_H