added GimpRectangleGuide enum.

2006-06-05  Karine Delvare  <edhel@gimp.org>

	* app/tools/tools-enums.[ch]: added GimpRectangleGuide enum.

	* app/tools/gimpcropoptions.c
	* app/tools/gimprectangleoptions.[ch]
	* app/tools/gimprectangletool.c: added GimpRectangleGuide option to
	draw guides inside the rectangle. Fixes bug #323669.
This commit is contained in:
Karine Delvare 2006-06-05 18:50:13 +00:00 committed by Karine Delvare
parent b37478550d
commit 23f86e93b8
7 changed files with 158 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2006-06-05 Karine Delvare <edhel@gimp.org>
* app/tools/tools-enums.[ch]: added GimpRectangleGuide enum.
* app/tools/gimpcropoptions.c
* app/tools/gimprectangleoptions.[ch]
* app/tools/gimprectangletool.c: added GimpRectangleGuide option to
draw guides inside the rectangle. Fixes bug #323669.
2006-06-05 Michael Natterer <mitch@gimp.org>
Applied slightly modified patch from saulgoode which allows to

View File

@ -102,6 +102,7 @@ gimp_crop_options_set_property (GObject *object,
switch (property_id)
{
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:
@ -138,6 +139,7 @@ gimp_crop_options_get_property (GObject *object,
switch (property_id)
{
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:

View File

@ -39,6 +39,7 @@ typedef struct _GimpRectangleOptionsPrivate GimpRectangleOptionsPrivate;
struct _GimpRectangleOptionsPrivate
{
gboolean highlight;
GimpRectangleGuide guide;
gboolean fixed_width;
gdouble width;
@ -66,6 +67,10 @@ static GimpRectangleOptionsPrivate *
void gimp_rectangle_options_set_highlight (GimpRectangleOptions *options,
gboolean highlight);
gboolean gimp_rectangle_options_get_highlight (GimpRectangleOptions *options);
void gimp_rectangle_options_set_guide (GimpRectangleOptions *options,
GimpRectangleGuide guide);
GimpRectangleGuide
gimp_rectangle_options_get_guide (GimpRectangleOptions *options);
void gimp_rectangle_options_set_fixed_width (GimpRectangleOptions *options,
gboolean fixed_width);
@ -145,6 +150,12 @@ gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *options_i
NULL, NULL,
TRUE,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (options_iface,
g_param_spec_enum ("guide",
NULL, NULL,
GIMP_TYPE_RECTANGLE_GUIDE,
GIMP_RECTANGLE_GUIDE_NONE,
GIMP_PARAM_READWRITE));
g_object_interface_install_property (options_iface,
g_param_spec_boolean ("new-fixed-width",
@ -285,6 +296,9 @@ gimp_rectangle_options_install_properties (GObjectClass *klass)
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT,
"highlight");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
"guide");
g_object_class_override_property (klass,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH,
"new-fixed-width");
@ -346,6 +360,32 @@ gimp_rectangle_options_get_highlight (GimpRectangleOptions *options)
return private->highlight;
}
void
gimp_rectangle_options_set_guide (GimpRectangleOptions *options,
GimpRectangleGuide guide)
{
GimpRectangleOptionsPrivate *private;
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
private->guide = guide;
g_object_notify (G_OBJECT (options), "guide");
}
GimpRectangleGuide
gimp_rectangle_options_get_guide (GimpRectangleOptions *options)
{
GimpRectangleOptionsPrivate *private;
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), FALSE);
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
return private->guide;
}
void
gimp_rectangle_options_set_fixed_width (GimpRectangleOptions *options,
gboolean fixed_width)
@ -645,6 +685,9 @@ gimp_rectangle_options_set_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
gimp_rectangle_options_set_highlight (options, g_value_get_boolean (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
gimp_rectangle_options_set_guide (options, g_value_get_enum (value));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
gimp_rectangle_options_set_fixed_width (options, g_value_get_boolean (value));
break;
@ -697,6 +740,9 @@ gimp_rectangle_options_get_property (GObject *object,
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
g_value_set_boolean (value, gimp_rectangle_options_get_highlight (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
g_value_set_enum (value, gimp_rectangle_options_get_guide (options));
break;
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
g_value_set_boolean (value, gimp_rectangle_options_get_fixed_width (options));
break;
@ -742,6 +788,7 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *combo;
GtkWidget *table;
GtkWidget *entry;
GtkWidget *hbox;
@ -756,6 +803,10 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
combo = gimp_prop_enum_combo_box_new (config, "guide", 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);

View File

@ -24,6 +24,7 @@ typedef enum
{
GIMP_RECTANGLE_OPTIONS_PROP_0,
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT,
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_WIDTH,
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT,

View File

@ -1665,10 +1665,14 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
void
gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
GimpCanvas *canvas = GIMP_CANVAS (shell->canvas);
GimpRectangleToolPrivate *private;
GimpRectangleOptions *options;
gint x1, x2, y1, y2;
guint function;
GimpRectangleGuide guide;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
@ -1697,6 +1701,51 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x2, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_EAST, FALSE);
options = GIMP_RECTANGLE_OPTIONS (tool->tool_info->tool_options);
g_object_get (options, "guide", &guide, NULL);
switch (guide)
{
case GIMP_RECTANGLE_GUIDE_NONE:
break;
case GIMP_RECTANGLE_GUIDE_CENTER_LINES:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (y1 + y2) / 2,
x2 - 1, (y1 + y2) / 2);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(x1 + x2) / 2, y1 + 1,
(x1 + x2) / 2, y2 - 1);
break;
case GIMP_RECTANGLE_GUIDE_THIRDS:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (2 * y1 + y2) / 3,
x2 - 1, (2 * y1 + y2) / 3);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (y1 + 2 * y2) / 3,
x2 - 1, (y1 + 2 * y2) / 3);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(2 * x1 + x2) / 3, y1 + 1,
(2 * x1 + x2) / 3, y2 - 1);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(x1 + 2 * x2) / 3, y1 + 1,
(x1 + 2 * x2) / 3, y2 - 1);
break;
case GIMP_RECTANGLE_GUIDE_GOLDEN:
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)),
x2 - 1, (2 * y1 + (1 + sqrt(5)) * y2) / (3 + sqrt(5)));
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
x1 + 1, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)),
x2 - 1, ((1 + sqrt(5)) * y1 + 2 * y2) / (3 + sqrt(5)));
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y1 + 1,
(2 * x1 + (1 + sqrt(5)) * x2) / (3 + sqrt(5)), y2 - 1);
gimp_canvas_draw_line (canvas, GIMP_CANVAS_STYLE_XOR,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y1 + 1,
((1 + sqrt(5)) * x1 + 2 * x2) / (3 + sqrt(5)), y2 - 1);
break;
}
}
void

View File

@ -41,6 +41,38 @@ gimp_color_pick_mode_get_type (void)
return type;
}
GType
gimp_rectangle_guide_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_RECTANGLE_GUIDE_NONE, "GIMP_RECTANGLE_GUIDE_NONE", "none" },
{ GIMP_RECTANGLE_GUIDE_CENTER_LINES, "GIMP_RECTANGLE_GUIDE_CENTER_LINES", "center-lines" },
{ GIMP_RECTANGLE_GUIDE_THIRDS, "GIMP_RECTANGLE_GUIDE_THIRDS", "thirds" },
{ GIMP_RECTANGLE_GUIDE_GOLDEN, "GIMP_RECTANGLE_GUIDE_GOLDEN", "golden" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_RECTANGLE_GUIDE_NONE, N_("No guides"), NULL },
{ GIMP_RECTANGLE_GUIDE_CENTER_LINES, N_("Center lines"), NULL },
{ GIMP_RECTANGLE_GUIDE_THIRDS, N_("Rule of thirds"), NULL },
{ GIMP_RECTANGLE_GUIDE_GOLDEN, N_("Golden sections"), NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (! type)
{
type = g_enum_register_static ("GimpRectangleGuide", values);
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_crop_mode_get_type (void)
{

View File

@ -36,6 +36,19 @@ typedef enum
} GimpColorPickMode;
#define GIMP_TYPE_RECTANGLE_GUIDE (gimp_rectangle_guide_get_type ())
GType gimp_rectangle_guide_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_RECTANGLE_GUIDE_NONE, /*< desc="No guides" >*/
GIMP_RECTANGLE_GUIDE_CENTER_LINES, /*< desc="Center lines" >*/
GIMP_RECTANGLE_GUIDE_THIRDS, /*< desc="Rule of thirds" >*/
GIMP_RECTANGLE_GUIDE_GOLDEN /*< desc="Golden sections" >*/
} GimpRectangleGuide;
#define GIMP_TYPE_CROP_MODE (gimp_crop_mode_get_type ())
GType gimp_crop_mode_get_type (void) G_GNUC_CONST;