From 3419680f2523414d4ac7349232eb92b627dd993a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Tue, 7 Dec 2010 00:59:05 +0100
Subject: Implement more of LdCanvas.
1. Add methods for coordinate translation between cairo/GtkWidget
coordinates and LdDocument coordinates.
2. Draw the grid correctly (also make it significantly faster).
3. Place the canvas into a GtkScrolledWindow and register
the set_scroll_adjustments signal in the GtkWidget base class.
4. Allow scrolling inside of an area of 200 x 200 units (for now).
In the future, it should be possible to go to infinity.
---
src/ld-window-main.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
(limited to 'src/ld-window-main.c')
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index bcacf3f..99910d8 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -97,6 +97,8 @@ struct _LdWindowMainPrivate
GtkWidget *toolbar;
LdLibrary *library;
+
+ GtkWidget *canvas_window;
LdCanvas *canvas;
GtkWidget *statusbar;
@@ -270,10 +272,9 @@ ld_window_main_init (LdWindowMain *self)
/* TODO in the future: GtkHPaned */
/* Canvas. */
- /* TODO: Put it into a GtkScrolledWindow. */
priv->canvas = ld_canvas_new ();
- /* TODO: To be able to draw a symbol menu over the canvas, we may:
+ /* XXX: To be able to draw a symbol menu over the canvas, we may:
* 1. Hook the expose-event and button-{press,release}-event signals.
* 2. Create a hook mechanism in the LdCanvas object.
* + The cairo context would not have to be created twice.
@@ -297,7 +298,10 @@ ld_window_main_init (LdWindowMain *self)
g_signal_handler_block (priv->canvas,
priv->symbol_menu.button_release_handler);
- gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->canvas),
+ priv->canvas_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (priv->canvas_window),
+ GTK_WIDGET (priv->canvas));
+ gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->canvas_window),
TRUE, TRUE, 0);
priv->statusbar = gtk_statusbar_new ();
--
cgit v1.2.3