From c8caca073ff7af35bbfabcdaa59e13de005e90d1 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Sun, 6 Mar 2011 15:56:41 +0100 Subject: Add API for turning off the grid. --- liblogdiag/ld-diagram-view.c | 38 +++++++++++++++++++++++++++++++++++++- liblogdiag/ld-diagram-view.h | 3 +++ 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'liblogdiag') diff --git a/liblogdiag/ld-diagram-view.c b/liblogdiag/ld-diagram-view.c index 212bf4f..8b0afe0 100644 --- a/liblogdiag/ld-diagram-view.c +++ b/liblogdiag/ld-diagram-view.c @@ -121,6 +121,7 @@ Color; * @x: the X coordinate of the center of view. * @y: the Y coordinate of the center of view. * @zoom: the current zoom. + * @show_grid: whether to show the grid. * @terminal: position of the highlighted terminal. * @terminal_hovered: whether a terminal is hovered. * @drag_start_pos: position of the mouse pointer when dragging started. @@ -142,6 +143,8 @@ struct _LdDiagramViewPrivate gdouble y; gdouble zoom; + gboolean show_grid; + LdPoint terminal; gboolean terminal_hovered; @@ -471,6 +474,8 @@ ld_diagram_view_init (LdDiagramView *self) self->priv->y = 0; self->priv->zoom = ZOOM_DEFAULT; + self->priv->show_grid = TRUE; + color_set (COLOR_GET (self, COLOR_BASE), 1, 1, 1, 1); color_set (COLOR_GET (self, COLOR_GRID), 0.5, 0.5, 0.5, 1); color_set (COLOR_GET (self, COLOR_OBJECT), 0, 0, 0, 1); @@ -1092,6 +1097,35 @@ ld_diagram_view_zoom_out (LdDiagramView *self) ld_diagram_view_set_zoom (self, self->priv->zoom / ZOOM_STEP); } +/** + * ld_diagram_view_get_show_grid: + * @self: an #LdDiagramView object. + * + * Return value: whether the grid is shown. + */ +gboolean +ld_diagram_view_get_show_grid (LdDiagramView *self) +{ + g_return_val_if_fail (LD_IS_DIAGRAM_VIEW (self), FALSE); + return self->priv->show_grid; +} + +/** + * ld_diagram_view_set_show_grid: + * @self: an #LdDiagramView object. + * @show_grid: whether to show the grid. + * + * Set whether the grid is shown. + */ +void +ld_diagram_view_set_show_grid (LdDiagramView *self, gboolean show_grid) +{ + g_return_if_fail (LD_IS_DIAGRAM_VIEW (self)); + + self->priv->show_grid = show_grid; + gtk_widget_queue_draw (GTK_WIDGET (self)); +} + /* ===== Helper functions ================================================== */ @@ -2298,7 +2332,9 @@ on_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) color_apply (COLOR_GET (data.self, COLOR_BASE), data.cr); cairo_paint (data.cr); - draw_grid (widget, &data); + if (data.self->priv->show_grid) + draw_grid (widget, &data); + draw_diagram (widget, &data); draw_terminal (widget, &data); diff --git a/liblogdiag/ld-diagram-view.h b/liblogdiag/ld-diagram-view.h index 8ba9fc1..8c5bd15 100644 --- a/liblogdiag/ld-diagram-view.h +++ b/liblogdiag/ld-diagram-view.h @@ -90,6 +90,9 @@ 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); +gboolean ld_diagram_view_get_show_grid (LdDiagramView *self); +void ld_diagram_view_set_show_grid (LdDiagramView *self, gboolean show_grid); + void ld_diagram_view_add_object_begin (LdDiagramView *self, LdDiagramObject *object); -- cgit v1.2.3-70-g09d2