Bug 496772 – Position shown in the statusbar needs more precision (for

2008-08-20  Michael Natterer  <mitch@gimp.org>

	Bug 496772 – Position shown in the statusbar needs more
	precision (for some tools)

	* app/display/display-enums.[ch]: add enum GimpCursorPrecision
	which can be one of { PIXEL_CENTER, PIXEL_BORDER, SUBPIXEL }.

	* app/display/gimpdisplayshell-cursor.[ch]: add "precision"
	parameter to gimp_display_shell_update_cursor() and pass it
	on to the statusbar.

	* app/display/gimpstatusbar.[ch]: add "precision" parameters to
	the cursor coordinates APIs, offset the passed coords accordingly
	and display them with one decimal point if SUBPIXEL is requested
	and the display's unit is PIXEL. Keep a second floating-point
	format string around at any time.

	* app/tools/gimptoolcontrol.[ch]: add a "precision" member and API
	so tools can configure the precision they need. Defalt to
	PIXEL_CENTER since that's right for almost all tools.

	* app/display/gimpdisplayshell-callbacks.c: pass the tool's
	precision to gimp_display_shell_update_cursor().

	* app/tools/gimptool.[ch]: add "precision" parameter to
	gimp_tool_push_status_coords() and pass it on to the statusbar.

	* app/tools/gimpaligntool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpcolortool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimpperspectiveclonetool.c
	* app/tools/gimprectangleselecttool.c
	* app/tools/gimprectangletool.c
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c: set precision in init() where
	needed. Adjust the precision in the fly when needed, e.g. while
	moving guides or when toggling hard-edge on paint tools. Also pass
	an appropriate precision to gimp_tool_push_status_coords(), which
	is not always the tool's precision as used for cursor display.


svn path=/trunk/; revision=26681
This commit is contained in:
Michael Natterer 2008-08-20 16:22:09 +00:00 committed by Michael Natterer
parent 05287d057a
commit d51c50820f
26 changed files with 370 additions and 112 deletions

View File

@ -1,3 +1,50 @@
2008-08-20 Michael Natterer <mitch@gimp.org>
Bug 496772 Position shown in the statusbar needs more
precision (for some tools)
* app/display/display-enums.[ch]: add enum GimpCursorPrecision
which can be one of { PIXEL_CENTER, PIXEL_BORDER, SUBPIXEL }.
* app/display/gimpdisplayshell-cursor.[ch]: add "precision"
parameter to gimp_display_shell_update_cursor() and pass it
on to the statusbar.
* app/display/gimpstatusbar.[ch]: add "precision" parameters to
the cursor coordinates APIs, offset the passed coords accordingly
and display them with one decimal point if SUBPIXEL is requested
and the display's unit is PIXEL. Keep a second floating-point
format string around at any time.
* app/tools/gimptoolcontrol.[ch]: add a "precision" member and API
so tools can configure the precision they need. Defalt to
PIXEL_CENTER since that's right for almost all tools.
* app/display/gimpdisplayshell-callbacks.c: pass the tool's
precision to gimp_display_shell_update_cursor().
* app/tools/gimptool.[ch]: add "precision" parameter to
gimp_tool_push_status_coords() and pass it on to the statusbar.
* app/tools/gimpaligntool.c
* app/tools/gimpblendtool.c
* app/tools/gimpcolortool.c
* app/tools/gimpcroptool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpfliptool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpmovetool.c
* app/tools/gimppainttool.c
* app/tools/gimpperspectiveclonetool.c
* app/tools/gimprectangleselecttool.c
* app/tools/gimprectangletool.c
* app/tools/gimptransformtool.c
* app/tools/gimpvectortool.c: set precision in init() where
needed. Adjust the precision in the fly when needed, e.g. while
moving guides or when toggling hard-edge on paint tools. Also pass
an appropriate precision to gimp_tool_push_status_coords(), which
is not always the tool's precision as used for cursor display.
2008-08-20 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/script-fu-console.c (script_fu_eval_run):

View File

@ -38,6 +38,36 @@ gimp_cursor_mode_get_type (void)
return type;
}
GType
gimp_cursor_precision_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_CURSOR_PRECISION_PIXEL_CENTER, "GIMP_CURSOR_PRECISION_PIXEL_CENTER", "pixel-center" },
{ GIMP_CURSOR_PRECISION_PIXEL_BORDER, "GIMP_CURSOR_PRECISION_PIXEL_BORDER", "pixel-border" },
{ GIMP_CURSOR_PRECISION_SUBPIXEL, "GIMP_CURSOR_PRECISION_SUBPIXEL", "subpixel" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_CURSOR_PRECISION_PIXEL_CENTER, "GIMP_CURSOR_PRECISION_PIXEL_CENTER", NULL },
{ GIMP_CURSOR_PRECISION_PIXEL_BORDER, "GIMP_CURSOR_PRECISION_PIXEL_BORDER", NULL },
{ GIMP_CURSOR_PRECISION_SUBPIXEL, "GIMP_CURSOR_PRECISION_SUBPIXEL", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpCursorPrecision", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_canvas_padding_mode_get_type (void)
{

View File

@ -32,6 +32,18 @@ typedef enum
} GimpCursorMode;
#define GIMP_TYPE_CURSOR_PRECISION (gimp_cursor_precision_get_type ())
GType gimp_cursor_precision_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_CURSOR_PRECISION_PIXEL_CENTER,
GIMP_CURSOR_PRECISION_PIXEL_BORDER,
GIMP_CURSOR_PRECISION_SUBPIXEL
} GimpCursorPrecision;
#define GIMP_TYPE_CANVAS_PADDING_MODE (gimp_canvas_padding_mode_get_type ())
GType gimp_canvas_padding_mode_get_type (void) G_GNUC_CONST;

View File

@ -1529,11 +1529,21 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
if (update_sw_cursor)
gimp_display_shell_update_cursor (shell,
(gint) display_coords.x,
(gint) display_coords.y,
(gint) image_coords.x,
(gint) image_coords.y);
{
GimpCursorPrecision precision = GIMP_CURSOR_PRECISION_PIXEL_CENTER;
active_tool = tool_manager_get_active (gimp);
if (active_tool)
precision = gimp_tool_control_get_precision (active_tool->control);
gimp_display_shell_update_cursor (shell,
precision,
(gint) display_coords.x,
(gint) display_coords.y,
image_coords.x,
image_coords.y);
}
return return_val;
}

View File

@ -117,11 +117,12 @@ gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell)
}
void
gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint display_x,
gint display_y,
gint image_x,
gint image_y)
gimp_display_shell_update_cursor (GimpDisplayShell *shell,
GimpCursorPrecision precision,
gint display_x,
gint display_y,
gdouble image_x,
gdouble image_y)
{
GimpDialogFactory *factory;
GimpSessionInfo *session_info;
@ -159,7 +160,7 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
* possibly snapped...
*/
gimp_statusbar_update_cursor (GIMP_STATUSBAR (shell->statusbar),
image_x, image_y);
precision, image_x, image_y);
factory = gimp_dialog_factory_from_name ("dock");
session_info = gimp_dialog_factory_find_session_info (factory,

View File

@ -20,21 +20,22 @@
#define __GIMP_DISPLAY_SHELL_CURSOR_H__
void gimp_display_shell_set_cursor (GimpDisplayShell *shell,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_display_shell_unset_cursor (GimpDisplayShell *shell);
void gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
GimpCursorType cursor_type);
void gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell);
void gimp_display_shell_set_cursor (GimpDisplayShell *shell,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_display_shell_unset_cursor (GimpDisplayShell *shell);
void gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
GimpCursorType cursor_type);
void gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell);
void gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint display_x,
gint display_y,
gint image_x,
gint image_y);
void gimp_display_shell_clear_cursor (GimpDisplayShell *shell);
void gimp_display_shell_update_cursor (GimpDisplayShell *shell,
GimpCursorPrecision precision,
gint display_x,
gint display_y,
gdouble image_x,
gdouble image_y);
void gimp_display_shell_clear_cursor (GimpDisplayShell *shell);
#endif /* __GIMP_DISPLAY_SHELL_CURSOR_H__ */

View File

@ -164,8 +164,9 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
statusbar->temp_context_id =
gimp_statusbar_get_context_id (statusbar, "gimp-statusbar-temp");
statusbar->cursor_format_str[0] = '\0';
statusbar->length_format_str[0] = '\0';
statusbar->cursor_format_str[0] = '\0';
statusbar->cursor_format_str_f[0] = '\0';
statusbar->length_format_str[0] = '\0';
statusbar->progress_active = FALSE;
statusbar->progress_shown = FALSE;
@ -792,14 +793,15 @@ gimp_statusbar_push_valist (GimpStatusbar *statusbar,
}
void
gimp_statusbar_push_coords (GimpStatusbar *statusbar,
const gchar *context,
const gchar *stock_id,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y,
const gchar *help)
gimp_statusbar_push_coords (GimpStatusbar *statusbar,
const gchar *context,
const gchar *stock_id,
GimpCursorPrecision precision,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y,
const gchar *help)
{
GimpDisplayShell *shell;
@ -812,16 +814,46 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
shell = statusbar->shell;
switch (precision)
{
case GIMP_CURSOR_PRECISION_PIXEL_CENTER:
x = RINT (x + 0.5);
y = RINT (y + 0.5);
break;
case GIMP_CURSOR_PRECISION_PIXEL_BORDER:
x = RINT (x);
y = RINT (y);
break;
case GIMP_CURSOR_PRECISION_SUBPIXEL:
break;
}
if (shell->unit == GIMP_UNIT_PIXEL)
{
gimp_statusbar_push (statusbar, context,
stock_id,
statusbar->cursor_format_str,
title,
(gint) RINT (x),
separator,
(gint) RINT (y),
help);
if (precision == GIMP_CURSOR_PRECISION_SUBPIXEL)
{
gimp_statusbar_push (statusbar, context,
stock_id,
statusbar->cursor_format_str_f,
title,
x,
separator,
y,
help);
}
else
{
gimp_statusbar_push (statusbar, context,
stock_id,
statusbar->cursor_format_str,
title,
(gint) RINT (x),
separator,
(gint) RINT (y),
help);
}
}
else /* show real world units */
{
@ -1132,13 +1164,12 @@ gimp_statusbar_pop_temp (GimpStatusbar *statusbar)
}
void
gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
gdouble x,
gdouble y)
gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
GimpCursorPrecision precision,
gdouble x,
gdouble y)
{
GimpDisplayShell *shell;
GtkTreeModel *model;
GimpUnitStore *store;
gchar buffer[CURSOR_LEN];
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
@ -1158,19 +1189,46 @@ gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
gtk_widget_set_sensitive (statusbar->cursor_label, TRUE);
}
model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
store = GIMP_UNIT_STORE (model);
switch (precision)
{
case GIMP_CURSOR_PRECISION_PIXEL_CENTER:
x = RINT (x + 0.5);
y = RINT (y + 0.5);
break;
gimp_unit_store_set_pixel_values (store, x, y);
case GIMP_CURSOR_PRECISION_PIXEL_BORDER:
x = RINT (x);
y = RINT (y);
break;
case GIMP_CURSOR_PRECISION_SUBPIXEL:
break;
}
if (shell->unit == GIMP_UNIT_PIXEL)
{
g_snprintf (buffer, sizeof (buffer),
statusbar->cursor_format_str,
"", (gint) RINT (x), ", ", (gint) RINT (y), "");
if (precision == GIMP_CURSOR_PRECISION_SUBPIXEL)
{
g_snprintf (buffer, sizeof (buffer),
statusbar->cursor_format_str_f,
"", x, ", ", y, "");
}
else
{
g_snprintf (buffer, sizeof (buffer),
statusbar->cursor_format_str,
"", (gint) RINT (x), ", ", (gint) RINT (y), "");
}
}
else /* show real world units */
{
GtkTreeModel *model;
GimpUnitStore *store;
model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
store = GIMP_UNIT_STORE (model);
gimp_unit_store_set_pixel_values (store, x, y);
gimp_unit_store_get_values (store, shell->unit, &x, &y);
g_snprintf (buffer, sizeof (buffer),
@ -1275,6 +1333,9 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
g_snprintf (statusbar->cursor_format_str,
sizeof (statusbar->cursor_format_str),
"%%s%%d%%s%%d%%s");
g_snprintf (statusbar->cursor_format_str_f,
sizeof (statusbar->cursor_format_str_f),
"%%s%%.1f%%s%%.1f%%s");
g_snprintf (statusbar->length_format_str,
sizeof (statusbar->length_format_str),
"%%s%%d%%s");
@ -1286,13 +1347,15 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
"%%s%%.%df%%s%%.%df%%s",
_gimp_unit_get_digits (shell->display->gimp, shell->unit),
_gimp_unit_get_digits (shell->display->gimp, shell->unit));
strcpy (statusbar->cursor_format_str_f, statusbar->cursor_format_str);
g_snprintf (statusbar->length_format_str,
sizeof (statusbar->length_format_str),
"%%s%%.%df%%s",
_gimp_unit_get_digits (shell->display->gimp, shell->unit));
}
gimp_statusbar_update_cursor (statusbar, image_width, image_height);
gimp_statusbar_update_cursor (statusbar, GIMP_CURSOR_PRECISION_SUBPIXEL,
image_width, image_height);
text = gtk_label_get_text (GTK_LABEL (statusbar->cursor_label));

View File

@ -52,6 +52,7 @@ struct _GimpStatusbar
GimpMessageSeverity temp_severity;
gchar cursor_format_str[CURSOR_FORMAT_LENGTH];
gchar cursor_format_str_f[CURSOR_FORMAT_LENGTH];
gchar length_format_str[CURSOR_FORMAT_LENGTH];
GtkWidget *cursor_label;
@ -93,6 +94,7 @@ void gimp_statusbar_push_valist (GimpStatusbar *statusbar,
void gimp_statusbar_push_coords (GimpStatusbar *statusbar,
const gchar *context,
const gchar *stock_id,
GimpCursorPrecision precision,
const gchar *title,
gdouble x,
const gchar *separator,
@ -133,6 +135,7 @@ void gimp_statusbar_push_temp_valist (GimpStatusbar *statusbar,
void gimp_statusbar_pop_temp (GimpStatusbar *statusbar);
void gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
GimpCursorPrecision precision,
gdouble x,
gdouble y);
void gimp_statusbar_clear_cursor (GimpStatusbar *statusbar);

View File

@ -176,6 +176,8 @@ gimp_align_tool_init (GimpAlignTool *align_tool)
align_tool->vert_offset = 0;
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);
}

View File

@ -390,7 +390,8 @@ gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
GdkModifierType state,
GimpDisplay *display)
{
gchar *status_help;
GimpTool *tool = GIMP_TOOL (blend_tool);
gchar *status_help;
status_help = gimp_suggest_modifiers ("",
((GDK_CONTROL_MASK | GDK_MOD1_MASK)
@ -398,11 +399,14 @@ gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
NULL,
_("%s for constrained angles"),
_("%s to move the whole line"));
gimp_tool_push_status_coords (GIMP_TOOL (blend_tool), display,
gimp_tool_push_status_coords (tool, display,
gimp_tool_control_get_precision (tool->control),
_("Blend: "),
blend_tool->end_x - blend_tool->start_x,
", ",
blend_tool->end_y - blend_tool->start_y,
status_help);
g_free (status_help);
}

View File

@ -254,6 +254,7 @@ gimp_color_tool_button_press (GimpTool *tool,
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
gimp_tool_push_status_coords (tool, display,
gimp_tool_control_get_precision (tool->control),
_("Move Sample Point: "),
color_tool->sample_point_x,
", ",
@ -431,6 +432,7 @@ gimp_color_tool_motion (GimpTool *tool,
else
{
gimp_tool_push_status_coords (tool, display,
gimp_tool_control_get_precision (tool->control),
color_tool->sample_point ?
_("Move Sample Point: ") :
_("Add Sample Point: "),

View File

@ -172,6 +172,8 @@ gimp_crop_tool_init (GimpCropTool *crop_tool)
gimp_rectangle_tool_init (GIMP_RECTANGLE_TOOL (crop_tool));
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
crop_tool->current_image = NULL;

View File

@ -186,6 +186,7 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool,
gboolean propagate_release)
{
GimpEditSelectionTool *edit_select;
GimpTool *tool;
GimpDisplayShell *shell;
GimpItem *active_item;
GimpChannel *channel;
@ -201,6 +202,8 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool,
edit_select->propagate_release = propagate_release;
tool = GIMP_TOOL (edit_select);
shell = GIMP_DISPLAY_SHELL (display->shell);
/* Make a check to see if it should be a floating selection translation */
@ -429,7 +432,7 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool,
break;
}
gimp_tool_control_set_snap_offsets (GIMP_TOOL (edit_select)->control,
gimp_tool_control_set_snap_offsets (tool->control,
x1 - coords->x,
y1 - coords->y,
x2 - x1,
@ -440,16 +443,17 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool,
edit_select->center_y = (y1 + y2) / 2.0;
}
gimp_tool_control_activate (GIMP_TOOL (edit_select)->control);
GIMP_TOOL (edit_select)->display = display;
gimp_tool_control_activate (tool->control);
tool->display = display;
tool_manager_push_tool (display->image->gimp, GIMP_TOOL (edit_select));
tool_manager_push_tool (display->image->gimp, tool);
/* pause the current selection */
gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE);
/* initialize the statusbar display */
gimp_tool_push_status_coords (GIMP_TOOL (edit_select), display,
gimp_tool_push_status_coords (tool, display,
gimp_tool_control_get_precision (tool->control),
_("Move: "), 0, ", ", 0, NULL);
gimp_draw_tool_start (GIMP_DRAW_TOOL (edit_select), display);
@ -579,8 +583,8 @@ gimp_edit_selection_tool_update_motion (GimpEditSelectionTool *edit_select,
gdouble new_y,
GimpDisplay *display)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (edit_select);
GimpTool *tool = GIMP_TOOL (edit_select);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (edit_select);
GimpTool *tool = GIMP_TOOL (edit_select);
GimpItem *active_item;
gint off_x, off_y;
gdouble motion_x, motion_y;
@ -718,6 +722,7 @@ gimp_edit_selection_tool_update_motion (GimpEditSelectionTool *edit_select,
gimp_tool_pop_status (tool, display);
gimp_tool_push_status_coords (tool, display,
gimp_tool_control_get_precision (tool->control),
_("Move: "),
edit_select->cumlx,
", ",
@ -772,7 +777,7 @@ static void
gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
{
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (draw_tool);
GimpDisplay *display = GIMP_TOOL (draw_tool)->display;
GimpDisplay *display = GIMP_TOOL (draw_tool)->display;
GimpItem *active_item;
active_item = gimp_edit_selection_tool_get_active_item (edit_select,

View File

@ -104,6 +104,8 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool)
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (flip_tool);
gimp_tool_control_set_snap_to (tool->control, FALSE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_CURSOR_MOUSE);
gimp_tool_control_set_tool_cursor (tool->control,

View File

@ -236,6 +236,8 @@ gimp_free_select_tool_init (GimpFreeSelectTool *fst)
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);

View File

@ -262,6 +262,9 @@ gimp_move_tool_button_press (GimpTool *tool,
move->guide_orientation = gimp_guide_get_orientation (guide);
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
gimp_tool_control_activate (tool->control);
gimp_display_shell_selection_control (shell,
@ -366,6 +369,9 @@ gimp_move_tool_button_release (GimpTool *tool,
gimp_tool_pop_status (tool, display);
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)

View File

@ -90,6 +90,10 @@ static void gimp_paint_tool_oper_update (GimpTool *tool,
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
static void gimp_paint_tool_hard_notify (GimpPaintOptions *options,
const GParamSpec *pspec,
GimpTool *tool);
G_DEFINE_TYPE (GimpPaintTool, gimp_paint_tool, GIMP_TYPE_COLOR_TOOL)
@ -121,8 +125,8 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
{
GimpTool *tool = GIMP_TOOL (paint_tool);
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_action_value_1 (tool->control,
"context/context-opacity-set");
@ -144,15 +148,17 @@ gimp_paint_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpTool *tool;
GimpPaintInfo *paint_info;
GimpPaintTool *paint_tool;
GObject *object;
GimpTool *tool;
GimpPaintInfo *paint_info;
GimpPaintTool *paint_tool;
GimpPaintOptions *options;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
tool = GIMP_TOOL (object);
paint_tool = GIMP_PAINT_TOOL (object);
options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
g_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_info));
@ -165,6 +171,12 @@ gimp_paint_tool_constructor (GType type,
"undo-desc", paint_info->blurb,
NULL);
g_signal_connect_object (options, "notify::hard",
G_CALLBACK (gimp_paint_tool_hard_notify),
tool, 0);
gimp_paint_tool_hard_notify (options, NULL, tool);
return object;
}
@ -706,3 +718,14 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
}
static void
gimp_paint_tool_hard_notify (GimpPaintOptions *options,
const GParamSpec *pspec,
GimpTool *tool)
{
gimp_tool_control_set_precision (tool->control,
options->hard ?
GIMP_CURSOR_PRECISION_PIXEL_CENTER :
GIMP_CURSOR_PRECISION_SUBPIXEL);
}

View File

@ -876,20 +876,25 @@ gimp_perspective_clone_tool_mode_notify (GimpPerspectiveCloneOptions *options,
GParamSpec *pspec,
GimpPerspectiveCloneTool *clone_tool)
{
GimpTool *tool = GIMP_TOOL (clone_tool);
GimpPerspectiveClone *clone;
clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (clone_tool)->core);
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
{
gimp_tool_control_set_tool_cursor (GIMP_TOOL (clone_tool)->control,
/* GimpPaintTool's notify callback will set the right precision */
g_object_notify (G_OBJECT (options), "hard");
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_CLONE);
gimp_perspective_clone_set_transform (clone, &clone_tool->transform);
}
else
{
GimpTool *tool = GIMP_TOOL (clone_tool);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PERSPECTIVE);

View File

@ -222,6 +222,8 @@ gimp_rectangle_select_tool_init (GimpRectangleSelectTool *rect_sel_tool)
priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool);
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_RECT_SELECT);
gimp_tool_control_set_dirty_mask (tool->control,

View File

@ -1080,6 +1080,7 @@ gimp_rectangle_tool_motion (GimpTool *tool,
aspect_text = g_strdup_printf (" (%.2f:1)", w / (gdouble) h);
gimp_tool_push_status_coords (tool, display,
GIMP_CURSOR_PRECISION_PIXEL_CENTER,
_("Rectangle: "),
w, " × ", h, aspect_text);
g_free (aspect_text);
@ -1976,6 +1977,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
/* initialize the statusbar display */
gimp_tool_push_status_coords (tool, tool->display,
GIMP_CURSOR_PRECISION_PIXEL_CENTER,
_("Rectangle: "), 0, " × ", 0, NULL);
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display);

View File

@ -864,13 +864,14 @@ gimp_tool_push_status (GimpTool *tool,
}
void
gimp_tool_push_status_coords (GimpTool *tool,
GimpDisplay *display,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y,
const gchar *help)
gimp_tool_push_status_coords (GimpTool *tool,
GimpDisplay *display,
GimpCursorPrecision precision,
const gchar *title,
gdouble x,
const gchar *separator,
gdouble y,
const gchar *help)
{
GimpDisplayShell *shell;
const gchar *stock_id;
@ -884,7 +885,8 @@ gimp_tool_push_status_coords (GimpTool *tool,
gimp_statusbar_push_coords (GIMP_STATUSBAR (shell->statusbar),
G_OBJECT_TYPE_NAME (tool), stock_id,
title, x, separator, y, help);
precision, title, x, separator, y,
help);
tool->status_displays = g_list_remove (tool->status_displays, display);
tool->status_displays = g_list_prepend (tool->status_displays, display);

View File

@ -191,6 +191,7 @@ void gimp_tool_push_status (GimpTool *tool,
...) G_GNUC_PRINTF(3,4);
void gimp_tool_push_status_coords (GimpTool *tool,
GimpDisplay *display,
GimpCursorPrecision precision,
const gchar *title,
gdouble x,
const gchar *separator,

View File

@ -60,6 +60,8 @@ gimp_tool_control_init (GimpToolControl *control)
control->snap_width = 0;
control->snap_height = 0;
control->precision = GIMP_CURSOR_PRECISION_PIXEL_CENTER;
control->toggled = FALSE;
control->cursor = GIMP_CURSOR_MOUSE;
@ -300,6 +302,24 @@ gimp_tool_control_get_snap_offsets (GimpToolControl *control,
if (height) *height = control->snap_height;
}
void
gimp_tool_control_set_precision (GimpToolControl *control,
GimpCursorPrecision precision)
{
g_return_if_fail (GIMP_IS_TOOL_CONTROL (control));
control->precision = precision;
}
GimpCursorPrecision
gimp_tool_control_get_precision (GimpToolControl *control)
{
g_return_val_if_fail (GIMP_IS_TOOL_CONTROL (control),
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
return control->precision;
}
void
gimp_tool_control_set_toggled (GimpToolControl *control,
gboolean toggled)

View File

@ -36,43 +36,45 @@ typedef struct _GimpToolControlClass GimpToolControlClass;
struct _GimpToolControl
{
GimpObject parent_instance;
GimpObject parent_instance;
gboolean active; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean active; /* state of tool activity */
gint paused_count; /* paused control count */
gboolean preserve; /* Preserve this tool across *
* drawable changes */
gboolean scroll_lock; /* allow scrolling or not */
gboolean handle_empty_image; /* invoke the tool on images *
* without active drawable */
gboolean wants_click; /* wants click detection */
GimpDirtyMask dirty_mask; /* if preserve is FALSE, cancel *
* the tool on these events */
GimpMotionMode motion_mode; /* how to process motion events *
* before they go to the tool */
gboolean auto_snap_to; /* snap to guides automatically */
gint snap_offset_x;
gint snap_offset_y;
gint snap_width;
gint snap_height;
gboolean preserve; /* Preserve this tool across *
* drawable changes */
gboolean scroll_lock; /* allow scrolling or not */
gboolean handle_empty_image; /* invoke the tool on images *
* without active drawable */
gboolean wants_click; /* wants click detection */
GimpDirtyMask dirty_mask; /* if preserve is FALSE, cancel *
* the tool on these events */
GimpMotionMode motion_mode; /* how to process motion events *
* before they go to the tool */
gboolean auto_snap_to; /* snap to guides automatically */
gint snap_offset_x;
gint snap_offset_y;
gint snap_width;
gint snap_height;
gboolean toggled;
GimpCursorPrecision precision;
GimpCursorType cursor;
GimpToolCursorType tool_cursor;
GimpCursorModifier cursor_modifier;
gboolean toggled;
GimpCursorType toggle_cursor;
GimpToolCursorType toggle_tool_cursor;
GimpCursorModifier toggle_cursor_modifier;
GimpCursorType cursor;
GimpToolCursorType tool_cursor;
GimpCursorModifier cursor_modifier;
gchar *action_value_1;
gchar *action_value_2;
gchar *action_value_3;
gchar *action_value_4;
gchar *action_object_1;
gchar *action_object_2;
GimpCursorType toggle_cursor;
GimpToolCursorType toggle_tool_cursor;
GimpCursorModifier toggle_cursor_modifier;
gchar *action_value_1;
gchar *action_value_2;
gchar *action_value_3;
gchar *action_value_4;
gchar *action_object_1;
gchar *action_object_2;
};
struct _GimpToolControlClass
@ -130,6 +132,11 @@ void gimp_tool_control_get_snap_offsets (GimpToolControl *control,
gint *width,
gint *height);
void gimp_tool_control_set_precision (GimpToolControl *control,
GimpCursorPrecision precision);
GimpCursorPrecision
gimp_tool_control_get_precision (GimpToolControl *control);
void gimp_tool_control_set_toggled (GimpToolControl *control,
gboolean toggled);
gboolean gimp_tool_control_get_toggled (GimpToolControl *control);

View File

@ -203,6 +203,8 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
GIMP_DIRTY_IMAGE_SIZE |
GIMP_DIRTY_DRAWABLE |
GIMP_DIRTY_SELECTION);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
tr_tool->function = TRANSFORM_CREATING;
tr_tool->original = NULL;

View File

@ -192,6 +192,8 @@ gimp_vector_tool_init (GimpVectorTool *vector_tool)
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
gimp_tool_control_set_motion_mode (tool->control,
GIMP_MOTION_MODE_COMPRESS);
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_PATHS);