Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added click and drag functionality

  • Loading branch information...
commit 8e0c8e4bcb5083456afedcc1594e3c404b5e93c5 1 parent 2a9ede8
@pchilds authored
View
62 gtk2plot/gtkplotlinear.c
@@ -100,29 +100,38 @@ static void drawz(GtkWidget *widget, cairo_t *cr)
cairo_rectangle(cr, xw-10.5, 0.5, 10, 10);
cairo_move_to(cr, xw-9, 5.5);
cairo_line_to(cr, xw-2, 5.5);
- cairo_move_to(cr, xw-5.5, 2);
- cairo_line_to(cr, xw-5.5, 9);
- if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0)
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0)
{
- cairo_move_to(cr, xw-6.5, 2.5);
- cairo_line_to(cr, xw-5.5, 2);
- cairo_line_to(cr, xw-4.5, 2.5);
cairo_move_to(cr, xw-2.5, 4.5);
cairo_line_to(cr, xw-2, 5.5);
cairo_line_to(cr, xw-2.5, 6.5);
- cairo_move_to(cr, xw-6.5, 8.5);
- cairo_line_to(cr, xw-5.5, 9);
- cairo_line_to(cr, xw-4.5, 8.5);
- cairo_move_to(cr, xw-8.5, 4.5);
- cairo_line_to(cr, xw-9, 5.5);
- cairo_line_to(cr, xw-8.5, 6.5);
}
else
{
- cairo_move_to(cr, xw-7.5, 3.5);
- cairo_line_to(cr, xw-3.5, 7.5);
- cairo_move_to(cr, xw-7.5, 7.5);
- cairo_line_to(cr, xw-3.5, 3.5);
+ cairo_move_to(cr, xw-5.5, 2);
+ cairo_line_to(cr, xw-5.5, 9);
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0)
+ {
+ cairo_move_to(cr, xw-6.5, 2.5);
+ cairo_line_to(cr, xw-5.5, 2);
+ cairo_line_to(cr, xw-4.5, 2.5);
+ cairo_move_to(cr, xw-2.5, 4.5);
+ cairo_line_to(cr, xw-2, 5.5);
+ cairo_line_to(cr, xw-2.5, 6.5);
+ cairo_move_to(cr, xw-6.5, 8.5);
+ cairo_line_to(cr, xw-5.5, 9);
+ cairo_line_to(cr, xw-4.5, 8.5);
+ cairo_move_to(cr, xw-8.5, 4.5);
+ cairo_line_to(cr, xw-9, 5.5);
+ cairo_line_to(cr, xw-8.5, 6.5);
+ }
+ else
+ {
+ cairo_move_to(cr, xw-7.5, 3.5);
+ cairo_line_to(cr, xw-3.5, 7.5);
+ cairo_move_to(cr, xw-7.5, 7.5);
+ cairo_line_to(cr, xw-3.5, 3.5);
+ }
}
cairo_stroke(cr);
if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_SGL)!=0)
@@ -4073,7 +4082,8 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
yn=(priv->rescale.ymax)-(priv->rescale.ymin);
if (((xn>DZE)||(xn<NZE))&&((yn>DZE)||(yn<NZE)))
{
- if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0) gtk_plot_linear_update_scale_pretty(widget, (priv->rescale.xmin), (priv->rescale.xmax), (priv->rescale.ymin), (priv->rescale.ymax));
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0) gtk_plot_linear_update_scale_pretty(widget, xn+(priv->bounds.xmin), xn+(priv->bounds.xmax), yn+(priv->bounds.ymin), yn+(priv->bounds.ymax));
+ else if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0) gtk_plot_linear_update_scale_pretty(widget, (priv->rescale.xmin), (priv->rescale.xmax), (priv->rescale.ymin), (priv->rescale.ymax));
else
{
s=((priv->bounds.xmax)-(priv->bounds.xmin))/xn;
@@ -4162,19 +4172,19 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
{
if ((event->x)>=xw-11)
{
- (plot->zmode)^=GTK_PLOT_LINEAR_ZOOM_OUT;
- gtk_plot_linear_redraw(widget);
- }
- else if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_SGL)!=0)
- {
- (plot->zmode)&=GTK_PLOT_LINEAR_ZOOM_OUT;
- gtk_plot_linear_redraw(widget);
+ if (((plot->zmode)&(GTK_PLOT_LINEAR_ZOOM_DRG|GTK_PLOT_LINEAR_ZOOM_OUT))==0) {(plot->zmode)&=!GTK_PLOT_LINEAR_ZOOM_SGL; (plot->zmode)|=GTK_PLOT_LINEAR_ZOOM_DRG;}
+ else (plot->zmode)--;
}
else
{
- {(plot->zmode)++; (plot->zmode)++;}
- gtk_plot_linear_redraw(widget);
+ (plot->zmode)-=GTK_PLOT_LINEAR_ZOOM_HZT;
+ if (((plot->zmode)&(GTK_PLOT_LINEAR_ZOOM_SGL|GTK_PLOT_LINEAR_ZOOM_HZT|GTK_PLOT_LINEAR_ZOOM_VRT))==0)
+ {
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0) (plot->zmode)|=(GTK_PLOT_LINEAR_ZOOM_VRT|GTK_PLOT_LINEAR_ZOOM_HZT);
+ else (plot->zmode)|=GTK_PLOT_LINEAR_ZOOM_SGL;
+ }
}
+ gtk_plot_linear_redraw(widget);
}
}
return FALSE;
View
7 gtk2plot/gtkplotlinear.h
@@ -40,9 +40,10 @@
typedef enum
{
GTK_PLOT_LINEAR_ZOOM_OUT = 1 << 0,
- GTK_PLOT_LINEAR_ZOOM_HZT = 1 << 1,
- GTK_PLOT_LINEAR_ZOOM_VRT = 1 << 2,
- GTK_PLOT_LINEAR_ZOOM_SGL = 1 << 3
+ GTK_PLOT_LINEAR_ZOOM_DRG = 1 << 1,
+ GTK_PLOT_LINEAR_ZOOM_HZT = 1 << 2,
+ GTK_PLOT_LINEAR_ZOOM_VRT = 1 << 3,
+ GTK_PLOT_LINEAR_ZOOM_SGL = 1 << 4
} GtkPlotLinearZoom;
typedef enum
{
View
7 gtk2plot/gtkplotpolar.c
@@ -5531,8 +5531,11 @@ static gboolean gtk_plot_polar_button_release(GtkWidget *widget, GdkEventButton
if ((event->x)>=xw-22)
{
if ((event->x)>=xw-11) (plot->zmode)^=GTK_PLOT_POLAR_ZOOM_OUT;
- else if (((plot->zmode)&GTK_PLOT_POLAR_ZOOM_SGL)!=0) (plot->zmode)&=GTK_PLOT_POLAR_ZOOM_OUT;
- else {(plot->zmode)++; (plot->zmode)++;}
+ else
+ {
+ (plot->zmode)-=GTK_PLOT_POLAR_ZOOM_RDL;
+ if (((plot->zmode)&(GTK_PLOT_POLAR_ZOOM_SGL|GTK_PLOT_POLAR_ZOOM_AZT|GTK_PLOT_POLAR_ZOOM_RDL))==0) (plot->zmode)|=GTK_PLOT_POLAR_ZOOM_SGL;
+ }
gtk_plot_polar_redraw(widget);
}
}
View
72 gtk3plot/gtkplotlinear.c
@@ -96,40 +96,41 @@ static void drawz(GtkWidget *widget, cairo_t *cr)
cairo_rectangle(cr, xw-10.5, 0.5, 10, 10);
cairo_move_to(cr, xw-9, 5.5);
cairo_line_to(cr, xw-2, 5.5);
- cairo_move_to(cr, xw-5.5, 2);
- cairo_line_to(cr, xw-5.5, 9);
- if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0)
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0)
{
- cairo_move_to(cr, xw-6.5, 2.5);
- cairo_line_to(cr, xw-5.5, 2);
- cairo_line_to(cr, xw-4.5, 2.5);
cairo_move_to(cr, xw-2.5, 4.5);
cairo_line_to(cr, xw-2, 5.5);
cairo_line_to(cr, xw-2.5, 6.5);
- cairo_move_to(cr, xw-6.5, 8.5);
- cairo_line_to(cr, xw-5.5, 9);
- cairo_line_to(cr, xw-4.5, 8.5);
- cairo_move_to(cr, xw-8.5, 4.5);
- cairo_line_to(cr, xw-9, 5.5);
- cairo_line_to(cr, xw-8.5, 6.5);
}
else
{
- cairo_move_to(cr, xw-7.5, 3.5);
- cairo_line_to(cr, xw-3.5, 7.5);
- cairo_move_to(cr, xw-7.5, 7.5);
- cairo_line_to(cr, xw-3.5, 3.5);
+ cairo_move_to(cr, xw-5.5, 2);
+ cairo_line_to(cr, xw-5.5, 9);
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0)
+ {
+ cairo_move_to(cr, xw-6.5, 2.5);
+ cairo_line_to(cr, xw-5.5, 2);
+ cairo_line_to(cr, xw-4.5, 2.5);
+ cairo_move_to(cr, xw-2.5, 4.5);
+ cairo_line_to(cr, xw-2, 5.5);
+ cairo_line_to(cr, xw-2.5, 6.5);
+ cairo_move_to(cr, xw-6.5, 8.5);
+ cairo_line_to(cr, xw-5.5, 9);
+ cairo_line_to(cr, xw-4.5, 8.5);
+ cairo_move_to(cr, xw-8.5, 4.5);
+ cairo_line_to(cr, xw-9, 5.5);
+ cairo_line_to(cr, xw-8.5, 6.5);
+ }
+ else
+ {
+ cairo_move_to(cr, xw-7.5, 3.5);
+ cairo_line_to(cr, xw-3.5, 7.5);
+ cairo_move_to(cr, xw-7.5, 7.5);
+ cairo_line_to(cr, xw-3.5, 3.5);
+ }
}
cairo_stroke(cr);
- if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_SGL)!=0)
- {
- cairo_move_to(cr, xw-20, 2);
- cairo_line_to(cr, xw-13, 9);
- cairo_move_to(cr, xw-20, 9);
- cairo_line_to(cr, xw-13, 2);
- cairo_stroke(cr);
- }
- else
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_SGL)==0)
{
cairo_save(cr);
dt=1;
@@ -4046,7 +4047,8 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
yn=(priv->rescale.ymax)-(priv->rescale.ymin);
if (((xn>DZE)||(xn<NZE))&&((yn>DZE)||(yn<NZE)))
{
- if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0) gtk_plot_linear_update_scale_pretty(widget, (priv->rescale.xmin), (priv->rescale.xmax), (priv->rescale.ymin), (priv->rescale.ymax));
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0) gtk_plot_linear_update_scale_pretty(widget, xn+(priv->bounds.xmin), xn+(priv->bounds.xmax), yn+(priv->bounds.ymin), yn+(priv->bounds.ymax));
+ else if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_OUT)==0) gtk_plot_linear_update_scale_pretty(widget, (priv->rescale.xmin), (priv->rescale.xmax), (priv->rescale.ymin), (priv->rescale.ymax));
else
{
s=((priv->bounds.xmax)-(priv->bounds.xmin))/xn;
@@ -4134,19 +4136,19 @@ static gboolean gtk_plot_linear_button_release(GtkWidget *widget, GdkEventButton
{
if ((event->x)>=xw-11)
{
- (plot->zmode)^=GTK_PLOT_LINEAR_ZOOM_OUT;
- gtk_plot_linear_redraw(widget);
- }
- else if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_SGL)!=0)
- {
- (plot->zmode)&=GTK_PLOT_LINEAR_ZOOM_OUT;
- gtk_plot_linear_redraw(widget);
+ if (((plot->zmode)&(GTK_PLOT_LINEAR_ZOOM_DRG|GTK_PLOT_LINEAR_ZOOM_OUT))==0) {(plot->zmode)&=!GTK_PLOT_LINEAR_ZOOM_SGL; (plot->zmode)|=GTK_PLOT_LINEAR_ZOOM_DRG;}
+ else (plot->zmode)--;
}
else
{
- {(plot->zmode)++; (plot->zmode)++;}
- gtk_plot_linear_redraw(widget);
+ (plot->zmode)-=GTK_PLOT_LINEAR_ZOOM_HZT;
+ if (((plot->zmode)&(GTK_PLOT_LINEAR_ZOOM_SGL|GTK_PLOT_LINEAR_ZOOM_HZT|GTK_PLOT_LINEAR_ZOOM_VRT))==0)
+ {
+ if (((plot->zmode)&GTK_PLOT_LINEAR_ZOOM_DRG)!=0) (plot->zmode)|=(GTK_PLOT_LINEAR_ZOOM_VRT|GTK_PLOT_LINEAR_ZOOM_HZT);
+ else (plot->zmode)|=GTK_PLOT_LINEAR_ZOOM_SGL;
+ }
}
+ gtk_plot_linear_redraw(widget);
}
}
return FALSE;
View
7 gtk3plot/gtkplotlinear.h
@@ -38,9 +38,10 @@
typedef enum
{
GTK_PLOT_LINEAR_ZOOM_OUT = 1 << 0,
- GTK_PLOT_LINEAR_ZOOM_HZT = 1 << 1,
- GTK_PLOT_LINEAR_ZOOM_VRT = 1 << 2,
- GTK_PLOT_LINEAR_ZOOM_SGL = 1 << 3
+ GTK_PLOT_LINEAR_ZOOM_DRG = 1 << 1,
+ GTK_PLOT_LINEAR_ZOOM_HZT = 1 << 2,
+ GTK_PLOT_LINEAR_ZOOM_VRT = 1 << 3,
+ GTK_PLOT_LINEAR_ZOOM_SGL = 1 << 4
} GtkPlotLinearZoom;
typedef enum
{
View
7 gtk3plot/gtkplotpolar.c
@@ -5516,8 +5516,11 @@ static gboolean gtk_plot_polar_button_release(GtkWidget *widget, GdkEventButton
if ((event->x)>=xw-22)
{
if ((event->x)>=xw-11) (plot->zmode)^=GTK_PLOT_POLAR_ZOOM_OUT;
- else if (((plot->zmode)&GTK_PLOT_POLAR_ZOOM_SGL)!=0) (plot->zmode)&=GTK_PLOT_POLAR_ZOOM_OUT;
- else {(plot->zmode)++; (plot->zmode)++;}
+ else
+ {
+ (plot->zmode)-=GTK_PLOT_POLAR_ZOOM_RDL;
+ if (((plot->zmode)&(GTK_PLOT_POLAR_ZOOM_SGL|GTK_PLOT_POLAR_ZOOM_AZT|GTK_PLOT_POLAR_ZOOM_RDL))==0) (plot->zmode)|=GTK_PLOT_POLAR_ZOOM_SGL;
+ }
gtk_plot_polar_redraw(widget);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.