Exemplo n.º 1
1
gboolean
rcm_gray_motion_notify_event (GtkWidget      *widget,
			      GdkEventMotion *event,
			      RcmGray        *circle)
{
  gint        x, y;
  GdkGCValues values;

  values.function = GDK_INVERT;
  xor_gc = gdk_gc_new_with_values (Current.From->preview->window,
				   &values,
                                   GDK_GC_FUNCTION);

  if (circle->action_flag == DRAG_START)
    {
      GtkStyle *style = gtk_widget_get_style (circle->preview);

      gtk_widget_queue_draw (circle->preview);
      color_rotate_draw_large_circle (circle->preview->window,
                                      style->black_gc,
                                      circle->gray_sat);

      circle->action_flag = DRAGING;
    }
  else
    {
      color_rotate_draw_little_circle (widget->window, xor_gc,
                                       circle->hue, circle->satur); /* erase */
    }

  x = event->x - GRAY_CENTER - LITTLE_RADIUS;
  y = GRAY_CENTER - event->y + LITTLE_RADIUS;

  circle->hue   = angle_mod_2PI (arctg (y, x));
  circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;

  if (circle->satur > 1.0)
    circle->satur = 1;

  color_rotate_draw_little_circle (widget->window, xor_gc,
                                   circle->hue, circle->satur);

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
                             circle->hue * rcm_units_factor(Current.Units));

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->satur_entry),
                             circle->satur);

  if (Current.RealTime)
    rcm_render_preview (Current.Bna->after);

  gdk_event_request_motions (event);

  return TRUE;
}
Exemplo n.º 2
0
gboolean
rcm_gray_motion_notify_event (GtkWidget      *widget,
			      GdkEventMotion *event,
			      RcmGray        *circle)
{
  gint x, y;

  gtk_widget_queue_draw (circle->preview);

  x = event->x - GRAY_CENTER - LITTLE_RADIUS;
  y = GRAY_CENTER - event->y + LITTLE_RADIUS;

  circle->hue   = angle_mod_2PI (arctg (y, x));
  circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;

  if (circle->satur > 1.0)
    circle->satur = 1;

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
                             circle->hue * rcm_units_factor(Current.Units));

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->satur_entry),
                             circle->satur);

  if (Current.RealTime)
    rcm_render_preview (Current.Bna->after);

  gdk_event_request_motions (event);

  return TRUE;
}
Exemplo n.º 3
0
gboolean
rcm_gray_release_event (GtkWidget      *widget,
			GdkEventButton *event,
			RcmGray        *circle)
{
  rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 4
0
void
rcm_switch_to_gray_from (GtkWidget *button,
			 gpointer  *value)
{
  if (! GTK_TOGGLE_BUTTON (button)->active)
    return;

  Current.Gray_to_from = GRAY_FROM;
  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 5
0
void
rcm_360_degrees (GtkWidget *button,
		 RcmCircle *circle)
{
  gtk_widget_queue_draw (circle->preview);

  circle->angle->beta = circle->angle->alpha-circle->angle->cw_ccw * 0.001;

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 6
0
void
rcm_set_gray_sat (GtkWidget *entry,
                  RcmGray   *circle)
{
  circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));

  gtk_widget_queue_draw (circle->preview);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 7
0
void
rcm_a_to_b (GtkWidget *button,
	    RcmCircle *circle)
{
  gtk_widget_queue_draw (circle->preview);

  SWAP (circle->angle->alpha, circle->angle->beta);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 8
0
void
rcm_switch_to_gray_from (GtkWidget *button,
			 gpointer  *value)
{
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
    {
      Current.Gray_to_from = GRAY_FROM;

      rcm_render_preview (Current.Bna->after);
    }
}
Exemplo n.º 9
0
void
rcm_set_hue (GtkWidget *entry,
             RcmGray   *circle)
{
  circle->hue = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                 rcm_units_factor(Current.Units));

  gtk_widget_queue_draw (circle->preview);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 10
0
void
rcm_360_degrees (GtkWidget *button,
		 RcmCircle *circle)
{
  circle->action_flag = DO_NOTHING;
  gtk_widget_queue_draw (circle->preview);
  circle->angle->beta = circle->angle->alpha-circle->angle->cw_ccw * 0.001;
  rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
                   circle->angle);
  circle->action_flag = VIRGIN;
  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 11
0
gboolean
rcm_button_press_event (GtkWidget      *widget,
			GdkEventButton *event,
			RcmCircle      *circle)
{
  float  clicked_angle;
  float *alpha;
  float *beta;

  alpha  = &circle->angle->alpha;
  beta   = &circle->angle->beta;

  circle->action_flag = DRAG_START;
  clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
  circle->prev_clicked = clicked_angle;

  if ((sqrt (SQR (event->y - CENTER) +
             SQR (event->x - CENTER)) > RADIUS * EACH_OR_BOTH) &&
      (min_prox (*alpha, *beta, clicked_angle) < G_PI / 12))
    {
      circle->mode = EACH;
      circle->target = closest (alpha, beta, clicked_angle);

      if (*(circle->target) != clicked_angle)
        {
          GtkStyle *style = gtk_widget_get_style (widget);

          *(circle->target) = clicked_angle;
          gtk_widget_queue_draw (circle->preview);
          color_rotate_draw_arrows (widget->window,
                                    style->black_gc,
                                    circle->angle);

          gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
                                     circle->angle->alpha *
                                     rcm_units_factor(Current.Units));

          gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->beta_entry),
                                     circle->angle->beta *
                                     rcm_units_factor(Current.Units));

          if (Current.RealTime)
            rcm_render_preview (Current.Bna->after);
        }
    }
  else
    circle->mode = BOTH;

  return TRUE;
}
Exemplo n.º 12
0
void
rcm_a_to_b (GtkWidget *button,
	    RcmCircle *circle)
{
  circle->action_flag = DO_NOTHING;
  gtk_widget_queue_draw (circle->preview);

  SWAP (circle->angle->alpha, circle->angle->beta);

  rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
                   circle->angle);

  circle->action_flag = VIRGIN;
  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 13
0
void
rcm_set_gray_sat (GtkWidget *entry,
		  gpointer   data)
{
  RcmGray *circle = data;

  circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));

  gtk_widget_queue_draw (circle->preview);

  rcm_draw_large_circle (circle->preview->window,
                         circle->preview->style->black_gc,
                         circle->gray_sat);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 14
0
void
rcm_set_gray_sat (GtkWidget *entry,
                  RcmGray   *circle)
{
  GtkStyle *style = gtk_widget_get_style (circle->preview);

  circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));

  gtk_widget_queue_draw (circle->preview);

  color_rotate_draw_large_circle (circle->preview->window,
                                  style->black_gc,
                                  circle->gray_sat);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 15
0
gboolean
rcm_release_event (GtkWidget *widget,
		   GdkEvent  *event,
		   RcmCircle *circle)
{
  if (circle->action_flag == DRAGING)
    {
      gtk_widget_queue_draw (circle->preview);
      rcm_draw_arrows (widget->window, widget->style->black_gc, circle->angle);
    }

  circle->action_flag = VIRGIN;

  rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 16
0
gboolean
rcm_gray_release_event (GtkWidget *widget,
			GdkEvent  *event,
			RcmGray   *circle)
{
  if (circle->action_flag == DRAGING)
    rcm_draw_little_circle (widget->window,
                            widget->style->black_gc,
                            circle->hue,
                            circle->satur);

  circle->action_flag = VIRGIN;

  rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 17
0
void
rcm_set_beta (GtkWidget *entry,
	      gpointer   data)
{
  RcmCircle *circle = data;

  if (circle->action_flag != VIRGIN)
    return;

  circle->angle->beta = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                         rcm_units_factor(Current.Units));

  gtk_widget_queue_draw (circle->preview);

  rcm_draw_arrows (circle->preview->window, circle->preview->style->black_gc,
                   circle->angle);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 18
0
gboolean
rcm_motion_notify_event (GtkWidget      *widget,
			 GdkEventMotion *event,
			 RcmCircle      *circle)
{
  gfloat  clicked_angle, delta;

  clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));

  delta = clicked_angle - circle->prev_clicked;
  circle->prev_clicked = clicked_angle;

  if (delta)
    {
      if (circle->mode == EACH)
        {
          *(circle->target) = clicked_angle;
        }
      else
        {
          circle->angle->alpha = angle_mod_2PI (circle->angle->alpha + delta);
          circle->angle->beta  = angle_mod_2PI (circle->angle->beta  + delta);
        }

      gtk_widget_queue_draw (widget);
      gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);

      gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
                                 circle->angle->alpha *
                                 rcm_units_factor(Current.Units));

      gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->beta_entry),
                                 circle->angle->beta *
                                 rcm_units_factor(Current.Units));

      if (Current.RealTime)
        rcm_render_preview (Current.Bna->after);
    }

  gdk_event_request_motions (event);

  return TRUE;
}
Exemplo n.º 19
0
void
rcm_set_alpha (GtkWidget *entry,
               RcmCircle *circle)
{
  GtkStyle *style = gtk_widget_get_style (circle->preview);

  if (circle->action_flag != VIRGIN)
    return;

  circle->angle->alpha = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                          rcm_units_factor (Current.Units));

  gtk_widget_queue_draw (circle->preview);

  color_rotate_draw_arrows (circle->preview->window,
                            style->black_gc,
                            circle->angle);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 20
0
gboolean
rcm_gray_release_event (GtkWidget      *widget,
			GdkEventButton *event,
			RcmGray        *circle)
{
  if (circle->action_flag == DRAGING)
    {
      GtkStyle *style = gtk_widget_get_style (widget);

      color_rotate_draw_little_circle (widget->window,
                                       style->black_gc,
                                       circle->hue,
                                       circle->satur);
    }

  circle->action_flag = VIRGIN;

  rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 21
0
gboolean
rcm_release_event (GtkWidget      *widget,
		   GdkEventButton *event,
		   RcmCircle      *circle)
{
  if (circle->action_flag == DRAGING)
    {
      GtkStyle *style = gtk_widget_get_style (widget);

      gtk_widget_queue_draw (circle->preview);
      color_rotate_draw_arrows (widget->window,
                                style->black_gc,
                                circle->angle);
    }

  circle->action_flag = VIRGIN;

  rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 22
0
gboolean
rcm_gray_button_press_event (GtkWidget      *widget,
			     GdkEventButton *event,
			     RcmGray        *circle)
{
  GtkStyle *style = gtk_widget_get_style (widget);
  int       x, y;

  x = event->x - GRAY_CENTER - LITTLE_RADIUS;
  y = GRAY_CENTER - event->y + LITTLE_RADIUS;

  circle->action_flag = DRAG_START;
  circle->hue         = angle_mod_2PI(arctg(y, x));
  circle->satur       = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;

  if (circle->satur > 1.0)
    circle->satur = 1;

  gtk_widget_queue_draw (circle->preview);
  color_rotate_draw_little_circle (widget->window,
                                   style->black_gc,
                                   circle->hue, circle->satur);

  color_rotate_draw_large_circle (circle->preview->window,
                                  gtk_widget_get_style (circle->preview)->black_gc,
                                  circle->gray_sat);

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
                             circle->hue * rcm_units_factor (Current.Units));

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->satur_entry),
                             circle->satur);

  if (Current.RealTime)
    rcm_render_preview (Current.Bna->after);

  return TRUE;
}
Exemplo n.º 23
0
void
rcm_set_satur (GtkWidget *entry,
	       gpointer   data)
{
  RcmGray *circle = data;

  if (circle->action_flag != VIRGIN)
    return;

  circle->satur = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));

  gtk_widget_queue_draw (circle->preview);

  rcm_draw_little_circle (circle->preview->window,
                          circle->preview->style->black_gc,
                          circle->hue, circle->satur);

  rcm_draw_large_circle (circle->preview->window,
                         circle->preview->style->black_gc,
                         circle->gray_sat);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 24
0
void
rcm_set_hue (GtkWidget *entry,
             RcmGray   *circle)
{
  GtkStyle *style = gtk_widget_get_style (circle->preview);

  if (circle->action_flag != VIRGIN)
    return;

  circle->hue = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
                 rcm_units_factor(Current.Units));

  gtk_widget_queue_draw (circle->preview);

  color_rotate_draw_little_circle (circle->preview->window,
                                   style->black_gc,
                                   circle->hue, circle->satur);

  color_rotate_draw_large_circle (circle->preview->window,
                                  style->black_gc,
                                  circle->gray_sat);

  rcm_render_preview (Current.Bna->after);
}
Exemplo n.º 25
0
gboolean
rcm_motion_notify_event (GtkWidget      *widget,
			 GdkEventMotion *event,
			 RcmCircle      *circle)
{
  gfloat       clicked_angle, delta;
  gfloat      *alpha, *beta;
  gint         cw_ccw;
  GdkGCValues  values;

  alpha  = &(circle->angle->alpha);
  beta   = &(circle->angle->beta);
  cw_ccw = circle->angle->cw_ccw;
  delta  = angle_mod_2PI (cw_ccw * (*beta - *alpha));

  values.function = GDK_INVERT;
  xor_gc = gdk_gc_new_with_values (Current.From->preview->window,
                                   &values,
                                   GDK_GC_FUNCTION);

  clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));

  delta = clicked_angle - circle->prev_clicked;
  circle->prev_clicked = clicked_angle;

  if (delta)
    {
      if (circle->action_flag == DRAG_START)
        {
          gtk_widget_queue_draw (circle->preview);
          circle->action_flag = DRAGING;
        }
      else
        {
          /* this should be erasing entire angle */
          color_rotate_draw_arrows (widget->window, xor_gc, circle->angle);
        }

      if (circle->mode == EACH)
        {
          *(circle->target)=clicked_angle;
        }
      else
        {
          circle->angle->alpha=angle_mod_2PI(circle->angle->alpha + delta);
          circle->angle->beta =angle_mod_2PI(circle->angle->beta  + delta);
        }

      gdk_window_process_updates (widget->window, FALSE);
      color_rotate_draw_arrows (widget->window, xor_gc, circle->angle);

      gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
                                 circle->angle->alpha *
                                 rcm_units_factor(Current.Units));

      gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->beta_entry),
                                 circle->angle->beta *
                                 rcm_units_factor(Current.Units));

      if (Current.RealTime)
        rcm_render_preview (Current.Bna->after);
    }

  gdk_event_request_motions (event);

  return TRUE;
}