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.

80 lines
2.2KB

  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 CANVASPORT_H
  18. #define CANVASPORT_H
  19. #include "patchcanvas.h"
  20. class QGraphicsSceneContextMenuEvent;
  21. class QGraphicsSceneMouseEvent;
  22. class QPainter;
  23. START_NAMESPACE_PATCHCANVAS
  24. class AbstractCanvasLineMov;
  25. class CanvasPort : public QGraphicsItem
  26. {
  27. public:
  28. CanvasPort(int port_id, QString port_name, PortMode port_mode, PortType port_type, QGraphicsItem* parent);
  29. int getPortId();
  30. PortMode getPortMode();
  31. PortType getPortType();
  32. QString getPortName();
  33. QString getFullPortName();
  34. int getPortWidth();
  35. int getPortHeight();
  36. void setPortMode(PortMode port_mode);
  37. void setPortType(PortType port_type);
  38. void setPortName(QString port_name);
  39. void setPortWidth(int port_width);
  40. virtual int type() const;
  41. private:
  42. int m_port_id;
  43. PortMode m_port_mode;
  44. PortType m_port_type;
  45. QString m_port_name;
  46. int m_port_width;
  47. int m_port_height;
  48. QFont m_port_font;
  49. AbstractCanvasLineMov* m_line_mov;
  50. CanvasPort* m_hover_item;
  51. bool m_last_selected_state;
  52. bool m_mouse_down;
  53. bool m_cursor_moving;
  54. virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
  55. virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
  56. virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
  57. virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
  58. virtual QRectF boundingRect() const;
  59. virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
  60. };
  61. END_NAMESPACE_PATCHCANVAS
  62. #endif // CANVASPORT_H