mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
Bill Skaggs <weskaggs@primate.ucdavis.edu>
Here is the big change-over, finally. * app/tools/gimprectselecttool.[ch]: removed. * app/tools/Makefile.am * app/tools/gimp-tools.c * app/tools/gimpellipseselecttool.c * app/tools/gimpellipseselecttool.h * app/tools/gimpnewrectselectoptions.c * app/tools/gimpnewrectselectoptions.h * app/tools/gimpnewrectselecttool.c * app/tools/gimpnewrectselecttool.h * app/tools/gimpselectionoptions.c * app/widgets/gimptoolbox.c * menus/image-menu.xml.in: get rid of the "new" in everything referring to the new rect select tool, except filenames. This will wait for yosh to perform cvs-magic-foo. * app/tools/gimprectangleoptions.[ch] * app/tools/gimprectangletool.[ch]: fix a couple of minor problems that popped up during testing.
This commit is contained in:
parent
10c8c709d3
commit
36ee184375
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2006-06-10 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
Here is the big change-over, finally.
|
||||
|
||||
* app/tools/gimprectselecttool.[ch]: removed.
|
||||
|
||||
* app/tools/Makefile.am
|
||||
* app/tools/gimp-tools.c
|
||||
* app/tools/gimpellipseselecttool.c
|
||||
* app/tools/gimpellipseselecttool.h
|
||||
* app/tools/gimpnewrectselectoptions.c
|
||||
* app/tools/gimpnewrectselectoptions.h
|
||||
* app/tools/gimpnewrectselecttool.c
|
||||
* app/tools/gimpnewrectselecttool.h
|
||||
* app/tools/gimpselectionoptions.c
|
||||
* app/widgets/gimptoolbox.c
|
||||
* menus/image-menu.xml.in: get rid of the "new" in everything
|
||||
referring to the new rect select tool, except filenames. This
|
||||
will wait for yosh to perform cvs-magic-foo.
|
||||
|
||||
* app/tools/gimprectangleoptions.[ch]
|
||||
* app/tools/gimprectangletool.[ch]: fix a couple of minor
|
||||
problems that popped up during testing.
|
||||
|
||||
2006-06-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpeditor.c (gimp_editor_add_action_button): simply
|
||||
|
|
|
@ -124,8 +124,6 @@ libapptools_a_sources = \
|
|||
gimprectangletool.h \
|
||||
gimprectangleoptions.c \
|
||||
gimprectangleoptions.h \
|
||||
gimprectselecttool.c \
|
||||
gimprectselecttool.h \
|
||||
gimprotatetool.c \
|
||||
gimprotatetool.h \
|
||||
gimpscaletool.c \
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
#include "gimppenciltool.h"
|
||||
#include "gimpperspectivetool.h"
|
||||
#include "gimpposterizetool.h"
|
||||
#include "gimprectselecttool.h"
|
||||
#include "gimpnewrectselecttool.h"
|
||||
#include "gimpthresholdtool.h"
|
||||
#include "gimprotatetool.h"
|
||||
|
@ -171,8 +170,7 @@ gimp_tools_init (Gimp *gimp)
|
|||
gimp_fuzzy_select_tool_register,
|
||||
gimp_free_select_tool_register,
|
||||
gimp_ellipse_select_tool_register,
|
||||
gimp_rect_select_tool_register,
|
||||
gimp_new_rect_select_tool_register
|
||||
gimp_rect_select_tool_register
|
||||
};
|
||||
|
||||
GList *default_order = NULL;
|
||||
|
@ -542,8 +540,7 @@ gimp_tools_register (GType tool_type,
|
|||
paint_core_name,
|
||||
stock_id);
|
||||
|
||||
visible = (! g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL) &&
|
||||
! g_type_is_a (tool_type, GIMP_TYPE_RECT_SELECT_TOOL));
|
||||
visible = (! g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL));
|
||||
|
||||
g_object_set (tool_info, "visible", visible, NULL);
|
||||
g_object_set_data (G_OBJECT (tool_info), "gimp-tool-default-visible",
|
||||
|
|
|
@ -45,16 +45,16 @@
|
|||
|
||||
static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_ellipse_select_tool_select (GimpNewRectSelectTool *rect_tool,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static void gimp_ellipse_select_tool_select (GimpRectSelectTool *rect_tool,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpEllipseSelectTool, gimp_ellipse_select_tool,
|
||||
GIMP_TYPE_NEW_RECT_SELECT_TOOL)
|
||||
GIMP_TYPE_RECT_SELECT_TOOL)
|
||||
|
||||
#define parent_class gimp_ellipse_select_tool_parent_class
|
||||
|
||||
|
@ -66,8 +66,8 @@ gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_ELLIPSE_SELECT_TOOL,
|
||||
GIMP_TYPE_NEW_RECT_SELECT_OPTIONS,
|
||||
gimp_new_rect_select_options_gui,
|
||||
GIMP_TYPE_RECT_SELECT_OPTIONS,
|
||||
gimp_rect_select_options_gui,
|
||||
0,
|
||||
"gimp-ellipse-select-tool",
|
||||
_("Ellipse Select"),
|
||||
|
@ -84,11 +84,11 @@ gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback,
|
|||
static void
|
||||
gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass)
|
||||
{
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GimpNewRectSelectToolClass *rect_tool_class;
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GimpRectSelectToolClass *rect_tool_class;
|
||||
|
||||
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
rect_tool_class = GIMP_NEW_RECT_SELECT_TOOL_CLASS (klass);
|
||||
rect_tool_class = GIMP_RECT_SELECT_TOOL_CLASS (klass);
|
||||
|
||||
draw_tool_class->draw = gimp_ellipse_select_tool_draw;
|
||||
|
||||
|
@ -109,7 +109,7 @@ gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select)
|
|||
static void
|
||||
gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_sel = GIMP_NEW_RECT_SELECT_TOOL (draw_tool);
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
|
@ -129,12 +129,12 @@ gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_ellipse_select_tool_select (GimpNewRectSelectTool *rect_tool,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_ellipse_select_tool_select (GimpRectSelectTool *rect_tool,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpSelectionOptions *options;
|
||||
|
|
|
@ -36,12 +36,12 @@ typedef struct _GimpEllipseSelectToolClass GimpEllipseSelectToolClass;
|
|||
|
||||
struct _GimpEllipseSelectTool
|
||||
{
|
||||
GimpNewRectSelectTool parent_instance;
|
||||
GimpRectSelectTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpEllipseSelectToolClass
|
||||
{
|
||||
GimpNewRectSelectToolClass parent_class;
|
||||
GimpRectSelectToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -35,17 +35,17 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_new_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface);
|
||||
static void gimp_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectOptions, gimp_new_rect_select_options,
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectOptions, gimp_rect_select_options,
|
||||
GIMP_TYPE_SELECTION_OPTIONS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_OPTIONS,
|
||||
gimp_new_rect_select_options_rectangle_options_iface_init))
|
||||
gimp_rect_select_options_rectangle_options_iface_init))
|
||||
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_class_init (GimpNewRectSelectOptionsClass *klass)
|
||||
gimp_rect_select_options_class_init (GimpRectSelectOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
|
@ -56,17 +56,17 @@ gimp_new_rect_select_options_class_init (GimpNewRectSelectOptionsClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_init (GimpNewRectSelectOptions *options)
|
||||
gimp_rect_select_options_init (GimpRectSelectOptions *options)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface)
|
||||
gimp_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_new_rect_select_options_gui (GimpToolOptions *tool_options)
|
||||
gimp_rect_select_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox_rectangle;
|
||||
|
|
|
@ -16,33 +16,33 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NEW_RECT_SELECT_OPTIONS_H__
|
||||
#define __GIMP_NEW_RECT_SELECT_OPTIONS_H__
|
||||
#ifndef __GIMP_RECT_SELECT_OPTIONS_H__
|
||||
#define __GIMP_RECT_SELECT_OPTIONS_H__
|
||||
|
||||
|
||||
#include "gimpselectionoptions.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_NEW_RECT_SELECT_OPTIONS (gimp_new_rect_select_options_get_type ())
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptions))
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
|
||||
#define GIMP_TYPE_RECT_SELECT_OPTIONS (gimp_rect_select_options_get_type ())
|
||||
#define GIMP_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptions))
|
||||
#define GIMP_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptionsClass))
|
||||
#define GIMP_IS_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_IS_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_RECT_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptionsClass))
|
||||
|
||||
|
||||
typedef struct _GimpNewRectSelectOptions GimpNewRectSelectOptions;
|
||||
typedef struct _GimpToolOptionsClass GimpNewRectSelectOptionsClass;
|
||||
typedef struct _GimpRectSelectOptions GimpRectSelectOptions;
|
||||
typedef struct _GimpToolOptionsClass GimpRectSelectOptionsClass;
|
||||
|
||||
struct _GimpNewRectSelectOptions
|
||||
struct _GimpRectSelectOptions
|
||||
{
|
||||
GimpSelectionOptions parent_instence;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_new_rect_select_options_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_rect_select_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_new_rect_select_options_gui (GimpToolOptions *tool_options);
|
||||
GtkWidget * gimp_rect_select_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
|
||||
#endif /* __GIMP_NEW_RECT_SELECT_OPTIONS_H__ */
|
||||
#endif /* __GIMP_RECT_SELECT_OPTIONS_H__ */
|
||||
|
|
|
@ -58,117 +58,116 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_new_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface);
|
||||
static void gimp_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface);
|
||||
|
||||
static GObject *
|
||||
gimp_new_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_new_rect_select_tool_finalize (GObject *object);
|
||||
static void gimp_new_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_select (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static gboolean gimp_new_rect_select_tool_execute (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static void gimp_new_rect_select_tool_cancel (GimpRectangleTool *rect_tool);
|
||||
static gboolean gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rect_tool);
|
||||
static void gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static GObject *gimp_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_rect_select_tool_finalize (GObject *object);
|
||||
static void gimp_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_select (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static gboolean gimp_rect_select_tool_execute (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static void gimp_rect_select_tool_cancel (GimpRectangleTool *rect_tool);
|
||||
static gboolean gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rect_tool);
|
||||
static void gimp_rect_select_tool_real_select (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectTool, gimp_new_rect_select_tool,
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectTool, gimp_rect_select_tool,
|
||||
GIMP_TYPE_SELECTION_TOOL,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_TOOL,
|
||||
gimp_new_rect_select_tool_rectangle_tool_iface_init))
|
||||
gimp_rect_select_tool_rectangle_tool_iface_init))
|
||||
|
||||
#define parent_class gimp_new_rect_select_tool_parent_class
|
||||
#define parent_class gimp_rect_select_tool_parent_class
|
||||
|
||||
|
||||
void
|
||||
gimp_new_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_NEW_RECT_SELECT_TOOL,
|
||||
GIMP_TYPE_NEW_RECT_SELECT_OPTIONS,
|
||||
gimp_new_rect_select_options_gui,
|
||||
(* callback) (GIMP_TYPE_RECT_SELECT_TOOL,
|
||||
GIMP_TYPE_RECT_SELECT_OPTIONS,
|
||||
gimp_rect_select_options_gui,
|
||||
0,
|
||||
"gimp-new-rect-select-tool",
|
||||
_("New Rect Select"),
|
||||
"gimp-rect-select-tool",
|
||||
_("Rect Select"),
|
||||
_("Select a Rectangular part of an image"),
|
||||
N_("_New Rect Select"), "R",
|
||||
N_("_Rect Select"), "R",
|
||||
NULL, GIMP_HELP_TOOL_RECT_SELECT,
|
||||
GIMP_STOCK_TOOL_RECT_SELECT,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass)
|
||||
gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_new_rect_select_tool_constructor;
|
||||
object_class->constructor = gimp_rect_select_tool_constructor;
|
||||
object_class->dispose = gimp_rectangle_tool_dispose;
|
||||
object_class->finalize = gimp_new_rect_select_tool_finalize;
|
||||
object_class->finalize = gimp_rect_select_tool_finalize;
|
||||
object_class->set_property = gimp_rectangle_tool_set_property;
|
||||
object_class->get_property = gimp_rectangle_tool_get_property;
|
||||
|
||||
gimp_rectangle_tool_install_properties (object_class);
|
||||
|
||||
tool_class->initialize = gimp_rectangle_tool_initialize;
|
||||
tool_class->control = gimp_new_rect_select_tool_control;
|
||||
tool_class->button_press = gimp_new_rect_select_tool_button_press;
|
||||
tool_class->button_release = gimp_new_rect_select_tool_button_release;
|
||||
tool_class->control = gimp_rect_select_tool_control;
|
||||
tool_class->button_press = gimp_rect_select_tool_button_press;
|
||||
tool_class->button_release = gimp_rect_select_tool_button_release;
|
||||
tool_class->motion = gimp_rectangle_tool_motion;
|
||||
tool_class->key_press = gimp_rectangle_tool_key_press;
|
||||
tool_class->modifier_key = gimp_new_rect_select_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_new_rect_select_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_new_rect_select_tool_cursor_update;
|
||||
tool_class->modifier_key = gimp_rect_select_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_rect_select_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_rect_select_tool_cursor_update;
|
||||
|
||||
draw_tool_class->draw = gimp_rectangle_tool_draw;
|
||||
|
||||
klass->select = gimp_new_rect_select_tool_real_select;
|
||||
klass->select = gimp_rect_select_tool_real_select;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_init (GimpNewRectSelectTool *rect_select)
|
||||
gimp_rect_select_tool_init (GimpRectSelectTool *rect_select)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_select);
|
||||
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (rect_select);
|
||||
|
@ -181,17 +180,17 @@ gimp_new_rect_select_tool_init (GimpNewRectSelectTool *rect_select)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface)
|
||||
gimp_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface)
|
||||
{
|
||||
iface->execute = gimp_new_rect_select_tool_execute;
|
||||
iface->cancel = gimp_new_rect_select_tool_cancel;
|
||||
iface->rectangle_changed = gimp_new_rect_select_tool_rectangle_changed;
|
||||
iface->execute = gimp_rect_select_tool_execute;
|
||||
iface->cancel = gimp_rect_select_tool_cancel;
|
||||
iface->rectangle_changed = gimp_rect_select_tool_rectangle_changed;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_new_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
gimp_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
|
||||
|
@ -203,15 +202,15 @@ gimp_new_rect_select_tool_constructor (GType type,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_finalize (GObject *object)
|
||||
gimp_rect_select_tool_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
gimp_rectangle_tool_control (tool, action, display);
|
||||
|
||||
|
@ -219,14 +218,14 @@ gimp_new_rect_select_tool_control (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
||||
gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
guint function;
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
guint function;
|
||||
|
||||
if (tool->display && display != tool->display)
|
||||
gimp_rectangle_tool_cancel (GIMP_RECTANGLE_TOOL (tool));
|
||||
|
@ -276,7 +275,7 @@ gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
|||
{
|
||||
gimp_image_undo (image);
|
||||
|
||||
/* we will need to redo if the user cancels */
|
||||
/* we will need to redo if the user cancels or executes */
|
||||
rect_select->redo = gimp_undo_stack_peek (image->redo_stack);
|
||||
}
|
||||
}
|
||||
|
@ -285,16 +284,35 @@ gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
||||
|
||||
gimp_tool_pop_status (tool, display);
|
||||
|
||||
/*
|
||||
* if the user has not moved the mouse, we need to redo the operation
|
||||
* that was undone on button press.
|
||||
*/
|
||||
if (gimp_rectangle_tool_no_movement (rectangle))
|
||||
{
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *redo;
|
||||
|
||||
redo = gimp_undo_stack_peek (image->redo_stack);
|
||||
|
||||
if (redo && rect_select->redo == redo)
|
||||
{
|
||||
gimp_image_redo (image);
|
||||
rect_select->redo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_rectangle_tool_button_release (tool, coords, time, state, display);
|
||||
|
||||
if ((state & GDK_BUTTON3_MASK))
|
||||
|
@ -311,22 +329,22 @@ gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
|
||||
display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
guint function;
|
||||
|
||||
|
@ -344,10 +362,10 @@ gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
gimp_rectangle_tool_cursor_update (tool, coords, state, display);
|
||||
|
||||
|
@ -369,19 +387,19 @@ gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
|||
* we clear the selection.
|
||||
*/
|
||||
static void
|
||||
gimp_new_rect_select_tool_select (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_select (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image;
|
||||
gboolean rectangle_exists;
|
||||
gboolean auto_shrink;
|
||||
SelectOps operation;
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image;
|
||||
gboolean rectangle_exists;
|
||||
gboolean auto_shrink;
|
||||
SelectOps operation;
|
||||
|
||||
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
|
@ -411,18 +429,18 @@ gimp_new_rect_select_tool_select (GimpRectangleTool *rectangle,
|
|||
|
||||
/* if rectangle exists, turn it into a selection */
|
||||
if (rectangle_exists)
|
||||
GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS (rect_select)->select (rect_select,
|
||||
GIMP_RECT_SELECT_TOOL_GET_CLASS (rect_select)->select (rect_select,
|
||||
operation,
|
||||
x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_real_select (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_select);
|
||||
GimpSelectionOptions *options;
|
||||
|
@ -438,17 +456,12 @@ gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
|
||||
/* don't keep the undo step across separate rectangles */
|
||||
rect_select->undo = NULL;
|
||||
|
||||
if (w == 0 && h == 0)
|
||||
{
|
||||
GimpImage *image = GIMP_TOOL (rectangle)->display->image;
|
||||
|
@ -530,10 +543,10 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
||||
gimp_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
|
||||
if (tool->display)
|
||||
{
|
||||
|
@ -558,17 +571,17 @@ gimp_new_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
||||
gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
|
||||
if (tool->display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *undo;
|
||||
gint x1, y1, x2, y2;
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *undo;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
/* if we got here via button release, we have already undone the
|
||||
* previous operation. But if we got here by some other means,
|
||||
|
@ -589,7 +602,7 @@ gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
|||
"y2", &y2,
|
||||
NULL);
|
||||
|
||||
gimp_new_rect_select_tool_select (rectangle, x1, y1, x2 - x1, y2 - y1);
|
||||
gimp_rect_select_tool_select (rectangle, x1, y1, x2 - x1, y2 - y1);
|
||||
|
||||
/* save the undo that we got when executing */
|
||||
rect_select->undo = gimp_undo_stack_peek (image->undo_stack);
|
||||
|
|
|
@ -16,24 +16,24 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NEW_RECT_SELECT_TOOL_H__
|
||||
#define __GIMP_NEW_RECT_SELECT_TOOL_H__
|
||||
#ifndef __GIMP_RECT_SELECT_TOOL_H__
|
||||
#define __GIMP_RECT_SELECT_TOOL_H__
|
||||
|
||||
#include "gimpselectiontool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_NEW_RECT_SELECT_TOOL (gimp_new_rect_select_tool_get_type ())
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectTool))
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
|
||||
#define GIMP_TYPE_RECT_SELECT_TOOL (gimp_rect_select_tool_get_type ())
|
||||
#define GIMP_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectTool))
|
||||
#define GIMP_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
|
||||
|
||||
typedef struct _GimpNewRectSelectTool GimpNewRectSelectTool;
|
||||
typedef struct _GimpNewRectSelectToolClass GimpNewRectSelectToolClass;
|
||||
typedef struct _GimpRectSelectTool GimpRectSelectTool;
|
||||
typedef struct _GimpRectSelectToolClass GimpRectSelectToolClass;
|
||||
|
||||
struct _GimpNewRectSelectTool
|
||||
struct _GimpRectSelectTool
|
||||
{
|
||||
GimpSelectionTool parent_instance;
|
||||
|
||||
|
@ -43,23 +43,23 @@ struct _GimpNewRectSelectTool
|
|||
GimpUndo *redo;
|
||||
};
|
||||
|
||||
struct _GimpNewRectSelectToolClass
|
||||
struct _GimpRectSelectToolClass
|
||||
{
|
||||
GimpSelectionToolClass parent_class;
|
||||
|
||||
void (* select) (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void (* select) (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
};
|
||||
|
||||
|
||||
void gimp_new_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
void gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data);
|
||||
|
||||
GType gimp_new_rect_select_tool_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_rect_select_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_NEW_RECT_SELECT_TOOL_H__ */
|
||||
#endif /* __GIMP_RECT_SELECT_TOOL_H__ */
|
||||
|
|
|
@ -67,8 +67,6 @@ static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInte
|
|||
static GimpRectangleOptionsPrivate *
|
||||
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
|
||||
|
||||
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);
|
||||
|
|
|
@ -73,6 +73,7 @@ void gimp_rectangle_options_get_property (GObject *object,
|
|||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
void gimp_rectangle_options_set_highlight (GimpRectangleOptions *options,
|
||||
gboolean highlight);
|
||||
|
||||
#endif /* __GIMP_RECTANGLE_OPTIONS_H__ */
|
||||
|
|
|
@ -35,17 +35,17 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_new_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface);
|
||||
static void gimp_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectOptions, gimp_new_rect_select_options,
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectOptions, gimp_rect_select_options,
|
||||
GIMP_TYPE_SELECTION_OPTIONS,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_OPTIONS,
|
||||
gimp_new_rect_select_options_rectangle_options_iface_init))
|
||||
gimp_rect_select_options_rectangle_options_iface_init))
|
||||
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_class_init (GimpNewRectSelectOptionsClass *klass)
|
||||
gimp_rect_select_options_class_init (GimpRectSelectOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
|
@ -56,17 +56,17 @@ gimp_new_rect_select_options_class_init (GimpNewRectSelectOptionsClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_init (GimpNewRectSelectOptions *options)
|
||||
gimp_rect_select_options_init (GimpRectSelectOptions *options)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface)
|
||||
gimp_rect_select_options_rectangle_options_iface_init (GimpRectangleOptionsInterface *iface)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_new_rect_select_options_gui (GimpToolOptions *tool_options)
|
||||
gimp_rect_select_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox_rectangle;
|
||||
|
|
|
@ -16,33 +16,33 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NEW_RECT_SELECT_OPTIONS_H__
|
||||
#define __GIMP_NEW_RECT_SELECT_OPTIONS_H__
|
||||
#ifndef __GIMP_RECT_SELECT_OPTIONS_H__
|
||||
#define __GIMP_RECT_SELECT_OPTIONS_H__
|
||||
|
||||
|
||||
#include "gimpselectionoptions.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_NEW_RECT_SELECT_OPTIONS (gimp_new_rect_select_options_get_type ())
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptions))
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_NEW_RECT_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_OPTIONS, GimpNewRectSelectOptionsClass))
|
||||
#define GIMP_TYPE_RECT_SELECT_OPTIONS (gimp_rect_select_options_get_type ())
|
||||
#define GIMP_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptions))
|
||||
#define GIMP_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptionsClass))
|
||||
#define GIMP_IS_RECT_SELECT_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_IS_RECT_SELECT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RECT_SELECT_OPTIONS))
|
||||
#define GIMP_RECT_SELECT_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RECT_SELECT_OPTIONS, GimpRectSelectOptionsClass))
|
||||
|
||||
|
||||
typedef struct _GimpNewRectSelectOptions GimpNewRectSelectOptions;
|
||||
typedef struct _GimpToolOptionsClass GimpNewRectSelectOptionsClass;
|
||||
typedef struct _GimpRectSelectOptions GimpRectSelectOptions;
|
||||
typedef struct _GimpToolOptionsClass GimpRectSelectOptionsClass;
|
||||
|
||||
struct _GimpNewRectSelectOptions
|
||||
struct _GimpRectSelectOptions
|
||||
{
|
||||
GimpSelectionOptions parent_instence;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_new_rect_select_options_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_rect_select_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_new_rect_select_options_gui (GimpToolOptions *tool_options);
|
||||
GtkWidget * gimp_rect_select_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
|
||||
#endif /* __GIMP_NEW_RECT_SELECT_OPTIONS_H__ */
|
||||
#endif /* __GIMP_RECT_SELECT_OPTIONS_H__ */
|
||||
|
|
|
@ -58,117 +58,116 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_new_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface);
|
||||
static void gimp_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface);
|
||||
|
||||
static GObject *
|
||||
gimp_new_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_new_rect_select_tool_finalize (GObject *object);
|
||||
static void gimp_new_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_new_rect_select_tool_select (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static gboolean gimp_new_rect_select_tool_execute (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static void gimp_new_rect_select_tool_cancel (GimpRectangleTool *rect_tool);
|
||||
static gboolean gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rect_tool);
|
||||
static void gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static GObject *gimp_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_rect_select_tool_finalize (GObject *object);
|
||||
static void gimp_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_select (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static gboolean gimp_rect_select_tool_execute (GimpRectangleTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
static void gimp_rect_select_tool_cancel (GimpRectangleTool *rect_tool);
|
||||
static gboolean gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rect_tool);
|
||||
static void gimp_rect_select_tool_real_select (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpNewRectSelectTool, gimp_new_rect_select_tool,
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectTool, gimp_rect_select_tool,
|
||||
GIMP_TYPE_SELECTION_TOOL,
|
||||
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_TOOL,
|
||||
gimp_new_rect_select_tool_rectangle_tool_iface_init))
|
||||
gimp_rect_select_tool_rectangle_tool_iface_init))
|
||||
|
||||
#define parent_class gimp_new_rect_select_tool_parent_class
|
||||
#define parent_class gimp_rect_select_tool_parent_class
|
||||
|
||||
|
||||
void
|
||||
gimp_new_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_NEW_RECT_SELECT_TOOL,
|
||||
GIMP_TYPE_NEW_RECT_SELECT_OPTIONS,
|
||||
gimp_new_rect_select_options_gui,
|
||||
(* callback) (GIMP_TYPE_RECT_SELECT_TOOL,
|
||||
GIMP_TYPE_RECT_SELECT_OPTIONS,
|
||||
gimp_rect_select_options_gui,
|
||||
0,
|
||||
"gimp-new-rect-select-tool",
|
||||
_("New Rect Select"),
|
||||
"gimp-rect-select-tool",
|
||||
_("Rect Select"),
|
||||
_("Select a Rectangular part of an image"),
|
||||
N_("_New Rect Select"), "R",
|
||||
N_("_Rect Select"), "R",
|
||||
NULL, GIMP_HELP_TOOL_RECT_SELECT,
|
||||
GIMP_STOCK_TOOL_RECT_SELECT,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_class_init (GimpNewRectSelectToolClass *klass)
|
||||
gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_new_rect_select_tool_constructor;
|
||||
object_class->constructor = gimp_rect_select_tool_constructor;
|
||||
object_class->dispose = gimp_rectangle_tool_dispose;
|
||||
object_class->finalize = gimp_new_rect_select_tool_finalize;
|
||||
object_class->finalize = gimp_rect_select_tool_finalize;
|
||||
object_class->set_property = gimp_rectangle_tool_set_property;
|
||||
object_class->get_property = gimp_rectangle_tool_get_property;
|
||||
|
||||
gimp_rectangle_tool_install_properties (object_class);
|
||||
|
||||
tool_class->initialize = gimp_rectangle_tool_initialize;
|
||||
tool_class->control = gimp_new_rect_select_tool_control;
|
||||
tool_class->button_press = gimp_new_rect_select_tool_button_press;
|
||||
tool_class->button_release = gimp_new_rect_select_tool_button_release;
|
||||
tool_class->control = gimp_rect_select_tool_control;
|
||||
tool_class->button_press = gimp_rect_select_tool_button_press;
|
||||
tool_class->button_release = gimp_rect_select_tool_button_release;
|
||||
tool_class->motion = gimp_rectangle_tool_motion;
|
||||
tool_class->key_press = gimp_rectangle_tool_key_press;
|
||||
tool_class->modifier_key = gimp_new_rect_select_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_new_rect_select_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_new_rect_select_tool_cursor_update;
|
||||
tool_class->modifier_key = gimp_rect_select_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_rect_select_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_rect_select_tool_cursor_update;
|
||||
|
||||
draw_tool_class->draw = gimp_rectangle_tool_draw;
|
||||
|
||||
klass->select = gimp_new_rect_select_tool_real_select;
|
||||
klass->select = gimp_rect_select_tool_real_select;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_init (GimpNewRectSelectTool *rect_select)
|
||||
gimp_rect_select_tool_init (GimpRectSelectTool *rect_select)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_select);
|
||||
GimpRectangleTool *rect_tool = GIMP_RECTANGLE_TOOL (rect_select);
|
||||
|
@ -181,17 +180,17 @@ gimp_new_rect_select_tool_init (GimpNewRectSelectTool *rect_select)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface)
|
||||
gimp_rect_select_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface)
|
||||
{
|
||||
iface->execute = gimp_new_rect_select_tool_execute;
|
||||
iface->cancel = gimp_new_rect_select_tool_cancel;
|
||||
iface->rectangle_changed = gimp_new_rect_select_tool_rectangle_changed;
|
||||
iface->execute = gimp_rect_select_tool_execute;
|
||||
iface->cancel = gimp_rect_select_tool_cancel;
|
||||
iface->rectangle_changed = gimp_rect_select_tool_rectangle_changed;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_new_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
gimp_rect_select_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
|
||||
|
@ -203,15 +202,15 @@ gimp_new_rect_select_tool_constructor (GType type,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_finalize (GObject *object)
|
||||
gimp_rect_select_tool_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
gimp_rectangle_tool_control (tool, action, display);
|
||||
|
||||
|
@ -219,14 +218,14 @@ gimp_new_rect_select_tool_control (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
||||
gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
guint function;
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
guint function;
|
||||
|
||||
if (tool->display && display != tool->display)
|
||||
gimp_rectangle_tool_cancel (GIMP_RECTANGLE_TOOL (tool));
|
||||
|
@ -276,7 +275,7 @@ gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
|||
{
|
||||
gimp_image_undo (image);
|
||||
|
||||
/* we will need to redo if the user cancels */
|
||||
/* we will need to redo if the user cancels or executes */
|
||||
rect_select->redo = gimp_undo_stack_peek (image->redo_stack);
|
||||
}
|
||||
}
|
||||
|
@ -285,16 +284,35 @@ gimp_new_rect_select_tool_button_press (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
||||
|
||||
gimp_tool_pop_status (tool, display);
|
||||
|
||||
/*
|
||||
* if the user has not moved the mouse, we need to redo the operation
|
||||
* that was undone on button press.
|
||||
*/
|
||||
if (gimp_rectangle_tool_no_movement (rectangle))
|
||||
{
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *redo;
|
||||
|
||||
redo = gimp_undo_stack_peek (image->redo_stack);
|
||||
|
||||
if (redo && rect_select->redo == redo)
|
||||
{
|
||||
gimp_image_redo (image);
|
||||
rect_select->redo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_rectangle_tool_button_release (tool, coords, time, state, display);
|
||||
|
||||
if ((state & GDK_BUTTON3_MASK))
|
||||
|
@ -311,22 +329,22 @@ gimp_new_rect_select_tool_button_release (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
|
||||
display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
gboolean proximity,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
guint function;
|
||||
|
||||
|
@ -344,10 +362,10 @@ gimp_new_rect_select_tool_oper_update (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
gimp_rect_select_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
gimp_rectangle_tool_cursor_update (tool, coords, state, display);
|
||||
|
||||
|
@ -369,19 +387,19 @@ gimp_new_rect_select_tool_cursor_update (GimpTool *tool,
|
|||
* we clear the selection.
|
||||
*/
|
||||
static void
|
||||
gimp_new_rect_select_tool_select (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_select (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image;
|
||||
gboolean rectangle_exists;
|
||||
gboolean auto_shrink;
|
||||
SelectOps operation;
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image;
|
||||
gboolean rectangle_exists;
|
||||
gboolean auto_shrink;
|
||||
SelectOps operation;
|
||||
|
||||
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
|
@ -411,18 +429,18 @@ gimp_new_rect_select_tool_select (GimpRectangleTool *rectangle,
|
|||
|
||||
/* if rectangle exists, turn it into a selection */
|
||||
if (rectangle_exists)
|
||||
GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS (rect_select)->select (rect_select,
|
||||
GIMP_RECT_SELECT_TOOL_GET_CLASS (rect_select)->select (rect_select,
|
||||
operation,
|
||||
x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_real_select (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_select);
|
||||
GimpSelectionOptions *options;
|
||||
|
@ -438,17 +456,12 @@ gimp_new_rect_select_tool_real_select (GimpNewRectSelectTool *rect_select,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
gimp_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
|
||||
/* don't keep the undo step across separate rectangles */
|
||||
rect_select->undo = NULL;
|
||||
|
||||
if (w == 0 && h == 0)
|
||||
{
|
||||
GimpImage *image = GIMP_TOOL (rectangle)->display->image;
|
||||
|
@ -530,10 +543,10 @@ gimp_new_rect_select_tool_execute (GimpRectangleTool *rectangle,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_new_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
||||
gimp_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (rectangle);
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (rectangle);
|
||||
|
||||
if (tool->display)
|
||||
{
|
||||
|
@ -558,17 +571,17 @@ gimp_new_rect_select_tool_cancel (GimpRectangleTool *rectangle)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
||||
gimp_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rectangle);
|
||||
|
||||
if (tool->display)
|
||||
{
|
||||
GimpNewRectSelectTool *rect_select = GIMP_NEW_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *undo;
|
||||
gint x1, y1, x2, y2;
|
||||
GimpRectSelectTool *rect_select = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionOptions *options;
|
||||
GimpImage *image = tool->display->image;
|
||||
GimpUndo *undo;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
/* if we got here via button release, we have already undone the
|
||||
* previous operation. But if we got here by some other means,
|
||||
|
@ -589,7 +602,7 @@ gimp_new_rect_select_tool_rectangle_changed (GimpRectangleTool *rectangle)
|
|||
"y2", &y2,
|
||||
NULL);
|
||||
|
||||
gimp_new_rect_select_tool_select (rectangle, x1, y1, x2 - x1, y2 - y1);
|
||||
gimp_rect_select_tool_select (rectangle, x1, y1, x2 - x1, y2 - y1);
|
||||
|
||||
/* save the undo that we got when executing */
|
||||
rect_select->undo = gimp_undo_stack_peek (image->undo_stack);
|
||||
|
|
|
@ -16,24 +16,24 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_NEW_RECT_SELECT_TOOL_H__
|
||||
#define __GIMP_NEW_RECT_SELECT_TOOL_H__
|
||||
#ifndef __GIMP_RECT_SELECT_TOOL_H__
|
||||
#define __GIMP_RECT_SELECT_TOOL_H__
|
||||
|
||||
#include "gimpselectiontool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_NEW_RECT_SELECT_TOOL (gimp_new_rect_select_tool_get_type ())
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectTool))
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
|
||||
#define GIMP_IS_NEW_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NEW_RECT_SELECT_TOOL))
|
||||
#define GIMP_NEW_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NEW_RECT_SELECT_TOOL, GimpNewRectSelectToolClass))
|
||||
#define GIMP_TYPE_RECT_SELECT_TOOL (gimp_rect_select_tool_get_type ())
|
||||
#define GIMP_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectTool))
|
||||
#define GIMP_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
|
||||
|
||||
typedef struct _GimpNewRectSelectTool GimpNewRectSelectTool;
|
||||
typedef struct _GimpNewRectSelectToolClass GimpNewRectSelectToolClass;
|
||||
typedef struct _GimpRectSelectTool GimpRectSelectTool;
|
||||
typedef struct _GimpRectSelectToolClass GimpRectSelectToolClass;
|
||||
|
||||
struct _GimpNewRectSelectTool
|
||||
struct _GimpRectSelectTool
|
||||
{
|
||||
GimpSelectionTool parent_instance;
|
||||
|
||||
|
@ -43,23 +43,23 @@ struct _GimpNewRectSelectTool
|
|||
GimpUndo *redo;
|
||||
};
|
||||
|
||||
struct _GimpNewRectSelectToolClass
|
||||
struct _GimpRectSelectToolClass
|
||||
{
|
||||
GimpSelectionToolClass parent_class;
|
||||
|
||||
void (* select) (GimpNewRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void (* select) (GimpRectSelectTool *rect_select,
|
||||
SelectOps operation,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
};
|
||||
|
||||
|
||||
void gimp_new_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
void gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data);
|
||||
|
||||
GType gimp_new_rect_select_tool_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_rect_select_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_NEW_RECT_SELECT_TOOL_H__ */
|
||||
#endif /* __GIMP_RECT_SELECT_TOOL_H__ */
|
||||
|
|
|
@ -883,7 +883,7 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
|
|||
"pressx", &pressx,
|
||||
"pressy", &pressy,
|
||||
NULL);
|
||||
if (private->lastx == pressx && private->lasty == pressy)
|
||||
if (gimp_rectangle_tool_no_movement (rectangle))
|
||||
{
|
||||
if (gimp_rectangle_tool_execute (rectangle))
|
||||
gimp_rectangle_tool_halt (rectangle);
|
||||
|
@ -2370,3 +2370,19 @@ gimp_rectangle_tool_notify_dimensions (GimpRectangleOptions *options,
|
|||
|
||||
g_signal_emit_by_name (rectangle, "rectangle-changed", NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_rectangle_tool_no_movement (GimpRectangleTool *rectangle)
|
||||
{
|
||||
gint pressx, pressy;
|
||||
GimpRectangleToolPrivate *private;
|
||||
|
||||
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rectangle);
|
||||
|
||||
g_object_get (rectangle,
|
||||
"pressx", &pressx,
|
||||
"pressy", &pressy,
|
||||
NULL);
|
||||
|
||||
return (private->lastx == pressx && private->lasty == pressy);
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ void gimp_rectangle_tool_halt (GimpRectangleTool *rectangl
|
|||
void gimp_rectangle_tool_configure (GimpRectangleTool *rectangle);
|
||||
void gimp_rectangle_tool_set_constrain (GimpRectangleTool *rectangle,
|
||||
gboolean constrain);
|
||||
gboolean gimp_rectangle_tool_no_movement (GimpRectangleTool *rectangle);
|
||||
|
||||
/* convenience functions */
|
||||
|
||||
|
|
|
@ -1,505 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpchannel-select.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-crop.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "gimprectselecttool.h"
|
||||
#include "gimpselectionoptions.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
static void gimp_rect_select_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display);
|
||||
|
||||
static void gimp_rect_select_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_rect_select_tool_real_rect_select (GimpRectSelectTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
static void gimp_rect_select_tool_update_options (GimpRectSelectTool *rect_sel,
|
||||
GimpDisplay *display);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpRectSelectTool, gimp_rect_select_tool,
|
||||
GIMP_TYPE_SELECTION_TOOL)
|
||||
|
||||
#define parent_class gimp_rect_select_tool_parent_class
|
||||
|
||||
|
||||
void
|
||||
gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_RECT_SELECT_TOOL,
|
||||
GIMP_TYPE_SELECTION_OPTIONS,
|
||||
gimp_selection_options_gui,
|
||||
0,
|
||||
"gimp-rect-select-tool",
|
||||
_("Rectangle Select"),
|
||||
_("Select rectangular regions"),
|
||||
N_("_Rectangle Select"), NULL,
|
||||
NULL, GIMP_HELP_TOOL_RECT_SELECT,
|
||||
GIMP_STOCK_TOOL_RECT_SELECT,
|
||||
data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_class_init (GimpRectSelectToolClass *klass)
|
||||
{
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
|
||||
tool_class->button_press = gimp_rect_select_tool_button_press;
|
||||
tool_class->button_release = gimp_rect_select_tool_button_release;
|
||||
tool_class->motion = gimp_rect_select_tool_motion;
|
||||
|
||||
draw_tool_class->draw = gimp_rect_select_tool_draw;
|
||||
|
||||
klass->rect_select = gimp_rect_select_tool_real_rect_select;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_init (GimpRectSelectTool *rect_select)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_select);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_TOOL_CURSOR_RECT_SELECT);
|
||||
|
||||
rect_select->sx = rect_select->sy = 0;
|
||||
rect_select->x = rect_select->y = 0;
|
||||
rect_select->w = rect_select->h = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionTool *sel_tool = GIMP_SELECTION_TOOL (tool);
|
||||
GimpSelectionOptions *options;
|
||||
GimpUnit unit = GIMP_UNIT_PIXEL;
|
||||
gdouble unit_factor;
|
||||
|
||||
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
rect_sel->sx = RINT(coords->x);
|
||||
rect_sel->sy = RINT(coords->y);
|
||||
rect_sel->x = 0;
|
||||
rect_sel->y = 0;
|
||||
rect_sel->w = 0;
|
||||
rect_sel->h = 0;
|
||||
rect_sel->lx = RINT(coords->x);
|
||||
rect_sel->ly = RINT(coords->y);
|
||||
rect_sel->center = FALSE;
|
||||
|
||||
rect_sel->fixed_mode = options->fixed_mode;
|
||||
rect_sel->fixed_width = options->fixed_width;
|
||||
rect_sel->fixed_height = options->fixed_height;
|
||||
unit = options->fixed_unit;
|
||||
|
||||
switch (unit)
|
||||
{
|
||||
case GIMP_UNIT_PIXEL:
|
||||
break;
|
||||
case GIMP_UNIT_PERCENT:
|
||||
rect_sel->fixed_width =
|
||||
display->image->width * rect_sel->fixed_width / 100;
|
||||
rect_sel->fixed_height =
|
||||
display->image->height * rect_sel->fixed_height / 100;
|
||||
break;
|
||||
default:
|
||||
unit_factor = _gimp_unit_get_factor (tool->tool_info->gimp, unit);
|
||||
rect_sel->fixed_width =
|
||||
rect_sel->fixed_width * display->image->xresolution / unit_factor;
|
||||
rect_sel->fixed_height =
|
||||
rect_sel->fixed_height * display->image->yresolution / unit_factor;
|
||||
break;
|
||||
}
|
||||
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
|
||||
|
||||
gimp_tool_control_activate (tool->control);
|
||||
tool->display = display;
|
||||
|
||||
if (gimp_selection_tool_start_edit (sel_tool, coords))
|
||||
return;
|
||||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (tool);
|
||||
|
||||
gimp_tool_pop_status (tool, display);
|
||||
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
gimp_tool_control_halt (tool->control);
|
||||
|
||||
/* First take care of the case where the user "cancels" the action */
|
||||
if (! (state & GDK_BUTTON3_MASK))
|
||||
{
|
||||
if (rect_sel->w == 0 || rect_sel->h == 0)
|
||||
{
|
||||
/* If there is a floating selection, anchor it */
|
||||
if (gimp_image_floating_sel (display->image))
|
||||
floating_sel_anchor (gimp_image_floating_sel (display->image));
|
||||
/* Otherwise, clear the selection mask */
|
||||
else
|
||||
gimp_channel_clear (gimp_image_get_mask (display->image), NULL,
|
||||
TRUE);
|
||||
|
||||
gimp_image_flush (display->image);
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_rect_select_tool_rect_select (rect_sel,
|
||||
rect_sel->x, rect_sel->y,
|
||||
rect_sel->w, rect_sel->h);
|
||||
|
||||
/* show selection on all views */
|
||||
gimp_image_flush (display->image);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (tool);
|
||||
GimpSelectionTool *sel_tool = GIMP_SELECTION_TOOL (tool);
|
||||
gint mx, my;
|
||||
gdouble ratio;
|
||||
|
||||
if (sel_tool->op == SELECTION_ANCHOR)
|
||||
{
|
||||
sel_tool->op = SELECTION_REPLACE;
|
||||
|
||||
gimp_tool_cursor_update (tool, coords, state, display);
|
||||
}
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
|
||||
if (state & GDK_MOD1_MASK)
|
||||
{
|
||||
/* Just move the selection rectangle around */
|
||||
|
||||
mx = RINT(coords->x) - rect_sel->lx;
|
||||
my = RINT(coords->y) - rect_sel->ly;
|
||||
|
||||
rect_sel->sx += mx;
|
||||
rect_sel->sy += my;
|
||||
rect_sel->x += mx;
|
||||
rect_sel->y += my;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Change the selection rectangle's size, first calculate absolute
|
||||
* width and height, then take care of quadrants.
|
||||
*/
|
||||
|
||||
if (rect_sel->fixed_mode == GIMP_RECT_SELECT_MODE_FIXED_SIZE)
|
||||
{
|
||||
rect_sel->w = RINT(rect_sel->fixed_width);
|
||||
rect_sel->h = RINT(rect_sel->fixed_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_sel->w = abs(RINT(coords->x) - rect_sel->sx);
|
||||
rect_sel->h = abs(RINT(coords->y) - rect_sel->sy);
|
||||
}
|
||||
|
||||
if (rect_sel->fixed_mode == GIMP_RECT_SELECT_MODE_FIXED_RATIO)
|
||||
{
|
||||
ratio = rect_sel->fixed_height / rect_sel->fixed_width;
|
||||
if ( ( (gdouble) rect_sel->h) / ( (gdouble) rect_sel->w ) > ratio)
|
||||
{
|
||||
rect_sel->w = RINT(rect_sel->h / ratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_sel->h = RINT(rect_sel->w * ratio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If the shift key is down, then make the rectangle square (or
|
||||
* ellipse circular)
|
||||
*/
|
||||
if ((state & GDK_SHIFT_MASK) &&
|
||||
rect_sel->fixed_mode == GIMP_RECT_SELECT_MODE_FREE)
|
||||
{
|
||||
if (rect_sel->w > rect_sel->h)
|
||||
{
|
||||
rect_sel->h = rect_sel->w;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_sel->w = rect_sel->h;
|
||||
}
|
||||
}
|
||||
|
||||
if (state & GDK_CONTROL_MASK)
|
||||
{
|
||||
/* If the control key is down, create the selection from the center out */
|
||||
if (rect_sel->fixed_mode == GIMP_RECT_SELECT_MODE_FIXED_SIZE)
|
||||
{
|
||||
/* Fixed size selection is simply centered over start point */
|
||||
rect_sel->x = RINT(rect_sel->sx - rect_sel->w / 2.0);
|
||||
rect_sel->y = RINT(rect_sel->sy - rect_sel->h / 2.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Non-fixed size is mirrored over starting point */
|
||||
rect_sel->x = rect_sel->sx - rect_sel->w;
|
||||
rect_sel->y = rect_sel->sy - rect_sel->h;
|
||||
rect_sel->w = rect_sel->w * 2;
|
||||
rect_sel->h = rect_sel->h * 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make (rect->x, rect->y) upper left hand point of selection */
|
||||
if (coords->x > rect_sel->sx)
|
||||
{
|
||||
rect_sel->x = rect_sel->sx;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_sel->x = rect_sel->sx - rect_sel->w;
|
||||
}
|
||||
if (coords->y > rect_sel->sy)
|
||||
{
|
||||
rect_sel->y = rect_sel->sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect_sel->y = rect_sel->sy - rect_sel->h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rect_sel->lx = RINT(coords->x);
|
||||
rect_sel->ly = RINT(coords->y);
|
||||
|
||||
gimp_rect_select_tool_update_options (rect_sel, display);
|
||||
|
||||
gimp_tool_pop_status (tool, display);
|
||||
gimp_tool_push_status_coords (tool, display,
|
||||
_("Selection: "),
|
||||
rect_sel->w, " × ", rect_sel->h);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
||||
|
||||
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||
FALSE,
|
||||
rect_sel->x, rect_sel->y,
|
||||
rect_sel->w, rect_sel->h,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_real_rect_select (GimpRectSelectTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpSelectionTool *sel_tool = GIMP_SELECTION_TOOL (rect_tool);
|
||||
GimpSelectionOptions *options;
|
||||
|
||||
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
gimp_channel_select_rectangle (gimp_image_get_mask (tool->display->image),
|
||||
x, y, w, h,
|
||||
sel_tool->op,
|
||||
options->feather,
|
||||
options->feather_radius,
|
||||
options->feather_radius);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpSelectionOptions *options;
|
||||
|
||||
g_return_if_fail (GIMP_IS_RECT_SELECT_TOOL (rect_tool));
|
||||
|
||||
tool = GIMP_TOOL (rect_tool);
|
||||
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
if (options->auto_shrink)
|
||||
{
|
||||
gint off_x = 0;
|
||||
gint off_y = 0;
|
||||
gint x2, y2;
|
||||
|
||||
if (! gimp_rectangle_intersect (x, y, w, h,
|
||||
0, 0,
|
||||
tool->display->image->width,
|
||||
tool->display->image->height,
|
||||
&x, &y, &w, &h))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (! options->shrink_merged)
|
||||
{
|
||||
GimpItem *item;
|
||||
gint width, height;
|
||||
|
||||
item = GIMP_ITEM (gimp_image_active_drawable (tool->display->image));
|
||||
|
||||
gimp_item_offsets (item, &off_x, &off_y);
|
||||
width = gimp_item_width (item);
|
||||
height = gimp_item_height (item);
|
||||
|
||||
if (! gimp_rectangle_intersect (x, y, w, h,
|
||||
off_x, off_y, width, height,
|
||||
&x, &y, &w, &h))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
x -= off_x;
|
||||
y -= off_y;
|
||||
}
|
||||
|
||||
if (gimp_image_crop_auto_shrink (tool->display->image,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
! options->shrink_merged,
|
||||
&x, &y,
|
||||
&x2, &y2))
|
||||
{
|
||||
w = x2 - x;
|
||||
h = y2 - y;
|
||||
}
|
||||
|
||||
x += off_x;
|
||||
y += off_y;
|
||||
}
|
||||
|
||||
GIMP_RECT_SELECT_TOOL_GET_CLASS (rect_tool)->rect_select (rect_tool,
|
||||
x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rect_select_tool_update_options (GimpRectSelectTool *rect_sel,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
gdouble width;
|
||||
gdouble height;
|
||||
|
||||
if (rect_sel->fixed_mode != GIMP_RECT_SELECT_MODE_FREE)
|
||||
return;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (display->shell);
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
{
|
||||
width = rect_sel->w;
|
||||
height = rect_sel->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpImage *image = display->image;
|
||||
|
||||
width = (rect_sel->w *
|
||||
_gimp_unit_get_factor (image->gimp,
|
||||
shell->unit) / image->xresolution);
|
||||
height = (rect_sel->h *
|
||||
_gimp_unit_get_factor (image->gimp,
|
||||
shell->unit) / image->yresolution);
|
||||
}
|
||||
|
||||
g_object_set (GIMP_TOOL (rect_sel)->tool_info->tool_options,
|
||||
"fixed-width", width,
|
||||
"fixed-height", height,
|
||||
"fixed-unit", shell->unit,
|
||||
NULL);
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_RECT_SELECT_TOOL_H__
|
||||
#define __GIMP_RECT_SELECT_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpselectiontool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_RECT_SELECT_TOOL (gimp_rect_select_tool_get_type ())
|
||||
#define GIMP_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectTool))
|
||||
#define GIMP_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_IS_RECT_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_RECT_SELECT_TOOL))
|
||||
#define GIMP_RECT_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_RECT_SELECT_TOOL, GimpRectSelectToolClass))
|
||||
|
||||
|
||||
typedef struct _GimpRectSelectTool GimpRectSelectTool;
|
||||
typedef struct _GimpRectSelectToolClass GimpRectSelectToolClass;
|
||||
|
||||
struct _GimpRectSelectTool
|
||||
{
|
||||
GimpSelectionTool parent_instance;
|
||||
|
||||
gint sx, sy; /* start coordinate where the button is
|
||||
* first pressed */
|
||||
gint x, y; /* upper left coordinate of selection */
|
||||
gint w, h; /* width, height of selection always >=0 */
|
||||
gint lx, ly; /* last coordinate of mouse cursor */
|
||||
gboolean center; /* is the selection being created from the
|
||||
* center out? */
|
||||
GimpRectSelectMode fixed_mode;
|
||||
gdouble fixed_width;
|
||||
gdouble fixed_height;
|
||||
};
|
||||
|
||||
struct _GimpRectSelectToolClass
|
||||
{
|
||||
GimpSelectionToolClass parent_class;
|
||||
|
||||
/* virtual function */
|
||||
|
||||
void (* rect_select) (GimpRectSelectTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
};
|
||||
|
||||
|
||||
void gimp_rect_select_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data);
|
||||
|
||||
GType gimp_rect_select_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_rect_select_tool_rect_select (GimpRectSelectTool *rect_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
#endif /* __GIMP_RECT_SELECT_TOOL_H__ */
|
|
@ -37,7 +37,6 @@
|
|||
#include "gimpellipseselecttool.h"
|
||||
#include "gimpforegroundselecttool.h"
|
||||
#include "gimpnewrectselecttool.h"
|
||||
#include "gimprectselecttool.h"
|
||||
#include "gimpfuzzyselecttool.h"
|
||||
#include "gimpiscissorstool.h"
|
||||
#include "gimpselectionoptions.h"
|
||||
|
@ -77,10 +76,6 @@ static void gimp_selection_options_get_property (GObject *object,
|
|||
|
||||
static void gimp_selection_options_reset (GimpToolOptions *tool_options);
|
||||
|
||||
static void selection_options_fixed_mode_notify (GimpSelectionOptions *options,
|
||||
GParamSpec *pspec,
|
||||
GtkWidget *fixed_box);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSelectionOptions, gimp_selection_options,
|
||||
GIMP_TYPE_TOOL_OPTIONS)
|
||||
|
@ -414,8 +409,7 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL ||
|
||||
tool_options->tool_info->tool_type == GIMP_TYPE_NEW_RECT_SELECT_TOOL ||
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL ||
|
||||
tool_options->tool_info->tool_type == GIMP_TYPE_FOREGROUND_SELECT_TOOL)
|
||||
{
|
||||
gtk_widget_set_sensitive (button, FALSE);
|
||||
|
@ -505,16 +499,10 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
|
|||
|
||||
/* widgets for fixed size select */
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL ||
|
||||
tool_options->tool_info->tool_type == GIMP_TYPE_NEW_RECT_SELECT_TOOL ||
|
||||
tool_options->tool_info->tool_type == GIMP_TYPE_ELLIPSE_SELECT_TOOL)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *table;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *width_spinbutton;
|
||||
GtkWidget *height_spinbutton;
|
||||
|
||||
frame = gimp_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
|
@ -539,67 +527,8 @@ gimp_selection_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL)
|
||||
{
|
||||
frame = gimp_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
combo = gimp_prop_enum_combo_box_new (config, "fixed-mode", 0, 0);
|
||||
gtk_frame_set_label_widget (GTK_FRAME (frame), combo);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
table = gtk_table_new (2, 3, FALSE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
||||
gtk_container_add (GTK_CONTAINER (frame), table);
|
||||
|
||||
gtk_widget_set_sensitive (table,
|
||||
options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE);
|
||||
g_signal_connect (config, "notify::fixed-mode",
|
||||
G_CALLBACK (selection_options_fixed_mode_notify),
|
||||
table);
|
||||
|
||||
width_spinbutton = gimp_prop_spin_button_new (config, "fixed-width",
|
||||
1.0, 50.0, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (width_spinbutton), 6);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("Width:"), 0.0, 0.5,
|
||||
width_spinbutton, 1, FALSE);
|
||||
|
||||
height_spinbutton = gimp_prop_spin_button_new (config, "fixed-height",
|
||||
1.0, 50.0, 0);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (height_spinbutton), 6);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||
_("Height:"), 0.0, 0.5,
|
||||
height_spinbutton, 1, FALSE);
|
||||
|
||||
menu = gimp_prop_unit_menu_new (config, "fixed-unit", "%a");
|
||||
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (menu);
|
||||
|
||||
g_object_set_data (G_OBJECT (menu), "set_digits", width_spinbutton);
|
||||
g_object_set_data (G_OBJECT (width_spinbutton), "set_digits",
|
||||
height_spinbutton);
|
||||
gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0);
|
||||
|
||||
gtk_widget_show (table);
|
||||
}
|
||||
}
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
selection_options_fixed_mode_notify (GimpSelectionOptions *options,
|
||||
GParamSpec *pspec,
|
||||
GtkWidget *fixed_box)
|
||||
{
|
||||
gtk_widget_set_sensitive (fixed_box,
|
||||
options->fixed_mode != GIMP_RECT_SELECT_MODE_FREE);
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
|
|||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimp->tool_info_list,
|
||||
"gimp-new-rect-select-tool");
|
||||
"gimp-rect-select-tool");
|
||||
tool_button = g_object_get_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY);
|
||||
|
||||
if (tool_button)
|
||||
|
@ -503,7 +503,7 @@ gimp_toolbox_set_geometry (GimpToolbox *toolbox)
|
|||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimp->tool_info_list,
|
||||
"gimp-new-rect-select-tool");
|
||||
"gimp-rect-select-tool");
|
||||
tool_button = g_object_get_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY);
|
||||
|
||||
if (tool_button)
|
||||
|
|
|
@ -477,7 +477,7 @@
|
|||
|
||||
<menu action="tools-menu" name="Tools">
|
||||
<menu action="tools-select-menu" name="Selection Tools">
|
||||
<menuitem action="tools-new-rect-select" />
|
||||
<menuitem action="tools-rect-select" />
|
||||
<menuitem action="tools-ellipse-select" />
|
||||
<menuitem action="tools-free-select" />
|
||||
<menuitem action="tools-foreground-select" />
|
||||
|
|
Loading…
Reference in a new issue