app: allow to position overlay widgets absolutely
This commit is contained in:
@ -363,7 +363,7 @@ gimp_overlay_box_add_child (GimpOverlayBox *box,
|
||||
}
|
||||
|
||||
void
|
||||
gimp_overlay_box_set_child_packing (GimpOverlayBox *box,
|
||||
gimp_overlay_box_set_child_alignment (GimpOverlayBox *box,
|
||||
GtkWidget *widget,
|
||||
gdouble xalign,
|
||||
gdouble yalign)
|
||||
@ -375,11 +375,13 @@ gimp_overlay_box_set_child_packing (GimpOverlayBox *box,
|
||||
xalign = CLAMP (xalign, 0.0, 1.0);
|
||||
yalign = CLAMP (yalign, 0.0, 1.0);
|
||||
|
||||
if (child->xalign != xalign ||
|
||||
if (child->has_position ||
|
||||
child->xalign != xalign ||
|
||||
child->yalign != yalign)
|
||||
{
|
||||
gimp_overlay_child_invalidate (box, child);
|
||||
|
||||
child->has_position = FALSE;
|
||||
child->xalign = xalign;
|
||||
child->yalign = yalign;
|
||||
|
||||
@ -388,6 +390,31 @@ gimp_overlay_box_set_child_packing (GimpOverlayBox *box,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_overlay_box_set_child_position (GimpOverlayBox *box,
|
||||
GtkWidget *widget,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
GimpOverlayChild *child = gimp_overlay_child_find (box, widget);
|
||||
|
||||
if (child)
|
||||
{
|
||||
if (! child->has_position ||
|
||||
child->x != x ||
|
||||
child->y != y)
|
||||
{
|
||||
gimp_overlay_child_invalidate (box, child);
|
||||
|
||||
child->has_position = TRUE;
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_overlay_box_set_child_angle (GimpOverlayBox *box,
|
||||
GtkWidget *widget,
|
||||
@ -453,13 +480,21 @@ gimp_overlay_box_scroll (GimpOverlayBox *box,
|
||||
|
||||
/* Undraw all overlays */
|
||||
for (list = box->children; list; list = g_list_next (list))
|
||||
gimp_overlay_child_invalidate (box, list->data);
|
||||
{
|
||||
GimpOverlayChild *child = list->data;
|
||||
|
||||
gimp_overlay_child_invalidate (box, child);
|
||||
}
|
||||
|
||||
gdk_window_scroll (window, offset_x, offset_y);
|
||||
|
||||
/* Re-draw all overlays */
|
||||
for (list = box->children; list; list = g_list_next (list))
|
||||
gimp_overlay_child_invalidate (box, list->data);
|
||||
{
|
||||
GimpOverlayChild *child = list->data;
|
||||
|
||||
gimp_overlay_child_invalidate (box, child);
|
||||
}
|
||||
|
||||
/* Make sure expose events are processed before scrolling again */
|
||||
gdk_window_process_updates (window, FALSE);
|
||||
|
@ -49,22 +49,26 @@ GType gimp_overlay_box_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_overlay_box_new (void);
|
||||
|
||||
void gimp_overlay_box_add_child (GimpOverlayBox *canvas,
|
||||
void gimp_overlay_box_add_child (GimpOverlayBox *box,
|
||||
GtkWidget *child,
|
||||
gdouble xalign,
|
||||
gdouble yalign);
|
||||
void gimp_overlay_box_set_child_packing (GimpOverlayBox *canvas,
|
||||
void gimp_overlay_box_set_child_alignment (GimpOverlayBox *box,
|
||||
GtkWidget *child,
|
||||
gdouble xalign,
|
||||
gdouble yalign);
|
||||
void gimp_overlay_box_set_child_angle (GimpOverlayBox *canvas,
|
||||
void gimp_overlay_box_set_child_position (GimpOverlayBox *box,
|
||||
GtkWidget *child,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_overlay_box_set_child_angle (GimpOverlayBox *box,
|
||||
GtkWidget *child,
|
||||
gdouble angle);
|
||||
void gimp_overlay_box_set_child_opacity (GimpOverlayBox *canvas,
|
||||
void gimp_overlay_box_set_child_opacity (GimpOverlayBox *box,
|
||||
GtkWidget *child,
|
||||
gdouble opacity);
|
||||
|
||||
void gimp_overlay_box_scroll (GimpOverlayBox *canvas,
|
||||
void gimp_overlay_box_scroll (GimpOverlayBox *box,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
||||
|
@ -72,6 +72,9 @@ gimp_overlay_child_new (GimpOverlayBox *box,
|
||||
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);
|
||||
|
||||
@ -271,6 +274,13 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,
|
||||
available_width = allocation.width - 2 * border;
|
||||
available_height = allocation.height - 2 * border;
|
||||
|
||||
if (child->has_position)
|
||||
{
|
||||
x = child->x;
|
||||
y = child->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = border;
|
||||
y = border;
|
||||
|
||||
@ -279,6 +289,7 @@ gimp_overlay_child_size_allocate (GimpOverlayBox *box,
|
||||
|
||||
if (available_height > bounds.height)
|
||||
y += child->yalign * (available_height - bounds.height) - bounds.y;
|
||||
}
|
||||
|
||||
cairo_matrix_init_translate (&child->matrix, x, y);
|
||||
|
||||
|
@ -29,8 +29,13 @@ struct _GimpOverlayChild
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkWindow *window;
|
||||
|
||||
gboolean has_position;
|
||||
gdouble xalign;
|
||||
gdouble yalign;
|
||||
gdouble x;
|
||||
gdouble y;
|
||||
|
||||
gdouble angle;
|
||||
gdouble opacity;
|
||||
|
||||
|
Reference in New Issue
Block a user