1 /* This file is part of Ganv. 2 * Copyright 2007-2014 David Robillard <http://drobilla.net> 3 * 4 * Ganv is free software: you can redistribute it and/or modify it under the 5 * terms of the GNU General Public License as published by the Free Software 6 * Foundation, either version 3 of the License, or any later version. 7 * 8 * Ganv is distributed in the hope that it will be useful, but WITHOUT ANY 9 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. 11 * 12 * You should have received a copy of the GNU General Public License along 13 * with Ganv. If not, see <http://www.gnu.org/licenses/>. 14 */ 15 16 // IWYU pragma: no_include "ganv-private.h" 17 18 #ifndef GANV_NODE_H 19 #define GANV_NODE_H 20 21 #include "ganv/item.h" 22 #include "ganv/types.h" 23 24 #include <glib-object.h> 25 #include <glib.h> 26 #include <gtk/gtk.h> 27 28 G_BEGIN_DECLS 29 30 #define GANV_TYPE_NODE (ganv_node_get_type()) 31 #define GANV_NODE(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_NODE, GanvNode)) 32 #define GANV_NODE_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_NODE, GanvNodeClass)) 33 #define GANV_IS_NODE(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_NODE)) 34 #define GANV_IS_NODE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_NODE)) 35 #define GANV_NODE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_NODE, GanvNodeClass)) 36 37 struct _GanvNodeClass; 38 39 typedef struct _GanvNodeClass GanvNodeClass; 40 typedef struct _GanvNodePrivate GanvNodePrivate; 41 42 struct _GanvNode { 43 GanvItem item; 44 GanvNodePrivate* impl; 45 }; 46 47 struct _GanvNodeClass { 48 GanvItemClass parent_class; 49 50 void (*tick)(GanvNode* self, 51 double seconds); 52 53 void (*move)(GanvNode* node, 54 double dx, 55 double dy); 56 57 void (*move_to)(GanvNode* node, 58 double x, 59 double y); 60 61 void (*resize)(GanvNode* node); 62 63 void (*redraw_text)(GanvNode* node); 64 65 void (*disconnect)(GanvNode* node); 66 67 gboolean (*is_within)(const GanvNode* self, 68 double x1, 69 double y1, 70 double x2, 71 double y2); 72 73 void (*tail_vector)(const GanvNode* self, 74 const GanvNode* head, 75 double* x, 76 double* y, 77 double* dx, 78 double* dy); 79 80 void (*head_vector)(const GanvNode* self, 81 const GanvNode* tail, 82 double* x, 83 double* y, 84 double* dx, 85 double* dy); 86 87 /* Reserved for future expansion */ 88 gpointer spare_vmethods[4]; 89 }; 90 91 GType ganv_node_get_type(void) G_GNUC_CONST; 92 93 /** 94 * ganv_node_can_tail: 95 * 96 * Return value: True iff node can act as the tail of an edge. 97 */ 98 gboolean 99 ganv_node_can_tail(const GanvNode* node); 100 101 /** 102 * ganv_node_can_head: 103 * 104 * Return value: True iff node can act as the head of an edge. 105 */ 106 gboolean 107 ganv_node_can_head(const GanvNode* node); 108 109 /** 110 * ganv_node_set_is_source: 111 * 112 * Flag a node as a source. This information is used to influence layout. 113 */ 114 void 115 ganv_node_set_is_source(const GanvNode* node, gboolean is_source); 116 117 /** 118 * ganv_node_is_within: 119 * 120 * Return value: True iff node is entirely within the given rectangle. 121 */ 122 gboolean 123 ganv_node_is_within(const GanvNode* node, 124 double x1, 125 double y1, 126 double x2, 127 double y2); 128 129 const char* ganv_node_get_label(const GanvNode* node); 130 131 double ganv_node_get_border_width(const GanvNode* node); 132 133 void ganv_node_set_border_width(const GanvNode* node, double border_width); 134 135 double ganv_node_get_dash_length(const GanvNode* node); 136 137 void ganv_node_set_dash_length(const GanvNode* node, double dash_length); 138 139 double ganv_node_get_dash_offset(const GanvNode* node); 140 141 void ganv_node_set_dash_offset(const GanvNode* node, double dash_offset); 142 143 guint ganv_node_get_fill_color(const GanvNode* node); 144 145 void ganv_node_set_fill_color(const GanvNode* node, guint fill_color); 146 147 guint ganv_node_get_border_color(const GanvNode* node); 148 149 void ganv_node_set_border_color(const GanvNode* node, guint border_color); 150 151 /** 152 * ganv_node_get_partner: 153 * 154 * Return value: (transfer none): The partner of @node. 155 */ 156 GanvNode* 157 ganv_node_get_partner(const GanvNode* node); 158 159 void ganv_node_set_label(GanvNode* node, const char* str); 160 void ganv_node_set_show_label(GanvNode* node, gboolean show); 161 162 void 163 ganv_node_move(GanvNode* node, 164 double dx, 165 double dy); 166 167 void 168 ganv_node_move_to(GanvNode* node, 169 double x, 170 double y); 171 172 void 173 ganv_node_resize(GanvNode* node); 174 175 void 176 ganv_node_redraw_text(GanvNode* node); 177 178 void 179 ganv_node_disconnect(GanvNode* node); 180 181 gboolean 182 ganv_node_is_selected(GanvNode* node); 183 184 G_END_DECLS 185 186 #endif /* GANV_NODE_H */ 187