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); } }
void gimp_display_shell_items_init (GimpDisplayShell *shell) { g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); shell->canvas_item = gimp_canvas_group_new (shell); shell->passe_partout = gimp_canvas_passe_partout_new (shell, 0, 0, 0, 0); gimp_canvas_item_set_visible (shell->passe_partout, FALSE); gimp_display_shell_add_item (shell, shell->passe_partout); g_object_unref (shell->passe_partout); shell->preview_items = gimp_canvas_group_new (shell); gimp_display_shell_add_item (shell, shell->preview_items); g_object_unref (shell->preview_items); shell->vectors = gimp_canvas_proxy_group_new (shell); gimp_display_shell_add_item (shell, shell->vectors); g_object_unref (shell->vectors); shell->grid = gimp_canvas_grid_new (shell, NULL); gimp_canvas_item_set_visible (shell->grid, FALSE); g_object_set (shell->grid, "grid-style", TRUE, NULL); gimp_display_shell_add_item (shell, shell->grid); g_object_unref (shell->grid); shell->guides = gimp_canvas_proxy_group_new (shell); gimp_display_shell_add_item (shell, shell->guides); g_object_unref (shell->guides); shell->sample_points = gimp_canvas_proxy_group_new (shell); gimp_display_shell_add_item (shell, shell->sample_points); g_object_unref (shell->sample_points); shell->layer_boundary = gimp_canvas_layer_boundary_new (shell); gimp_canvas_item_set_visible (shell->layer_boundary, FALSE); gimp_display_shell_add_item (shell, shell->layer_boundary); g_object_unref (shell->layer_boundary); shell->tool_items = gimp_canvas_group_new (shell); gimp_display_shell_add_item (shell, shell->tool_items); g_object_unref (shell->tool_items); g_signal_connect (shell->canvas_item, "update", G_CALLBACK (gimp_display_shell_item_update), shell); shell->unrotated_item = gimp_canvas_group_new (shell); shell->cursor = gimp_canvas_cursor_new (shell); gimp_canvas_item_set_visible (shell->cursor, FALSE); gimp_display_shell_add_unrotated_item (shell, shell->cursor); g_object_unref (shell->cursor); g_signal_connect (shell->unrotated_item, "update", G_CALLBACK (gimp_display_shell_unrotated_item_update), shell); }
void gimp_display_shell_clear_software_cursor (GimpDisplayShell *shell) { GimpStatusbar *statusbar; GimpSessionInfo *session_info; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); gimp_canvas_item_set_visible (shell->cursor, FALSE); statusbar = gimp_display_shell_get_statusbar (shell); gimp_statusbar_clear_cursor (statusbar); session_info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (), "gimp-cursor-view"); if (session_info && gimp_session_info_get_widget (session_info)) { GtkWidget *cursor_view; cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info))); if (cursor_view) gimp_cursor_view_clear_cursor (GIMP_CURSOR_VIEW (cursor_view)); } }
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool) { GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool); if (blend_tool->grabbed_point != POINT_FILL_MODE && blend_tool->grabbed_point != POINT_INIT_MODE) { blend_tool->line = gimp_draw_tool_add_line (draw_tool, blend_tool->start_x, blend_tool->start_y, blend_tool->end_x, blend_tool->end_y); gimp_canvas_item_set_visible (blend_tool->line, SHOW_LINE); blend_tool->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); blend_tool->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); blend_tool->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); blend_tool->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); gimp_blend_tool_update_item_hilight (blend_tool); } }
static void gimp_display_shell_vectors_visible_handler (GimpVectors *vectors, GimpDisplayShell *shell) { GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors); GimpCanvasItem *item; item = gimp_canvas_proxy_group_get_item (group, vectors); gimp_canvas_item_set_visible (item, gimp_item_get_visible (GIMP_ITEM (vectors))); }
static void gimp_display_shell_vectors_add_handler (GimpContainer *container, GimpVectors *vectors, GimpDisplayShell *shell) { GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors); GimpCanvasItem *item; item = gimp_canvas_path_new (shell, gimp_vectors_get_bezier (vectors), 0, 0, FALSE, GIMP_PATH_STYLE_VECTORS); gimp_canvas_item_set_visible (item, gimp_item_get_visible (GIMP_ITEM (vectors))); gimp_canvas_proxy_group_add_item (group, vectors, item); g_object_unref (item); }
void gimp_display_shell_update_software_cursor (GimpDisplayShell *shell, GimpCursorPrecision precision, gint display_x, gint display_y, gdouble image_x, gdouble image_y) { GimpStatusbar *statusbar; GimpSessionInfo *session_info; GimpImage *image; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); image = gimp_display_get_image (shell->display); if (shell->draw_cursor && shell->proximity && display_x >= 0 && display_y >= 0) { gimp_canvas_item_begin_change (shell->cursor); gimp_canvas_cursor_set (shell->cursor, display_x, display_y); gimp_canvas_item_set_visible (shell->cursor, TRUE); gimp_canvas_item_end_change (shell->cursor); } else { gimp_canvas_item_set_visible (shell->cursor, FALSE); } /* use the passed image_coords for the statusbar because they are * possibly snapped... */ statusbar = gimp_display_shell_get_statusbar (shell); gimp_statusbar_update_cursor (statusbar, precision, image_x, image_y); session_info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (), "gimp-cursor-view"); if (session_info && gimp_session_info_get_widget (session_info)) { GtkWidget *cursor_view; cursor_view = gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (session_info))); if (cursor_view) { gint t_x = -1; gint t_y = -1; /* ...but use the unsnapped display_coords for the info window */ if (display_x >= 0 && display_y >= 0) gimp_display_shell_untransform_xy (shell, display_x, display_y, &t_x, &t_y, FALSE); gimp_cursor_view_update_cursor (GIMP_CURSOR_VIEW (cursor_view), image, shell->unit, t_x, t_y); } } }
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); } }