+
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = req.width;
+ rect.height = req.height;
+
+ gtk_widget_queue_draw(drawing->ruler);
+ //gtk_widget_draw( drawing->ruler, &rect);
+}
+
+/* Redraw the ruler */
+static gboolean
+expose_ruler( GtkWidget *widget, GdkEventExpose *event, gpointer user_data )
+{
+ Drawing_t *drawing = (Drawing_t*)user_data;
+
+ gchar text[255];
+
+ PangoContext *context;
+ PangoLayout *layout;
+ PangoAttribute *attribute;
+ PangoFontDescription *FontDesc;
+ gint Font_Size;
+ PangoRectangle ink_rect;
+ guint global_width=0;
+ GdkColor foreground = { 0, 0, 0, 0 };
+ GdkColor background = { 0, 0xffff, 0xffff, 0xffff };
+
+ LttTime window_end =
+ ltt_time_add(drawing->control_flow_data->time_window.time_width,
+ drawing->control_flow_data->time_window.start_time);
+ LttTime half_width =
+ ltt_time_div(drawing->control_flow_data->time_window.time_width,2.0);
+ LttTime window_middle =
+ ltt_time_add(half_width,
+ drawing->control_flow_data->time_window.start_time);
+ g_critical("ruler expose event");
+
+ gdk_draw_rectangle (drawing->ruler->window,
+ drawing->ruler->style->white_gc,
+ TRUE,
+ event->area.x, event->area.y,
+ event->area.width,
+ event->area.height);
+
+ GdkGC *gc = gdk_gc_new(drawing->ruler->window);
+ gdk_gc_copy(gc, drawing->ruler->style->black_gc);
+ gdk_gc_set_line_attributes(gc,
+ 2,
+ GDK_LINE_SOLID,
+ GDK_CAP_BUTT,
+ GDK_JOIN_MITER);
+ gdk_draw_line (drawing->ruler->window,
+ gc,
+ event->area.x, 1,
+ event->area.x + event->area.width, 1);
+
+
+ snprintf(text, 255, "%lus\n%luns",
+ drawing->control_flow_data->time_window.start_time.tv_sec,
+ drawing->control_flow_data->time_window.start_time.tv_nsec);
+
+ layout = gtk_widget_create_pango_layout(drawing->drawing_area, NULL);
+
+ context = pango_layout_get_context(layout);
+ FontDesc = pango_context_get_font_description(context);
+
+ pango_font_description_set_size(FontDesc, 6*PANGO_SCALE);
+ pango_layout_context_changed(layout);
+
+ pango_layout_set_text(layout, text, -1);
+ pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
+ global_width += ink_rect.width;
+
+ gdk_draw_layout_with_colors(drawing->ruler->window,
+ gc,
+ 0,
+ 6,
+ layout, &foreground, &background);
+
+ gdk_gc_set_line_attributes(gc,
+ 2,
+ GDK_LINE_SOLID,
+ GDK_CAP_ROUND,
+ GDK_JOIN_ROUND);
+
+ gdk_draw_line (drawing->ruler->window,
+ gc,
+ 1, 1,
+ 1, 7);
+
+
+ snprintf(text, 255, "%lus\n%luns", window_end.tv_sec,
+ window_end.tv_nsec);
+
+ pango_layout_set_text(layout, text, -1);
+ pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
+ global_width += ink_rect.width;
+
+ if(global_width <= drawing->ruler->allocation.width)
+ {
+ gdk_draw_layout_with_colors(drawing->ruler->window,
+ gc,
+ drawing->ruler->allocation.width - ink_rect.width,
+ 6,
+ layout, &foreground, &background);
+
+ gdk_gc_set_line_attributes(gc,
+ 2,
+ GDK_LINE_SOLID,
+ GDK_CAP_ROUND,
+ GDK_JOIN_ROUND);
+
+ gdk_draw_line (drawing->ruler->window,
+ gc,
+ drawing->ruler->allocation.width-1, 1,
+ drawing->ruler->allocation.width-1, 7);
+ }
+
+
+ snprintf(text, 255, "%lus\n%luns", window_middle.tv_sec,
+ window_middle.tv_nsec);
+
+ pango_layout_set_text(layout, text, -1);
+ pango_layout_get_pixel_extents(layout, &ink_rect, NULL);
+ global_width += ink_rect.width;
+
+ if(global_width <= drawing->ruler->allocation.width)
+ {
+ gdk_draw_layout_with_colors(drawing->ruler->window,
+ gc,
+ (drawing->ruler->allocation.width - ink_rect.width)/2,
+ 6,
+ layout, &foreground, &background);
+
+ gdk_gc_set_line_attributes(gc,
+ 2,
+ GDK_LINE_SOLID,
+ GDK_CAP_ROUND,
+ GDK_JOIN_ROUND);
+
+ gdk_draw_line (drawing->ruler->window,
+ gc,
+ drawing->ruler->allocation.width/2, 1,
+ drawing->ruler->allocation.width/2, 7);
+
+
+
+
+ }
+
+ gdk_gc_unref(gc);
+ g_object_unref(layout);
+
+ return FALSE;
+}
+
+
+/* notify mouse on ruler */
+static gboolean
+motion_notify_ruler(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
+{
+ //g_critical("motion");
+ //eventually follow mouse and show time here
+}