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