mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
app: add a pivot selector to the Rotate tool
Add a GimpPivotSelector widget to the Rotate tool dialog, to allow for quickly picking a pivot.
This commit is contained in:
parent
46e01d37db
commit
c0552de62b
3 changed files with 48 additions and 2 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "core/gimpimage.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimppivotselector.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
@ -53,7 +54,7 @@ enum
|
|||
};
|
||||
|
||||
|
||||
#define SB_WIDTH 10
|
||||
#define SB_WIDTH 8
|
||||
#define EPSILON 1e-6
|
||||
|
||||
|
||||
|
@ -80,6 +81,8 @@ static void rotate_angle_changed (GtkAdjustment *
|
|||
GimpTransformGridTool *tg_tool);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
static void rotate_pivot_changed (GimpPivotSelector *selector,
|
||||
GimpTransformGridTool *tg_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpRotateTool, gimp_rotate_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
||||
|
@ -288,7 +291,7 @@ gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, rotate->angle_adj);
|
||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||
gtk_widget_set_hexpand (scale, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), scale, 1, 1, 1, 1);
|
||||
gtk_grid_attach (GTK_GRID (grid), scale, 1, 1, 2, 1);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
adj = gtk_adjustment_new (0, -1, 1, 1, 10, 0);
|
||||
|
@ -312,6 +315,14 @@ gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
g_signal_connect (rotate->sizeentry, "value-changed",
|
||||
G_CALLBACK (rotate_center_changed),
|
||||
tg_tool);
|
||||
|
||||
rotate->pivot_selector = gimp_pivot_selector_new (0.0, 0.0, 0.0, 0.0);
|
||||
gtk_grid_attach (GTK_GRID (grid), rotate->pivot_selector, 2, 2, 1, 2);
|
||||
gtk_widget_show (rotate->pivot_selector);
|
||||
|
||||
g_signal_connect (rotate->pivot_selector, "changed",
|
||||
G_CALLBACK (rotate_pivot_changed),
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -334,6 +345,19 @@ gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
|||
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tg_tool);
|
||||
|
||||
g_signal_handlers_block_by_func (rotate->pivot_selector,
|
||||
rotate_pivot_changed,
|
||||
tg_tool);
|
||||
|
||||
gimp_pivot_selector_set_position (
|
||||
GIMP_PIVOT_SELECTOR (rotate->pivot_selector),
|
||||
tg_tool->trans_info[PIVOT_X],
|
||||
tg_tool->trans_info[PIVOT_Y]);
|
||||
|
||||
g_signal_handlers_unblock_by_func (rotate->pivot_selector,
|
||||
rotate_pivot_changed,
|
||||
tg_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -381,6 +405,10 @@ gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool)
|
|||
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
||||
rotate_center_changed,
|
||||
tg_tool);
|
||||
|
||||
gimp_pivot_selector_set_bounds (GIMP_PIVOT_SELECTOR (rotate->pivot_selector),
|
||||
tr_tool->x1, tr_tool->y1,
|
||||
tr_tool->x2, tr_tool->y2);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -491,3 +519,19 @@ rotate_center_changed (GtkWidget *widget,
|
|||
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_pivot_changed (GimpPivotSelector *selector,
|
||||
GimpTransformGridTool *tg_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (tg_tool);
|
||||
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
||||
|
||||
gimp_pivot_selector_get_position (selector,
|
||||
&tg_tool->trans_info[PIVOT_X],
|
||||
&tg_tool->trans_info[PIVOT_Y]);
|
||||
|
||||
gimp_transform_grid_tool_push_internal_undo (tg_tool, TRUE);
|
||||
|
||||
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GimpRotateTool
|
|||
GtkAdjustment *angle_adj;
|
||||
GtkWidget *angle_spin_button;
|
||||
GtkWidget *sizeentry;
|
||||
GtkWidget *pivot_selector;
|
||||
};
|
||||
|
||||
struct _GimpRotateToolClass
|
||||
|
|
|
@ -155,6 +155,7 @@ libappwidgets_sources = [
|
|||
'gimppdbdialog.c',
|
||||
'gimppickablebutton.c',
|
||||
'gimppickablepopup.c',
|
||||
'gimppivotselector.c',
|
||||
'gimppixbuf.c',
|
||||
'gimppluginview.c',
|
||||
'gimppolar.c',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue