[xiph-commits] r12045 - trunk/sushivision
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Mon Nov 6 13:32:04 PST 2006
Author: xiphmont
Date: 2006-11-06 13:32:02 -0800 (Mon, 06 Nov 2006)
New Revision: 12045
Modified:
trunk/sushivision/plot.c
trunk/sushivision/plot.h
Log:
Display a focus stipple box around the plot pane when it is focused
Modified: trunk/sushivision/plot.c
===================================================================
--- trunk/sushivision/plot.c 2006-11-06 21:18:14 UTC (rev 12044)
+++ trunk/sushivision/plot.c 2006-11-06 21:32:02 UTC (rev 12045)
@@ -260,6 +260,23 @@
cairo_stroke(c);
}
+ if(p->widgetfocus){
+ double dashes[] = {1., /* ink */
+ 1.};
+ cairo_save(c);
+ cairo_set_dash (c, dashes, 2, .5);
+ cairo_set_source_rgba(c,0.,0.,0.,1.);
+ cairo_set_line_width(c,1.);
+ cairo_rectangle(c,.5,.5,
+ widget->allocation.width-1.,
+ widget->allocation.height-1.);
+ cairo_stroke_preserve (c);
+ cairo_set_dash (c, dashes, 2, 1.5);
+ cairo_set_source_rgba(c,1.,1.,1.,1.);
+ cairo_stroke(c);
+ cairo_restore(c);
+ }
+
cairo_destroy(c);
// blit to window
@@ -296,7 +313,6 @@
GdkEventKey *event){
Plot *p = PLOT(widget);
- fprintf(stderr,"KEY");
int shift = (event->state&GDK_SHIFT_MASK);
if(event->state&GDK_MOD1_MASK) return FALSE;
if(event->state&GDK_CONTROL_MASK)return FALSE;
@@ -317,7 +333,29 @@
return TRUE;
case GDK_Left:
+ {
+ double x = scalespace_pixel(&p->x,p->selx)-1;
+ if(shift)
+ x-=9;
+ p->selx = scalespace_value(&p->x,x);
+ if(p->crosshairs_callback)
+ p->crosshairs_callback(p->cross_data);
+ plot_expose_request(p);
+ }
+ return TRUE;
+
case GDK_Right:
+ {
+ double x = scalespace_pixel(&p->x,p->selx)+1;
+ if(shift)
+ x+=9;
+ p->selx = scalespace_value(&p->x,x);
+ if(p->crosshairs_callback)
+ p->crosshairs_callback(p->cross_data);
+ plot_expose_request(p);
+
+ }
+ return TRUE;
case GDK_Up:
case GDK_Down:
break;
@@ -332,6 +370,7 @@
gint attributes_mask;
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
@@ -478,6 +517,7 @@
p->box_active = 0;
p->button_down=1;
}
+ gtk_widget_grab_focus(widget);
return TRUE;
}
@@ -521,6 +561,22 @@
return TRUE;
}
+static gboolean plot_unfocus(GtkWidget *widget,
+ GdkEventFocus *event){
+ Plot *p=PLOT(widget);
+ p->widgetfocus=0;
+ plot_expose_request(p);
+ return TRUE;
+}
+
+static gboolean plot_refocus(GtkWidget *widget,
+ GdkEventFocus *event){
+ Plot *p=PLOT(widget);
+ p->widgetfocus=1;
+ plot_expose_request(p);
+ return TRUE;
+}
+
static void plot_class_init (PlotClass * class) {
GtkObjectClass *object_class;
@@ -540,10 +596,13 @@
widget_class->button_press_event = mouse_press;
widget_class->button_release_event = mouse_release;
widget_class->motion_notify_event = mouse_motion;
- widget_class->enter_notify_event = plot_enter;
- widget_class->leave_notify_event = plot_leave;
+ //widget_class->enter_notify_event = plot_enter;
+ //widget_class->leave_notify_event = plot_leave;
widget_class->key_press_event = key_press;
+ widget_class->focus_out_event = plot_unfocus;
+ widget_class->focus_in_event = plot_refocus;
+
}
GType plot_get_type (void){
Modified: trunk/sushivision/plot.h
===================================================================
--- trunk/sushivision/plot.h 2006-11-06 21:18:14 UTC (rev 12044)
+++ trunk/sushivision/plot.h 2006-11-06 21:32:02 UTC (rev 12045)
@@ -44,6 +44,7 @@
cairo_surface_t *back;
cairo_surface_t *fore;
cairo_surface_t *stage;
+ int widgetfocus;
int scalespacing;
scalespace x;
More information about the commits
mailing list