summaryrefslogtreecommitdiffstats
path: root/ganv
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-03-15 22:35:18 +0000
committerDavid Robillard <d@drobilla.net>2014-03-15 22:35:18 +0000
commit3b63d9fa3114f0292561484f299d9d45ec451c17 (patch)
treeb45de3ba8d2eded5731908cf6842b4bb6392863f /ganv
parentba34221e0ee4c32ced4770563638f472860e0a16 (diff)
downloadganv-3b63d9fa3114f0292561484f299d9d45ec451c17.tar.gz
ganv-3b63d9fa3114f0292561484f299d9d45ec451c17.tar.bz2
ganv-3b63d9fa3114f0292561484f299d9d45ec451c17.zip
Clean up public canvas interface.
Eliminate thin C wrappers around C++ methods (move actual implementation into C). git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5338 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ganv')
-rw-r--r--ganv/Canvas.hpp29
-rw-r--r--ganv/box.h5
-rw-r--r--ganv/canvas.h136
-rw-r--r--ganv/circle.h5
-rw-r--r--ganv/edge.h7
-rw-r--r--ganv/group.h3
-rw-r--r--ganv/item.h5
-rw-r--r--ganv/module.h7
-rw-r--r--ganv/node.h7
-rw-r--r--ganv/port.h5
-rw-r--r--ganv/text.h5
-rw-r--r--ganv/widget.h7
12 files changed, 74 insertions, 147 deletions
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp
index 7b71642..b3281ad 100644
--- a/ganv/Canvas.hpp
+++ b/ganv/Canvas.hpp
@@ -61,7 +61,6 @@ public:
METHOD0(ganv_canvas, get_zoom);
METHOD1(ganv_canvas, set_zoom, double, pix_per_unit);
METHOD1(ganv_canvas, set_font_size, double, points);
- METHOD2(ganv_canvas, set_scale, double, zoom, double, points);
METHOD0(ganv_canvas, zoom_full);
METHODRET0(ganv_canvas, double, get_font_size)
METHODRET0(ganv_canvas, double, get_default_font_size)
@@ -71,7 +70,10 @@ public:
METHOD2(ganv_canvas, resize, double, width, double, height);
METHOD2(ganv_canvas, for_each_node, GanvNodeFunc, f, void*, data)
METHOD2(ganv_canvas, for_each_selected_node, GanvNodeFunc, f, void*, data)
+ METHOD2(ganv_canvas, for_each_edge, GanvEdgeFunc, f, void*, data)
+ METHOD2(ganv_canvas, for_each_selected_edge, GanvEdgeFunc, f, void*, data)
METHODRET0(ganv_canvas, gboolean, empty)
+ METHOD2(ganv_canvas, scroll_to, int, x, int, y);
METHOD3(ganv_canvas, for_each_edge_from,
const GanvNode*, tail,
@@ -95,7 +97,9 @@ public:
RW_PROPERTY(double, height)
RW_PROPERTY(GanvDirection, direction);
- Gtk::Layout& widget();
+ Gtk::Layout& widget() {
+ return *Glib::wrap(&_gobj->layout);
+ }
/** Get the edge from @c tail to @c head if one exists. */
Edge* get_edge(Node* tail, Node* head) const;
@@ -105,18 +109,18 @@ public:
void remove_edge(Edge* edge);
- void for_each_edge(GanvEdgeFunc f, void* data);
- void for_each_selected_edge(GanvEdgeFunc f, void* data);
-
- void get_scroll_offsets(int& cx, int& cy) const;
- void scroll_to(int x, int y);
+ void get_scroll_offsets(int& cx, int& cy) const {
+ ganv_canvas_get_scroll_offsets(gobj(), &cx, &cy);
+ }
GQuark wrapper_key();
- GanvItem* root();
+ GanvItem* root() {
+ return ganv_canvas_root(gobj());
+ }
- GanvCanvas* gobj();
- const GanvCanvas* gobj() const;
+ GanvCanvas* gobj() { return GANV_CANVAS(_gobj); }
+ const GanvCanvas* gobj() const { return GANV_CANVAS(_gobj); }
sigc::signal<bool, GdkEvent*> signal_event;
sigc::signal<void, Node*, Node*> signal_connect;
@@ -126,11 +130,6 @@ private:
Canvas(const Canvas&); ///< Noncopyable
const Canvas& operator=(const Canvas&); ///< Noncopyable
- inline GanvCanvasImpl* impl() { return _gobj->impl; }
- inline const GanvCanvasImpl* impl() const { return _gobj->impl; }
-
- sigc::connection _animate_connection;
-
GanvCanvas* const _gobj;
};
diff --git a/ganv/box.h b/ganv/box.h
index bef20a0..da94c68 100644
--- a/ganv/box.h
+++ b/ganv/box.h
@@ -48,9 +48,12 @@ struct _GanvBoxClass {
void (*set_height)(GanvBox* box,
double height);
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_box_get_type(void);
+GType ganv_box_get_type(void) G_GNUC_CONST;
double ganv_box_get_x1(const GanvBox* box);
double ganv_box_get_y1(const GanvBox* box);
double ganv_box_get_x2(const GanvBox* box);
diff --git a/ganv/canvas.h b/ganv/canvas.h
index 38f3371..f1bea92 100644
--- a/ganv/canvas.h
+++ b/ganv/canvas.h
@@ -35,8 +35,7 @@ G_BEGIN_DECLS
#define GANV_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_CANVAS))
#define GANV_CANVAS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_CANVAS, GanvCanvasClass))
-struct GanvCanvasImpl;
-
+typedef struct GanvCanvasImpl GanvCanvasImpl;
typedef struct _GanvCanvasClass GanvCanvasClass;
/**
@@ -53,111 +52,13 @@ typedef enum {
} GanvDirection;
struct _GanvCanvas {
- GtkLayout layout;
-
- struct GanvCanvasImpl* impl;
-
- /* Root canvas item */
- GanvItem* root;
-
- /* Region that needs redrawing (list of rectangles) */
- GSList* redraw_region;
-
- /* The item containing the mouse pointer, or NULL if none */
- GanvItem* current_item;
-
- /* Item that is about to become current (used to track deletions and such) */
- GanvItem* new_current_item;
-
- /* Item that holds a pointer grab, or NULL if none */
- GanvItem* grabbed_item;
-
- /* If non-NULL, the currently focused item */
- GanvItem* focused_item;
-
- /* GC for temporary draw pixmap */
- GdkGC* pixmap_gc;
-
- /* Event on which selection of current item is based */
- GdkEvent pick_event;
-
- /* Scrolling region */
- double scroll_x1, scroll_y1;
- double scroll_x2, scroll_y2;
-
- /* Scaling factor to be used for display */
- double pixels_per_unit;
-
- /* Idle handler ID */
- guint idle_id;
-
- /* Signal handler ID for destruction of the root item */
- guint root_destroy_id;
-
- /* Area that is being redrawn. Contains (x1, y1) but not (x2, y2).
- * Specified in canvas pixel coordinates.
- */
- int redraw_x1, redraw_y1;
- int redraw_x2, redraw_y2;
-
- /* Offsets of the temprary drawing pixmap */
- int draw_xofs, draw_yofs;
-
- /* Internal pixel offsets when zoomed out */
- int zoom_xofs, zoom_yofs;
-
- /* Last known modifier state, for deferred repick when a button is down */
- int state;
-
- /* Event mask specified when grabbing an item */
- guint grabbed_event_mask;
-
- /* Tolerance distance for picking items */
- int close_enough;
-
- /* Whether the canvas should center the scroll region in the middle of
- * the window if the scroll region is smaller than the window.
- */
- unsigned int center_scroll_region : 1;
-
- /* Whether items need update at next idle loop iteration */
- unsigned int need_update : 1;
-
- /* Whether the canvas needs redrawing at the next idle loop iteration */
- unsigned int need_redraw : 1;
-
- /* Whether current item will be repicked at next idle loop iteration */
- unsigned int need_repick : 1;
-
- /* For use by internal pick_current_item() function */
- unsigned int left_grabbed_item : 1;
-
- /* For use by internal pick_current_item() function */
- unsigned int in_repick : 1;
-
- /* Flow direction */
- GanvDirection direction;
-
- /* Canvas width */
- double width;
-
- /* Canvas height */
- double height;
-
- /* Disable changes to canvas */
- gboolean locked;
-
-#ifdef GANV_FDGL
- guint layout_idle_id;
-#endif
+ GtkLayout layout;
+ GanvCanvasImpl* impl;
};
struct _GanvCanvasClass {
GtkLayoutClass parent_class;
- /* Private Virtual methods for groping the canvas inside bonobo */
- void (* request_update)(GanvCanvas* canvas);
-
/* Reserved for future expansion */
gpointer spare_vmethods [4];
};
@@ -178,11 +79,9 @@ void ganv_canvas_set_center_scroll_region(GanvCanvas* canvas, gboolean center_sc
gboolean ganv_canvas_get_center_scroll_region(GanvCanvas* canvas);
-void ganv_canvas_set_pixels_per_unit(GanvCanvas* canvas, double n);
-
void ganv_canvas_scroll_to(GanvCanvas* canvas, int cx, int cy);
-void ganv_canvas_get_scroll_offsets(GanvCanvas* canvas, int* cx, int* cy);
+void ganv_canvas_get_scroll_offsets(const GanvCanvas* canvas, int* cx, int* cy);
GanvItem* ganv_canvas_get_item_at(GanvCanvas* canvas, double x, double y);
@@ -204,9 +103,6 @@ void
ganv_canvas_resize(GanvCanvas* canvas, double width, double height);
void
-ganv_canvas_contents_changed(GanvCanvas* canvas);
-
-void
ganv_canvas_add_node(GanvCanvas* canvas,
GanvNode* node);
@@ -231,6 +127,9 @@ ganv_canvas_remove_edge_between(GanvCanvas* canvas,
double
ganv_canvas_get_default_font_size(const GanvCanvas* canvas);
+GanvDirection
+ganv_canvas_get_direction(GanvCanvas* canvas);
+
void
ganv_canvas_set_direction(GanvCanvas* canvas, GanvDirection dir);
@@ -243,6 +142,9 @@ ganv_canvas_arrange(GanvCanvas* canvas);
void
ganv_canvas_export_dot(GanvCanvas* canvas, const char* filename);
+gboolean
+ganv_canvas_get_locked(GanvCanvas* canvas);
+
/**
* GanvEdgeFunc:
* A node function that takes a user data argument (for callbacks).
@@ -341,6 +243,17 @@ ganv_canvas_for_each_edge_on(GanvCanvas* canvas,
void* data);
/**
+ * ganv_canvas_for_each_selected_edge:
+ * @canvas: The canvas.
+ * @f: (scope call): A function to call on every edge attached to @node.
+ * @data: Data to pass to @f.
+ */
+void
+ganv_canvas_for_each_selected_edge(GanvCanvas* canvas,
+ GanvEdgeFunc f,
+ void* data);
+
+/**
* ganv_canvas_clear:
* Remove all items from the canvas.
*/
@@ -383,13 +296,6 @@ void
ganv_canvas_set_font_size(GanvCanvas* canvas, double points);
/**
- * ganv_canvas_set_scale:
- * Set the zoom and font size for the canvas.
- */
-void
-ganv_canvas_set_scale(GanvCanvas* canvas, double zoom, double points);
-
-/**
* ganv_canvas_zoom_full:
* Zoom so all canvas contents are visible.
*/
diff --git a/ganv/circle.h b/ganv/circle.h
index 3739620..859bb29 100644
--- a/ganv/circle.h
+++ b/ganv/circle.h
@@ -44,9 +44,12 @@ struct _GanvCircle {
struct _GanvCircleClass {
GanvNodeClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_circle_get_type(void);
+GType ganv_circle_get_type(void) G_GNUC_CONST;
GanvCircle*
ganv_circle_new(GanvCanvas* canvas,
diff --git a/ganv/edge.h b/ganv/edge.h
index b5c6fb0..d5c0c59 100644
--- a/ganv/edge.h
+++ b/ganv/edge.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
#define GANV_EDGE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_EDGE, GanvEdgeClass))
typedef struct _GanvEdgeClass GanvEdgeClass;
-typedef struct _GanvEdgeImpl GanvEdgeImpl;
+typedef struct _GanvEdgeImpl GanvEdgeImpl;
struct _GanvEdge {
GanvItem item;
@@ -39,9 +39,12 @@ struct _GanvEdge {
struct _GanvEdgeClass {
GanvItemClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_edge_get_type(void);
+GType ganv_edge_get_type(void) G_GNUC_CONST;
GanvEdge*
ganv_edge_new(GanvCanvas* canvas,
diff --git a/ganv/group.h b/ganv/group.h
index 678eacf..0d77ee6 100644
--- a/ganv/group.h
+++ b/ganv/group.h
@@ -45,6 +45,9 @@ struct _GanvGroup {
struct _GanvGroupClass {
GanvItemClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
GType ganv_group_get_type(void) G_GNUC_CONST;
diff --git a/ganv/item.h b/ganv/item.h
index 6a77378..25d2985 100644
--- a/ganv/item.h
+++ b/ganv/item.h
@@ -165,11 +165,6 @@ void ganv_item_show(GanvItem* item);
void ganv_item_hide(GanvItem* item);
-int ganv_item_grab(GanvItem* item, unsigned int event_mask,
- GdkCursor* cursor, guint32 etime);
-
-void ganv_item_ungrab(GanvItem* item, guint32 etime);
-
void ganv_item_i2w(GanvItem* item, double* x, double* y);
void ganv_item_w2i(GanvItem* item, double* x, double* y);
diff --git a/ganv/module.h b/ganv/module.h
index 2e350a6..3ee94b5 100644
--- a/ganv/module.h
+++ b/ganv/module.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#define GANV_MODULE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_MODULE, GanvModuleClass))
typedef struct _GanvModuleClass GanvModuleClass;
-typedef struct _GanvModuleImpl GanvModuleImpl;
+typedef struct _GanvModuleImpl GanvModuleImpl;
typedef void (*GanvPortFunc)(GanvPort* port, void* data);
@@ -42,9 +42,12 @@ struct _GanvModule {
struct _GanvModuleClass {
GanvBoxClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_module_get_type(void);
+GType ganv_module_get_type(void) G_GNUC_CONST;
GanvModule*
ganv_module_new(GanvCanvas* canvas,
diff --git a/ganv/node.h b/ganv/node.h
index db50d1c..583d608 100644
--- a/ganv/node.h
+++ b/ganv/node.h
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
#define GANV_NODE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_NODE, GanvNodeClass))
typedef struct _GanvNodeClass GanvNodeClass;
-typedef struct _GanvNodeImpl GanvNodeImpl;
+typedef struct _GanvNodeImpl GanvNodeImpl;
struct _GanvNode {
GanvItem item;
@@ -76,9 +76,12 @@ struct _GanvNodeClass {
double* y,
double* dx,
double* dy);
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_node_get_type(void);
+GType ganv_node_get_type(void) G_GNUC_CONST;
/**
* ganv_node_can_tail:
diff --git a/ganv/port.h b/ganv/port.h
index 9775ac6..a4c43ef 100644
--- a/ganv/port.h
+++ b/ganv/port.h
@@ -39,9 +39,12 @@ struct _GanvPort {
struct _GanvPortClass {
GanvBoxClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_port_get_type(void);
+GType ganv_port_get_type(void) G_GNUC_CONST;
GanvPort*
ganv_port_new(GanvModule* module,
diff --git a/ganv/text.h b/ganv/text.h
index 11394b5..7429fcc 100644
--- a/ganv/text.h
+++ b/ganv/text.h
@@ -38,9 +38,12 @@ struct _GanvText {
struct _GanvTextClass {
GanvItemClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_text_get_type(void);
+GType ganv_text_get_type(void) G_GNUC_CONST;
void ganv_text_layout(GanvText* text);
diff --git a/ganv/widget.h b/ganv/widget.h
index c5064d2..f9134ce 100644
--- a/ganv/widget.h
+++ b/ganv/widget.h
@@ -31,7 +31,7 @@ G_BEGIN_DECLS
#define GANV_IS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GANV_TYPE_WIDGET))
#define GANV_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GANV_TYPE_WIDGET, GanvWidgetClass))
-typedef struct _GanvWidget GanvWidget;
+typedef struct _GanvWidget GanvWidget;
typedef struct _GanvWidgetClass GanvWidgetClass;
struct _GanvWidget {
@@ -54,9 +54,12 @@ struct _GanvWidget {
struct _GanvWidgetClass {
GanvItemClass parent_class;
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
};
-GType ganv_widget_get_type(void);
+GType ganv_widget_get_type(void) G_GNUC_CONST;
G_END_DECLS