added unit properties for stroke width and dashes. Use convenience macros

2003-09-27  Sven Neumann  <sven@gimp.org>

	* app/core/gimpstrokeoptions.[ch]: added unit properties for
	stroke width and dashes. Use convenience macros from GimpConfig to
	register the properties. Removed init function since all values
	are construct properties.

	* app/vectors/gimpvectors.c: respect the stroke width unit.

	* app/widgets/gimpstrokeeditor.c: added a unit menu here.
This commit is contained in:
Sven Neumann 2003-09-27 14:58:46 +00:00 committed by Sven Neumann
parent 07417fb07e
commit b2a6cddcfb
7 changed files with 106 additions and 92 deletions

View File

@ -1,3 +1,14 @@
2003-09-27 Sven Neumann <sven@gimp.org>
* app/core/gimpstrokeoptions.[ch]: added unit properties for
stroke width and dashes. Use convenience macros from GimpConfig to
register the properties. Removed init function since all values
are construct properties.
* app/vectors/gimpvectors.c: respect the stroke width unit.
* app/widgets/gimpstrokeeditor.c: added a unit menu here.
2003-09-27 Michael Natterer <mitch@gimp.org>
* app/gui/stroke-dialog.[ch]: made it a view on the GimpItem to

View File

@ -27,7 +27,7 @@
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "gimpstrokeoptions.h"
@ -35,16 +35,17 @@ enum
{
PROP_0,
PROP_WIDTH,
PROP_WIDTH_UNIT,
PROP_CAP_STYLE,
PROP_JOIN_STYLE,
PROP_MITER,
PROP_ANTIALIAS,
PROP_DASH_UNIT,
PROP_DASH_OFFSET,
PROP_DASH_INFO
};
static void gimp_stroke_options_init (GimpStrokeOptions *options);
static void gimp_stroke_options_class_init (GimpStrokeOptionsClass *options_class);
static void gimp_stroke_options_set_property (GObject *object,
@ -77,7 +78,7 @@ gimp_stroke_options_get_type (void)
NULL, /* class_data */
sizeof (GimpStrokeOptions),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_stroke_options_init,
NULL /* instance_init */
};
type = g_type_register_static (GIMP_TYPE_CONTEXT,
@ -101,70 +102,49 @@ gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass)
object_class->set_property = gimp_stroke_options_set_property;
object_class->get_property = gimp_stroke_options_get_property;
g_object_class_install_property (object_class, PROP_WIDTH,
g_param_spec_double ("width",
NULL, NULL,
0.0, 2000.0,
5.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_CAP_STYLE,
g_param_spec_enum ("cap-style",
NULL, NULL,
GIMP_TYPE_CAP_STYLE,
GIMP_CAP_BUTT,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_JOIN_STYLE,
g_param_spec_enum ("join-style",
NULL, NULL,
GIMP_TYPE_JOIN_STYLE,
GIMP_JOIN_MITER,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_MITER,
g_param_spec_double ("miter",
NULL, NULL,
0.0, 100.0,
10.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ANTIALIAS,
g_param_spec_boolean ("antialias",
NULL, NULL,
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DASH_OFFSET,
g_param_spec_double ("dash-offset",
NULL, NULL,
0.0, 2000.0,
0.0,
G_PARAM_READWRITE));
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_WIDTH,
"width", NULL,
0.0, 2000.0, 5.0,
0);
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_WIDTH_UNIT,
"width-unit", NULL,
TRUE, FALSE, GIMP_UNIT_PIXEL,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CAP_STYLE,
"cap-style", NULL,
GIMP_TYPE_CAP_STYLE, GIMP_CAP_BUTT,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_JOIN_STYLE,
"join-style", NULL,
GIMP_TYPE_JOIN_STYLE, GIMP_JOIN_MITER,
0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MITER,
"miter", NULL,
0.0, 100.0, 10.0,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
"antialias", NULL,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_DASH_UNIT,
"dash-unit", NULL,
TRUE, FALSE, GIMP_UNIT_PIXEL,
0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_DASH_OFFSET,
"dash-offset", NULL,
0.0, 2000.0, 10.0,
0);
array_spec = g_param_spec_double ("dash-length", NULL, NULL,
0.0, 2000.0, 1.0, G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_DASH_INFO,
g_param_spec_value_array ("dash-info",
NULL, NULL,
array_spec,
G_PARAM_READWRITE));
GIMP_CONFIG_PARAM_FLAGS));
}
static void
gimp_stroke_options_init (GimpStrokeOptions *options)
{
options->width = 5.0;
options->cap_style = GIMP_CAP_BUTT;
options->join_style = GIMP_JOIN_MITER;
options->miter = 10.0;
options->antialias = TRUE;
options->dash_offset = 0.0;
options->dash_info = NULL;
}
static void
gimp_stroke_options_set_property (GObject *object,
guint property_id,
@ -184,6 +164,9 @@ gimp_stroke_options_set_property (GObject *object,
case PROP_WIDTH:
options->width = g_value_get_double (value);
break;
case PROP_WIDTH_UNIT:
options->width_unit = g_value_get_int (value);
break;
case PROP_CAP_STYLE:
options->cap_style = g_value_get_enum (value);
break;
@ -196,6 +179,9 @@ gimp_stroke_options_set_property (GObject *object,
case PROP_ANTIALIAS:
options->antialias = g_value_get_boolean (value);
break;
case PROP_DASH_UNIT:
options->dash_unit = g_value_get_int (value);
break;
case PROP_DASH_OFFSET:
options->dash_offset = g_value_get_double (value);
break;
@ -252,6 +238,9 @@ gimp_stroke_options_get_property (GObject *object,
case PROP_WIDTH:
g_value_set_double (value, options->width);
break;
case PROP_WIDTH_UNIT:
g_value_set_int (value, options->width_unit);
break;
case PROP_CAP_STYLE:
g_value_set_enum (value, options->cap_style);
break;
@ -264,6 +253,9 @@ gimp_stroke_options_get_property (GObject *object,
case PROP_ANTIALIAS:
g_value_set_boolean (value, options->antialias);
break;
case PROP_DASH_UNIT:
g_value_set_int (value, options->dash_unit);
break;
case PROP_DASH_OFFSET:
g_value_set_double (value, options->dash_offset);
break;

View File

@ -41,6 +41,7 @@ struct _GimpStrokeOptions
GimpContext parent_instance;
gdouble width;
GimpUnit width_unit;
GimpCapStyle cap_style;
GimpJoinStyle join_style;
@ -49,6 +50,7 @@ struct _GimpStrokeOptions
gboolean antialias;
GimpUnit dash_unit;
gdouble dash_offset;
GArray *dash_info;
};

View File

@ -34,6 +34,7 @@
#include "core/gimpmarshal.h"
#include "core/gimppaintinfo.h"
#include "core/gimpstrokeoptions.h"
#include "core/gimpunit.h"
#include "libgimpcolor/gimpcolor.h"
#include "paint/gimppaintcore-stroke.h"
@ -558,50 +559,41 @@ gimp_vectors_stroke (GimpItem *item,
if (GIMP_IS_STROKE_OPTIONS (stroke_desc))
{
GimpContext *context;
GimpRGB color;
gdouble width;
gboolean antialias;
GimpCapStyle cap_style;
GimpJoinStyle join_style;
GValue value = { 0, };
GimpContext *context;
GimpRGB color;
gdouble width;
stroke_options = GIMP_STROKE_OPTIONS (stroke_desc);
context = GIMP_CONTEXT (stroke_options);
gimp_context_get_foreground (context, &color);
g_value_init (&value, G_TYPE_DOUBLE);
g_object_get_property (G_OBJECT (stroke_options), "width", &value);
width = g_value_get_double (&value);
g_value_unset (&value);
width = stroke_options->width;
g_value_init (&value, GIMP_TYPE_CAP_STYLE);
g_object_get_property (G_OBJECT (stroke_options), "cap-style", &value);
cap_style = g_value_get_enum (&value);
g_value_unset (&value);
if (stroke_options->width_unit != GIMP_UNIT_PIXEL)
{
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
g_value_init (&value, GIMP_TYPE_JOIN_STYLE);
g_object_get_property (G_OBJECT (stroke_options), "join-style", &value);
join_style = g_value_get_enum (&value);
g_value_unset (&value);
g_value_init (&value, G_TYPE_BOOLEAN);
g_object_get_property (G_OBJECT (stroke_options), "antialias", &value);
antialias = g_value_get_boolean (&value);
g_value_unset (&value);
width = (width *
_gimp_unit_get_factor (gimage->gimp,
stroke_options->width_unit) *
(gimage->xresolution + gimage->yresolution) / 2);
}
gimp_drawable_stroke_vectors (drawable, vectors,
gimp_context_get_opacity (context),
&color,
gimp_context_get_paint_mode (context),
width, join_style, cap_style, antialias);
width,
stroke_options->join_style,
stroke_options->cap_style,
stroke_options->antialias);
retval = TRUE;
}
else
{
GimpPaintCore *core;
paint_info = GIMP_PAINT_INFO (stroke_desc);
core = g_object_new (paint_info->paint_type, NULL);

View File

@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
@ -108,7 +109,9 @@ gimp_stroke_editor_new (GimpStrokeOptions *options)
GimpStrokeEditor *editor;
GtkWidget *table;
GtkWidget *menu;
GtkWidget *spinbutton;
GtkWidget *button;
gint digits;
gint row = 0;
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL);
@ -124,33 +127,41 @@ gimp_stroke_editor_new (GimpStrokeOptions *options)
gtk_box_pack_start (GTK_BOX (editor), table, FALSE, FALSE, 0);
gtk_widget_show (table);
gimp_prop_scale_entry_new (G_OBJECT (options), "width",
GTK_TABLE (table), 0, row++,
_("Stroke Width:"),
1.0, 1.0, 1,
FALSE, 0.0, 0.0);
digits = gimp_unit_get_digits (options->width_unit);
spinbutton = gimp_prop_spin_button_new (G_OBJECT (options), "width",
1.0, 10.0, digits);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row,
_("Stroke _Width:"), 1.0, 0.5,
spinbutton, 1, FALSE);
menu = gimp_prop_unit_menu_new (G_OBJECT (options), "width-unit", "%a");
g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (menu);
row++;
menu = gimp_prop_enum_option_menu_new (G_OBJECT (options), "cap-style",
0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Cap Style:"), 1.0, 0.5,
_("_Cap Style:"), 1.0, 0.5,
menu, 2, TRUE);
menu = gimp_prop_enum_option_menu_new (G_OBJECT (options), "join-style",
0, 0);
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Join Style:"), 1.0, 0.5,
_("_Join Style:"), 1.0, 0.5,
menu, 2, TRUE);
gimp_prop_scale_entry_new (G_OBJECT (options), "miter",
GTK_TABLE (table), 0, row++,
_("Miter:"),
_("_Miter Limit:"),
1.0, 1.0, 1,
FALSE, 0.0, 0.0);
button = gimp_prop_check_button_new (G_OBJECT (options), "antialias",
_("Antialiasing"));
gtk_table_attach (GTK_TABLE (table), button, 1, 3, row, row + 1,
gtk_table_attach (GTK_TABLE (table), button, 0, 2, row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (button);
row++;

View File

@ -1,3 +1,7 @@
2003-09-27 Sven Neumann <sven@gimp.org>
* POTFILES.in: added new files.
2003-09-27 Danilo Šegan <dsegan@gmx.net>
* sr.po, sr@Latn.po: Updated Serbian translation.

View File

@ -138,6 +138,7 @@ app/gui/resolution-calibrate-dialog.c
app/gui/select-commands.c
app/gui/session.c
app/gui/splash.c
app/gui/stroke-dialog.c
app/gui/templates-commands.c
app/gui/templates-menu.c
app/gui/themes.c
@ -280,6 +281,7 @@ app/widgets/gimplayertreeview.c
app/widgets/gimppaletteeditor.c
app/widgets/gimppropwidgets.c
app/widgets/gimpselectioneditor.c
app/widgets/gimpstrokeeditor.c
app/widgets/gimptemplateeditor.c
app/widgets/gimptemplateview.c
app/widgets/gimptexteditor.c