Esempio n. 1
0
static void
rectangle_assign(Object_t *obj, Object_t *des)
{
   Rectangle_t *src_rectangle = ObjectToRectangle(obj);
   Rectangle_t *des_rectangle = ObjectToRectangle(des);
   des_rectangle->x = src_rectangle->x;
   des_rectangle->y = src_rectangle->y;
   des_rectangle->width = src_rectangle->width;
   des_rectangle->height = src_rectangle->height;
}
Esempio n. 2
0
static void
rectangle_write_csim(Object_t *obj, gpointer param, OutputFunc_t output)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   output(param, "\"rect\" coords=\"%d,%d,%d,%d\"", rectangle->x, rectangle->y,
          rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
Esempio n. 3
0
static gboolean
rectangle_point_is_on(Object_t *obj, gint x, gint y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   return x >= rectangle->x && x <= rectangle->x + rectangle->width &&
      y >= rectangle->y && y <= rectangle->y + rectangle->height;
}
Esempio n. 4
0
static MoveSashFunc_t
rectangle_near_sash(Object_t *obj, gint x, gint y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   if (near_sash(rectangle->x, rectangle->y, x, y))
      return MoveUpperLeftSash;
   else if (near_sash(rectangle->x + rectangle->width / 2, rectangle->y, x, y))
      return MoveUpperSash;
   else if (near_sash(rectangle->x + rectangle->width, rectangle->y, x, y))
      return MoveUpperRightSash;
   else if (near_sash(rectangle->x, rectangle->y + rectangle->height / 2,
                      x, y))
      return MoveLeftSash;
   else if (near_sash(rectangle->x + rectangle->width,
                      rectangle->y + rectangle->height / 2, x, y))
      return MoveRightSash;
   else if (near_sash(rectangle->x, rectangle->y + rectangle->height, x, y))
      return MoveLowerLeftSash;
   else if (near_sash(rectangle->x + rectangle->width / 2,
                      rectangle->y + rectangle->height, x, y))
      return MoveLowerSash;
   else if (near_sash(rectangle->x + rectangle->width,
                      rectangle->y + rectangle->height, x, y))
      return MoveLowerRightSash;
   return NULL;
}
Esempio n. 5
0
static void
MoveLowerRightSash(Object_t *obj, gint dx, gint dy)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   rectangle->width += dx;
   rectangle->height += dy;
}
Esempio n. 6
0
static void
MoveLeftSash(Object_t *obj, gint dx, gint dy)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   rectangle->x += dx;
   rectangle->width -= dx;
}
Esempio n. 7
0
static void
MoveUpperSash(Object_t *obj, gint dx, gint dy)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   rectangle->y += dy;
   rectangle->height -= dy;
}
Esempio n. 8
0
static void
rectangle_write_cern(Object_t *obj, gpointer param, OutputFunc_t output)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   output(param, "rect (%d,%d) (%d,%d)", rectangle->x, rectangle->y,
          rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
Esempio n. 9
0
static void
rectangle_draw(Object_t *obj, cairo_t *cr)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   draw_any_rectangle(cr, rectangle->x, rectangle->y,
                      rectangle->width, rectangle->height);
}
Esempio n. 10
0
static void
rectangle_move(Object_t *obj, gint dx, gint dy)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   rectangle->x += dx;
   rectangle->y += dy;
}
Esempio n. 11
0
static void
select_release(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
   SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
   Object_t *obj = command->obj;
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   gpointer id;
   gint count;

   g_signal_handlers_disconnect_by_func(widget,
                                        select_motion, data);
   g_signal_handlers_disconnect_by_func(widget,
                                        select_release, data);

   object_normalize(obj);

   id = object_list_add_select_cb(command->list, select_one_object, command);
   count = object_list_select_region(command->list, rectangle->x, rectangle->y,
                                     rectangle->width, rectangle->height);
   object_list_remove_select_cb(command->list, id);

   if (count) {
      command_list_add(&command->parent);
   } else {                     /* Nothing selected */
      if (command->unselect_command->sub_commands)
         command_list_add(&command->parent);
   }
   preview_unset_tmp_obj (command->obj);

   preview_redraw ();
}
Esempio n. 12
0
static void
height_changed_cb(GtkWidget *widget, gpointer data)
{
   Object_t *obj = ((RectangleProperties_t*) data)->obj;
   gint height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
   ObjectToRectangle(obj)->height = height;
   edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
Esempio n. 13
0
static void
rectangle_write_ncsa(Object_t *obj, gpointer param, OutputFunc_t output)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   output(param, "rect %s %d,%d %d,%d", obj->url,
          rectangle->x, rectangle->y,
          rectangle->x + rectangle->width, rectangle->y + rectangle->height);
}
Esempio n. 14
0
static void
rectangle_resize(Object_t *obj, gint percentage_x, gint percentage_y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   rectangle->x = rectangle->x * percentage_x / 100;
   rectangle->y = rectangle->y * percentage_y / 100;
   rectangle->width = rectangle->width * percentage_x / 100;
   rectangle->height = rectangle->height * percentage_y / 100;
}
Esempio n. 15
0
static void
rectangle_get_dimensions(Object_t *obj, gint *x, gint *y,
                         gint *width, gint *height)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   *x = rectangle->x;
   *y = rectangle->y;
   *width = rectangle->width;
   *height = rectangle->height;
}
Esempio n. 16
0
static gboolean
rectangle_factory_finish(Object_t *obj, gint x, gint y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);

   rectangle->width = x - rectangle->x;
   rectangle->height = y - rectangle->y;

   rectangle_normalize(obj);

   return TRUE;
}
Esempio n. 17
0
static Object_t*
rectangle_clone(Object_t *obj)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   Rectangle_t *clone = g_new(Rectangle_t, 1);

   clone->x = rectangle->x;
   clone->y = rectangle->y;
   clone->width = rectangle->width;
   clone->height = rectangle->height;
   return &clone->obj;
}
Esempio n. 18
0
static void
rectangle_normalize(Object_t *obj)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   if (rectangle->width < 0) {
      rectangle->x += rectangle->width;
      rectangle->width = -rectangle->width;
   }
   if (rectangle->height < 0) {
      rectangle->y += rectangle->height;
      rectangle->height = -rectangle->height;
   }
}
Esempio n. 19
0
static void
rectangle_update(Object_t* obj, gpointer data)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   RectangleProperties_t *props = (RectangleProperties_t*) data;

   rectangle->x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->x));
   rectangle->y = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(props->y));
   rectangle->width = gtk_spin_button_get_value_as_int(
      GTK_SPIN_BUTTON(props->width));
   rectangle->height = gtk_spin_button_get_value_as_int(
      GTK_SPIN_BUTTON(props->height));
}
Esempio n. 20
0
static void
rectangle_fill_info_tab(Object_t *obj, gpointer data)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   RectangleProperties_t *props = (RectangleProperties_t*) data;

   props->obj = obj;
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->x), rectangle->x);
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), rectangle->y);
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->width), rectangle->width);
   gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->height),
                             rectangle->height);
}
Esempio n. 21
0
static void
x_changed_cb(GtkWidget *widget, gpointer data)
{
   RectangleProperties_t *props = (RectangleProperties_t*) data;
   Object_t *obj = props->obj;
   gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));

   if (gimp_chain_button_get_active(GIMP_CHAIN_BUTTON(props->chain_button)))
      gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), x);

   ObjectToRectangle(obj)->x = x;
   edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
Esempio n. 22
0
static void
select_motion(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
   SelectRegionCommand_t *command = (SelectRegionCommand_t*) data;
   Object_t *obj = command->obj;
   Rectangle_t *rectangle = ObjectToRectangle(obj);

   gint x = get_real_coord((gint) event->x);
   gint y = get_real_coord((gint) event->y);

   rectangle->width = x - rectangle->x;
   rectangle->height = y - rectangle->y;

   preview_redraw ();
}
Esempio n. 23
0
static void
rectangle_draw_sashes(Object_t *obj, cairo_t *cr)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   draw_sash(cr, rectangle->x, rectangle->y);
   draw_sash(cr, rectangle->x + rectangle->width / 2, rectangle->y);
   draw_sash(cr, rectangle->x + rectangle->width, rectangle->y);
   draw_sash(cr, rectangle->x, rectangle->y + rectangle->height / 2);
   draw_sash(cr, rectangle->x + rectangle->width,
             rectangle->y + rectangle->height / 2);
   draw_sash(cr, rectangle->x, rectangle->y + rectangle->height);
   draw_sash(cr, rectangle->x + rectangle->width / 2,
             rectangle->y + rectangle->height);
   draw_sash(cr, rectangle->x + rectangle->width,
             rectangle->y + rectangle->height);
}
Esempio n. 24
0
static void
rectangle_factory_set_xy(Object_t *obj, guint state, gint x, gint y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);

   rectangle->width = x - rectangle->x;
   rectangle->height = y - rectangle->y;

   if (state & GDK_SHIFT_MASK){
      gint width = abs(rectangle->width);
      gint height = abs(rectangle->height);
      if (width < height)
         rectangle->height = (rectangle->height < 0) ? -width : width;
      else
         rectangle->width = (rectangle->width < 0) ? -height : height;
   }

   main_set_dimension(rectangle->width, rectangle->height);
}
Esempio n. 25
0
static gboolean
rectangle_is_valid(Object_t *obj)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);
   return rectangle->width && rectangle->height;
}