Rename LdCanvas to LdDiagramView.

This commit is contained in:
Přemysl Eric Janouch 2011-02-16 07:50:07 +01:00
parent 6a8238846c
commit 7fa6efbaec
11 changed files with 515 additions and 507 deletions

View File

@ -119,7 +119,7 @@ set (liblogdiag_SOURCES
liblogdiag/ld-diagram-object.c
liblogdiag/ld-diagram-symbol.c
liblogdiag/ld-diagram-connection.c
liblogdiag/ld-canvas.c
liblogdiag/ld-diagram-view.c
liblogdiag/ld-library.c
liblogdiag/ld-library-toolbar.c
liblogdiag/ld-symbol-category.c
@ -136,7 +136,7 @@ set (liblogdiag_HEADERS
liblogdiag/ld-diagram-object.h
liblogdiag/ld-diagram-symbol.h
liblogdiag/ld-diagram-connection.h
liblogdiag/ld-canvas.h
liblogdiag/ld-diagram-view.h
liblogdiag/ld-library.h
liblogdiag/ld-library-toolbar.h
liblogdiag/ld-symbol-category.h

View File

@ -1,93 +0,0 @@
/*
* ld-canvas.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_CANVAS_H__
#define __LD_CANVAS_H__
G_BEGIN_DECLS
#define LD_TYPE_CANVAS (ld_canvas_get_type ())
#define LD_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_CANVAS, LdCanvas))
#define LD_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_CANVAS, LdCanvasClass))
#define LD_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_CANVAS))
#define LD_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_CANVAS))
#define LD_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_CANVAS, LdCanvasClass))
typedef struct _LdCanvas LdCanvas;
typedef struct _LdCanvasPrivate LdCanvasPrivate;
typedef struct _LdCanvasClass LdCanvasClass;
/**
* LdCanvas:
*/
struct _LdCanvas
{
/*< private >*/
GtkDrawingArea parent_instance;
LdCanvasPrivate *priv;
};
struct _LdCanvasClass
{
/*< private >*/
GtkDrawingAreaClass parent_class;
guint cancel_operation_signal;
guint move_signal;
void (*set_scroll_adjustments) (LdCanvas *self,
GtkAdjustment *horizontal, GtkAdjustment *vertical);
void (*cancel_operation) (LdCanvas *self);
void (*move) (LdCanvas *self, gdouble dx, gdouble dy);
};
/**
* LD_CANVAS_BASE_UNIT_LENGTH:
*
* Length of the base unit in milimetres.
*/
#define LD_CANVAS_BASE_UNIT_LENGTH 2.5
GType ld_canvas_get_type (void) G_GNUC_CONST;
GtkWidget *ld_canvas_new (void);
void ld_canvas_set_diagram (LdCanvas *self, LdDiagram *diagram);
LdDiagram *ld_canvas_get_diagram (LdCanvas *self);
void ld_canvas_set_library (LdCanvas *self, LdLibrary *library);
LdLibrary *ld_canvas_get_library (LdCanvas *self);
void ld_canvas_widget_to_diagram_coords (LdCanvas *self,
gdouble wx, gdouble wy, gdouble *dx, gdouble *dy);
void ld_canvas_diagram_to_widget_coords (LdCanvas *self,
gdouble dx, gdouble dy, gdouble *wx, gdouble *wy);
gdouble ld_canvas_get_zoom (LdCanvas *self);
void ld_canvas_set_zoom (LdCanvas *self, gdouble zoom);
gboolean ld_canvas_can_zoom_in (LdCanvas *self);
void ld_canvas_zoom_in (LdCanvas *self);
gboolean ld_canvas_can_zoom_out (LdCanvas *self);
void ld_canvas_zoom_out (LdCanvas *self);
void ld_canvas_add_object_begin (LdCanvas *self, LdDiagramObject *object);
G_END_DECLS
#endif /* ! __LD_CANVAS_H__ */

View File

@ -17,7 +17,7 @@
/**
* SECTION:ld-diagram-object
* @short_description: A diagram object
* @see_also: #LdDiagram, #LdCanvas
* @see_also: #LdDiagram, #LdDiagramView
*
* #LdDiagramObject represents an object in an #LdDiagram.
*/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
/*
* ld-diagram-view.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010 - 2011. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_DIAGRAM_VIEW_H__
#define __LD_DIAGRAM_VIEW_H__
G_BEGIN_DECLS
#define LD_TYPE_DIAGRAM_VIEW (ld_diagram_view_get_type ())
#define LD_DIAGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_DIAGRAM_VIEW, LdDiagramView))
#define LD_DIAGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_DIAGRAM_VIEW, LdDiagramViewClass))
#define LD_IS_DIAGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_DIAGRAM_VIEW))
#define LD_IS_DIAGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_DIAGRAM_VIEW))
#define LD_DIAGRAM_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_DIAGRAM_VIEW, LdDiagramViewClass))
typedef struct _LdDiagramView LdDiagramView;
typedef struct _LdDiagramViewPrivate LdDiagramViewPrivate;
typedef struct _LdDiagramViewClass LdDiagramViewClass;
/**
* LdDiagramView:
*/
struct _LdDiagramView
{
/*< private >*/
GtkDrawingArea parent_instance;
LdDiagramViewPrivate *priv;
};
struct _LdDiagramViewClass
{
/*< private >*/
GtkDrawingAreaClass parent_class;
guint cancel_operation_signal;
guint move_signal;
void (*set_scroll_adjustments) (LdDiagramView *self,
GtkAdjustment *horizontal, GtkAdjustment *vertical);
void (*cancel_operation) (LdDiagramView *self);
void (*move) (LdDiagramView *self, gdouble dx, gdouble dy);
};
/**
* LD_DIAGRAM_VIEW_BASE_UNIT_LENGTH:
*
* Length of the base unit in milimetres.
*/
#define LD_DIAGRAM_VIEW_BASE_UNIT_LENGTH 2.5
GType ld_diagram_view_get_type (void) G_GNUC_CONST;
GtkWidget *ld_diagram_view_new (void);
void ld_diagram_view_set_diagram (LdDiagramView *self, LdDiagram *diagram);
LdDiagram *ld_diagram_view_get_diagram (LdDiagramView *self);
void ld_diagram_view_set_library (LdDiagramView *self, LdLibrary *library);
LdLibrary *ld_diagram_view_get_library (LdDiagramView *self);
void ld_diagram_view_widget_to_diagram_coords (LdDiagramView *self,
gdouble wx, gdouble wy, gdouble *dx, gdouble *dy);
void ld_diagram_view_diagram_to_widget_coords (LdDiagramView *self,
gdouble dx, gdouble dy, gdouble *wx, gdouble *wy);
gdouble ld_diagram_view_get_zoom (LdDiagramView *self);
void ld_diagram_view_set_zoom (LdDiagramView *self, gdouble zoom);
gboolean ld_diagram_view_can_zoom_in (LdDiagramView *self);
void ld_diagram_view_zoom_in (LdDiagramView *self);
gboolean ld_diagram_view_can_zoom_out (LdDiagramView *self);
void ld_diagram_view_zoom_out (LdDiagramView *self);
void ld_diagram_view_add_object_begin (LdDiagramView *self,
LdDiagramObject *object);
G_END_DECLS
#endif /* ! __LD_DIAGRAM_VIEW_H__ */

View File

@ -15,7 +15,7 @@
/**
* SECTION:ld-diagram
* @short_description: A model for diagrams
* @see_also: #LdCanvas
* @see_also: #LdDiagramView
*
* #LdDiagram is a model used for storing diagrams.
*/

View File

@ -61,25 +61,25 @@ struct _SymbolMenuData
enum
{
CANVAS_HANDLER_EXPOSE,
CANVAS_HANDLER_MOTION_NOTIFY,
CANVAS_HANDLER_BUTTON_PRESS,
CANVAS_HANDLER_BUTTON_RELEASE,
CANVAS_HANDLER_COUNT
VIEW_HANDLER_EXPOSE,
VIEW_HANDLER_MOTION_NOTIFY,
VIEW_HANDLER_BUTTON_PRESS,
VIEW_HANDLER_BUTTON_RELEASE,
VIEW_HANDLER_COUNT
};
/*
* LdLibraryToolbarPrivate:
* @library: a library object assigned to this canvas as a model.
* @canvas: a canvas object for showing symbol menus.
* @canvas_handlers: signal handlers that hook the canvas.
* @library: a library object assigned as a model.
* @view: a view widget for showing symbol menus.
* @view_handlers: signal handlers that hook the view.
* @symbol_menu: data related to menus.
*/
struct _LdLibraryToolbarPrivate
{
LdLibrary *library;
LdCanvas *canvas;
gulong canvas_handlers[CANVAS_HANDLER_COUNT];
LdDiagramView *view;
gulong view_handlers[VIEW_HANDLER_COUNT];
SymbolMenuData symbol_menu;
};
@ -87,7 +87,7 @@ enum
{
PROP_0,
PROP_LIBRARY,
PROP_CANVAS
PROP_VIEW
};
static void ld_library_toolbar_get_property (GObject *object, guint property_id,
@ -106,16 +106,16 @@ static void emit_symbol_signal (LdLibraryToolbar *self,
static void on_category_toggle (GtkToggleButton *toggle_button,
gpointer user_data);
static inline void block_canvas_handlers (LdLibraryToolbar *self);
static inline void unblock_canvas_handlers (LdLibraryToolbar *self);
static inline void disconnect_canvas_handlers (LdLibraryToolbar *self);
static gboolean on_canvas_exposed (GtkWidget *widget,
static inline void block_view_handlers (LdLibraryToolbar *self);
static inline void unblock_view_handlers (LdLibraryToolbar *self);
static inline void disconnect_view_handlers (LdLibraryToolbar *self);
static gboolean on_view_exposed (GtkWidget *widget,
GdkEventExpose *event, gpointer user_data);
static gboolean on_canvas_motion_notify (GtkWidget *widget,
static gboolean on_view_motion_notify (GtkWidget *widget,
GdkEventMotion *event, gpointer user_data);
static gboolean on_canvas_button_press (GtkWidget *widget,
static gboolean on_view_button_press (GtkWidget *widget,
GdkEventButton *event, gpointer user_data);
static gboolean on_canvas_button_release (GtkWidget *widget,
static gboolean on_view_button_release (GtkWidget *widget,
GdkEventButton *event, gpointer user_data);
@ -138,22 +138,22 @@ ld_library_toolbar_class_init (LdLibraryToolbarClass *klass)
/**
* LdLibraryToolbar:library:
*
* The #LdLibrary that this canvas retrieves symbols from.
* The #LdLibrary that this toolbar retrieves symbols from.
*/
pspec = g_param_spec_object ("library", "Library",
"The library that this canvas retrieves symbols from.",
"The library that this toolbar retrieves symbols from.",
LD_TYPE_LIBRARY, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_LIBRARY, pspec);
/**
* LdLibraryToolbar:canvas:
* LdLibraryToolbar:view:
*
* The #LdCanvas misused for showing symbol menus.
* The #LdDiagramView widget misused for showing symbol menus.
*/
pspec = g_param_spec_object ("canvas", "Canvas",
"The canvas misused for showing symbol menus.",
LD_TYPE_CANVAS, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CANVAS, pspec);
pspec = g_param_spec_object ("view", "View",
"The view widget misused for showing symbol menus.",
LD_TYPE_DIAGRAM_VIEW, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_VIEW, pspec);
/**
* LdLibraryToolbar::symbol-chosen:
@ -218,7 +218,7 @@ ld_library_toolbar_dispose (GObject *gobject)
self = LD_LIBRARY_TOOLBAR (gobject);
ld_library_toolbar_set_library (self, NULL);
ld_library_toolbar_set_canvas (self, NULL);
ld_library_toolbar_set_view (self, NULL);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_library_toolbar_parent_class)->dispose (gobject);
@ -236,8 +236,8 @@ ld_library_toolbar_get_property (GObject *object, guint property_id,
case PROP_LIBRARY:
g_value_set_object (value, ld_library_toolbar_get_library (self));
break;
case PROP_CANVAS:
g_value_set_object (value, ld_library_toolbar_get_canvas (self));
case PROP_VIEW:
g_value_set_object (value, ld_library_toolbar_get_view (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -257,9 +257,9 @@ ld_library_toolbar_set_property (GObject *object, guint property_id,
ld_library_toolbar_set_library (self,
LD_LIBRARY (g_value_get_object (value)));
break;
case PROP_CANVAS:
ld_library_toolbar_set_canvas (self,
LD_CANVAS (g_value_get_object (value)));
case PROP_VIEW:
ld_library_toolbar_set_view (self,
LD_DIAGRAM_VIEW (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -281,7 +281,7 @@ ld_library_toolbar_new (void)
/**
* ld_library_toolbar_set_library:
* @self: an #LdLibraryToolbar object.
* @library: (allow-none): the #LdLibrary to be assigned to the toolbar.
* @library: (allow-none): the library to be assigned to the toolbar.
*
* Assign an #LdLibrary object to the toolbar.
*/
@ -315,8 +315,8 @@ ld_library_toolbar_set_library (LdLibraryToolbar *self, LdLibrary *library)
* ld_library_toolbar_get_library:
* @self: an #LdLibraryToolbar object.
*
* Get the #LdLibrary object assigned to this toolbar.
* The reference count on the library is not incremented.
* Return value: (transfer: none): the #LdLibrary object
* assigned to the toolbar.
*/
LdLibrary *
ld_library_toolbar_get_library (LdLibraryToolbar *self)
@ -326,59 +326,59 @@ ld_library_toolbar_get_library (LdLibraryToolbar *self)
}
/**
* ld_library_toolbar_set_canvas:
* ld_library_toolbar_set_view:
* @self: an #LdLibraryToolbar object.
* @canvas: (allow-none): the #LdCanvas to be assigned to the toolbar.
* @view: (allow-none): the widget to be assigned to the toolbar.
*
* Assign an #LdCanvas object to the toolbar.
* Assign an #LdDiagramView widget to the toolbar.
*/
void
ld_library_toolbar_set_canvas (LdLibraryToolbar *self, LdCanvas *canvas)
ld_library_toolbar_set_view (LdLibraryToolbar *self, LdDiagramView *view)
{
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
g_return_if_fail (LD_IS_CANVAS (canvas) || canvas == NULL);
g_return_if_fail (LD_IS_DIAGRAM_VIEW (view) || view == NULL);
if (self->priv->canvas)
if (self->priv->view)
{
disconnect_canvas_handlers (self);
g_object_unref (self->priv->canvas);
disconnect_view_handlers (self);
g_object_unref (self->priv->view);
}
self->priv->canvas = canvas;
self->priv->view = view;
if (canvas)
if (view)
{
self->priv->canvas_handlers[CANVAS_HANDLER_EXPOSE]
= g_signal_connect (canvas, "expose-event",
G_CALLBACK (on_canvas_exposed), self);
self->priv->canvas_handlers[CANVAS_HANDLER_MOTION_NOTIFY]
= g_signal_connect (canvas, "motion-notify-event",
G_CALLBACK (on_canvas_motion_notify), self);
self->priv->canvas_handlers[CANVAS_HANDLER_BUTTON_PRESS]
= g_signal_connect (canvas, "button-press-event",
G_CALLBACK (on_canvas_button_press), self);
self->priv->canvas_handlers[CANVAS_HANDLER_BUTTON_RELEASE]
= g_signal_connect (canvas, "button-release-event",
G_CALLBACK (on_canvas_button_release), self);
self->priv->view_handlers[VIEW_HANDLER_EXPOSE]
= g_signal_connect (view, "expose-event",
G_CALLBACK (on_view_exposed), self);
self->priv->view_handlers[VIEW_HANDLER_MOTION_NOTIFY]
= g_signal_connect (view, "motion-notify-event",
G_CALLBACK (on_view_motion_notify), self);
self->priv->view_handlers[VIEW_HANDLER_BUTTON_PRESS]
= g_signal_connect (view, "button-press-event",
G_CALLBACK (on_view_button_press), self);
self->priv->view_handlers[VIEW_HANDLER_BUTTON_RELEASE]
= g_signal_connect (view, "button-release-event",
G_CALLBACK (on_view_button_release), self);
block_canvas_handlers (self);
g_object_ref (canvas);
block_view_handlers (self);
g_object_ref (view);
}
g_object_notify (G_OBJECT (self), "canvas");
g_object_notify (G_OBJECT (self), "view");
}
/**
* ld_library_toolbar_get_canvas:
* ld_library_toolbar_get_view:
* @self: an #LdLibraryToolbar object.
*
* Get the #LdLibrary object assigned to this toolbar.
* The reference count on the canvas is not incremented.
* Return value: (transfer: none): the #LdDiagramView widget
* assigned to the toolbar.
*/
LdCanvas *
ld_library_toolbar_get_canvas (LdLibraryToolbar *self)
LdDiagramView *
ld_library_toolbar_get_view (LdLibraryToolbar *self)
{
g_return_val_if_fail (LD_IS_LIBRARY_TOOLBAR (self), NULL);
return self->priv->canvas;
return self->priv->view;
}
static void
@ -439,7 +439,7 @@ load_category_cb (gpointer data, gpointer user_data)
gtk_container_add (GTK_CONTAINER (button), img);
gtk_container_add (GTK_CONTAINER (item), button);
/* Don't steal focus from the canvas. */
/* Don't steal focus from the view. */
g_object_set (button, "can-focus", FALSE, NULL);
/* Assign the category to the toggle button. */
@ -498,7 +498,7 @@ redraw_symbol_menu (LdLibraryToolbar *self)
g_return_if_fail (LD_IS_LIBRARY_TOOLBAR (self));
data = &self->priv->symbol_menu;
gtk_widget_queue_draw_area (GTK_WIDGET (self->priv->canvas),
gtk_widget_queue_draw_area (GTK_WIDGET (self->priv->view),
0, data->menu_y - 1, data->menu_width + 2, data->menu_height + 2);
}
@ -541,7 +541,7 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
{
gint i;
block_canvas_handlers (self);
block_view_handlers (self);
g_object_unref (data->active_button);
data->active_button = NULL;
@ -559,7 +559,7 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
g_free (data->items);
data->items = NULL;
gtk_grab_remove (GTK_WIDGET (self->priv->canvas));
gtk_grab_remove (GTK_WIDGET (self->priv->view));
}
else
{
@ -568,12 +568,12 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
gint x, y, menu_width;
g_return_if_fail (gtk_widget_translate_coordinates (GTK_WIDGET
(toggle_button), GTK_WIDGET (priv->canvas), 0, 0, &x, &y));
(toggle_button), GTK_WIDGET (priv->view), 0, 0, &x, &y));
data->menu_y = y;
data->menu_height = GTK_WIDGET (toggle_button)->allocation.height;
unblock_canvas_handlers (self);
unblock_view_handlers (self);
data->active_button = toggle_button;
g_object_ref (data->active_button);
@ -616,28 +616,28 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
}
data->menu_width = menu_width;
gtk_grab_add (GTK_WIDGET (self->priv->canvas));
gtk_grab_add (GTK_WIDGET (self->priv->view));
}
redraw_symbol_menu (self);
}
#define DEFINE_CANVAS_HANDLER_FUNC(name) \
#define DEFINE_VIEW_HANDLER_FUNC(name) \
static inline void \
name ## _canvas_handlers (LdLibraryToolbar *self) \
name ## _view_handlers (LdLibraryToolbar *self) \
{ \
gint i; \
g_return_if_fail (LD_IS_CANVAS (self->priv->canvas)); \
for (i = 0; i < CANVAS_HANDLER_COUNT; i++) \
g_signal_handler_ ## name (self->priv->canvas, \
self->priv->canvas_handlers[i]); \
g_return_if_fail (LD_IS_DIAGRAM_VIEW (self->priv->view)); \
for (i = 0; i < VIEW_HANDLER_COUNT; i++) \
g_signal_handler_ ## name (self->priv->view, \
self->priv->view_handlers[i]); \
}
DEFINE_CANVAS_HANDLER_FUNC (block)
DEFINE_CANVAS_HANDLER_FUNC (unblock)
DEFINE_CANVAS_HANDLER_FUNC (disconnect)
DEFINE_VIEW_HANDLER_FUNC (block)
DEFINE_VIEW_HANDLER_FUNC (unblock)
DEFINE_VIEW_HANDLER_FUNC (disconnect)
static gboolean
on_canvas_exposed (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
on_view_exposed (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
cairo_t *cr;
LdLibraryToolbar *self;
@ -702,7 +702,7 @@ on_canvas_exposed (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
}
static gboolean
on_canvas_motion_notify (GtkWidget *widget, GdkEventMotion *event,
on_view_motion_notify (GtkWidget *widget, GdkEventMotion *event,
gpointer user_data)
{
LdLibraryToolbar *self;
@ -715,7 +715,7 @@ on_canvas_motion_notify (GtkWidget *widget, GdkEventMotion *event,
if (widget->window != event->window
|| event->x < 0 || event->y < data->menu_y
|| event->y >= data->menu_y + data->menu_height)
goto on_canvas_motion_notify_end;
goto on_view_motion_notify_end;
for (x = i = 0; i < data->n_items; i++)
{
@ -727,7 +727,7 @@ on_canvas_motion_notify (GtkWidget *widget, GdkEventMotion *event,
}
}
on_canvas_motion_notify_end:
on_view_motion_notify_end:
if (data->active_item != at_cursor)
{
emit_symbol_signal (self, LD_LIBRARY_TOOLBAR_GET_CLASS (self)
@ -743,7 +743,7 @@ on_canvas_motion_notify_end:
}
static gboolean
on_canvas_button_press (GtkWidget *widget, GdkEventButton *event,
on_view_button_press (GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
LdLibraryToolbar *self;
@ -764,7 +764,7 @@ on_canvas_button_press (GtkWidget *widget, GdkEventButton *event,
}
static gboolean
on_canvas_button_release (GtkWidget *widget, GdkEventButton *event,
on_view_button_release (GtkWidget *widget, GdkEventButton *event,
gpointer user_data)
{
LdLibraryToolbar *self;

View File

@ -59,9 +59,9 @@ GtkWidget *ld_library_toolbar_new (void);
void ld_library_toolbar_set_library (LdLibraryToolbar *self,
LdLibrary *library);
LdLibrary *ld_library_toolbar_get_library (LdLibraryToolbar *self);
void ld_library_toolbar_set_canvas (LdLibraryToolbar *self,
LdCanvas *canvas);
LdCanvas *ld_library_toolbar_get_canvas (LdLibraryToolbar *self);
void ld_library_toolbar_set_view (LdLibraryToolbar *self,
LdDiagramView *view);
LdDiagramView *ld_library_toolbar_get_view (LdLibraryToolbar *self);
G_END_DECLS

View File

@ -15,9 +15,9 @@
/**
* SECTION:ld-symbol
* @short_description: A symbol
* @see_also: #LdDiagramSymbol, #LdCanvas
* @see_also: #LdDiagramSymbol, #LdDiagramView
*
* #LdSymbol represents a symbol to be drawn onto a #LdCanvas.
* #LdSymbol represents a symbol to be drawn by #LdDiagramView.
*
* All implementations of this abstract class are required to use
* cairo_save() and cairo_restore() when drawing to store the state.

View File

@ -27,7 +27,7 @@
#include "ld-diagram-connection.h"
#include "ld-diagram.h"
#include "ld-canvas.h"
#include "ld-diagram-view.h"
#include "ld-library-toolbar.h"
#include "ld-lua.h"

View File

@ -32,8 +32,8 @@ struct _LdWindowMainPrivate
LdDiagram *diagram;
gchar *filename;
GtkWidget *canvas_window;
LdCanvas *canvas;
GtkWidget *scrolled_window;
LdDiagramView *view;
GtkWidget *statusbar;
guint statusbar_symbol_context_id;
@ -59,7 +59,7 @@ static void update_title (LdWindowMain *self);
static void action_set_sensitive (LdWindowMain *self, const gchar *name,
gboolean sensitive);
static void on_canvas_zoom_changed (LdCanvas *canvas,
static void on_view_zoom_changed (LdDiagramView *view,
GParamSpec *pspec, LdWindowMain *self);
static void on_diagram_changed (LdDiagram *diagram, LdWindowMain *self);
@ -242,10 +242,10 @@ ld_window_main_init (LdWindowMain *self)
gtk_toolbar_set_orientation (GTK_TOOLBAR (priv->library_toolbar),
GTK_ORIENTATION_VERTICAL);
priv->canvas = LD_CANVAS (ld_canvas_new ());
priv->canvas_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (priv->canvas_window),
GTK_WIDGET (priv->canvas));
priv->view = LD_DIAGRAM_VIEW (ld_diagram_view_new ());
priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (priv->scrolled_window),
GTK_WIDGET (priv->view));
priv->statusbar = gtk_statusbar_new ();
priv->statusbar_menu_context_id = gtk_statusbar_get_context_id
@ -257,7 +257,7 @@ ld_window_main_init (LdWindowMain *self)
priv->hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->library_toolbar,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->canvas_window,
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->scrolled_window,
TRUE, TRUE, 0);
priv->vbox = gtk_vbox_new (FALSE, 0);
@ -292,16 +292,16 @@ ld_window_main_init (LdWindowMain *self)
priv->library = ld_library_new ();
ld_library_load (priv->library, PROJECT_SHARE_DIR "library");
ld_canvas_set_diagram (priv->canvas, priv->diagram);
ld_canvas_set_library (priv->canvas, priv->library);
ld_diagram_view_set_diagram (priv->view, priv->diagram);
ld_diagram_view_set_library (priv->view, priv->library);
g_signal_connect (priv->canvas, "notify::zoom",
G_CALLBACK (on_canvas_zoom_changed), self);
g_signal_connect (priv->view, "notify::zoom",
G_CALLBACK (on_view_zoom_changed), self);
ld_library_toolbar_set_library (LD_LIBRARY_TOOLBAR (priv->library_toolbar),
priv->library);
ld_library_toolbar_set_canvas (LD_LIBRARY_TOOLBAR (priv->library_toolbar),
priv->canvas);
ld_library_toolbar_set_view (LD_LIBRARY_TOOLBAR (priv->library_toolbar),
priv->view);
g_signal_connect_after (priv->library_toolbar, "symbol-selected",
G_CALLBACK (on_symbol_selected), self);
@ -317,7 +317,7 @@ ld_window_main_init (LdWindowMain *self)
action_set_sensitive (self, "Delete", FALSE);
action_set_sensitive (self, "NormalSize", FALSE);
gtk_widget_grab_focus (GTK_WIDGET (priv->canvas));
gtk_widget_grab_focus (GTK_WIDGET (priv->view));
/* Realize the window. */
gtk_widget_show_all (GTK_WIDGET (self));
@ -529,8 +529,8 @@ diagram_new (LdWindowMain *self)
ld_diagram_clear (self->priv->diagram);
ld_diagram_set_modified (self->priv->diagram, FALSE);
/* TODO: Reset canvas view to the center. */
ld_canvas_set_zoom (self->priv->canvas, 1);
/* TODO: Reset view to the center. */
ld_diagram_view_set_zoom (self->priv->view, 1);
diagram_set_filename (self, NULL);
}
@ -805,19 +805,20 @@ on_symbol_chosen (LdLibraryToolbar *toolbar, LdSymbol *symbol,
diagram_symbol = ld_diagram_symbol_new (NULL);
ld_diagram_symbol_set_class (diagram_symbol, klass);
ld_canvas_add_object_begin (self->priv->canvas,
ld_diagram_view_add_object_begin (self->priv->view,
LD_DIAGRAM_OBJECT (diagram_symbol));
}
static void
on_canvas_zoom_changed (LdCanvas *canvas, GParamSpec *pspec, LdWindowMain *self)
on_view_zoom_changed (LdDiagramView *view, GParamSpec *pspec,
LdWindowMain *self)
{
action_set_sensitive (self, "ZoomIn",
ld_canvas_can_zoom_in (self->priv->canvas));
ld_diagram_view_can_zoom_in (self->priv->view));
action_set_sensitive (self, "ZoomOut",
ld_canvas_can_zoom_out (self->priv->canvas));
ld_diagram_view_can_zoom_out (self->priv->view));
action_set_sensitive (self, "NormalSize",
ld_canvas_get_zoom (self->priv->canvas) != 1);
ld_diagram_view_get_zoom (self->priv->view) != 1);
}
static void
@ -889,17 +890,17 @@ on_action_select_all (GtkAction *action, LdWindowMain *self)
static void
on_action_zoom_in (GtkAction *action, LdWindowMain *self)
{
ld_canvas_zoom_in (self->priv->canvas);
ld_diagram_view_zoom_in (self->priv->view);
}
static void
on_action_zoom_out (GtkAction *action, LdWindowMain *self)
{
ld_canvas_zoom_out (self->priv->canvas);
ld_diagram_view_zoom_out (self->priv->view);
}
static void
on_action_normal_size (GtkAction *action, LdWindowMain *self)
{
ld_canvas_set_zoom (self->priv->canvas, 1);
ld_diagram_view_set_zoom (self->priv->view, 1);
}