static void gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool) { GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool); if (gimp_draw_tool_is_active (draw_tool)) { GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_visible = dist < FULL_HANDLE_THRESHOLD_SQ; } gimp_canvas_item_set_visible (blend_tool->start_handle_circle, start_visible); gimp_canvas_item_set_visible (blend_tool->end_handle_circle, end_visible); /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); gimp_canvas_item_set_highlight (blend_tool->start_handle_circle, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->end_handle_circle, hilight_point == POINT_END); gimp_canvas_item_set_highlight (blend_tool->end_handle_cross, hilight_point == POINT_END); } }
/** * gimp_draw_tool_add_corner: * @draw_tool: the #GimpDrawTool * @highlight: * @put_outside: whether to put the handles on the outside of the rectangle * @x1: * @y1: * @x2: * @y2: * @width: corner width * @height: corner height * @anchor: which corner to draw * * This function takes image space coordinates and transforms them to * screen window coordinates. It draws a corner into an already drawn * rectangle outline, taking care of not drawing over an already drawn line. **/ GimpCanvasItem * gimp_draw_tool_add_corner (GimpDrawTool *draw_tool, gboolean highlight, gboolean put_outside, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gint width, gint height, GimpHandleAnchor anchor) { GimpCanvasItem *item; g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL); item = gimp_canvas_corner_new (gimp_display_get_shell (draw_tool->display), x1, y1, x2 - x1, y2 - y1, anchor, width, height, put_outside); gimp_canvas_item_set_highlight (item, highlight); gimp_draw_tool_add_item (draw_tool, item); g_object_unref (item); return item; }
static void gimp_color_tool_draw (GimpDrawTool *draw_tool) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (draw_tool); if (color_tool->enabled) { if (color_tool->sample_point) { GimpImage *image = gimp_display_get_image (draw_tool->display); GimpCanvasItem *item; gint index; gint x; gint y; gimp_sample_point_get_position (color_tool->sample_point, &x, &y); index = g_list_index (gimp_image_get_sample_points (image), color_tool->sample_point) + 1; item = gimp_draw_tool_add_sample_point (draw_tool, x, y, index); gimp_canvas_item_set_highlight (item, TRUE); } if (color_tool->moving_sample_point) { if (color_tool->sample_point_x != SAMPLE_POINT_POSITION_INVALID && color_tool->sample_point_y != SAMPLE_POINT_POSITION_INVALID) { gimp_draw_tool_add_crosshair (draw_tool, color_tool->sample_point_x, color_tool->sample_point_y); } } else if (color_tool->options->sample_average && gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control)) { gdouble radius = color_tool->options->average_radius; gimp_draw_tool_add_rectangle (draw_tool, FALSE, color_tool->center_x - radius, color_tool->center_y - radius, 2 * radius + 1, 2 * radius + 1); } } }
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool) { GimpFlipTool *flip = GIMP_FLIP_TOOL (draw_tool); if (flip->guide) { GimpCanvasItem *item; GimpGuideStyle style; style = gimp_guide_get_style (flip->guide); item = gimp_draw_tool_add_guide (draw_tool, gimp_guide_get_orientation (flip->guide), gimp_guide_get_position (flip->guide), style); gimp_canvas_item_set_highlight (item, TRUE); } }
static void gimp_display_shell_active_vectors_handler (GimpImage *image, GimpDisplayShell *shell) { GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors); GimpVectors *active = gimp_image_get_active_vectors (image); GList *list; for (list = gimp_image_get_vectors_iter (image); list; list = g_list_next (list)) { GimpVectors *vectors = list->data; GimpCanvasItem *item; item = gimp_canvas_proxy_group_get_item (group, vectors); gimp_canvas_item_set_highlight (item, vectors == active); } }
static void gimp_move_tool_draw (GimpDrawTool *draw_tool) { GimpMoveTool *move = GIMP_MOVE_TOOL (draw_tool); if (move->guide) { GimpCanvasItem *item; item = gimp_draw_tool_add_guide (draw_tool, gimp_guide_get_orientation (move->guide), gimp_guide_get_position (move->guide), TRUE); gimp_canvas_item_set_highlight (item, TRUE); } if (move->moving_guide && move->guide_position != GUIDE_POSITION_INVALID) { gimp_draw_tool_add_guide (draw_tool, move->guide_orientation, move->guide_position, FALSE); } }
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool); GimpCanvasItem *start_handle_cross, *end_handle_cross; gimp_draw_tool_add_line (draw_tool, blend_tool->start_x, blend_tool->start_y, blend_tool->end_x, blend_tool->end_y); start_handle_cross = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->start_x, blend_tool->start_y, HANDLE_CROSS_DIAMETER, HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); end_handle_cross = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CROSS, blend_tool->end_x, blend_tool->end_y, HANDLE_CROSS_DIAMETER, HANDLE_CROSS_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_visible = dist < FULL_HANDLE_THRESHOLD_SQ; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_visible = dist < FULL_HANDLE_THRESHOLD_SQ; } /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (start_visible) { GimpCanvasItem *start_handle_circle; start_handle_circle = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, blend_tool->start_x, blend_tool->start_y, HANDLE_DIAMETER, HANDLE_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); gimp_canvas_item_set_highlight (start_handle_circle, hilight_point == POINT_START); } if (end_visible) { GimpCanvasItem *end_handle_circle; end_handle_circle = gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_CIRCLE, blend_tool->end_x, blend_tool->end_y, HANDLE_DIAMETER, HANDLE_DIAMETER, GIMP_HANDLE_ANCHOR_CENTER); gimp_canvas_item_set_highlight (end_handle_circle, hilight_point == POINT_END); } gimp_canvas_item_set_highlight (start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (end_handle_cross, hilight_point == POINT_END); }
static void gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool) { GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool); if (gimp_draw_tool_is_active (draw_tool)) { GimpBlendToolPoint hilight_point; gboolean start_visible, end_visible; gint start_diameter, end_diameter; /* Calculate handle visibility */ if (blend_tool->grabbed_point) { start_visible = FALSE; end_visible = FALSE; } else { gdouble dist; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->start_x, blend_tool->start_y); start_diameter = calc_handle_diameter (dist); start_visible = start_diameter > 2; dist = gimp_draw_tool_calc_distance_square (draw_tool, draw_tool->display, blend_tool->mouse_x, blend_tool->mouse_y, blend_tool->end_x, blend_tool->end_y); end_diameter = calc_handle_diameter (dist); end_visible = end_diameter > 2; } gimp_canvas_item_set_visible (blend_tool->start_handle_circle, start_visible); gimp_canvas_item_set_visible (blend_tool->end_handle_circle, end_visible); /* Update hilights */ if (blend_tool->grabbed_point) hilight_point = blend_tool->grabbed_point; else hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool); if (start_visible) { gimp_canvas_item_begin_change (blend_tool->start_handle_circle); g_object_set (blend_tool->start_handle_circle, "width", start_diameter, "height", start_diameter, NULL); gimp_canvas_item_end_change (blend_tool->start_handle_circle); } if (end_visible) { gimp_canvas_item_begin_change (blend_tool->end_handle_circle); g_object_set (blend_tool->end_handle_circle, "width", end_diameter, "height", end_diameter, NULL); gimp_canvas_item_end_change (blend_tool->end_handle_circle); } gimp_canvas_item_set_highlight (blend_tool->start_handle_circle, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->start_handle_cross, hilight_point == POINT_START); gimp_canvas_item_set_highlight (blend_tool->end_handle_circle, hilight_point == POINT_END); gimp_canvas_item_set_highlight (blend_tool->end_handle_cross, hilight_point == POINT_END); } }