tools: fix on-canvas text editor position on screen after being moved
After the on-canvas text editor has been moved, it should remain fixed on the screen when zooming or panning the canvas. This commit preserves the current behavior when the editor is in its original position, and fixes its position on-screen after it has been moved.
This commit is contained in:
parent
dae8472d58
commit
bd6fc8594a
4 changed files with 44 additions and 15 deletions
|
|
@ -43,6 +43,7 @@
|
|||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimpdockcontainer.h"
|
||||
#include "widgets/gimpoverlaybox.h"
|
||||
#include "widgets/gimpoverlaychild.h"
|
||||
#include "widgets/gimpoverlayframe.h"
|
||||
#include "widgets/gimptextbuffer.h"
|
||||
#include "widgets/gimptexteditor.h"
|
||||
|
|
@ -1960,9 +1961,12 @@ gimp_text_tool_style_overlay_button_press (GtkWidget *widget,
|
|||
GdkEventButton *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (user_data);
|
||||
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
||||
GimpTextStyleEditor *editor = GIMP_TEXT_STYLE_EDITOR (text_tool->style_editor);
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (user_data);
|
||||
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
||||
GimpTextStyleEditor *editor = GIMP_TEXT_STYLE_EDITOR (text_tool->style_editor);
|
||||
GimpTool *tool = GIMP_TOOL (text_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpOverlayChild *child_overlay = NULL;
|
||||
|
||||
if (event_widget != GTK_WIDGET (editor->dnd_handle) &&
|
||||
gtk_widget_is_ancestor (event_widget, GTK_WIDGET (text_tool->style_editor)))
|
||||
|
|
@ -1986,6 +1990,10 @@ gimp_text_tool_style_overlay_button_press (GtkWidget *widget,
|
|||
text_tool->drag_offset_x = event->x;
|
||||
text_tool->drag_offset_y = event->y;
|
||||
|
||||
child_overlay = gimp_overlay_child_find (GIMP_OVERLAY_BOX (shell->canvas),
|
||||
text_tool->style_overlay);
|
||||
gimp_overlay_child_set_relative_to_shell (child_overlay, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1994,9 +2002,12 @@ gimp_text_tool_style_overlay_button_release (GtkWidget *widget,
|
|||
GdkEventButton *event,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (user_data);
|
||||
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
||||
GimpTextStyleEditor *editor = GIMP_TEXT_STYLE_EDITOR (text_tool->style_editor);
|
||||
GimpTextTool *text_tool = GIMP_TEXT_TOOL (user_data);
|
||||
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
||||
GimpTextStyleEditor *editor = GIMP_TEXT_STYLE_EDITOR (text_tool->style_editor);
|
||||
GimpTool *tool = GIMP_TOOL (text_tool);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
||||
GimpOverlayChild *child_overlay = NULL;
|
||||
|
||||
if (event_widget != GTK_WIDGET (editor->dnd_handle) &&
|
||||
gtk_widget_is_ancestor (event_widget, GTK_WIDGET (text_tool->style_editor)))
|
||||
|
|
@ -2006,6 +2017,10 @@ gimp_text_tool_style_overlay_button_release (GtkWidget *widget,
|
|||
|
||||
text_tool->overlay_dragging = FALSE;
|
||||
|
||||
child_overlay = gimp_overlay_child_find (GIMP_OVERLAY_BOX (shell->canvas),
|
||||
text_tool->style_overlay);
|
||||
gimp_overlay_child_set_relative_to_shell (child_overlay, TRUE);
|
||||
|
||||
if (gtk_widget_get_window (GTK_WIDGET (text_tool->style_overlay)))
|
||||
gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (text_tool->style_overlay)), NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ gimp_overlay_box_set_child_position (GimpOverlayBox *box,
|
|||
{
|
||||
GimpOverlayChild *child = gimp_overlay_child_find (box, widget);
|
||||
|
||||
if (child)
|
||||
if (child && ! child->relative_to_shell)
|
||||
{
|
||||
if (! child->has_position ||
|
||||
child->x != x ||
|
||||
|
|
|
|||
|
|
@ -70,14 +70,15 @@ gimp_overlay_child_new (GimpOverlayBox *box,
|
|||
|
||||
child = g_slice_new0 (GimpOverlayChild);
|
||||
|
||||
child->widget = widget;
|
||||
child->xalign = CLAMP (xalign, 0.0, 1.0);
|
||||
child->yalign = CLAMP (yalign, 0.0, 1.0);
|
||||
child->x = 0.0;
|
||||
child->y = 0.0;
|
||||
child->has_position = FALSE;
|
||||
child->angle = angle;
|
||||
child->opacity = CLAMP (opacity, 0.0, 1.0);
|
||||
child->widget = widget;
|
||||
child->xalign = CLAMP (xalign, 0.0, 1.0);
|
||||
child->yalign = CLAMP (yalign, 0.0, 1.0);
|
||||
child->x = 0.0;
|
||||
child->y = 0.0;
|
||||
child->relative_to_shell = FALSE;
|
||||
child->has_position = FALSE;
|
||||
child->angle = angle;
|
||||
child->opacity = CLAMP (opacity, 0.0, 1.0);
|
||||
|
||||
cairo_matrix_init_identity (&child->matrix);
|
||||
|
||||
|
|
@ -509,6 +510,16 @@ gimp_overlay_child_pick (GimpOverlayBox *box,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_overlay_child_set_relative_to_shell (GimpOverlayChild *child,
|
||||
gboolean relative_to_shell)
|
||||
{
|
||||
g_return_if_fail (child != NULL);
|
||||
|
||||
child->relative_to_shell = relative_to_shell;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct _GimpOverlayChild
|
|||
GtkWidget *widget;
|
||||
GdkWindow *window;
|
||||
|
||||
gboolean relative_to_shell;
|
||||
gboolean has_position;
|
||||
gdouble xalign;
|
||||
gdouble yalign;
|
||||
|
|
@ -81,3 +82,5 @@ gboolean gimp_overlay_child_pick (GimpOverlayBox *bo
|
|||
GimpOverlayChild *child,
|
||||
gdouble box_x,
|
||||
gdouble box_y);
|
||||
void gimp_overlay_child_set_relative_to_shell (GimpOverlayChild *child,
|
||||
gboolean relative_to_shell);
|
||||
|
|
|
|||
Loading…
Reference in a new issue