Commit 1899c612 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer
Browse files

app/brush_select.c app/pattern_select.c wheelmouse support for the

1999-07-24  Michael Natterer  <mitschel@cs.tu-berlin.de>

	* app/brush_select.c
	* app/pattern_select.c
	* app/gradient.c: wheelmouse support for the brush/pattern lists
	and for the gradient preview.
parent 9b9f3d10
1999-07-24 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/brush_select.c
* app/pattern_select.c
* app/gradient.c: wheelmouse support for the brush/pattern lists
and for the gradient preview.
1999-07-24 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/color_picker.[ch]: set the "preserve" flag to FALSE. This
......
......@@ -1139,6 +1139,25 @@ brush_select_events (GtkWidget *widget,
brush_popup_open (bsp, bevent->x, bevent->y, brush);
}
}
/* wheelmouse support */
else if (bevent->button == 4)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
else if (bevent->button == 5)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
case GDK_BUTTON_RELEASE:
......
......@@ -2012,6 +2012,27 @@ prev_events (GtkWidget *widget,
cpopup_do_popup ();
break;
/* wheelmouse support */
case 4:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
case 5:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value + adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
default:
break;
}
......@@ -2427,116 +2448,151 @@ control_do_hint(gint x, gint y)
/*****/
static void
control_button_press(gint x, gint y, guint button, guint state)
control_button_press (gint x,
gint y,
guint button,
guint state)
{
grad_segment_t *seg;
control_drag_mode_t handle;
double xpos;
int in_handle;
/* See which button was pressed */
switch (button) {
case 1:
break;
case 3:
cpopup_do_popup();
return;
grad_segment_t *seg;
control_drag_mode_t handle;
double xpos;
gint in_handle;
default:
return;
} /* switch */
/* See which button was pressed */
/* Find the closest handle */
xpos = control_calc_g_pos(x);
seg_get_closest_handle(curr_gradient, xpos, &seg, &handle);
in_handle = control_point_in_handle(x, y, seg, handle);
/* Now see what we have */
switch (button)
{
case 1:
break;
if (in_handle)
switch (handle) {
case GRAD_DRAG_LEFT:
if (seg != NULL) {
/* Left handle of some segment */
case 3:
cpopup_do_popup();
return;
if (state & GDK_SHIFT_MASK) {
if (seg->prev != NULL) {
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
g_editor->control_compress = 1;
} else {
control_extend_selection(seg, xpos);
/* wheelmouse support */
case 4:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value - adj->page_increment / 2;
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return;
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
} else
if (seg->prev != NULL) {
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
} else {
control_select_single_segment(seg);
case 5:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return;
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
default:
return;
}
return;
} else {
/* Right handle of last segment */
/* Find the closest handle */
seg = seg_get_last_segment(curr_gradient->segments);
xpos = control_calc_g_pos (x);
if (state & GDK_SHIFT_MASK) {
control_extend_selection(seg, xpos);
seg_get_closest_handle (curr_gradient, xpos, &seg, &handle);
ed_update_editor(GRAD_UPDATE_CONTROL);
} else {
control_select_single_segment(seg);
in_handle = control_point_in_handle (x, y, seg, handle);
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
/* Now see what we have */
return;
} /* else */
if (in_handle)
{
switch (handle)
{
case GRAD_DRAG_LEFT:
if (seg != NULL)
{
/* Left handle of some segment */
if (state & GDK_SHIFT_MASK)
{
if (seg->prev != NULL)
{
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
g_editor->control_compress = 1;
}
else
{
control_extend_selection (seg, xpos);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
}
else if (seg->prev != NULL)
{
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
}
else
{
control_select_single_segment (seg);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
break;
return;
}
else /* seg == NULL */
{
/* Right handle of last segment */
seg = seg_get_last_segment (curr_gradient->segments);
if (state & GDK_SHIFT_MASK)
{
control_extend_selection (seg, xpos);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
else
{
control_select_single_segment (seg);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
case GRAD_DRAG_MIDDLE:
if (state & GDK_SHIFT_MASK) {
control_extend_selection(seg, xpos);
return;
}
ed_update_editor(GRAD_UPDATE_CONTROL);
} else {
g_editor->control_drag_mode = GRAD_DRAG_MIDDLE;
g_editor->control_drag_segment = seg;
} /* else */
break;
return;
case GRAD_DRAG_MIDDLE:
if (state & GDK_SHIFT_MASK)
{
control_extend_selection(seg, xpos);
ed_update_editor(GRAD_UPDATE_CONTROL);
}
else
{
g_editor->control_drag_mode = GRAD_DRAG_MIDDLE;
g_editor->control_drag_segment = seg;
}
default:
g_message ("control_button_press(): oops, in_handle is true "
"yet we got handle type %d", (int) handle);
return;
} /* switch */
else {
seg = seg_get_segment_at(curr_gradient, xpos);
return;
g_editor->control_drag_mode = GRAD_DRAG_ALL;
g_editor->control_drag_segment = seg;
g_editor->control_last_gx = xpos;
g_editor->control_orig_pos = xpos;
default:
g_message ("control_button_press(): oops, in_handle is true "
"yet we got handle type %d", (int) handle);
return;
}
}
else /* !in_handle */
{
seg = seg_get_segment_at (curr_gradient, xpos);
if (state & GDK_SHIFT_MASK)
g_editor->control_compress = 1;
g_editor->control_drag_mode = GRAD_DRAG_ALL;
g_editor->control_drag_segment = seg;
g_editor->control_last_gx = xpos;
g_editor->control_orig_pos = xpos;
return;
} /* else */
} /* control_button_press */
if (state & GDK_SHIFT_MASK)
g_editor->control_compress = 1;
return;
}
}
/*****/
......
......@@ -2012,6 +2012,27 @@ prev_events (GtkWidget *widget,
cpopup_do_popup ();
break;
/* wheelmouse support */
case 4:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
case 5:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value + adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
default:
break;
}
......@@ -2427,116 +2448,151 @@ control_do_hint(gint x, gint y)
/*****/
static void
control_button_press(gint x, gint y, guint button, guint state)
control_button_press (gint x,
gint y,
guint button,
guint state)
{
grad_segment_t *seg;
control_drag_mode_t handle;
double xpos;
int in_handle;
/* See which button was pressed */
switch (button) {
case 1:
break;
case 3:
cpopup_do_popup();
return;
grad_segment_t *seg;
control_drag_mode_t handle;
double xpos;
gint in_handle;
default:
return;
} /* switch */
/* See which button was pressed */
/* Find the closest handle */
xpos = control_calc_g_pos(x);
seg_get_closest_handle(curr_gradient, xpos, &seg, &handle);
in_handle = control_point_in_handle(x, y, seg, handle);
/* Now see what we have */
switch (button)
{
case 1:
break;
if (in_handle)
switch (handle) {
case GRAD_DRAG_LEFT:
if (seg != NULL) {
/* Left handle of some segment */
case 3:
cpopup_do_popup();
return;
if (state & GDK_SHIFT_MASK) {
if (seg->prev != NULL) {
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
g_editor->control_compress = 1;
} else {
control_extend_selection(seg, xpos);
/* wheelmouse support */
case 4:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value - adj->page_increment / 2;
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return;
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
} else
if (seg->prev != NULL) {
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
} else {
control_select_single_segment(seg);
case 5:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value + adj->page_increment / 2;
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
return;
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
default:
return;
}
return;
} else {
/* Right handle of last segment */
/* Find the closest handle */
seg = seg_get_last_segment(curr_gradient->segments);
xpos = control_calc_g_pos (x);
if (state & GDK_SHIFT_MASK) {
control_extend_selection(seg, xpos);
seg_get_closest_handle (curr_gradient, xpos, &seg, &handle);
ed_update_editor(GRAD_UPDATE_CONTROL);
} else {
control_select_single_segment(seg);
in_handle = control_point_in_handle (x, y, seg, handle);
ed_update_editor(GRAD_UPDATE_CONTROL);
} /* else */
/* Now see what we have */
return;
} /* else */
if (in_handle)
{
switch (handle)
{
case GRAD_DRAG_LEFT:
if (seg != NULL)
{
/* Left handle of some segment */
if (state & GDK_SHIFT_MASK)
{
if (seg->prev != NULL)
{
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
g_editor->control_compress = 1;
}
else
{
control_extend_selection (seg, xpos);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
}
else if (seg->prev != NULL)
{
g_editor->control_drag_mode = GRAD_DRAG_LEFT;
g_editor->control_drag_segment = seg;
}
else
{
control_select_single_segment (seg);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
break;
return;
}
else /* seg == NULL */
{
/* Right handle of last segment */
seg = seg_get_last_segment (curr_gradient->segments);
if (state & GDK_SHIFT_MASK)
{
control_extend_selection (seg, xpos);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
else
{
control_select_single_segment (seg);
ed_update_editor (GRAD_UPDATE_CONTROL);
}
case GRAD_DRAG_MIDDLE:
if (state & GDK_SHIFT_MASK) {
control_extend_selection(seg, xpos);
return;
}
ed_update_editor(GRAD_UPDATE_CONTROL);
} else {
g_editor->control_drag_mode = GRAD_DRAG_MIDDLE;
g_editor->control_drag_segment = seg;
} /* else */
break;
return;
case GRAD_DRAG_MIDDLE:
if (state & GDK_SHIFT_MASK)
{
control_extend_selection(seg, xpos);
ed_update_editor(GRAD_UPDATE_CONTROL);
}
else
{
g_editor->control_drag_mode = GRAD_DRAG_MIDDLE;
g_editor->control_drag_segment = seg;
}
default:
g_message ("control_button_press(): oops, in_handle is true "
"yet we got handle type %d", (int) handle);
return;
} /* switch */
else {
seg = seg_get_segment_at(curr_gradient, xpos);
return;
g_editor->control_drag_mode = GRAD_DRAG_ALL;
g_editor->control_drag_segment = seg;
g_editor->control_last_gx = xpos;
g_editor->control_orig_pos = xpos;
default:
g_message ("control_button_press(): oops, in_handle is true "
"yet we got handle type %d", (int) handle);
return;
}
}
else /* !in_handle */
{
seg = seg_get_segment_at (curr_gradient, xpos);
if (state & GDK_SHIFT_MASK)
g_editor->control_compress = 1;
g_editor->control_drag_mode = GRAD_DRAG_ALL;
g_editor->control_drag_segment = seg;
g_editor->control_last_gx = xpos;
g_editor->control_orig_pos = xpos;
return;
} /* else */
} /* control_button_press */
if (state & GDK_SHIFT_MASK)
g_editor->control_compress = 1;
return;
}
}
/*****/
......
......@@ -1139,6 +1139,25 @@ brush_select_events (GtkWidget *widget,
brush_popup_open (bsp, bevent->x, bevent->y, brush);
}
}
/* wheelmouse support */
else if (bevent->button == 4)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
else if (bevent->button == 5)
{
GtkAdjustment *adj = bsp->sbar_data;
gfloat new_value = adj->value + adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
case GDK_BUTTON_RELEASE:
......
......@@ -2012,6 +2012,27 @@ prev_events (GtkWidget *widget,
cpopup_do_popup ();
break;
/* wheelmouse support */
case 4:
{
GtkAdjustment *adj = GTK_ADJUSTMENT (g_editor->scroll_data);
gfloat new_value = adj->value - adj->page_increment / 2;
new_value =
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
gtk_adjustment_set_value (adj, new_value);
}
break;
case 5:
{